From dd383f47508d4fb214f146e37dd63fbae9f7e7dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Th=C3=A9ate?= <97221392+antoineatrhea@users.noreply.github.com> Date: Wed, 16 Aug 2023 11:08:49 +0200 Subject: [PATCH] Fix #420: Downloaded source codes for BabylonJS (#423) --- COMETwebapp/wwwroot/Scripts/BabylonJS/babylon.js | 2 ++ .../wwwroot/Scripts/BabylonJS/babylonjs.loaders.min.js | 2 ++ COMETwebapp/wwwroot/index.html | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 COMETwebapp/wwwroot/Scripts/BabylonJS/babylon.js create mode 100644 COMETwebapp/wwwroot/Scripts/BabylonJS/babylonjs.loaders.min.js diff --git a/COMETwebapp/wwwroot/Scripts/BabylonJS/babylon.js b/COMETwebapp/wwwroot/Scripts/BabylonJS/babylon.js new file mode 100644 index 00000000..462077b5 --- /dev/null +++ b/COMETwebapp/wwwroot/Scripts/BabylonJS/babylon.js @@ -0,0 +1,2 @@ +!function (e, t) { "object" == typeof exports && "object" == typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define("babylonjs", [], t) : "object" == typeof exports ? exports.babylonjs = t() : e.BABYLON = t() }("undefined" != typeof self ? self : "undefined" != typeof global ? global : this, (() => (() => { "use strict"; var e = { d: (t, i) => { for (var r in i) e.o(i, r) && !e.o(t, r) && Object.defineProperty(t, r, { enumerable: !0, get: i[r] }) } }; e.g = function () { if ("object" == typeof globalThis) return globalThis; try { return this || new Function("return this")() } catch (e) { if ("object" == typeof window) return window } }(), e.o = (e, t) => Object.prototype.hasOwnProperty.call(e, t), e.r = e => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e, "__esModule", { value: !0 }) }; var t = {}; e.d(t, { default: () => lC }); var i = {}; e.r(i), e.d(i, { AxesViewer: () => du, BoneAxesViewer: () => pu, DebugLayer: () => fu, DebugLayerTab: () => cu, DirectionalLightFrustumViewer: () => kh, PhysicsViewer: () => Bh, RayHelper: () => Uh, SkeletonViewer: () => Vh }); var r = {}; e.r(r), e.d(r, { AbstractActionManager: () => s, AbstractAssetTask: () => Yx, AbstractMesh: () => Ln, AbstractScene: () => o, AcquireNativeObjectAsync: () => Ud, Action: () => k, ActionEvent: () => G, ActionManager: () => de, AddBlock: () => Kv, AddressMode: () => $d, AdvancedTimer: () => Am, AlignBlock: () => qT, AlphaState: () => zt, AmmoJSPlugin: () => _g, AnaglyphArcRotateCamera: () => Pl, AnaglyphFreeCamera: () => Il, AnaglyphGamepadCamera: () => Ml, AnaglyphPostProcess: () => Rl, AnaglyphUniversalCamera: () => Ol, Analyser: () => no, AndOrNotEvaluator: () => _e, Angle: () => Or, Animatable: () => Cr, AnimatedInputBlockTypes: () => _a, Animation: () => je, AnimationAssetTask: () => Zx, AnimationEvent: () => Qr, AnimationGroup: () => Zr, AnimationKeyInterpolation: () => Be, AnimationPropertiesOverride: () => Ir, AnimationRange: () => ke, AnisotropyBlock: () => Ly, ApplyPostProcess: () => ad, Arc2: () => Dr, ArcFollowCamera: () => hl, ArcRotateCamera: () => nl, ArcRotateCameraGamepadInput: () => Ns, ArcRotateCameraInputsManager: () => Bs, ArcRotateCameraKeyboardMoveInput: () => Fs, ArcRotateCameraMouseWheelInput: () => Ls, ArcRotateCameraPointersInput: () => ws, ArcRotateCameraVRDeviceOrientationInput: () => Us, ArcTan2Block: () => gy, AssetContainer: () => ro, AssetTaskState: () => Hx, AssetsManager: () => oA, AssetsProgressEvent: () => Kx, AsyncLoop: () => Ri, AttachToBoxBehavior: () => Po, AudioEngine: () => oo, AudioSceneComponent: () => lo, AutoLayoutMode: () => up, AutoReleaseWorkerPool: () => Z_, AutoRotationBehavior: () => xo, AxesViewer: () => du, Axis: () => Ar, AxisDragGizmo: () => hu, AxisScaleGizmo: () => Kf, BRDFTextureTools: () => y_, BabylonFileLoaderConfiguration: () => vg, BackEase: () => Ur, BackgroundMaterial: () => p_, BakedVertexAnimationManager: () => uo, BallAndSocketConstraint: () => ZE, BaseCameraMouseWheelInput: () => Rs, BaseCameraPointersInput: () => Cs, BaseError: () => ct, BaseParticleSystem: () => Ha, BaseSixDofDragBehavior: () => Uo, BaseTexture: () => po, BasisTools: () => lv, BasisToolsOptions: () => ev, BasisTranscodeConfiguration: () => $g, BezierCurve: () => Mr, BezierCurveEase: () => Kr, BiPlanarBlock: () => Zy, BinaryFileAssetTask: () => $x, BlackAndWhitePostProcess: () => SS, BlendFactor: () => _p, BlendOperation: () => mp, BloomEffect: () => CS, BloomMergePostProcess: () => RS, BlurPostProcess: () => c_, Bone: () => Rr, BoneAxesViewer: () => pu, BoneIKController: () => Es, BoneLookController: () => Ss, BonesBlock: () => Tv, BounceEase: () => Vr, BouncingBehavior: () => Ao, BoundingBox: () => un, BoundingBoxGizmo: () => Qf, BoundingBoxRenderer: () => px, BoundingInfo: () => mn, BoundingSphere: () => hn, BoxBlock: () => dT, BoxBuilder: () => vu, BoxParticleEmitter: () => Fa, Buffer: () => Wi, BufferBindingType: () => np, BufferMapState: () => Xd, BufferUsage: () => jd, CSG: () => wb, Camera: () => ln, CameraGizmo: () => l_, CameraInputTypes: () => Ps, CameraInputsManager: () => Is, CannonJSPlugin: () => pg, CanvasAlphaMode: () => Rp, CapsuleBlock: () => ET, CapsuleBuilder: () => xu, CascadedShadowGenerator: () => eg, ChromaticAberrationPostProcess: () => PS, CircleEase: () => Br, CircleOfConfusionPostProcess: () => IS, ClampBlock: () => qv, ClearCoatBlock: () => By, ClipPlanesBlock: () => Xv, ClipboardEventTypes: () => Uf, ClipboardInfo: () => Vf, CloudBlock: () => Yy, CloudPoint: () => CE, Collider: () => Jc, Color3: () => B, Color3Gradient: () => dE, Color4: () => U, ColorCorrectionPostProcess: () => MS, ColorCurves: () => Oi, ColorGradient: () => hE, ColorGradingTexture: () => Dg, ColorMergerBlock: () => ty, ColorSplitterBlock: () => Xa, ColorWriteFlags: () => fp, CombineAction: () => se, CompareFunction: () => ip, CompatibilityOptions: () => xn, CompilationMessageType: () => lp, CompleteGreasedLineColorTable: () => oT, CompleteGreasedLineWidthTable: () => nT, ComputeBindingType: () => eu, ComputeEffect: () => tu, ComputeNormalsBlock: () => VT, ComputePassTimestampLocation: () => Tp, ComputeShader: () => iu, ComputeShaderParticleSystem: () => cE, Condition: () => Q, ConditionBlock: () => FT, ConditionBlockTests: () => DT, ConditionalBlock: () => jy, ConditionalBlockConditions: () => Hy, ConeParticleEmitter: () => La, Constants: () => a, ContainerAssetTask: () => Qx, ConversionMode: () => Dx, ConvolutionPostProcess: () => OS, Coordinate: () => xr, CopyTextureToTexture: () => Lx, CopyTools: () => go, CreateBox: () => gu, CreateBoxVertexData: () => _u, CreateCapsule: () => Su, CreateCapsuleVertexData: () => Eu, CreateCylinder: () => Dc, CreateCylinderVertexData: () => Oc, CreateDashedLines: () => Ku, CreateDashedLinesVertexData: () => Xu, CreateDecal: () => Eh, CreateDisc: () => Iu, CreateDiscVertexData: () => Pu, CreateEnvTextureAsync: () => vd, CreateGeodesic: () => Ph, CreateGoldberg: () => Oh, CreateGoldbergVertexData: () => Mh, CreateGreasedLine: () => rT, CreateGreasedLineMaterial: () => iT, CreateGround: () => Gc, CreateGroundFromHeightMap: () => Wc, CreateGroundFromHeightMapVertexData: () => kc, CreateGroundVertexData: () => Uc, CreateHemisphere: () => n_, CreateIcoSphere: () => cs, CreateIcoSphereVertexData: () => ls, CreateImageDataArrayBufferViews: () => bd, CreateLathe: () => lh, CreateLineSystem: () => ju, CreateLineSystemVertexData: () => Hu, CreateLines: () => Yu, CreatePlane: () => No, CreatePlaneVertexData: () => Do, CreatePolygon: () => th, CreatePolygonVertexData: () => eh, CreatePolyhedron: () => ph, CreatePolyhedronVertexData: () => dh, CreateResizedCopy: () => od, CreateRibbon: () => Ru, CreateRibbonVertexData: () => Au, CreateScreenshot: () => PA, CreateScreenshotAsync: () => IA, CreateScreenshotUsingRenderTarget: () => OA, CreateScreenshotUsingRenderTargetAsync: () => DA, CreateScreenshotWithResizeAsync: () => MA, CreateSegmentedBoxVertexData: () => mu, CreateSphere: () => bu, CreateSphereVertexData: () => yu, CreateText: () => Lh, CreateTextShapePaths: () => Fh, CreateTiledBox: () => Lu, CreateTiledBoxVertexData: () => Fu, CreateTiledGround: () => zc, CreateTiledGroundVertexData: () => Vc, CreateTiledPlane: () => Du, CreateTiledPlaneVertexData: () => Ou, CreateTorus: () => Lc, CreateTorusKnot: () => Uu, CreateTorusKnotVertexData: () => Bu, CreateTorusVertexData: () => Fc, CreateTube: () => uh, CrossBlock: () => Zv, CubeMapToSphericalPolynomialTools: () => dd, CubeTexture: () => h_, CubeTextureAssetTask: () => iA, CubicEase: () => kr, CullMode: () => pp, CurrentScreenBlock: () => Ea, Curve3: () => Lr, CurveBlock: () => rb, CurveBlockTypes: () => tb, CustomBlock: () => Jv, CustomOptimization: () => mA, CustomParticleEmitter: () => za, CustomProceduralTexture: () => fv, CylinderBlock: () => TT, CylinderBuilder: () => Nc, CylinderDirectedParticleEmitter: () => Ba, CylinderParticleEmitter: () => wa, DDSTools: () => W_, DataBuffer: () => Kt, DataReader: () => BA, DataStorage: () => UA, Database: () => aE, DaydreamController: () => kf, DebugBlock: () => tE, DebugLayer: () => fu, DebugLayerTab: () => cu, DecalBuilder: () => Sh, DecalMapConfiguration: () => hb, DecalMapDefines: () => ub, Decode: () => ft, DecodeBase64ToBinary: () => gt, DecodeBase64ToString: () => mt, DecodeBase64UrlToBinary: () => gi, DecodeBase64UrlToString: () => yi, DeepCopier: () => he, DefaultCollisionCoordinator: () => $c, DefaultKTX2DecoderOptions: () => em, DefaultLoadingScreen: () => rg, DefaultRenderingPipeline: () => ZS, Deferred: () => aA, DepthCullingState: () => kt, DepthOfFieldBlurPostProcess: () => DS, DepthOfFieldEffect: () => LS, DepthOfFieldEffectBlurLevel: () => NS, DepthOfFieldMergePostProcess: () => FS, DepthPeelingRenderer: () => mx, DepthPeelingSceneComponent: () => gx, DepthReducer: () => Km, DepthRenderer: () => jm, DepthRendererSceneComponent: () => fx, DepthSortedParticle: () => xE, DerivativeBlock: () => Mv, DesaturateBlock: () => Ny, DetailMapConfiguration: () => pc, DeviceInputEventType: () => Gi, DeviceLostReason: () => Cp, DeviceOrientationCamera: () => ol, DeviceSource: () => hr, DeviceSourceManager: () => pr, DeviceType: () => Fi, DirectionalLight: () => r_, DirectionalLightFrustumViewer: () => kh, DiscBlock: () => ST, DiscBuilder: () => Mu, DiscardBlock: () => Pv, DisplayPassPostProcess: () => wS, DistanceBlock: () => dy, DistanceConstraint: () => JE, DistanceJoint: () => jo, DivideBlock: () => ny, DoNothingAction: () => ae, DomManagement: () => ot, DotBlock: () => $v, DracoCompression: () => Ib, DrawWrapper: () => Jt, DualSenseInput: () => Ui, DualShockButton: () => ml, DualShockDpad: () => gl, DualShockInput: () => Bi, DualShockPad: () => yl, DumpTools: () => $a, DynamicFloat32Array: () => YA, DynamicTexture: () => gc, EasingFunction: () => wr, EdgesRenderer: () => yx, Effect: () => Vt, EffectFallbacks: () => Ra, EffectLayer: () => Lm, EffectLayerSceneComponent: () => wm, EffectRenderer: () => Ya, EffectWrapper: () => Ka, ElasticEase: () => Gr, ElbowBlock: () => Qy, EncodeArrayBufferToBase64: () => _t, EndsWith: () => dt, Engine: () => In, EngineFactory: () => Bf, EngineFormat: () => K_, EngineInstrumentation: () => Nm, EngineStore: () => S, EngineView: () => jh, EnvironmentHelper: () => f_, EnvironmentTextureTools: () => Rd, Epsilon: () => _, EquiRectangularCubeTexture: () => Ng, EquiRectangularCubeTextureAssetTask: () => nA, ErrorCodes: () => ut, ErrorFilter: () => Pp, EventConstants: () => ar, EventState: () => l, ExecuteCodeAction: () => le, ExponentialEase: () => zr, ExternalTexture: () => sf, ExtractHighlightsPostProcess: () => AS, ExtrudePolygon: () => ih, ExtrudeShape: () => nh, ExtrudeShapeCustom: () => oh, FactorGradient: () => pE, FadeInOutBehavior: () => Io, FeatureName: () => Hd, FileTools: () => vi, FileToolsOptions: () => si, FilesInput: () => lA, FilesInputStore: () => st, FilterMode: () => ep, FilterPostProcess: () => BS, FlowGraph: () => JR, FlowGraphAddNumberBlock: () => tC, FlowGraphBlock: () => YR, FlowGraphEventBlock: () => ZR, FlowGraphExecutionBlock: () => QR, FlowGraphForLoopBlock: () => $R, FlowGraphLogBlock: () => eC, FlowGraphMeshPickEventBlock: () => iC, FlowGraphSceneReadyEventBlock: () => rC, FlowGraphSignalConnection: () => KR, FluidRenderer: () => Vx, FluidRendererSceneComponent: () => Ux, FluidRenderingDebug: () => Cx, FluidRenderingObject: () => Ix, FluidRenderingObjectCustomParticles: () => Fx, FluidRenderingObjectParticleSystem: () => Mx, FluidRenderingTargetRenderer: () => Nx, FlyCamera: () => sl, FlyCameraInputsManager: () => al, FlyCameraKeyboardInput: () => Vs, FlyCameraMouseInput: () => ks, FogBlock: () => Uv, FollowBehavior: () => Go, FollowCamera: () => ul, FollowCameraInputsManager: () => ll, FollowCameraKeyboardMoveInput: () => Gs, FollowCameraMouseWheelInput: () => zs, FollowCameraPointersInput: () => Ws, FragCoordBlock: () => Ov, FragDepthBlock: () => wv, FragmentOutputBlock: () => fa, FramingBehavior: () => Ro, FreeCamera: () => il, FreeCameraDeviceOrientationInput: () => qs, FreeCameraGamepadInput: () => Js, FreeCameraInputsManager: () => Qs, FreeCameraKeyboardMoveInput: () => Hs, FreeCameraMouseInput: () => js, FreeCameraMouseWheelInput: () => Ys, FreeCameraTouchInput: () => Ks, FreeCameraVirtualJoystickInput: () => el, FresnelBlock: () => cy, FresnelParameters: () => Cg, FromHalfFloat: () => ld, FrontFace: () => dp, FrontFacingBlock: () => Iv, Frustum: () => vr, FxaaPostProcess: () => US, GPUParticleSystem: () => vE, GUID: () => Si, Gamepad: () => Os, GamepadCamera: () => Sl, GamepadManager: () => bl, GamepadSystemSceneComponent: () => Tl, GearVRController: () => Gf, GenerateBase64StringFromPixelData: () => fo, GenerateBase64StringFromTexture: () => _o, GenerateBase64StringFromTextureAsync: () => mo, GenericController: () => zf, GenericPad: () => Ds, GeodesicData: () => Ch, Geometry: () => An, GeometryBufferRenderer: () => zS, GeometryBufferRendererSceneComponent: () => HS, GeometryElbowBlock: () => UT, GeometryInputBlock: () => hT, GeometryOptimizeBlock: () => fT, GeometryOutputBlock: () => cT, GeometryTransformBlock: () => XT, GeometryTrigonometryBlock: () => HT, GeometryTrigonometryBlockOperations: () => zT, GetClass: () => T, GetDOMTextContent: () => rt, GetEnvInfo: () => md, GetEnvironmentBRDFTexture: () => v_, GetInternalFormatFromBasisFormat: () => tv, GetTGAHeader: () => Yg, Gizmo: () => uu, GizmoAnchorPoint: () => ou, GizmoCoordinatesMode: () => au, GizmoManager: () => t_, GlowLayer: () => Bm, GoldbergMesh: () => Ih, GradientBlock: () => Ay, GradientBlockColorStep: () => xy, GradientHelper: () => fE, GrainPostProcess: () => VS, GreasedLineMesh: () => tT, GreasedLineMeshColorDistribution: () => qb, GreasedLineMeshColorDistributionType: () => ab, GreasedLineMeshColorMode: () => ob, GreasedLineMeshMaterialType: () => nb, GreasedLineMeshWidthDistribution: () => Zb, GreasedLinePluginMaterial: () => bb, GreasedLineTools: () => Kb, GridBlock: () => yT, GroundBuilder: () => Hc, GroundMesh: () => Bc, HDRCubeTexture: () => sg, HDRCubeTextureAssetTask: () => rA, HDRFiltering: () => ag, HDRTools: () => og, HandConstraintBehavior: () => Ts, HandConstraintOrientation: () => _s, HandConstraintVisibility: () => ms, HandConstraintZone: () => fs, HandPart: () => hs, HardwareScalingOptimization: () => dA, HavokPlugin: () => uS, HeightToNormalBlock: () => Lv, HemisphereBuilder: () => o_, HemisphericLight: () => Zl, HemisphericParticleEmitter: () => Ua, HighlightLayer: () => Vm, HighlightsPostProcess: () => kS, Hinge2Joint: () => Qo, HingeConstraint: () => $E, HingeJoint: () => Ko, HtmlElementTexture: () => Fg, IWebXRControllerPhysicsOptions: () => sR, IcoSphereBlock: () => gT, IcoSphereBuilder: () => ps, ImageAssetTask: () => eA, ImageProcessingBlock: () => Av, ImageProcessingConfiguration: () => Ni, ImageProcessingConfigurationDefines: () => Di, ImageProcessingPostProcess: () => bc, ImageSourceBlock: () => kv, IncrementValueAction: () => re, IndexFormat: () => vp, InputBlock: () => Ta, InputStepMode: () => bp, InspectableType: () => FA, InstancedLinesMesh: () => Wu, InstancedMesh: () => $n, InstancesBlock: () => Ev, InstantiateOnFacesBlock: () => $T, InstantiateOnVerticesBlock: () => JT, InstantiatedEntries: () => io, IntFloatConverterBlock: () => eE, InternalTexture: () => Ht, InternalTextureSource: () => It, InterpolateValueAction: () => Ye, IntersectionInfo: () => cn, IsBase64DataUrl: () => _i, IsDocumentAvailable: () => it, IsFileURL: () => fi, IsNavigatorAvailable: () => tt, IsWindowObjectExist: () => et, JoystickAxis: () => Zs, KeepAssets: () => to, KeyboardEventTypes: () => ir, KeyboardInfo: () => rr, KeyboardInfoPre: () => nr, KhronosTextureContainer: () => Q_, KhronosTextureContainer2: () => tm, LatheBuilder: () => ch, Layer: () => Gm, LayerSceneComponent: () => km, LengthBlock: () => py, LensFlare: () => zm, LensFlareSystem: () => Wm, LensFlareSystemSceneComponent: () => Hm, LensFlaresOptimization: () => _A, LensRenderingPipeline: () => JS, LerpBlock: () => ry, Light: () => eo, LightBlock: () => Vv, LightGizmo: () => s_, LightInformationBlock: () => xv, LineEdgesRenderer: () => bx, LinesBuilder: () => Qu, LinesMesh: () => zu, LoadFile: () => di, LoadFileError: () => ni, LoadImage: () => ui, LoadOp: () => Sp, LoadTextureFromTranscodeResult: () => sv, LockConstraint: () => tS, Logger: () => $, MapMode: () => Yd, MapRangeBlock: () => NT, Material: () => Hn, MaterialAnisotropicDefines: () => R_, MaterialClearCoatDefines: () => E_, MaterialDefines: () => Mi, MaterialDetailMapDefines: () => dc, MaterialFlags: () => ic, MaterialGreasedLineDefines: () => yb, MaterialHelper: () => zn, MaterialIridescenceDefines: () => x_, MaterialPluginBase: () => hc, MaterialPluginEvent: () => Gn, MaterialPluginManager: () => nc, MaterialSheenDefines: () => P_, MaterialSubSurfaceDefines: () => M_, MathBlock: () => OT, MathBlockOperations: () => IT, Matrix: () => I, MatrixBuilderBlock: () => Xy, MatrixDeterminantBlock: () => Jy, MatrixTransposeBlock: () => eb, MaxBlock: () => uy, MergeGeometryBlock: () => BT, MergeMeshesOptimization: () => yA, Mesh: () => Jn, MeshAssetTask: () => qx, MeshAttributeExistsBlock: () => ib, MeshAttributeExistsBlockTypes: () => $y, MeshBlock: () => mT, MeshBuilder: () => wh, MeshDebugMode: () => Tb, MeshDebugPluginMaterial: () => xb, MeshExploder: () => sA, MeshLODLevel: () => jn, MeshParticleEmitter: () => Wa, MeshUVSpaceRenderer: () => Bb, MeshoptCompression: () => Mb, MinBlock: () => hy, MinMaxReducer: () => Ym, MipmapFilterMode: () => tp, MirrorTexture: () => u_, ModBlock: () => Wy, ModelShape: () => SE, MorphTarget: () => lg, MorphTargetManager: () => ug, MorphTargetsBlock: () => Sv, MotionBlurPostProcess: () => XS, MotorEnabledJoint: () => Yo, MultiMaterial: () => Xn, MultiObserver: () => cA, MultiPointerScaleBehavior: () => Bo, MultiRenderTarget: () => hv, MultiplyBlock: () => Na, NLerpBlock: () => Ry, NativeDataStream: () => Jh, NativeEngine: () => zd, NativePointerInput: () => wi, NativeXRFrame: () => HR, NativeXRLayerRenderTargetTextureProvider: () => Pc, NativeXRLayerWrapper: () => Cc, NativeXRRenderTarget: () => Ic, NegateBlock: () => fy, Node: () => ze, NodeGeometry: () => pT, NodeGeometryBlock: () => lT, NodeGeometryBlockConnectionPointTypes: () => Jb, NodeGeometryBuildState: () => uT, NodeGeometryConnectionPoint: () => sT, NodeGeometryConnectionPointCompatibilityStates: () => $b, NodeGeometryConnectionPointDirection: () => eT, NodeGeometryContextualSources: () => aT, NodeMaterial: () => ss, NodeMaterialBlock: () => sa, NodeMaterialBlockConnectionPointMode: () => da, NodeMaterialBlockConnectionPointTypes: () => Jo, NodeMaterialBlockTargets: () => $o, NodeMaterialConnectionPoint: () => aa, NodeMaterialConnectionPointCompatibilityStates: () => ia, NodeMaterialConnectionPointCustomObject: () => bv, NodeMaterialConnectionPointDirection: () => ra, NodeMaterialDefines: () => as, NodeMaterialModes: () => Da, NodeMaterialOptimizer: () => sb, NodeMaterialSystemValues: () => pa, NodeMaterialTeleportInBlock: () => jv, NodeMaterialTeleportOutBlock: () => Yv, NoiseBlock: () => wT, NoiseProceduralTexture: () => _v, NormalBlendBlock: () => Iy, NormalizeBlock: () => ey, NormalizeVectorBlock: () => GT, NullBlock: () => xT, NullEngine: () => zh, NullEngineOptions: () => Gh, Observable: () => u, Observer: () => c, OcclusionMaterial: () => Pg, Octree: () => nu, OctreeBlock: () => ru, OctreeSceneComponent: () => su, OculusTouchController: () => Wf, OimoJSPlugin: () => fg, OnAfterEnteringVRObservableEvent: () => Qc, OneMinusBlock: () => sy, Orientation: () => Pr, OutlineRenderer: () => Px, PBRAnisotropicConfiguration: () => C_, PBRBaseMaterial: () => F_, PBRBaseSimpleMaterial: () => Ig, PBRClearCoatConfiguration: () => S_, PBRIridescenceConfiguration: () => A_, PBRMaterial: () => L_, PBRMaterialDefines: () => N_, PBRMetallicRoughnessBlock: () => zy, PBRMetallicRoughnessMaterial: () => Mg, PBRSheenConfiguration: () => I_, PBRSpecularGlossinessMaterial: () => Og, PBRSubSurfaceConfiguration: () => O_, PHI: () => f, PadNumber: () => vt, PanoramaToCubeMapTools: () => ng, Particle: () => _E, ParticleBlendMultiplyBlock: () => Aa, ParticleHelper: () => bE, ParticleRampGradientBlock: () => xa, ParticleSystem: () => gE, ParticleSystemSet: () => yE, ParticleTextureBlock: () => Sa, ParticlesOptimization: () => gA, PassCubePostProcess: () => Al, PassPostProcess: () => xl, Path2: () => Nr, Path3D: () => Fr, PathCursor: () => Jr, PerfCollectionStrategy: () => eR, PerfCounter: () => mr, PerformanceConfigurator: () => E, PerformanceMonitor: () => Rn, PerformanceViewerCollector: () => JA, PerturbNormalBlock: () => Cv, PhotoDome: () => m_, Physics6DoFConstraint: () => qE, Physics6DoFLimit: () => QE, PhysicsAggregate: () => nS, PhysicsBody: () => UE, PhysicsConstraint: () => KE, PhysicsConstraintAxis: () => OE, PhysicsConstraintAxisLimitMode: () => ME, PhysicsConstraintMotorType: () => FE, PhysicsConstraintType: () => DE, PhysicsEngine: () => dg, PhysicsEngineV2: () => BE, PhysicsEventType: () => LE, PhysicsHelper: () => _S, PhysicsImpostor: () => Zo, PhysicsJoint: () => Xo, PhysicsMaterialCombineMode: () => VE, PhysicsMotionType: () => wE, PhysicsRadialExplosionEventOptions: () => bS, PhysicsRadialImpulseFalloff: () => dS, PhysicsRaycastResult: () => hg, PhysicsShape: () => kE, PhysicsShapeBox: () => HE, PhysicsShapeCapsule: () => zE, PhysicsShapeContainer: () => YE, PhysicsShapeConvexHull: () => XE, PhysicsShapeCylinder: () => WE, PhysicsShapeMesh: () => jE, PhysicsShapeSphere: () => GE, PhysicsShapeType: () => NE, PhysicsUpdraftEventOptions: () => TS, PhysicsUpdraftMode: () => pS, PhysicsViewer: () => Bh, PhysicsVortexEventOptions: () => ES, PickingInfo: () => Xi, PipelineErrorReason: () => cp, PivotTools: () => Oo, Plane: () => gr, PlaneBlock: () => _T, PlaneBuilder: () => Fo, PlaneDragGizmo: () => Jf, PlaneRotationGizmo: () => qf, PlayAnimationAction: () => ne, PlaySoundAction: () => pe, PointColor: () => TE, PointLight: () => ig, PointParticleEmitter: () => Va, PointerDragBehavior: () => wo, PointerEventTypes: () => Ji, PointerInfo: () => tr, PointerInfoBase: () => $i, PointerInfoPre: () => er, PointerInput: () => Li, PointsCloudSystem: () => IE, PointsGroup: () => PE, Polar: () => Ab, Polygon: () => Ju, PolygonBuilder: () => rh, PolygonMeshBuilder: () => $u, PolyhedronBuilder: () => fh, PolyhedronData: () => Rh, PoseEnabledController: () => _l, PoseEnabledControllerHelper: () => fl, PoseEnabledControllerType: () => cl, PositionGizmo: () => $f, PositionNormalTextureVertex: () => ga, PositionNormalVertex: () => ma, PostProcess: () => Ia, PostProcessManager: () => ji, PostProcessRenderEffect: () => xS, PostProcessRenderPipeline: () => KS, PostProcessRenderPipelineManager: () => QS, PostProcessRenderPipelineManagerSceneComponent: () => qS, PostProcessesOptimization: () => fA, PosterizeBlock: () => Ey, PowBlock: () => _y, PowerEase: () => Wr, PowerPreference: () => Wd, PrePassRenderer: () => Ex, PrePassRendererSceneComponent: () => Sx, PrecisionDate: () => at, PredicateCondition: () => Z, PressureObserverWrapper: () => jA, PrimitiveTopology: () => hp, PrismaticConstraint: () => iS, ProceduralTexture: () => rs, ProceduralTextureSceneComponent: () => ts, PropertyTypeForEdition: () => ca, PushMaterial: () => ta, QuadraticEase: () => Hr, QuadraticErrorSimplification: () => jb, QuarticEase: () => Xr, Quaternion: () => P, QueryType: () => Ap, QuinticEase: () => jr, RGBDTextureTools: () => ud, RandomBlock: () => LT, RandomGUID: () => Ei, RandomNumberBlock: () => my, RawCubeTexture: () => mv, RawTexture: () => Eo, RawTexture2DArray: () => cg, RawTexture3D: () => gv, Ray: () => Mo, RayHelper: () => Uh, ReadFile: () => hi, ReadFileError: () => ai, RecastJSCrowd: () => oE, RecastJSPlugin: () => nE, ReciprocalBlock: () => yy, ReflectBlock: () => Oy, ReflectionBlock: () => wy, ReflectionProbe: () => mg, ReflectionTextureBlock: () => Wv, Reflector: () => XA, RefractBlock: () => Dy, RefractionBlock: () => Vy, RefractionPostProcess: () => jS, RefractionTexture: () => vv, RegisterClass: () => b, RegisterMaterialPlugin: () => lc, RegisterNativeTypeAsync: () => Vd, RemapBlock: () => Oa, RenderPassTimestampLocation: () => Ep, RenderTargetTexture: () => es, RenderTargetWrapper: () => Ca, RenderTargetsOptimization: () => vA, RenderingGroup: () => Yi, RenderingGroupInfo: () => Ki, RenderingManager: () => Qi, ReplaceColorBlock: () => by, RequestFile: () => pi, RequestFileError: () => oi, RetryStrategy: () => lt, RibbonBuilder: () => Cu, RollingAverage: () => Cn, Rotate2dBlock: () => My, RotationGizmo: () => Zf, RotationXBlock: () => jT, RotationYBlock: () => YT, RotationZBlock: () => KT, RuntimeAnimation: () => $e, RuntimeError: () => ht, SSAO2RenderingPipeline: () => ex, SSAORenderingPipeline: () => tx, SSRRenderingPipeline: () => lx, SamplerBindingType: () => op, Scalar: () => h, ScaleBlock: () => Qv, ScaleGizmo: () => e_, ScalingBlock: () => QT, Scene: () => Sr, SceneComponentConstants: () => qi, SceneDepthBlock: () => Hv, SceneInstrumentation: () => Fm, SceneLoader: () => ea, SceneLoaderAnimationGroupLoadingMode: () => qo, SceneLoaderFlags: () => Sn, SceneOptimization: () => uA, SceneOptimizer: () => TA, SceneOptimizerOptions: () => bA, ScenePerformancePriority: () => or, SceneRecorder: () => VA, SceneSerializer: () => AA, ScreenSizeBlock: () => Dv, ScreenSpaceBlock: () => Nv, ScreenSpaceCurvaturePostProcess: () => dx, ScreenSpaceReflectionPostProcess: () => rx, ScreenshotTools: () => LA, SerializationHelper: () => Ue, SetColorsBlock: () => PT, SetCorsBehavior: () => ci, SetMaterialIDBlock: () => WT, SetNormalsBlock: () => RT, SetParentAction: () => ce, SetPositionsBlock: () => AT, SetStateAction: () => te, SetTangentsBlock: () => MT, SetUVsBlock: () => CT, SetValueAction: () => ie, ShaderCodeInliner: () => Nd, ShaderLanguage: () => nt, ShaderMaterial: () => Gu, ShaderStage: () => rp, ShaderStore: () => Ut, ShadowDepthWrapper: () => cb, ShadowGenerator: () => Xm, ShadowGeneratorSceneComponent: () => tg, ShadowLight: () => i_, ShadowMapBlock: () => Bv, ShadowsOptimization: () => pA, ShapeBuilder: () => sh, SharpenPostProcess: () => YS, SheenBlock: () => Fy, SimplexPerlin3DBlock: () => Py, SimplicationQueueSceneComponent: () => Yb, SimplificationQueue: () => Gb, SimplificationSettings: () => kb, SimplificationType: () => Ub, SineEase: () => Yr, SixDofDragBehavior: () => Vo, Size: () => We, Skeleton: () => xs, SkeletonViewer: () => Vh, SliderConstraint: () => eS, SmartArray: () => Ci, SmartArrayNoDuplicate: () => Pi, SmoothStepBlock: () => vy, SolidParticle: () => EE, SolidParticleSystem: () => RE, SolidParticleVertex: () => AE, Sound: () => ao, SoundTrack: () => so, SourceTextureFormat: () => j_, Space: () => Er, SphereBlock: () => vT, SphereBuilder: () => Tu, SphereDirectedParticleEmitter: () => Ga, SphereParticleEmitter: () => ka, Spherical: () => Rb, SphericalHarmonics: () => rd, SphericalPolynomial: () => nd, SpotLight: () => a_, SpringConstraint: () => rS, Sprite: () => kx, SpriteManager: () => Wx, SpriteMap: () => Xx, SpritePackedManager: () => jx, SpriteSceneComponent: () => Gx, Stage: () => Zi, StandardMaterial: () => mc, StandardMaterialDefines: () => _c, StandardRenderingPipeline: () => nx, StartsWith: () => pt, StateCondition: () => J, StencilOperation: () => gp, StencilState: () => Gt, StencilStateComposer: () => $t, StepBlock: () => ay, StereoscopicArcRotateCamera: () => Ll, StereoscopicFreeCamera: () => wl, StereoscopicGamepadCamera: () => Bl, StereoscopicInterlacePostProcess: () => Nl, StereoscopicInterlacePostProcessI: () => Dl, StereoscopicScreenUniversalCamera: () => Vl, StereoscopicUniversalCamera: () => Ul, StickValues: () => Ms, StopAnimationAction: () => oe, StopSoundAction: () => fe, StorageBuffer: () => As, StorageTextureAccess: () => sp, StoreOp: () => xp, StringDictionary: () => Ii, StringTools: () => yt, SubEmitter: () => mE, SubEmitterType: () => uE, SubMesh: () => bn, SubSurfaceBlock: () => ky, SubSurfaceSceneComponent: () => Rx, SubtractBlock: () => oy, SurfaceMagnetismBehavior: () => ko, SwitchBooleanAction: () => ee, SwitchInput: () => ki, TBNBlock: () => Rv, TGATools: () => Qg, Tags: () => me, TargetCamera: () => tl, TargetedAnimation: () => qr, TeleportInBlock: () => iE, TeleportOutBlock: () => rE, TestBase64DataUrl: () => mi, TextFileAssetTask: () => Jx, Texture: () => vo, TextureAspect: () => Zd, TextureAssetTask: () => tA, TextureBlock: () => Gv, TextureDimension: () => Kd, TextureFormat: () => Jd, TextureOptimization: () => hA, TexturePacker: () => pv, TexturePackerFrame: () => dv, TextureSampleType: () => ap, TextureSampler: () => Wt, TextureTools: () => cd, TextureUsage: () => Qd, TextureViewDimension: () => qd, ThinEngine: () => ti, ThinRenderTargetTexture: () => yv, ThinTexture: () => ho, TiledBoxBuilder: () => wu, TiledPlaneBuilder: () => Nu, TimerState: () => bm, TmpColors: () => V, TmpVectors: () => O, ToGammaSpace: () => d, ToHalfFloat: () => sd, ToLinearSpace: () => p, TonemapPostProcess: () => ux, TonemappingOperator: () => cx, Tools: () => xi, TorusBlock: () => bT, TorusBuilder: () => wc, TorusKnotBuilder: () => Vu, TouchCamera: () => rl, TrailMesh: () => Vb, Trajectory: () => kA, TrajectoryClassifier: () => HA, TranscodeAsync: () => ov, TranscodeTarget: () => Y_, TransformBlock: () => la, TransformNode: () => On, TranslationBlock: () => ZT, TriPlanarBlock: () => qy, TrigonometryBlock: () => ns, TrigonometryBlockOperations: () => is, TubeBuilder: () => hh, TwirlBlock: () => Fv, UniformBuffer: () => zi, UniversalCamera: () => El, UnregisterAllMaterialPlugins: () => uc, UnregisterMaterialPlugin: () => cc, UploadContent: () => Kg, UploadEnvLevelsAsync: () => Td, UploadEnvSpherical: () => xd, UploadLevelsAsync: () => Sd, UtilityLayerRenderer: () => lu, VRCameraMetrics: () => Gl, VRDeviceOrientationArcRotateCamera: () => Kl, VRDeviceOrientationFreeCamera: () => Ql, VRDeviceOrientationGamepadCamera: () => ql, VRDistortionCorrectionPostProcess: () => zl, VRExperienceHelper: () => qc, VRMultiviewToSingleviewPostProcess: () => jl, ValidatedNativeDataStream: () => Ip, ValueCondition: () => q, Vector2: () => A, Vector3: () => R, Vector4: () => C, VectorConverterBlock: () => kT, VectorMergerBlock: () => Ma, VectorSplitterBlock: () => iy, VertexAnimationBaker: () => So, VertexBuffer: () => Hi, VertexData: () => En, VertexDataMaterialInfo: () => Tn, VertexFormat: () => yp, VertexOutputBlock: () => ua, VideoDome: () => Dm, VideoRecorder: () => RA, VideoTexture: () => Om, ViewDirectionBlock: () => ly, Viewport: () => sn, VirtualJoystick: () => $s, VirtualJoysticksCamera: () => kl, ViveController: () => Hf, VolumetricLightScatteringPostProcess: () => hx, VoronoiNoiseBlock: () => Ky, WaveBlock: () => Sy, WaveBlockKind: () => Ty, WebGL2ParticleSystem: () => lE, WebGL2ShaderProcessor: () => Yt, WebGLDataBuffer: () => Qt, WebGLHardwareTexture: () => Zt, WebGLPipelineContext: () => qt, WebGPUCacheBindGroups: () => hf, WebGPUCacheRenderPipeline: () => tf, WebGPUCacheRenderPipelineTree: () => nf, WebGPUCacheSampler: () => Jp, WebGPUDataBuffer: () => jp, WebGPUDrawContext: () => cf, WebGPUEngine: () => Of, WebGPUTintWASM: () => Af, WebRequest: () => He, WebVRController: () => ec, WebVRFreeCamera: () => $l, WebXRAbstractFeature: () => Ho, WebXRAbstractMotionController: () => sm, WebXRAnchorSystem: () => rR, WebXRBackgroundRemover: () => aR, WebXRCamera: () => nm, WebXRCompositionLayerWrapper: () => xR, WebXRControllerComponent: () => am, WebXRControllerMovement: () => mR, WebXRControllerPhysics: () => lR, WebXRControllerPointerSelection: () => vm, WebXRDefaultExperience: () => Pm, WebXRDefaultExperienceOptions: () => Cm, WebXRDepthSensing: () => OR, WebXRDomOverlay: () => _R, WebXREnterExitUI: () => Sm, WebXREnterExitUIButton: () => Tm, WebXREnterExitUIOptions: () => Em, WebXRExperienceHelper: () => om, WebXREyeTracking: () => vR, WebXRFeatureName: () => zo, WebXRFeaturePointSystem: () => uR, WebXRFeaturesManager: () => Wo, WebXRGenericHandController: () => LR, WebXRGenericTriggerMotionController: () => lm, WebXRHTCViveMotionController: () => GR, WebXRHand: () => ys, WebXRHandJoint: () => ds, WebXRHandTracking: () => bs, WebXRHitTest: () => cR, WebXRHitTestLegacy: () => tR, WebXRImageTracking: () => fR, WebXRInput: () => gm, WebXRInputSource: () => mm, WebXRLayers: () => MR, WebXRLightEstimation: () => gR, WebXRManagedOutputCanvas: () => Rc, WebXRManagedOutputCanvasOptions: () => Ac, WebXRMeshDetector: () => pR, WebXRMicrosoftMixedRealityController: () => BR, WebXRMotionControllerManager: () => dm, WebXRMotionControllerTeleportation: () => Rm, WebXRNearControllerMode: () => fm, WebXRNearInteraction: () => ym, WebXROculusTouchMotionController: () => VR, WebXRPlaneDetector: () => oR, WebXRProfiledMotionController: () => um, WebXRProjectionLayerWrapper: () => RR, WebXRSessionManager: () => Mc, WebXRSpaceWarp: () => FR, WebXRSpaceWarpRenderTargetTextureProvider: () => NR, WebXRState: () => vc, WebXRTrackingState: () => yc, WebXRWalkingLocomotion: () => SR, WeightedSound: () => co, WindowsMotionController: () => jf, WorkerPool: () => q_, WorleyNoise3DBlock: () => Cy, XRSpaceWarpRenderTarget: () => DR, XRWindowsMotionController: () => Yf, Xbox360Button: () => dl, Xbox360Dpad: () => pl, Xbox360Pad: () => vl, XboxInput: () => Vi, _BabylonLoaderRegistered: () => gg, _BasisTextureLoader: () => uv, _CreationDataStorage: () => Yn, _DDSTextureLoader: () => H_, _ENVTextureLoader: () => X_, _HDRTextureLoader: () => Zg, _IAnimationState: () => Xe, _InstancesBatch: () => Qn, _KTXTextureLoader: () => rm, _MeshCollisionData: () => Dn, _OcclusionDataStorage: () => Hh, _PrimaryIsoTriangle: () => Ah, _TGATextureLoader: () => qg, _TimeToken: () => Wh, _UpdateRGBDAsync: () => Ad, _forceSceneHelpersToBundle: () => Im, _forceTransformFeedbackToBundle: () => Xh, _injectLTSFileTools: () => bi, addClipPlaneUniforms: () => wn, allocateAndCopyTypedBuffer: () => Pn, bindClipPlane: () => Vn, className: () => Ai, createDetailMapPlugin: () => vb, createPBRAnisotropicPlugin: () => db, createPBRBRDFPlugin: () => pb, createPBRClearCoatPlugin: () => fb, createPBRIridescencePlugin: () => _b, createPBRSheenPlugin: () => mb, createPBRSubSurfacePlugin: () => gb, createYieldingScheduler: () => en, editableInPropertyPage: () => ha, expandToProperty: () => Se, extractMinAndMax: () => yn, extractMinAndMaxIndexed: () => vn, inlineScheduler: () => $r, makeAsyncFunction: () => an, makeSyncFunction: () => on, nativeOverride: () => Ve, normalizeEnvInfo: () => gd, prepareDefinesForClipPlanes: () => Un, prepareStringDefinesForClipPlanes: () => Bn, runCoroutine: () => tn, runCoroutineAsync: () => nn, runCoroutineSync: () => rn, serialize: () => xe, serializeAsCameraReference: () => we, serializeAsColor3: () => Re, serializeAsColor4: () => De, serializeAsColorCurves: () => Oe, serializeAsFresnelParameters: () => Ce, serializeAsImageProcessingConfiguration: () => Ne, serializeAsMatrix: () => Le, serializeAsMeshReference: () => Me, serializeAsQuaternion: () => Fe, serializeAsTexture: () => Ae, serializeAsVector2: () => Pe, serializeAsVector3: () => Ie, setAndStartTimer: () => xm, setStereoscopicAnaglyphRigMode: () => Cl, setStereoscopicRigMode: () => Fl, setVRRigMode: () => Yl, setWebVRRigMode: () => Jl }); var n = {}; e.r(n), e.d(n, { AbstractActionManager: () => s, AbstractAssetTask: () => Yx, AbstractMesh: () => Ln, AbstractScene: () => o, AcquireNativeObjectAsync: () => Ud, Action: () => k, ActionEvent: () => G, ActionManager: () => de, AddBlock: () => Kv, AddressMode: () => $d, AdvancedTimer: () => Am, AlignBlock: () => qT, AlphaState: () => zt, AmmoJSPlugin: () => _g, AnaglyphArcRotateCamera: () => Pl, AnaglyphFreeCamera: () => Il, AnaglyphGamepadCamera: () => Ml, AnaglyphPostProcess: () => Rl, AnaglyphUniversalCamera: () => Ol, Analyser: () => no, AndOrNotEvaluator: () => _e, Angle: () => Or, Animatable: () => Cr, AnimatedInputBlockTypes: () => _a, Animation: () => je, AnimationAssetTask: () => Zx, AnimationEvent: () => Qr, AnimationGroup: () => Zr, AnimationKeyInterpolation: () => Be, AnimationPropertiesOverride: () => Ir, AnimationRange: () => ke, AnisotropyBlock: () => Ly, ApplyPostProcess: () => ad, Arc2: () => Dr, ArcFollowCamera: () => hl, ArcRotateCamera: () => nl, ArcRotateCameraGamepadInput: () => Ns, ArcRotateCameraInputsManager: () => Bs, ArcRotateCameraKeyboardMoveInput: () => Fs, ArcRotateCameraMouseWheelInput: () => Ls, ArcRotateCameraPointersInput: () => ws, ArcRotateCameraVRDeviceOrientationInput: () => Us, ArcTan2Block: () => gy, AssetContainer: () => ro, AssetTaskState: () => Hx, AssetsManager: () => oA, AssetsProgressEvent: () => Kx, AsyncLoop: () => Ri, AttachToBoxBehavior: () => Po, AudioEngine: () => oo, AudioSceneComponent: () => lo, AutoLayoutMode: () => up, AutoReleaseWorkerPool: () => Z_, AutoRotationBehavior: () => xo, AxesViewer: () => du, Axis: () => Ar, AxisDragGizmo: () => hu, AxisScaleGizmo: () => Kf, BRDFTextureTools: () => y_, BabylonFileLoaderConfiguration: () => vg, BackEase: () => Ur, BackgroundMaterial: () => p_, BakedVertexAnimationManager: () => uo, BallAndSocketConstraint: () => ZE, BaseCameraMouseWheelInput: () => Rs, BaseCameraPointersInput: () => Cs, BaseError: () => ct, BaseParticleSystem: () => Ha, BaseSixDofDragBehavior: () => Uo, BaseTexture: () => po, BasisTools: () => lv, BasisToolsOptions: () => ev, BasisTranscodeConfiguration: () => $g, BezierCurve: () => Mr, BezierCurveEase: () => Kr, BiPlanarBlock: () => Zy, BinaryFileAssetTask: () => $x, BlackAndWhitePostProcess: () => SS, BlendFactor: () => _p, BlendOperation: () => mp, BloomEffect: () => CS, BloomMergePostProcess: () => RS, BlurPostProcess: () => c_, Bone: () => Rr, BoneAxesViewer: () => pu, BoneIKController: () => Es, BoneLookController: () => Ss, BonesBlock: () => Tv, BounceEase: () => Vr, BouncingBehavior: () => Ao, BoundingBox: () => un, BoundingBoxGizmo: () => Qf, BoundingBoxRenderer: () => px, BoundingInfo: () => mn, BoundingSphere: () => hn, BoxBlock: () => dT, BoxBuilder: () => vu, BoxParticleEmitter: () => Fa, Buffer: () => Wi, BufferBindingType: () => np, BufferMapState: () => Xd, BufferUsage: () => jd, CSG: () => wb, Camera: () => ln, CameraGizmo: () => l_, CameraInputTypes: () => Ps, CameraInputsManager: () => Is, CannonJSPlugin: () => pg, CanvasAlphaMode: () => Rp, CapsuleBlock: () => ET, CapsuleBuilder: () => xu, CascadedShadowGenerator: () => eg, ChromaticAberrationPostProcess: () => PS, CircleEase: () => Br, CircleOfConfusionPostProcess: () => IS, ClampBlock: () => qv, ClearCoatBlock: () => By, ClipPlanesBlock: () => Xv, ClipboardEventTypes: () => Uf, ClipboardInfo: () => Vf, CloudBlock: () => Yy, CloudPoint: () => CE, Collider: () => Jc, Color3: () => B, Color3Gradient: () => dE, Color4: () => U, ColorCorrectionPostProcess: () => MS, ColorCurves: () => Oi, ColorGradient: () => hE, ColorGradingTexture: () => Dg, ColorMergerBlock: () => ty, ColorSplitterBlock: () => Xa, ColorWriteFlags: () => fp, CombineAction: () => se, CompareFunction: () => ip, CompatibilityOptions: () => xn, CompilationMessageType: () => lp, CompleteGreasedLineColorTable: () => oT, CompleteGreasedLineWidthTable: () => nT, ComputeBindingType: () => eu, ComputeEffect: () => tu, ComputeNormalsBlock: () => VT, ComputePassTimestampLocation: () => Tp, ComputeShader: () => iu, ComputeShaderParticleSystem: () => cE, Condition: () => Q, ConditionBlock: () => FT, ConditionBlockTests: () => DT, ConditionalBlock: () => jy, ConditionalBlockConditions: () => Hy, ConeParticleEmitter: () => La, Constants: () => a, ContainerAssetTask: () => Qx, ConversionMode: () => Dx, ConvolutionPostProcess: () => OS, Coordinate: () => xr, CopyTextureToTexture: () => Lx, CopyTools: () => go, CreateBox: () => gu, CreateBoxVertexData: () => _u, CreateCapsule: () => Su, CreateCapsuleVertexData: () => Eu, CreateCylinder: () => Dc, CreateCylinderVertexData: () => Oc, CreateDashedLines: () => Ku, CreateDashedLinesVertexData: () => Xu, CreateDecal: () => Eh, CreateDisc: () => Iu, CreateDiscVertexData: () => Pu, CreateEnvTextureAsync: () => vd, CreateGeodesic: () => Ph, CreateGoldberg: () => Oh, CreateGoldbergVertexData: () => Mh, CreateGreasedLine: () => rT, CreateGreasedLineMaterial: () => iT, CreateGround: () => Gc, CreateGroundFromHeightMap: () => Wc, CreateGroundFromHeightMapVertexData: () => kc, CreateGroundVertexData: () => Uc, CreateHemisphere: () => n_, CreateIcoSphere: () => cs, CreateIcoSphereVertexData: () => ls, CreateImageDataArrayBufferViews: () => bd, CreateLathe: () => lh, CreateLineSystem: () => ju, CreateLineSystemVertexData: () => Hu, CreateLines: () => Yu, CreatePlane: () => No, CreatePlaneVertexData: () => Do, CreatePolygon: () => th, CreatePolygonVertexData: () => eh, CreatePolyhedron: () => ph, CreatePolyhedronVertexData: () => dh, CreateResizedCopy: () => od, CreateRibbon: () => Ru, CreateRibbonVertexData: () => Au, CreateScreenshot: () => PA, CreateScreenshotAsync: () => IA, CreateScreenshotUsingRenderTarget: () => OA, CreateScreenshotUsingRenderTargetAsync: () => DA, CreateScreenshotWithResizeAsync: () => MA, CreateSegmentedBoxVertexData: () => mu, CreateSphere: () => bu, CreateSphereVertexData: () => yu, CreateText: () => Lh, CreateTextShapePaths: () => Fh, CreateTiledBox: () => Lu, CreateTiledBoxVertexData: () => Fu, CreateTiledGround: () => zc, CreateTiledGroundVertexData: () => Vc, CreateTiledPlane: () => Du, CreateTiledPlaneVertexData: () => Ou, CreateTorus: () => Lc, CreateTorusKnot: () => Uu, CreateTorusKnotVertexData: () => Bu, CreateTorusVertexData: () => Fc, CreateTube: () => uh, CrossBlock: () => Zv, CubeMapToSphericalPolynomialTools: () => dd, CubeTexture: () => h_, CubeTextureAssetTask: () => iA, CubicEase: () => kr, CullMode: () => pp, CurrentScreenBlock: () => Ea, Curve3: () => Lr, CurveBlock: () => rb, CurveBlockTypes: () => tb, CustomBlock: () => Jv, CustomOptimization: () => mA, CustomParticleEmitter: () => za, CustomProceduralTexture: () => fv, CylinderBlock: () => TT, CylinderBuilder: () => Nc, CylinderDirectedParticleEmitter: () => Ba, CylinderParticleEmitter: () => wa, DDSTools: () => W_, DataBuffer: () => Kt, DataReader: () => BA, DataStorage: () => UA, Database: () => aE, DaydreamController: () => kf, Debug: () => sC, DebugBlock: () => tE, DebugLayer: () => fu, DebugLayerTab: () => cu, DecalBuilder: () => Sh, DecalMapConfiguration: () => hb, DecalMapDefines: () => ub, Decode: () => ft, DecodeBase64ToBinary: () => gt, DecodeBase64ToString: () => mt, DecodeBase64UrlToBinary: () => gi, DecodeBase64UrlToString: () => yi, DeepCopier: () => he, DefaultCollisionCoordinator: () => $c, DefaultKTX2DecoderOptions: () => em, DefaultLoadingScreen: () => rg, DefaultRenderingPipeline: () => ZS, Deferred: () => aA, DepthCullingState: () => kt, DepthOfFieldBlurPostProcess: () => DS, DepthOfFieldEffect: () => LS, DepthOfFieldEffectBlurLevel: () => NS, DepthOfFieldMergePostProcess: () => FS, DepthPeelingRenderer: () => mx, DepthPeelingSceneComponent: () => gx, DepthReducer: () => Km, DepthRenderer: () => jm, DepthRendererSceneComponent: () => fx, DepthSortedParticle: () => xE, DerivativeBlock: () => Mv, DesaturateBlock: () => Ny, DetailMapConfiguration: () => pc, DeviceInputEventType: () => Gi, DeviceLostReason: () => Cp, DeviceOrientationCamera: () => ol, DeviceSource: () => hr, DeviceSourceManager: () => pr, DeviceType: () => Fi, DirectionalLight: () => r_, DirectionalLightFrustumViewer: () => kh, DiscBlock: () => ST, DiscBuilder: () => Mu, DiscardBlock: () => Pv, DisplayPassPostProcess: () => wS, DistanceBlock: () => dy, DistanceConstraint: () => JE, DistanceJoint: () => jo, DivideBlock: () => ny, DoNothingAction: () => ae, DomManagement: () => ot, DotBlock: () => $v, DracoCompression: () => Ib, DrawWrapper: () => Jt, DualSenseInput: () => Ui, DualShockButton: () => ml, DualShockDpad: () => gl, DualShockInput: () => Bi, DualShockPad: () => yl, DumpTools: () => $a, DynamicFloat32Array: () => YA, DynamicTexture: () => gc, EasingFunction: () => wr, EdgesRenderer: () => yx, Effect: () => Vt, EffectFallbacks: () => Ra, EffectLayer: () => Lm, EffectLayerSceneComponent: () => wm, EffectRenderer: () => Ya, EffectWrapper: () => Ka, ElasticEase: () => Gr, ElbowBlock: () => Qy, EncodeArrayBufferToBase64: () => _t, EndsWith: () => dt, Engine: () => In, EngineFactory: () => Bf, EngineFormat: () => K_, EngineInstrumentation: () => Nm, EngineStore: () => S, EngineView: () => jh, EnvironmentHelper: () => f_, EnvironmentTextureTools: () => Rd, Epsilon: () => _, EquiRectangularCubeTexture: () => Ng, EquiRectangularCubeTextureAssetTask: () => nA, ErrorCodes: () => ut, ErrorFilter: () => Pp, EventConstants: () => ar, EventState: () => l, ExecuteCodeAction: () => le, ExponentialEase: () => zr, ExternalTexture: () => sf, ExtractHighlightsPostProcess: () => AS, ExtrudePolygon: () => ih, ExtrudeShape: () => nh, ExtrudeShapeCustom: () => oh, FactorGradient: () => pE, FadeInOutBehavior: () => Io, FeatureName: () => Hd, FileTools: () => vi, FileToolsOptions: () => si, FilesInput: () => lA, FilesInputStore: () => st, FilterMode: () => ep, FilterPostProcess: () => BS, FlowGraph: () => JR, FlowGraphAddNumberBlock: () => tC, FlowGraphBlock: () => YR, FlowGraphEventBlock: () => ZR, FlowGraphExecutionBlock: () => QR, FlowGraphForLoopBlock: () => $R, FlowGraphLogBlock: () => eC, FlowGraphMeshPickEventBlock: () => iC, FlowGraphSceneReadyEventBlock: () => rC, FlowGraphSignalConnection: () => KR, FluidRenderer: () => Vx, FluidRendererSceneComponent: () => Ux, FluidRenderingDebug: () => Cx, FluidRenderingObject: () => Ix, FluidRenderingObjectCustomParticles: () => Fx, FluidRenderingObjectParticleSystem: () => Mx, FluidRenderingTargetRenderer: () => Nx, FlyCamera: () => sl, FlyCameraInputsManager: () => al, FlyCameraKeyboardInput: () => Vs, FlyCameraMouseInput: () => ks, FogBlock: () => Uv, FollowBehavior: () => Go, FollowCamera: () => ul, FollowCameraInputsManager: () => ll, FollowCameraKeyboardMoveInput: () => Gs, FollowCameraMouseWheelInput: () => zs, FollowCameraPointersInput: () => Ws, FragCoordBlock: () => Ov, FragDepthBlock: () => wv, FragmentOutputBlock: () => fa, FramingBehavior: () => Ro, FreeCamera: () => il, FreeCameraDeviceOrientationInput: () => qs, FreeCameraGamepadInput: () => Js, FreeCameraInputsManager: () => Qs, FreeCameraKeyboardMoveInput: () => Hs, FreeCameraMouseInput: () => js, FreeCameraMouseWheelInput: () => Ys, FreeCameraTouchInput: () => Ks, FreeCameraVirtualJoystickInput: () => el, FresnelBlock: () => cy, FresnelParameters: () => Cg, FromHalfFloat: () => ld, FrontFace: () => dp, FrontFacingBlock: () => Iv, Frustum: () => vr, FxaaPostProcess: () => US, GPUParticleSystem: () => vE, GUID: () => Si, Gamepad: () => Os, GamepadCamera: () => Sl, GamepadManager: () => bl, GamepadSystemSceneComponent: () => Tl, GearVRController: () => Gf, GenerateBase64StringFromPixelData: () => fo, GenerateBase64StringFromTexture: () => _o, GenerateBase64StringFromTextureAsync: () => mo, GenericController: () => zf, GenericPad: () => Ds, GeodesicData: () => Ch, Geometry: () => An, GeometryBufferRenderer: () => zS, GeometryBufferRendererSceneComponent: () => HS, GeometryElbowBlock: () => UT, GeometryInputBlock: () => hT, GeometryOptimizeBlock: () => fT, GeometryOutputBlock: () => cT, GeometryTransformBlock: () => XT, GeometryTrigonometryBlock: () => HT, GeometryTrigonometryBlockOperations: () => zT, GetClass: () => T, GetDOMTextContent: () => rt, GetEnvInfo: () => md, GetEnvironmentBRDFTexture: () => v_, GetInternalFormatFromBasisFormat: () => tv, GetTGAHeader: () => Yg, Gizmo: () => uu, GizmoAnchorPoint: () => ou, GizmoCoordinatesMode: () => au, GizmoManager: () => t_, GlowLayer: () => Bm, GoldbergMesh: () => Ih, GradientBlock: () => Ay, GradientBlockColorStep: () => xy, GradientHelper: () => fE, GrainPostProcess: () => VS, GreasedLineMesh: () => tT, GreasedLineMeshColorDistribution: () => qb, GreasedLineMeshColorDistributionType: () => ab, GreasedLineMeshColorMode: () => ob, GreasedLineMeshMaterialType: () => nb, GreasedLineMeshWidthDistribution: () => Zb, GreasedLinePluginMaterial: () => bb, GreasedLineTools: () => Kb, GridBlock: () => yT, GroundBuilder: () => Hc, GroundMesh: () => Bc, HDRCubeTexture: () => sg, HDRCubeTextureAssetTask: () => rA, HDRFiltering: () => ag, HDRTools: () => og, HandConstraintBehavior: () => Ts, HandConstraintOrientation: () => _s, HandConstraintVisibility: () => ms, HandConstraintZone: () => fs, HandPart: () => hs, HardwareScalingOptimization: () => dA, HavokPlugin: () => uS, HeightToNormalBlock: () => Lv, HemisphereBuilder: () => o_, HemisphericLight: () => Zl, HemisphericParticleEmitter: () => Ua, HighlightLayer: () => Vm, HighlightsPostProcess: () => kS, Hinge2Joint: () => Qo, HingeConstraint: () => $E, HingeJoint: () => Ko, HtmlElementTexture: () => Fg, IWebXRControllerPhysicsOptions: () => sR, IcoSphereBlock: () => gT, IcoSphereBuilder: () => ps, ImageAssetTask: () => eA, ImageProcessingBlock: () => Av, ImageProcessingConfiguration: () => Ni, ImageProcessingConfigurationDefines: () => Di, ImageProcessingPostProcess: () => bc, ImageSourceBlock: () => kv, IncrementValueAction: () => re, IndexFormat: () => vp, InputBlock: () => Ta, InputStepMode: () => bp, InspectableType: () => FA, InstancedLinesMesh: () => Wu, InstancedMesh: () => $n, InstancesBlock: () => Ev, InstantiateOnFacesBlock: () => $T, InstantiateOnVerticesBlock: () => JT, InstantiatedEntries: () => io, IntFloatConverterBlock: () => eE, InternalTexture: () => Ht, InternalTextureSource: () => It, InterpolateValueAction: () => Ye, IntersectionInfo: () => cn, IsBase64DataUrl: () => _i, IsDocumentAvailable: () => it, IsFileURL: () => fi, IsNavigatorAvailable: () => tt, IsWindowObjectExist: () => et, JoystickAxis: () => Zs, KeepAssets: () => to, KeyboardEventTypes: () => ir, KeyboardInfo: () => rr, KeyboardInfoPre: () => nr, KhronosTextureContainer: () => Q_, KhronosTextureContainer2: () => tm, LatheBuilder: () => ch, Layer: () => Gm, LayerSceneComponent: () => km, LengthBlock: () => py, LensFlare: () => zm, LensFlareSystem: () => Wm, LensFlareSystemSceneComponent: () => Hm, LensFlaresOptimization: () => _A, LensRenderingPipeline: () => JS, LerpBlock: () => ry, Light: () => eo, LightBlock: () => Vv, LightGizmo: () => s_, LightInformationBlock: () => xv, LineEdgesRenderer: () => bx, LinesBuilder: () => Qu, LinesMesh: () => zu, LoadFile: () => di, LoadFileError: () => ni, LoadImage: () => ui, LoadOp: () => Sp, LoadTextureFromTranscodeResult: () => sv, LockConstraint: () => tS, Logger: () => $, MapMode: () => Yd, MapRangeBlock: () => NT, Material: () => Hn, MaterialAnisotropicDefines: () => R_, MaterialClearCoatDefines: () => E_, MaterialDefines: () => Mi, MaterialDetailMapDefines: () => dc, MaterialFlags: () => ic, MaterialGreasedLineDefines: () => yb, MaterialHelper: () => zn, MaterialIridescenceDefines: () => x_, MaterialPluginBase: () => hc, MaterialPluginEvent: () => Gn, MaterialPluginManager: () => nc, MaterialSheenDefines: () => P_, MaterialSubSurfaceDefines: () => M_, MathBlock: () => OT, MathBlockOperations: () => IT, Matrix: () => I, MatrixBuilderBlock: () => Xy, MatrixDeterminantBlock: () => Jy, MatrixTransposeBlock: () => eb, MaxBlock: () => uy, MergeGeometryBlock: () => BT, MergeMeshesOptimization: () => yA, Mesh: () => Jn, MeshAssetTask: () => qx, MeshAttributeExistsBlock: () => ib, MeshAttributeExistsBlockTypes: () => $y, MeshBlock: () => mT, MeshBuilder: () => wh, MeshDebugMode: () => Tb, MeshDebugPluginMaterial: () => xb, MeshExploder: () => sA, MeshLODLevel: () => jn, MeshParticleEmitter: () => Wa, MeshUVSpaceRenderer: () => Bb, MeshoptCompression: () => Mb, MinBlock: () => hy, MinMaxReducer: () => Ym, MipmapFilterMode: () => tp, MirrorTexture: () => u_, ModBlock: () => Wy, ModelShape: () => SE, MorphTarget: () => lg, MorphTargetManager: () => ug, MorphTargetsBlock: () => Sv, MotionBlurPostProcess: () => XS, MotorEnabledJoint: () => Yo, MultiMaterial: () => Xn, MultiObserver: () => cA, MultiPointerScaleBehavior: () => Bo, MultiRenderTarget: () => hv, MultiplyBlock: () => Na, NLerpBlock: () => Ry, NativeDataStream: () => Jh, NativeEngine: () => zd, NativePointerInput: () => wi, NativeXRFrame: () => HR, NativeXRLayerRenderTargetTextureProvider: () => Pc, NativeXRLayerWrapper: () => Cc, NativeXRRenderTarget: () => Ic, NegateBlock: () => fy, Node: () => ze, NodeGeometry: () => pT, NodeGeometryBlock: () => lT, NodeGeometryBlockConnectionPointTypes: () => Jb, NodeGeometryBuildState: () => uT, NodeGeometryConnectionPoint: () => sT, NodeGeometryConnectionPointCompatibilityStates: () => $b, NodeGeometryConnectionPointDirection: () => eT, NodeGeometryContextualSources: () => aT, NodeMaterial: () => ss, NodeMaterialBlock: () => sa, NodeMaterialBlockConnectionPointMode: () => da, NodeMaterialBlockConnectionPointTypes: () => Jo, NodeMaterialBlockTargets: () => $o, NodeMaterialConnectionPoint: () => aa, NodeMaterialConnectionPointCompatibilityStates: () => ia, NodeMaterialConnectionPointCustomObject: () => bv, NodeMaterialConnectionPointDirection: () => ra, NodeMaterialDefines: () => as, NodeMaterialModes: () => Da, NodeMaterialOptimizer: () => sb, NodeMaterialSystemValues: () => pa, NodeMaterialTeleportInBlock: () => jv, NodeMaterialTeleportOutBlock: () => Yv, NoiseBlock: () => wT, NoiseProceduralTexture: () => _v, NormalBlendBlock: () => Iy, NormalizeBlock: () => ey, NormalizeVectorBlock: () => GT, NullBlock: () => xT, NullEngine: () => zh, NullEngineOptions: () => Gh, Observable: () => u, Observer: () => c, OcclusionMaterial: () => Pg, Octree: () => nu, OctreeBlock: () => ru, OctreeSceneComponent: () => su, OculusTouchController: () => Wf, OimoJSPlugin: () => fg, OnAfterEnteringVRObservableEvent: () => Qc, OneMinusBlock: () => sy, Orientation: () => Pr, OutlineRenderer: () => Px, PBRAnisotropicConfiguration: () => C_, PBRBaseMaterial: () => F_, PBRBaseSimpleMaterial: () => Ig, PBRClearCoatConfiguration: () => S_, PBRIridescenceConfiguration: () => A_, PBRMaterial: () => L_, PBRMaterialDefines: () => N_, PBRMetallicRoughnessBlock: () => zy, PBRMetallicRoughnessMaterial: () => Mg, PBRSheenConfiguration: () => I_, PBRSpecularGlossinessMaterial: () => Og, PBRSubSurfaceConfiguration: () => O_, PHI: () => f, PadNumber: () => vt, PanoramaToCubeMapTools: () => ng, Particle: () => _E, ParticleBlendMultiplyBlock: () => Aa, ParticleHelper: () => bE, ParticleRampGradientBlock: () => xa, ParticleSystem: () => gE, ParticleSystemSet: () => yE, ParticleTextureBlock: () => Sa, ParticlesOptimization: () => gA, PassCubePostProcess: () => Al, PassPostProcess: () => xl, Path2: () => Nr, Path3D: () => Fr, PathCursor: () => Jr, PerfCollectionStrategy: () => eR, PerfCounter: () => mr, PerformanceConfigurator: () => E, PerformanceMonitor: () => Rn, PerformanceViewerCollector: () => JA, PerturbNormalBlock: () => Cv, PhotoDome: () => m_, Physics6DoFConstraint: () => qE, Physics6DoFLimit: () => QE, PhysicsAggregate: () => nS, PhysicsBody: () => UE, PhysicsConstraint: () => KE, PhysicsConstraintAxis: () => OE, PhysicsConstraintAxisLimitMode: () => ME, PhysicsConstraintMotorType: () => FE, PhysicsConstraintType: () => DE, PhysicsEngine: () => dg, PhysicsEngineV2: () => BE, PhysicsEventType: () => LE, PhysicsHelper: () => _S, PhysicsImpostor: () => Zo, PhysicsJoint: () => Xo, PhysicsMaterialCombineMode: () => VE, PhysicsMotionType: () => wE, PhysicsRadialExplosionEventOptions: () => bS, PhysicsRadialImpulseFalloff: () => dS, PhysicsRaycastResult: () => hg, PhysicsShape: () => kE, PhysicsShapeBox: () => HE, PhysicsShapeCapsule: () => zE, PhysicsShapeContainer: () => YE, PhysicsShapeConvexHull: () => XE, PhysicsShapeCylinder: () => WE, PhysicsShapeMesh: () => jE, PhysicsShapeSphere: () => GE, PhysicsShapeType: () => NE, PhysicsUpdraftEventOptions: () => TS, PhysicsUpdraftMode: () => pS, PhysicsViewer: () => Bh, PhysicsVortexEventOptions: () => ES, PickingInfo: () => Xi, PipelineErrorReason: () => cp, PivotTools: () => Oo, Plane: () => gr, PlaneBlock: () => _T, PlaneBuilder: () => Fo, PlaneDragGizmo: () => Jf, PlaneRotationGizmo: () => qf, PlayAnimationAction: () => ne, PlaySoundAction: () => pe, PointColor: () => TE, PointLight: () => ig, PointParticleEmitter: () => Va, PointerDragBehavior: () => wo, PointerEventTypes: () => Ji, PointerInfo: () => tr, PointerInfoBase: () => $i, PointerInfoPre: () => er, PointerInput: () => Li, PointsCloudSystem: () => IE, PointsGroup: () => PE, Polar: () => Ab, Polygon: () => Ju, PolygonBuilder: () => rh, PolygonMeshBuilder: () => $u, PolyhedronBuilder: () => fh, PolyhedronData: () => Rh, PoseEnabledController: () => _l, PoseEnabledControllerHelper: () => fl, PoseEnabledControllerType: () => cl, PositionGizmo: () => $f, PositionNormalTextureVertex: () => ga, PositionNormalVertex: () => ma, PostProcess: () => Ia, PostProcessManager: () => ji, PostProcessRenderEffect: () => xS, PostProcessRenderPipeline: () => KS, PostProcessRenderPipelineManager: () => QS, PostProcessRenderPipelineManagerSceneComponent: () => qS, PostProcessesOptimization: () => fA, PosterizeBlock: () => Ey, PowBlock: () => _y, PowerEase: () => Wr, PowerPreference: () => Wd, PrePassRenderer: () => Ex, PrePassRendererSceneComponent: () => Sx, PrecisionDate: () => at, PredicateCondition: () => Z, PressureObserverWrapper: () => jA, PrimitiveTopology: () => hp, PrismaticConstraint: () => iS, ProceduralTexture: () => rs, ProceduralTextureSceneComponent: () => ts, PropertyTypeForEdition: () => ca, PushMaterial: () => ta, QuadraticEase: () => Hr, QuadraticErrorSimplification: () => jb, QuarticEase: () => Xr, Quaternion: () => P, QueryType: () => Ap, QuinticEase: () => jr, RGBDTextureTools: () => ud, RandomBlock: () => LT, RandomGUID: () => Ei, RandomNumberBlock: () => my, RawCubeTexture: () => mv, RawTexture: () => Eo, RawTexture2DArray: () => cg, RawTexture3D: () => gv, Ray: () => Mo, RayHelper: () => Uh, ReadFile: () => hi, ReadFileError: () => ai, RecastJSCrowd: () => oE, RecastJSPlugin: () => nE, ReciprocalBlock: () => yy, ReflectBlock: () => Oy, ReflectionBlock: () => wy, ReflectionProbe: () => mg, ReflectionTextureBlock: () => Wv, Reflector: () => XA, RefractBlock: () => Dy, RefractionBlock: () => Vy, RefractionPostProcess: () => jS, RefractionTexture: () => vv, RegisterClass: () => b, RegisterMaterialPlugin: () => lc, RegisterNativeTypeAsync: () => Vd, RemapBlock: () => Oa, RenderPassTimestampLocation: () => Ep, RenderTargetTexture: () => es, RenderTargetWrapper: () => Ca, RenderTargetsOptimization: () => vA, RenderingGroup: () => Yi, RenderingGroupInfo: () => Ki, RenderingManager: () => Qi, ReplaceColorBlock: () => by, RequestFile: () => pi, RequestFileError: () => oi, RetryStrategy: () => lt, RibbonBuilder: () => Cu, RollingAverage: () => Cn, Rotate2dBlock: () => My, RotationGizmo: () => Zf, RotationXBlock: () => jT, RotationYBlock: () => YT, RotationZBlock: () => KT, RuntimeAnimation: () => $e, RuntimeError: () => ht, SSAO2RenderingPipeline: () => ex, SSAORenderingPipeline: () => tx, SSRRenderingPipeline: () => lx, SamplerBindingType: () => op, Scalar: () => h, ScaleBlock: () => Qv, ScaleGizmo: () => e_, ScalingBlock: () => QT, Scene: () => Sr, SceneComponentConstants: () => qi, SceneDepthBlock: () => Hv, SceneInstrumentation: () => Fm, SceneLoader: () => ea, SceneLoaderAnimationGroupLoadingMode: () => qo, SceneLoaderFlags: () => Sn, SceneOptimization: () => uA, SceneOptimizer: () => TA, SceneOptimizerOptions: () => bA, ScenePerformancePriority: () => or, SceneRecorder: () => VA, SceneSerializer: () => AA, ScreenSizeBlock: () => Dv, ScreenSpaceBlock: () => Nv, ScreenSpaceCurvaturePostProcess: () => dx, ScreenSpaceReflectionPostProcess: () => rx, ScreenshotTools: () => LA, SerializationHelper: () => Ue, SetColorsBlock: () => PT, SetCorsBehavior: () => ci, SetMaterialIDBlock: () => WT, SetNormalsBlock: () => RT, SetParentAction: () => ce, SetPositionsBlock: () => AT, SetStateAction: () => te, SetTangentsBlock: () => MT, SetUVsBlock: () => CT, SetValueAction: () => ie, ShaderCodeInliner: () => Nd, ShaderLanguage: () => nt, ShaderMaterial: () => Gu, ShaderStage: () => rp, ShaderStore: () => Ut, ShadowDepthWrapper: () => cb, ShadowGenerator: () => Xm, ShadowGeneratorSceneComponent: () => tg, ShadowLight: () => i_, ShadowMapBlock: () => Bv, ShadowsOptimization: () => pA, ShapeBuilder: () => sh, SharpenPostProcess: () => YS, SheenBlock: () => Fy, SimplexPerlin3DBlock: () => Py, SimplicationQueueSceneComponent: () => Yb, SimplificationQueue: () => Gb, SimplificationSettings: () => kb, SimplificationType: () => Ub, SineEase: () => Yr, SixDofDragBehavior: () => Vo, Size: () => We, Skeleton: () => xs, SkeletonViewer: () => Vh, SliderConstraint: () => eS, SmartArray: () => Ci, SmartArrayNoDuplicate: () => Pi, SmoothStepBlock: () => vy, SolidParticle: () => EE, SolidParticleSystem: () => RE, SolidParticleVertex: () => AE, Sound: () => ao, SoundTrack: () => so, SourceTextureFormat: () => j_, Space: () => Er, SphereBlock: () => vT, SphereBuilder: () => Tu, SphereDirectedParticleEmitter: () => Ga, SphereParticleEmitter: () => ka, Spherical: () => Rb, SphericalHarmonics: () => rd, SphericalPolynomial: () => nd, SpotLight: () => a_, SpringConstraint: () => rS, Sprite: () => kx, SpriteManager: () => Wx, SpriteMap: () => Xx, SpritePackedManager: () => jx, SpriteSceneComponent: () => Gx, Stage: () => Zi, StandardMaterial: () => mc, StandardMaterialDefines: () => _c, StandardRenderingPipeline: () => nx, StartsWith: () => pt, StateCondition: () => J, StencilOperation: () => gp, StencilState: () => Gt, StencilStateComposer: () => $t, StepBlock: () => ay, StereoscopicArcRotateCamera: () => Ll, StereoscopicFreeCamera: () => wl, StereoscopicGamepadCamera: () => Bl, StereoscopicInterlacePostProcess: () => Nl, StereoscopicInterlacePostProcessI: () => Dl, StereoscopicScreenUniversalCamera: () => Vl, StereoscopicUniversalCamera: () => Ul, StickValues: () => Ms, StopAnimationAction: () => oe, StopSoundAction: () => fe, StorageBuffer: () => As, StorageTextureAccess: () => sp, StoreOp: () => xp, StringDictionary: () => Ii, StringTools: () => yt, SubEmitter: () => mE, SubEmitterType: () => uE, SubMesh: () => bn, SubSurfaceBlock: () => ky, SubSurfaceSceneComponent: () => Rx, SubtractBlock: () => oy, SurfaceMagnetismBehavior: () => ko, SwitchBooleanAction: () => ee, SwitchInput: () => ki, TBNBlock: () => Rv, TGATools: () => Qg, Tags: () => me, TargetCamera: () => tl, TargetedAnimation: () => qr, TeleportInBlock: () => iE, TeleportOutBlock: () => rE, TestBase64DataUrl: () => mi, TextFileAssetTask: () => Jx, Texture: () => vo, TextureAspect: () => Zd, TextureAssetTask: () => tA, TextureBlock: () => Gv, TextureDimension: () => Kd, TextureFormat: () => Jd, TextureOptimization: () => hA, TexturePacker: () => pv, TexturePackerFrame: () => dv, TextureSampleType: () => ap, TextureSampler: () => Wt, TextureTools: () => cd, TextureUsage: () => Qd, TextureViewDimension: () => qd, ThinEngine: () => ti, ThinRenderTargetTexture: () => yv, ThinTexture: () => ho, TiledBoxBuilder: () => wu, TiledPlaneBuilder: () => Nu, TimerState: () => bm, TmpColors: () => V, TmpVectors: () => O, ToGammaSpace: () => d, ToHalfFloat: () => sd, ToLinearSpace: () => p, TonemapPostProcess: () => ux, TonemappingOperator: () => cx, Tools: () => xi, TorusBlock: () => bT, TorusBuilder: () => wc, TorusKnotBuilder: () => Vu, TouchCamera: () => rl, TrailMesh: () => Vb, Trajectory: () => kA, TrajectoryClassifier: () => HA, TranscodeAsync: () => ov, TranscodeTarget: () => Y_, TransformBlock: () => la, TransformNode: () => On, TranslationBlock: () => ZT, TriPlanarBlock: () => qy, TrigonometryBlock: () => ns, TrigonometryBlockOperations: () => is, TubeBuilder: () => hh, TwirlBlock: () => Fv, UniformBuffer: () => zi, UniversalCamera: () => El, UnregisterAllMaterialPlugins: () => uc, UnregisterMaterialPlugin: () => cc, UploadContent: () => Kg, UploadEnvLevelsAsync: () => Td, UploadEnvSpherical: () => xd, UploadLevelsAsync: () => Sd, UtilityLayerRenderer: () => lu, VRCameraMetrics: () => Gl, VRDeviceOrientationArcRotateCamera: () => Kl, VRDeviceOrientationFreeCamera: () => Ql, VRDeviceOrientationGamepadCamera: () => ql, VRDistortionCorrectionPostProcess: () => zl, VRExperienceHelper: () => qc, VRMultiviewToSingleviewPostProcess: () => jl, ValidatedNativeDataStream: () => Ip, ValueCondition: () => q, Vector2: () => A, Vector3: () => R, Vector4: () => C, VectorConverterBlock: () => kT, VectorMergerBlock: () => Ma, VectorSplitterBlock: () => iy, VertexAnimationBaker: () => So, VertexBuffer: () => Hi, VertexData: () => En, VertexDataMaterialInfo: () => Tn, VertexFormat: () => yp, VertexOutputBlock: () => ua, VideoDome: () => Dm, VideoRecorder: () => RA, VideoTexture: () => Om, ViewDirectionBlock: () => ly, Viewport: () => sn, VirtualJoystick: () => $s, VirtualJoysticksCamera: () => kl, ViveController: () => Hf, VolumetricLightScatteringPostProcess: () => hx, VoronoiNoiseBlock: () => Ky, WaveBlock: () => Sy, WaveBlockKind: () => Ty, WebGL2ParticleSystem: () => lE, WebGL2ShaderProcessor: () => Yt, WebGLDataBuffer: () => Qt, WebGLHardwareTexture: () => Zt, WebGLPipelineContext: () => qt, WebGPUCacheBindGroups: () => hf, WebGPUCacheRenderPipeline: () => tf, WebGPUCacheRenderPipelineTree: () => nf, WebGPUCacheSampler: () => Jp, WebGPUDataBuffer: () => jp, WebGPUDrawContext: () => cf, WebGPUEngine: () => Of, WebGPUTintWASM: () => Af, WebRequest: () => He, WebVRController: () => ec, WebVRFreeCamera: () => $l, WebXRAbstractFeature: () => Ho, WebXRAbstractMotionController: () => sm, WebXRAnchorSystem: () => rR, WebXRBackgroundRemover: () => aR, WebXRCamera: () => nm, WebXRCompositionLayerWrapper: () => xR, WebXRControllerComponent: () => am, WebXRControllerMovement: () => mR, WebXRControllerPhysics: () => lR, WebXRControllerPointerSelection: () => vm, WebXRDefaultExperience: () => Pm, WebXRDefaultExperienceOptions: () => Cm, WebXRDepthSensing: () => OR, WebXRDomOverlay: () => _R, WebXREnterExitUI: () => Sm, WebXREnterExitUIButton: () => Tm, WebXREnterExitUIOptions: () => Em, WebXRExperienceHelper: () => om, WebXREyeTracking: () => vR, WebXRFeatureName: () => zo, WebXRFeaturePointSystem: () => uR, WebXRFeaturesManager: () => Wo, WebXRGenericHandController: () => LR, WebXRGenericTriggerMotionController: () => lm, WebXRHTCViveMotionController: () => GR, WebXRHand: () => ys, WebXRHandJoint: () => ds, WebXRHandTracking: () => bs, WebXRHitTest: () => cR, WebXRHitTestLegacy: () => tR, WebXRImageTracking: () => fR, WebXRInput: () => gm, WebXRInputSource: () => mm, WebXRLayers: () => MR, WebXRLightEstimation: () => gR, WebXRManagedOutputCanvas: () => Rc, WebXRManagedOutputCanvasOptions: () => Ac, WebXRMeshDetector: () => pR, WebXRMicrosoftMixedRealityController: () => BR, WebXRMotionControllerManager: () => dm, WebXRMotionControllerTeleportation: () => Rm, WebXRNearControllerMode: () => fm, WebXRNearInteraction: () => ym, WebXROculusTouchMotionController: () => VR, WebXRPlaneDetector: () => oR, WebXRProfiledMotionController: () => um, WebXRProjectionLayerWrapper: () => RR, WebXRSessionManager: () => Mc, WebXRSpaceWarp: () => FR, WebXRSpaceWarpRenderTargetTextureProvider: () => NR, WebXRState: () => vc, WebXRTrackingState: () => yc, WebXRWalkingLocomotion: () => SR, WeightedSound: () => co, WindowsMotionController: () => jf, WorkerPool: () => q_, WorleyNoise3DBlock: () => Cy, XRSpaceWarpRenderTarget: () => DR, XRWindowsMotionController: () => Yf, Xbox360Button: () => dl, Xbox360Dpad: () => pl, Xbox360Pad: () => vl, XboxInput: () => Vi, _BabylonLoaderRegistered: () => gg, _BasisTextureLoader: () => uv, _CreationDataStorage: () => Yn, _DDSTextureLoader: () => H_, _ENVTextureLoader: () => X_, _HDRTextureLoader: () => Zg, _IAnimationState: () => Xe, _InstancesBatch: () => Qn, _KTXTextureLoader: () => rm, _MeshCollisionData: () => Dn, _OcclusionDataStorage: () => Hh, _PrimaryIsoTriangle: () => Ah, _TGATextureLoader: () => qg, _TimeToken: () => Wh, _UpdateRGBDAsync: () => Ad, _forceSceneHelpersToBundle: () => Im, _forceTransformFeedbackToBundle: () => Xh, _injectLTSFileTools: () => bi, addClipPlaneUniforms: () => wn, allocateAndCopyTypedBuffer: () => Pn, bindClipPlane: () => Vn, className: () => Ai, createDetailMapPlugin: () => vb, createPBRAnisotropicPlugin: () => db, createPBRBRDFPlugin: () => pb, createPBRClearCoatPlugin: () => fb, createPBRIridescencePlugin: () => _b, createPBRSheenPlugin: () => mb, createPBRSubSurfacePlugin: () => gb, createYieldingScheduler: () => en, editableInPropertyPage: () => ha, expandToProperty: () => Se, extractMinAndMax: () => yn, extractMinAndMaxIndexed: () => vn, inlineScheduler: () => $r, makeAsyncFunction: () => an, makeSyncFunction: () => on, nativeOverride: () => Ve, normalizeEnvInfo: () => gd, prepareDefinesForClipPlanes: () => Un, prepareStringDefinesForClipPlanes: () => Bn, runCoroutine: () => tn, runCoroutineAsync: () => nn, runCoroutineSync: () => rn, serialize: () => xe, serializeAsCameraReference: () => we, serializeAsColor3: () => Re, serializeAsColor4: () => De, serializeAsColorCurves: () => Oe, serializeAsFresnelParameters: () => Ce, serializeAsImageProcessingConfiguration: () => Ne, serializeAsMatrix: () => Le, serializeAsMeshReference: () => Me, serializeAsQuaternion: () => Fe, serializeAsTexture: () => Ae, serializeAsVector2: () => Pe, serializeAsVector3: () => Ie, setAndStartTimer: () => xm, setStereoscopicAnaglyphRigMode: () => Cl, setStereoscopicRigMode: () => Fl, setVRRigMode: () => Yl, setWebVRRigMode: () => Jl }); 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_WEBVR = 21, 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; i < this._observers.length; i++) { var r = this._observers[i]; if (!(r._willBeUnregistered || r.callback !== e || t && t !== r.scope)) return this._deferUnregister(r), !0 } return !1 }, e.prototype._deferUnregister = function (e) { var t = this; e._willBeUnregistered || (this._numObserversMarkedAsDeleted++, e.unregisterOnNextCall = !1, e._willBeUnregistered = !0, setTimeout((function () { t._remove(e) }), 0)) }, e.prototype._remove = function (e, t) { if (void 0 === t && (t = !0), !e) return !1; var i = this._observers.indexOf(e); return -1 !== i && (t && this._numObserversMarkedAsDeleted--, this._observers.splice(i, 1), !0) }, e.prototype.makeObserverTopPriority = function (e) { this._remove(e, !1), this._observers.unshift(e) }, e.prototype.makeObserverBottomPriority = function (e) { this._remove(e, !1), this._observers.push(e) }, e.prototype.notifyObservers = function (e, t, i, r, n) { if (void 0 === t && (t = -1), this.notifyIfTriggered && (this._hasNotified = !0, this._lastNotifiedValue = e), !this._observers.length) return !0; var o = this._eventState; o.mask = t, o.target = i, o.currentTarget = r, o.skipNextObservers = !1, o.lastReturnValue = e, o.userInfo = n; for (var a = 0, s = this._observers; a < s.length; a++) { var l = s[a]; if (!l._willBeUnregistered && (l.mask & t && (l.unregisterOnNextCall && this._deferUnregister(l), l.scope ? o.lastReturnValue = l.callback.apply(l.scope, [e, o]) : o.lastReturnValue = l.callback(e, o)), o.skipNextObservers)) return !1 } return !0 }, e.prototype.notifyObserver = function (e, t, i) { if (void 0 === i && (i = -1), this.notifyIfTriggered && (this._hasNotified = !0, this._lastNotifiedValue = t), !e._willBeUnregistered) { var r = this._eventState; r.mask = i, r.skipNextObservers = !1, e.unregisterOnNextCall && this._deferUnregister(e), e.callback(t, r) } }, e.prototype.hasObservers = function () { return this._observers.length - this._numObserversMarkedAsDeleted > 0 }, e.prototype.clear = function () { for (; this._observers.length;) { var e = this._observers.pop(); e && (e._remove = null) } this._onObserverAdded = null, this._numObserversMarkedAsDeleted = 0, this.cleanLastNotifiedState() }, e.prototype.cleanLastNotifiedState = function () { this._hasNotified = !1, this._lastNotifiedValue = void 0 }, e.prototype.clone = function () { var t = new e; return t._observers = this._observers.slice(0), t }, e.prototype.hasSpecificMask = function (e) { void 0 === e && (e = -1); for (var t = 0, i = this._observers; t < i.length; t++) { var r = i[t]; if (r.mask & e || r.mask === e) return !0 } return !1 }, e }(), h = function () { function e() { } return e.WithinEpsilon = function (e, t, i) { return void 0 === i && (i = 1401298e-51), Math.abs(e - t) <= i }, e.ToHex = function (e) { var t = e.toString(16); return e <= 15 ? ("0" + t).toUpperCase() : t.toUpperCase() }, e.Sign = function (e) { return 0 == (e = +e) || isNaN(e) ? e : e > 0 ? 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 -r < n && n < r ? o = i : (i = t + n, o = e.MoveTowards(t, i, r)), o }, e.Lerp = function (e, t, i) { return e + (t - e) * i }, e.LerpAngle = function (t, i, r) { var n = e.Repeat(i - t, 360); return n > 180 && (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; r < e; ++r)i.push(t()); return i }, e.BuildTuple = function (t, i) { return e.BuildArray(t, i) }, e }(), g = ["push", "splice", "pop", "shift", "unshift"]; function v(e, t) { var i = g.map((function (i) { return function (e, t, i) { var r = e[t]; if ("function" != typeof r) return null; var n = function () { var r = e.length, o = n.previous.apply(e, arguments); return i(t, r), o }; return r.next = n, n.previous = r, e[t] = n, function () { var i = n.previous; if (i) { var r = n.next; r ? (i.next = r, r.previous = i) : (i.next = void 0, e[t] = i), n.next = void 0, n.previous = void 0 } } }(e, i, t) })); return function () { i.forEach((function (e) { null == e || e() })) } } var y = {}; function b(e, t) { y[e] = t } function T(e) { return y[e] } var E = function () { function e() { } return e.SetMatrixPrecision = function (t) { if (e.MatrixTrackPrecisionChange = !1, t && !e.MatrixUse64Bits && e.MatrixTrackedMatrices) for (var i = 0; i < e.MatrixTrackedMatrices.length; ++i) { var r = e.MatrixTrackedMatrices[i], n = r._m; r._m = new Array(16); for (var o = 0; o < 16; ++o)r._m[o] = n[o] } e.MatrixUse64Bits = t, e.MatrixCurrentType = e.MatrixUse64Bits ? Array : Float32Array, e.MatrixTrackedMatrices = null }, e.MatrixUse64Bits = !1, e.MatrixTrackPrecisionChange = !0, e.MatrixCurrentType = Float32Array, e.MatrixTrackedMatrices = [], e }(), S = function () { function e() { } return Object.defineProperty(e, "LastCreatedEngine", { get: function () { return 0 === this.Instances.length ? null : this.Instances[this.Instances.length - 1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "LastCreatedScene", { get: function () { return this._LastCreatedScene }, enumerable: !1, configurable: !0 }), e.Instances = new Array, e.OnEnginesDisposedObservable = new u, e._LastCreatedScene = null, e.UseFallbackTexture = !0, e.FallbackTexture = "", e }(), x = function (e) { return parseInt(e.toString().replace(/\W/g, "")) }, A = function () { function e(e, t) { void 0 === e && (e = 0), void 0 === t && (t = 0), this.x = e, this.y = t } return e.prototype.toString = function () { return "{X: ".concat(this.x, " Y: ").concat(this.y, "}") }, e.prototype.getClassName = function () { return "Vector2" }, e.prototype.getHashCode = function () { var e = x(this.x); return 397 * e ^ x(this.y) }, e.prototype.toArray = function (e, t) { return void 0 === t && (t = 0), e[t] = this.x, e[t + 1] = this.y, this }, e.prototype.fromArray = function (t, i) { return void 0 === i && (i = 0), e.FromArrayToRef(t, i, this), this }, e.prototype.asArray = function () { var e = new Array; return this.toArray(e, 0), e }, e.prototype.copyFrom = function (e) { return this.x = e.x, this.y = e.y, this }, e.prototype.copyFromFloats = function (e, t) { return this.x = e, this.y = t, this }, e.prototype.set = function (e, t) { return this.copyFromFloats(e, t) }, e.prototype.add = function (e) { return new this.constructor(this.x + e.x, this.y + e.y) }, e.prototype.addToRef = function (e, t) { return t.x = this.x + e.x, t.y = this.y + e.y, t }, e.prototype.addInPlace = function (e) { return this.x += e.x, this.y += e.y, this }, e.prototype.addVector3 = function (e) { return new this.constructor(this.x + e.x, this.y + e.y) }, e.prototype.subtract = function (e) { return new this.constructor(this.x - e.x, this.y - e.y) }, e.prototype.subtractToRef = function (e, t) { return t.x = this.x - e.x, t.y = this.y - e.y, t }, e.prototype.subtractInPlace = function (e) { return this.x -= e.x, this.y -= e.y, this }, e.prototype.multiplyInPlace = function (e) { return this.x *= e.x, this.y *= e.y, this }, e.prototype.multiply = function (e) { return new this.constructor(this.x * e.x, this.y * e.y) }, e.prototype.multiplyToRef = function (e, t) { return t.x = this.x * e.x, t.y = this.y * e.y, t }, e.prototype.multiplyByFloats = function (e, t) { return new this.constructor(this.x * e, this.y * t) }, e.prototype.divide = function (e) { return new this.constructor(this.x / e.x, this.y / e.y) }, e.prototype.divideToRef = function (e, t) { return t.x = this.x / e.x, t.y = this.y / e.y, t }, e.prototype.divideInPlace = function (e) { return this.divideToRef(e, this) }, e.prototype.negate = function () { return new this.constructor(-this.x, -this.y) }, e.prototype.negateInPlace = function () { return this.x *= -1, this.y *= -1, this }, e.prototype.negateToRef = function (e) { return e.copyFromFloats(-1 * this.x, -1 * this.y) }, e.prototype.scaleInPlace = function (e) { return this.x *= e, this.y *= e, this }, e.prototype.scale = function (e) { var t = new this.constructor(0, 0); return this.scaleToRef(e, t), t }, e.prototype.scaleToRef = function (e, t) { return t.x = this.x * e, t.y = this.y * e, t }, e.prototype.scaleAndAddToRef = function (e, t) { return t.x += this.x * e, t.y += this.y * e, t }, e.prototype.equals = function (e) { return e && this.x === e.x && this.y === e.y }, 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) }, e.prototype.floor = function () { return new this.constructor(Math.floor(this.x), Math.floor(this.y)) }, e.prototype.fract = function () { return new this.constructor(this.x - Math.floor(this.x), this.y - Math.floor(this.y)) }, e.prototype.rotateToRef = function (e, t) { var i = Math.cos(e), r = Math.sin(e), n = i * this.x - r * this.y, o = r * this.x + i * this.y; return t.x = n, t.y = o, t }, e.prototype.length = function () { return Math.sqrt(this.x * this.x + this.y * this.y) }, e.prototype.lengthSquared = function () { return this.x * this.x + this.y * this.y }, e.prototype.normalize = function () { return e.NormalizeToRef(this, this), this }, e.prototype.clone = function () { return new this.constructor(this.x, this.y) }, e.Zero = function () { return new e(0, 0) }, e.One = function () { return new e(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)) }, Object.defineProperty(e, "ZeroReadOnly", { get: function () { return e._ZeroReadOnly }, enumerable: !1, configurable: !0 }), e.FromArray = function (t, i) { return void 0 === i && (i = 0), new e(t[i], t[i + 1]) }, e.FromArrayToRef = function (e, t, i) { return i.x = e[t], i.y = e[t + 1], i }, 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); return new e.constructor(s, l) }, e.Clamp = function (e, t, i) { var r = e.x; r = (r = r > i.x ? i.x : r) < t.x ? t.x : r; var n = e.y; return n = (n = n > i.y ? i.y : n) < t.y ? t.y : n, new e.constructor(r, n) }, 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; return new e.constructor(h, d) }, 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 }, e.Lerp = function (e, t, i) { var r = e.x + (t.x - e.x) * i, n = e.y + (t.y - e.y) * i; return new e.constructor(r, n) }, e.Dot = function (e, t) { return e.x * t.x + e.y * t.y }, e.Normalize = function (e) { var t = new e.constructor; return this.NormalizeToRef(e, t), t }, e.NormalizeToRef = function (e, t) { var i = e.length(); return 0 === i || (t.x = e.x / i, t.y = e.y / i), t }, e.Minimize = function (e, t) { var i = e.x < t.x ? e.x : t.x, r = e.y < t.y ? e.y : t.y; return new e.constructor(i, r) }, e.Maximize = function (e, t) { var i = e.x > 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) < Math.pow(10, -10)) r.setAll(1 / 0); else { var l = -(e.Dot(i, n) + o) / s, c = a.scaleInPlace(l); i.addToRef(c, r) } return r }, e.prototype.equals = function (e) { return e && this._x === e._x && this._y === e._y && this._z === e._z }, e.prototype.equalsWithEpsilon = function (e, t) { return void 0 === t && (t = _), e && h.WithinEpsilon(this._x, e._x, t) && h.WithinEpsilon(this._y, e._y, t) && h.WithinEpsilon(this._z, e._z, t) }, e.prototype.equalsToFloats = function (e, t, i) { return this._x === e && this._y === t && this._z === i }, e.prototype.multiplyInPlace = function (e) { return this._x *= e._x, this._y *= e._y, this._z *= e._z, this._isDirty = !0, this }, e.prototype.multiply = function (e) { return this.multiplyByFloats(e._x, e._y, e._z) }, e.prototype.multiplyToRef = function (e, t) { return t.copyFromFloats(this._x * e._x, this._y * e._y, this._z * e._z) }, e.prototype.multiplyByFloats = function (e, t, i) { return new this.constructor(this._x * e, this._y * t, this._z * i) }, e.prototype.divide = function (e) { return new this.constructor(this._x / e._x, this._y / e._y, this._z / e._z) }, e.prototype.divideToRef = function (e, t) { return t.copyFromFloats(this._x / e._x, this._y / e._y, this._z / e._z) }, e.prototype.divideInPlace = function (e) { return this.divideToRef(e, this) }, e.prototype.minimizeInPlace = function (e) { return this.minimizeInPlaceFromFloats(e._x, e._y, e._z) }, e.prototype.maximizeInPlace = function (e) { return this.maximizeInPlaceFromFloats(e._x, e._y, e._z) }, e.prototype.minimizeInPlaceFromFloats = function (e, t, i) { return e < this._x && (this.x = e), t < this._y && (this.y = t), i < this._z && (this.z = i), this }, e.prototype.maximizeInPlaceFromFloats = function (e, t, i) { return e > 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) < t._x ? t._x : n; var o = e._y; o = (o = o > i._y ? i._y : o) < t._y ? t._y : o; var a = e._z; return a = (a = a > i._z ? i._z : a) < t._z ? t._z : a, r.copyFromFloats(n, o, a), r }, e.CheckExtends = function (e, t, i) { t.minimizeInPlace(e), i.maximizeInPlace(e) }, 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; return new e.constructor(h, d, p) }, 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._isDirty = !0, o }, e.Lerp = function (t, i, r) { var n = new t.constructor(0, 0, 0); return e.LerpToRef(t, i, r, n), n }, e.LerpToRef = function (e, t, i, r) { return r._x = e._x + (t._x - e._x) * i, r._y = e._y + (t._y - e._y) * i, r._z = e._z + (t._z - e._z) * i, r._isDirty = !0, r }, e.Dot = function (e, t) { return e._x * t._x + e._y * t._y + e._z * t._z }, e.Cross = function (t, i) { var r = new t.constructor; return e.CrossToRef(t, i, r), r }, e.CrossToRef = function (e, t, i) { var r = e._y * t._z - e._z * t._y, n = e._z * t._x - e._x * t._z, o = e._x * t._y - e._y * t._x; return i.copyFromFloats(r, n, o), i }, e.Normalize = function (t) { var i = e.Zero(); return e.NormalizeToRef(t, i), i }, e.NormalizeToRef = function (e, t) { return e.normalizeToRef(t), t }, e.Project = function (t, i, r, n) { var o = new t.constructor; return e.ProjectToRef(t, i, r, n, o), o }, e.ProjectToRef = function (t, i, r, n, o) { var a = n.width, s = n.height, l = n.x, c = n.y, u = M.Matrix[1]; I.FromValuesToRef(a / 2, 0, 0, 0, 0, -s / 2, 0, 0, 0, 0, .5, 0, l + a / 2, s / 2 + c, .5, 1, u); var h = M.Matrix[0]; return i.multiplyToRef(r, h), h.multiplyToRef(u, h), e.TransformCoordinatesToRef(t, h, o), o }, e.Reflect = function (t, i) { return this.ReflectToRef(t, i, new e) }, e.ReflectToRef = function (t, i, r) { var n = O.Vector3[0]; return n.copyFrom(i).scaleInPlace(2 * e.Dot(t, i)), r.copyFrom(t).subtractInPlace(n) }, e._UnprojectFromInvertedMatrixToRef = function (t, i, r) { e.TransformCoordinatesToRef(t, i, r); var n = i.m, o = t._x * n[3] + t._y * n[7] + t._z * n[11] + n[15]; return h.WithinEpsilon(o, 1) && r.scaleInPlace(1 / o), r }, e.UnprojectFromTransform = function (e, t, i, r, n) { return this.Unproject(e, t, i, r, n, I.IdentityReadOnly) }, e.Unproject = function (t, i, r, n, o, a) { var s = new t.constructor; return e.UnprojectToRef(t, i, r, n, o, a, s), s }, e.UnprojectToRef = function (t, i, r, n, o, a, s) { return e.UnprojectFloatsToRef(t._x, t._y, t._z, i, r, n, o, a, s), s }, e.UnprojectFloatsToRef = function (t, i, r, n, o, a, s, l, c) { var u, h = M.Matrix[0]; a.multiplyToRef(s, h), h.multiplyToRef(l, h), h.invert(); var d = M.Vector3[0]; return d.x = t / n * 2 - 1, d.y = -(i / o * 2 - 1), (null === (u = S.LastCreatedEngine) || void 0 === u ? void 0 : u.isNDCHalfZRange) ? d.z = r : d.z = 2 * r - 1, e._UnprojectFromInvertedMatrixToRef(d, h, c), c }, 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; return i * i + r * r + n * n }, e.ProjectOnTriangleToRef = function (t, i, r, n, o) { var a = M.Vector3[0], s = M.Vector3[1], l = M.Vector3[2], c = M.Vector3[3], u = M.Vector3[4]; r.subtractToRef(i, a), n.subtractToRef(i, s), n.subtractToRef(r, l); var d = a.length(), p = s.length(), f = l.length(); if (d < _ || p < _ || f < _) return o.copyFrom(i), e.Distance(t, i); t.subtractToRef(i, u), e.CrossToRef(a, s, c); var m = c.length(); if (m < _) return o.copyFrom(i), e.Distance(t, i); c.normalizeFromLength(m); var g = u.length(); if (g < _) return o.copyFrom(i), 0; u.normalizeFromLength(g); var v = e.Dot(c, u), y = M.Vector3[5], b = M.Vector3[6]; y.copyFrom(c).scaleInPlace(-g * v), b.copyFrom(t).addInPlace(y); var T = M.Vector3[4], E = M.Vector3[5], S = M.Vector3[7], x = M.Vector3[8]; T.copyFrom(a).scaleInPlace(1 / d), x.copyFrom(s).scaleInPlace(1 / p), T.addInPlace(x).scaleInPlace(-1), E.copyFrom(a).scaleInPlace(-1 / d), x.copyFrom(l).scaleInPlace(1 / f), E.addInPlace(x).scaleInPlace(-1), S.copyFrom(l).scaleInPlace(-1 / f), x.copyFrom(s).scaleInPlace(-1 / p), S.addInPlace(x).scaleInPlace(-1); var A = M.Vector3[9]; A.copyFrom(b).subtractInPlace(i), e.CrossToRef(T, A, x); var R = e.Dot(x, c); A.copyFrom(b).subtractInPlace(r), e.CrossToRef(E, A, x); var C = e.Dot(x, c); A.copyFrom(b).subtractInPlace(n), e.CrossToRef(S, A, x); var P, I, O = e.Dot(x, c), D = M.Vector3[10]; R > 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.x < this.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.maximizeInPlace = function (e) { return e.x > this.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 n < r ? Math.abs(e.x) > Math.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.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.scaling.x < 0 ? -1 : 1, s = n.scaling.y < 0 ? -1 : 1, l = n.scaling.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) { var r = R.Dot(t, e), n = i._m; if (r < -1 + _) n[0] = -1, n[1] = 0, n[2] = 0, n[3] = 0, n[4] = 0, n[5] = -1, n[6] = 0, n[7] = 0, n[8] = 0, n[9] = 0, n[10] = 1, n[11] = 0; else { var o = R.Cross(t, e), a = 1 / (1 + r); n[0] = o._x * o._x * a + r, n[1] = o._y * o._x * a - o._z, n[2] = o._z * o._x * a + o._y, n[3] = 0, n[4] = o._x * o._y * a + o._z, n[5] = o._y * o._y * a + r, n[6] = o._z * o._y * a - o._x, n[7] = 0, n[8] = o._x * o._z * a - o._y, n[9] = o._y * o._z * a + o._x, n[10] = o._z * o._z * a + r, n[11] = 0 } return n[12] = 0, n[13] = 0, n[14] = 0, n[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.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.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.PerspectiveFovWebVRToRef = function (e, t, i, r, n, o, a) { void 0 === n && (n = !1), void 0 === a && (a = 0); var s = n ? -1 : 1, l = Math.tan(e.upDegrees * Math.PI / 180), c = Math.tan(e.downDegrees * Math.PI / 180), u = Math.tan(e.leftDegrees * Math.PI / 180), h = Math.tan(e.rightDegrees * Math.PI / 180), d = 2 / (u + h), p = 2 / (l + c), f = Math.tan(a), _ = r._m; return _[0] = d, _[1] = _[2] = _[3] = _[4] = 0, _[5] = p, _[6] = 0, _[7] = f, _[8] = (u - h) * d * .5, _[9] = -(l - c) * p * .5, _[10] = -i / (t - i), _[11] = 1 * s, _[12] = _[13] = _[15] = 0, _[14] = -2 * i * t / (i - t), o && r.multiplyToRef(D, r), r.markAsUpdated(), r }, 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 = t._m, r = e.m; return i[0] = r[0], i[1] = r[4], i[2] = r[8], i[3] = r[12], i[4] = r[1], i[5] = r[5], i[6] = r[9], i[7] = r[13], i[8] = r[2], i[9] = r[6], i[10] = r[10], i[11] = r[14], i[12] = r[3], i[13] = r[7], i[14] = r[11], i[15] = r[15], 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 < r && (a += 6)) : n == i ? a = (r - t) / c + 2 : n == r && (a = (t - i) / c + 4), a *= 60), e.r = a, e.g = s, e.b = l }, 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)), 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)), this }, e.HSVtoRGBToRef = function (e, t, i, r) { var n = i * t, o = e / 60, a = n * (1 - Math.abs(o % 2 - 1)), s = 0, l = 0, c = 0; o >= 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 < e.length; r += 3) { var n = r / 3 * 4; i[n] = e[r], i[n + 1] = e[r + 1], i[n + 2] = e[r + 2], i[n + 3] = 1 } return i } return e }, e }(), V = function () { function e() { } return e.Color3 = m.BuildArray(3, B.Black), e.Color4 = m.BuildArray(3, (function () { return new U(0, 0, 0, 0) })), e }(); b("BABYLON.Color3", B), b("BABYLON.Color4", U); var k = function () { function e(e, t) { this.triggerOptions = e, this.onBeforeExecuteObservable = new u, e.parameter ? (this.trigger = e.trigger, this._triggerParameter = e.parameter) : e.trigger ? this.trigger = e.trigger : this.trigger = e, this._nextActiveAction = this, this._condition = t } return e.prototype._prepare = function () { }, e.prototype.getTriggerParameter = function () { return this._triggerParameter }, e.prototype.setTriggerParameter = function (e) { this._triggerParameter = e }, e.prototype._evaluateConditionForCurrentFrame = function () { var e = this._condition; if (!e) return !0; var t = this._actionManager.getScene().getRenderId(); return e._evaluationId !== t && (e._evaluationId = t, e._currentResult = e.isValid()), e._currentResult }, e.prototype._executeCurrent = function (e) { this._evaluateConditionForCurrentFrame() && (this.onBeforeExecuteObservable.notifyObservers(this), this._nextActiveAction.execute(e), this.skipToNextActiveAction()) }, e.prototype.execute = function (e) { }, e.prototype.skipToNextActiveAction = function () { this._nextActiveAction._child ? (this._nextActiveAction._child._actionManager || (this._nextActiveAction._child._actionManager = this._actionManager), this._nextActiveAction = this._nextActiveAction._child) : this._nextActiveAction = this }, e.prototype.then = function (e) { return this._child = e, e._actionManager = this._actionManager, e._prepare(), e }, e.prototype._getProperty = function (e) { return this._actionManager._getProperty(e) }, e.prototype._getEffectiveTarget = function (e, t) { return this._actionManager._getEffectiveTarget(e, t) }, e.prototype.serialize = function (e) { }, e.prototype._serialize = function (e, t) { var i = { type: 1, children: [], name: e.name, properties: e.properties || [] }; if (this._child && this._child.serialize(i), this._condition) { var r = this._condition.serialize(); return r.children.push(i), t && t.children.push(r), r } return t && t.children.push(i), i }, e._SerializeValueAsString = function (e) { return "number" == typeof e ? e.toString() : "boolean" == typeof e ? e ? "true" : "false" : e instanceof A ? e.x + ", " + e.y : e instanceof R ? e.x + ", " + e.y + ", " + e.z : e instanceof B ? e.r + ", " + e.g + ", " + e.b : e instanceof U ? e.r + ", " + e.g + ", " + e.b + ", " + e.a : e }, e._GetTargetProperty = function (e) { return { name: "target", targetType: e._isMesh ? "MeshProperties" : e._isLight ? "LightProperties" : e._isCamera ? "CameraProperties" : e._isMaterial ? "MaterialProperties" : "SceneProperties", value: e._isScene ? "Scene" : e.name } }, e }(); b("BABYLON.Action", k); var G = function () { function e(e, t, i, r, n, o) { this.source = e, this.pointerX = t, this.pointerY = i, this.meshUnderPointer = r, this.sourceEvent = n, this.additionalData = o } return e.CreateNew = function (t, i, r) { var n = t.getScene(); return new e(t, n.pointerX, n.pointerY, n.meshUnderPointer || t, i, r) }, e.CreateNewFromSprite = function (t, i, r, n) { return new e(t, i.pointerX, i.pointerY, i.meshUnderPointer, r, n) }, e.CreateNewFromScene = function (t, i) { return new e(null, t.pointerX, t.pointerY, t.meshUnderPointer, i) }, e.CreateNewFromPrimitive = function (t, i, r, n) { return new e(t, i.x, i.y, null, r, n) }, e }(), z = function (e, t) { return z = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (e, t) { e.__proto__ = t } || function (e, t) { for (var i in t) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]) }, z(e, t) }; function W(e, t) { if ("function" != typeof t && null !== t) throw new TypeError("Class extends value " + String(t) + " is not a constructor or null"); function i() { this.constructor = e } z(e, t), e.prototype = null === t ? Object.create(t) : (i.prototype = t.prototype, new i) } var H = function () { return H = Object.assign || function (e) { for (var t, i = 1, r = arguments.length; i < r; i++)for (var n in t = arguments[i]) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]); return e }, H.apply(this, arguments) }; function X(e, t, i, r) { var n, o = arguments.length, a = o < 3 ? t : null === r ? r = Object.getOwnPropertyDescriptor(t, i) : r; if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) a = Reflect.decorate(e, t, i, r); else for (var s = e.length - 1; s >= 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] < n[3])) { a.label = s[1]; break } if (6 === s[0] && a.label < n[1]) { a.label = n[1], n = s; break } if (n && a.label < n[2]) { a.label = n[2], a.ops.push(s); break } n[2] && a.ops.pop(), a.trys.pop(); continue }s = t.call(e, a) } catch (e) { s = [6, e], r = 0 } finally { i = n = 0 } if (5 & s[0]) throw s[1]; return { value: s[0] ? s[1] : void 0, done: !0 } }([s, l]) } } } function K(e, t, i) { if (i || 2 === arguments.length) for (var r, n = 0, o = t.length; n < o; n++)!r && n in t || (r || (r = Array.prototype.slice.call(t, 0, n)), r[n] = t[n]); return e.concat(r || Array.prototype.slice.call(t)) } Object.create, Object.create, "function" == typeof SuppressedError && SuppressedError; var Q = function () { function e(e) { this._actionManager = e } return e.prototype.isValid = function () { return !0 }, e.prototype._getProperty = function (e) { return this._actionManager._getProperty(e) }, e.prototype._getEffectiveTarget = function (e, t) { return this._actionManager._getEffectiveTarget(e, t) }, e.prototype.serialize = function () { }, e.prototype._serialize = function (e) { return { type: 2, children: [], name: e.name, properties: e.properties } }, e }(), q = function (e) { function t(i, r, n, o, a) { void 0 === a && (a = t.IsEqual); var s = e.call(this, i) || this; return s.propertyPath = n, s.value = o, s.operator = a, s._target = r, s._effectiveTarget = s._getEffectiveTarget(r, s.propertyPath), s._property = s._getProperty(s.propertyPath), s } return W(t, e), Object.defineProperty(t, "IsEqual", { get: function () { return t._IsEqual }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "IsDifferent", { get: function () { return t._IsDifferent }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "IsGreater", { get: function () { return t._IsGreater }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "IsLesser", { get: function () { return t._IsLesser }, enumerable: !1, configurable: !0 }), t.prototype.isValid = function () { switch (this.operator) { case t.IsGreater: return this._effectiveTarget[this._property] > this.value; case t.IsLesser: return this._effectiveTarget[this._property] < this.value; case t.IsEqual: case t.IsDifferent: var e; return e = this.value.equals ? this.value.equals(this._effectiveTarget[this._property]) : this.value === this._effectiveTarget[this._property], this.operator === t.IsEqual ? e : !e }return !1 }, t.prototype.serialize = function () { return this._serialize({ name: "ValueCondition", properties: [k._GetTargetProperty(this._target), { name: "propertyPath", value: this.propertyPath }, { name: "value", value: k._SerializeValueAsString(this.value) }, { name: "operator", value: t.GetOperatorName(this.operator) }] }) }, t.GetOperatorName = function (e) { switch (e) { case t._IsEqual: return "IsEqual"; case t._IsDifferent: return "IsDifferent"; case t._IsGreater: return "IsGreater"; case t._IsLesser: return "IsLesser"; default: return "" } }, t._IsEqual = 0, t._IsDifferent = 1, t._IsGreater = 2, t._IsLesser = 3, t }(Q), Z = function (e) { function t(t, i) { var r = e.call(this, t) || this; return r.predicate = i, r } return W(t, e), t.prototype.isValid = function () { return this.predicate() }, t }(Q), J = function (e) { function t(t, i, r) { var n = e.call(this, t) || this; return n.value = r, n._target = i, n } return W(t, e), t.prototype.isValid = function () { return this._target.state === this.value }, t.prototype.serialize = function () { return this._serialize({ name: "StateCondition", properties: [k._GetTargetProperty(this._target), { name: "value", value: this.value }] }) }, t }(Q); b("BABYLON.ValueCondition", q), b("BABYLON.PredicateCondition", Z), b("BABYLON.StateCondition", J); var $ = function () { function e() { } return e._CheckLimit = function (t, i) { var r = e._LogLimitOutputs[t]; return r ? r.current++ : (r = { limit: i, current: 1 }, e._LogLimitOutputs[t] = r), r.current <= r.limit }, e._GenerateLimitMessage = function (t, i) { var r; void 0 === i && (i = 1); var n = e._LogLimitOutputs[t]; if (n && e.MessageLimitReached) { var o = this._Levels[i]; n.current === n.limit && e[o.name](e.MessageLimitReached.replace(/%LIMIT%/g, "" + n.limit).replace(/%TYPE%/g, null !== (r = o.name) && void 0 !== r ? r : "")) } }, e._AddLogEntry = function (t) { e._LogCache = t + e._LogCache, e.OnNewCacheEntry && e.OnNewCacheEntry(t) }, e._FormatMessage = function (e) { var t = function (e) { return e < 10 ? "0" + e : "" + e }, i = new Date; return "[" + t(i.getHours()) + ":" + t(i.getMinutes()) + ":" + t(i.getSeconds()) + "]: " + e }, e._LogDisabled = function (e, t) { }, e._LogEnabled = function (t, i, r) { if (void 0 === t && (t = 1), void 0 === r || e._CheckLimit(i, r)) { var n = e._FormatMessage(i), o = this._Levels[t]; o.logFunc && o.logFunc("BJS - " + n); var a = "
").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; e < this.children.length; e++)this.children[e]._actionManager = this._actionManager, this.children[e]._prepare() }, t.prototype.execute = function (e) { for (var t = 0, i = this.children; t < i.length; t++) { var r = i[t]; this.enableChildrenConditions && !r._evaluateConditionForCurrentFrame() || r.execute(e) } }, t.prototype.serialize = function (t) { for (var i = e.prototype._serialize.call(this, { name: "CombineAction", properties: [], combine: [] }, t), r = 0; r < this.children.length; r++)i.combine.push(this.children[r].serialize(null)); return i }, t }(k), le = function (e) { function t(t, i, r) { var n = e.call(this, t, r) || this; return n.func = i, n } return W(t, e), t.prototype.execute = function (e) { this.func(e) }, t }(k), ce = function (e) { function t(t, i, r, n) { var o = e.call(this, t, n) || this; return o._target = i, o._parent = r, o } return W(t, e), t.prototype._prepare = function () { }, t.prototype.execute = function () { if (this._target.parent !== this._parent) { var e = this._parent.getWorldMatrix().clone(); e.invert(), this._target.position = R.TransformCoordinates(this._target.position, e), this._target.parent = this._parent } }, t.prototype.serialize = function (t) { return e.prototype._serialize.call(this, { name: "SetParentAction", properties: [k._GetTargetProperty(this._target), k._GetTargetProperty(this._parent)] }, t) }, t }(k); b("BABYLON.SetParentAction", ce), b("BABYLON.ExecuteCodeAction", le), b("BABYLON.DoNothingAction", ae), b("BABYLON.StopAnimationAction", oe), b("BABYLON.PlayAnimationAction", ne), b("BABYLON.IncrementValueAction", re), b("BABYLON.SetValueAction", ie), b("BABYLON.SetStateAction", te), b("BABYLON.SetParentAction", ce), b("BABYLON.SwitchBooleanAction", ee), b("BABYLON.CombineAction", se); var ue = function (e, t) { return e ? e.getClassName && "Mesh" === e.getClassName() ? null : !e.getClassName || "SubMesh" !== e.getClassName() && "PhysicsBody" !== e.getClassName() ? e.clone ? e.clone() : Array.isArray(e) ? e.slice() : null : e.clone(t) : null }, he = function () { function e() { } return e.DeepCopy = function (e, t, i, r) { for (var n = function (e) { var t = []; do { Object.getOwnPropertyNames(e).forEach((function (e) { -1 === t.indexOf(e) && t.push(e) })) } while (e = Object.getPrototypeOf(e)); return t }(e), o = 0, a = n; o < a.length; o++) { var s = a[o]; if (("_" !== s[0] || r && -1 !== r.indexOf(s)) && !(s.endsWith("Observable") || i && -1 !== i.indexOf(s))) { var l = e[s], c = typeof l; if ("function" !== c) try { if ("object" === c) if (l instanceof Uint8Array) t[s] = Uint8Array.from(l); else if (l instanceof Array) { if (t[s] = [], l.length > 0) if ("object" == typeof l[0]) for (var u = 0; u < l.length; u++) { var h = ue(l[u], t); -1 === t[s].indexOf(h) && t[s].push(h) } else t[s] = l.slice(0) } else t[s] = ue(l, t); else t[s] = l } catch (e) { $.Warn(e.message) } } } }, e }(), de = function (e) { function t(t) { var i = e.call(this) || this; return (t = t || S.LastCreatedScene) ? (i._scene = t, t.actionManagers.push(i), i) : i } return W(t, e), t.prototype.dispose = function () { for (var e = this, i = this._scene.actionManagers.indexOf(this), r = 0; r < this.actions.length; r++) { var n = this.actions[r]; t.Triggers[n.trigger]--, 0 === t.Triggers[n.trigger] && delete t.Triggers[n.trigger] } this.actions.length = 0, i > -1 && this._scene.actionManagers.splice(i, 1); var o = this._scene.meshes.find((function (t) { return t.actionManager === e })); o && (o.actionManager = null) }, t.prototype.getScene = function () { return this._scene }, t.prototype.hasSpecificTriggers = function (e) { for (var t = 0; t < this.actions.length; t++) { var i = this.actions[t]; if (e.indexOf(i.trigger) > -1) return !0 } return !1 }, t.prototype.hasSpecificTriggers2 = function (e, t) { for (var i = 0; i < this.actions.length; i++) { var r = this.actions[i]; if (e == r.trigger || t == r.trigger) return !0 } return !1 }, t.prototype.hasSpecificTrigger = function (e, t) { for (var i = 0; i < this.actions.length; i++) { var r = this.actions[i]; if (r.trigger === e) { if (!t) return !0; if (t(r.getTriggerParameter())) return !0 } } return !1 }, Object.defineProperty(t.prototype, "hasPointerTriggers", { get: function () { for (var e = 0; e < this.actions.length; e++) { var i = this.actions[e]; if (i.trigger >= 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 < this.actions.length; e++) { var i = this.actions[e]; if (i.trigger >= 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; r < this.actions.length; r++) { var n = this.actions[r]; if (n.trigger === e) { if (i && (e === t.OnKeyUpTrigger || e === t.OnKeyDownTrigger)) { var o = n.getTriggerParameter(); if ("function" == typeof o) { if (!o(i)) continue } else if (o && o !== i.sourceEvent.keyCode) { if (!o.toLowerCase) continue; var a = o.toLowerCase(); if (a !== i.sourceEvent.key) { var s = i.sourceEvent.charCode ? i.sourceEvent.charCode : i.sourceEvent.keyCode; if (String.fromCharCode(s).toLowerCase() !== a) continue } } } n._executeCurrent(i) } } }, t.prototype._getEffectiveTarget = function (e, t) { for (var i = t.split("."), r = 0; r < i.length - 1; r++)e = e[i[r]]; return e }, t.prototype._getProperty = function (e) { var t = e.split("."); return t[t.length - 1] }, t.prototype.serialize = function (e) { for (var i = { children: new Array, name: e, type: 3, properties: new Array }, r = 0; r < this.actions.length; r++) { var n = { type: 0, children: new Array, name: t.GetTriggerName(this.actions[r].trigger), properties: new Array }, o = this.actions[r].triggerOptions; if (o && "number" != typeof o) if (o.parameter instanceof Node) n.properties.push(k._GetTargetProperty(o.parameter)); else if ("object" == typeof o.parameter) { var a = {}; he.DeepCopy(o.parameter, a, ["mesh"]), o.parameter && o.parameter.mesh && (a._meshId = o.parameter.mesh.id), n.properties.push({ name: "parameter", targetType: null, value: a }) } else n.properties.push({ name: "parameter", targetType: null, value: o.parameter }); this.actions[r].serialize(n), i.children.push(n) } return i }, t.Parse = function (e, i, r) { var n = new t(r); null === i ? r.actionManager = n : i.actionManager = n; for (var o = function (e, t, i, r) { if (null === r) { var n = parseFloat(t); return "true" === t || "false" === t ? "true" === t : isNaN(n) ? t : n } for (var o = r.split("."), a = t.split(","), s = 0; s < o.length; s++)i = i[o[s]]; if ("boolean" == typeof i) return "true" === a[0]; if ("string" == typeof i) return a[0]; var l = new Array; for (s = 0; s < a.length; s++)l.push(parseFloat(a[s])); return i instanceof R ? R.FromArray(l) : i instanceof C ? C.FromArray(l) : i instanceof B ? B.FromArray(l) : i instanceof U ? U.FromArray(l) : parseFloat(a[0]) }, a = function (e, i, s, l, c) { if (void 0 === c && (c = null), !e.detached) { var u = new Array, h = null, d = null, p = e.combine && e.combine.length > 0; if (2 === e.type ? u.push(n) : u.push(i), p) { for (var f = new Array, _ = 0; _ < e.combine.length; _++)a(e.combine[_], t.NothingTrigger, s, l, f); u.push(f) } else for (var m = 0; m < e.properties.length; m++) { var g = e.properties[m].value, v = e.properties[m].name, y = e.properties[m].targetType; "target" === v ? g = h = "SceneProperties" === y ? r : "MaterialProperties" === y ? r.getMaterialByName(g) : r.getNodeByName(g) : "parent" === v ? g = r.getNodeByName(g) : "sound" === v ? r.getSoundByName && (g = r.getSoundByName(g)) : "propertyPath" !== v ? g = 2 === e.type && "operator" === v ? q[g] : o(0, g, h, "value" === v ? d : null) : d = g, u.push(g) } if (null === c ? u.push(s) : u.push(null), "InterpolateValueAction" === e.name) { var b = u[u.length - 2]; u[u.length - 1] = b, u[u.length - 2] = s } var E, S, x = (E = u, (S = T("BABYLON." + e.name)) && new (S.bind.apply(S, K([void 0], E, !1)))); if (x instanceof Q && null !== s) { var A = new ae(i, s); l ? l.then(A) : n.registerAction(A), l = A } for (null === c ? x instanceof Q ? (s = x, x = l) : (s = null, l ? l.then(x) : n.registerAction(x)) : c.push(x), m = 0; m < e.children.length; m++)a(e.children[m], i, s, x, null) } }, s = 0; s < e.children.length; s++) { var l = void 0, c = e.children[s]; if (c.properties.length > 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; d < c.children.length; d++)c.detached || a(c.children[d], l, null, null) } }, t.GetTriggerName = function (e) { switch (e) { case a.ACTION_NothingTrigger: return "NothingTrigger"; case a.ACTION_OnPickTrigger: return "OnPickTrigger"; case a.ACTION_OnLeftPickTrigger: return "OnLeftPickTrigger"; case a.ACTION_OnRightPickTrigger: return "OnRightPickTrigger"; case a.ACTION_OnCenterPickTrigger: return "OnCenterPickTrigger"; case a.ACTION_OnPickDownTrigger: return "OnPickDownTrigger"; case a.ACTION_OnDoublePickTrigger: return "OnDoublePickTrigger"; case a.ACTION_OnPickUpTrigger: return "OnPickUpTrigger"; case a.ACTION_OnLongPressTrigger: return "OnLongPressTrigger"; case a.ACTION_OnPointerOverTrigger: return "OnPointerOverTrigger"; case a.ACTION_OnPointerOutTrigger: return "OnPointerOutTrigger"; case a.ACTION_OnEveryFrameTrigger: return "OnEveryFrameTrigger"; case a.ACTION_OnIntersectionEnterTrigger: return "OnIntersectionEnterTrigger"; case a.ACTION_OnIntersectionExitTrigger: return "OnIntersectionExitTrigger"; case a.ACTION_OnKeyDownTrigger: return "OnKeyDownTrigger"; case a.ACTION_OnKeyUpTrigger: return "OnKeyUpTrigger"; case a.ACTION_OnPickOutTrigger: return "OnPickOutTrigger"; default: return "" } }, t.NothingTrigger = a.ACTION_NothingTrigger, t.OnPickTrigger = a.ACTION_OnPickTrigger, t.OnLeftPickTrigger = a.ACTION_OnLeftPickTrigger, t.OnRightPickTrigger = a.ACTION_OnRightPickTrigger, t.OnCenterPickTrigger = a.ACTION_OnCenterPickTrigger, t.OnPickDownTrigger = a.ACTION_OnPickDownTrigger, t.OnDoublePickTrigger = a.ACTION_OnDoublePickTrigger, t.OnPickUpTrigger = a.ACTION_OnPickUpTrigger, t.OnPickOutTrigger = a.ACTION_OnPickOutTrigger, t.OnLongPressTrigger = a.ACTION_OnLongPressTrigger, t.OnPointerOverTrigger = a.ACTION_OnPointerOverTrigger, t.OnPointerOutTrigger = a.ACTION_OnPointerOutTrigger, t.OnEveryFrameTrigger = a.ACTION_OnEveryFrameTrigger, t.OnIntersectionEnterTrigger = a.ACTION_OnIntersectionEnterTrigger, t.OnIntersectionExitTrigger = a.ACTION_OnIntersectionExitTrigger, t.OnKeyDownTrigger = a.ACTION_OnKeyDownTrigger, t.OnKeyUpTrigger = a.ACTION_OnKeyUpTrigger, t }(s), pe = function (e) { function t(t, i, r) { var n = e.call(this, t, r) || this; return n._sound = i, n } return W(t, e), t.prototype._prepare = function () { }, t.prototype.execute = function () { void 0 !== this._sound && this._sound.play() }, t.prototype.serialize = function (t) { return e.prototype._serialize.call(this, { name: "PlaySoundAction", properties: [{ name: "sound", value: this._sound.name }] }, t) }, t }(k), fe = function (e) { function t(t, i, r) { var n = e.call(this, t, r) || this; return n._sound = i, n } return W(t, e), t.prototype._prepare = function () { }, t.prototype.execute = function () { void 0 !== this._sound && this._sound.stop() }, t.prototype.serialize = function (t) { return e.prototype._serialize.call(this, { name: "StopSoundAction", properties: [{ name: "sound", value: this._sound.name }] }, t) }, t }(k); b("BABYLON.PlaySoundAction", pe), b("BABYLON.StopSoundAction", fe); var _e = function () { function e() { } return e.Eval = function (t, i) { return "true" === (t = t.match(/\([^()]*\)/g) ? t.replace(/\([^()]*\)/g, (function (t) { return t = t.slice(1, t.length - 1), e._HandleParenthesisContent(t, i) })) : e._HandleParenthesisContent(t, i)) || "false" !== t && e.Eval(t, i) }, e._HandleParenthesisContent = function (t, i) { var r; i = i || function (e) { return "true" === e }; var n = t.split("||"); for (var o in n) if (Object.prototype.hasOwnProperty.call(n, o)) { var a = e._SimplifyNegation(n[o].trim()), s = a.split("&&"); if (s.length > 1) for (var l = 0; l < s.length; ++l) { var c = e._SimplifyNegation(s[l].trim()); if (!(r = "true" !== c && "false" !== c ? "!" === c[0] ? !i(c.substring(1)) : i(c) : "true" === c)) { a = "false"; break } } if (r || "true" === a) { r = !0; break } r = "true" !== a && "false" !== a ? "!" === a[0] ? !i(a.substring(1)) : i(a) : "true" === a } return r ? "true" : "false" }, e._SimplifyNegation = function (e) { return "!true" === (e = (e = e.replace(/^[\s!]+/, (function (e) { return (e = e.replace(/[\s]/g, (function () { return "" }))).length % 2 ? "!" : "" }))).trim()) ? e = "false" : "!false" === e && (e = "true"), e }, e }(), me = function () { function e() { } return e.EnableFor = function (t) { t._tags = t._tags || {}, t.hasTags = function () { return e.HasTags(t) }, t.addTags = function (i) { return e.AddTagsTo(t, i) }, t.removeTags = function (i) { return e.RemoveTagsFrom(t, i) }, t.matchesTagsQuery = function (i) { return e.MatchesQuery(t, i) } }, e.DisableFor = function (e) { delete e._tags, delete e.hasTags, delete e.addTags, delete e.removeTags, delete e.matchesTagsQuery }, e.HasTags = function (e) { if (!e._tags) return !1; var t = e._tags; for (var i in t) if (Object.prototype.hasOwnProperty.call(t, i)) return !0; return !1 }, e.GetTags = function (e, t) { if (void 0 === t && (t = !0), !e._tags) return null; if (t) { var i = []; for (var r in e._tags) Object.prototype.hasOwnProperty.call(e._tags, r) && !0 === e._tags[r] && i.push(r); return i.join(" ") } return e._tags }, e.AddTagsTo = function (t, i) { i && "string" == typeof i && i.split(" ").forEach((function (i) { e._AddTagTo(t, i) })) }, e._AddTagTo = function (t, i) { "" !== (i = i.trim()) && "true" !== i && "false" !== i && (i.match(/[\s]/) || i.match(/^([!]|([|]|[&]){2})/) || (e.EnableFor(t), t._tags[i] = !0)) }, e.RemoveTagsFrom = function (t, i) { if (e.HasTags(t)) { var r = i.split(" "); for (var n in r) e._RemoveTagFrom(t, r[n]) } }, e._RemoveTagFrom = function (e, t) { delete e._tags[t] }, e.MatchesQuery = function (t, i) { return void 0 === i || ("" === i ? e.HasTags(t) : _e.Eval(i, (function (i) { return e.HasTags(t) && t._tags[i] }))) }, e }(); function ge(e) { return "".concat(e, " needs to be imported before as it contains a side-effect required by your code.") } var ve = {}, ye = {}, be = function (e, t, i, r) { void 0 === r && (r = {}); var n = e(); me && me.HasTags(t) && me.AddTagsTo(n, me.GetTags(t, !0)); var o = Te(n), a = {}; for (var s in o) { var l = o[s], c = t[s], u = l.type; if (null != c && ("uniqueId" !== s || Ue.AllowLoadingUniqueId)) switch (u) { case 0: case 6: case 11: n[s] = c; break; case 1: r.cloneTexturesOnlyOnce && a[c.uniqueId] ? n[s] = a[c.uniqueId] : (n[s] = i || c.isRenderTarget ? c : c.clone(), a[c.uniqueId] = n[s]); break; case 2: case 3: case 4: case 5: case 7: case 10: case 12: n[s] = i ? c : c.clone() } } return n }; function Te(e) { var t = e.getClassName(); if (ye[t]) return ye[t]; ye[t] = {}; for (var i = ye[t], r = e, n = t; n;) { var o = ve[n]; for (var a in o) i[a] = o[a]; var s = void 0, l = !1; do { if (!(s = Object.getPrototypeOf(r)).getClassName) { l = !0; break } if (s.getClassName() !== n) break; r = s } while (s); if (l) break; n = s.getClassName(), r = s } return i } function Ee(e, t) { return function (i, r) { var n = function (e) { var t = e.getClassName(); return ve[t] || (ve[t] = {}), ve[t] }(i); n[r] || (n[r] = { type: e, sourceName: t }) } } function Se(e, t) { return void 0 === t && (t = null), function (e, t) { return void 0 === t && (t = null), function (i, r) { var n = t || "_" + r; Object.defineProperty(i, r, { get: function () { return this[n] }, set: function (t) { "function" == typeof this.equals && this.equals(t) || this[n] !== t && (this[n] = t, i[e].apply(this)) }, enumerable: !0, configurable: !0 }) } }(e, t) } function xe(e) { return Ee(0, e) } function Ae(e) { return Ee(1, e) } function Re(e) { return Ee(2, e) } function Ce(e) { return Ee(3, e) } function Pe(e) { return Ee(4, e) } function Ie(e) { return Ee(5, e) } function Me(e) { return Ee(6, e) } function Oe(e) { return Ee(7, e) } function De(e) { return Ee(8, e) } function Ne(e) { return Ee(9, e) } function Fe(e) { return Ee(10, e) } function Le(e) { return Ee(12, e) } function we(e) { return Ee(11, e) } var Be, Ue = function () { function e() { } return e.AppendSerializedAnimations = function (e, t) { if (e.animations) { t.animations = []; for (var i = 0; i < e.animations.length; i++) { var r = e.animations[i]; t.animations.push(r.serialize()) } } }, e.Serialize = function (t, i) { i || (i = {}), me && (i.tags = me.GetTags(t)); var r = Te(t); for (var n in r) { var o = r[n], a = o.sourceName || n, s = o.type, l = t[n]; if (null != l && ("uniqueId" !== n || e.AllowLoadingUniqueId)) switch (s) { case 0: i[a] = l; break; case 1: case 3: case 7: case 9: i[a] = l.serialize(); break; case 2: case 4: case 5: case 8: case 10: case 12: i[a] = l.asArray(); break; case 6: case 11: i[a] = l.id } } return i }, e.ParseProperties = function (t, i, r, n) { n || (n = ""); var o = Te(i); for (var a in o) { var s = o[a], l = t[s.sourceName || a], c = s.type; if (null != l && ("uniqueId" !== a || e.AllowLoadingUniqueId)) { var u = i; switch (c) { case 0: u[a] = l; break; case 1: r && (u[a] = e._TextureParser(l, r, n)); break; case 2: u[a] = B.FromArray(l); break; case 3: u[a] = e._FresnelParametersParser(l); break; case 4: u[a] = A.FromArray(l); break; case 5: u[a] = R.FromArray(l); break; case 6: r && (u[a] = r.getLastMeshById(l)); break; case 7: u[a] = e._ColorCurvesParser(l); break; case 8: u[a] = U.FromArray(l); break; case 9: u[a] = e._ImageProcessingConfigurationParser(l); break; case 10: u[a] = P.FromArray(l); break; case 11: r && (u[a] = r.getCameraById(l)); break; case 12: u[a] = I.FromArray(l) } } } }, e.Parse = function (t, i, r, n) { void 0 === n && (n = null); var o = t(); return me && me.AddTagsTo(o, i.tags), e.ParseProperties(i, o, r, n), o }, e.Clone = function (e, t, i) { return void 0 === i && (i = {}), be(e, t, !1, i) }, e.Instanciate = function (e, t) { return be(e, t, !0) }, e.AllowLoadingUniqueId = !1, e._ImageProcessingConfigurationParser = function (e) { throw ge("ImageProcessingConfiguration") }, e._FresnelParametersParser = function (e) { throw ge("FresnelParameters") }, e._ColorCurvesParser = function (e) { throw ge("ColorCurves") }, e._TextureParser = function (e, t, i) { throw ge("Texture") }, e }(); function Ve(e, t, i, r) { var n = i.value; i.value = function () { for (var i = [], o = 0; o < arguments.length; o++)i[o] = arguments[o]; var a = n; if ("undefined" != typeof _native && _native[t]) { var s = _native[t]; a = r ? function () { for (var e = [], t = 0; t < arguments.length; t++)e[t] = arguments[t]; return r.apply(void 0, e) ? s.apply(void 0, e) : n.apply(void 0, e) } : s } return e[t] = a, a.apply(void 0, i) } } Ve.filter = function (e) { return function (t, i, r) { return Ve(t, i, r, e) } }, function (e) { e[e.NONE = 0] = "NONE", e[e.STEP = 1] = "STEP" }(Be || (Be = {})); var ke = function () { function e(e, t, i) { this.name = e, this.from = t, this.to = i } return e.prototype.clone = function () { return new e(this.name, this.from, this.to) }, e }(), Ge = function () { this._doNotSerialize = !1, this._isDisposed = !1, this._sceneRootNodesIndex = -1, this._isEnabled = !0, this._isParentEnabled = !0, this._isReady = !0, this._onEnabledStateChangedObservable = new u, this._onClonedObservable = new u }, ze = function () { function e(e, t) { void 0 === t && (t = null), this._isDirty = !1, this._nodeDataStorage = new Ge, this.state = "", this.metadata = null, this.reservedDataStore = null, this._accessibilityTag = null, this.onAccessibilityTagChangedObservable = new u, this._parentContainer = null, this.animations = new Array, this._ranges = {}, this.onReady = null, this._currentRenderId = -1, this._parentUpdateId = -1, this._childUpdateId = -1, this._waitingParentId = null, this._waitingParentInstanceIndex = null, this._waitingParsedUniqueId = null, this._cache = {}, this._parentNode = null, this._children = null, this._worldMatrix = I.Identity(), this._worldMatrixDeterminant = 0, this._worldMatrixDeterminantIsDirty = !0, this._animationPropertiesOverride = null, this._isNode = !0, this.onDisposeObservable = new u, this._onDisposeObserver = null, this._behaviors = new Array, this.name = e, this.id = e, this._scene = t || S.LastCreatedScene, this.uniqueId = this._scene.getUniqueId(), this._initCache() } return e.AddNodeConstructor = function (e, t) { this._NodeConstructors[e] = t }, e.Construct = function (e, t, i, r) { var n = this._NodeConstructors[e]; return n ? n(t, i, r) : null }, Object.defineProperty(e.prototype, "accessibilityTag", { get: function () { return this._accessibilityTag }, set: function (e) { this._accessibilityTag = e, this.onAccessibilityTagChangedObservable.notifyObservers(e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "doNotSerialize", { get: function () { return !!this._nodeDataStorage._doNotSerialize || !!this._parentNode && this._parentNode.doNotSerialize }, set: function (e) { this._nodeDataStorage._doNotSerialize = e }, enumerable: !1, configurable: !0 }), e.prototype.isDisposed = function () { return this._nodeDataStorage._isDisposed }, Object.defineProperty(e.prototype, "parent", { get: function () { return this._parentNode }, set: function (e) { if (this._parentNode !== e) { var t = this._parentNode; if (this._parentNode && void 0 !== this._parentNode._children && null !== this._parentNode._children) { var i = this._parentNode._children.indexOf(this); -1 !== i && this._parentNode._children.splice(i, 1), e || this._nodeDataStorage._isDisposed || this._addToSceneRootNodes() } this._parentNode = e, this._parentNode && (void 0 !== this._parentNode._children && null !== this._parentNode._children || (this._parentNode._children = new Array), this._parentNode._children.push(this), t || this._removeFromSceneRootNodes()), this._syncParentEnabledState() } }, enumerable: !1, configurable: !0 }), e.prototype._serializeAsParent = function (e) { e.parentId = this.uniqueId }, e.prototype._addToSceneRootNodes = function () { -1 === this._nodeDataStorage._sceneRootNodesIndex && (this._nodeDataStorage._sceneRootNodesIndex = this._scene.rootNodes.length, this._scene.rootNodes.push(this)) }, e.prototype._removeFromSceneRootNodes = function () { if (-1 !== this._nodeDataStorage._sceneRootNodesIndex) { var e = this._scene.rootNodes, t = e.length - 1; e[this._nodeDataStorage._sceneRootNodesIndex] = e[t], e[this._nodeDataStorage._sceneRootNodesIndex]._nodeDataStorage._sceneRootNodesIndex = this._nodeDataStorage._sceneRootNodesIndex, this._scene.rootNodes.pop(), this._nodeDataStorage._sceneRootNodesIndex = -1 } }, 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 }), e.prototype.getClassName = function () { return "Node" }, 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, "onEnabledStateChangedObservable", { get: function () { return this._nodeDataStorage._onEnabledStateChangedObservable }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "onClonedObservable", { get: function () { return this._nodeDataStorage._onClonedObservable }, enumerable: !1, configurable: !0 }), e.prototype.getScene = function () { return this._scene }, e.prototype.getEngine = function () { return this._scene.getEngine() }, e.prototype.addBehavior = function (e, t) { var i = this; return void 0 === t && (t = !1), -1 !== this._behaviors.indexOf(e) || (e.init(), this._scene.isLoading && !t ? this._scene.onDataLoadedObservable.addOnce((function () { e.attach(i) })) : e.attach(this), this._behaviors.push(e)), this }, e.prototype.removeBehavior = function (e) { var t = this._behaviors.indexOf(e); return -1 === t || (this._behaviors[t].detach(), this._behaviors.splice(t, 1)), this }, Object.defineProperty(e.prototype, "behaviors", { get: function () { return this._behaviors }, enumerable: !1, configurable: !0 }), e.prototype.getBehaviorByName = function (e) { for (var t = 0, i = this._behaviors; t < i.length; t++) { var r = i[t]; if (r.name === e) return r } return null }, e.prototype.getWorldMatrix = function () { return this._currentRenderId !== this._scene.getRenderId() && this.computeWorldMatrix(), this._worldMatrix }, e.prototype._getWorldMatrixDeterminant = function () { return this._worldMatrixDeterminantIsDirty && (this._worldMatrixDeterminantIsDirty = !1, this._worldMatrixDeterminant = this._worldMatrix.determinant()), this._worldMatrixDeterminant }, Object.defineProperty(e.prototype, "worldMatrixFromCache", { get: function () { return this._worldMatrix }, enumerable: !1, configurable: !0 }), e.prototype._initCache = function () { this._cache = {}, this._cache.parent = void 0 }, e.prototype.updateCache = function (e) { !e && this.isSynchronized() || (this._cache.parent = this.parent, this._updateCache()) }, e.prototype._getActionManagerForTrigger = function (e, t) { return void 0 === t && (t = !0), this.parent ? this.parent._getActionManagerForTrigger(e, !1) : null }, e.prototype._updateCache = function (e) { }, e.prototype._isSynchronized = function () { return !0 }, e.prototype._markSyncedWithParent = function () { this._parentNode && (this._parentUpdateId = this._parentNode._childUpdateId) }, e.prototype.isSynchronizedWithParent = function () { return !this._parentNode || !this._parentNode._isDirty && this._parentUpdateId === this._parentNode._childUpdateId && this._parentNode.isSynchronized() }, e.prototype.isSynchronized = function () { return this._cache.parent !== this._parentNode ? (this._cache.parent = this._parentNode, !1) : !(this._parentNode && !this.isSynchronizedWithParent()) && this._isSynchronized() }, e.prototype.isReady = function (e) { return void 0 === e && (e = !1), this._nodeDataStorage._isReady }, e.prototype.markAsDirty = function (e) { return this._currentRenderId = Number.MAX_VALUE, this._isDirty = !0, this }, e.prototype.isEnabled = function (e) { return void 0 === e && (e = !0), !1 === e ? this._nodeDataStorage._isEnabled : !!this._nodeDataStorage._isEnabled && this._nodeDataStorage._isParentEnabled }, e.prototype._syncParentEnabledState = function () { this._nodeDataStorage._isParentEnabled = !this._parentNode || this._parentNode.isEnabled(), this._children && this._children.forEach((function (e) { e._syncParentEnabledState() })) }, e.prototype.setEnabled = function (e) { this._nodeDataStorage._isEnabled !== e && (this._nodeDataStorage._isEnabled = e, this._syncParentEnabledState(), this._nodeDataStorage._onEnabledStateChangedObservable.notifyObservers(e)) }, e.prototype.isDescendantOf = function (e) { return !!this.parent && (this.parent === e || this.parent.isDescendantOf(e)) }, e.prototype._getDescendants = function (e, t, i) { if (void 0 === t && (t = !1), this._children) for (var r = 0; r < this._children.length; r++) { var n = this._children[r]; i && !i(n) || e.push(n), t || n._getDescendants(e, !1, i) } }, e.prototype.getDescendants = function (e, t) { var i = new Array; return this._getDescendants(i, e, t), i }, e.prototype.getChildMeshes = function (e, t) { var i = []; return this._getDescendants(i, e, (function (e) { return (!t || t(e)) && void 0 !== e.cullingStrategy })), i }, e.prototype.getChildren = function (e, t) { return void 0 === t && (t = !0), this.getDescendants(t, e) }, e.prototype._setReady = function (e) { e !== this._nodeDataStorage._isReady && (e ? (this.onReady && this.onReady(this), this._nodeDataStorage._isReady = !0) : this._nodeDataStorage._isReady = !1) }, e.prototype.getAnimationByName = function (e) { for (var t = 0; t < this.animations.length; t++) { var i = this.animations[t]; if (i.name === e) return i } return null }, e.prototype.createAnimationRange = function (t, i, r) { if (!this._ranges[t]) { this._ranges[t] = e._AnimationRangeFactory(t, i, r); for (var n = 0, o = this.animations.length; n < o; n++)this.animations[n] && this.animations[n].createRange(t, i, r) } }, e.prototype.deleteAnimationRange = function (e, t) { void 0 === t && (t = !0); for (var i = 0, r = this.animations.length; i < r; i++)this.animations[i] && this.animations[i].deleteRange(e, t); this._ranges[e] = null }, e.prototype.getAnimationRange = function (e) { return this._ranges[e] || null }, e.prototype.clone = function (t, i, r) { var n = this, o = Ue.Clone((function () { return new e(t, n.getScene()) }), this); if (i && (o.parent = i), !r) for (var a = this.getDescendants(!0), s = 0; s < a.length; s++) { var l = a[s]; l.clone(t + "." + l.name, o) } return o }, e.prototype.getAnimationRanges = function () { var e, t = []; for (e in this._ranges) t.push(this._ranges[e]); return t }, e.prototype.beginAnimation = function (e, t, i, r) { var n = this.getAnimationRange(e); return n ? this._scene.beginAnimation(this, n.from, n.to, t, i, r) : null }, e.prototype.serializeAnimationRanges = function () { var e = []; for (var t in this._ranges) { var i = this._ranges[t]; if (i) { var r = {}; r.name = t, r.from = i.from, r.to = i.to, e.push(r) } } return e }, e.prototype.computeWorldMatrix = function (e) { return this._worldMatrix || (this._worldMatrix = I.Identity()), this._worldMatrix }, e.prototype.dispose = function (e, t) { if (void 0 === t && (t = !1), this._nodeDataStorage._isDisposed = !0, !e) for (var i = 0, r = this.getDescendants(!0); i < r.length; i++)r[i].dispose(e, t); this.parent ? this.parent = null : this._removeFromSceneRootNodes(), this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear(), this.onEnabledStateChangedObservable.clear(), this.onClonedObservable.clear(); for (var n = 0, o = this._behaviors; n < o.length; n++)o[n].detach(); this._behaviors.length = 0, this.metadata = null }, e.ParseAnimationRanges = function (e, t, i) { if (t.ranges) for (var r = 0; r < t.ranges.length; r++) { var n = t.ranges[r]; e.createAnimationRange(n.name, n.from, n.to) } }, e.prototype.getHierarchyBoundingVectors = function (e, t) { var i, r; void 0 === e && (e = !0), void 0 === t && (t = null), this.getScene().incrementRenderId(), this.computeWorldMatrix(!0); var n = this; if (n.getBoundingInfo && n.subMeshes) { var o = n.getBoundingInfo(); i = o.boundingBox.minimumWorld.clone(), r = o.boundingBox.maximumWorld.clone() } else i = new R(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), r = new R(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE); if (e) for (var a = 0, s = this.getDescendants(!1); a < s.length; a++) { var l = s[a]; if (l.computeWorldMatrix(!0), (!t || t(l)) && l.getBoundingInfo && 0 !== l.getTotalVertices()) { var c = l.getBoundingInfo().boundingBox, u = c.minimumWorld, h = c.maximumWorld; R.CheckExtends(u, i, r), R.CheckExtends(h, i, r) } } return { min: i, max: r } }, e._AnimationRangeFactory = function (e, t, i) { throw ge("AnimationRange") }, e._NodeConstructors = {}, X([xe()], e.prototype, "name", void 0), X([xe()], e.prototype, "id", void 0), X([xe()], e.prototype, "uniqueId", void 0), X([xe()], e.prototype, "state", void 0), X([xe()], e.prototype, "metadata", void 0), e }(), We = function () { function e(e, t) { this.width = e, this.height = t } return e.prototype.toString = function () { return "{W: ".concat(this.width, ", H: ").concat(this.height, "}") }, e.prototype.getClassName = function () { return "Size" }, e.prototype.getHashCode = function () { var e = 0 | this.width; return 397 * e ^ (0 | this.height) }, e.prototype.copyFrom = function (e) { this.width = e.width, this.height = e.height }, e.prototype.copyFromFloats = function (e, t) { return this.width = e, this.height = t, this }, e.prototype.set = function (e, t) { return this.copyFromFloats(e, t) }, e.prototype.multiplyByFloats = function (t, i) { return new e(this.width * t, this.height * i) }, e.prototype.clone = function () { return new e(this.width, this.height) }, e.prototype.equals = function (e) { return !!e && this.width === e.width && this.height === e.height }, Object.defineProperty(e.prototype, "surface", { get: function () { return this.width * this.height }, enumerable: !1, configurable: !0 }), e.Zero = function () { return new e(0, 0) }, e.prototype.add = function (t) { return new e(this.width + t.width, this.height + t.height) }, e.prototype.subtract = function (t) { return new e(this.width - t.width, this.height - t.height) }, e.Lerp = function (t, i, r) { return new e(t.width + (i.width - t.width) * r, t.height + (i.height - t.height) * r) }, e }(), He = function () { function e() { this._xhr = "undefined" != typeof _native && _native.XMLHttpRequest ? new _native.XMLHttpRequest : new XMLHttpRequest, this._requestURL = "" } return 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 < n.length; r++) { var o = n[r]; if (this._shouldSkipRequestModifications(i)) return; o(this._xhr, i) } return i = (i = i.replace("file:http:", "http:")).replace("file:https:", "https:"), this._requestURL = i, this._xhr.open(t, i, !0) }, e.prototype.setRequestHeader = function (e, t) { this._xhr.setRequestHeader(e, t) }, e.prototype.getResponseHeader = function (e) { return this._xhr.getResponseHeader(e) }, e.CustomRequestHeaders = {}, e.CustomRequestModifiers = new Array, e.SkipRequestModificationForBabylonCDN = !0, e }(), Xe = function () { }, je = function () { function e(t, i, r, n, o, a) { this.name = t, this.targetProperty = i, this.framePerSecond = r, this.dataType = n, this.loopMode = o, this.enableBlending = a, this._easingFunction = null, this._runtimeAnimations = new Array, this._events = new Array, this.blendingSpeed = .01, this._ranges = {}, this.targetPropertyPath = i.split("."), this.dataType = n, this.loopMode = void 0 === o ? e.ANIMATIONLOOPMODE_CYCLE : o, this.uniqueId = e._UniqueIdGenerator++ } return e._PrepareAnimation = function (t, i, r, n, o, a, s, l) { var c = void 0; if (!isNaN(parseFloat(o)) && isFinite(o) ? c = e.ANIMATIONTYPE_FLOAT : o instanceof P ? c = e.ANIMATIONTYPE_QUATERNION : o instanceof R ? c = e.ANIMATIONTYPE_VECTOR3 : o instanceof A ? c = e.ANIMATIONTYPE_VECTOR2 : o instanceof B ? c = e.ANIMATIONTYPE_COLOR3 : o instanceof U ? c = e.ANIMATIONTYPE_COLOR4 : o instanceof We && (c = e.ANIMATIONTYPE_SIZE), null == c) return null; var u = new e(t, i, r, c, s), h = [{ frame: 0, value: o }, { frame: n, value: a }]; return u.setKeys(h), void 0 !== l && u.setEasingFunction(l), u }, e.CreateAnimation = function (t, i, r, n) { var o = new e(t + "Animation", t, r, i, e.ANIMATIONLOOPMODE_CONSTANT); return o.setEasingFunction(n), o }, e.CreateAndStartAnimation = function (t, i, r, n, o, a, s, l, c, u, h) { var d = e._PrepareAnimation(t, r, n, o, a, s, l, c); return d ? (i.getScene && (h = i.getScene()), h ? h.beginDirectAnimation(i, [d], 0, o, 1 === d.loopMode, 1, u) : null) : null }, e.CreateAndStartHierarchyAnimation = function (t, i, r, n, o, a, s, l, c, u, h) { var d = e._PrepareAnimation(t, n, o, a, s, l, c, u); return d ? i.getScene().beginDirectHierarchyAnimation(i, r, [d], 0, a, 1 === d.loopMode, 1, h) : null }, e.CreateMergeAndStartAnimation = function (t, i, r, n, o, a, s, l, c, u) { var h = e._PrepareAnimation(t, r, n, o, a, s, l, c); return h ? (i.animations.push(h), i.getScene().beginAnimation(i, 0, o, 1 === h.loopMode, 1, u)) : null }, e.MakeAnimationAdditive = function (t, i, r, n, o) { void 0 === i && (i = 0), void 0 === n && (n = !1); var a = t; if (n && ((a = t.clone()).name = o || a.name), !a._keys.length) return a; i = i >= 0 ? i : 0; var s = 0, l = a._keys[0], c = a._keys.length - 1, u = a._keys[c], h = { referenceValue: l.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] }, d = !1, p = l.frame, f = u.frame; if (r) { var _ = a.getRange(r); _ && (p = _.from, f = _.to) } var m = l.frame === p, g = u.frame === f; if (1 === a._keys.length) { var v = a._getKeyValue(a._keys[0]); h.referenceValue = v.clone ? v.clone() : v, d = !0 } else i <= l.frame ? (v = a._getKeyValue(l.value), h.referenceValue = v.clone ? v.clone() : v, d = !0) : i >= u.frame && (v = a._getKeyValue(u.value), h.referenceValue = v.clone ? v.clone() : v, d = !0); for (var y = 0; !d || !m || !g && y < a._keys.length - 1;) { var b = a._keys[y], T = a._keys[y + 1]; if (!d && i >= b.frame && i <= T.frame) { if (v = void 0, i === b.frame) v = a._getKeyValue(b.value); else if (i === T.frame) v = a._getKeyValue(T.value); else { var E = { key: y, repeatCount: 0, loopMode: this.ANIMATIONLOOPMODE_CONSTANT }; v = a._interpolate(i, E) } h.referenceValue = v.clone ? v.clone() : v, d = !0 } if (!m && p >= b.frame && p <= T.frame) { if (p === b.frame) s = y; else if (p === T.frame) s = y + 1; else { E = { key: y, repeatCount: 0, loopMode: this.ANIMATIONLOOPMODE_CONSTANT }; var S = { frame: p, value: (v = a._interpolate(p, E)).clone ? v.clone() : v }; a._keys.splice(y + 1, 0, S), s = y + 1 } m = !0 } !g && f >= b.frame && f <= T.frame && (f === b.frame ? c = y : (f === T.frame || (E = { key: y, repeatCount: 0, loopMode: this.ANIMATIONLOOPMODE_CONSTANT }, S = { frame: f, value: (v = a._interpolate(f, E)).clone ? v.clone() : v }, a._keys.splice(y + 1, 0, S)), c = y + 1), g = !0), y++ } for (a.dataType === e.ANIMATIONTYPE_QUATERNION ? h.referenceValue.normalize().conjugateInPlace() : a.dataType === e.ANIMATIONTYPE_MATRIX && (h.referenceValue.decompose(h.referenceScaling, h.referenceQuaternion, h.referencePosition), h.referenceQuaternion.normalize().conjugateInPlace()), y = s; y <= c; y++)if (S = a._keys[y], !y || a.dataType === e.ANIMATIONTYPE_FLOAT || S.value !== l.value) switch (a.dataType) { case e.ANIMATIONTYPE_MATRIX: S.value.decompose(h.keyScaling, h.keyQuaternion, h.keyPosition), h.keyPosition.subtractInPlace(h.referencePosition), h.keyScaling.divideInPlace(h.referenceScaling), h.referenceQuaternion.multiplyToRef(h.keyQuaternion, h.keyQuaternion), I.ComposeToRef(h.keyScaling, h.keyQuaternion, h.keyPosition, S.value); break; case e.ANIMATIONTYPE_QUATERNION: h.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(h.referenceValue, S.value); break; case e.ANIMATIONTYPE_SIZE: S.value.width -= h.referenceValue.width, S.value.height -= h.referenceValue.height; break; default: S.value -= h.referenceValue }return a }, 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 < t.length; e++)if (!t[e].isStopped()) return !0; return !1 }, enumerable: !1, configurable: !0 }), e.prototype.toString = function (e) { var t = "Name: " + this.name + ", property: " + this.targetProperty; if (t += ", datatype: " + ["Float", "Vector3", "Quaternion", "Matrix", "Color3", "Vector2"][this.dataType], t += ", nKeys: " + (this._keys ? this._keys.length : "none"), t += ", nRanges: " + (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.addEvent = function (e) { this._events.push(e), this._events.sort((function (e, t) { return e.frame - t.frame })) }, e.prototype.removeEvents = function (e) { for (var t = 0; t < this._events.length; t++)this._events[t].frame === e && (this._events.splice(t, 1), t--) }, e.prototype.getEvents = function () { return this._events }, e.prototype.createRange = function (e, t, i) { this._ranges[e] || (this._ranges[e] = new ke(e, t, i)) }, e.prototype.deleteRange = function (e, t) { void 0 === t && (t = !0); var i = this._ranges[e]; if (i) { if (t) for (var r = i.from, n = i.to, o = this._keys.length - 1; o >= 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; t < i; t++)e < this._keys[t].frame && (e = this._keys[t].frame); return e }, e.prototype.getEasingFunction = function () { return this._easingFunction }, e.prototype.setEasingFunction = function (e) { this._easingFunction = e }, e.prototype.floatInterpolateFunction = function (e, t, i) { return h.Lerp(e, t, i) }, e.prototype.floatInterpolateFunctionWithTangents = function (e, t, i, r, n) { return h.Hermite(e, t, i, r, n) }, e.prototype.quaternionInterpolateFunction = function (e, t, i) { return P.Slerp(e, t, i) }, e.prototype.quaternionInterpolateFunctionWithTangents = function (e, t, i, r, n) { return P.Hermite(e, t, i, r, n).normalize() }, e.prototype.vector3InterpolateFunction = function (e, t, i) { return R.Lerp(e, t, i) }, e.prototype.vector3InterpolateFunctionWithTangents = function (e, t, i, r, n) { return R.Hermite(e, t, i, r, n) }, e.prototype.vector2InterpolateFunction = function (e, t, i) { return A.Lerp(e, t, i) }, e.prototype.vector2InterpolateFunctionWithTangents = function (e, t, i, r, n) { return A.Hermite(e, t, i, r, n) }, e.prototype.sizeInterpolateFunction = function (e, t, i) { return We.Lerp(e, t, i) }, e.prototype.color3InterpolateFunction = function (e, t, i) { return B.Lerp(e, t, i) }, e.prototype.color3InterpolateFunctionWithTangents = function (e, t, i, r, n) { return B.Hermite(e, t, i, r, n) }, e.prototype.color4InterpolateFunction = function (e, t, i) { return U.Lerp(e, t, i) }, e.prototype.color4InterpolateFunctionWithTangents = function (e, t, i, r, n) { return U.Hermite(e, t, i, r, n) }, e.prototype._getKeyValue = function (e) { return "function" == typeof e ? e() : e }, e.prototype.evaluate = function (t) { return this._interpolate(t, { key: 0, repeatCount: 0, loopMode: e.ANIMATIONLOOPMODE_CONSTANT }) }, e.prototype._interpolate = function (t, i) { if (i.loopMode === e.ANIMATIONLOOPMODE_CONSTANT && i.repeatCount > 0) return i.highLimitValue.clone ? i.highLimitValue.clone() : i.highLimitValue; for (var r = this._keys, n = r.length, o = i.key; o >= 0 && t < r[o].frame;)--o; for (; o + 1 <= n - 1 && t >= r[o + 1].frame;)++o; if (i.key = o, o < 0) return this._getKeyValue(r[0].value); if (o + 1 > n - 1) return this._getKeyValue(r[n - 1].value); var a = r[o], s = r[o + 1], l = this._getKeyValue(a.value), c = this._getKeyValue(s.value); if (a.interpolation === Be.STEP) return s.frame > t ? l : c; var u = void 0 !== a.outTangent && void 0 !== s.inTangent, h = s.frame - a.frame, d = (t - a.frame) / h, p = this.getEasingFunction(); switch (null !== p && (d = p.ease(d)), this.dataType) { case e.ANIMATIONTYPE_FLOAT: var f = u ? this.floatInterpolateFunctionWithTangents(l, a.outTangent * h, c, s.inTangent * h, d) : this.floatInterpolateFunction(l, c, d); switch (i.loopMode) { case e.ANIMATIONLOOPMODE_CYCLE: case e.ANIMATIONLOOPMODE_CONSTANT: case e.ANIMATIONLOOPMODE_YOYO: return f; case e.ANIMATIONLOOPMODE_RELATIVE: return i.offsetValue * i.repeatCount + f }break; case e.ANIMATIONTYPE_QUATERNION: var _ = u ? this.quaternionInterpolateFunctionWithTangents(l, a.outTangent.scale(h), c, s.inTangent.scale(h), d) : this.quaternionInterpolateFunction(l, c, d); switch (i.loopMode) { case e.ANIMATIONLOOPMODE_CYCLE: case e.ANIMATIONLOOPMODE_CONSTANT: case e.ANIMATIONLOOPMODE_YOYO: return _; case e.ANIMATIONLOOPMODE_RELATIVE: return _.addInPlace(i.offsetValue.scale(i.repeatCount)) }return _; case e.ANIMATIONTYPE_VECTOR3: var m = u ? this.vector3InterpolateFunctionWithTangents(l, a.outTangent.scale(h), c, s.inTangent.scale(h), d) : this.vector3InterpolateFunction(l, c, d); switch (i.loopMode) { case e.ANIMATIONLOOPMODE_CYCLE: case e.ANIMATIONLOOPMODE_CONSTANT: case e.ANIMATIONLOOPMODE_YOYO: return m; case e.ANIMATIONLOOPMODE_RELATIVE: return m.add(i.offsetValue.scale(i.repeatCount)) }break; case e.ANIMATIONTYPE_VECTOR2: var g = u ? this.vector2InterpolateFunctionWithTangents(l, a.outTangent.scale(h), c, s.inTangent.scale(h), d) : this.vector2InterpolateFunction(l, c, d); 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_SIZE: switch (i.loopMode) { case e.ANIMATIONLOOPMODE_CYCLE: case e.ANIMATIONLOOPMODE_CONSTANT: case e.ANIMATIONLOOPMODE_YOYO: return this.sizeInterpolateFunction(l, c, d); case e.ANIMATIONLOOPMODE_RELATIVE: return this.sizeInterpolateFunction(l, c, d).add(i.offsetValue.scale(i.repeatCount)) }break; case e.ANIMATIONTYPE_COLOR3: var v = u ? this.color3InterpolateFunctionWithTangents(l, a.outTangent.scale(h), c, s.inTangent.scale(h), d) : this.color3InterpolateFunction(l, c, d); 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_COLOR4: var y = u ? this.color4InterpolateFunctionWithTangents(l, a.outTangent.scale(h), c, s.inTangent.scale(h), d) : this.color4InterpolateFunction(l, c, d); 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_MATRIX: switch (i.loopMode) { case e.ANIMATIONLOOPMODE_CYCLE: case e.ANIMATIONLOOPMODE_CONSTANT: case e.ANIMATIONLOOPMODE_YOYO: return e.AllowMatricesInterpolation ? this.matrixInterpolateFunction(l, c, d, i.workValue) : l; case e.ANIMATIONLOOPMODE_RELATIVE: return l } }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) { this._keys = e.slice(0) }, 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 < r.length; n++) { var o = r[n], a = {}; switch (a.frame = o.frame, i) { case e.ANIMATIONTYPE_FLOAT: a.values = [o.value], void 0 !== o.inTangent && a.values.push(o.inTangent), void 0 !== o.outTangent && (void 0 === o.inTangent && a.values.push(void 0), a.values.push(o.outTangent)), void 0 !== o.interpolation && (void 0 === o.inTangent && a.values.push(void 0), void 0 === o.outTangent && a.values.push(void 0), a.values.push(o.interpolation)); break; case e.ANIMATIONTYPE_QUATERNION: case e.ANIMATIONTYPE_MATRIX: case e.ANIMATIONTYPE_VECTOR3: case e.ANIMATIONTYPE_COLOR3: case e.ANIMATIONTYPE_COLOR4: a.values = o.value.asArray(), null != o.inTangent && a.values.push(o.inTangent.asArray()), null != o.outTangent && (void 0 === o.inTangent && a.values.push(void 0), a.values.push(o.outTangent.asArray())), void 0 !== o.interpolation && (void 0 === o.inTangent && a.values.push(void 0), void 0 === o.outTangent && a.values.push(void 0), a.values.push(o.interpolation)) }t.keys.push(a) } for (var s in t.ranges = [], this._ranges) { var l = this._ranges[s]; if (l) { var c = {}; c.name = s, c.from = l.from, c.to = l.to, t.ranges.push(c) } } return t }, e._UniversalLerp = function (e, t, i) { var r = e.constructor; return r.Lerp ? r.Lerp(e, t, i) : r.Slerp ? r.Slerp(e, t, i) : e.toFixed ? e * (1 - i) + i * t : t }, e.Parse = function (t) { var i, r, n = new e(t.name, t.property, t.framePerSecond, t.dataType, t.loopBehavior), o = t.dataType, a = []; for (t.enableBlending && (n.enableBlending = t.enableBlending), t.blendingSpeed && (n.blendingSpeed = t.blendingSpeed), r = 0; r < t.keys.length; r++) { var s = t.keys[r], l = void 0, c = void 0, u = void 0; switch (o) { case e.ANIMATIONTYPE_FLOAT: i = s.values[0], s.values.length >= 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; r < t.ranges.length; r++)i = t.ranges[r], n.createRange(i.name, i.from, i.to); return n }, e.AppendSerializedAnimations = function (e, t) { Ue.AppendSerializedAnimations(e, t) }, e.ParseFromFileAsync = function (e, t) { var i = this; return new Promise((function (r, n) { var o = new He; o.addEventListener("readystatechange", (function () { if (4 == o.readyState) if (200 == o.status) { var t = JSON.parse(o.responseText); if (t.animations && (t = t.animations), t.length) { for (var a = new Array, s = 0, l = t; s < l.length; s++) { var c = l[s]; a.push(i.Parse(c)) } r(a) } else a = i.Parse(t), e && (a.name = e), r(a) } else n("Unable to load the animation") })), o.open("GET", t), o.send() })) }, e.ParseFromSnippetAsync = function (e) { var t = this; return new Promise((function (i, r) { var n = new He; n.addEventListener("readystatechange", (function () { if (4 == n.readyState) if (200 == n.status) { var o = JSON.parse(JSON.parse(n.responseText).jsonPayload); if (o.animations) { for (var a = JSON.parse(o.animations), s = new Array, l = 0, c = a.animations; l < c.length; l++) { var u = c[l]; (h = t.Parse(u)).snippetId = e, s.push(h) } i(s) } else { var h; a = JSON.parse(o.animation), (h = t.Parse(a)).snippetId = e, i(h) } } else r("Unable to load the snippet " + e) })), n.open("GET", t.SnippetUrl + "/" + e.replace(/#/g, "/")), n.send() })) }, e._UniqueIdGenerator = 0, e.AllowMatricesInterpolation = !1, e.AllowMatrixDecomposeForInterpolation = !0, e.SnippetUrl = a.SnippetUrl, e.ANIMATIONTYPE_FLOAT = 0, e.ANIMATIONTYPE_VECTOR3 = 1, e.ANIMATIONTYPE_QUATERNION = 2, e.ANIMATIONTYPE_MATRIX = 3, e.ANIMATIONTYPE_COLOR3 = 4, e.ANIMATIONTYPE_COLOR4 = 7, e.ANIMATIONTYPE_VECTOR2 = 5, e.ANIMATIONTYPE_SIZE = 6, e.ANIMATIONLOOPMODE_RELATIVE = 0, e.ANIMATIONLOOPMODE_CYCLE = 1, e.ANIMATIONLOOPMODE_CONSTANT = 2, e.ANIMATIONLOOPMODE_YOYO = 4, e.CreateFromSnippetAsync = e.ParseFromSnippetAsync, e }(); b("BABYLON.Animation", je), ze._AnimationRangeFactory = function (e, t, i) { return new ke(e, t, i) }; var Ye = function (e) { function t(t, i, r, n, o, a, s, l) { void 0 === o && (o = 1e3); var c = e.call(this, t, a) || this; return c.duration = 1e3, c.onInterpolationDoneObservable = new u, c.propertyPath = r, c.value = n, c.duration = o, c.stopOtherAnimations = s, c.onInterpolationDone = l, c._target = c._effectiveTarget = i, c } 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 () { var e, t = this, i = this._actionManager.getScene(), r = [{ frame: 0, value: this._effectiveTarget[this._property] }, { frame: 100, value: this.value }]; if ("number" == typeof this.value) e = je.ANIMATIONTYPE_FLOAT; else if (this.value instanceof B) e = je.ANIMATIONTYPE_COLOR3; else if (this.value instanceof R) e = je.ANIMATIONTYPE_VECTOR3; else if (this.value instanceof I) e = je.ANIMATIONTYPE_MATRIX; else { if (!(this.value instanceof P)) return void $.Warn("InterpolateValueAction: Unsupported type (" + typeof this.value + ")"); e = je.ANIMATIONTYPE_QUATERNION } var n = new je("InterpolateValueAction", this._property, 1e3 / this.duration * 100, e, je.ANIMATIONLOOPMODE_CONSTANT); n.setKeys(r), this.stopOtherAnimations && i.stopAnimation(this._effectiveTarget), i.beginDirectAnimation(this._effectiveTarget, [n], 0, 100, !1, 1, (function () { t.onInterpolationDoneObservable.notifyObservers(t), t.onInterpolationDone && t.onInterpolationDone() })) }, t.prototype.serialize = function (t) { return e.prototype._serialize.call(this, { name: "InterpolateValueAction", properties: [k._GetTargetProperty(this._target), { name: "propertyPath", value: this.propertyPath }, { name: "value", value: k._SerializeValueAsString(this.value) }, { name: "duration", value: k._SerializeValueAsString(this.duration) }, { name: "stopOtherAnimations", value: k._SerializeValueAsString(this.stopOtherAnimations) || !1 }] }, t) }, t }(k); b("BABYLON.InterpolateValueAction", Ye); var Ke = Object.freeze(new P(0, 0, 0, 0)), Qe = Object.freeze(R.Zero()), qe = Object.freeze(A.Zero()), Ze = Object.freeze(We.Zero()), Je = Object.freeze(B.Black()), $e = function () { function e(e, t, i, r) { var n = this; if (this._events = new Array, this._currentFrame = 0, this._originalValue = new Array, this._originalBlendValue = null, this._offsetsCache = {}, this._highLimitsCache = {}, this._stopped = !1, this._blendingFactor = 0, this._currentValue = null, this._currentActiveTarget = null, this._directTarget = null, this._targetPath = "", this._weight = 1, this._absoluteFrameOffset = 0, this._previousElapsedTime = 0, this._previousAbsoluteFrame = 0, this._targetIsArray = !1, this._animation = t, this._target = e, this._scene = i, this._host = r, this._activeTargets = [], t._runtimeAnimations.push(this), this._animationState = { key: 0, repeatCount: 0, loopMode: this._getCorrectLoopMode() }, this._animation.dataType === je.ANIMATIONTYPE_MATRIX && (this._animationState.workValue = I.Zero()), this._keys = this._animation.getKeys(), this._minFrame = this._keys[0].frame, this._maxFrame = this._keys[this._keys.length - 1].frame, this._minValue = this._keys[0].value, this._maxValue = this._keys[this._keys.length - 1].value, 0 !== this._minFrame) { var o = { frame: 0, value: this._minValue }; this._keys.splice(0, 0, o) } if (this._target instanceof Array) { for (var a = 0, s = 0, l = this._target; s < l.length; s++) { var c = l[s]; this._preparePath(c, a), this._getOriginalValues(a), a++ } this._targetIsArray = !0 } else this._preparePath(this._target), this._getOriginalValues(), this._targetIsArray = !1, this._directTarget = this._activeTargets[0]; var u = t.getEvents(); u && u.length > 0 && 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 < i.length - 1; n++)r = r[i[n]]; this._targetPath = i[i.length - 1], this._activeTargets[t] = r } else this._targetPath = i[0], this._activeTargets[t] = e }, Object.defineProperty(e.prototype, "animation", { get: function () { return this._animation }, enumerable: !1, configurable: !0 }), e.prototype.reset = function (e) { if (void 0 === e && (e = !1), e) if (this._target instanceof Array) for (var t = 0, i = 0, r = this._target; i < r.length; i++) { var n = r[i]; void 0 !== this._originalValue[t] && this._setValue(n, this._activeTargets[t], this._originalValue[t], -1, t), t++ } else void 0 !== this._originalValue[0] && this._setValue(this._target, this._directTarget, this._originalValue[0], -1, 0); for (this._offsetsCache = {}, this._highLimitsCache = {}, this._currentFrame = 0, this._blendingFactor = 0, t = 0; t < this._events.length; t++)this._events[t].isDone = !1 }, e.prototype.isStopped = function () { return this._stopped }, e.prototype.dispose = function () { var e = this._animation.runtimeAnimations.indexOf(this); e > -1 && this._animation.runtimeAnimations.splice(e, 1) }, e.prototype.setValue = function (e, t) { if (this._targetIsArray) for (var i = 0; i < this._target.length; i++) { var r = this._target[i]; this._setValue(r, this._activeTargets[i], e, t, i) } else this._setValue(this._target, this._directTarget, e, t, 0) }, e.prototype._getOriginalValues = function (e) { var t; void 0 === e && (e = 0); var i = this._activeTargets[e]; (t = i.getRestPose && "_matrix" === this._targetPath ? i.getRestPose() : i[this._targetPath]) && t.clone ? this._originalValue[e] = t.clone() : this._originalValue[e] = t }, e.prototype._setValue = function (e, t, i, r, n) { if (this._currentActiveTarget = t, this._weight = r, this._enableBlending && this._blendingFactor <= 1) { if (!this._originalBlendValue) { var o = t[this._targetPath]; o.clone ? this._originalBlendValue = o.clone() : this._originalBlendValue = o } this._originalBlendValue.m ? je.AllowMatrixDecomposeForInterpolation ? this._currentValue ? I.DecomposeLerpToRef(this._originalBlendValue, i, this._blendingFactor, this._currentValue) : this._currentValue = I.DecomposeLerp(this._originalBlendValue, i, this._blendingFactor) : this._currentValue ? I.LerpToRef(this._originalBlendValue, i, this._blendingFactor, this._currentValue) : this._currentValue = I.Lerp(this._originalBlendValue, i, this._blendingFactor) : this._currentValue = je._UniversalLerp(this._originalBlendValue, i, this._blendingFactor); var a = e && e.animationPropertiesOverride ? e.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed; this._blendingFactor += a } else this._currentValue ? this._currentValue.copyFrom ? this._currentValue.copyFrom(i) : this._currentValue = i : (null == i ? void 0 : i.clone) ? this._currentValue = i.clone() : this._currentValue = i; -1 !== r ? this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[n]) : t[this._targetPath] = this._currentValue, e.markAsDirty && e.markAsDirty(this._animation.targetProperty) }, e.prototype._getCorrectLoopMode = function () { return this._target && this._target.animationPropertiesOverride ? this._target.animationPropertiesOverride.loopMode : this._animation.loopMode }, e.prototype.goToFrame = function (e) { var t = this._animation.getKeys(); e < t[0].frame ? e = t[0].frame : e > t[t.length - 1].frame && (e = t[t.length - 1].frame); var i = this._events; if (i.length) for (var r = 0; r < i.length; r++)i[r].onlyOnce || (i[r].isDone = i[r].frame < e); this._currentFrame = e; var n = this._animation._interpolate(e, this._animationState); this.setValue(n, -1) }, e.prototype._prepareForSpeedRatioChange = function (e) { var t = this._previousElapsedTime * (this._animation.framePerSecond * e) / 1e3; this._absoluteFrameOffset = this._previousAbsoluteFrame - t }, e.prototype.animate = function (e, t, i, r, n, o) { void 0 === o && (o = -1); var a = this._animation, s = a.targetPropertyPath; if (!s || s.length < 1) return this._stopped = !0, !1; var l = !0; (t < this._minFrame || t > this._maxFrame) && (t = this._minFrame), (i < this._minFrame || i > this._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 === je.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 !== je.ANIMATIONLOOPMODE_CYCLE) { var _ = i.toString() + t.toString(); if (!this._offsetsCache[_]) { this._animationState.repeatCount = 0, this._animationState.loopMode = je.ANIMATIONLOOPMODE_CYCLE; var m = a._interpolate(t, this._animationState), g = a._interpolate(i, this._animationState); switch (this._animationState.loopMode = this._getCorrectLoopMode(), a.dataType) { case je.ANIMATIONTYPE_FLOAT: this._offsetsCache[_] = g - m; break; case je.ANIMATIONTYPE_QUATERNION: case je.ANIMATIONTYPE_VECTOR3: case je.ANIMATIONTYPE_VECTOR2: case je.ANIMATIONTYPE_SIZE: case je.ANIMATIONTYPE_COLOR3: this._offsetsCache[_] = g.subtract(m) }this._highLimitsCache[_] = g } p = this._highLimitsCache[_], c = this._offsetsCache[_] } if (void 0 === c) switch (a.dataType) { case je.ANIMATIONTYPE_FLOAT: c = 0; break; case je.ANIMATIONTYPE_QUATERNION: c = Ke; break; case je.ANIMATIONTYPE_VECTOR3: c = Qe; break; case je.ANIMATIONTYPE_VECTOR2: c = qe; break; case je.ANIMATIONTYPE_SIZE: c = Ze; break; case je.ANIMATIONTYPE_COLOR3: c = Je }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 && t < i ? l && 0 !== h ? i + d % h : t : l && 0 !== h ? t + d % h : i; var y = this._events; if (n > 0 && this.currentFrame > u || n < 0 && this.currentFrame < u) { this._onLoop(); for (var b = 0; b < y.length; b++)y[b].onlyOnce || (y[b].isDone = !1); this._animationState.key = n > 0 ? 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; b < y.length; b++)if (h > 0 && 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 et() { return "undefined" != typeof window } function tt() { return "undefined" != typeof navigator } function it() { return "undefined" != typeof document } function rt(e) { for (var t = "", i = e.firstChild; i;)3 === i.nodeType && (t += i.textContent), i = i.nextSibling; return t } var nt, ot = { IsWindowObjectExist: et, IsNavigatorAvailable: tt, IsDocumentAvailable: it, GetDOMTextContent: rt }, at = function () { function e() { } return Object.defineProperty(e, "Now", { get: function () { return et() && window.performance && window.performance.now ? window.performance.now() : Date.now() }, enumerable: !1, configurable: !0 }), e }(), st = function () { function e() { } return e.FilesToLoad = {}, e }(), lt = 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 }(), ct = 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), ut = { MeshInvalidPositionsError: 0, UnsupportedTextureError: 1e3, GLTFLoaderUnexpectedMagicError: 2e3, SceneLoaderError: 3e3, LoadFileError: 4e3, RequestFileError: 4001, ReadFileError: 4002 }, ht = function (e) { function t(i, r, n) { var o = e.call(this, i) || this; return o.errorCode = r, o.innerError = n, o.name = "RuntimeError", ct._setPrototypeOf(o, t.prototype), o } return W(t, e), t }(ct), dt = function (e, t) { return e.endsWith(t) }, pt = function (e, t) { return !!e && e.startsWith(t) }, ft = function (e) { if ("undefined" != typeof TextDecoder) return (new TextDecoder).decode(e); for (var t = "", i = 0; i < e.byteLength; i++)t += String.fromCharCode(e[i]); return t }, _t = function (e) { for (var t, i, r, n, o, a, s, l = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", c = "", u = 0, h = ArrayBuffer.isView(e) ? new Uint8Array(e.buffer, e.byteOffset, e.byteLength) : new Uint8Array(e); u < h.length;)n = (t = h[u++]) >> 2, o = (3 & t) << 4 | (i = u < h.length ? h[u++] : Number.NaN) >> 4, a = (15 & i) << 2 | (r = u < h.length ? h[u++] : Number.NaN) >> 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 }, mt = function (e) { return atob(e) }, gt = function (e) { for (var t = mt(e), i = t.length, r = new Uint8Array(new ArrayBuffer(i)), n = 0; n < i; n++)r[n] = t.charCodeAt(n); return r.buffer }, vt = function (e, t) { for (var i = String(e); i.length < t;)i = "0" + i; return i }, yt = { EndsWith: dt, StartsWith: pt, Decode: ft, EncodeArrayBufferToBase64: _t, DecodeBase64ToString: mt, DecodeBase64ToBinary: gt, PadNumber: vt }, bt = function () { function e() { this.children = [] } return e.prototype.isValid = function (e) { return !0 }, e.prototype.process = function (e, t) { var i, r, n, o, a, s, l, c = ""; if (this.line) { var u = this.line, h = t.processor; if (h) { h.lineProcessor && (u = h.lineProcessor(u, t.isFragment, t.processingContext)); var d = null !== (r = null === (i = t.processor) || void 0 === i ? void 0 : i.attributeKeywordName) && void 0 !== r ? r : "attribute", p = t.isFragment && (null === (n = t.processor) || void 0 === n ? void 0 : n.varyingFragmentKeywordName) ? null === (o = t.processor) || void 0 === o ? void 0 : o.varyingFragmentKeywordName : !t.isFragment && (null === (a = t.processor) || void 0 === a ? void 0 : a.varyingVertexKeywordName) ? null === (s = t.processor) || void 0 === s ? void 0 : s.varyingVertexKeywordName : "varying"; !t.isFragment && h.attributeProcessor && this.line.startsWith(d) ? u = h.attributeProcessor(this.line, e, t.processingContext) : h.varyingProcessor && ((null === (l = h.varyingCheck) || void 0 === l ? void 0 : l.call(h, this.line, t.isFragment)) || !h.varyingCheck && this.line.startsWith(p)) ? u = h.varyingProcessor(this.line, t.isFragment, e, t.processingContext) : h.uniformProcessor && h.uniformRegexp && h.uniformRegexp.test(this.line) ? t.lookForClosingBracketForUniformBuffer || (u = h.uniformProcessor(this.line, t.isFragment, e, t.processingContext)) : h.uniformBufferProcessor && h.uniformBufferRegexp && h.uniformBufferRegexp.test(this.line) ? t.lookForClosingBracketForUniformBuffer || (u = h.uniformBufferProcessor(this.line, t.isFragment, t.processingContext), t.lookForClosingBracketForUniformBuffer = !0) : h.textureProcessor && h.textureRegexp && h.textureRegexp.test(this.line) ? u = h.textureProcessor(this.line, t.isFragment, e, t.processingContext) : (h.uniformProcessor || h.uniformBufferProcessor) && this.line.startsWith("uniform") && !t.lookForClosingBracketForUniformBuffer && (/uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/.test(this.line) ? h.uniformProcessor && (u = h.uniformProcessor(this.line, t.isFragment, e, t.processingContext)) : h.uniformBufferProcessor && (u = h.uniformBufferProcessor(this.line, t.isFragment, t.processingContext), t.lookForClosingBracketForUniformBuffer = !0)), t.lookForClosingBracketForUniformBuffer && -1 !== this.line.indexOf("}") && (t.lookForClosingBracketForUniformBuffer = !1, h.endOfUniformBufferProcessor && (u = h.endOfUniformBufferProcessor(this.line, t.isFragment, t.processingContext))) } c += u + "\n" } return this.children.forEach((function (i) { c += i.process(e, t) })), this.additionalDefineKey && (e[this.additionalDefineKey] = this.additionalDefineValue || "true"), c }, e }(), Tt = function () { function e() { this._lines = [] } return Object.defineProperty(e.prototype, "currentLine", { get: function () { return this._lines[this.lineIndex] }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "canRead", { get: function () { return this.lineIndex < this._lines.length - 1 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "lines", { set: function (e) { this._lines.length = 0; for (var t = 0, i = e; t < i.length; t++) { var r = i[t]; if (r && "\r" !== r) if ("#" !== r[0]) { var n = r.trim(); if (n) if (n.startsWith("//")) this._lines.push(r); else { var o = n.indexOf(";"); if (-1 === o) this._lines.push(n); else if (o === n.length - 1) n.length > 1 && this._lines.push(n); else for (var a = r.split(";"), s = 0; s < a.length; s++) { var l = a[s]; l && (l = l.trim()) && this._lines.push(l + (s !== a.length - 1 ? ";" : "")) } } } else this._lines.push(r) } }, enumerable: !1, configurable: !0 }), e }(), Et = function (e) { function t() { return null !== e && e.apply(this, arguments) || this } return W(t, e), t.prototype.process = function (e, t) { for (var i = 0; i < this.children.length; i++) { var r = this.children[i]; if (r.isValid(e)) return r.process(e, t) } return "" }, t }(bt), St = function (e) { function t() { return null !== e && e.apply(this, arguments) || this } return W(t, e), t.prototype.isValid = function (e) { return this.testExpression.isTrue(e) }, t }(bt), xt = function () { function e() { } return e.prototype.isTrue = function (e) { return !0 }, e.postfixToInfix = function (t) { for (var i = [], r = 0, n = t; r < n.length; r++) { var o = n[r]; if (void 0 === e._OperatorPriority[o]) i.push(o); else { var a = i[i.length - 1], s = i[i.length - 2]; i.length -= 2, i.push("(".concat(s).concat(o).concat(a, ")")) } } return i[i.length - 1] }, e.infixToPostfix = function (t) { var i = e._InfixToPostfixCache.get(t); if (i) return i.accessTime = Date.now(), i.result; if (!(t.includes("&&") || t.includes("||") || t.includes(")") || t.includes("("))) return [t]; for (var r = [], n = -1, o = function () { "" !== (u = u.trim()) && (r.push(u), u = "") }, a = function (t) { n < e._Stack.length - 1 && (e._Stack[++n] = t) }, s = function () { return e._Stack[n] }, l = function () { return -1 === n ? "!!INVALID EXPRESSION!!" : e._Stack[n--] }, c = 0, u = ""; c < t.length;) { var h = t.charAt(c), d = c < t.length - 1 ? t.substr(c, 2) : ""; if ("(" === h) u = "", a(h); else if (")" === h) { for (o(); -1 !== n && "(" !== s();)r.push(l()); l() } else if (e._OperatorPriority[d] > 1) { 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 < e.InfixToPostfixCacheCleanupSize; i++)e._InfixToPostfixCache.delete(t[i][0]) }, e.InfixToPostfixCacheLimitSize = 5e4, e.InfixToPostfixCacheCleanupSize = 25e3, e._InfixToPostfixCache = new Map, e._OperatorPriority = { ")": 0, "(": 1, "||": 2, "&&": 3 }, e._Stack = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""], e }(), At = function (e) { function t(t, i) { void 0 === i && (i = !1); var r = e.call(this) || this; return r.define = t, r.not = i, r } return W(t, e), t.prototype.isTrue = function (e) { var t = void 0 !== e[this.define]; return this.not && (t = !t), t }, t }(xt), Rt = function (e) { function t() { return null !== e && e.apply(this, arguments) || this } return W(t, e), t.prototype.isTrue = function (e) { return this.leftOperand.isTrue(e) || this.rightOperand.isTrue(e) }, t }(xt), Ct = function (e) { function t() { return null !== e && e.apply(this, arguments) || this } return W(t, e), t.prototype.isTrue = function (e) { return this.leftOperand.isTrue(e) && this.rightOperand.isTrue(e) }, t }(xt), Pt = function (e) { function t(t, i, r) { var n = e.call(this) || this; return n.define = t, n.operand = i, n.testValue = r, n } return W(t, e), t.prototype.isTrue = function (e) { var t = e[this.define]; void 0 === t && (t = this.define); var i = !1, r = parseInt(t), n = parseInt(this.testValue); switch (this.operand) { case ">": i = r > n; break; case "<": i = r < n; break; case "<=": i = r <= n; break; case ">=": i = r >= n; break; case "==": i = r === n; break; case "!=": i = r !== n }return i }, t }(xt); !function (e) { e[e.GLSL = 0] = "GLSL", e[e.WGSL = 1] = "WGSL" }(nt || (nt = {})); var It, Mt = /defined\s*?\((.+?)\)/g, Ot = /defined\s*?\[(.+?)\]/g, Dt = /#include\s?<(.+)>(\((.*)\))*(\[(.*)\])*/g, Nt = /__decl__/, Ft = /light\{X\}.(\w*)/g, Lt = /\{X\}/g, wt = [], Bt = 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 At(t[1].trim(), "!" === e[0]); for (var i = "", r = 0, n = 0, o = ["==", "!=", ">=", "<=", "<", ">"]; n < o.length && (i = o[n], !((r = e.indexOf(i)) > -1)); n++); if (-1 === r) return new At(e); var a = e.substring(0, r).trim(), s = e.substring(r + i.length).trim(); return new Pt(a, i, s) }, e._BuildSubExpression = function (e) { e = e.replace(Mt, "defined[$1]"); for (var t = [], i = 0, r = xt.infixToPostfix(e); i < r.length; i++) { var n = r[i]; if ("||" !== n && "&&" !== n) t.push(n); else if (t.length >= 2) { var o = t[t.length - 1], a = t[t.length - 2]; t.length -= 2; var s = "&&" == n ? new Ct : new Rt; "string" == typeof o && (o = o.replace(Ot, "defined($1)")), "string" == typeof a && (a = a.replace(Ot, "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(Ot, "defined($1)")), "string" == typeof l ? this._ExtractOperation(l) : l }, e._BuildExpression = function (e, t) { var i = new St, 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 At(n) : "#ifndef" === r ? new At(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 bt; 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 Et; 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 Et, i.children.push(o), a = this._BuildExpression(r, 7), o.children.push(a), this._MoveCursorWithinIf(t, o, a); break; case "#if": o = new Et, a = this._BuildExpression(r, 3), i.children.push(o), o.children.push(a), this._MoveCursorWithinIf(t, o, a) }continue } } var s = new bt; 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 bt, n = new Tt; 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; n < o.length; n++) { var a = o[n].replace("#define", "").replace(";", "").trim().split(" "); r[a[0]] = a.length > 1 ? a[1] : "" } return (null === (i = e.processor) || void 0 === i ? void 0 : i.shaderLanguage) === nt.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 === nt.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 (wt.length = 0; null !== (n = Dt.exec(t));)wt.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(Nt, ""), 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 < u.length; h += 2) { var d = new RegExp(u[h], "g"), p = u[h + 1]; c = c.replace(d, p) } if (t[4]) { var f = t[5]; if (-1 !== f.indexOf("..")) { var _ = f.split(".."), m = parseInt(_[0]), g = parseInt(_[1]), v = c.slice(0); c = "", isNaN(g) && (g = i.indexParameters[_[1]]); for (var y = m; y < g; y++)i.supportsUniformBuffers || (v = v.replace(Ft, (function (e, t) { return t + "{X}" }))), c += v.replace(Lt, y.toString()) + "\n" } else i.supportsUniformBuffers || (c = c.replace(Ft, (function (e, t) { return t + "{X}" }))), c = c.replace(Lt, f) } for (var b = [], T = 0, E = s; T < E.length; T++) { var S = E[T].split(t[0]); for (y = 0; y < S.length - 1; y++)b.push(S[y]), b.push(c); b.push(S[S.length - 1]) } s = b, l = l || c.indexOf("#include<") >= 0 || c.indexOf("#include <") >= 0 }, u = 0, h = wt; u < h.length; u++) { var d = c(h[u]); if ("object" == typeof d) return d.value } wt.length = 0, a = s.join(""), l ? this._ProcessIncludes(a.toString(), i, r) : r(a) }, e._FileToolsLoadFile = function (e, t, i, r, n, o) { throw ge("FileTools") }, e._MoveCursorRegex = /(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/, e }(), Ut = function () { function e() { } return e.GetShadersRepository = function (t) { return void 0 === t && (t = nt.GLSL), t === nt.GLSL ? e.ShadersRepository : e.ShadersRepositoryWGSL }, e.GetShadersStore = function (t) { return void 0 === t && (t = nt.GLSL), t === nt.GLSL ? e.ShadersStore : e.ShadersStoreWGSL }, e.GetIncludesShadersStore = function (t) { return void 0 === t && (t = nt.GLSL), t === nt.GLSL ? e.IncludesShadersStore : e.IncludesShadersStoreWGSL }, e.ShadersRepository = "src/Shaders/", e.ShadersStore = {}, e.IncludesShadersStore = {}, e.ShadersRepositoryWGSL = "src/ShadersWGSL/", e.ShadersStoreWGSL = {}, e.IncludesShadersStoreWGSL = {}, e }(), Vt = function () { function e(t, i, r, n, o, a, s, l, c, h, d, p) { void 0 === n && (n = null), void 0 === a && (a = null), void 0 === s && (s = null), void 0 === l && (l = null), void 0 === c && (c = null), void 0 === d && (d = ""), void 0 === p && (p = nt.GLSL); var f, _, m, g = this; this.name = null, this.defines = "", this.onCompiled = null, this.onError = null, this.onBind = null, this.uniqueId = 0, this.onCompileObservable = new u, this.onErrorObservable = new u, this._onBindObservable = null, this._wasPreviouslyReady = !1, this._forceRebindOnNextCall = !1, this._wasPreviouslyUsingInstances = null, this._isDisposed = !1, this._bonesComputationForcedToCPU = !1, this._uniformBuffersNames = {}, this._multiTarget = !1, this._samplers = {}, this._isReady = !1, this._compilationError = "", this._allFallbacksProcessed = !1, this._uniforms = {}, this._key = "", this._fallbacks = null, this._vertexSourceCodeOverride = "", this._fragmentSourceCodeOverride = "", this._transformFeedbackVaryings = null, this._pipelineContext = null, this._vertexSourceCode = "", this._fragmentSourceCode = "", this._vertexSourceCodeBeforeMigration = "", this._fragmentSourceCodeBeforeMigration = "", this._rawVertexSourceCode = "", this._rawFragmentSourceCode = "", this.name = t, this._key = d; var v, y, b = void 0, T = null; if (i.attributes) { var E = i; if (this._engine = r, this._attributesNames = E.attributes, this._uniformsNames = E.uniformsNames.concat(E.samplers), this._samplerList = E.samplers.slice(), this.defines = E.defines, this.onError = E.onError, this.onCompiled = E.onCompiled, this._fallbacks = E.fallbacks, this._indexParameters = E.indexParameters, this._transformFeedbackVaryings = E.transformFeedbackVaryings || null, this._multiTarget = !!E.multiTarget, this._shaderLanguage = null !== (f = E.shaderLanguage) && void 0 !== f ? f : nt.GLSL, E.uniformBuffersNames) { this._uniformBuffersNamesList = E.uniformBuffersNames.slice(); for (var S = 0; S < E.uniformBuffersNames.length; S++)this._uniformBuffersNames[E.uniformBuffersNames[S]] = S } T = null !== (_ = E.processFinalCode) && void 0 !== _ ? _ : null, b = null !== (m = E.processCodeAfterIncludes) && void 0 !== m ? m : void 0 } else this._engine = o, this.defines = null == a ? "" : a, this._uniformsNames = r.concat(n), this._samplerList = n ? n.slice() : [], this._attributesNames = i, this._uniformBuffersNamesList = [], this._shaderLanguage = p, this.onError = c, this.onCompiled = l, this._indexParameters = h, this._fallbacks = s; this._attributeLocationByName = {}, this.uniqueId = e._UniqueIdSeed++; var x = et() ? this._engine.getHostDocument() : null; t.vertexSource ? v = "source:" + t.vertexSource : t.vertexElement ? (v = x ? x.getElementById(t.vertexElement) : null) || (v = t.vertexElement) : v = t.vertex || t, t.fragmentSource ? y = "source:" + t.fragmentSource : t.fragmentElement ? (y = x ? x.getElementById(t.fragmentElement) : null) || (y = t.fragmentElement) : y = t.fragment || t, this._processingContext = this._engine._getShaderProcessingContext(this._shaderLanguage); var A = { defines: this.defines.split("\n"), indexParameters: this._indexParameters, isFragment: !1, shouldUseHighPrecisionShader: this._engine._shouldUseHighPrecisionShader, processor: this._engine._getShaderProcessor(this._shaderLanguage), supportsUniformBuffers: this._engine.supportsUniformBuffers, shadersRepository: Ut.GetShadersRepository(this._shaderLanguage), includesShadersStore: Ut.GetIncludesShadersStore(this._shaderLanguage), version: (100 * this._engine.version).toString(), platformName: this._engine.shaderPlatformName, processingContext: this._processingContext, isNDCHalfZRange: this._engine.isNDCHalfZRange, useReverseDepthBuffer: this._engine.useReverseDepthBuffer, processCodeAfterIncludes: b }, R = [void 0, void 0], C = function () { if (R[0] && R[1]) { A.isFragment = !0; var e = R[0], i = R[1]; Bt.Process(i, A, (function (i, r) { g._fragmentSourceCodeBeforeMigration = r, T && (i = T("fragment", i)); var n = Bt.Finalize(e, i, A); A = null, g._useFinalCode(n.vertexCode, n.fragmentCode, t) }), g._engine) } }; this._loadShader(v, "Vertex", "", (function (e) { Bt.Initialize(A), Bt.Process(e, A, (function (t, i) { g._rawVertexSourceCode = e, g._vertexSourceCodeBeforeMigration = i, T && (t = T("vertex", t)), R[0] = t, C() }), g._engine) })), this._loadShader(y, "Fragment", "Pixel", (function (e) { g._rawFragmentSourceCode = e, R[1] = e, C() })) } return Object.defineProperty(e, "ShadersRepository", { get: function () { return Ut.ShadersRepository }, set: function (e) { Ut.ShadersRepository = 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 }), e.prototype._useFinalCode = function (e, t, i) { if (i) { var r = i.vertexElement || i.vertex || i.spectorName || i, n = i.fragmentElement || i.fragment || i.spectorName || i; this._vertexSourceCode = (this._shaderLanguage === nt.WGSL ? "//" : "") + "#define SHADER_NAME vertex:" + r + "\n" + e, this._fragmentSourceCode = (this._shaderLanguage === nt.WGSL ? "//" : "") + "#define SHADER_NAME fragment:" + n + "\n" + t } else this._vertexSourceCode = e, this._fragmentSourceCode = t; this._prepareEffect() }, Object.defineProperty(e.prototype, "key", { get: function () { return this._key }, enumerable: !1, configurable: !0 }), e.prototype.isReady = function () { try { return this._isReadyInternal() } catch (e) { return !1 } }, e.prototype._isReadyInternal = function () { return !!this._isReady || !!this._pipelineContext && this._pipelineContext.isReady }, e.prototype.getEngine = function () { return this._engine }, e.prototype.getPipelineContext = function () { return this._pipelineContext }, e.prototype.getAttributesNames = function () { return this._attributesNames }, e.prototype.getAttributeLocation = function (e) { return this._attributes[e] }, e.prototype.getAttributeLocationByName = function (e) { return this._attributeLocationByName[e] }, e.prototype.getAttributesCount = function () { return this._attributes.length }, e.prototype.getUniformIndex = function (e) { return this._uniformsNames.indexOf(e) }, e.prototype.getUniform = function (e) { return this._uniforms[e] }, e.prototype.getSamplers = function () { return this._samplerList }, e.prototype.getUniformNames = function () { return this._uniformsNames }, e.prototype.getUniformBuffersNames = function () { return this._uniformBuffersNamesList }, e.prototype.getIndexParameters = function () { return this._indexParameters }, e.prototype.getCompilationError = function () { return this._compilationError }, e.prototype.allFallbacksProcessed = function () { return this._allFallbacksProcessed }, e.prototype.executeWhenCompiled = function (e) { var t = this; this.isReady() ? e(this) : (this.onCompileObservable.add((function (t) { e(t) })), this._pipelineContext && !this._pipelineContext.isAsync || setTimeout((function () { t._checkIsReady(null) }), 16)) }, e.prototype._checkIsReady = function (e) { var t = this; try { if (this._isReadyInternal()) return } catch (t) { return void this._processCompilationErrors(t, e) } this._isDisposed || setTimeout((function () { t._checkIsReady(e) }), 16) }, e.prototype._loadShader = function (e, t, i, r) { if ("undefined" != typeof HTMLElement && e instanceof HTMLElement) r(rt(e)); else if ("source:" !== e.substr(0, 7)) if ("base64:" !== e.substr(0, 7)) { var n, o = Ut.GetShadersStore(this._shaderLanguage); o[e + t + "Shader"] ? r(o[e + t + "Shader"]) : i && o[e + i + "Shader"] ? r(o[e + i + "Shader"]) : (n = "." === e[0] || "/" === e[0] || e.indexOf("http") > -1 ? e : Ut.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 < e.length; t++)e[t].markAllMaterialsAsDirty(a.MATERIAL_AllDirtyFlag); n._pipelineContext._handlesSpectorRebuildCallback(i) }, this._fallbacks = null, this._prepareEffect() }, e.prototype._prepareEffect = function () { var e = this, t = this._attributesNames, i = this.defines, r = this._pipelineContext; this._isReady = !1; try { var n = this._engine; this._pipelineContext = n.createPipelineContext(this._processingContext), this._pipelineContext._name = this._key; var o = this._rebuildProgram.bind(this); this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride ? n._preparePipelineContext(this._pipelineContext, this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, !0, this._rawVertexSourceCode, this._rawFragmentSourceCode, o, null, this._transformFeedbackVaryings, this._key) : n._preparePipelineContext(this._pipelineContext, this._vertexSourceCode, this._fragmentSourceCode, !1, this._rawVertexSourceCode, this._rawFragmentSourceCode, o, i, this._transformFeedbackVaryings, this._key), n._executeWhenRenderingStateIsCompiled(this._pipelineContext, (function () { if (e._attributes = [], e._pipelineContext._fillEffectInformation(e, e._uniformBuffersNames, e._uniformsNames, e._uniforms, e._samplerList, e._samplers, t, e._attributes), t) for (var i = 0; i < t.length; i++) { var o = t[i]; e._attributeLocationByName[o] = e._attributes[i] } n.bindSamplers(e), e._compilationError = "", e._isReady = !0, e.onCompiled && e.onCompiled(e), e.onCompileObservable.notifyObservers(e), e.onCompileObservable.clear(), e._fallbacks && e._fallbacks.unBindMesh(), r && e.getEngine()._deletePipelineContext(r) })), this._pipelineContext.isAsync && this._checkIsReady(r) } catch (e) { this._processCompilationErrors(e, r) } }, e.prototype._getShaderCodeAndErrorLine = function (e, t, i) { var r = i ? /FRAGMENT SHADER ERROR: 0:(\d+?):/ : /VERTEX SHADER ERROR: 0:(\d+?):/, n = null; if (t && e) { var o = t.match(r); if (o && 2 === o.length) { var a = parseInt(o[1]), s = e.split("\n", -1); s.length >= 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; n < t.length; n++) { var o = i + (n - 1).toString(); this._samplerList.splice(r + n, 0, o) } for (var a = 0, s = 0, l = this._samplerList; s < l.length; s++) { var c = l[s]; this._samplers[c] = a, a += 1 } } this._engine.setTextureArray(this._samplers[e], this._uniforms[e], t, e) }, e.prototype.setTextureFromPostProcess = function (e, t) { this._engine.setTextureFromPostProcess(this._samplers[e], t, e) }, e.prototype.setTextureFromPostProcessOutput = function (e, t) { this._engine.setTextureFromPostProcessOutput(this._samplers[e], t, e) }, e.prototype.bindUniformBuffer = function (t, i) { var r = this._uniformBuffersNames[i]; void 0 === r || e._BaseCache[r] === t && this._engine._features.useUBOBindingCache || (e._BaseCache[r] = t, this._engine.bindUniformBufferBase(t, r, i)) }, e.prototype.bindUniformBlock = function (e, t) { this._engine.bindUniformBlock(this._pipelineContext, e, t) }, e.prototype.setInt = function (e, t) { return this._pipelineContext.setInt(e, t), this }, e.prototype.setInt2 = function (e, t, i) { return this._pipelineContext.setInt2(e, t, i), this }, e.prototype.setInt3 = function (e, t, i, r) { return this._pipelineContext.setInt3(e, t, i, r), this }, e.prototype.setInt4 = function (e, t, i, r, n) { return this._pipelineContext.setInt4(e, t, i, r, n), this }, e.prototype.setIntArray = function (e, t) { return this._pipelineContext.setIntArray(e, t), this }, e.prototype.setIntArray2 = function (e, t) { return this._pipelineContext.setIntArray2(e, t), this }, e.prototype.setIntArray3 = function (e, t) { return this._pipelineContext.setIntArray3(e, t), this }, e.prototype.setIntArray4 = function (e, t) { return this._pipelineContext.setIntArray4(e, t), this }, e.prototype.setUInt = function (e, t) { return this._pipelineContext.setInt(e, t), this }, e.prototype.setUInt2 = function (e, t, i) { return this._pipelineContext.setInt2(e, t, i), this }, e.prototype.setUInt3 = function (e, t, i, r) { return this._pipelineContext.setInt3(e, t, i, r), this }, e.prototype.setUInt4 = function (e, t, i, r, n) { return this._pipelineContext.setInt4(e, t, i, r, n), this }, e.prototype.setUIntArray = function (e, t) { return this._pipelineContext.setUIntArray(e, t), this }, e.prototype.setUIntArray2 = function (e, t) { return this._pipelineContext.setUIntArray2(e, t), this }, e.prototype.setUIntArray3 = function (e, t) { return this._pipelineContext.setUIntArray3(e, t), this }, e.prototype.setUIntArray4 = function (e, t) { return this._pipelineContext.setUIntArray4(e, t), this }, e.prototype.setFloatArray = function (e, t) { return this._pipelineContext.setArray(e, t), this }, e.prototype.setFloatArray2 = function (e, t) { return this._pipelineContext.setArray2(e, t), this }, e.prototype.setFloatArray3 = function (e, t) { return this._pipelineContext.setArray3(e, t), this }, e.prototype.setFloatArray4 = function (e, t) { return this._pipelineContext.setArray4(e, t), this }, e.prototype.setArray = function (e, t) { return this._pipelineContext.setArray(e, t), this }, e.prototype.setArray2 = function (e, t) { return this._pipelineContext.setArray2(e, t), this }, e.prototype.setArray3 = function (e, t) { return this._pipelineContext.setArray3(e, t), this }, e.prototype.setArray4 = function (e, t) { return this._pipelineContext.setArray4(e, t), this }, e.prototype.setMatrices = function (e, t) { return this._pipelineContext.setMatrices(e, t), this }, e.prototype.setMatrix = function (e, t) { return this._pipelineContext.setMatrix(e, t), this }, e.prototype.setMatrix3x3 = function (e, t) { return this._pipelineContext.setMatrix3x3(e, t), this }, e.prototype.setMatrix2x2 = function (e, t) { return this._pipelineContext.setMatrix2x2(e, t), this }, e.prototype.setFloat = function (e, t) { return this._pipelineContext.setFloat(e, t), this }, e.prototype.setBool = function (e, t) { return this._pipelineContext.setInt(e, t ? 1 : 0), this }, e.prototype.setVector2 = function (e, t) { return this._pipelineContext.setVector2(e, t), this }, e.prototype.setFloat2 = function (e, t, i) { return this._pipelineContext.setFloat2(e, t, i), this }, e.prototype.setVector3 = function (e, t) { return this._pipelineContext.setVector3(e, t), this }, e.prototype.setFloat3 = function (e, t, i, r) { return this._pipelineContext.setFloat3(e, t, i, r), this }, e.prototype.setVector4 = function (e, t) { return this._pipelineContext.setVector4(e, t), this }, e.prototype.setQuaternion = function (e, t) { return this._pipelineContext.setQuaternion(e, t), this }, e.prototype.setFloat4 = function (e, t, i, r, n) { return this._pipelineContext.setFloat4(e, t, i, r, n), this }, e.prototype.setColor3 = function (e, t) { return this._pipelineContext.setColor3(e, t), this }, e.prototype.setColor4 = function (e, t, i) { return this._pipelineContext.setColor4(e, t, i), this }, e.prototype.setDirectColor4 = function (e, t) { return this._pipelineContext.setDirectColor4(e, t), this }, e.prototype.dispose = function () { this._pipelineContext && this._pipelineContext.dispose(), this._engine._releaseEffect(this), this._isDisposed = !0 }, e.RegisterShader = function (e, t, i, r) { void 0 === r && (r = nt.GLSL), t && (Ut.GetShadersStore(r)["".concat(e, "PixelShader")] = t), i && (Ut.GetShadersStore(r)["".concat(e, "VertexShader")] = i) }, e.ResetCache = function () { e._BaseCache = {} }, e.LogShaderCodeOnCompilationError = !0, e._UniqueIdSeed = 0, e._BaseCache = {}, e.ShadersStore = Ut.ShadersStore, e.IncludesShadersStore = Ut.IncludesShadersStore, e }(), kt = function () { function e(e) { void 0 === e && (e = !0), this._isDepthTestDirty = !1, this._isDepthMaskDirty = !1, this._isDepthFuncDirty = !1, this._isCullFaceDirty = !1, this._isCullDirty = !1, this._isZOffsetDirty = !1, this._isFrontFaceDirty = !1, e && this.reset() } return Object.defineProperty(e.prototype, "isDirty", { get: function () { return this._isDepthFuncDirty || this._isDepthTestDirty || this._isDepthMaskDirty || this._isCullFaceDirty || this._isCullDirty || this._isZOffsetDirty || this._isFrontFaceDirty }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "zOffset", { get: function () { return this._zOffset }, set: function (e) { this._zOffset !== e && (this._zOffset = e, this._isZOffsetDirty = !0) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "zOffsetUnits", { get: function () { return this._zOffsetUnits }, set: function (e) { this._zOffsetUnits !== e && (this._zOffsetUnits = e, this._isZOffsetDirty = !0) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "cullFace", { get: function () { return this._cullFace }, set: function (e) { this._cullFace !== e && (this._cullFace = e, this._isCullFaceDirty = !0) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "cull", { get: function () { return this._cull }, set: function (e) { this._cull !== e && (this._cull = e, this._isCullDirty = !0) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "depthFunc", { get: function () { return this._depthFunc }, set: function (e) { this._depthFunc !== e && (this._depthFunc = e, this._isDepthFuncDirty = !0) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "depthMask", { get: function () { return this._depthMask }, set: function (e) { this._depthMask !== e && (this._depthMask = e, this._isDepthMaskDirty = !0) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "depthTest", { get: function () { return this._depthTest }, set: function (e) { this._depthTest !== e && (this._depthTest = e, this._isDepthTestDirty = !0) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "frontFace", { get: function () { return this._frontFace }, set: function (e) { this._frontFace !== e && (this._frontFace = e, this._isFrontFaceDirty = !0) }, enumerable: !1, configurable: !0 }), e.prototype.reset = function () { this._depthMask = !0, this._depthTest = !0, this._depthFunc = null, this._cullFace = null, this._cull = null, this._zOffset = 0, this._zOffsetUnits = 0, this._frontFace = null, this._isDepthTestDirty = !0, this._isDepthMaskDirty = !0, this._isDepthFuncDirty = !1, this._isCullFaceDirty = !1, this._isCullDirty = !1, this._isZOffsetDirty = !0, this._isFrontFaceDirty = !1 }, e.prototype.apply = function (e) { this.isDirty && (this._isCullDirty && (this.cull ? e.enable(e.CULL_FACE) : e.disable(e.CULL_FACE), this._isCullDirty = !1), this._isCullFaceDirty && (e.cullFace(this.cullFace), this._isCullFaceDirty = !1), this._isDepthMaskDirty && (e.depthMask(this.depthMask), this._isDepthMaskDirty = !1), this._isDepthTestDirty && (this.depthTest ? e.enable(e.DEPTH_TEST) : e.disable(e.DEPTH_TEST), this._isDepthTestDirty = !1), this._isDepthFuncDirty && (e.depthFunc(this.depthFunc), this._isDepthFuncDirty = !1), this._isZOffsetDirty && (this.zOffset || this.zOffsetUnits ? (e.enable(e.POLYGON_OFFSET_FILL), e.polygonOffset(this.zOffset, this.zOffsetUnits)) : e.disable(e.POLYGON_OFFSET_FILL), this._isZOffsetDirty = !1), this._isFrontFaceDirty && (e.frontFace(this.frontFace), this._isFrontFaceDirty = !1)) }, e }(), Gt = function () { function e() { this.reset() } return e.prototype.reset = function () { this.enabled = !1, this.mask = 255, this.func = e.ALWAYS, this.funcRef = 1, this.funcMask = 255, this.opStencilFail = e.KEEP, this.opDepthFail = e.KEEP, this.opStencilDepthPass = e.REPLACE }, Object.defineProperty(e.prototype, "stencilFunc", { get: function () { return this.func }, set: function (e) { this.func = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "stencilFuncRef", { get: function () { return this.funcRef }, set: function (e) { this.funcRef = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "stencilFuncMask", { get: function () { return this.funcMask }, set: function (e) { this.funcMask = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "stencilOpStencilFail", { get: function () { return this.opStencilFail }, set: function (e) { this.opStencilFail = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "stencilOpDepthFail", { get: function () { return this.opDepthFail }, set: function (e) { this.opDepthFail = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "stencilOpStencilDepthPass", { get: function () { return this.opStencilDepthPass }, set: function (e) { this.opStencilDepthPass = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "stencilMask", { get: function () { return this.mask }, set: function (e) { this.mask = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "stencilTest", { get: function () { return this.enabled }, set: function (e) { this.enabled = e }, enumerable: !1, configurable: !0 }), e.ALWAYS = a.ALWAYS, e.KEEP = a.KEEP, e.REPLACE = a.REPLACE, e }(), zt = function () { function e() { this._blendFunctionParameters = new Array(4), this._blendEquationParameters = new Array(2), this._blendConstants = new Array(4), this._isBlendConstantsDirty = !1, this._alphaBlend = !1, this._isAlphaBlendDirty = !1, this._isBlendFunctionParametersDirty = !1, this._isBlendEquationParametersDirty = !1, this.reset() } return Object.defineProperty(e.prototype, "isDirty", { get: function () { return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty || this._isBlendEquationParametersDirty }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "alphaBlend", { get: function () { return this._alphaBlend }, set: function (e) { this._alphaBlend !== e && (this._alphaBlend = e, this._isAlphaBlendDirty = !0) }, enumerable: !1, configurable: !0 }), e.prototype.setAlphaBlendConstants = function (e, t, i, r) { this._blendConstants[0] === e && this._blendConstants[1] === t && this._blendConstants[2] === i && this._blendConstants[3] === r || (this._blendConstants[0] = e, this._blendConstants[1] = t, this._blendConstants[2] = i, this._blendConstants[3] = r, this._isBlendConstantsDirty = !0) }, e.prototype.setAlphaBlendFunctionParameters = function (e, t, i, r) { this._blendFunctionParameters[0] === e && this._blendFunctionParameters[1] === t && this._blendFunctionParameters[2] === i && this._blendFunctionParameters[3] === r || (this._blendFunctionParameters[0] = e, this._blendFunctionParameters[1] = t, this._blendFunctionParameters[2] = i, this._blendFunctionParameters[3] = r, this._isBlendFunctionParametersDirty = !0) }, e.prototype.setAlphaEquationParameters = function (e, t) { this._blendEquationParameters[0] === e && this._blendEquationParameters[1] === t || (this._blendEquationParameters[0] = e, this._blendEquationParameters[1] = t, this._isBlendEquationParametersDirty = !0) }, e.prototype.reset = function () { this._alphaBlend = !1, this._blendFunctionParameters[0] = null, this._blendFunctionParameters[1] = null, this._blendFunctionParameters[2] = null, this._blendFunctionParameters[3] = null, this._blendEquationParameters[0] = null, this._blendEquationParameters[1] = null, this._blendConstants[0] = null, this._blendConstants[1] = null, this._blendConstants[2] = null, this._blendConstants[3] = null, this._isAlphaBlendDirty = !0, this._isBlendFunctionParametersDirty = !1, this._isBlendEquationParametersDirty = !1, this._isBlendConstantsDirty = !1 }, e.prototype.apply = function (e) { this.isDirty && (this._isAlphaBlendDirty && (this._alphaBlend ? e.enable(e.BLEND) : e.disable(e.BLEND), this._isAlphaBlendDirty = !1), this._isBlendFunctionParametersDirty && (e.blendFuncSeparate(this._blendFunctionParameters[0], this._blendFunctionParameters[1], this._blendFunctionParameters[2], this._blendFunctionParameters[3]), this._isBlendFunctionParametersDirty = !1), this._isBlendEquationParametersDirty && (e.blendEquationSeparate(this._blendEquationParameters[0], this._blendEquationParameters[1]), this._isBlendEquationParametersDirty = !1), this._isBlendConstantsDirty && (e.blendColor(this._blendConstants[0], this._blendConstants[1], this._blendConstants[2], this._blendConstants[3]), this._isBlendConstantsDirty = !1)) }, e }(), Wt = function () { function e() { this.samplingMode = -1, this._useMipMaps = !0, this._cachedWrapU = null, this._cachedWrapV = null, this._cachedWrapR = null, this._cachedAnisotropicFilteringLevel = null, this._comparisonFunction = 0 } return Object.defineProperty(e.prototype, "wrapU", { get: function () { return this._cachedWrapU }, set: function (e) { this._cachedWrapU = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "wrapV", { get: function () { return this._cachedWrapV }, set: function (e) { this._cachedWrapV = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "wrapR", { get: function () { return this._cachedWrapR }, set: function (e) { this._cachedWrapR = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "anisotropicFilteringLevel", { get: function () { return this._cachedAnisotropicFilteringLevel }, set: function (e) { this._cachedAnisotropicFilteringLevel = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "comparisonFunction", { get: function () { return this._comparisonFunction }, set: function (e) { this._comparisonFunction = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "useMipMaps", { get: function () { return this._useMipMaps }, set: function (e) { this._useMipMaps = e }, enumerable: !1, configurable: !0 }), e.prototype.setParameters = function (e, t, i, r, n, o) { return void 0 === e && (e = a.TEXTURE_WRAP_ADDRESSMODE), void 0 === t && (t = a.TEXTURE_WRAP_ADDRESSMODE), void 0 === i && (i = a.TEXTURE_WRAP_ADDRESSMODE), void 0 === r && (r = 1), void 0 === n && (n = a.TEXTURE_BILINEAR_SAMPLINGMODE), void 0 === o && (o = 0), this._cachedWrapU = e, this._cachedWrapV = t, this._cachedWrapR = i, this._cachedAnisotropicFilteringLevel = r, this.samplingMode = n, this._comparisonFunction = o, this }, e.prototype.compareSampler = function (e) { return this._cachedWrapU === e._cachedWrapU && this._cachedWrapV === e._cachedWrapV && this._cachedWrapR === e._cachedWrapR && this._cachedAnisotropicFilteringLevel === e._cachedAnisotropicFilteringLevel && this.samplingMode === e.samplingMode && this._comparisonFunction === e._comparisonFunction && this._useMipMaps === e._useMipMaps }, e }(); !function (e) { e[e.Unknown = 0] = "Unknown", e[e.Url = 1] = "Url", e[e.Temp = 2] = "Temp", e[e.Raw = 3] = "Raw", e[e.Dynamic = 4] = "Dynamic", e[e.RenderTarget = 5] = "RenderTarget", e[e.MultiRenderTarget = 6] = "MultiRenderTarget", e[e.Cube = 7] = "Cube", e[e.CubeRaw = 8] = "CubeRaw", e[e.CubePrefiltered = 9] = "CubePrefiltered", e[e.Raw3D = 10] = "Raw3D", e[e.Raw2DArray = 11] = "Raw2DArray", e[e.DepthStencil = 12] = "DepthStencil", e[e.CubeRawRGBD = 13] = "CubeRawRGBD", e[e.Depth = 14] = "Depth" }(It || (It = {})); var Ht = function (e) { function t(i, r, n) { void 0 === n && (n = !1); var o = e.call(this) || this; return o.isReady = !1, o.isCube = !1, o.is3D = !1, o.is2DArray = !1, o.isMultiview = !1, o.url = "", o.generateMipMaps = !1, o.samples = 0, o.type = -1, o.format = -1, o.onLoadedObservable = new u, o.onErrorObservable = new u, o.onRebuildCallback = null, o.width = 0, o.height = 0, o.depth = 0, o.baseWidth = 0, o.baseHeight = 0, o.baseDepth = 0, o.invertY = !1, o._invertVScale = !1, o._associatedChannel = -1, o._source = It.Unknown, o._buffer = null, o._bufferView = null, o._bufferViewArray = null, o._bufferViewArrayArray = null, o._size = 0, o._extension = "", o._files = null, o._workingCanvas = null, o._workingContext = null, o._cachedCoordinatesMode = null, o._isDisabled = !1, o._compression = null, o._sphericalPolynomial = null, o._sphericalPolynomialPromise = null, o._sphericalPolynomialComputed = !1, o._lodGenerationScale = 0, o._lodGenerationOffset = 0, o._useSRGBBuffer = !1, o._lodTextureHigh = null, o._lodTextureMid = null, o._lodTextureLow = null, o._isRGBD = !1, o._linearSpecularLOD = !1, o._irradianceTexture = null, o._hardwareTexture = null, o._maxLodLevel = null, o._references = 1, o._gammaSpace = null, o._engine = i, o._source = r, o._uniqueId = t._Counter++, n || (o._hardwareTexture = i._createHardwareTexture()), o } return W(t, e), Object.defineProperty(t.prototype, "useMipMaps", { get: function () { return this.generateMipMaps }, set: function (e) { this.generateMipMaps = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "uniqueId", { get: function () { return this._uniqueId }, enumerable: !1, configurable: !0 }), t.prototype._setUniqueId = function (e) { this._uniqueId = e }, t.prototype.getEngine = function () { return this._engine }, Object.defineProperty(t.prototype, "source", { get: function () { return this._source }, enumerable: !1, configurable: !0 }), t.prototype.incrementReferences = function () { this._references++ }, t.prototype.updateSize = function (e, t, i) { void 0 === i && (i = 1), this._engine.updateTextureDimensions(this, e, t, i), this.width = e, this.height = t, this.depth = i, this.baseWidth = e, this.baseHeight = t, this.baseDepth = i, this._size = e * t * i }, t.prototype._rebuild = function () { var e, t = this; if (this.isReady = !1, this._cachedCoordinatesMode = null, this._cachedWrapU = null, this._cachedWrapV = null, this._cachedWrapR = null, this._cachedAnisotropicFilteringLevel = null, this.onRebuildCallback) { var i = this.onRebuildCallback(this), r = function (e) { e._swapAndDie(t, !1), t.isReady = i.isReady }; i.isAsync ? i.proxy.then(r) : r(i.proxy) } else { var n; switch (this.source) { case It.Temp: break; case It.Url: return void (n = this._engine.createTexture(null !== (e = this._originalUrl) && void 0 !== e ? e : this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, (function (e) { e._swapAndDie(t, !1), t.isReady = !0 }), null, this._buffer, void 0, this.format, this._extension, void 0, void 0, void 0, this._useSRGBBuffer)); case It.Raw: (n = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type, void 0, this._useSRGBBuffer))._swapAndDie(this, !1), this.isReady = !0; break; case It.Raw3D: (n = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type))._swapAndDie(this, !1), this.isReady = !0; break; case It.Raw2DArray: (n = this._engine.createRawTexture2DArray(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type))._swapAndDie(this, !1), this.isReady = !0; break; case It.Dynamic: (n = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode))._swapAndDie(this, !1), this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, void 0, void 0, !0); break; case It.Cube: return void (n = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, (function () { n._swapAndDie(t, !1), t.isReady = !0 }), null, this.format, this._extension, !1, 0, 0, null, void 0, this._useSRGBBuffer)); case It.CubeRaw: (n = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression))._swapAndDie(this, !1), this.isReady = !0; break; case It.CubeRawRGBD: return; case It.CubePrefiltered: return void ((n = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, (function (e) { e && e._swapAndDie(t, !1), t.isReady = !0 }), null, this.format, this._extension))._sphericalPolynomial = this._sphericalPolynomial) } } }, t.prototype._swapAndDie = function (e, t) { var i; void 0 === t && (t = !0), null === (i = this._hardwareTexture) || void 0 === i || i.setUsage(e._source, this.generateMipMaps, this.isCube, this.width, this.height), e._hardwareTexture = this._hardwareTexture, t && (e._isRGBD = this._isRGBD), this._lodTextureHigh && (e._lodTextureHigh && e._lodTextureHigh.dispose(), e._lodTextureHigh = this._lodTextureHigh), this._lodTextureMid && (e._lodTextureMid && e._lodTextureMid.dispose(), e._lodTextureMid = this._lodTextureMid), this._lodTextureLow && (e._lodTextureLow && e._lodTextureLow.dispose(), e._lodTextureLow = this._lodTextureLow), this._irradianceTexture && (e._irradianceTexture && e._irradianceTexture.dispose(), e._irradianceTexture = this._irradianceTexture); var r = this._engine.getLoadedTexturesCache(), n = r.indexOf(this); -1 !== n && r.splice(n, 1), -1 === (n = r.indexOf(e)) && r.push(e) }, t.prototype.dispose = function () { this._references--, this.onLoadedObservable.clear(), this.onErrorObservable.clear(), 0 === this._references && (this._engine._releaseTexture(this), this._hardwareTexture = null) }, t._Counter = 0, t }(Wt), Xt = function () { function e() { this.shaderLanguage = nt.GLSL } return e.prototype.postProcessor = function (e, t, i, r, n) { return n.getCaps().drawBuffersExtension || (e = e.replace(/#extension.+GL_EXT_draw_buffers.+(enable|require)/g, "")), e }, e }(), jt = /(flat\s)?\s*varying\s*.*/, Yt = function () { function e() { this.shaderLanguage = nt.GLSL } return e.prototype.attributeProcessor = function (e) { return e.replace("attribute", "in") }, e.prototype.varyingCheck = function (e, t) { return jt.test(e) }, e.prototype.varyingProcessor = function (e, t) { return e.replace("varying", t ? "in" : "out") }, e.prototype.postProcessor = function (e, t, i) { var r = -1 !== e.search(/#extension.+GL_EXT_draw_buffers.+require/); if (e = (e = e.replace(/#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g, "")).replace(/texture2D\s*\(/g, "texture("), i) { var n = -1 !== e.search(/layout *\(location *= *0\) *out/g); 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(/void\s+?main\s*\(/g, (r || n ? "" : "layout(location = 0) out vec4 glFragColor;\n") + "void main(") } else if (-1 !== t.indexOf("#define MULTIVIEW")) return "#extension GL_OVR_multiview2 : require\nlayout (num_views = 2) in;\n" + e; return e }, e }(), Kt = function () { function e() { this.references = 0, this.capacity = 0, this.is32Bits = !1, this.uniqueId = e._Counter++ } return Object.defineProperty(e.prototype, "underlyingResource", { get: function () { return null }, enumerable: !1, configurable: !0 }), e._Counter = 0, e }(), Qt = function (e) { function t(t) { var i = e.call(this) || this; return i._buffer = t, i } return W(t, e), Object.defineProperty(t.prototype, "underlyingResource", { get: function () { return this._buffer }, enumerable: !1, configurable: !0 }), t }(Kt), qt = function () { function e() { this._valueCache = {}, this.vertexCompilationError = null, this.fragmentCompilationError = null, this.programLinkError = null, this.programValidationError = null, this._isDisposed = !1 } return Object.defineProperty(e.prototype, "isAsync", { get: function () { return this.isParallelCompiled }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isReady", { get: function () { return !!this.program && (!this.isParallelCompiled || this.engine._isRenderingStateCompiled(this)) }, enumerable: !1, configurable: !0 }), e.prototype._handlesSpectorRebuildCallback = function (e) { e && this.program && e(this.program) }, e.prototype._fillEffectInformation = function (e, t, i, r, n, o, a, s) { var l, c = this.engine; if (c.supportsUniformBuffers) for (var u in t) e.bindUniformBlock(u, t[u]); for (this.engine.getUniforms(this, i).forEach((function (e, t) { r[i[t]] = e })), this._uniforms = r, l = 0; l < n.length; l++)null == e.getUniform(n[l]) && (n.splice(l, 1), l--); n.forEach((function (e, t) { o[e] = t })); for (var h = 0, d = c.getAttributes(this, a); h < d.length; h++) { var p = d[h]; s.push(p) } }, e.prototype.dispose = function () { this._uniforms = {}, this._isDisposed = !0 }, e.prototype._cacheMatrix = function (e, t) { var i = this._valueCache[e], r = t.updateFlag; return (void 0 === i || i !== r) && (this._valueCache[e] = r, !0) }, e.prototype._cacheFloat2 = function (e, t, i) { var r = this._valueCache[e]; if (!r || 2 !== r.length) return r = [t, i], this._valueCache[e] = r, !0; var n = !1; return r[0] !== t && (r[0] = t, n = !0), r[1] !== i && (r[1] = i, n = !0), n }, e.prototype._cacheFloat3 = function (e, t, i, r) { var n = this._valueCache[e]; if (!n || 3 !== n.length) return n = [t, i, r], this._valueCache[e] = n, !0; var o = !1; return n[0] !== t && (n[0] = t, o = !0), n[1] !== i && (n[1] = i, o = !0), n[2] !== r && (n[2] = r, o = !0), o }, e.prototype._cacheFloat4 = function (e, t, i, r, n) { var o = this._valueCache[e]; if (!o || 4 !== o.length) return o = [t, i, r, n], this._valueCache[e] = o, !0; var a = !1; return o[0] !== t && (o[0] = t, a = !0), o[1] !== i && (o[1] = i, a = !0), o[2] !== r && (o[2] = r, a = !0), o[3] !== n && (o[3] = n, a = !0), a }, e.prototype.setInt = function (e, t) { var i = this._valueCache[e]; void 0 !== i && i === t || this.engine.setInt(this._uniforms[e], t) && (this._valueCache[e] = t) }, e.prototype.setInt2 = function (e, t, i) { this._cacheFloat2(e, t, i) && (this.engine.setInt2(this._uniforms[e], t, i) || (this._valueCache[e] = null)) }, e.prototype.setInt3 = function (e, t, i, r) { this._cacheFloat3(e, t, i, r) && (this.engine.setInt3(this._uniforms[e], t, i, r) || (this._valueCache[e] = null)) }, e.prototype.setInt4 = function (e, t, i, r, n) { this._cacheFloat4(e, t, i, r, n) && (this.engine.setInt4(this._uniforms[e], t, i, r, n) || (this._valueCache[e] = null)) }, e.prototype.setIntArray = function (e, t) { this._valueCache[e] = null, this.engine.setIntArray(this._uniforms[e], t) }, e.prototype.setIntArray2 = function (e, t) { this._valueCache[e] = null, this.engine.setIntArray2(this._uniforms[e], t) }, e.prototype.setIntArray3 = function (e, t) { this._valueCache[e] = null, this.engine.setIntArray3(this._uniforms[e], t) }, e.prototype.setIntArray4 = function (e, t) { this._valueCache[e] = null, this.engine.setIntArray4(this._uniforms[e], t) }, e.prototype.setUInt = function (e, t) { var i = this._valueCache[e]; void 0 !== i && i === t || this.engine.setUInt(this._uniforms[e], t) && (this._valueCache[e] = t) }, e.prototype.setUInt2 = function (e, t, i) { this._cacheFloat2(e, t, i) && (this.engine.setUInt2(this._uniforms[e], t, i) || (this._valueCache[e] = null)) }, e.prototype.setUInt3 = function (e, t, i, r) { this._cacheFloat3(e, t, i, r) && (this.engine.setUInt3(this._uniforms[e], t, i, r) || (this._valueCache[e] = null)) }, e.prototype.setUInt4 = function (e, t, i, r, n) { this._cacheFloat4(e, t, i, r, n) && (this.engine.setUInt4(this._uniforms[e], t, i, r, n) || (this._valueCache[e] = null)) }, e.prototype.setUIntArray = function (e, t) { this._valueCache[e] = null, this.engine.setUIntArray(this._uniforms[e], t) }, e.prototype.setUIntArray2 = function (e, t) { this._valueCache[e] = null, this.engine.setUIntArray2(this._uniforms[e], t) }, e.prototype.setUIntArray3 = function (e, t) { this._valueCache[e] = null, this.engine.setUIntArray3(this._uniforms[e], t) }, e.prototype.setUIntArray4 = function (e, t) { this._valueCache[e] = null, this.engine.setUIntArray4(this._uniforms[e], t) }, e.prototype.setArray = function (e, t) { this._valueCache[e] = null, this.engine.setArray(this._uniforms[e], t) }, e.prototype.setArray2 = function (e, t) { this._valueCache[e] = null, this.engine.setArray2(this._uniforms[e], t) }, e.prototype.setArray3 = function (e, t) { this._valueCache[e] = null, this.engine.setArray3(this._uniforms[e], t) }, e.prototype.setArray4 = function (e, t) { this._valueCache[e] = null, this.engine.setArray4(this._uniforms[e], t) }, e.prototype.setMatrices = function (e, t) { t && (this._valueCache[e] = null, this.engine.setMatrices(this._uniforms[e], t)) }, e.prototype.setMatrix = function (e, t) { this._cacheMatrix(e, t) && (this.engine.setMatrices(this._uniforms[e], t.toArray()) || (this._valueCache[e] = null)) }, e.prototype.setMatrix3x3 = function (e, t) { this._valueCache[e] = null, this.engine.setMatrix3x3(this._uniforms[e], t) }, e.prototype.setMatrix2x2 = function (e, t) { this._valueCache[e] = null, this.engine.setMatrix2x2(this._uniforms[e], t) }, e.prototype.setFloat = function (e, t) { var i = this._valueCache[e]; void 0 !== i && i === t || this.engine.setFloat(this._uniforms[e], t) && (this._valueCache[e] = t) }, e.prototype.setVector2 = function (e, t) { this._cacheFloat2(e, t.x, t.y) && (this.engine.setFloat2(this._uniforms[e], t.x, t.y) || (this._valueCache[e] = null)) }, e.prototype.setFloat2 = function (e, t, i) { this._cacheFloat2(e, t, i) && (this.engine.setFloat2(this._uniforms[e], t, i) || (this._valueCache[e] = null)) }, e.prototype.setVector3 = function (e, t) { this._cacheFloat3(e, t.x, t.y, t.z) && (this.engine.setFloat3(this._uniforms[e], t.x, t.y, t.z) || (this._valueCache[e] = null)) }, e.prototype.setFloat3 = function (e, t, i, r) { this._cacheFloat3(e, t, i, r) && (this.engine.setFloat3(this._uniforms[e], t, i, r) || (this._valueCache[e] = null)) }, e.prototype.setVector4 = function (e, t) { this._cacheFloat4(e, t.x, t.y, t.z, t.w) && (this.engine.setFloat4(this._uniforms[e], t.x, t.y, t.z, t.w) || (this._valueCache[e] = null)) }, e.prototype.setQuaternion = function (e, t) { this._cacheFloat4(e, t.x, t.y, t.z, t.w) && (this.engine.setFloat4(this._uniforms[e], t.x, t.y, t.z, t.w) || (this._valueCache[e] = null)) }, e.prototype.setFloat4 = function (e, t, i, r, n) { this._cacheFloat4(e, t, i, r, n) && (this.engine.setFloat4(this._uniforms[e], t, i, r, n) || (this._valueCache[e] = null)) }, e.prototype.setColor3 = function (e, t) { this._cacheFloat3(e, t.r, t.g, t.b) && (this.engine.setFloat3(this._uniforms[e], t.r, t.g, t.b) || (this._valueCache[e] = null)) }, e.prototype.setColor4 = function (e, t, i) { this._cacheFloat4(e, t.r, t.g, t.b, i) && (this.engine.setFloat4(this._uniforms[e], t.r, t.g, t.b, i) || (this._valueCache[e] = null)) }, e.prototype.setDirectColor4 = function (e, t) { this._cacheFloat4(e, t.r, t.g, t.b, t.a) && (this.engine.setFloat4(this._uniforms[e], t.r, t.g, t.b, t.a) || (this._valueCache[e] = null)) }, e.prototype._getVertexShaderCode = function () { return this.vertexShader ? this.engine._getShaderSource(this.vertexShader) : null }, e.prototype._getFragmentShaderCode = function () { return this.fragmentShader ? this.engine._getShaderSource(this.fragmentShader) : null }, e }(), Zt = function () { function e(e, t) { if (void 0 === e && (e = null), this._MSAARenderBuffers = null, this._context = t, !e && !(e = t.createTexture())) throw new Error("Unable to create webGL texture"); this.set(e) } return Object.defineProperty(e.prototype, "underlyingResource", { get: function () { return this._webGLTexture }, enumerable: !1, configurable: !0 }), e.prototype.setUsage = function () { }, e.prototype.set = function (e) { this._webGLTexture = e }, e.prototype.reset = function () { this._webGLTexture = null, this._MSAARenderBuffers = null }, e.prototype.addMSAARenderBuffer = function (e) { this._MSAARenderBuffers || (this._MSAARenderBuffers = []), this._MSAARenderBuffers.push(e) }, e.prototype.releaseMSAARenderBuffers = function () { if (this._MSAARenderBuffers) { for (var e = 0, t = this._MSAARenderBuffers; e < t.length; e++) { var i = t[e]; this._context.deleteRenderbuffer(i) } this._MSAARenderBuffers = null } }, e.prototype.release = function () { this.releaseMSAARenderBuffers(), this._webGLTexture && this._context.deleteTexture(this._webGLTexture), this.reset() }, e }(), Jt = function () { function e(e, t) { void 0 === t && (t = !0), this.effect = null, this.defines = null, this.drawContext = e.createDrawContext(), t && (this.materialContext = e.createMaterialContext()) } return e.IsWrapper = function (e) { return void 0 === e.getPipelineContext }, e.GetEffect = function (e) { return void 0 === e.getPipelineContext ? e.effect : e }, e.prototype.setEffect = function (e, t, i) { var r; void 0 === i && (i = !0), this.effect = e, void 0 !== t && (this.defines = t), i && (null === (r = this.drawContext) || void 0 === r || r.reset()) }, e.prototype.dispose = function () { var e; null === (e = this.drawContext) || void 0 === e || e.dispose() }, e }(), $t = function () { function e(e) { void 0 === e && (e = !0), this._isStencilTestDirty = !1, this._isStencilMaskDirty = !1, this._isStencilFuncDirty = !1, this._isStencilOpDirty = !1, this.useStencilGlobalOnly = !1, e && this.reset() } return Object.defineProperty(e.prototype, "isDirty", { get: function () { return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "func", { get: function () { return this._func }, set: function (e) { this._func !== e && (this._func = e, this._isStencilFuncDirty = !0) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "funcRef", { get: function () { return this._funcRef }, set: function (e) { this._funcRef !== e && (this._funcRef = e, this._isStencilFuncDirty = !0) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "funcMask", { get: function () { return this._funcMask }, set: function (e) { this._funcMask !== e && (this._funcMask = e, this._isStencilFuncDirty = !0) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "opStencilFail", { get: function () { return this._opStencilFail }, set: function (e) { this._opStencilFail !== e && (this._opStencilFail = e, this._isStencilOpDirty = !0) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "opDepthFail", { get: function () { return this._opDepthFail }, set: function (e) { this._opDepthFail !== e && (this._opDepthFail = e, this._isStencilOpDirty = !0) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "opStencilDepthPass", { get: function () { return this._opStencilDepthPass }, set: function (e) { this._opStencilDepthPass !== e && (this._opStencilDepthPass = e, this._isStencilOpDirty = !0) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "mask", { get: function () { return this._mask }, set: function (e) { this._mask !== e && (this._mask = e, this._isStencilMaskDirty = !0) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "enabled", { get: function () { return this._enabled }, set: function (e) { this._enabled !== e && (this._enabled = e, this._isStencilTestDirty = !0) }, enumerable: !1, configurable: !0 }), e.prototype.reset = function () { var e; this.stencilMaterial = void 0, null === (e = this.stencilGlobal) || void 0 === e || e.reset(), this._isStencilTestDirty = !0, this._isStencilMaskDirty = !0, this._isStencilFuncDirty = !0, this._isStencilOpDirty = !0 }, e.prototype.apply = function (e) { var t; if (e) { var i = !this.useStencilGlobalOnly && !!(null === (t = this.stencilMaterial) || void 0 === t ? void 0 : t.enabled); this.enabled = i ? this.stencilMaterial.enabled : this.stencilGlobal.enabled, this.func = i ? this.stencilMaterial.func : this.stencilGlobal.func, this.funcRef = i ? this.stencilMaterial.funcRef : this.stencilGlobal.funcRef, this.funcMask = i ? this.stencilMaterial.funcMask : this.stencilGlobal.funcMask, this.opStencilFail = i ? this.stencilMaterial.opStencilFail : this.stencilGlobal.opStencilFail, this.opDepthFail = i ? this.stencilMaterial.opDepthFail : this.stencilGlobal.opDepthFail, this.opStencilDepthPass = i ? this.stencilMaterial.opStencilDepthPass : this.stencilGlobal.opStencilDepthPass, this.mask = i ? this.stencilMaterial.mask : this.stencilGlobal.mask, this.isDirty && (this._isStencilTestDirty && (this.enabled ? e.enable(e.STENCIL_TEST) : e.disable(e.STENCIL_TEST), this._isStencilTestDirty = !1), this._isStencilMaskDirty && (e.stencilMask(this.mask), this._isStencilMaskDirty = !1), this._isStencilFuncDirty && (e.stencilFunc(this.func, this.funcRef, this.funcMask), this._isStencilFuncDirty = !1), this._isStencilOpDirty && (e.stencilOp(this.opStencilFail, this.opDepthFail, this.opStencilDepthPass), this._isStencilOpDirty = !1)) } }, e }(), ei = function () { }, ti = function () { function e(t, i, r, n) { var o, s, l, c, h, d, p, f, _, m, g, v = this; this._name = "WebGL", this._isDisposed = !1, this.forcePOTTextures = !1, this.isFullscreen = !1, this.cullBackFaces = null, this.renderEvenInBackground = !0, this.preventCacheWipeBetweenFrames = !1, this.validateShaderPrograms = !1, this._useReverseDepthBuffer = !1, this.isNDCHalfZRange = !1, this.hasOriginBottomLeft = !0, this.disableUniformBuffers = !1, this.onDisposeObservable = new u, this._frameId = 0, this._uniformBuffers = new Array, this._storageBuffers = new Array, this._webGLVersion = 1, this._windowIsBackground = !1, this._highPrecisionShadersAllowed = !0, this._badOS = !1, this._badDesktopOS = !1, this._renderingQueueLaunched = !1, this._activeRenderLoops = new Array, this.onContextLostObservable = new u, this.onContextRestoredObservable = new u, this._contextWasLost = !1, this._doNotHandleContextLost = !1, this.disableVertexArrayObjects = !1, this._colorWrite = !0, this._colorWriteChanged = !0, this._depthCullingState = new kt, this._stencilStateComposer = new $t, this._stencilState = new Gt, this._alphaState = new zt, this._alphaMode = a.ALPHA_ADD, this._alphaEquation = a.ALPHA_DISABLE, this._internalTexturesCache = new Array, this._renderTargetWrapperCache = new Array, this._activeChannel = 0, this._currentTextureChannel = -1, this._boundTexturesCache = {}, this._compiledEffects = {}, this._vertexAttribArraysEnabled = [], this._uintIndicesCurrentlySet = !1, this._currentBoundBuffer = new Array, this._currentFramebuffer = null, this._dummyFramebuffer = null, this._currentBufferPointers = new Array, this._currentInstanceLocations = new Array, this._currentInstanceBuffers = new Array, this._vaoRecordInProgress = !1, this._mustWipeVertexAttributes = !1, this._nextFreeTextureSlots = new Array, this._maxSimultaneousTextures = 0, this._maxMSAASamplesOverride = null, this._activeRequests = new Array, this.adaptToDeviceRatio = !1, this._lastDevicePixelRatio = 1, this._transformTextureUrl = null, this.hostInformation = { isMobile: !1 }, this.premultipliedAlpha = !0, this.onBeforeTextureInitObservable = new u, this._isWebGPU = !1, this._snapshotRenderingMode = a.SNAPSHOTRENDERING_STANDARD, this._viewportCached = { x: 0, y: 0, z: 0, w: 0 }, this._unpackFlipYCached = null, this.enableUnpackFlipYCached = !0, this._boundUniforms = {}, this.startTime = at.Now; var y = null; r = r || {}, this._creationOptions = r, this.adaptToDeviceRatio = null != n && n, this._stencilStateComposer.stencilGlobal = this._stencilState, E.SetMatrixPrecision(!!r.useHighPrecisionMatrix), r.antialias = null != i ? i : r.antialias, r.deterministicLockstep = null !== (o = r.deterministicLockstep) && void 0 !== o && o, r.lockstepMaxSteps = null !== (s = r.lockstepMaxSteps) && void 0 !== s ? s : 4, r.timeStep = null !== (l = r.timeStep) && void 0 !== l ? l : 1 / 60, r.audioEngine = null === (c = r.audioEngine) || void 0 === c || c, r.stencil = null === (h = r.stencil) || void 0 === h || h, this._audioContext = null !== (p = null === (d = r.audioEngineOptions) || void 0 === d ? void 0 : d.audioContext) && void 0 !== p ? p : null, this._audioDestination = null !== (_ = null === (f = r.audioEngineOptions) || void 0 === f ? void 0 : f.audioDestination) && void 0 !== _ ? _ : null, this.premultipliedAlpha = null === (m = r.premultipliedAlpha) || void 0 === m || m, this.useExactSrgbConversions = null !== (g = r.useExactSrgbConversions) && void 0 !== g && g, this._doNotHandleContextLost = !!r.doNotHandleContextLost, this._isStencilEnable = !!r.stencil, n = n || r.adaptToDeviceRatio || !1; var b = et() && window.devicePixelRatio || 1, T = r.limitDeviceRatio || b; if (this._hardwareScalingLevel = n ? 1 / Math.min(T, b) : 1, this._lastDevicePixelRatio = b, t) { if (t.getContext) { if (y = t, this._renderingCanvas = y, void 0 === r.preserveDrawingBuffer && (r.preserveDrawingBuffer = !1), void 0 === r.xrCompatible && (r.xrCompatible = !0), navigator && navigator.userAgent) { this._setupMobileChecks(); for (var S = navigator.userAgent, x = 0, A = e.ExceptionList; x < A.length; x++) { var R = A[x], C = R.key, P = R.targets; if (new RegExp(C).test(S)) { if (R.capture && R.captureConstraint) { var I = R.capture, M = R.captureConstraint, O = new RegExp(I).exec(S); if (O && O.length > 0 && parseInt(O[O.length - 1]) >= M) continue } for (var D = 0, N = P; D < N.length; D++)switch (N[D]) { case "uniformBuffer": this.disableUniformBuffers = !0; break; case "vao": this.disableVertexArrayObjects = !0; break; case "antialias": r.antialias = !1; break; case "maxMSAASamples": this._maxMSAASamplesOverride = 1 } } } } if (this._doNotHandleContextLost || (this._onContextLost = function (e) { e.preventDefault(), v._contextWasLost = !0, $.Warn("WebGL context lost."), v.onContextLostObservable.notifyObservers(v) }, this._onContextRestored = function () { v._restoreEngineAfterContextLost(v._initGLContext.bind(v)) }, y.addEventListener("webglcontextlost", this._onContextLost, !1), y.addEventListener("webglcontextrestored", this._onContextRestored, !1), r.powerPreference = r.powerPreference || "high-performance"), this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent), this._badDesktopOS && (r.xrCompatible = !1), !r.disableWebGL2Support) try { this._gl = y.getContext("webgl2", r) || y.getContext("experimental-webgl2", r), this._gl && (this._webGLVersion = 2, this._shaderPlatformName = "WEBGL2", this._gl.deleteQuery || (this._webGLVersion = 1, this._shaderPlatformName = "WEBGL1")) } catch (e) { } if (!this._gl) { if (!y) throw new Error("The provided canvas is null or undefined."); try { this._gl = y.getContext("webgl", r) || y.getContext("experimental-webgl", r) } catch (e) { throw new Error("WebGL not supported") } } if (!this._gl) throw new Error("WebGL not supported") } else { this._gl = t, this._renderingCanvas = this._gl.canvas, this._gl.renderbufferStorageMultisample ? (this._webGLVersion = 2, this._shaderPlatformName = "WEBGL2") : this._shaderPlatformName = "WEBGL1"; var F = this._gl.getContextAttributes(); F && (r.stencil = F.stencil) } this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE), void 0 !== r.useHighPrecisionFloats && (this._highPrecisionShadersAllowed = r.useHighPrecisionFloats), this.resize(), this._initGLContext(), this._initFeatures(); for (var L = 0; L < this._caps.maxVertexAttribs; L++)this._currentBufferPointers[L] = new ei; this._shaderProcessor = this.webGLVersion > 1 ? new Yt : new Xt, 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.16.1" }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "Version", { get: function () { return "6.16.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 Vt.ShadersRepository }, set: function (e) { Vt.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") && it() && "ontouchend" in document }, this._checkForMobile(), et() && 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(); e < t.length; e++)t[e]._rebuild() }, e.prototype._rebuildRenderTargetWrappers = function () { for (var e = 0, t = this._renderTargetWrapperCache.slice(); e < t.length; e++)t[e]._rebuild() }, e.prototype._rebuildEffects = function () { for (var e in this._compiledEffects) { var t = this._compiledEffects[e]; t._pipelineContext = null, t._wasPreviouslyReady = !1, t._prepareEffect() } Vt.ResetCache() }, e.prototype.areAllEffectsReady = function () { for (var e in this._compiledEffects) if (!this._compiledEffects[e].isReady()) return !1; return !0 }, e.prototype._rebuildBuffers = function () { for (var e = 0, t = this._uniformBuffers; e < t.length; e++)t[e]._rebuild(); for (var i = 0, r = this._storageBuffers; i < r.length; i++)r[i]._rebuild() }, e.prototype._initGLContext = function () { var e; this._caps = { maxTexturesImageUnits: this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS), maxCombinedTexturesImageUnits: this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS), maxVertexTextureImageUnits: this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS), maxTextureSize: this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE), maxSamples: this._webGLVersion > 1 ? this._gl.getParameter(this._gl.MAX_SAMPLES) : 1, maxCubemapTextureSize: this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE), maxRenderTextureSize: this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE), maxVertexAttribs: this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS), maxVaryingVectors: this._gl.getParameter(this._gl.MAX_VARYING_VECTORS), maxFragmentUniformVectors: this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS), maxVertexUniformVectors: this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS), parallelShaderCompile: this._gl.getExtension("KHR_parallel_shader_compile") || void 0, standardDerivatives: this._webGLVersion > 1 || null !== this._gl.getExtension("OES_standard_derivatives"), maxAnisotropy: 1, astc: this._gl.getExtension("WEBGL_compressed_texture_astc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_astc"), bptc: this._gl.getExtension("EXT_texture_compression_bptc") || this._gl.getExtension("WEBKIT_EXT_texture_compression_bptc"), s3tc: this._gl.getExtension("WEBGL_compressed_texture_s3tc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"), s3tc_srgb: this._gl.getExtension("WEBGL_compressed_texture_s3tc_srgb") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc_srgb"), pvrtc: this._gl.getExtension("WEBGL_compressed_texture_pvrtc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"), etc1: this._gl.getExtension("WEBGL_compressed_texture_etc1") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"), etc2: this._gl.getExtension("WEBGL_compressed_texture_etc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc") || this._gl.getExtension("WEBGL_compressed_texture_es3_0"), textureAnisotropicFilterExtension: this._gl.getExtension("EXT_texture_filter_anisotropic") || this._gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic") || this._gl.getExtension("MOZ_EXT_texture_filter_anisotropic"), uintIndices: this._webGLVersion > 1 || null !== this._gl.getExtension("OES_element_index_uint"), fragmentDepthSupported: this._webGLVersion > 1 || null !== this._gl.getExtension("EXT_frag_depth"), highPrecisionShaderSupported: !1, timerQuery: this._gl.getExtension("EXT_disjoint_timer_query_webgl2") || this._gl.getExtension("EXT_disjoint_timer_query"), supportOcclusionQuery: this._webGLVersion > 1, canUseTimestampForTimerQuery: !1, drawBuffersExtension: !1, maxMSAASamples: 1, colorBufferFloat: !!(this._webGLVersion > 1 && this._gl.getExtension("EXT_color_buffer_float")), 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 < this._maxSimultaneousTextures; h++)this._nextFreeTextureSlots.push(h); "Mali-G72" === this._glRenderer && (this._caps.disableMorphTargetTexture = !0) }, e.prototype._initFeatures = function () { this._features = { forceBitmapOverHTMLImageElement: !1, supportRenderAndCopyToLodForFloatTextures: 1 !== this._webGLVersion, supportDepthStencilTexture: 1 !== this._webGLVersion, supportShadowSamplers: 1 !== this._webGLVersion, uniformBufferHardCheckMatrix: !1, allowTexturePrefiltering: 1 !== this._webGLVersion, trackUbosInFrame: !1, checkUbosContentBeforeUpload: !1, supportCSM: 1 !== this._webGLVersion, basisNeedsPOT: 1 === this._webGLVersion, support3DTextures: 1 !== this._webGLVersion, needTypeSuffixInShaderConstants: 1 !== this._webGLVersion, supportMSAA: 1 !== this._webGLVersion, supportSSAO2: 1 !== this._webGLVersion, supportExtendedTextureFormats: 1 !== this._webGLVersion, supportSwitchCaseInShader: 1 !== this._webGLVersion, supportSyncTextureRead: !0, needsInvertingBitmap: !0, useUBOBindingCache: !0, needShaderCodeInlining: !1, needToAlwaysBindUniformBuffers: !1, supportRenderPasses: !1, supportSpriteInstancing: !0, _collectUbosUpdatedInFrame: !1 } }, Object.defineProperty(e.prototype, "webGLVersion", { get: function () { return this._webGLVersion }, enumerable: !1, configurable: !0 }), e.prototype.getClassName = function () { return "ThinEngine" }, Object.defineProperty(e.prototype, "isStencilEnable", { get: function () { return this._isStencilEnable }, enumerable: !1, configurable: !0 }), e.prototype._prepareWorkingCanvas = function () { if (!this._workingCanvas) { this._workingCanvas = this.createCanvas(1, 1); var e = this._workingCanvas.getContext("2d"); e && (this._workingContext = e) } }, e.prototype.resetTextureCache = function () { for (var e in this._boundTexturesCache) Object.prototype.hasOwnProperty.call(this._boundTexturesCache, e) && (this._boundTexturesCache[e] = null); this._currentTextureChannel = -1 }, e.prototype.getInfo = function () { return this.getGlInfo() }, e.prototype.getGlInfo = function () { return { vendor: this._glVendor, renderer: this._glRenderer, version: this._glVersion } }, e.prototype.setHardwareScalingLevel = function (e) { this._hardwareScalingLevel = e, this.resize() }, e.prototype.getHardwareScalingLevel = function () { return this._hardwareScalingLevel }, e.prototype.getLoadedTexturesCache = function () { return this._internalTexturesCache }, e.prototype.getCaps = function () { return this._caps }, e.prototype.stopRenderLoop = function (e) { if (!e) return this._activeRenderLoops.length = 0, void this._cancelFrame(); var t = this._activeRenderLoops.indexOf(e); t >= 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, et()) { 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; t < this._activeRenderLoops.length; t++)(0, this._activeRenderLoops[t])(); this.endFrame() } } this._activeRenderLoops.length > 0 ? 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 et() ? 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) { -1 === this._activeRenderLoops.indexOf(e) && (this._activeRenderLoops.push(e), this._renderingQueueLaunched || (this._renderingQueueLaunched = !0, this._boundRenderFunction = this._renderLoop.bind(this), 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 = et() && window.devicePixelRatio || 1, n = this._lastDevicePixelRatio / r; this._lastDevicePixelRatio = r, this._hardwareScalingLevel *= n } if (et() && it()) 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; void 0 === t && (t = 0), void 0 === o && (o = 0), void 0 === a && (a = 0); var d = e; this._currentRenderTarget && this.unBindFramebuffer(this._currentRenderTarget), this._currentRenderTarget = e, this._bindUnboundFramebuffer(d._MSAAFramebuffer ? d._MSAAFramebuffer : d._framebuffer); var p = this._gl; e.isMulti || (e.is2DArray ? p.framebufferTextureLayer(p.FRAMEBUFFER, p.COLOR_ATTACHMENT0, null === (s = e.texture._hardwareTexture) || void 0 === s ? void 0 : s.underlyingResource, o, a) : e.isCube && p.framebufferTexture2D(p.FRAMEBUFFER, p.COLOR_ATTACHMENT0, p.TEXTURE_CUBE_MAP_POSITIVE_X + t, null === (l = e.texture._hardwareTexture) || void 0 === l ? void 0 : l.underlyingResource, o)); var f = e._depthStencilTexture; if (f) { var _ = e._depthStencilTextureWithStencil ? p.DEPTH_STENCIL_ATTACHMENT : p.DEPTH_ATTACHMENT; e.is2DArray ? p.framebufferTextureLayer(p.FRAMEBUFFER, _, null === (c = f._hardwareTexture) || void 0 === c ? void 0 : c.underlyingResource, o, a) : e.isCube ? p.framebufferTexture2D(p.FRAMEBUFFER, _, p.TEXTURE_CUBE_MAP_POSITIVE_X + t, null === (u = f._hardwareTexture) || void 0 === u ? void 0 : u.underlyingResource, o) : p.framebufferTexture2D(p.FRAMEBUFFER, _, p.TEXTURE_2D, null === (h = f._hardwareTexture) || void 0 === h ? void 0 : h.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) { 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 Qt(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) { return this._createVertexBuffer(e, this._gl.DYNAMIC_DRAW) }, e.prototype._resetIndexBufferBinding = function () { this.bindIndexBuffer(null), this._cachedIndexBuffer = null }, e.prototype.createIndexBuffer = function (e, t) { var i = this._gl.createBuffer(), r = new Qt(i); if (!i) throw new Error("Unable to create index buffer"); this.bindIndexBuffer(r); var n = this._normalizeIndexData(e); return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, n, t ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW), this._resetIndexBufferBinding(), r.references = 1, r.is32Bits = 4 === n.BYTES_PER_ELEMENT, r }, 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 < e.length; t++)if (e[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 < r.length; n++) { var o = t.getAttributeLocation(n); if (o >= 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 < o; s++)if (s < i.length) { var l = n.getAttributeLocation(s); l >= 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; t < i; t++) { var r = this._currentInstanceBuffers[t]; e != r && r.references && (e = r, this.bindArrayBuffer(r)); var n = this._currentInstanceLocations[t]; this._gl.vertexAttribDivisor(n, 0) } this._currentInstanceBuffers.length = 0, this._currentInstanceLocations.length = 0 }, e.prototype.releaseVertexArrayObject = function (e) { this._gl.deleteVertexArray(e) }, e.prototype._releaseBuffer = function (e) { return e.references--, 0 === e.references && (this._deleteBuffer(e), !0) }, e.prototype._deleteBuffer = function (e) { this._gl.deleteBuffer(e.underlyingResource) }, e.prototype.updateAndBindInstancesBuffer = function (e, t, i) { if (this.bindArrayBuffer(e), t && this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, t), void 0 !== i[0].index) this.bindInstancesBuffer(e, i, !0); else for (var r = 0; r < 4; r++) { var n = i[r]; this._vertexAttribArraysEnabled[n] || (this._gl.enableVertexAttribArray(n), this._vertexAttribArraysEnabled[n] = !0), this._vertexAttribPointer(e, n, 4, this._gl.FLOAT, !1, 64, 16 * r), this._gl.vertexAttribDivisor(n, 1), this._currentInstanceLocations.push(n), this._currentInstanceBuffers.push(e) } }, e.prototype.bindInstancesBuffer = function (e, t, i) { void 0 === i && (i = !0), this.bindArrayBuffer(e); var r = 0; if (i) for (var n = 0; n < t.length; n++)r += 4 * (o = t[n]).attributeSize; for (n = 0; n < t.length; n++) { var o; void 0 === (o = t[n]).index && (o.index = this._currentEffect.getAttributeLocationByName(o.attributeName)), o.index < 0 || (this._vertexAttribArraysEnabled[o.index] || (this._gl.enableVertexAttribArray(o.index), this._vertexAttribArraysEnabled[o.index] = !0), this._vertexAttribPointer(e, o.index, o.attributeSize, o.attributeType || this._gl.FLOAT, o.normalized || !1, r, o.offset), this._gl.vertexAttribDivisor(o.index, void 0 === o.divisor ? 1 : o.divisor), this._currentInstanceLocations.push(o.index), this._currentInstanceBuffers.push(e)) } }, e.prototype.disableInstanceAttributeByName = function (e) { if (this._currentEffect) { var t = this._currentEffect.getAttributeLocationByName(e); this.disableInstanceAttribute(t) } }, e.prototype.disableInstanceAttribute = function (e) { for (var t, i = !1; -1 !== (t = this._currentInstanceLocations.indexOf(e));)this._currentInstanceLocations.splice(t, 1), this._currentInstanceBuffers.splice(t, 1), i = !0, t = this._currentInstanceLocations.indexOf(e); i && (this._gl.vertexAttribDivisor(e, 0), this.disableAttributeByIndex(e)) }, e.prototype.disableAttributeByIndex = function (e) { this._gl.disableVertexAttribArray(e), this._vertexAttribArraysEnabled[e] = !1, this._currentBufferPointers[e].active = !1 }, e.prototype.draw = function (e, t, i, r) { this.drawElementsType(e ? a.MATERIAL_TriangleFillMode : a.MATERIAL_WireFrameFillMode, t, i, r) }, e.prototype.drawPointClouds = function (e, t, i) { this.drawArraysType(a.MATERIAL_PointFillMode, e, t, i) }, e.prototype.drawUnIndexed = function (e, t, i, r) { this.drawArraysType(e ? a.MATERIAL_TriangleFillMode : a.MATERIAL_WireFrameFillMode, t, i, r) }, e.prototype.drawElementsType = function (e, t, i, r) { this.applyStates(), this._reportDrawCall(); var n = this._drawMode(e), o = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT, a = this._uintIndicesCurrentlySet ? 4 : 2; r ? this._gl.drawElementsInstanced(n, i, o, t * a, r) : this._gl.drawElements(n, i, o, t * a) }, e.prototype.drawArraysType = function (e, t, i, r) { this.applyStates(), this._reportDrawCall(); var n = this._drawMode(e); r ? this._gl.drawArraysInstanced(n, t, i, r) : this._gl.drawArrays(n, t, i) }, e.prototype._drawMode = function (e) { switch (e) { case a.MATERIAL_TriangleFillMode: return this._gl.TRIANGLES; case a.MATERIAL_PointFillMode: return this._gl.POINTS; case a.MATERIAL_WireFrameFillMode: return this._gl.LINES; case a.MATERIAL_PointListDrawMode: return this._gl.POINTS; case a.MATERIAL_LineListDrawMode: return this._gl.LINES; case a.MATERIAL_LineLoopDrawMode: return this._gl.LINE_LOOP; case a.MATERIAL_LineStripDrawMode: return this._gl.LINE_STRIP; case a.MATERIAL_TriangleStripDrawMode: return this._gl.TRIANGLE_STRIP; case a.MATERIAL_TriangleFanDrawMode: return this._gl.TRIANGLE_FAN; default: return this._gl.TRIANGLES } }, e.prototype._reportDrawCall = function () { }, e.prototype._releaseEffect = function (e) { this._compiledEffects[e._key] && delete this._compiledEffects[e._key]; var t = e.getPipelineContext(); t && this._deletePipelineContext(t) }, e.prototype._deletePipelineContext = function (e) { var t = e; t && t.program && (t.program.__SPECTOR_rebuildProgram = null, this._gl.deleteProgram(t.program)) }, e.prototype._getGlobalDefines = function (e) { if (e) return this.isNDCHalfZRange ? e.IS_NDC_HALF_ZRANGE = "" : delete e.IS_NDC_HALF_ZRANGE, this.useReverseDepthBuffer ? e.USE_REVERSE_DEPTHBUFFER = "" : delete e.USE_REVERSE_DEPTHBUFFER, void (this.useExactSrgbConversions ? e.USE_EXACT_SRGB_CONVERSIONS = "" : delete e.USE_EXACT_SRGB_CONVERSIONS); var t = ""; return this.isNDCHalfZRange && (t += "#define IS_NDC_HALF_ZRANGE"), this.useReverseDepthBuffer && (t && (t += "\n"), t += "#define USE_REVERSE_DEPTHBUFFER"), this.useExactSrgbConversions && (t && (t += "\n"), t += "#define USE_EXACT_SRGB_CONVERSIONS"), t }, e.prototype.createEffect = function (e, t, i, r, n, o, a, s, l, c) { var u; void 0 === c && (c = nt.GLSL); var h = e.vertexElement || e.vertex || e.vertexToken || e.vertexSource || e, d = e.fragmentElement || e.fragment || e.fragmentToken || e.fragmentSource || e, p = this._getGlobalDefines(), f = null !== (u = null != n ? n : t.defines) && void 0 !== u ? u : ""; p && (f += p); var _ = h + "+" + d + "@" + f; if (this._compiledEffects[_]) { var m = this._compiledEffects[_]; return a && m.isReady() && a(m), m } var g = new Vt(e, t, i, r, this, n, o, a, s, l, _, c); return this._compiledEffects[_] = g, g }, e._ConcatenateShader = function (e, t, i) { return void 0 === i && (i = ""), i + (t ? t + "\n" : "") + e }, e.prototype._compileShader = function (t, i, r, n) { return this._compileRawShader(e._ConcatenateShader(t, r, n), i) }, e.prototype._compileRawShader = function (e, t) { var i = this._gl, r = i.createShader("vertex" === t ? i.VERTEX_SHADER : i.FRAGMENT_SHADER); if (!r) { for (var n = i.NO_ERROR, o = i.NO_ERROR; (o = i.getError()) !== i.NO_ERROR;)n = o; throw new Error("Something went wrong while creating a gl ".concat(t, " shader object. gl error=").concat(n, ", gl isContextLost=").concat(i.isContextLost(), ", _contextWasLost=").concat(this._contextWasLost)) } return i.shaderSource(r, e), i.compileShader(r), r }, e.prototype._getShaderSource = function (e) { return this._gl.getShaderSource(e) }, e.prototype.createRawShaderProgram = function (e, t, i, r, n) { void 0 === n && (n = null), r = r || this._gl; var o = this._compileRawShader(t, "vertex"), a = this._compileRawShader(i, "fragment"); return this._createShaderProgram(e, o, a, r, n) }, e.prototype.createShaderProgram = function (e, t, i, r, n, o) { void 0 === o && (o = null), n = n || this._gl; var a = this._webGLVersion > 1 ? "#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 qt; 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; n < t.length; n++)i.push(this._gl.getUniformLocation(r.program, t[n])); return i }, e.prototype.getAttributes = function (e, t) { for (var i = [], r = e, n = 0; n < t.length; n++)try { i.push(this._gl.getAttribLocation(r.program, t[n])) } catch (e) { i.push(-1) } return i }, e.prototype.enableEffect = function (e) { (e = null !== e && Jt.IsWrapper(e) ? e.effect : e) && e !== this._currentEffect && (this._stencilStateComposer.stencilMaterial = void 0, this.bindSamplers(e), this._currentEffect = e, e.onBind && e.onBind(e), e._onBindObservable && e._onBindObservable.notifyObservers(e)) }, e.prototype.setInt = function (e, t) { return !!e && (this._gl.uniform1i(e, t), !0) }, e.prototype.setInt2 = function (e, t, i) { return !!e && (this._gl.uniform2i(e, t, i), !0) }, e.prototype.setInt3 = function (e, t, i, r) { return !!e && (this._gl.uniform3i(e, t, i, r), !0) }, e.prototype.setInt4 = function (e, t, i, r, n) { return !!e && (this._gl.uniform4i(e, t, i, r, n), !0) }, e.prototype.setIntArray = function (e, t) { return !!e && (this._gl.uniform1iv(e, t), !0) }, e.prototype.setIntArray2 = function (e, t) { return !(!e || t.length % 2 != 0 || (this._gl.uniform2iv(e, t), 0)) }, e.prototype.setIntArray3 = function (e, t) { return !(!e || t.length % 3 != 0 || (this._gl.uniform3iv(e, t), 0)) }, e.prototype.setIntArray4 = function (e, t) { return !(!e || t.length % 4 != 0 || (this._gl.uniform4iv(e, t), 0)) }, e.prototype.setUInt = function (e, t) { return !!e && (this._gl.uniform1ui(e, t), !0) }, e.prototype.setUInt2 = function (e, t, i) { return !!e && (this._gl.uniform2ui(e, t, i), !0) }, e.prototype.setUInt3 = function (e, t, i, r) { return !!e && (this._gl.uniform3ui(e, t, i, r), !0) }, e.prototype.setUInt4 = function (e, t, i, r, n) { return !!e && (this._gl.uniform4ui(e, t, i, r, n), !0) }, e.prototype.setUIntArray = function (e, t) { return !!e && (this._gl.uniform1uiv(e, t), !0) }, e.prototype.setUIntArray2 = function (e, t) { return !(!e || t.length % 2 != 0 || (this._gl.uniform2uiv(e, t), 0)) }, e.prototype.setUIntArray3 = function (e, t) { return !(!e || t.length % 3 != 0 || (this._gl.uniform3uiv(e, t), 0)) }, e.prototype.setUIntArray4 = function (e, t) { return !(!e || t.length % 4 != 0 || (this._gl.uniform4uiv(e, t), 0)) }, e.prototype.setArray = function (e, t) { return !(!e || t.length < 1 || (this._gl.uniform1fv(e, t), 0)) }, e.prototype.setArray2 = function (e, t) { return !(!e || t.length % 2 != 0 || (this._gl.uniform2fv(e, t), 0)) }, e.prototype.setArray3 = function (e, t) { return !(!e || t.length % 3 != 0 || (this._gl.uniform3fv(e, t), 0)) }, e.prototype.setArray4 = function (e, t) { return !(!e || t.length % 4 != 0 || (this._gl.uniform4fv(e, t), 0)) }, e.prototype.setMatrices = function (e, t) { return !!e && (this._gl.uniformMatrix4fv(e, !1, t), !0) }, e.prototype.setMatrix3x3 = function (e, t) { return !!e && (this._gl.uniformMatrix3fv(e, !1, t), !0) }, e.prototype.setMatrix2x2 = function (e, t) { return !!e && (this._gl.uniformMatrix2fv(e, !1, t), !0) }, e.prototype.setFloat = function (e, t) { return !!e && (this._gl.uniform1f(e, t), !0) }, e.prototype.setFloat2 = function (e, t, i) { return !!e && (this._gl.uniform2f(e, t, i), !0) }, e.prototype.setFloat3 = function (e, t, i, r) { return !!e && (this._gl.uniform3f(e, t, i, r), !0) }, e.prototype.setFloat4 = function (e, t, i, r, n) { return !!e && (this._gl.uniform4f(e, t, i, r, n), !0) }, e.prototype.applyStates = function () { if (this._depthCullingState.apply(this._gl), this._stencilStateComposer.apply(this._gl), this._alphaState.apply(this._gl), this._colorWriteChanged) { this._colorWriteChanged = !1; var e = this._colorWrite; this._gl.colorMask(e, e, e, e) } }, e.prototype.setColorWrite = function (e) { e !== this._colorWrite && (this._colorWriteChanged = !0, this._colorWrite = e) }, e.prototype.getColorWrite = function () { return this._colorWrite }, Object.defineProperty(e.prototype, "depthCullingState", { get: function () { return this._depthCullingState }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "alphaState", { get: function () { return this._alphaState }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "stencilState", { get: function () { return this._stencilState }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "stencilStateComposer", { get: function () { return this._stencilStateComposer }, enumerable: !1, configurable: !0 }), e.prototype.clearInternalTexturesCache = function () { this._internalTexturesCache.length = 0 }, e.prototype.wipeCaches = function (e) { this.preventCacheWipeBetweenFrames && !e || (this._currentEffect = null, this._viewportCached.x = 0, this._viewportCached.y = 0, this._viewportCached.z = 0, this._viewportCached.w = 0, this._unbindVertexArrayObject(), e && (this._currentProgram = null, this.resetTextureCache(), this._stencilStateComposer.reset(), this._depthCullingState.reset(), this._depthCullingState.depthFunc = this._gl.LEQUAL, this._alphaState.reset(), this._alphaMode = a.ALPHA_ADD, this._alphaEquation = a.ALPHA_DISABLE, this._colorWrite = !0, this._colorWriteChanged = !0, this._unpackFlipYCached = null, this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE), this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0), this._mustWipeVertexAttributes = !0, this.unbindAllAttributes()), this._resetVertexBufferBinding(), this._cachedIndexBuffer = null, this._cachedEffectForVertexBuffers = null, this.bindIndexBuffer(null)) }, e.prototype._getSamplingParameters = function (e, t) { var i = this._gl, r = i.NEAREST, n = i.NEAREST; switch (e) { case a.TEXTURE_LINEAR_LINEAR_MIPNEAREST: r = i.LINEAR, n = t ? i.LINEAR_MIPMAP_NEAREST : i.LINEAR; break; case a.TEXTURE_LINEAR_LINEAR_MIPLINEAR: r = i.LINEAR, n = t ? i.LINEAR_MIPMAP_LINEAR : i.LINEAR; break; case a.TEXTURE_NEAREST_NEAREST_MIPLINEAR: r = i.NEAREST, n = t ? i.NEAREST_MIPMAP_LINEAR : i.NEAREST; break; case a.TEXTURE_NEAREST_NEAREST_MIPNEAREST: r = i.NEAREST, n = t ? i.NEAREST_MIPMAP_NEAREST : i.NEAREST; break; case a.TEXTURE_NEAREST_LINEAR_MIPNEAREST: r = i.NEAREST, n = t ? i.LINEAR_MIPMAP_NEAREST : i.LINEAR; break; case a.TEXTURE_NEAREST_LINEAR_MIPLINEAR: r = i.NEAREST, n = t ? i.LINEAR_MIPMAP_LINEAR : i.LINEAR; break; case a.TEXTURE_NEAREST_LINEAR: r = i.NEAREST, n = i.LINEAR; break; case a.TEXTURE_NEAREST_NEAREST: r = i.NEAREST, n = i.NEAREST; break; case a.TEXTURE_LINEAR_NEAREST_MIPNEAREST: r = i.LINEAR, n = t ? i.NEAREST_MIPMAP_NEAREST : i.NEAREST; break; case a.TEXTURE_LINEAR_NEAREST_MIPLINEAR: r = i.LINEAR, n = t ? i.NEAREST_MIPMAP_LINEAR : i.NEAREST; break; case a.TEXTURE_LINEAR_LINEAR: r = i.LINEAR, n = i.LINEAR; break; case a.TEXTURE_LINEAR_NEAREST: r = i.LINEAR, n = i.NEAREST }return { min: n, mag: r } }, e.prototype._createTexture = function () { var e = this._gl.createTexture(); if (!e) throw new Error("Unable to create texture"); return e }, e.prototype._createHardwareTexture = function () { return new Zt(this._createTexture(), this._gl) }, e.prototype._createInternalTexture = function (e, t, i, r) { var n; void 0 === i && (i = !0), void 0 === r && (r = It.Unknown); var o, s = !1, l = a.TEXTURETYPE_UNSIGNED_INT, c = a.TEXTURE_TRILINEAR_SAMPLINGMODE, u = a.TEXTUREFORMAT_RGBA, h = !1, d = 1; void 0 !== t && "object" == typeof t ? (s = !!t.generateMipMaps, l = void 0 === t.type ? a.TEXTURETYPE_UNSIGNED_INT : t.type, c = void 0 === t.samplingMode ? a.TEXTURE_TRILINEAR_SAMPLINGMODE : t.samplingMode, u = void 0 === t.format ? a.TEXTUREFORMAT_RGBA : t.format, h = void 0 !== t.useSRGBBuffer && t.useSRGBBuffer, d = null !== (n = t.samples) && void 0 !== n ? n : 1, o = t.label) : s = !!t, h && (h = this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || 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 Ht(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 Ht(this, It.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; P < I.length; P++) { var M = I[P]; if (M.canLoad(R, _)) { C = M; break } } n && n.addPendingData(E), E.url = t, E.generateMipMaps = !i, E.samplingMode = o, E.invertY = r, E._useSRGBBuffer = this._getUseSRGBBuffer(!!g, i), this._doNotHandleContextLost || (E._buffer = h); var O = null; s && !d && (O = E.onLoadedObservable.add(s)), d || this._internalTexturesCache.push(E); var D = function (e, r) { n && n.removePendingData(E), t === x ? (O && E.onLoadedObservable.remove(O), S.UseFallbackTexture && v._createTextureBase(S.FallbackTexture, i, E.invertY, n, o, null, l, c, u, h, E), e = (e || "Unknown error") + (S.UseFallbackTexture ? " - Fallback texture was used" : ""), E.onErrorObservable.notifyObservers({ message: e, exception: r }), l && l(e, r)) : ($.Warn("Failed to load ".concat(t, ", falling back to ").concat(x)), v._createTextureBase(x, i, E.invertY, n, o, s, l, c, u, h, E, p, f, _, m, g)) }; if (C) { var N = function (e) { C.loadData(e, E, (function (e, t, i, r, a, s) { s ? D("TextureLoader failed to load data") : c(E, R, n, { width: e, height: t }, E.invertY, !i, r, (function () { return a(), !1 }), o) }), m) }; h ? h instanceof ArrayBuffer ? N(new Uint8Array(h)) : ArrayBuffer.isView(h) ? N(h) : l && l("Unable to load: only ArrayBuffer or ArrayBufferView is supported", null) : this._loadFile(t, (function (e) { return N(new Uint8Array(e)) }), void 0, n ? n.offlineProvider : void 0, !0, (function (e, t) { D("Unable to load " + (e && e.responseURL, t)) })) } else { var F = function (e) { b && !v._doNotHandleContextLost && (E._buffer = e), c(E, R, n, e, E.invertY, i, !1, u, o) }; !y || T ? h && ("string" == typeof h.decoding || h.close) ? F(h) : e._FileToolsLoadImage(t, F, D, n ? n.offlineProvider : null, _, E.invertY && this._features.needsInvertingBitmap ? { imageOrientation: "flipY" } : void 0) : "string" == typeof h || h instanceof ArrayBuffer || ArrayBuffer.isView(h) || h instanceof Blob ? e._FileToolsLoadImage(h, F, D, n ? n.offlineProvider : null, _, E.invertY && this._features.needsInvertingBitmap ? { imageOrientation: "flipY" } : void 0) : h && F(h) } return E }, e.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, this._prepareWebGLTexture.bind(this), (function (e, t, i, n, o, a) { var s = m._gl, l = i.width === e && i.height === t, c = u ? m._getInternalFormat(u, o._useSRGBBuffer) : ".jpg" !== n || o._useSRGBBuffer ? o._useSRGBBuffer ? m._glSRGBExtensionValues.SRGB8_ALPHA8 : s.RGBA : s.RGB, h = u ? m._getInternalFormat(u) : ".jpg" !== n || o._useSRGBBuffer ? s.RGBA : s.RGB; if (o._useSRGBBuffer && 1 === m.webGLVersion && (h = c), l) return s.texImage2D(s.TEXTURE_2D, 0, c, h, s.UNSIGNED_BYTE, i), !1; var d = m._caps.maxTextureSize; if (i.width > d || i.height > d || !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, h, s.UNSIGNED_BYTE, m._workingCanvas), o.width = e, o.height = t, 1)); var p = new Ht(m, It.Temp); return m._bindTextureDirectly(s.TEXTURE_2D, p, !0), s.texImage2D(s.TEXTURE_2D, 0, c, h, s.UNSIGNED_BYTE, i), m._rescaleTexture(p, o, r, c, (function () { m._releaseTexture(p), m._bindTextureDirectly(s.TEXTURE_2D, o, !0), a() })), !0 }), l, c, u, h, d, p, _) }, e._FileToolsLoadImage = function (e, t, i, r, n, o) { throw ge("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), ge("Engine.RawTexture") }, e.prototype.createRawCubeTexture = function (e, t, i, r, n, o, a, s) { throw void 0 === s && (s = null), ge("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), ge("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), ge("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, 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 < i.length; r++) { var n = e.getUniform(i[r]); n && (this._boundUniforms[r] = n) } this._currentEffect = null }, e.prototype._activateCurrentTexture = function () { this._currentTextureChannel !== this._activeChannel && (this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel), this._currentTextureChannel = this._activeChannel) }, e.prototype._bindTextureDirectly = function (e, t, i, r) { var n, o; void 0 === i && (i = !1), void 0 === r && (r = !1); var a = !1, s = t && t._associatedChannel > -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; e < this._maxSimultaneousTextures; 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)) }, 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 < i.length; n++) { var o = i[n].getInternalTexture(); o ? (this._textureUnits[n] = e + n, o._associatedChannel = e + n) : this._textureUnits[n] = -1 } this._gl.uniform1iv(t, this._textureUnits); for (var a = 0; a < i.length; a++)this._setTexture(this._textureUnits[a], i[a], !0) } }, e.prototype._setAnisotropicLevel = function (e, t, i) { var r = this._caps.textureAnisotropicFilterExtension; t.samplingMode !== a.TEXTURE_LINEAR_LINEAR_MIPNEAREST && t.samplingMode !== a.TEXTURE_LINEAR_LINEAR_MIPLINEAR && t.samplingMode !== a.TEXTURE_LINEAR_LINEAR && (i = 1), r && t._cachedAnisotropicFilteringLevel !== i && (this._setTextureParameterFloat(e, r.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(i, this._caps.maxAnisotropy), t), t._cachedAnisotropicFilteringLevel = i) }, e.prototype._setTextureParameterFloat = function (e, t, i, r) { this._bindTextureDirectly(e, r, !0, !0), this._gl.texParameterf(e, t, i) }, e.prototype._setTextureParameterInteger = function (e, t, i, r) { r && this._bindTextureDirectly(e, r, !0, !0), this._gl.texParameteri(e, t, i) }, e.prototype.unbindAllAttributes = function () { if (this._mustWipeVertexAttributes) { this._mustWipeVertexAttributes = !1; for (var e = 0; e < this._caps.maxVertexAttribs; e++)this.disableAttributeByIndex(e) } else { e = 0; for (var t = this._vertexAttribArraysEnabled.length; e < t; e++)e >= 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; 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 = {}, et() && 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, Vt.ResetCache(); for (var t = 0, i = this._activeRequests; t < i.length; t++)i[t].abort(); this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear() }, e.prototype.attachContextLostEvent = function (e) { this._renderingCanvas && this._renderingCanvas.addEventListener("webglcontextlost", e, !1) }, e.prototype.attachContextRestoredEvent = function (e) { this._renderingCanvas && this._renderingCanvas.addEventListener("webglcontextrestored", e, !1) }, e.prototype.getError = function () { return this._gl.getError() }, e.prototype._canRenderToFloatFramebuffer = function () { return this._webGLVersion > 1 ? 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 ge("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 (et()) { 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 : it() ? 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 }(), ii = function () { function e() { } return e.SetImmediate = function (e) { et() && window.setImmediate ? window.setImmediate(e) : setTimeout(e, 1) }, e }(), ri = new RegExp(/^data:([^,]+\/[^,]+)?;base64,/i), ni = function (e) { function t(i, r) { var n = e.call(this, i, ut.LoadFileError) || this; return n.name = "LoadFileError", ct._setPrototypeOf(n, t.prototype), r instanceof He ? n.request = r : n.file = r, n } return W(t, e), t }(ht), oi = function (e) { function t(i, r) { var n = e.call(this, i, ut.RequestFileError) || this; return n.request = r, n.name = "RequestFileError", ct._setPrototypeOf(n, t.prototype), n } return W(t, e), t }(ht), ai = function (e) { function t(i, r) { var n = e.call(this, i, ut.ReadFileError) || this; return n.file = r, n.name = "ReadFileError", ct._setPrototypeOf(n, t.prototype), n } return W(t, e), t }(ht), si = { DefaultRetryStrategy: lt.ExponentialBackoff(), BaseUrl: "", CorsBehavior: "anonymous", PreprocessUrl: function (e) { return e } }, li = function (e) { return e.replace(/#/gm, "%23") }, ci = function (e, t) { if ((!e || 0 !== e.indexOf("data:")) && si.CorsBehavior) if ("string" == typeof si.CorsBehavior || si.CorsBehavior instanceof String) t.crossOrigin = si.CorsBehavior; else { var i = si.CorsBehavior(e); i && (t.crossOrigin = i) } }, ui = 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,") + _t(e) : e instanceof Blob ? (s = URL.createObjectURL(e), l = !0) : (s = li(e), s = si.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 di(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; ci(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 || _ ? h.src = s : di(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 (st.FilesToLoad[g] && "undefined" != typeof URL) { try { var v = void 0; try { v = URL.createObjectURL(st.FilesToLoad[g]) } catch (e) { v = URL.createObjectURL(st.FilesToLoad[g]) } h.src = v, l = !0 } catch (e) { h.src = "" } return h } } m() } return h }, hi = 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 ai("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 }, di = function (e, t, i, r, n, o, a) { if (e.name) return hi(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 = st.FilesToLoad[l]; if (c) return hi(c, t, i, n, o ? function (e) { return o(void 0, new ni(e.message, e.file)) } : void 0) } var h = mi(s), d = h.match, p = h.type; if (d) { var f = { onCompleteObservable: new u, abort: function () { return function () { } } }; try { var _ = n ? gi(s) : yi(s); t(_, void 0, p) } catch (e) { o ? o(void 0, e) : $.Error(e.message || "Failed to parse the Data URL") } return ii.SetImmediate((function () { f.onCompleteObservable.notifyObservers(f) })), f } return pi(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 ni(e.message, e.request)) } : void 0, a) }, pi = function (e, t, i, r, n, o, a) { e = li(e), e = si.PreprocessUrl(e); var s = si.BaseUrl + e, l = !1, c = { onCompleteObservable: new u, abort: function () { return l = !0 } }, h = function () { var e, r = new He, 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 oi(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 && (!et() || fi())) { try { t && t(n ? r.response : r.responseText, r) } catch (e) { p(e) } return } var i = si.DefaultRetryStrategy; if (i) { var a = i(s, r, c); if (-1 !== a) return h(), r = new He, void (u = setTimeout((function () { return f(c + 1) }), a)) } var d = new oi("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(si.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 }, fi = function () { return "undefined" != typeof location && "file:" === location.protocol }, _i = function (e) { return ri.test(e) }, mi = function (e) { var t = ri.exec(e); return null === t || 0 === t.length ? { match: !1, type: "" } : { match: !0, type: t[0].replace("data:", "").replace("base64,", "") } }; function gi(e) { return gt(e.split(",")[1]) } var vi, yi = function (e) { return mt(e.split(",")[1]) }; ti._FileToolsLoadImage = ui, ti._FileToolsLoadFile = di, Bt._FileToolsLoadFile = di; var bi = function (e, t, i, r, n, o, a, s, l, c) { vi = { 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(vi, "DefaultRetryStrategy", { get: function () { return i.DefaultRetryStrategy }, set: function (e) { i.DefaultRetryStrategy = e } }), Object.defineProperty(vi, "BaseUrl", { get: function () { return i.BaseUrl }, set: function (e) { i.BaseUrl = e } }), Object.defineProperty(vi, "PreprocessUrl", { get: function () { return i.PreprocessUrl }, set: function (e) { i.PreprocessUrl = e } }), Object.defineProperty(vi, "CorsBehavior", { get: function () { return i.CorsBehavior }, set: function (e) { i.CorsBehavior = e } }) }; bi(gi, yi, si, _i, fi, di, ui, hi, pi, ci); var Ti = 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; n < o; n++)r = r[i[n]]; return "function" != typeof r ? null : r }, e.RegisteredExternalClasses = {}, e }(); function Ei() { return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (function (e) { var t = 16 * Math.random() | 0; return ("x" === e ? t : 3 & t | 8).toString(16) })) } var Si = { RandomId: Ei }, xi = function () { function e() { } return Object.defineProperty(e, "BaseUrl", { get: function () { return si.BaseUrl }, set: function (e) { si.BaseUrl = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "DefaultRetryStrategy", { get: function () { return si.DefaultRetryStrategy }, set: function (e) { si.DefaultRetryStrategy = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "CorsBehavior", { get: function () { return si.CorsBehavior }, set: function (e) { si.CorsBehavior = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "UseFallbackTexture", { get: function () { return S.UseFallbackTexture }, set: function (e) { S.UseFallbackTexture = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "RegisteredExternalClasses", { get: function () { return Ti.RegisteredExternalClasses }, set: function (e) { Ti.RegisteredExternalClasses = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "fallbackTexture", { get: function () { return S.FallbackTexture }, set: function (e) { S.FallbackTexture = e }, enumerable: !1, configurable: !0 }), e.FetchToRef = function (e, t, i, r, n, o) { var a = 4 * ((Math.abs(e) * i % i | 0) + (Math.abs(t) * r % r | 0) * i); o.r = n[a] / 255, o.g = n[a + 1] / 255, o.b = n[a + 2] / 255, o.a = n[a + 3] / 255 }, e.Mix = function (e, t, i) { return e * (1 - i) + t * i }, e.Instantiate = function (e) { return Ti.Instantiate(e) }, e.SetImmediate = function (e) { ii.SetImmediate(e) }, e.IsExponentOfTwo = function (e) { var t = 1; do { t *= 2 } while (t < e); return t === e }, e.FloatRound = function (t) { return Math.fround ? Math.fround(t) : (e._TmpFloatArray[0] = t, e._TmpFloatArray[0]) }, e.GetFilename = function (e) { var t = e.lastIndexOf("/"); return t < 0 ? e : e.substring(t + 1) }, e.GetFolderPath = function (e, t) { void 0 === t && (t = !1); var i = e.lastIndexOf("/"); return i < 0 ? t ? e : "" : e.substring(0, i + 1) }, e.ToDegrees = function (e) { return 180 * e / Math.PI }, e.ToRadians = function (e) { return e * Math.PI / 180 }, e.SmoothAngleChange = function (e, t, i) { void 0 === i && (i = .9); var r = this.ToRadians(e), n = this.ToRadians(t); return this.ToDegrees(Math.atan2((1 - i) * Math.sin(n) + i * Math.sin(r), (1 - i) * Math.cos(n) + i * Math.cos(r))) }, e.MakeArray = function (e, t) { return !0 === t || void 0 !== e && null != e ? Array.isArray(e) ? e : [e] : null }, e.GetPointerPrefix = function (e) { var t = "pointer"; return et() && !window.PointerEvent && (t = "mouse"), !e._badDesktopOS || e._badOS || document && "ontouchend" in document || (t = "mouse"), t }, e.SetCorsBehavior = function (e, t) { ci(e, t) }, e.SetReferrerPolicyBehavior = function (e, t) { t.referrerPolicy = e }, e.CleanUrl = function (e) { return e.replace(/#/gm, "%23") }, Object.defineProperty(e, "PreprocessUrl", { get: function () { return si.PreprocessUrl }, set: function (e) { si.PreprocessUrl = e }, enumerable: !1, configurable: !0 }), e.LoadImage = function (e, t, i, r, n, o) { return ui(e, t, i, r, n, o) }, e.LoadFile = function (e, t, i, r, n, o) { return di(e, t, i, r, n, o) }, e.LoadFileAsync = function (e, t) { return void 0 === t && (t = !0), new Promise((function (i, r) { di(e, (function (e) { i(e) }), void 0, void 0, t, (function (e, t) { r(t) })) })) }, e.LoadScript = function (e, t, i, r) { if ("function" != typeof importScripts) if (et()) { var n = document.getElementsByTagName("head")[0], o = document.createElement("script"); o.setAttribute("type", "text/javascript"), o.setAttribute("src", e), r && (o.id = r), o.onload = function () { t && t() }, o.onerror = function (t) { i && i("Unable to load script '".concat(e, "'"), t) }, n.appendChild(o) } else null == i || i("Cannot load script '".concat(e, "' outside of a window or a worker")); else try { importScripts(e), t() } catch (t) { null == i || i("Unable to load script '".concat(e, "' in worker"), t) } }, e.LoadScriptAsync = function (e) { var t = this; return new Promise((function (i, r) { t.LoadScript(e, (function () { i() }), (function (e, t) { r(t || new Error(e)) })) })) }, e.ReadFileAsDataURL = function (e, t, i) { var r = new FileReader, n = { onCompleteObservable: new u, abort: function () { return r.abort() } }; return r.onloadend = function () { n.onCompleteObservable.notifyObservers(n) }, r.onload = function (e) { t(e.target.result) }, r.onprogress = i, r.readAsDataURL(e), n }, e.ReadFile = function (e, t, i, r, n) { return hi(e, t, i, r, n) }, e.FileAsURL = function (e) { var t = new Blob([e]); return window.URL.createObjectURL(t) }, e.Format = function (e, t) { return void 0 === t && (t = 2), e.toFixed(t) }, e.DeepCopy = function (e, t, i, r) { he.DeepCopy(e, t, i, r) }, e.IsEmpty = function (e) { for (var t in e) if (Object.prototype.hasOwnProperty.call(e, t)) return !1; return !0 }, e.RegisterTopRootEvents = function (e, t) { for (var i = 0; i < t.length; i++) { var r = t[i]; e.addEventListener(r.name, r.handler, !1); try { window.parent && window.parent.addEventListener(r.name, r.handler, !1) } catch (e) { } } }, e.UnregisterTopRootEvents = function (e, t) { for (var i = 0; i < t.length; i++) { var r = t[i]; e.removeEventListener(r.name, r.handler); try { e.parent && e.parent.removeEventListener(r.name, r.handler) } catch (e) { } } }, e.DumpFramebuffer = function (e, t, i, r, n, o, a) { return void 0 === n && (n = "image/png"), j(this, void 0, void 0, (function () { return Y(this, (function (e) { throw ge("DumpTools") })) })) }, e.DumpData = function (e, t, i, r, n, o, a, s, l) { throw void 0 === n && (n = "image/png"), void 0 === a && (a = !1), void 0 === s && (s = !1), ge("DumpTools") }, e.DumpDataAsync = function (e, t, i, r, n, o, a, s) { throw void 0 === r && (r = "image/png"), void 0 === o && (o = !1), void 0 === a && (a = !1), ge("DumpTools") }, e._IsOffScreenCanvas = function (e) { return void 0 !== e.convertToBlob }, e.ToBlob = function (t, i, r, n) { void 0 === r && (r = "image/png"), e._IsOffScreenCanvas(t) || t.toBlob || (t.toBlob = function (e, t, i) { var r = this; setTimeout((function () { for (var n = atob(r.toDataURL(t, i).split(",")[1]), o = n.length, a = new Uint8Array(o), s = 0; s < o; s++)a[s] = n.charCodeAt(s); e(new Blob([a])) })) }), e._IsOffScreenCanvas(t) ? t.convertToBlob({ type: r, quality: n }).then((function (e) { return i(e) })) : t.toBlob((function (e) { i(e) }), r, n) }, e.DownloadBlob = function (t, i) { if ("download" in document.createElement("a")) { if (!i) { var r = new Date; i = "screenshot_" + (r.getFullYear() + "-" + (r.getMonth() + 1)).slice(2) + "-" + r.getDate() + "_" + r.getHours() + "-" + ("0" + r.getMinutes()).slice(-2) + ".png" } e.Download(t, i) } else if (t && "undefined" != typeof URL) { var n = URL.createObjectURL(t), o = window.open(""); if (!o) return; var a = o.document.createElement("img"); a.onload = function () { URL.revokeObjectURL(n) }, a.src = n, o.document.body.appendChild(a) } }, e.EncodeScreenshotCanvasData = function (t, i, r, n, o) { if (void 0 === r && (r = "image/png"), "string" != typeof n && i) { if (i) { if (e._IsOffScreenCanvas(t)) return void t.convertToBlob({ type: r, quality: o }).then((function (e) { var t = new FileReader; t.readAsDataURL(e), t.onloadend = function () { var e = t.result; i(e) } })); var a = t.toDataURL(r, o); i(a) } } else this.ToBlob(t, (function (t) { t && e.DownloadBlob(t, n), i && i("") }), r, o) }, e.Download = function (e, t) { if ("undefined" != typeof URL) { var i = window.URL.createObjectURL(e), r = document.createElement("a"); document.body.appendChild(r), r.style.display = "none", r.href = i, r.download = t, r.addEventListener("click", (function () { r.parentElement && r.parentElement.removeChild(r) })), r.click(), window.URL.revokeObjectURL(i) } }, e.BackCompatCameraNoPreventDefault = function (e) { return "boolean" == typeof e[0] ? e[0] : "boolean" == typeof e[1] && e[1] }, e.CreateScreenshot = function (e, t, i, r, n, o, a) { throw void 0 === n && (n = "image/png"), void 0 === o && (o = !1), ge("ScreenshotTools") }, e.CreateScreenshotAsync = function (e, t, i, r, n) { throw void 0 === r && (r = "image/png"), ge("ScreenshotTools") }, e.CreateScreenshotUsingRenderTarget = function (e, t, i, r, n, o, a, s, l, c, u, h) { throw void 0 === n && (n = "image/png"), void 0 === o && (o = 1), void 0 === a && (a = !1), void 0 === l && (l = !1), void 0 === c && (c = !1), void 0 === u && (u = !0), ge("ScreenshotTools") }, e.CreateScreenshotUsingRenderTargetAsync = function (e, t, i, r, n, o, a, s, l, c, u) { throw 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), ge("ScreenshotTools") }, e.RandomId = function () { return Ei() }, e.IsBase64 = function (e) { return _i(e) }, e.DecodeBase64 = function (e) { return gi(e) }, Object.defineProperty(e, "errorsCount", { get: function () { return $.errorsCount }, enumerable: !1, configurable: !0 }), e.Log = function (e) { $.Log(e) }, e.Warn = function (e) { $.Warn(e) }, e.Error = function (e) { $.Error(e) }, Object.defineProperty(e, "LogCache", { get: function () { return $.LogCache }, enumerable: !1, configurable: !0 }), e.ClearLogCache = function () { $.ClearLogCache() }, Object.defineProperty(e, "LogLevels", { set: function (e) { $.LogLevels = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "PerformanceLogLevel", { set: function (t) { return (t & e.PerformanceUserMarkLogLevel) === e.PerformanceUserMarkLogLevel ? (e.StartPerformanceCounter = e._StartUserMark, void (e.EndPerformanceCounter = e._EndUserMark)) : (t & e.PerformanceConsoleLogLevel) === e.PerformanceConsoleLogLevel ? (e.StartPerformanceCounter = e._StartPerformanceConsole, void (e.EndPerformanceCounter = e._EndPerformanceConsole)) : (e.StartPerformanceCounter = e._StartPerformanceCounterDisabled, void (e.EndPerformanceCounter = e._EndPerformanceCounterDisabled)) }, enumerable: !1, configurable: !0 }), e._StartPerformanceCounterDisabled = function (e, t) { }, e._EndPerformanceCounterDisabled = function (e, t) { }, e._StartUserMark = function (t, i) { if (void 0 === i && (i = !0), !e._Performance) { if (!et()) return; e._Performance = window.performance } i && e._Performance.mark && e._Performance.mark(t + "-Begin") }, e._EndUserMark = function (t, i) { void 0 === i && (i = !0), i && e._Performance.mark && (e._Performance.mark(t + "-End"), e._Performance.measure(t, t + "-Begin", t + "-End")) }, e._StartPerformanceConsole = function (t, i) { void 0 === i && (i = !0), i && (e._StartUserMark(t, i), console.time && console.time(t)) }, e._EndPerformanceConsole = function (t, i) { void 0 === i && (i = !0), i && (e._EndUserMark(t, i), console.timeEnd(t)) }, Object.defineProperty(e, "Now", { get: function () { return at.Now }, enumerable: !1, configurable: !0 }), e.GetClassName = function (e, t) { void 0 === t && (t = !1); var i = null; return !t && e.getClassName ? i = e.getClassName() : (e instanceof Object && (i = (t ? e : Object.getPrototypeOf(e)).constructor.__bjsclassName__), i || (i = typeof e)), i }, e.First = function (e, t) { for (var i = 0, r = e; i < r.length; i++) { var n = r[i]; if (t(n)) return n } return null }, e.getFullClassName = function (e, t) { void 0 === t && (t = !1); var i = null, r = null; if (!t && e.getClassName) i = e.getClassName(); else { if (e instanceof Object) { var n = t ? e : Object.getPrototypeOf(e); i = n.constructor.__bjsclassName__, r = n.constructor.__bjsmoduleName__ } i || (i = typeof e) } return i ? (null != r ? r + "." : "") + i : null }, e.DelayAsync = function (e) { return new Promise((function (t) { setTimeout((function () { t() }), e) })) }, e.IsSafari = function () { return !!tt() && /^((?!chrome|android).)*safari/i.test(navigator.userAgent) }, e.UseCustomRequestHeaders = !1, e.CustomRequestHeaders = He.CustomRequestHeaders, e._TmpFloatArray = new Float32Array(1), e.GetDOMTextContent = rt, e.GetAbsoluteUrl = "object" == typeof document ? function (e) { var t = document.createElement("a"); return t.href = e, t.href } : "function" == typeof URL && "object" == typeof location ? function (e) { return new URL(e, location.origin).href } : function () { throw new Error("Unable to get absolute URL. Override BABYLON.Tools.GetAbsoluteUrl to a custom implementation for the current context.") }, e.NoneLogLevel = $.NoneLogLevel, e.MessageLogLevel = $.MessageLogLevel, e.WarningLogLevel = $.WarningLogLevel, e.ErrorLogLevel = $.ErrorLogLevel, e.AllLogLevel = $.AllLogLevel, e.IsWindowObjectExist = et, e.PerformanceNoneLogLevel = 0, e.PerformanceUserMarkLogLevel = 1, e.PerformanceConsoleLogLevel = 2, e.StartPerformanceCounter = e._StartPerformanceCounterDisabled, e.EndPerformanceCounter = e._EndPerformanceCounterDisabled, e }(); function Ai(e, t) { return function (i) { i.__bjsclassName__ = e, i.__bjsmoduleName__ = null != t ? t : null } } var Ri = function () { function e(e, t, i, r) { void 0 === r && (r = 0), this.iterations = e, this.index = r - 1, this._done = !1, this._fn = t, this._successCallback = i } return e.prototype.executeNext = function () { this._done || (this.index + 1 < this.iterations ? (++this.index, this._fn(this)) : this.breakLoop()) }, e.prototype.breakLoop = function () { this._done = !0, this._successCallback() }, e.Run = function (t, i, r, n) { void 0 === n && (n = 0); var o = new e(t, i, r, n); return o.executeNext(), o }, e.SyncAsyncForLoop = function (t, i, r, n, o, a) { return void 0 === a && (a = 0), e.Run(Math.ceil(t / i), (function (e) { o && o() ? e.breakLoop() : setTimeout((function () { for (var n = 0; n < i; ++n) { var a = e.index * i + n; if (a >= 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 Ci = 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; t < this.length; t++)e(this.data[t]) }, e.prototype.sort = function (e) { this.data.sort(e) }, e.prototype.reset = function () { this.length = 0 }, e.prototype.dispose = function () { this.reset(), this.data && (this.data.length = 0) }, e.prototype.concat = 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; t < e.length; t++)this.data[this.length++] = (e.data || e)[t] } }, e.prototype.indexOf = function (e) { var t = this.data.indexOf(e); return t >= this.length ? -1 : t }, e.prototype.contains = function (e) { return -1 !== this.indexOf(e) }, e._GlobalId = 0, e }(), Pi = 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; t < e.length; t++) { var i = (e.data || e)[t]; this.pushNoDuplicate(i) } } }, t }(Ci), Ii = function () { function e() { this._count = 0, this._data = {} } return e.prototype.copyFrom = function (e) { var t = this; this.clear(), e.forEach((function (e, i) { return t.add(e, i) })) }, e.prototype.get = function (e) { var t = this._data[e]; if (void 0 !== t) return t }, e.prototype.getOrAddWithFactory = function (e, t) { var i = this.get(e); return void 0 !== i || (i = t(e)) && this.add(e, i), i }, e.prototype.getOrAdd = function (e, t) { var i = this.get(e); return void 0 !== i ? i : (this.add(e, t), t) }, e.prototype.contains = function (e) { return void 0 !== this._data[e] }, e.prototype.add = function (e, t) { return void 0 === this._data[e] && (this._data[e] = t, ++this._count, !0) }, e.prototype.set = function (e, t) { return void 0 !== this._data[e] && (this._data[e] = t, !0) }, e.prototype.getAndRemove = function (e) { var t = this.get(e); return void 0 !== t ? (delete this._data[e], --this._count, t) : null }, e.prototype.remove = function (e) { return !!this.contains(e) && (delete this._data[e], --this._count, !0) }, e.prototype.clear = function () { this._data = {}, this._count = 0 }, Object.defineProperty(e.prototype, "count", { get: function () { return this._count }, enumerable: !1, configurable: !0 }), e.prototype.forEach = function (e) { for (var t in this._data) e(t, this._data[t]) }, e.prototype.first = function (e) { for (var t in this._data) { var i = e(t, this._data[t]); if (i) return i } return null }, e }(), Mi = function () { function e(e) { if (this._keys = [], this._isDirty = !0, this._areLightsDirty = !0, this._areLightsDisposed = !1, this._areAttributesDirty = !0, this._areTexturesDirty = !0, this._areFresnelDirty = !0, this._areMiscDirty = !0, this._arePrePassDirty = !0, this._areImageProcessingDirty = !0, this._normals = !1, this._uvs = !1, this._needNormals = !1, this._needUVs = !1, this._externalProperties = e, e) for (var t in e) Object.prototype.hasOwnProperty.call(e, t) && this._setDefaultValue(t) } return Object.defineProperty(e.prototype, "isDirty", { get: function () { return this._isDirty }, enumerable: !1, configurable: !0 }), e.prototype.markAsProcessed = function () { this._isDirty = !1, this._areAttributesDirty = !1, this._areTexturesDirty = !1, this._areFresnelDirty = !1, this._areLightsDirty = !1, this._areLightsDisposed = !1, this._areMiscDirty = !1, this._arePrePassDirty = !1, this._areImageProcessingDirty = !1 }, e.prototype.markAsUnprocessed = function () { this._isDirty = !0 }, e.prototype.markAllAsDirty = function () { this._areTexturesDirty = !0, this._areAttributesDirty = !0, this._areLightsDirty = !0, this._areFresnelDirty = !0, this._areMiscDirty = !0, this._arePrePassDirty = !1, this._areImageProcessingDirty = !0, this._isDirty = !0 }, e.prototype.markAsImageProcessingDirty = function () { this._areImageProcessingDirty = !0, this._isDirty = !0 }, e.prototype.markAsLightDirty = function (e) { void 0 === e && (e = !1), this._areLightsDirty = !0, this._areLightsDisposed = this._areLightsDisposed || e, this._isDirty = !0 }, e.prototype.markAsAttributesDirty = function () { this._areAttributesDirty = !0, this._isDirty = !0 }, e.prototype.markAsTexturesDirty = function () { this._areTexturesDirty = !0, this._isDirty = !0 }, e.prototype.markAsFresnelDirty = function () { this._areFresnelDirty = !0, this._isDirty = !0 }, e.prototype.markAsMiscDirty = function () { this._areMiscDirty = !0, this._isDirty = !0 }, e.prototype.markAsPrePassDirty = function () { this._arePrePassDirty = !0, this._isDirty = !0 }, e.prototype.rebuild = function () { this._keys.length = 0; for (var e = 0, t = Object.keys(this); e < t.length; e++) { var i = t[e]; "_" !== i[0] && this._keys.push(i) } if (this._externalProperties) for (var r in this._externalProperties) -1 === this._keys.indexOf(r) && this._keys.push(r) }, e.prototype.isEqual = function (e) { if (this._keys.length !== e._keys.length) return !1; for (var t = 0; t < this._keys.length; t++) { var i = this._keys[t]; if (this[i] !== e[i]) return !1 } return !0 }, e.prototype.cloneTo = function (e) { this._keys.length !== e._keys.length && (e._keys = this._keys.slice(0)); for (var t = 0; t < this._keys.length; t++) { var i = this._keys[t]; e[i] = this[i] } }, e.prototype.reset = function () { var e = this; this._keys.forEach((function (t) { return e._setDefaultValue(t) })) }, e.prototype._setDefaultValue = function (e) { var t, i, r, n, o, a = null !== (r = null === (i = null === (t = this._externalProperties) || void 0 === t ? void 0 : t[e]) || void 0 === i ? void 0 : i.type) && void 0 !== r ? r : typeof this[e], s = null === (o = null === (n = this._externalProperties) || void 0 === n ? void 0 : n[e]) || void 0 === o ? void 0 : o.default; switch (a) { case "number": this[e] = null != s ? s : 0; break; case "string": this[e] = null != s ? s : ""; break; default: this[e] = null != s && s } }, e.prototype.toString = function () { for (var e = "", t = 0; t < this._keys.length; t++) { var i = this._keys[t], r = this[i]; switch (typeof r) { case "number": case "string": e += "#define " + i + " " + r + "\n"; break; default: r && (e += "#define " + i + "\n") } } return e }, e }(), Oi = function () { function e() { this._dirty = !0, this._tempColor = new U(0, 0, 0, 0), this._globalCurve = new U(0, 0, 0, 0), this._highlightsCurve = new U(0, 0, 0, 0), this._midtonesCurve = new U(0, 0, 0, 0), this._shadowsCurve = new U(0, 0, 0, 0), this._positiveCurve = new U(0, 0, 0, 0), this._negativeCurve = new U(0, 0, 0, 0), this._globalHue = 30, this._globalDensity = 0, this._globalSaturation = 0, this._globalExposure = 0, this._highlightsHue = 30, this._highlightsDensity = 0, this._highlightsSaturation = 0, this._highlightsExposure = 0, this._midtonesHue = 30, this._midtonesDensity = 0, this._midtonesSaturation = 0, this._midtonesExposure = 0, this._shadowsHue = 30, this._shadowsDensity = 0, this._shadowsSaturation = 0, this._shadowsExposure = 0 } return Object.defineProperty(e.prototype, "globalHue", { get: function () { return this._globalHue }, set: function (e) { this._globalHue = e, this._dirty = !0 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "globalDensity", { get: function () { return this._globalDensity }, set: function (e) { this._globalDensity = e, this._dirty = !0 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "globalSaturation", { get: function () { return this._globalSaturation }, set: function (e) { this._globalSaturation = e, this._dirty = !0 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "globalExposure", { get: function () { return this._globalExposure }, set: function (e) { this._globalExposure = e, this._dirty = !0 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "highlightsHue", { get: function () { return this._highlightsHue }, set: function (e) { this._highlightsHue = e, this._dirty = !0 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "highlightsDensity", { get: function () { return this._highlightsDensity }, set: function (e) { this._highlightsDensity = e, this._dirty = !0 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "highlightsSaturation", { get: function () { return this._highlightsSaturation }, set: function (e) { this._highlightsSaturation = e, this._dirty = !0 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "highlightsExposure", { get: function () { return this._highlightsExposure }, set: function (e) { this._highlightsExposure = e, this._dirty = !0 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "midtonesHue", { get: function () { return this._midtonesHue }, set: function (e) { this._midtonesHue = e, this._dirty = !0 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "midtonesDensity", { get: function () { return this._midtonesDensity }, set: function (e) { this._midtonesDensity = e, this._dirty = !0 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "midtonesSaturation", { get: function () { return this._midtonesSaturation }, set: function (e) { this._midtonesSaturation = e, this._dirty = !0 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "midtonesExposure", { get: function () { return this._midtonesExposure }, set: function (e) { this._midtonesExposure = e, this._dirty = !0 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "shadowsHue", { get: function () { return this._shadowsHue }, set: function (e) { this._shadowsHue = e, this._dirty = !0 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "shadowsDensity", { get: function () { return this._shadowsDensity }, set: function (e) { this._shadowsDensity = e, this._dirty = !0 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "shadowsSaturation", { get: function () { return this._shadowsSaturation }, set: function (e) { this._shadowsSaturation = e, this._dirty = !0 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "shadowsExposure", { get: function () { return this._shadowsExposure }, set: function (e) { this._shadowsExposure = e, this._dirty = !0 }, enumerable: !1, configurable: !0 }), e.prototype.getClassName = function () { return "ColorCurves" }, e.Bind = function (e, t, i, r, n) { void 0 === i && (i = "vCameraColorCurvePositive"), void 0 === r && (r = "vCameraColorCurveNeutral"), void 0 === n && (n = "vCameraColorCurveNegative"), e._dirty && (e._dirty = !1, e._getColorGradingDataToRef(e._globalHue, e._globalDensity, e._globalSaturation, e._globalExposure, e._globalCurve), e._getColorGradingDataToRef(e._highlightsHue, e._highlightsDensity, e._highlightsSaturation, e._highlightsExposure, e._tempColor), e._tempColor.multiplyToRef(e._globalCurve, e._highlightsCurve), e._getColorGradingDataToRef(e._midtonesHue, e._midtonesDensity, e._midtonesSaturation, e._midtonesExposure, e._tempColor), e._tempColor.multiplyToRef(e._globalCurve, e._midtonesCurve), e._getColorGradingDataToRef(e._shadowsHue, e._shadowsDensity, e._shadowsSaturation, e._shadowsExposure, e._tempColor), e._tempColor.multiplyToRef(e._globalCurve, e._shadowsCurve), e._highlightsCurve.subtractToRef(e._midtonesCurve, e._positiveCurve), e._midtonesCurve.subtractToRef(e._shadowsCurve, e._negativeCurve)), t && (t.setFloat4(i, e._positiveCurve.r, e._positiveCurve.g, e._positiveCurve.b, e._positiveCurve.a), t.setFloat4(r, e._midtonesCurve.r, e._midtonesCurve.g, e._midtonesCurve.b, e._midtonesCurve.a), t.setFloat4(n, e._negativeCurve.r, e._negativeCurve.g, e._negativeCurve.b, e._negativeCurve.a)) }, e.PrepareUniforms = function (e) { e.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative") }, e.prototype._getColorGradingDataToRef = function (t, i, r, n, o) { null != t && (t = e._Clamp(t, 0, 360), i = e._Clamp(i, -100, 100), r = e._Clamp(r, -100, 100), n = e._Clamp(n, -100, 100), i = e._ApplyColorGradingSliderNonlinear(i), i *= .5, n = e._ApplyColorGradingSliderNonlinear(n), i < 0 && (i *= -1, t = (t + 180) % 360), e._FromHSBToRef(t, i, 50 + .25 * n, o), o.scaleToRef(2, o), o.a = 1 + .01 * r) }, e._ApplyColorGradingSliderNonlinear = function (e) { e /= 100; var t = Math.abs(e); return t = Math.pow(t, 2), e < 0 && (t *= -1), 100 * t }, e._FromHSBToRef = function (t, i, r, n) { var o = e._Clamp(t, 0, 360), a = e._Clamp(i / 100, 0, 1), s = e._Clamp(r / 100, 0, 1); if (0 === a) n.r = s, n.g = s, n.b = s; else { o /= 60; var l = Math.floor(o), c = o - l, u = s * (1 - a), h = s * (1 - a * c), d = s * (1 - a * (1 - c)); switch (l) { case 0: n.r = s, n.g = d, n.b = u; break; case 1: n.r = h, n.g = s, n.b = u; break; case 2: n.r = u, n.g = s, n.b = d; break; case 3: n.r = u, n.g = h, n.b = s; break; case 4: n.r = d, n.g = u, n.b = s; break; default: n.r = s, n.g = u, n.b = h } } n.a = 1 }, e._Clamp = function (e, t, i) { return Math.min(Math.max(e, t), i) }, e.prototype.clone = function () { return Ue.Clone((function () { return new e }), this) }, e.prototype.serialize = function () { return Ue.Serialize(this) }, e.Parse = function (t) { return Ue.Parse((function () { return new e }), t, null, null) }, X([xe()], e.prototype, "_globalHue", void 0), X([xe()], e.prototype, "_globalDensity", void 0), X([xe()], e.prototype, "_globalSaturation", void 0), X([xe()], e.prototype, "_globalExposure", void 0), X([xe()], e.prototype, "_highlightsHue", void 0), X([xe()], e.prototype, "_highlightsDensity", void 0), X([xe()], e.prototype, "_highlightsSaturation", void 0), X([xe()], e.prototype, "_highlightsExposure", void 0), X([xe()], e.prototype, "_midtonesHue", void 0), X([xe()], e.prototype, "_midtonesDensity", void 0), X([xe()], e.prototype, "_midtonesSaturation", void 0), X([xe()], e.prototype, "_midtonesExposure", void 0), e }(); Ue._ColorCurvesParser = Oi.Parse; var Di = function (e) { function t() { var t = e.call(this) || this; return t.IMAGEPROCESSING = !1, t.VIGNETTE = !1, t.VIGNETTEBLENDMODEMULTIPLY = !1, t.VIGNETTEBLENDMODEOPAQUE = !1, t.TONEMAPPING = !1, t.TONEMAPPING_ACES = !1, t.CONTRAST = !1, t.COLORCURVES = !1, t.COLORGRADING = !1, t.COLORGRADING3D = !1, t.SAMPLER3DGREENDEPTH = !1, t.SAMPLER3DBGRMAP = !1, t.DITHER = !1, t.IMAGEPROCESSINGPOSTPROCESS = !1, t.EXPOSURE = !1, t.SKIPFINALCOLORCLAMP = !1, t.rebuild(), t } return W(t, e), t }(Mi), Ni = function () { function e() { this.colorCurves = new Oi, this._colorCurvesEnabled = !1, this._colorGradingEnabled = !1, this._colorGradingWithGreenDepth = !0, this._colorGradingBGR = !0, this._exposure = 1, this._toneMappingEnabled = !1, this._toneMappingType = e.TONEMAPPING_STANDARD, this._contrast = 1, this.vignetteStretch = 0, this.vignetteCenterX = 0, this.vignetteCenterY = 0, this.vignetteWeight = 1.5, this.vignetteColor = new U(0, 0, 0, 0), this.vignetteCameraFov = .5, this._vignetteBlendMode = e.VIGNETTEMODE_MULTIPLY, this._vignetteEnabled = !1, this._ditheringEnabled = !1, this._ditheringIntensity = 1 / 255, this._skipFinalColorClamp = !1, this._applyByPostProcess = !1, this._isEnabled = !0, this.onUpdateParameters = new u } return Object.defineProperty(e.prototype, "colorCurvesEnabled", { get: function () { return this._colorCurvesEnabled }, set: function (e) { this._colorCurvesEnabled !== e && (this._colorCurvesEnabled = e, this._updateParameters()) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "colorGradingTexture", { get: function () { return this._colorGradingTexture }, set: function (e) { this._colorGradingTexture !== e && (this._colorGradingTexture = e, this._updateParameters()) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "colorGradingEnabled", { get: function () { return this._colorGradingEnabled }, set: function (e) { this._colorGradingEnabled !== e && (this._colorGradingEnabled = e, this._updateParameters()) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "colorGradingWithGreenDepth", { get: function () { return this._colorGradingWithGreenDepth }, set: function (e) { this._colorGradingWithGreenDepth !== e && (this._colorGradingWithGreenDepth = e, this._updateParameters()) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "colorGradingBGR", { get: function () { return this._colorGradingBGR }, set: function (e) { this._colorGradingBGR !== e && (this._colorGradingBGR = e, this._updateParameters()) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "exposure", { get: function () { return this._exposure }, set: function (e) { this._exposure !== e && (this._exposure = e, this._updateParameters()) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "toneMappingEnabled", { get: function () { return this._toneMappingEnabled }, set: function (e) { this._toneMappingEnabled !== e && (this._toneMappingEnabled = e, this._updateParameters()) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "toneMappingType", { get: function () { return this._toneMappingType }, set: function (e) { this._toneMappingType !== e && (this._toneMappingType = e, this._updateParameters()) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "contrast", { get: function () { return this._contrast }, set: function (e) { this._contrast !== e && (this._contrast = e, this._updateParameters()) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "vignetteCentreY", { get: function () { return this.vignetteCenterY }, set: function (e) { this.vignetteCenterY = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "vignetteCentreX", { get: function () { return this.vignetteCenterX }, set: function (e) { this.vignetteCenterX = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "vignetteBlendMode", { get: function () { return this._vignetteBlendMode }, set: function (e) { this._vignetteBlendMode !== e && (this._vignetteBlendMode = e, this._updateParameters()) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "vignetteEnabled", { get: function () { return this._vignetteEnabled }, set: function (e) { this._vignetteEnabled !== e && (this._vignetteEnabled = e, this._updateParameters()) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "ditheringEnabled", { get: function () { return this._ditheringEnabled }, set: function (e) { this._ditheringEnabled !== e && (this._ditheringEnabled = e, this._updateParameters()) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "ditheringIntensity", { get: function () { return this._ditheringIntensity }, set: function (e) { this._ditheringIntensity !== e && (this._ditheringIntensity = e, this._updateParameters()) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "skipFinalColorClamp", { get: function () { return this._skipFinalColorClamp }, set: function (e) { this._skipFinalColorClamp !== e && (this._skipFinalColorClamp = e, this._updateParameters()) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "applyByPostProcess", { get: function () { return this._applyByPostProcess }, set: function (e) { this._applyByPostProcess !== e && (this._applyByPostProcess = e, this._updateParameters()) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isEnabled", { get: function () { return this._isEnabled }, set: function (e) { this._isEnabled !== e && (this._isEnabled = e, this._updateParameters()) }, enumerable: !1, configurable: !0 }), e.prototype._updateParameters = function () { this.onUpdateParameters.notifyObservers(this) }, e.prototype.getClassName = function () { return "ImageProcessingConfiguration" }, e.PrepareUniforms = function (e, t) { t.EXPOSURE && e.push("exposureLinear"), t.CONTRAST && e.push("contrast"), t.COLORGRADING && e.push("colorTransformSettings"), (t.VIGNETTE || t.DITHER) && e.push("vInverseScreenSize"), t.VIGNETTE && (e.push("vignetteSettings1"), e.push("vignetteSettings2")), t.COLORCURVES && Oi.PrepareUniforms(e), t.DITHER && e.push("ditherIntensity") }, e.PrepareSamplers = function (e, t) { t.COLORGRADING && e.push("txColorTransform") }, e.prototype.prepareDefines = function (t, i) { if (void 0 === i && (i = !1), i !== this.applyByPostProcess || !this._isEnabled) return t.VIGNETTE = !1, t.TONEMAPPING = !1, t.TONEMAPPING_ACES = !1, t.CONTRAST = !1, t.EXPOSURE = !1, t.COLORCURVES = !1, t.COLORGRADING = !1, t.COLORGRADING3D = !1, t.DITHER = !1, t.IMAGEPROCESSING = !1, t.SKIPFINALCOLORCLAMP = this.skipFinalColorClamp, void (t.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled); t.VIGNETTE = this.vignetteEnabled, t.VIGNETTEBLENDMODEMULTIPLY = this.vignetteBlendMode === e._VIGNETTEMODE_MULTIPLY, t.VIGNETTEBLENDMODEOPAQUE = !t.VIGNETTEBLENDMODEMULTIPLY, t.TONEMAPPING = this.toneMappingEnabled, this._toneMappingType === e.TONEMAPPING_ACES ? t.TONEMAPPING_ACES = !0 : t.TONEMAPPING_ACES = !1, t.CONTRAST = 1 !== this.contrast, t.EXPOSURE = 1 !== this.exposure, t.COLORCURVES = this.colorCurvesEnabled && !!this.colorCurves, t.COLORGRADING = this.colorGradingEnabled && !!this.colorGradingTexture, t.COLORGRADING ? t.COLORGRADING3D = this.colorGradingTexture.is3D : t.COLORGRADING3D = !1, t.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth, t.SAMPLER3DBGRMAP = this.colorGradingBGR, t.DITHER = this._ditheringEnabled, t.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess, t.SKIPFINALCOLORCLAMP = this.skipFinalColorClamp, t.IMAGEPROCESSING = t.VIGNETTE || t.TONEMAPPING || t.CONTRAST || t.EXPOSURE || t.COLORCURVES || t.COLORGRADING || t.DITHER }, e.prototype.isReady = function () { return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady() }, e.prototype.bind = function (e, t) { if (this._colorCurvesEnabled && this.colorCurves && Oi.Bind(this.colorCurves, e), this._vignetteEnabled || this._ditheringEnabled) { var i = 1 / e.getEngine().getRenderWidth(), r = 1 / e.getEngine().getRenderHeight(); if (e.setFloat2("vInverseScreenSize", i, r), this._ditheringEnabled && e.setFloat("ditherIntensity", .5 * this._ditheringIntensity), this._vignetteEnabled) { var n = null != t ? t : r / i, o = Math.tan(.5 * this.vignetteCameraFov), a = o * n, s = Math.sqrt(a * o); a = xi.Mix(a, s, this.vignetteStretch), o = xi.Mix(o, s, this.vignetteStretch), e.setFloat4("vignetteSettings1", a, o, -a * this.vignetteCenterX, -o * this.vignetteCenterY); var l = -2 * this.vignetteWeight; e.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, l) } } if (e.setFloat("exposureLinear", this.exposure), e.setFloat("contrast", this.contrast), this.colorGradingTexture) { e.setTexture("txColorTransform", this.colorGradingTexture); var c = this.colorGradingTexture.getSize().height; e.setFloat4("colorTransformSettings", (c - 1) / c, .5 / c, c, this.colorGradingTexture.level) } }, e.prototype.clone = function () { return Ue.Clone((function () { return new e }), this) }, e.prototype.serialize = function () { return Ue.Serialize(this) }, e.Parse = function (t) { var i = Ue.Parse((function () { return new e }), t, null, null); return void 0 !== t.vignetteCentreX && (i.vignetteCenterX = t.vignetteCentreX), void 0 !== t.vignetteCentreY && (i.vignetteCenterY = t.vignetteCentreY), i }, Object.defineProperty(e, "VIGNETTEMODE_MULTIPLY", { get: function () { return this._VIGNETTEMODE_MULTIPLY }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "VIGNETTEMODE_OPAQUE", { get: function () { return this._VIGNETTEMODE_OPAQUE }, enumerable: !1, configurable: !0 }), e.TONEMAPPING_STANDARD = 0, e.TONEMAPPING_ACES = 1, e._VIGNETTEMODE_MULTIPLY = 0, e._VIGNETTEMODE_OPAQUE = 1, X([Oe()], e.prototype, "colorCurves", void 0), X([xe()], e.prototype, "_colorCurvesEnabled", void 0), X([Ae("colorGradingTexture")], e.prototype, "_colorGradingTexture", void 0), X([xe()], e.prototype, "_colorGradingEnabled", void 0), X([xe()], e.prototype, "_colorGradingWithGreenDepth", void 0), X([xe()], e.prototype, "_colorGradingBGR", void 0), X([xe()], e.prototype, "_exposure", void 0), X([xe()], e.prototype, "_toneMappingEnabled", void 0), X([xe()], e.prototype, "_toneMappingType", void 0), X([xe()], e.prototype, "_contrast", void 0), X([xe()], e.prototype, "vignetteStretch", void 0), X([xe()], e.prototype, "vignetteCenterX", void 0), X([xe()], e.prototype, "vignetteCenterY", void 0), X([xe()], e.prototype, "vignetteWeight", void 0), X([De()], e.prototype, "vignetteColor", void 0), X([xe()], e.prototype, "vignetteCameraFov", void 0), X([xe()], e.prototype, "_vignetteBlendMode", void 0), X([xe()], e.prototype, "_vignetteEnabled", void 0), X([xe()], e.prototype, "_ditheringEnabled", void 0), X([xe()], e.prototype, "_ditheringIntensity", void 0), X([xe()], e.prototype, "_skipFinalColorClamp", void 0), X([xe()], e.prototype, "_applyByPostProcess", void 0), X([xe()], e.prototype, "_isEnabled", void 0), e }(); Ue._ImageProcessingConfigurationParser = Ni.Parse, ti.prototype.createUniformBuffer = function (e) { var t = this._gl.createBuffer(); if (!t) throw new Error("Unable to create uniform buffer"); var i = new Qt(t); return this.bindUniformBuffer(i), e instanceof Float32Array ? this._gl.bufferData(this._gl.UNIFORM_BUFFER, e, this._gl.STATIC_DRAW) : this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(e), this._gl.STATIC_DRAW), this.bindUniformBuffer(null), i.references = 1, i }, ti.prototype.createDynamicUniformBuffer = function (e) { var t = this._gl.createBuffer(); if (!t) throw new Error("Unable to create dynamic uniform buffer"); var i = new Qt(t); return this.bindUniformBuffer(i), e instanceof Float32Array ? this._gl.bufferData(this._gl.UNIFORM_BUFFER, e, this._gl.DYNAMIC_DRAW) : this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(e), this._gl.DYNAMIC_DRAW), this.bindUniformBuffer(null), i.references = 1, i }, ti.prototype.updateUniformBuffer = function (e, t, i, r) { this.bindUniformBuffer(e), void 0 === i && (i = 0), void 0 === r ? t instanceof Float32Array ? this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, i, t) : this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, i, new Float32Array(t)) : t instanceof Float32Array ? this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, t.subarray(i, i + r)) : this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, new Float32Array(t).subarray(i, i + r)), this.bindUniformBuffer(null) }, ti.prototype.bindUniformBuffer = function (e) { this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, e ? e.underlyingResource : null) }, ti.prototype.bindUniformBufferBase = function (e, t, i) { this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, t, e ? e.underlyingResource : null) }, ti.prototype.bindUniformBlock = function (e, t, i) { var r = e.program, n = this._gl.getUniformBlockIndex(r, t); 4294967295 !== n && this._gl.uniformBlockBinding(r, n, i) }; var Fi, Li, wi, Bi, Ui, Vi, ki, Gi, zi = function () { function e(e, t, i, r, n) { void 0 === n && (n = !1), this._valueCache = {}, this._engine = e, this._noUBO = !e.supportsUniformBuffers || n, this._dynamic = i, this._name = null != r ? r : "no-name", this._data = t || [], this._uniformLocations = {}, this._uniformSizes = {}, this._uniformArraySizes = {}, this._uniformLocationPointer = 0, this._needSync = !1, this._engine._features.trackUbosInFrame && (this._buffers = [], this._bufferIndex = -1, this._createBufferOnWrite = !1, this._currentFrameId = 0), this._noUBO ? (this.updateMatrix3x3 = this._updateMatrix3x3ForEffect, this.updateMatrix2x2 = this._updateMatrix2x2ForEffect, this.updateFloat = this._updateFloatForEffect, this.updateFloat2 = this._updateFloat2ForEffect, this.updateFloat3 = this._updateFloat3ForEffect, this.updateFloat4 = this._updateFloat4ForEffect, this.updateFloatArray = this._updateFloatArrayForEffect, this.updateArray = this._updateArrayForEffect, this.updateIntArray = this._updateIntArrayForEffect, this.updateUIntArray = this._updateUIntArrayForEffect, this.updateMatrix = this._updateMatrixForEffect, this.updateMatrices = this._updateMatricesForEffect, this.updateVector3 = this._updateVector3ForEffect, this.updateVector4 = this._updateVector4ForEffect, this.updateColor3 = this._updateColor3ForEffect, this.updateColor4 = this._updateColor4ForEffect, this.updateDirectColor4 = this._updateDirectColor4ForEffect, this.updateInt = this._updateIntForEffect, this.updateInt2 = this._updateInt2ForEffect, this.updateInt3 = this._updateInt3ForEffect, this.updateInt4 = this._updateInt4ForEffect, this.updateUInt = this._updateUIntForEffect, this.updateUInt2 = this._updateUInt2ForEffect, this.updateUInt3 = this._updateUInt3ForEffect, this.updateUInt4 = this._updateUInt4ForEffect) : (this._engine._uniformBuffers.push(this), this.updateMatrix3x3 = this._updateMatrix3x3ForUniform, this.updateMatrix2x2 = this._updateMatrix2x2ForUniform, this.updateFloat = this._updateFloatForUniform, this.updateFloat2 = this._updateFloat2ForUniform, this.updateFloat3 = this._updateFloat3ForUniform, this.updateFloat4 = this._updateFloat4ForUniform, this.updateFloatArray = this._updateFloatArrayForUniform, this.updateArray = this._updateArrayForUniform, this.updateIntArray = this._updateIntArrayForUniform, this.updateUIntArray = this._updateUIntArrayForUniform, this.updateMatrix = this._updateMatrixForUniform, this.updateMatrices = this._updateMatricesForUniform, this.updateVector3 = this._updateVector3ForUniform, this.updateVector4 = this._updateVector4ForUniform, this.updateColor3 = this._updateColor3ForUniform, this.updateColor4 = this._updateColor4ForUniform, this.updateDirectColor4 = this._updateDirectColor4ForUniform, this.updateInt = this._updateIntForUniform, this.updateInt2 = this._updateInt2ForUniform, this.updateInt3 = this._updateInt3ForUniform, this.updateInt4 = this._updateInt4ForUniform, this.updateUInt = this._updateUIntForUniform, this.updateUInt2 = this._updateUInt2ForUniform, this.updateUInt3 = this._updateUInt3ForUniform, this.updateUInt4 = this._updateUInt4ForUniform) } return Object.defineProperty(e.prototype, "useUbo", { get: function () { return !this._noUBO }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isSync", { get: function () { return !this._needSync }, enumerable: !1, configurable: !0 }), e.prototype.isDynamic = function () { return void 0 !== this._dynamic }, e.prototype.getData = function () { return this._bufferData }, e.prototype.getBuffer = function () { return this._buffer }, e.prototype._fillAlignment = function (e) { var t; if (t = e <= 2 ? e : 4, this._uniformLocationPointer % t != 0) { var i = this._uniformLocationPointer; this._uniformLocationPointer += t - this._uniformLocationPointer % t; for (var r = this._uniformLocationPointer - i, n = 0; n < r; n++)this._data.push(0) } }, e.prototype.addUniform = function (e, t, i) { if (void 0 === i && (i = 0), !this._noUBO && void 0 === this._uniformLocations[e]) { var r; if (i > 0) { 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; n < t; n++)r.push(0) } else { if (t instanceof Array) t = (r = t).length; else for (r = [], n = 0; n < t; n++)r.push(0); this._fillAlignment(t) } for (this._uniformSizes[e] = t, this._uniformLocations[e] = this._uniformLocationPointer, this._uniformLocationPointer += t, n = 0; n < t; n++)this._data.push(r[n]); this._needSync = !0 } }, e.prototype.addMatrix = function (e, t) { this.addUniform(e, Array.prototype.slice.call(t.toArray())) }, e.prototype.addFloat2 = function (e, t, i) { var r = [t, i]; this.addUniform(e, r) }, e.prototype.addFloat3 = function (e, t, i, r) { var n = [t, i, r]; this.addUniform(e, n) }, e.prototype.addColor3 = function (e, t) { var i = [t.r, t.g, t.b]; this.addUniform(e, i) }, e.prototype.addColor4 = function (e, t, i) { var r = [t.r, t.g, t.b, i]; this.addUniform(e, r) }, e.prototype.addVector3 = function (e, t) { var i = [t.x, t.y, t.z]; this.addUniform(e, i) }, e.prototype.addMatrix3x3 = function (e) { this.addUniform(e, 12) }, e.prototype.addMatrix2x2 = function (e) { this.addUniform(e, 8) }, e.prototype.create = function () { this._noUBO || this._buffer || (this._fillAlignment(4), this._bufferData = new Float32Array(this._data), this._rebuild(), this._needSync = !0) }, e.prototype._rebuild = function () { !this._noUBO && this._bufferData && (this._dynamic ? this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData) : this._buffer = this._engine.createUniformBuffer(this._bufferData), this._engine._features.trackUbosInFrame && (this._buffers.push([this._buffer, this._engine._features.checkUbosContentBeforeUpload ? this._bufferData.slice() : void 0]), this._bufferIndex = this._buffers.length - 1, this._createBufferOnWrite = !1)) }, Object.defineProperty(e.prototype, "_numBuffers", { get: function () { return this._buffers.length }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "_indexBuffer", { get: function () { return this._bufferIndex }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "name", { get: function () { return this._name }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "currentEffect", { get: function () { return this._currentEffect }, enumerable: !1, configurable: !0 }), e.prototype._buffersEqual = function (e, t) { for (var i = 0; i < e.length; ++i)if (e[i] !== t[i]) return !1; return !0 }, e.prototype._copyBuffer = function (e, t) { for (var i = 0; i < e.length; ++i)t[i] = e[i] }, e.prototype.update = function () { if (!this._noUBO) if (this.bindUniformBuffer(), this._buffer) if (this._dynamic || this._needSync) { if (this._buffers && this._buffers.length > 1 && 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 + 1 < this._buffers.length ? (this._bufferIndex++, this._buffer = this._buffers[this._bufferIndex][0], this._createBufferOnWrite = !1, this._needSync = !0) : this._rebuild() }, e.prototype._checkNewFrame = function () { this._engine._features.trackUbosInFrame && this._currentFrameId !== this._engine.frameId && (this._currentFrameId = this._engine.frameId, this._createBufferOnWrite = !1, this._buffers && this._buffers.length > 0 ? (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; o < i; o++)this._bufferData[r + o] = t[o]; else { for (var n = !1, o = 0; o < i; o++)(16 === i && !this._engine._features.uniformBufferHardCheckMatrix || this._bufferData[r + o] !== xi.FloatRound(t[o])) && (n = !0, this._createBufferOnWrite && this._createNewBuffer(), this._bufferData[r + o] = t[o]); this._needSync = this._needSync || n } }, e.prototype.updateUniformArray = function (e, t, i) { this._checkNewFrame(); var r = this._uniformLocations[e]; if (void 0 !== r) { this._buffer || this.create(); var n = this._uniformArraySizes[e]; if (this._dynamic) for (l = 0; l < i; l++)this._bufferData[r + l] = t[l]; else { for (var o = !1, a = 0, s = 0, l = 0; l < i; l++)if (this._bufferData[r + 4 * s + a] !== xi.FloatRound(t[l]) && (o = !0, this._createBufferOnWrite && this._createNewBuffer(), this._bufferData[r + 4 * s + a] = t[l]), ++a === n.strideSize) { for (; a < 4; a++)this._bufferData[r + 4 * s + a] = 0; a = 0, s++ } this._needSync = this._needSync || o } } else $.Error("Cannot add an uniform Array dynamically. Please, add it using addUniform and make sure that uniform buffers are supported by the current engine.") }, e.prototype._cacheMatrix = function (e, t) { this._checkNewFrame(); var i = this._valueCache[e], r = t.updateFlag; return (void 0 === i || i !== r) && (this._valueCache[e] = r, !0) }, e.prototype._updateMatrix3x3ForUniform = function (t, i) { for (var r = 0; r < 3; r++)e._TempBuffer[4 * r] = i[3 * r], e._TempBuffer[4 * r + 1] = i[3 * r + 1], e._TempBuffer[4 * r + 2] = i[3 * r + 2], e._TempBuffer[4 * r + 3] = 0; this.updateUniform(t, e._TempBuffer, 12) }, e.prototype._updateMatrix3x3ForEffect = function (e, t) { this._currentEffect.setMatrix3x3(e, t) }, e.prototype._updateMatrix2x2ForEffect = function (e, t) { this._currentEffect.setMatrix2x2(e, t) }, e.prototype._updateMatrix2x2ForUniform = function (t, i) { for (var r = 0; r < 2; r++)e._TempBuffer[4 * r] = i[2 * r], e._TempBuffer[4 * r + 1] = i[2 * r + 1], e._TempBuffer[4 * r + 2] = 0, e._TempBuffer[4 * r + 3] = 0; this.updateUniform(t, e._TempBuffer, 8) }, e.prototype._updateFloatForEffect = function (e, t) { this._currentEffect.setFloat(e, t) }, e.prototype._updateFloatForUniform = function (t, i) { e._TempBuffer[0] = i, this.updateUniform(t, e._TempBuffer, 1) }, e.prototype._updateFloat2ForEffect = function (e, t, i, r) { void 0 === r && (r = ""), this._currentEffect.setFloat2(e + r, t, i) }, e.prototype._updateFloat2ForUniform = function (t, i, r) { e._TempBuffer[0] = i, e._TempBuffer[1] = r, this.updateUniform(t, e._TempBuffer, 2) }, e.prototype._updateFloat3ForEffect = function (e, t, i, r, n) { void 0 === n && (n = ""), this._currentEffect.setFloat3(e + n, t, i, r) }, e.prototype._updateFloat3ForUniform = function (t, i, r, n) { e._TempBuffer[0] = i, e._TempBuffer[1] = r, e._TempBuffer[2] = n, this.updateUniform(t, e._TempBuffer, 3) }, e.prototype._updateFloat4ForEffect = function (e, t, i, r, n, o) { void 0 === o && (o = ""), this._currentEffect.setFloat4(e + o, t, i, r, n) }, e.prototype._updateFloat4ForUniform = function (t, i, r, n, o) { e._TempBuffer[0] = i, e._TempBuffer[1] = r, e._TempBuffer[2] = n, e._TempBuffer[3] = o, this.updateUniform(t, e._TempBuffer, 4) }, e.prototype._updateFloatArrayForEffect = function (e, t) { this._currentEffect.setFloatArray(e, t) }, e.prototype._updateFloatArrayForUniform = function (e, t) { this.updateUniformArray(e, t, t.length) }, e.prototype._updateArrayForEffect = function (e, t) { this._currentEffect.setArray(e, t) }, e.prototype._updateArrayForUniform = function (e, t) { this.updateUniformArray(e, t, t.length) }, e.prototype._updateIntArrayForEffect = function (e, t) { this._currentEffect.setIntArray(e, t) }, e.prototype._updateIntArrayForUniform = function (t, i) { e._TempBufferInt32View.set(i), this.updateUniformArray(t, e._TempBuffer, i.length) }, e.prototype._updateUIntArrayForEffect = function (e, t) { this._currentEffect.setUIntArray(e, t) }, e.prototype._updateUIntArrayForUniform = function (t, i) { e._TempBufferUInt32View.set(i), this.updateUniformArray(t, e._TempBuffer, i.length) }, e.prototype._updateMatrixForEffect = function (e, t) { this._currentEffect.setMatrix(e, t) }, e.prototype._updateMatrixForUniform = function (e, t) { this._cacheMatrix(e, t) && this.updateUniform(e, t.toArray(), 16) }, e.prototype._updateMatricesForEffect = function (e, t) { this._currentEffect.setMatrices(e, t) }, e.prototype._updateMatricesForUniform = function (e, t) { this.updateUniform(e, t, t.length) }, e.prototype._updateVector3ForEffect = function (e, t) { this._currentEffect.setVector3(e, t) }, e.prototype._updateVector3ForUniform = function (t, i) { e._TempBuffer[0] = i.x, e._TempBuffer[1] = i.y, e._TempBuffer[2] = i.z, this.updateUniform(t, e._TempBuffer, 3) }, e.prototype._updateVector4ForEffect = function (e, t) { this._currentEffect.setVector4(e, t) }, e.prototype._updateVector4ForUniform = function (t, i) { e._TempBuffer[0] = i.x, e._TempBuffer[1] = i.y, e._TempBuffer[2] = i.z, e._TempBuffer[3] = i.w, this.updateUniform(t, e._TempBuffer, 4) }, e.prototype._updateColor3ForEffect = function (e, t, i) { void 0 === i && (i = ""), this._currentEffect.setColor3(e + i, t) }, e.prototype._updateColor3ForUniform = function (t, i) { e._TempBuffer[0] = i.r, e._TempBuffer[1] = i.g, e._TempBuffer[2] = i.b, this.updateUniform(t, e._TempBuffer, 3) }, e.prototype._updateColor4ForEffect = function (e, t, i, r) { void 0 === r && (r = ""), this._currentEffect.setColor4(e + r, t, i) }, e.prototype._updateDirectColor4ForEffect = function (e, t, i) { void 0 === i && (i = ""), this._currentEffect.setDirectColor4(e + i, t) }, e.prototype._updateColor4ForUniform = function (t, i, r) { e._TempBuffer[0] = i.r, e._TempBuffer[1] = i.g, e._TempBuffer[2] = i.b, e._TempBuffer[3] = r, this.updateUniform(t, e._TempBuffer, 4) }, e.prototype._updateDirectColor4ForUniform = function (t, i) { e._TempBuffer[0] = i.r, e._TempBuffer[1] = i.g, e._TempBuffer[2] = i.b, e._TempBuffer[3] = i.a, this.updateUniform(t, e._TempBuffer, 4) }, e.prototype._updateIntForEffect = function (e, t, i) { void 0 === i && (i = ""), this._currentEffect.setInt(e + i, t) }, e.prototype._updateIntForUniform = function (t, i) { e._TempBufferInt32View[0] = i, this.updateUniform(t, e._TempBuffer, 1) }, e.prototype._updateInt2ForEffect = function (e, t, i, r) { void 0 === r && (r = ""), this._currentEffect.setInt2(e + r, t, i) }, e.prototype._updateInt2ForUniform = function (t, i, r) { e._TempBufferInt32View[0] = i, e._TempBufferInt32View[1] = r, this.updateUniform(t, e._TempBuffer, 2) }, e.prototype._updateInt3ForEffect = function (e, t, i, r, n) { void 0 === n && (n = ""), this._currentEffect.setInt3(e + n, t, i, r) }, e.prototype._updateInt3ForUniform = function (t, i, r, n) { e._TempBufferInt32View[0] = i, e._TempBufferInt32View[1] = r, e._TempBufferInt32View[2] = n, this.updateUniform(t, e._TempBuffer, 3) }, e.prototype._updateInt4ForEffect = function (e, t, i, r, n, o) { void 0 === o && (o = ""), this._currentEffect.setInt4(e + o, t, i, r, n) }, e.prototype._updateInt4ForUniform = function (t, i, r, n, o) { e._TempBufferInt32View[0] = i, e._TempBufferInt32View[1] = r, e._TempBufferInt32View[2] = n, e._TempBufferInt32View[3] = o, this.updateUniform(t, e._TempBuffer, 4) }, e.prototype._updateUIntForEffect = function (e, t, i) { void 0 === i && (i = ""), this._currentEffect.setUInt(e + i, t) }, e.prototype._updateUIntForUniform = function (t, i) { e._TempBufferUInt32View[0] = i, this.updateUniform(t, e._TempBuffer, 1) }, e.prototype._updateUInt2ForEffect = function (e, t, i, r) { void 0 === r && (r = ""), this._currentEffect.setUInt2(e + r, t, i) }, e.prototype._updateUInt2ForUniform = function (t, i, r) { e._TempBufferUInt32View[0] = i, e._TempBufferUInt32View[1] = r, this.updateUniform(t, e._TempBuffer, 2) }, e.prototype._updateUInt3ForEffect = function (e, t, i, r, n) { void 0 === n && (n = ""), this._currentEffect.setUInt3(e + n, t, i, r) }, e.prototype._updateUInt3ForUniform = function (t, i, r, n) { e._TempBufferUInt32View[0] = i, e._TempBufferUInt32View[1] = r, e._TempBufferUInt32View[2] = n, this.updateUniform(t, e._TempBuffer, 3) }, e.prototype._updateUInt4ForEffect = function (e, t, i, r, n, o) { void 0 === o && (o = ""), this._currentEffect.setUInt4(e + o, t, i, r, n) }, e.prototype._updateUInt4ForUniform = function (t, i, r, n, o) { e._TempBufferUInt32View[0] = i, e._TempBufferUInt32View[1] = r, e._TempBufferUInt32View[2] = n, e._TempBufferUInt32View[3] = o, this.updateUniform(t, e._TempBuffer, 4) }, e.prototype.setTexture = function (e, t) { this._currentEffect.setTexture(e, t) }, e.prototype.updateUniformDirectly = function (e, t) { this.updateUniform(e, t, t.length), this.update() }, e.prototype.bindToEffect = function (e, t) { this._currentEffect = e, this._currentEffectName = t }, e.prototype.bindUniformBuffer = function () { !this._noUBO && this._buffer && this._currentEffect && this._currentEffect.bindUniformBuffer(this._buffer, this._currentEffectName) }, e.prototype.unbindEffect = function () { this._currentEffect = void 0, this._currentEffectName = void 0 }, e.prototype.setDataBuffer = function (e) { if (!this._buffers) return this._buffer === e; for (var t = 0; t < this._buffers.length; ++t)if (this._buffers[t][0] === e) return this._bufferIndex = t, this._buffer = e, this._createBufferOnWrite = !1, this._currentEffect = void 0, !0; return !1 }, e.prototype.dispose = function () { if (!this._noUBO) { var e = this._engine._uniformBuffers, t = e.indexOf(this); if (-1 !== t && (e[t] = e[e.length - 1], e.pop()), this._engine._features.trackUbosInFrame && this._buffers) for (var i = 0; i < this._buffers.length; ++i) { var r = this._buffers[i][0]; this._engine._releaseBuffer(r) } else this._buffer && this._engine._releaseBuffer(this._buffer) && (this._buffer = null) } }, e._UpdatedUbosInFrame = {}, e._MAX_UNIFORM_SIZE = 256, e._TempBuffer = new Float32Array(e._MAX_UNIFORM_SIZE), e._TempBufferInt32View = new Int32Array(e._TempBuffer.buffer), e._TempBufferUInt32View = new Uint32Array(e._TempBuffer.buffer), e }(), Wi = function () { function e(e, t, i, r, n, o, a, s) { void 0 === r && (r = 0), void 0 === n && (n = !1), void 0 === o && (o = !1), void 0 === a && (a = !1), this._isAlreadyOwned = !1, e.getScene ? this._engine = e.getScene().getEngine() : this._engine = e, this._updatable = i, this._instanced = o, this._divisor = s || 1, t instanceof Kt ? (this._data = null, this._buffer = t) : (this._data = t, this._buffer = null), this.byteStride = a ? r : r * Float32Array.BYTES_PER_ELEMENT, n || this.create() } return e.prototype.createVertexBuffer = function (e, t, i, r, n, o, a) { void 0 === o && (o = !1); var s = o ? t : t * Float32Array.BYTES_PER_ELEMENT, l = r ? o ? r : r * Float32Array.BYTES_PER_ELEMENT : this.byteStride; return new Hi(this._engine, this, e, this._updatable, !0, l, void 0 === n ? this._instanced : n, s, i, void 0, void 0, !0, this._divisor || a) }, e.prototype.isUpdatable = function () { return this._updatable }, e.prototype.getData = function () { return this._data }, e.prototype.getBuffer = function () { return this._buffer }, e.prototype.getStrideSize = function () { return this.byteStride / Float32Array.BYTES_PER_ELEMENT }, e.prototype.create = function (e) { void 0 === e && (e = null), !e && this._buffer || (e = e || this._data) && (this._buffer ? this._updatable && (this._engine.updateDynamicVertexBuffer(this._buffer, e), this._data = e) : this._updatable ? (this._buffer = this._engine.createDynamicVertexBuffer(e), this._data = e) : this._buffer = this._engine.createVertexBuffer(e)) }, e.prototype._rebuild = function () { this._buffer = null, this.create(this._data) }, e.prototype.update = function (e) { this.create(e) }, e.prototype.updateDirectly = function (e, t, i, r) { void 0 === r && (r = !1), this._buffer && this._updatable && (this._engine.updateDynamicVertexBuffer(this._buffer, e, r ? t : t * Float32Array.BYTES_PER_ELEMENT, i ? i * this.byteStride : void 0), this._data = 0 === t && void 0 === i ? e : null) }, e.prototype._increaseReferences = function () { this._buffer && (this._isAlreadyOwned ? this._buffer.references++ : this._isAlreadyOwned = !0) }, e.prototype.dispose = function () { this._buffer && this._engine._releaseBuffer(this._buffer) && (this._buffer = null, this._data = null) }, e }(), Hi = function () { function e(t, i, r, n, o, a, s, l, c, u, h, d, p, f) { if (void 0 === h && (h = !1), void 0 === d && (d = !1), void 0 === p && (p = 1), void 0 === f && (f = !1), i instanceof Wi ? (this._buffer = i, this._ownsBuffer = f) : (this._buffer = new Wi(t, i, n, a, o, s, d), this._ownsBuffer = !0), this.uniqueId = e._Counter++, this._kind = r, null == u) { var _ = this.getData(); this.type = e.FLOAT, _ instanceof Int8Array ? this.type = e.BYTE : _ instanceof Uint8Array ? this.type = e.UNSIGNED_BYTE : _ instanceof Int16Array ? this.type = e.SHORT : _ instanceof Uint16Array ? this.type = e.UNSIGNED_SHORT : _ instanceof Int32Array ? this.type = e.INT : _ instanceof Uint32Array && (this.type = e.UNSIGNED_INT) } else this.type = u; var m = e.GetTypeByteLength(this.type); d ? (this._size = c || (a ? a / m : e.DeduceStride(r)), this.byteStride = a || this._buffer.byteStride || this._size * m, this.byteOffset = l || 0) : (this._size = c || a || e.DeduceStride(r), this.byteStride = a ? a * m : this._buffer.byteStride || this._size * m, this.byteOffset = (l || 0) * m), this.normalized = h, this._instanced = void 0 !== s && s, this._instanceDivisor = s ? p : 0, this._computeHashCode() } return Object.defineProperty(e.prototype, "instanceDivisor", { get: function () { return this._instanceDivisor }, set: function (e) { var t = 0 != e; this._instanceDivisor = e, t !== this._instanced && (this._instanced = t, this._computeHashCode()) }, enumerable: !1, configurable: !0 }), e.prototype._computeHashCode = function () { this.hashCode = (this.type - 5120 << 0) + ((this.normalized ? 1 : 0) << 3) + (this._size << 4) + ((this._instanced ? 1 : 0) << 6) + (this.byteStride << 12) }, e.prototype._rebuild = function () { this._buffer && this._buffer._rebuild() }, e.prototype.getKind = function () { return this._kind }, e.prototype.isUpdatable = function () { return this._buffer.isUpdatable() }, e.prototype.getData = function () { return this._buffer.getData() }, e.prototype.getFloatData = function (t, i) { var r = this.getData(); if (!r) return null; var n = this.getSize() * e.GetTypeByteLength(this.type), o = t * this.getSize(); if (this.type !== e.FLOAT || this.byteStride !== n) { var a = new Float32Array(o); return this.forEach(o, (function (e, t) { return a[t] = e })), a } if (!(r instanceof Array || r instanceof Float32Array) || 0 !== this.byteOffset || r.length !== o) { if (r instanceof Array) { var s = this.byteOffset / 4; return r.slice(s, s + o) } if (r instanceof ArrayBuffer) return new Float32Array(r, this.byteOffset, o); if (s = r.byteOffset + this.byteOffset, i) { var l = new Float32Array(o), c = new Float32Array(r.buffer, s, o); return l.set(c), l } var u = s % 4; return u && (s = Math.max(0, s - u)), new Float32Array(r.buffer, s, o) } return i ? r.slice() : r }, e.prototype.getBuffer = function () { return this._buffer.getBuffer() }, e.prototype.getStrideSize = function () { return this.byteStride / e.GetTypeByteLength(this.type) }, e.prototype.getOffset = function () { return this.byteOffset / e.GetTypeByteLength(this.type) }, e.prototype.getSize = function (t) { return void 0 === t && (t = !1), t ? this._size * e.GetTypeByteLength(this.type) : this._size }, e.prototype.getIsInstanced = function () { return this._instanced }, e.prototype.getInstanceDivisor = function () { return this._instanceDivisor }, e.prototype.create = function (e) { this._buffer.create(e) }, e.prototype.update = function (e) { this._buffer.update(e) }, e.prototype.updateDirectly = function (e, t, i) { void 0 === i && (i = !1), this._buffer.updateDirectly(e, t, void 0, i) }, e.prototype.dispose = function () { this._ownsBuffer && this._buffer.dispose() }, e.prototype.forEach = function (t, i) { e.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, t, this.normalized, i) }, e.DeduceStride = function (t) { switch (t) { case e.UVKind: case e.UV2Kind: case e.UV3Kind: case e.UV4Kind: case e.UV5Kind: case e.UV6Kind: return 2; case e.NormalKind: case e.PositionKind: return 3; case e.ColorKind: case e.MatricesIndicesKind: case e.MatricesIndicesExtraKind: case e.MatricesWeightsKind: case e.MatricesWeightsExtraKind: case e.TangentKind: return 4; default: throw new Error("Invalid kind '" + t + "'") } }, e.GetTypeByteLength = function (t) { switch (t) { case e.BYTE: case e.UNSIGNED_BYTE: return 1; case e.SHORT: case e.UNSIGNED_SHORT: return 2; case e.INT: case e.UNSIGNED_INT: case e.FLOAT: return 4; default: throw new Error("Invalid type '".concat(t, "'")) } }, e.ForEach = function (t, i, r, n, o, a, s, l) { if (t instanceof Array) for (var c = i / 4, u = r / 4, h = 0; h < a; h += n) { for (var d = 0; d < n; d++)l(t[c + d], h + d); c += u } else { var p = t instanceof ArrayBuffer ? new DataView(t) : new DataView(t.buffer, t.byteOffset, t.byteLength), f = e.GetTypeByteLength(o); for (h = 0; h < a; h += n) { var _ = i; for (d = 0; d < n; d++)l(e._GetFloatValue(p, o, _, s), h + d), _ += f; i += r } } }, e._GetFloatValue = function (t, i, r, n) { switch (i) { case e.BYTE: var o = t.getInt8(r); return n && (o = Math.max(o / 127, -1)), o; case e.UNSIGNED_BYTE: return o = t.getUint8(r), n && (o /= 255), o; case e.SHORT: return o = t.getInt16(r, !0), n && (o = Math.max(o / 32767, -1)), o; case e.UNSIGNED_SHORT: return o = t.getUint16(r, !0), n && (o /= 65535), o; case e.INT: return t.getInt32(r, !0); case e.UNSIGNED_INT: return t.getUint32(r, !0); case e.FLOAT: return t.getFloat32(r, !0); default: throw new Error("Invalid component type ".concat(i)) } }, e._Counter = 0, e.BYTE = 5120, e.UNSIGNED_BYTE = 5121, e.SHORT = 5122, e.UNSIGNED_SHORT = 5123, e.INT = 5124, e.UNSIGNED_INT = 5125, e.FLOAT = 5126, e.PositionKind = "position", e.NormalKind = "normal", e.TangentKind = "tangent", e.UVKind = "uv", e.UV2Kind = "uv2", e.UV3Kind = "uv3", e.UV4Kind = "uv4", e.UV5Kind = "uv5", e.UV6Kind = "uv6", e.ColorKind = "color", e.ColorInstanceKind = "instanceColor", e.MatricesIndicesKind = "matricesIndices", e.MatricesWeightsKind = "matricesWeights", e.MatricesIndicesExtraKind = "matricesIndicesExtra", e.MatricesWeightsExtraKind = "matricesWeightsExtra", e }(), Xi = function () { function e() { this.hit = !1, this.distance = 0, this.pickedPoint = null, this.pickedMesh = null, this.bu = 0, this.bv = 0, this.faceId = -1, this.subMeshFaceId = -1, this.subMeshId = 0, this.pickedSprite = null, this.thinInstanceIndex = -1, this.ray = null, this.originMesh = null, this.aimTransform = null, this.gripTransform = null } return e.prototype.getNormal = function (e, t) { if (void 0 === e && (e = !1), void 0 === t && (t = !0), !this.pickedMesh || t && !this.pickedMesh.isVerticesDataPresent(Hi.NormalKind)) return null; var i, r = this.pickedMesh.getIndices(); 0 === (null == r ? void 0 : r.length) && (r = null); var n = O.Vector3[0], o = O.Vector3[1], a = O.Vector3[2]; if (t) { var s = this.pickedMesh.getVerticesData(Hi.NormalKind), l = r ? R.FromArrayToRef(s, 3 * r[3 * this.faceId], n) : n.copyFromFloats(s[3 * this.faceId * 3], s[3 * this.faceId * 3 + 1], s[3 * this.faceId * 3 + 2]), c = r ? R.FromArrayToRef(s, 3 * r[3 * this.faceId + 1], o) : o.copyFromFloats(s[3 * (3 * this.faceId + 1)], s[3 * (3 * this.faceId + 1) + 1], s[3 * (3 * this.faceId + 1) + 2]), u = r ? R.FromArrayToRef(s, 3 * r[3 * this.faceId + 2], a) : a.copyFromFloats(s[3 * (3 * this.faceId + 2)], s[3 * (3 * this.faceId + 2) + 1], s[3 * (3 * this.faceId + 2) + 2]); l = l.scale(this.bu), c = c.scale(this.bv), u = u.scale(1 - this.bu - this.bv), i = new R(l.x + c.x + u.x, l.y + c.y + u.y, l.z + c.z + u.z) } else { var h = this.pickedMesh.getVerticesData(Hi.PositionKind), d = r ? R.FromArrayToRef(h, 3 * r[3 * this.faceId], n) : n.copyFromFloats(h[3 * this.faceId * 3], h[3 * this.faceId * 3 + 1], h[3 * this.faceId * 3 + 2]), p = r ? R.FromArrayToRef(h, 3 * r[3 * this.faceId + 1], o) : o.copyFromFloats(h[3 * (3 * this.faceId + 1)], h[3 * (3 * this.faceId + 1) + 1], h[3 * (3 * this.faceId + 1) + 2]), f = r ? R.FromArrayToRef(h, 3 * r[3 * this.faceId + 2], a) : a.copyFromFloats(h[3 * (3 * this.faceId + 2)], h[3 * (3 * this.faceId + 2) + 1], h[3 * (3 * this.faceId + 2) + 2]), _ = d.subtract(p), m = f.subtract(p); i = R.Cross(_, m) } var g = function (e, t) { var i = e.getWorldMatrix(); e.nonUniformScaling && (O.Matrix[0].copyFrom(i), (i = O.Matrix[0]).setTranslationFromFloats(0, 0, 0), i.invert(), i.transposeToRef(O.Matrix[1]), i = O.Matrix[1]), R.TransformNormalToRef(t, i, t) }; if (e && g(this.pickedMesh, i), this.ray) { var v = O.Vector3[0].copyFrom(i); e || g(this.pickedMesh, v), R.Dot(v, this.ray.direction) > 0 && i.negateInPlace() } return i.normalize(), i }, e.prototype.getTextureCoordinates = function (e) { if (void 0 === e && (e = Hi.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 }(), ji = function () { function e(e) { this._vertexBuffers = {}, this._scene = e } return e.prototype._prepareBuffers = function () { if (!this._vertexBuffers[Hi.PositionKind]) { var e = []; e.push(1, 1), e.push(-1, 1), e.push(-1, -1), e.push(1, -1), this._vertexBuffers[Hi.PositionKind] = new Hi(this._scene.getEngine(), e, Hi.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[Hi.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; c < e.length; c++) { c < e.length - 1 ? e[c + 1].activate(this._scene.activeCamera, null == t ? void 0 : t.texture) : (t ? l.bindFramebuffer(t, r, void 0, void 0, i, n) : o || l.restoreDefaultFramebuffer(), null === (s = l._debugInsertMarker) || void 0 === s || s.call(l, "post process ".concat(e[c].name, " output"))); var u = e[c], h = u.apply(); h && (u.onBeforeRenderObservable.notifyObservers(h), this._prepareBuffers(), l.bindBuffers(this._vertexBuffers, this._indexBuffer, h), l.drawElementsType(a.MATERIAL_TriangleFillMode, 0, 6), u.onAfterRenderObservable.notifyObservers(h)) } l.setDepthBuffer(!0), l.setDepthWrite(!0) }, e.prototype._finalizeFrame = function (e, t, i, r, n) { var o; void 0 === n && (n = !1); var s = this._scene.activeCamera; if (s && (r = r || s._postProcesses.filter((function (e) { return null != e })), 0 !== r.length && this._scene.postProcessesEnabled)) { for (var l = this._scene.getEngine(), c = 0, u = r.length; c < u; c++) { var h = r[c]; if (c < u - 1 ? h._outputTexture = r[c + 1].activate(s, null == t ? void 0 : t.texture) : (t ? (l.bindFramebuffer(t, i, void 0, void 0, n), h._outputTexture = t) : (l.restoreDefaultFramebuffer(), h._outputTexture = null), null === (o = l._debugInsertMarker) || void 0 === o || o.call(l, "post process ".concat(r[c].name, " output"))), e) break; var d = h.apply(); d && (h.onBeforeRenderObservable.notifyObservers(d), this._prepareBuffers(), l.bindBuffers(this._vertexBuffers, this._indexBuffer, d), l.drawElementsType(a.MATERIAL_TriangleFillMode, 0, 6), h.onAfterRenderObservable.notifyObservers(d)) } l.setDepthBuffer(!0), l.setDepthWrite(!0), l.setAlphaMode(a.ALPHA_DISABLE) } }, e.prototype.dispose = function () { var e = this._vertexBuffers[Hi.PositionKind]; e && (e.dispose(), this._vertexBuffers[Hi.PositionKind] = null), this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer), this._indexBuffer = null) }, e }(), Yi = function () { function e(e, t, i, r, n) { void 0 === i && (i = null), void 0 === r && (r = null), void 0 === n && (n = null), this.index = e, this._opaqueSubMeshes = new Ci(256), this._transparentSubMeshes = new Ci(256), this._alphaTestSubMeshes = new Ci(256), this._depthOnlySubMeshes = new Ci(256), this._particleSystems = new Ci(256), this._spriteManagers = new Ci(256), this._empty = !0, this._edgesRenderers = new Pi(16), this._scene = t, this.opaqueSortCompareFn = i, this.alphaTestSortCompareFn = r, this.transparentSortCompareFn = n } return Object.defineProperty(e.prototype, "opaqueSortCompareFn", { set: function (t) { this._opaqueSortCompareFn = t || e.PainterSortCompare, this._renderOpaque = this._renderOpaqueSorted }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "alphaTestSortCompareFn", { set: function (t) { this._alphaTestSortCompareFn = t || e.PainterSortCompare, this._renderAlphaTest = this._renderAlphaTestSorted }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "transparentSortCompareFn", { set: function (t) { this._transparentSortCompareFn = t || e.defaultTransparentSortCompare, this._renderTransparent = this._renderTransparentSorted }, enumerable: !1, configurable: !0 }), e.prototype.render = function (e, t, i, r) { if (e) e(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes); else { var n = this._scene.getEngine(); 0 !== this._depthOnlySubMeshes.length && (n.setColorWrite(!1), this._renderAlphaTest(this._depthOnlySubMeshes), n.setColorWrite(!0)), 0 !== this._opaqueSubMeshes.length && this._renderOpaque(this._opaqueSubMeshes), 0 !== this._alphaTestSubMeshes.length && this._renderAlphaTest(this._alphaTestSubMeshes); var o = n.getStencilBuffer(); if (n.setStencilBuffer(!1), t && this._renderSprites(), i && this._renderParticles(r), this.onBeforeTransparentRendering && this.onBeforeTransparentRendering(), 0 !== this._transparentSubMeshes.length || this._scene.useOrderIndependentTransparency) { if (n.setStencilBuffer(o), this._scene.useOrderIndependentTransparency) { var s = this._scene.depthPeelingRenderer.render(this._transparentSubMeshes); s.length && this._renderTransparent(s) } else this._renderTransparent(this._transparentSubMeshes); n.setAlphaMode(a.ALPHA_DISABLE) } if (n.setStencilBuffer(!1), this._edgesRenderers.length) { for (var l = 0; l < this._edgesRenderers.length; l++)this._edgesRenderers.data[l].render(); n.setAlphaMode(a.ALPHA_DISABLE) } n.setStencilBuffer(o) } }, e.prototype._renderOpaqueSorted = function (t) { return e._RenderSorted(t, this._opaqueSortCompareFn, this._scene.activeCamera, !1) }, e.prototype._renderAlphaTestSorted = function (t) { return e._RenderSorted(t, this._alphaTestSortCompareFn, this._scene.activeCamera, !1) }, e.prototype._renderTransparentSorted = function (t) { return e._RenderSorted(t, this._transparentSortCompareFn, this._scene.activeCamera, !0) }, e._RenderSorted = function (t, i, r, n) { var o, s = 0, l = r ? r.globalPosition : e._ZeroVector; if (n) for (; s < t.length; s++)(o = t.data[s])._alphaIndex = o.getMesh().alphaIndex, o._distanceToCamera = R.Distance(o.getBoundingInfo().boundingSphere.centerWorld, l); var c = t.length === t.data.length ? t.data : t.data.slice(0, t.length); i && c.sort(i); var u = c[0].getMesh().getScene(); for (s = 0; s < c.length; s++)if (o = c[s], !u._activeMeshesFrozenButKeepClipping || o.isInFrustum(u._frustumPlanes)) { if (n) { var h = o.getMaterial(); if (h && h.needDepthPrePass) { var d = h.getScene().getEngine(); d.setColorWrite(!1), d.setAlphaMode(a.ALPHA_DISABLE), o.render(!1), d.setColorWrite(!0) } } o.render(n) } }, e.defaultTransparentSortCompare = function (t, i) { return t._alphaIndex > i._alphaIndex ? 1 : t._alphaIndex < i._alphaIndex ? -1 : e.backToFrontSortCompare(t, i) }, e.backToFrontSortCompare = function (e, t) { return e._distanceToCamera < t._distanceToCamera ? 1 : e._distanceToCamera > t._distanceToCamera ? -1 : 0 }, e.frontToBackSortCompare = function (e, t) { return e._distanceToCamera < t._distanceToCamera ? -1 : e._distanceToCamera > t._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 < this._particleSystems.length; i++) { var r = this._particleSystems.data[i]; if (0 !== (t && t.layerMask & r.layerMask)) { var n = r.emitter; n.position && e && -1 === e.indexOf(n) || this._scene._activeParticles.addCount(r.render(), !1) } } this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene) } }, e.prototype._renderSprites = function () { if (this._scene.spritesEnabled && 0 !== this._spriteManagers.length) { var e = this._scene.activeCamera; this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene); for (var t = 0; t < this._spriteManagers.length; t++) { var i = this._spriteManagers.data[t]; 0 !== (e && e.layerMask & i.layerMask) && i.render() } this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene) } }, e._ZeroVector = R.Zero(), e }(), Ki = function () { }, Qi = function () { function e(t) { this._useSceneAutoClearSetup = !1, this._renderingGroups = new Array, this._autoClearDepthStencil = {}, this._customOpaqueSortCompareFn = {}, this._customAlphaTestSortCompareFn = {}, this._customTransparentSortCompareFn = {}, this._renderingGroupInfo = new Ki, this._maintainStateBetweenFrames = !1, this._scene = t; for (var i = e.MIN_RENDERINGGROUPS; i < e.MAX_RENDERINGGROUPS; i++)this._autoClearDepthStencil[i] = { autoClear: !0, depth: !0, stencil: !0 } } return Object.defineProperty(e.prototype, "maintainStateBetweenFrames", { get: function () { return this._maintainStateBetweenFrames }, set: function (e) { if (e !== this._maintainStateBetweenFrames && (this._maintainStateBetweenFrames = e, !this._maintainStateBetweenFrames)) { for (var t = 0, i = this._scene.meshes; t < i.length; t++) { var r = i[t]; if (r.subMeshes) for (var n = 0, o = r.subMeshes; n < o.length; n++)o[n]._wasDispatched = !1 } if (this._scene.spriteManagers) for (var a = 0, s = this._scene.spriteManagers; a < s.length; a++)s[a]._wasDispatched = !1; for (var l = 0, c = this._scene.particleSystems; l < c.length; l++)c[l]._wasDispatched = !1 } }, enumerable: !1, configurable: !0 }), e.prototype.getRenderingGroup = function (e) { var t = e || 0; return this._prepareRenderingGroup(t), this._renderingGroups[t] }, e.prototype._clearDepthStencilBuffer = function (e, t) { void 0 === e && (e = !0), void 0 === t && (t = !0), this._depthStencilBufferAlreadyCleaned || (this._scene.getEngine().clear(null, !1, e, t), this._depthStencilBufferAlreadyCleaned = !0) }, e.prototype.render = function (t, i, r, n) { var o = this._renderingGroupInfo; if (o.scene = this._scene, o.camera = this._scene.activeCamera, this._scene.spriteManagers && n) for (var a = 0; a < this._scene.spriteManagers.length; a++) { var s = this._scene.spriteManagers[a]; this.dispatchSprites(s) } for (a = e.MIN_RENDERINGGROUPS; a < e.MAX_RENDERINGGROUPS; a++) { this._depthStencilBufferAlreadyCleaned = a === e.MIN_RENDERINGGROUPS; var l = this._renderingGroups[a]; if (l && !l._empty) { var c = Math.pow(2, a); if (o.renderingGroupId = a, this._scene.onBeforeRenderingGroupObservable.notifyObservers(o, c), e.AUTOCLEAR) { var u = this._useSceneAutoClearSetup ? this._scene.getAutoClearDepthStencilSetup(a) : this._autoClearDepthStencil[a]; u && u.autoClear && this._clearDepthStencilBuffer(u.depth, u.stencil) } for (var h = 0, d = this._scene._beforeRenderingGroupDrawStage; h < d.length; h++)d[h].action(a); l.render(t, n, r, i); for (var p = 0, f = this._scene._afterRenderingGroupDrawStage; p < f.length; p++)f[p].action(a); this._scene.onAfterRenderingGroupObservable.notifyObservers(o, c) } } }, e.prototype.reset = function () { if (!this.maintainStateBetweenFrames) for (var t = e.MIN_RENDERINGGROUPS; t < e.MAX_RENDERINGGROUPS; t++) { var i = this._renderingGroups[t]; i && i.prepare() } }, e.prototype.resetSprites = function () { if (!this.maintainStateBetweenFrames) for (var t = e.MIN_RENDERINGGROUPS; t < e.MAX_RENDERINGGROUPS; t++) { var i = this._renderingGroups[t]; i && i.prepareSprites() } }, e.prototype.dispose = function () { this.freeRenderingGroups(), this._renderingGroups.length = 0, this._renderingGroupInfo = null }, e.prototype.freeRenderingGroups = function () { for (var t = e.MIN_RENDERINGGROUPS; t < e.MAX_RENDERINGGROUPS; t++) { var i = this._renderingGroups[t]; i && i.dispose() } }, e.prototype._prepareRenderingGroup = function (e) { void 0 === this._renderingGroups[e] && (this._renderingGroups[e] = new Yi(e, this._scene, this._customOpaqueSortCompareFn[e], this._customAlphaTestSortCompareFn[e], this._customTransparentSortCompareFn[e])) }, e.prototype.dispatchSprites = function (e) { this.maintainStateBetweenFrames && e._wasDispatched || (e._wasDispatched = !0, this.getRenderingGroup(e.renderingGroupId).dispatchSprites(e)) }, e.prototype.dispatchParticles = function (e) { this.maintainStateBetweenFrames && e._wasDispatched || (e._wasDispatched = !0, this.getRenderingGroup(e.renderingGroupId).dispatchParticles(e)) }, e.prototype.dispatch = function (e, t, i) { void 0 === t && (t = e.getMesh()), this.maintainStateBetweenFrames && e._wasDispatched || (e._wasDispatched = !0, this.getRenderingGroup(t.renderingGroupId).dispatch(e, t, i)) }, e.prototype.setRenderingOrder = function (e, t, i, r) { if (void 0 === t && (t = null), void 0 === i && (i = null), void 0 === r && (r = null), this._customOpaqueSortCompareFn[e] = t, this._customAlphaTestSortCompareFn[e] = i, this._customTransparentSortCompareFn[e] = r, this._renderingGroups[e]) { var n = this._renderingGroups[e]; n.opaqueSortCompareFn = this._customOpaqueSortCompareFn[e], n.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[e], n.transparentSortCompareFn = this._customTransparentSortCompareFn[e] } }, e.prototype.setRenderingAutoClearDepthStencil = function (e, t, i, r) { void 0 === i && (i = !0), void 0 === r && (r = !0), this._autoClearDepthStencil[e] = { autoClear: t, depth: i, stencil: r } }, e.prototype.getAutoClearDepthStencilSetup = function (e) { return this._autoClearDepthStencil[e] }, e.MAX_RENDERINGGROUPS = 4, e.MIN_RENDERINGGROUPS = 0, e.AUTOCLEAR = !0, e }(), qi = function () { function e() { } return e.NAME_EFFECTLAYER = "EffectLayer", e.NAME_LAYER = "Layer", e.NAME_LENSFLARESYSTEM = "LensFlareSystem", e.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer", e.NAME_PARTICLESYSTEM = "ParticleSystem", e.NAME_GAMEPAD = "Gamepad", e.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue", e.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer", e.NAME_PREPASSRENDERER = "PrePassRenderer", e.NAME_DEPTHRENDERER = "DepthRenderer", e.NAME_DEPTHPEELINGRENDERER = "DepthPeelingRenderer", e.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager", e.NAME_SPRITE = "Sprite", e.NAME_SUBSURFACE = "SubSurface", e.NAME_OUTLINERENDERER = "Outline", e.NAME_PROCEDURALTEXTURE = "ProceduralTexture", e.NAME_SHADOWGENERATOR = "ShadowGenerator", e.NAME_OCTREE = "Octree", e.NAME_PHYSICSENGINE = "PhysicsEngine", e.NAME_AUDIO = "Audio", e.NAME_FLUIDRENDERER = "FluidRenderer", e.STEP_ISREADYFORMESH_EFFECTLAYER = 0, e.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0, e.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0, e.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER = 0, e.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1, e.STEP_BEFORECAMERADRAW_PREPASS = 0, e.STEP_BEFORECAMERADRAW_EFFECTLAYER = 1, e.STEP_BEFORECAMERADRAW_LAYER = 2, e.STEP_BEFORERENDERTARGETDRAW_PREPASS = 0, e.STEP_BEFORERENDERTARGETDRAW_LAYER = 1, e.STEP_BEFORERENDERINGMESH_PREPASS = 0, e.STEP_BEFORERENDERINGMESH_OUTLINE = 1, e.STEP_AFTERRENDERINGMESH_PREPASS = 0, e.STEP_AFTERRENDERINGMESH_OUTLINE = 1, e.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0, e.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1, e.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0, e.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1, e.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0, e.STEP_BEFORECLEAR_PREPASS = 1, e.STEP_BEFORERENDERTARGETCLEAR_PREPASS = 0, e.STEP_AFTERRENDERTARGETDRAW_PREPASS = 0, e.STEP_AFTERRENDERTARGETDRAW_LAYER = 1, e.STEP_AFTERCAMERADRAW_PREPASS = 0, e.STEP_AFTERCAMERADRAW_EFFECTLAYER = 1, e.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 2, e.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 3, e.STEP_AFTERCAMERADRAW_LAYER = 4, e.STEP_AFTERCAMERADRAW_FLUIDRENDERER = 5, e.STEP_AFTERCAMERAPOSTPROCESS_LAYER = 0, e.STEP_AFTERRENDERTARGETPOSTPROCESS_LAYER = 0, e.STEP_AFTERRENDER_AUDIO = 0, e.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 0, e.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1, e.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 2, e.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3, e.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0, e.STEP_GATHERACTIVECAMERARENDERTARGETS_FLUIDRENDERER = 1, e.STEP_POINTERMOVE_SPRITE = 0, e.STEP_POINTERDOWN_SPRITE = 0, e.STEP_POINTERUP_SPRITE = 0, e }(), Zi = function (e) { function t(t) { return e.apply(this, t) || this } return W(t, e), t.Create = function () { return Object.create(t.prototype) }, t.prototype.registerStep = function (e, t, i) { var r = 0; for (Number.MAX_VALUE; r < this.length && !(e < this[r].index); r++); this.splice(r, 0, { index: e, component: t, action: i.bind(t) }) }, t.prototype.clear = function () { this.length = 0 }, t }(Array), Ji = function () { function e() { } return e.POINTERDOWN = 1, e.POINTERUP = 2, e.POINTERMOVE = 4, e.POINTERWHEEL = 8, e.POINTERPICK = 16, e.POINTERTAP = 32, e.POINTERDOUBLETAP = 64, e }(), $i = function (e, t) { this.type = e, this.event = t }, er = function (e) { function t(t, i, r, n) { var o = e.call(this, t, i) || this; return o.ray = null, o.originalPickingInfo = null, o.skipOnPointerObservable = !1, o.localPosition = new A(r, n), o } return W(t, e), t }($i), tr = function (e) { function t(t, i, r, n) { void 0 === n && (n = null); var o = e.call(this, t, i) || this; return o._pickInfo = r, o._inputManager = n, o } return W(t, e), Object.defineProperty(t.prototype, "pickInfo", { get: function () { return this._pickInfo || this._generatePickInfo(), this._pickInfo }, enumerable: !1, configurable: !0 }), t.prototype._generatePickInfo = function () { this._inputManager && (this._pickInfo = this._inputManager._pickMove(this.event), this._inputManager._setRayOnPointerInfo(this._pickInfo, this.event), this._inputManager = null) }, t }($i), ir = function () { function e() { } return e.KEYDOWN = 1, e.KEYUP = 2, e }(), rr = function (e, t) { this.type = e, this.event = t }, nr = function (e) { function t(t, i) { var r = e.call(this, t, i) || this; return r.type = t, r.event = i, r.skipOnKeyboardObservable = !1, r } return W(t, e), Object.defineProperty(t.prototype, "skipOnPointerObservable", { get: function () { return this.skipOnKeyboardObservable }, set: function (e) { this.skipOnKeyboardObservable = e }, enumerable: !1, configurable: !0 }), t }(rr); !function (e) { e[e.Generic = 0] = "Generic", e[e.Keyboard = 1] = "Keyboard", e[e.Mouse = 2] = "Mouse", e[e.Touch = 3] = "Touch", e[e.DualShock = 4] = "DualShock", e[e.Xbox = 5] = "Xbox", e[e.Switch = 6] = "Switch", e[e.DualSense = 7] = "DualSense" }(Fi || (Fi = {})), function (e) { e[e.Horizontal = 0] = "Horizontal", e[e.Vertical = 1] = "Vertical", e[e.LeftClick = 2] = "LeftClick", e[e.MiddleClick = 3] = "MiddleClick", e[e.RightClick = 4] = "RightClick", e[e.BrowserBack = 5] = "BrowserBack", e[e.BrowserForward = 6] = "BrowserForward", e[e.MouseWheelX = 7] = "MouseWheelX", e[e.MouseWheelY = 8] = "MouseWheelY", e[e.MouseWheelZ = 9] = "MouseWheelZ", e[e.Move = 12] = "Move" }(Li || (Li = {})), function (e) { e[e.Horizontal = 0] = "Horizontal", e[e.Vertical = 1] = "Vertical", e[e.LeftClick = 2] = "LeftClick", e[e.MiddleClick = 3] = "MiddleClick", e[e.RightClick = 4] = "RightClick", e[e.BrowserBack = 5] = "BrowserBack", e[e.BrowserForward = 6] = "BrowserForward", e[e.MouseWheelX = 7] = "MouseWheelX", e[e.MouseWheelY = 8] = "MouseWheelY", e[e.MouseWheelZ = 9] = "MouseWheelZ", e[e.DeltaHorizontal = 10] = "DeltaHorizontal", e[e.DeltaVertical = 11] = "DeltaVertical" }(wi || (wi = {})), 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.L2 = 6] = "L2", e[e.R2 = 7] = "R2", e[e.Share = 8] = "Share", e[e.Options = 9] = "Options", e[e.L3 = 10] = "L3", e[e.R3 = 11] = "R3", e[e.DPadUp = 12] = "DPadUp", e[e.DPadDown = 13] = "DPadDown", e[e.DPadLeft = 14] = "DPadLeft", e[e.DPadRight = 15] = "DPadRight", e[e.Home = 16] = "Home", e[e.TouchPad = 17] = "TouchPad", e[e.LStickXAxis = 18] = "LStickXAxis", e[e.LStickYAxis = 19] = "LStickYAxis", e[e.RStickXAxis = 20] = "RStickXAxis", e[e.RStickYAxis = 21] = "RStickYAxis" }(Bi || (Bi = {})), 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.L2 = 6] = "L2", e[e.R2 = 7] = "R2", e[e.Create = 8] = "Create", e[e.Options = 9] = "Options", e[e.L3 = 10] = "L3", e[e.R3 = 11] = "R3", e[e.DPadUp = 12] = "DPadUp", e[e.DPadDown = 13] = "DPadDown", e[e.DPadLeft = 14] = "DPadLeft", e[e.DPadRight = 15] = "DPadRight", e[e.Home = 16] = "Home", e[e.TouchPad = 17] = "TouchPad", e[e.LStickXAxis = 18] = "LStickXAxis", e[e.LStickYAxis = 19] = "LStickYAxis", e[e.RStickXAxis = 20] = "RStickXAxis", e[e.RStickYAxis = 21] = "RStickYAxis" }(Ui || (Ui = {})), 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.LT = 6] = "LT", e[e.RT = 7] = "RT", e[e.Back = 8] = "Back", e[e.Start = 9] = "Start", e[e.LS = 10] = "LS", e[e.RS = 11] = "RS", e[e.DPadUp = 12] = "DPadUp", e[e.DPadDown = 13] = "DPadDown", e[e.DPadLeft = 14] = "DPadLeft", e[e.DPadRight = 15] = "DPadRight", e[e.Home = 16] = "Home", e[e.LStickXAxis = 17] = "LStickXAxis", e[e.LStickYAxis = 18] = "LStickYAxis", e[e.RStickXAxis = 19] = "RStickXAxis", e[e.RStickYAxis = 20] = "RStickYAxis" }(Vi || (Vi = {})), function (e) { e[e.B = 0] = "B", e[e.A = 1] = "A", e[e.Y = 2] = "Y", e[e.X = 3] = "X", e[e.L = 4] = "L", e[e.R = 5] = "R", e[e.ZL = 6] = "ZL", e[e.ZR = 7] = "ZR", e[e.Minus = 8] = "Minus", e[e.Plus = 9] = "Plus", e[e.LS = 10] = "LS", e[e.RS = 11] = "RS", e[e.DPadUp = 12] = "DPadUp", e[e.DPadDown = 13] = "DPadDown", e[e.DPadLeft = 14] = "DPadLeft", e[e.DPadRight = 15] = "DPadRight", e[e.Home = 16] = "Home", e[e.Capture = 17] = "Capture", e[e.LStickXAxis = 18] = "LStickXAxis", e[e.LStickYAxis = 19] = "LStickYAxis", e[e.RStickXAxis = 20] = "RStickXAxis", e[e.RStickYAxis = 21] = "RStickYAxis" }(ki || (ki = {})), function (e) { e[e.PointerMove = 0] = "PointerMove", e[e.PointerDown = 1] = "PointerDown", e[e.PointerUp = 2] = "PointerUp" }(Gi || (Gi = {})); var or, ar = function () { function e() { } return e.DOM_DELTA_PIXEL = 0, e.DOM_DELTA_LINE = 1, e.DOM_DELTA_PAGE = 2, e }(), sr = function () { function e() { } return e.CreateDeviceEvent = function (e, t, i, r, n, o, a) { switch (e) { case Fi.Keyboard: return this._CreateKeyboardEvent(i, r, n, o); case Fi.Mouse: if (i === Li.MouseWheelX || i === Li.MouseWheelY || i === Li.MouseWheelZ) return this._CreateWheelEvent(e, t, i, r, n, o); case Fi.Touch: return this._CreatePointerEvent(e, t, i, r, n, o, a); default: throw "Unable to generate event for device ".concat(Fi[e]) } }, e._CreatePointerEvent = function (e, t, i, r, n, o, a) { var s = this._CreateMouseEvent(e, t, i, r, n, o); e === Fi.Mouse ? (s.deviceType = Fi.Mouse, s.pointerId = 1, s.pointerType = "mouse") : (s.deviceType = Fi.Touch, s.pointerId = null != a ? a : t, s.pointerType = "touch"); var l = 0; return l += n.pollInput(e, t, Li.LeftClick), l += 2 * n.pollInput(e, t, Li.RightClick), l += 4 * n.pollInput(e, t, Li.MiddleClick), s.buttons = l, i === Li.Move ? s.type = "pointermove" : i >= Li.LeftClick && i <= Li.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 = ar.DOM_DELTA_PIXEL, a.deltaX = 0, a.deltaY = 0, a.deltaZ = 0, i) { case Li.MouseWheelX: a.deltaX = r; break; case Li.MouseWheelY: a.deltaY = r; break; case Li.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, Li.Horizontal), l = n.pollInput(e, t, Li.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, wi.DeltaHorizontal), a.movementY = n.pollInput(e, t, wi.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 = Fi.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(Fi.Keyboard), r = i && 1 === t.pollInput(Fi.Keyboard, 0, a.INPUT_ALT_KEY), n = i && 1 === t.pollInput(Fi.Keyboard, 0, a.INPUT_CTRL_KEY), o = i && (1 === t.pollInput(Fi.Keyboard, 0, a.INPUT_META_KEY1) || 1 === t.pollInput(Fi.Keyboard, 0, a.INPUT_META_KEY2) || 1 === t.pollInput(Fi.Keyboard, 0, a.INPUT_META_KEY3)), s = i && 1 === t.pollInput(Fi.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 }(), lr = 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 = sr.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 === Fi.Mouse || e === Fi.Touch }, e.prototype.dispose = function () { this._nativeInput.dispose() }, e.prototype._createDummyNativeInput = function () { return { pollInput: function () { return 0 }, isDeviceAvailable: function () { return !1 }, dispose: function () { } } }, e }(), cr = Object.keys(Li).length / 2, ur = function () { function e(e, t, i, r) { var n = this; this._inputs = [], this._keyboardActive = !1, this._pointerActive = !1, this._usingSafari = xi.IsSafari(), this._usingMacOS = tt() && /(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._eventsAttached = !1, this._mouseId = -1, this._isUsingFirefox = tt() && navigator.userAgent && -1 !== navigator.userAgent.indexOf("Firefox"), this._maxTouchPoints = 0, this._pointerInputClearObserver = null, this._gamepadConnectedEvent = function (e) { }, this._gamepadDisconnectedEvent = function (e) { }, this._eventPrefix = xi.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(Fi[e]); e >= Fi.DualShock && e <= Fi.DualSense && this._updateDevice(e, t, i); var n = r[i]; if (void 0 === n) throw "Unable to find input ".concat(i, " for device ").concat(Fi[e], " in slot ").concat(t); return i === Li.Move && xi.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; t < i.length; t++) { var r = i[t]; if (r) for (var n in r) { var o = r[+n]; if (o) for (var a = 0; a < o.length; a++)o[a] = 0 } } this._elementToAttachTo = e, this._elementToAttachTo.tabIndex = -1 !== this._elementToAttachTo.tabIndex ? this._elementToAttachTo.tabIndex : this._engine.canvasTabIndex, this._handleKeyActions(), this._handlePointerActions(), this._handleGamepadActions(), this._eventsAttached = !0, this._checkForConnectedDevices() } }, e.prototype._disableEvents = function () { this._elementToAttachTo && (this._elementToAttachTo.removeEventListener("blur", this._keyboardBlurEvent), this._elementToAttachTo.removeEventListener("blur", this._pointerBlurEvent), this._elementToAttachTo.removeEventListener("keydown", this._keyboardDownEvent), this._elementToAttachTo.removeEventListener("keyup", this._keyboardUpEvent), this._elementToAttachTo.removeEventListener(this._eventPrefix + "move", this._pointerMoveEvent), this._elementToAttachTo.removeEventListener(this._eventPrefix + "down", this._pointerDownEvent), this._elementToAttachTo.removeEventListener(this._eventPrefix + "up", this._pointerUpEvent), this._elementToAttachTo.removeEventListener(this._eventPrefix + "cancel", this._pointerCancelEvent), this._elementToAttachTo.removeEventListener(this._wheelEventName, this._pointerWheelEvent), window.removeEventListener("gamepadconnected", this._gamepadConnectedEvent), window.removeEventListener("gamepaddisconnected", this._gamepadDisconnectedEvent)), this._pointerInputClearObserver && this._engine.onEndFrameObservable.remove(this._pointerInputClearObserver), this._eventsAttached = !1 }, e.prototype._checkForConnectedDevices = function () { if (navigator.getGamepads) for (var e = 0, t = navigator.getGamepads(); e < t.length; e++) { var i = t[e]; i && this._addGamePad(i) } "function" == typeof matchMedia && matchMedia("(pointer:fine)").matches && this._addPointerDevice(Fi.Mouse, 0, 0, 0) }, e.prototype._addGamePad = function (e) { var t = this._getGamepadDeviceType(e.id), i = e.index; this._gamepads = this._gamepads || new Array(e.index + 1), this._registerDevice(t, i, e.buttons.length + e.axes.length), this._gamepads[i] = t }, e.prototype._addPointerDevice = function (e, t, i, r) { this._pointerActive || (this._pointerActive = !0), this._registerDevice(e, t, cr); var n = this._inputs[e][t]; n[0] = i, n[1] = r }, e.prototype._registerDevice = function (e, t, i) { if (void 0 === t) throw "Unable to register device ".concat(Fi[e], " to undefined slot."); if (this._inputs[e] || (this._inputs[e] = {}), !this._inputs[e][t]) { var r = new Array(i); r.fill(0), this._inputs[e][t] = r, this._onDeviceConnected(e, t) } }, e.prototype._unregisterDevice = function (e, t) { this._inputs[e][t] && (delete this._inputs[e][t], this._onDeviceDisconnected(e, t)) }, e.prototype._handleKeyActions = function () { var e = this; this._keyboardDownEvent = function (t) { e._keyboardActive || (e._keyboardActive = !0, e._registerDevice(Fi.Keyboard, 0, 255)); var i = e._inputs[Fi.Keyboard][0]; if (i) { i[t.keyCode] = 1; var r = t; r.inputIndex = t.keyCode, e._usingMacOS && t.metaKey && "Meta" !== t.key && (e._metaKeys.includes(t.keyCode) || e._metaKeys.push(t.keyCode)), e._onInputChanged(Fi.Keyboard, 0, r) } }, this._keyboardUpEvent = function (t) { e._keyboardActive || (e._keyboardActive = !0, e._registerDevice(Fi.Keyboard, 0, 255)); var i = e._inputs[Fi.Keyboard][0]; if (i) { i[t.keyCode] = 0; var r = t; if (r.inputIndex = t.keyCode, e._usingMacOS && "Meta" === t.key && e._metaKeys.length > 0) { for (var n = 0, o = e._metaKeys; n < o.length; n++) { var a = o[n], s = sr.CreateDeviceEvent(Fi.Keyboard, 0, a, 0, e, e._elementToAttachTo); i[a] = 0, e._onInputChanged(Fi.Keyboard, 0, s) } e._metaKeys.splice(0, e._metaKeys.length) } e._onInputChanged(Fi.Keyboard, 0, r) } }, this._keyboardBlurEvent = function () { if (e._keyboardActive) { for (var t = e._inputs[Fi.Keyboard][0], i = 0; i < t.length; i++)if (0 !== t[i]) { t[i] = 0; var r = sr.CreateDeviceEvent(Fi.Keyboard, 0, i, 0, e, e._elementToAttachTo); e._onInputChanged(Fi.Keyboard, 0, r) } e._usingMacOS && e._metaKeys.splice(0, e._metaKeys.length) } }, this._elementToAttachTo.addEventListener("keydown", this._keyboardDownEvent), this._elementToAttachTo.addEventListener("keyup", this._keyboardUpEvent), this._elementToAttachTo.addEventListener("blur", this._keyboardBlurEvent) }, e.prototype._handlePointerActions = function () { var e = this; this._maxTouchPoints = tt() && navigator.maxTouchPoints || 2, this._activeTouchIds || (this._activeTouchIds = new Array(this._maxTouchPoints)); for (var t = 0; t < this._maxTouchPoints; t++)this._activeTouchIds[t] = -1; this._pointerMoveEvent = function (t) { var i = e._getPointerType(t), r = i === Fi.Mouse ? 0 : e._activeTouchIds.indexOf(t.pointerId); e._inputs[i] || (e._inputs[i] = {}), e._inputs[i][r] || e._addPointerDevice(i, r, t.clientX, t.clientY); var n = e._inputs[i][r]; if (n) { var o = t; o.inputIndex = Li.Move, n[Li.Horizontal] = t.clientX, n[Li.Vertical] = t.clientY, void 0 === t.pointerId && (t.pointerId = e._mouseId), e._onInputChanged(i, r, o), e._usingSafari || -1 === t.button || (o.inputIndex = t.button + 2, n[t.button + 2] = n[t.button + 2] ? 0 : 1, e._onInputChanged(i, r, o)) } }, this._pointerDownEvent = function (t) { var i = e._getPointerType(t), r = i === Fi.Mouse ? 0 : t.pointerId; if (i === Fi.Touch) { var n = e._activeTouchIds.indexOf(-1); if (!(n >= 0)) return void xi.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 === Fi.Touch && e._onDeviceConnected(i, r) : e._addPointerDevice(i, r, t.clientX, t.clientY); var o = e._inputs[i][r]; if (o) { var a = o[Li.Horizontal], s = o[Li.Vertical]; if (i === Fi.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[Li.Horizontal] = t.clientX, o[Li.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 = Li.Move, e._onInputChanged(i, r, l)) } }, this._pointerUpEvent = function (t) { var i, r, n, o, a, s = e._getPointerType(t), l = s === Fi.Mouse ? 0 : e._activeTouchIds.indexOf(t.pointerId); if (s === Fi.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[Li.Horizontal], h = c[Li.Vertical]; c[Li.Horizontal] = t.clientX, c[Li.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 = Li.Move, e._onInputChanged(s, l, d)), d.inputIndex = t.button + 2, s === Fi.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 === Fi.Touch && e._onDeviceDisconnected(s, l) } }, this._pointerCancelEvent = function (t) { var i, r, n, o; if ("mouse" === t.pointerType) { var a = e._inputs[Fi.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 = Li.LeftClick; s <= Li.BrowserForward; s++)if (1 === a[s]) { a[s] = 0; var l = sr.CreateDeviceEvent(Fi.Mouse, 0, s, 0, e, e._elementToAttachTo); e._onInputChanged(Fi.Mouse, 0, l) } } else { var c = e._activeTouchIds.indexOf(t.pointerId); (null === (o = (n = e._elementToAttachTo).hasPointerCapture) || void 0 === o ? void 0 : o.call(n, t.pointerId)) && e._elementToAttachTo.releasePointerCapture(t.pointerId), e._inputs[Fi.Touch][c][Li.LeftClick] = 0, l = sr.CreateDeviceEvent(Fi.Touch, c, Li.LeftClick, 0, e, e._elementToAttachTo, t.pointerId), e._onInputChanged(Fi.Touch, c, l), e._activeTouchIds[c] = -1, e._onDeviceDisconnected(Fi.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(Fi.Mouse)) { var a = e._inputs[Fi.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 = Li.LeftClick; s <= Li.BrowserForward; s++)if (1 === a[s]) { a[s] = 0; var l = sr.CreateDeviceEvent(Fi.Mouse, 0, s, 0, e, e._elementToAttachTo); e._onInputChanged(Fi.Mouse, 0, l) } } if (e.isDeviceAvailable(Fi.Touch)) { a = e._inputs[Fi.Touch]; for (var c = 0; c < e._activeTouchIds.length; c++) { var u = e._activeTouchIds[c]; (null === (n = (r = e._elementToAttachTo).hasPointerCapture) || void 0 === n ? void 0 : n.call(r, u)) && e._elementToAttachTo.releasePointerCapture(u), -1 !== u && 1 === (null === (o = a[c]) || void 0 === o ? void 0 : o[Li.LeftClick]) && (a[c][Li.LeftClick] = 0, l = sr.CreateDeviceEvent(Fi.Touch, c, Li.LeftClick, 0, e, e._elementToAttachTo, u), e._onInputChanged(Fi.Touch, c, l), e._activeTouchIds[c] = -1, e._onDeviceDisconnected(Fi.Touch, c)) } } }, this._pointerWheelEvent = function (t) { var i = Fi.Mouse; e._inputs[i] || (e._inputs[i] = []), e._inputs[i][0] || (e._pointerActive = !0, e._registerDevice(i, 0, cr)); var r = e._inputs[i][0]; if (r) { r[Li.MouseWheelX] = t.deltaX || 0, r[Li.MouseWheelY] = t.deltaY || t.wheelDelta || 0, r[Li.MouseWheelZ] = t.deltaZ || 0; var n = t; void 0 === t.pointerId && (t.pointerId = e._mouseId), 0 !== r[Li.MouseWheelX] && (n.inputIndex = Li.MouseWheelX, e._onInputChanged(i, 0, n)), 0 !== r[Li.MouseWheelY] && (n.inputIndex = Li.MouseWheelY, e._onInputChanged(i, 0, n)), 0 !== r[Li.MouseWheelZ] && (n.inputIndex = Li.MouseWheelZ, e._onInputChanged(i, 0, n)) } }, 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(Fi.Mouse)) { var t = e._inputs[Fi.Mouse][0]; t[Li.MouseWheelX] = 0, t[Li.MouseWheelY] = 0, t[Li.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") ? Fi.DualSense : Fi.DualShock : -1 !== e.indexOf("Xbox One") || -1 !== e.search("Xbox 360") || -1 !== e.search("xinput") ? Fi.Xbox : -1 !== e.indexOf("057e") ? Fi.Switch : Fi.Generic }, e.prototype._getPointerType = function (e) { var t = Fi.Mouse; return ("touch" === e.pointerType || "pen" === e.pointerType || e.touches) && (t = Fi.Touch), t }, e }(), hr = 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 }(), dr = function () { function e(e) { var t = this; this._registeredManagers = new Array, this._refCount = 0, this.registerManager = function (e) { for (var i = 0; i < t._devices.length; i++) { var r = t._devices[i]; for (var n in r) { var o = +n; e._addDevice(new hr(t._deviceInputSystem, i, o)) } } t._registeredManagers.push(e) }, this.unregisterManager = function (e) { var i = t._registeredManagers.indexOf(e); i > -1 && t._registeredManagers.splice(i, 1) }; var i = Object.keys(Fi).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 < n.length; r++) { var o = n[r], a = new hr(t._deviceInputSystem, e, i); o._addDevice(a) } }, n = function (e, i) { var r; (null === (r = t._devices[e]) || void 0 === r ? void 0 : r[i]) && delete t._devices[e][i]; for (var n = 0, o = t._registeredManagers; n < o.length; n++)o[n]._removeDevice(e, i) }, o = function (e, i, r) { if (r) for (var n = 0, o = t._registeredManagers; n < o.length; n++)o[n]._onInputChanged(e, i, r) }; "undefined" != typeof _native ? this._deviceInputSystem = new lr(r, n, o) : this._deviceInputSystem = new ur(e, r, n, o) } return e.prototype.dispose = function () { this._deviceInputSystem.dispose() }, e }(), pr = function () { function e(e) { var t = this, i = Object.keys(Fi).length / 2; this._devices = new Array(i), this._firstDevice = new Array(i), this._engine = e, this._engine._deviceSourceManager || (this._engine._deviceSourceManager = new dr(e)), this._engine._deviceSourceManager._refCount++, this.onDeviceConnectedObservable = new u((function (e) { for (var i = 0, r = t._devices; i < r.length; i++) { var n = r[i]; if (n) for (var o = 0, a = n; o < a.length; o++) { var s = a[o]; s && t.onDeviceConnectedObservable.notifyObserver(e, s) } } })), this.onDeviceDisconnectedObservable = new u, this._engine._deviceSourceManager.registerManager(this), this._onDisposeObserver = e.onDisposeObservable.add((function () { t.dispose() })) } return e.prototype.getDeviceSource = function (e, t) { if (void 0 === t) { if (void 0 === this._firstDevice[e]) return null; t = this._firstDevice[e] } return this._devices[e] && void 0 !== this._devices[e][t] ? this._devices[e][t] : null }, e.prototype.getDeviceSources = function (e) { return this._devices[e] ? this._devices[e].filter((function (e) { return !!e })) : [] }, e.prototype.dispose = function () { this.onDeviceConnectedObservable.clear(), this.onDeviceDisconnectedObservable.clear(), this._engine._deviceSourceManager && (this._engine._deviceSourceManager.unregisterManager(this), --this._engine._deviceSourceManager._refCount < 1 && (this._engine._deviceSourceManager.dispose(), delete this._engine._deviceSourceManager)), this._engine.onDisposeObservable.remove(this._onDisposeObserver) }, e.prototype._addDevice = function (e) { this._devices[e.deviceType] || (this._devices[e.deviceType] = new Array), this._devices[e.deviceType][e.deviceSlot] || (this._devices[e.deviceType][e.deviceSlot] = e, this._updateFirstDevices(e.deviceType)), this.onDeviceConnectedObservable.notifyObservers(e) }, e.prototype._removeDevice = function (e, t) { var i, r, n = null === (i = this._devices[e]) || void 0 === i ? void 0 : i[t]; this.onDeviceDisconnectedObservable.notifyObservers(n), (null === (r = this._devices[e]) || void 0 === r ? void 0 : r[t]) && delete this._devices[e][t], this._updateFirstDevices(e) }, e.prototype._onInputChanged = function (e, t, i) { var r, n; null === (n = null === (r = this._devices[e]) || void 0 === r ? void 0 : r[t]) || void 0 === n || n.onInputChangedObservable.notifyObservers(i) }, e.prototype._updateFirstDevices = function (e) { switch (e) { case Fi.Keyboard: case Fi.Mouse: this._firstDevice[e] = 0; break; case Fi.Touch: case Fi.DualSense: case Fi.DualShock: case Fi.Xbox: case Fi.Switch: case Fi.Generic: delete this._firstDevice[e]; var t = this._devices[e]; if (t) for (var i = 0; i < t.length; i++)if (t[i]) { this._firstDevice[e] = i; break } } }, e }(), fr = function () { function e() { this._singleClick = !1, this._doubleClick = !1, this._hasSwiped = !1, this._ignore = !1 } return Object.defineProperty(e.prototype, "singleClick", { get: function () { return this._singleClick }, set: function (e) { this._singleClick = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "doubleClick", { get: function () { return this._doubleClick }, set: function (e) { this._doubleClick = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "hasSwiped", { get: function () { return this._hasSwiped }, set: function (e) { this._hasSwiped = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "ignore", { get: function () { return this._ignore }, set: function (e) { this._ignore = e }, enumerable: !1, configurable: !0 }), e }(), _r = function () { function e(e) { this._alreadyAttached = !1, this._meshPickProceed = !1, this._currentPickResult = null, this._previousPickResult = null, this._totalPointersPressed = 0, this._doubleClickOccured = !1, this._isSwiping = !1, this._swipeButtonPressed = -1, this._skipPointerTap = !1, this._isMultiTouchGesture = !1, this._pointerX = 0, this._pointerY = 0, this._startingPointerPosition = new A(0, 0), this._previousStartingPointerPosition = new A(0, 0), this._startingPointerTime = 0, this._previousStartingPointerTime = 0, this._pointerCaptures = {}, this._meshUnderPointerId = {}, this._movePointerInfo = null, this._cameraObserverCount = 0, this._delayedClicks = [null, null, null, null, null], this._deviceSourceManager = null, this._scene = e || S.LastCreatedScene, this._scene } return Object.defineProperty(e.prototype, "meshUnderPointer", { get: function () { return this._movePointerInfo && (this._movePointerInfo._generatePickInfo(), this._movePointerInfo = null), this._pointerOverMesh }, enumerable: !1, configurable: !0 }), e.prototype.getMeshUnderPointerByPointerId = function (e) { return this._meshUnderPointerId[e] || null }, Object.defineProperty(e.prototype, "unTranslatedPointer", { get: function () { return new A(this._unTranslatedPointerX, this._unTranslatedPointerY) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "pointerX", { get: function () { return this._pointerX }, set: function (e) { this._pointerX = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "pointerY", { get: function () { return this._pointerY }, set: function (e) { this._pointerY = e }, enumerable: !1, configurable: !0 }), e.prototype._updatePointerPosition = function (e) { var t = this._scene.getEngine().getInputElementClientRect(); t && (this._pointerX = e.clientX - t.left, this._pointerY = e.clientY - t.top, this._unTranslatedPointerX = this._pointerX, this._unTranslatedPointerY = this._pointerY) }, e.prototype._processPointerMove = function (e, t) { var i = this._scene, r = i.getEngine(), n = r.getInputElement(); n && (n.tabIndex = r.canvasTabIndex, i.doNotHandleCursors || (n.style.cursor = i.defaultCursor)), this._setCursorAndPointerOverMesh(e, t, i); for (var o = 0, a = i._pointerMoveStage; o < a.length; o++) { var s = a[o], l = !!(null == (e = e || this._pickMove(t)) ? void 0 : e.pickedMesh); e = s.action(this._unTranslatedPointerX, this._unTranslatedPointerY, e, l, n) } var c, u = t.inputIndex >= Li.MouseWheelX && t.inputIndex <= Li.MouseWheelZ ? Ji.POINTERWHEEL : Ji.POINTERMOVE; i.onPointerMove && (e = e || this._pickMove(t), i.onPointerMove(t, e, u)), e ? (c = new tr(u, t, e), this._setRayOnPointerInfo(e, t)) : (c = new tr(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 er(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 = Li.Move, this._checkPrePointerObservable(e, i, Ji.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, Ji.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; l < c.length; l++)t = c[l].action(this._unTranslatedPointerX, this._unTranslatedPointerY, t, i, !1); var u = Ji.POINTERDOWN; t ? (o.onPointerDown && o.onPointerDown(i, t, u), r = new tr(u, i, t), this._setRayOnPointerInfo(t, i)) : r = new tr(u, i, null, this), o.onPointerObservable.hasObservers() && o.onPointerObservable.notifyObservers(r, u) }, e.prototype._isPointerSwiping = function () { return this._isSwiping }, e.prototype.simulatePointerUp = function (e, t, i) { var r = new PointerEvent("pointerup", t); r.inputIndex = Li.Move; var n = new fr; i ? n.doubleClick = !0 : n.singleClick = !0, this._checkPrePointerObservable(e, r, Ji.POINTERUP) || this._processPointerUp(e, r, n) }, e.prototype._processPointerUp = function (e, t, i) { var r = this._scene; if (null == e ? void 0 : e.pickedMesh) { if (this._pickedUpMesh = e.pickedMesh, this._pickedDownMesh === this._pickedUpMesh && (r.onPointerPick && r.onPointerPick(t, e), i.singleClick && !i.ignore && r.onPointerObservable.observers.length > this._cameraObserverCount)) { var n = Ji.POINTERPICK, o = new tr(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; c < u.length; c++)e = u[c].action(this._unTranslatedPointerX, this._unTranslatedPointerY, e, t, i.doubleClick); if (this._pickedDownMesh && this._pickedDownMesh !== this._pickedUpMesh) { var h = this._pickedDownMesh._getActionManagerForTrigger(a.ACTION_OnPickOutTrigger); h && h.processTrigger(a.ACTION_OnPickOutTrigger, G.CreateNew(this._pickedDownMesh, t)) } if (!i.ignore && (o = new tr(Ji.POINTERUP, t, e), this._setRayOnPointerInfo(e, t), r.onPointerObservable.notifyObservers(o, Ji.POINTERUP), r.onPointerUp && r.onPointerUp(t, e, Ji.POINTERUP), !i.hasSwiped && !this._skipPointerTap && !this._isMultiTouchGesture && (n = 0, i.singleClick ? n = Ji.POINTERTAP : i.doubleClick && (n = Ji.POINTERDOUBLETAP), n))) { var d = new tr(n, t, e); r.onPointerObservable.hasObservers() && r.onPointerObservable.hasSpecificMask(n) && r.onPointerObservable.notifyObservers(d, n) } }, e.prototype.isPointerCaptured = function (e) { return void 0 === e && (e = 0), this._pointerCaptures[e] }, e.prototype.attachControl = function (t, i, r, n) { var o = this; void 0 === t && (t = !0), void 0 === i && (i = !0), void 0 === r && (r = !0), void 0 === n && (n = null); var l = this._scene, c = l.getEngine(); n || (n = c.getInputElement()), this._alreadyAttached && this.detachControl(), n && (this._alreadyAttachedTo = n), this._deviceSourceManager = new pr(c), this._initActionManager = function (e) { if (!o._meshPickProceed) { var t = l.skipPointerUpPicking || 0 === l._registeredActions && !o._checkForPicking() && !l.onPointerUp ? null : l.pick(o._unTranslatedPointerX, o._unTranslatedPointerY, l.pointerUpPredicate, l.pointerUpFastCheck, l.cameraToUseForPointers); o._currentPickResult = t, t && (e = t.hit && t.pickedMesh ? t.pickedMesh._getActionManagerForTrigger() : null), o._meshPickProceed = !0 } return e }, this._delayedSimpleClick = function (t, i, r) { if ((Date.now() - o._previousStartingPointerTime > e.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 = Ji.POINTERTAP, s = new tr(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 fr; o._currentPickResult = null; var h = null, d = t.hasSpecificMask(Ji.POINTERPICK) || i.hasSpecificMask(Ji.POINTERPICK) || t.hasSpecificMask(Ji.POINTERTAP) || i.hasSpecificMask(Ji.POINTERTAP) || t.hasSpecificMask(Ji.POINTERDOUBLETAP) || i.hasSpecificMask(Ji.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(Ji.POINTERDOUBLETAP) && !i.hasSpecificMask(Ji.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(Ji.POINTERDOUBLETAP) || i.hasSpecificMask(Ji.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._previousStartingPointerTime < e.DoubleClickDelay && !o._doubleClickOccured ? (u.hasSwiped || o._isPointerSwiping() ? (o._doubleClickOccured = !1, o._previousStartingPointerTime = o._startingPointerTime, o._previousStartingPointerPosition.x = o._startingPointerPosition.x, o._previousStartingPointerPosition.y = o._startingPointerPosition.y, o._previousButtonPressed = f, e.ExclusiveDoubleClickMode ? (o._delayedClicks[f] && (clearTimeout(null === (c = o._delayedClicks[f]) || void 0 === c ? void 0 : c.timeoutId), o._delayedClicks[f] = null), n(u, o._previousPickResult)) : n(u, o._currentPickResult)) : (o._previousStartingPointerTime = 0, o._doubleClickOccured = !0, u.doubleClick = !0, u.ignore = !1, e.ExclusiveDoubleClickMode && o._delayedClicks[f] && (clearTimeout(null === (l = o._delayedClicks[f]) || void 0 === l ? void 0 : l.timeoutId), o._delayedClicks[f] = null), n(u, o._currentPickResult)), p = !0) : (o._doubleClickOccured = !1, o._previousStartingPointerTime = o._startingPointerTime, o._previousStartingPointerPosition.x = o._startingPointerPosition.x, o._previousStartingPointerPosition.y = o._startingPointerPosition.y, o._previousButtonPressed = f)) } } p || n(u, o._currentPickResult) }, this._onPointerMove = function (t) { if (o._updatePointerPosition(t), o._isSwiping || -1 === o._swipeButtonPressed || (o._isSwiping = Math.abs(o._startingPointerPosition.x - o._pointerX) > e.DragMovementThreshold || Math.abs(o._startingPointerPosition.y - o._pointerY) > e.DragMovementThreshold), c.isPointerLock && c._verifyPointerLock(), !o._checkPrePointerObservable(null, t, t.inputIndex >= Li.MouseWheelX && t.inputIndex <= Li.MouseWheelZ ? Ji.POINTERWHEEL : Ji.POINTERMOVE) && (l.cameraToUseForPointers || l.activeCamera)) if (l.skipPointerMovePicking) o._processPointerMove(new Xi, 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; a < o._delayedClicks.length; a++)if (o._delayedClicks[a]) if (t.button === a) clearTimeout(null === (i = o._delayedClicks[a]) || void 0 === i ? void 0 : i.timeoutId); else { var s = o._delayedClicks[a].clickInfo; o._doubleClickOccured = !1, s.singleClick = !0, s.ignore = !1; var c = o._delayedClicks[a].evt, u = Ji.POINTERTAP, h = new tr(u, c, o._currentPickResult); l.onPointerObservable.hasObservers() && l.onPointerObservable.hasSpecificMask(u) && l.onPointerObservable.notifyObservers(h, u), o._delayedClicks[a] = null } o._updatePointerPosition(t), -1 === o._swipeButtonPressed && (o._swipeButtonPressed = t.button), l.preventDefaultOnPointerDown && n && (t.preventDefault(), n.focus()), o._startingPointerPosition.x = o._pointerX, o._startingPointerPosition.y = o._pointerY, o._startingPointerTime = Date.now(), o._checkPrePointerObservable(null, t, Ji.POINTERDOWN) || (l.cameraToUseForPointers || l.activeCamera) && (o._pointerCaptures[t.pointerId] = !0, l.pointerDownPredicate || (l.pointerDownPredicate = function (e) { return e.isPickable && e.isVisible && e.isReady() && e.isEnabled() && (!l.cameraToUseForPointers || 0 != (l.cameraToUseForPointers.layerMask & e.layerMask)) }), o._pickedDownMesh = null, r = l.skipPointerDownPicking || 0 === l._registeredActions && !o._checkForPicking() && !l.onPointerDown ? new Xi : l.pick(o._unTranslatedPointerX, o._unTranslatedPointerY, l.pointerDownPredicate, l.pointerDownFastCheck, l.cameraToUseForPointers), o._processPointerDown(r, t)) }, this._onPointerUp = function (e) { 0 !== o._totalPointersPressed && (o._totalPointersPressed--, o._pickedUpMesh = null, o._meshPickProceed = !1, o._updatePointerPosition(e), l.preventDefaultOnPointerUp && n && (e.preventDefault(), n.focus()), o._initClickEvent(l.onPrePointerObservable, l.onPointerObservable, e, (function (t, i) { if (l.onPrePointerObservable.hasObservers() && (o._skipPointerTap = !1, !t.ignore)) { if (o._checkPrePointerObservable(null, e, Ji.POINTERUP)) return o._swipeButtonPressed === e.button && (o._isSwiping = !1, o._swipeButtonPressed = -1), void (0 === e.buttons && (o._pointerCaptures[e.pointerId] = !1)); t.hasSwiped || (t.singleClick && l.onPrePointerObservable.hasSpecificMask(Ji.POINTERTAP) && o._checkPrePointerObservable(null, e, Ji.POINTERTAP) && (o._skipPointerTap = !0), t.doubleClick && l.onPrePointerObservable.hasSpecificMask(Ji.POINTERDOUBLETAP) && o._checkPrePointerObservable(null, e, Ji.POINTERDOUBLETAP) && (o._skipPointerTap = !0)) } o._pointerCaptures[e.pointerId] ? (0 === e.buttons && (o._pointerCaptures[e.pointerId] = !1), (l.cameraToUseForPointers || l.activeCamera) && (l.pointerUpPredicate || (l.pointerUpPredicate = function (e) { return e.isPickable && e.isVisible && e.isReady() && e.isEnabled() && (!l.cameraToUseForPointers || 0 != (l.cameraToUseForPointers.layerMask & e.layerMask)) }), !o._meshPickProceed && (s && s.HasTriggers || o._checkForPicking() || l.onPointerUp) && o._initActionManager(null, t), i || (i = o._currentPickResult), o._processPointerUp(i, e, t), o._previousPickResult = o._currentPickResult, o._swipeButtonPressed === e.button && (o._isSwiping = !1, o._swipeButtonPressed = -1))) : o._swipeButtonPressed === e.button && (o._isSwiping = !1, o._swipeButtonPressed = -1) }))) }, this._onKeyDown = function (e) { var t = ir.KEYDOWN; if (l.onPreKeyboardObservable.hasObservers()) { var i = new nr(t, e); if (l.onPreKeyboardObservable.notifyObservers(i, t), i.skipOnKeyboardObservable) return } l.onKeyboardObservable.hasObservers() && (i = new rr(t, e), l.onKeyboardObservable.notifyObservers(i, t)), l.actionManager && l.actionManager.processTrigger(a.ACTION_OnKeyDownTrigger, G.CreateNewFromScene(l, e)) }, this._onKeyUp = function (e) { var t = ir.KEYUP; if (l.onPreKeyboardObservable.hasObservers()) { var i = new nr(t, e); if (l.onPreKeyboardObservable.notifyObservers(i, t), i.skipOnKeyboardObservable) return } l.onKeyboardObservable.hasObservers() && (i = new rr(t, e), l.onKeyboardObservable.notifyObservers(i, t)), l.actionManager && l.actionManager.processTrigger(a.ACTION_OnKeyUpTrigger, G.CreateNewFromScene(l, e)) }, this._deviceSourceManager.onDeviceConnectedObservable.add((function (e) { e.deviceType === Fi.Mouse ? e.onInputChangedObservable.add((function (n) { n.inputIndex === Li.LeftClick || n.inputIndex === Li.MiddleClick || n.inputIndex === Li.RightClick || n.inputIndex === Li.BrowserBack || n.inputIndex === Li.BrowserForward ? i && 1 === e.getInput(n.inputIndex) ? o._onPointerDown(n) : t && 0 === e.getInput(n.inputIndex) && o._onPointerUp(n) : r && (n.inputIndex === Li.Move ? o._onPointerMove(n) : n.inputIndex !== Li.MouseWheelX && n.inputIndex !== Li.MouseWheelY && n.inputIndex !== Li.MouseWheelZ || o._onPointerMove(n)) })) : e.deviceType === Fi.Touch ? e.onInputChangedObservable.add((function (n) { n.inputIndex === Li.LeftClick && (i && 1 === e.getInput(n.inputIndex) ? (o._onPointerDown(n), o._totalPointersPressed > 1 && (o._isMultiTouchGesture = !0)) : t && 0 === e.getInput(n.inputIndex) && (o._onPointerUp(n), 0 === o._totalPointersPressed && (o._isMultiTouchGesture = !1))), r && n.inputIndex === Li.Move && o._onPointerMove(n) })) : e.deviceType === Fi.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 }(), mr = 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 = at.Now) }, e.prototype.endMonitoring = function (t) { if (void 0 === t && (t = !0), e.Enabled) { t && this.fetchNewFrame(); var i = at.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 = at.Now; e - this._lastSecTime > 1e3 && (this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount, this._lastSecTime = e, this._lastSecAccumulated = 0, this._lastSecValueCount = 0) }, e.Enabled = !0, e }(), gr = 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 }(), vr = function () { function e() { } return e.GetPlanes = function (t) { for (var i = [], r = 0; r < 6; r++)i.push(new gr(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 }(), yr = 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 }(), br = 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 }(), Tr = 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" }(or || (or = {})); var Er, Sr = function (e) { function t(i, r) { var n = e.call(this) || this; n._inputManager = new _r(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 = or.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 Pi(256), n._pointerPickingConfiguration = new Tr, 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 Pi(256), n.proceduralTexturesEnabled = !0, n._totalVertices = new mr, n._activeIndices = new mr, n._activeParticles = new mr, n._activeBones = new mr, 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 Ci(256), n._processedMaterials = new Ci(256), n._renderTargets = new Pi(256), n._materialsRenderTargets = new Pi(256), n._activeParticleSystems = new Ci(256), n._activeSkeletons = new Pi(32), n._softwareSkinnedMeshes = new Pi(32), n._activeAnimatables = new Array, n._transformMatrix = I.Zero(), n.requireLightSorting = !1, n._components = [], n._serializableComponents = [], n._transientComponents = [], n._beforeCameraUpdateStage = Zi.Create(), n._beforeClearStage = Zi.Create(), n._beforeRenderTargetClearStage = Zi.Create(), n._gatherRenderTargetsStage = Zi.Create(), n._gatherActiveCameraRenderTargetsStage = Zi.Create(), n._isReadyForMeshStage = Zi.Create(), n._beforeEvaluateActiveMeshStage = Zi.Create(), n._evaluateSubMeshStage = Zi.Create(), n._preActiveMeshStage = Zi.Create(), n._cameraDrawRenderTargetStage = Zi.Create(), n._beforeCameraDrawStage = Zi.Create(), n._beforeRenderTargetDrawStage = Zi.Create(), n._beforeRenderingGroupDrawStage = Zi.Create(), n._beforeRenderingMeshStage = Zi.Create(), n._afterRenderingMeshStage = Zi.Create(), n._afterRenderingGroupDrawStage = Zi.Create(), n._afterCameraDrawStage = Zi.Create(), n._afterCameraPostProcessStage = Zi.Create(), n._afterRenderTargetDrawStage = Zi.Create(), n._afterRenderTargetPostProcessStage = Zi.Create(), n._afterRenderStage = Zi.Create(), n._pointerMoveStage = Zi.Create(), n._pointerDownStage = Zi.Create(), n._pointerUpStage = Zi.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 n._engine = i || S.LastCreatedEngine, o.virtual ? n._engine._virtualScenes.push(n) : (S._LastCreatedScene = n, n._engine.scenes.push(n)), n._uid = null, n._renderingManager = new Qi(n), ji && (n.postProcessManager = new ji(n)), et() && n.attachControl(), n._createUbo(), Ni && (n._imageProcessingConfiguration = new Ni), n.setDefaultCandidateProviders(), o.useGeometryUniqueIdsMap && (n._geometriesByUniqueId = {}), n.useMaterialMeshMap = o.useMaterialMeshMap, n.useClonedMeshMap = o.useClonedMeshMap, r && r.virtual || n._engine.onNewSceneAddedObservable.notifyObservers(n), n } return W(t, e), t.DefaultMaterialFactory = function (e) { throw ge("StandardMaterial") }, t.CollisionCoordinatorFactory = function () { throw ge("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 or.BackwardCompatible: this.skipFrustumClipping = !1, this._renderingManager.maintainStateBetweenFrames = !1, this.skipPointerMovePicking = !1, this.autoClear = !0; break; case or.Intermediate: this.skipFrustumClipping = !1, this._renderingManager.maintainStateBetweenFrames = !1, this.skipPointerMovePicking = !0, this.autoClear = !1; break; case or.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 _r.DragMovementThreshold }, set: function (e) { _r.DragMovementThreshold = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "LongPressDelay", { get: function () { return _r.LongPressDelay }, set: function (e) { _r.LongPressDelay = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "DoubleClickDelay", { get: function () { return _r.DoubleClickDelay }, set: function (e) { _r.DoubleClickDelay = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "ExclusiveDoubleClickMode", { get: function () { return _r.ExclusiveDoubleClickMode }, set: function (e) { _r.ExclusiveDoubleClickMode = e }, enumerable: !1, configurable: !0 }), t.prototype.bindEyePosition = function (e, t, i) { var r; void 0 === t && (t = "vEyePosition"), void 0 === i && (i = !1); var n = this._forcedViewPosition ? this._forcedViewPosition : this._mirroredCameraPosition ? this._mirroredCameraPosition : null !== (r = this.activeCamera.globalPosition) && void 0 !== r ? r : this.activeCamera.devicePosition, o = this.useRightHandedSystem === (null != this._mirroredCameraPosition); return O.Vector4[0].set(n.x, n.y, n.z, o ? -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; e < t.length; e++)t[e].register(); this._transientComponents.length = 0 } }, t.prototype._addComponent = function (e) { this._components.push(e), this._transientComponents.push(e); var t = e; t.addFromContainer && t.serialize && this._serializableComponents.push(t) }, t.prototype._getComponent = function (e) { for (var t = 0, i = this._components; t < i.length; t++) { var r = i[t]; if (r.name === e) return r } return null }, t.prototype.getClassName = function () { return "Scene" }, t.prototype._getDefaultMeshCandidates = function () { return this._defaultMeshCandidates.data = this.meshes, this._defaultMeshCandidates.length = this.meshes.length, this._defaultMeshCandidates }, t.prototype._getDefaultSubMeshCandidates = function (e) { return this._defaultSubMeshCandidates.data = e.subMeshes, this._defaultSubMeshCandidates.length = e.subMeshes.length, this._defaultSubMeshCandidates }, t.prototype.setDefaultCandidateProviders = function () { this.getActiveMeshCandidates = this._getDefaultMeshCandidates.bind(this), this.getActiveSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this), this.getIntersectingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this), this.getCollidingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this) }, Object.defineProperty(t.prototype, "meshUnderPointer", { get: function () { return this._inputManager.meshUnderPointer }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "pointerX", { get: function () { return this._inputManager.pointerX }, set: function (e) { this._inputManager.pointerX = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "pointerY", { get: function () { return this._inputManager.pointerY }, set: function (e) { this._inputManager.pointerY = e }, enumerable: !1, configurable: !0 }), t.prototype.getCachedMaterial = function () { return this._cachedMaterial }, t.prototype.getCachedEffect = function () { return this._cachedEffect }, t.prototype.getCachedVisibility = function () { return this._cachedVisibility }, t.prototype.isCachedMaterialInvalid = function (e, t, i) { return void 0 === i && (i = 1), this._cachedEffect !== t || this._cachedMaterial !== e || this._cachedVisibility !== i }, t.prototype.getEngine = function () { return this._engine }, t.prototype.getTotalVertices = function () { return this._totalVertices.current }, Object.defineProperty(t.prototype, "totalVerticesPerfCounter", { get: function () { return this._totalVertices }, enumerable: !1, configurable: !0 }), t.prototype.getActiveIndices = function () { return this._activeIndices.current }, Object.defineProperty(t.prototype, "totalActiveIndicesPerfCounter", { get: function () { return this._activeIndices }, enumerable: !1, configurable: !0 }), t.prototype.getActiveParticles = function () { return this._activeParticles.current }, Object.defineProperty(t.prototype, "activeParticlesPerfCounter", { get: function () { return this._activeParticles }, enumerable: !1, configurable: !0 }), t.prototype.getActiveBones = function () { return this._activeBones.current }, Object.defineProperty(t.prototype, "activeBonesPerfCounter", { get: function () { return this._activeBones }, enumerable: !1, configurable: !0 }), t.prototype.getActiveMeshes = function () { return this._activeMeshes }, t.prototype.getAnimationRatio = function () { return void 0 !== this._animationRatio ? this._animationRatio : 1 }, t.prototype.getRenderId = function () { return this._renderId }, t.prototype.getFrameId = function () { return this._frameId }, t.prototype.incrementRenderId = function () { this._renderId++ }, t.prototype._createUbo = function () { this.setSceneUniformBuffer(this.createSceneUniformBuffer()) }, t.prototype.simulatePointerMove = function (e, t) { return this._inputManager.simulatePointerMove(e, t), this }, t.prototype.simulatePointerDown = function (e, t) { return this._inputManager.simulatePointerDown(e, t), this }, t.prototype.simulatePointerUp = function (e, t, i) { return this._inputManager.simulatePointerUp(e, t, i), this }, t.prototype.isPointerCaptured = function (e) { return void 0 === e && (e = 0), this._inputManager.isPointerCaptured(e) }, t.prototype.attachControl = function (e, t, i) { void 0 === e && (e = !0), void 0 === t && (t = !0), void 0 === i && (i = !0), this._inputManager.attachControl(e, t, i) }, t.prototype.detachControl = function () { this._inputManager.detachControl() }, t.prototype.isReady = function (e) { var t, i, r, n; if (void 0 === e && (e = !0), this._isDisposed) return !1; var o = this.getEngine(), s = o.currentRenderPassId; o.currentRenderPassId = null !== (i = null === (t = this.activeCamera) || void 0 === t ? void 0 : t.renderPassId) && void 0 !== i ? i : s; var l = !0; for (this._pendingData.length > 0 && (l = !1), null === (r = this.prePassRenderer) || void 0 === r || r.update(), e && (this._processedMaterials.reset(), this._materialsRenderTargets.reset()), n = 0; n < this.meshes.length; n++) { var c = this.meshes[n]; if (c.subMeshes && 0 !== c.subMeshes.length) if (c.isReady(!0)) { for (var u = c.hasThinInstances || "InstancedMesh" === c.getClassName() || "InstancedLinesMesh" === c.getClassName() || o.getCaps().instancedArrays && c.instances.length > 0, h = 0, d = this._isReadyForMeshStage; h < d.length; h++)d[h].action(c, u) || (l = !1); if (e) { var p = c.material || this.defaultMaterial; if (p) if (p._storeEffectOnSubMeshes) for (var f = 0, _ = c.subMeshes; f < _.length; f++) { var m = _[f].getMaterial(); m && m.hasRenderTargetTextures && null != m.getRenderTargetTextures && -1 === this._processedMaterials.indexOf(m) && (this._processedMaterials.push(m), this._materialsRenderTargets.concatWithNoDuplicate(m.getRenderTargetTextures())) } else p.hasRenderTargetTextures && null != p.getRenderTargetTextures && -1 === this._processedMaterials.indexOf(p) && (this._processedMaterials.push(p), this._materialsRenderTargets.concatWithNoDuplicate(p.getRenderTargetTextures())) } } else l = !1 } if (e) for (n = 0; n < this._materialsRenderTargets.length; ++n)this._materialsRenderTargets.data[n].isReadyForRendering() || (l = !1); for (n = 0; n < this.geometries.length; n++)this.geometries[n].delayLoadState === a.DELAYLOADSTATE_LOADING && (l = !1); if (this.activeCameras && this.activeCameras.length > 0) for (var g = 0, v = this.activeCameras; g < v.length; g++)v[g].isReady(!0) || (l = !1); else this.activeCamera && (this.activeCamera.isReady(!0) || (l = !1)); for (var y = 0, b = this.particleSystems; y < b.length; y++)b[y].isReady() || (l = !1); if (this.layers) for (var T = 0, E = this.layers; T < E.length; T++)E[T].isReady() || (l = !1); return o.areAllEffectsReady() || (l = !1), o.currentRenderPassId = s, l }, t.prototype.resetCachedMaterial = function () { this._cachedMaterial = null, this._cachedEffect = null, this._cachedVisibility = null }, t.prototype.registerBeforeRender = function (e) { this.onBeforeRenderObservable.add(e) }, t.prototype.unregisterBeforeRender = function (e) { this.onBeforeRenderObservable.removeCallback(e) }, t.prototype.registerAfterRender = function (e) { this.onAfterRenderObservable.add(e) }, t.prototype.unregisterAfterRender = function (e) { this.onAfterRenderObservable.removeCallback(e) }, t.prototype._executeOnceBeforeRender = function (e) { var t = this, i = function () { e(), setTimeout((function () { t.unregisterBeforeRender(i) })) }; this.registerBeforeRender(i) }, t.prototype.executeOnceBeforeRender = function (e, t) { var i = this; void 0 !== t ? setTimeout((function () { i._executeOnceBeforeRender(e) }), t) : this._executeOnceBeforeRender(e) }, t.prototype.addPendingData = function (e) { this._pendingData.push(e) }, t.prototype.removePendingData = function (e) { var t = this.isLoading, i = this._pendingData.indexOf(e); -1 !== i && this._pendingData.splice(i, 1), t && !this.isLoading && this.onDataLoadedObservable.notifyObservers(this) }, t.prototype.getWaitingItemsCount = function () { return this._pendingData.length }, Object.defineProperty(t.prototype, "isLoading", { get: function () { return this._pendingData.length > 0 }, 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 = at.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 ? vr.GetPlanesToRef(this._transformMatrix, this._frustumPlanes) : this._frustumPlanes = vr.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 zi(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 yr.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; i < r.length; i++)r[i]._removeLightSource(e, !1); this.lights.splice(t, 1), this.sortLightsByPriority(), e.parent || e._removeFromSceneRootNodes() } return this.onLightRemovedObservable.notifyObservers(e), t }, t.prototype.removeCamera = function (e) { var t = this.cameras.indexOf(e); if (-1 !== t && (this.cameras.splice(t, 1), e.parent || e._removeFromSceneRootNodes()), this.activeCameras) { var i = this.activeCameras.indexOf(e); -1 !== i && this.activeCameras.splice(i, 1) } return this.activeCamera === e && (this.cameras.length > 0 ? 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 < this.materials.length) { if (t !== this.materials.length - 1) { var i = this.materials[this.materials.length - 1]; this.materials[t] = i, i._indexInSceneMaterialArray = t } e._indexInSceneMaterialArray = -1, this.materials.pop() } return this.onMaterialRemovedObservable.notifyObservers(e), t }, t.prototype.removeActionManager = function (e) { var t = this.actionManagers.indexOf(e); return -1 !== t && this.actionManagers.splice(t, 1), t }, t.prototype.removeTexture = function (e) { var t = this.textures.indexOf(e); return -1 !== t && this.textures.splice(t, 1), this.onTextureRemovedObservable.notifyObservers(e), t }, t.prototype.addLight = function (e) { if (!this._blockEntityCollection) { this.lights.push(e), this.sortLightsByPriority(), e.parent || e._addToSceneRootNodes(); for (var t = 0, i = this.meshes; t < i.length; t++) { var r = i[t]; -1 === r.lightSources.indexOf(e) && (r.lightSources.push(e), r._resyncLightSources()) } this.onNewLightAddedObservable.notifyObservers(e) } }, t.prototype.sortLightsByPriority = function () { this.requireLightSorting && this.lights.sort(br.CompareLightsPriority) }, t.prototype.addCamera = function (e) { this._blockEntityCollection || (this.cameras.push(e), this.onNewCameraAddedObservable.notifyObservers(e), e.parent || e._addToSceneRootNodes()) }, t.prototype.addSkeleton = function (e) { this._blockEntityCollection || (this.skeletons.push(e), this.onNewSkeletonAddedObservable.notifyObservers(e)) }, t.prototype.addParticleSystem = function (e) { this._blockEntityCollection || this.particleSystems.push(e) }, t.prototype.addAnimation = function (e) { this._blockEntityCollection || this.animations.push(e) }, t.prototype.addAnimationGroup = function (e) { this._blockEntityCollection || this.animationGroups.push(e) }, t.prototype.addMultiMaterial = function (e) { this._blockEntityCollection || (this.multiMaterials.push(e), this.onNewMultiMaterialAddedObservable.notifyObservers(e)) }, t.prototype.addMaterial = function (e) { this._blockEntityCollection || e.getScene() === this && -1 !== e._indexInSceneMaterialArray || (e._indexInSceneMaterialArray = this.materials.length, this.materials.push(e), this.onNewMaterialAddedObservable.notifyObservers(e)) }, t.prototype.addMorphTargetManager = function (e) { this._blockEntityCollection || this.morphTargetManagers.push(e) }, t.prototype.addGeometry = function (e) { this._blockEntityCollection || (this._geometriesByUniqueId && (this._geometriesByUniqueId[e.uniqueId] = this.geometries.length), this.geometries.push(e)) }, t.prototype.addActionManager = function (e) { this.actionManagers.push(e) }, t.prototype.addTexture = function (e) { this._blockEntityCollection || (this.textures.push(e), this.onNewTextureAddedObservable.notifyObservers(e)) }, t.prototype.switchActiveCamera = function (e, t) { void 0 === t && (t = !0), this._engine.getInputElement() && (this.activeCamera && this.activeCamera.detachControl(), this.activeCamera = e, t && e.attachControl()) }, t.prototype.setActiveCameraById = function (e) { var t = this.getCameraById(e); return t ? (this.activeCamera = t, t) : null }, t.prototype.setActiveCameraByName = function (e) { var t = this.getCameraByName(e); return t ? (this.activeCamera = t, t) : null }, t.prototype.getAnimationGroupByName = function (e) { for (var t = 0; t < this.animationGroups.length; t++)if (this.animationGroups[t].name === e) return this.animationGroups[t]; return null }, t.prototype._getMaterial = function (e, t) { for (var i = 0; i < this.materials.length; i++)if (t(r = this.materials[i])) return r; if (e) for (i = 0; i < this.multiMaterials.length; i++) { var r; if (t(r = this.multiMaterials[i])) return r } return null }, t.prototype.getMaterialByUniqueID = function (e, t) { return void 0 === t && (t = !1), this._getMaterial(t, (function (t) { return t.uniqueId === e })) }, t.prototype.getMaterialById = function (e, t) { return void 0 === t && (t = !1), this._getMaterial(t, (function (t) { return t.id === e })) }, t.prototype.getMaterialByName = function (e, t) { return void 0 === t && (t = !1), this._getMaterial(t, (function (t) { return t.name === e })) }, t.prototype.getLastMaterialById = function (e, t) { void 0 === t && (t = !1); for (var i = this.materials.length - 1; i >= 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 < this.textures.length; t++)if (this.textures[t].uniqueId === e) return this.textures[t]; return null }, t.prototype.getTextureByName = function (e) { for (var t = 0; t < this.textures.length; t++)if (this.textures[t].name === e) return this.textures[t]; return null }, t.prototype.getCameraById = function (e) { for (var t = 0; t < this.cameras.length; t++)if (this.cameras[t].id === e) return this.cameras[t]; return null }, t.prototype.getCameraByUniqueId = function (e) { for (var t = 0; t < this.cameras.length; t++)if (this.cameras[t].uniqueId === e) return this.cameras[t]; return null }, t.prototype.getCameraByName = function (e) { for (var t = 0; t < this.cameras.length; t++)if (this.cameras[t].name === e) return this.cameras[t]; return null }, t.prototype.getBoneById = function (e) { for (var t = 0; t < this.skeletons.length; t++)for (var i = this.skeletons[t], r = 0; r < i.bones.length; r++)if (i.bones[r].id === e) return i.bones[r]; return null }, t.prototype.getBoneByName = function (e) { for (var t = 0; t < this.skeletons.length; t++)for (var i = this.skeletons[t], r = 0; r < i.bones.length; r++)if (i.bones[r].name === e) return i.bones[r]; return null }, t.prototype.getLightByName = function (e) { for (var t = 0; t < this.lights.length; t++)if (this.lights[t].name === e) return this.lights[t]; return null }, t.prototype.getLightById = function (e) { for (var t = 0; t < this.lights.length; t++)if (this.lights[t].id === e) return this.lights[t]; return null }, t.prototype.getLightByUniqueId = function (e) { for (var t = 0; t < this.lights.length; t++)if (this.lights[t].uniqueId === e) return this.lights[t]; return null }, t.prototype.getParticleSystemById = function (e) { for (var t = 0; t < this.particleSystems.length; t++)if (this.particleSystems[t].id === e) return this.particleSystems[t]; return null }, t.prototype.getGeometryById = function (e) { for (var t = 0; t < this.geometries.length; t++)if (this.geometries[t].id === e) return this.geometries[t]; return null }, t.prototype._getGeometryByUniqueId = function (e) { if (this._geometriesByUniqueId) { if (void 0 !== (t = this._geometriesByUniqueId[e])) return this.geometries[t] } else for (var t = 0; t < this.geometries.length; t++)if (this.geometries[t].uniqueId === e) return this.geometries[t]; return null }, t.prototype.pushGeometry = function (e, t) { return !(!t && this._getGeometryByUniqueId(e.uniqueId) || (this.addGeometry(e), this.onNewGeometryAddedObservable.notifyObservers(e), 0)) }, t.prototype.removeGeometry = function (e) { var t; if (this._geometriesByUniqueId) { if (void 0 === (t = this._geometriesByUniqueId[e.uniqueId])) return !1 } else if ((t = this.geometries.indexOf(e)) < 0) return !1; if (t !== this.geometries.length - 1) { var i = this.geometries[this.geometries.length - 1]; i && (this.geometries[t] = i, this._geometriesByUniqueId && (this._geometriesByUniqueId[i.uniqueId] = t)) } return this._geometriesByUniqueId && (this._geometriesByUniqueId[e.uniqueId] = void 0), this.geometries.pop(), this.onGeometryRemovedObservable.notifyObservers(e), !0 }, t.prototype.getGeometries = function () { return this.geometries }, t.prototype.getMeshById = function (e) { for (var t = 0; t < this.meshes.length; t++)if (this.meshes[t].id === e) return this.meshes[t]; return null }, t.prototype.getMeshesById = function (e) { return this.meshes.filter((function (t) { return t.id === e })) }, t.prototype.getTransformNodeById = function (e) { for (var t = 0; t < this.transformNodes.length; t++)if (this.transformNodes[t].id === e) return this.transformNodes[t]; return null }, t.prototype.getTransformNodeByUniqueId = function (e) { for (var t = 0; t < this.transformNodes.length; t++)if (this.transformNodes[t].uniqueId === e) return this.transformNodes[t]; return null }, t.prototype.getTransformNodesById = function (e) { return this.transformNodes.filter((function (t) { return t.id === e })) }, t.prototype.getMeshByUniqueId = function (e) { for (var t = 0; t < this.meshes.length; t++)if (this.meshes[t].uniqueId === e) return this.meshes[t]; return null }, t.prototype.getLastMeshById = function (e) { for (var t = this.meshes.length - 1; 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 < this.meshes.length; t++)if (this.meshes[t].name === e) return this.meshes[t]; return null }, t.prototype.getTransformNodeByName = function (e) { for (var t = 0; t < this.transformNodes.length; t++)if (this.transformNodes[t].name === e) return this.transformNodes[t]; return null }, t.prototype.getLastSkeletonById = function (e) { for (var t = this.skeletons.length - 1; t >= 0; t--)if (this.skeletons[t].id === e) return this.skeletons[t]; return null }, t.prototype.getSkeletonByUniqueId = function (e) { for (var t = 0; t < this.skeletons.length; t++)if (this.skeletons[t].uniqueId === e) return this.skeletons[t]; return null }, t.prototype.getSkeletonById = function (e) { for (var t = 0; t < this.skeletons.length; t++)if (this.skeletons[t].id === e) return this.skeletons[t]; return null }, t.prototype.getSkeletonByName = function (e) { for (var t = 0; t < this.skeletons.length; t++)if (this.skeletons[t].name === e) return this.skeletons[t]; return null }, t.prototype.getMorphTargetManagerById = function (e) { for (var t = 0; t < this.morphTargetManagers.length; t++)if (this.morphTargetManagers[t].uniqueId === e) return this.morphTargetManagers[t]; return null }, t.prototype.getMorphTargetById = function (e) { for (var t = 0; t < this.morphTargetManagers.length; ++t)for (var i = this.morphTargetManagers[t], r = 0; r < i.numTargets; ++r) { var n = i.getTarget(r); if (n.id === e) return n } return null }, t.prototype.getMorphTargetByName = function (e) { for (var t = 0; t < this.morphTargetManagers.length; ++t)for (var i = this.morphTargetManagers[t], r = 0; r < i.numTargets; ++r) { var n = i.getTarget(r); if (n.name === e) return n } return null }, t.prototype.getPostProcessByName = function (e) { for (var t = 0; t < this.postProcesses.length; ++t) { var i = this.postProcesses[t]; if (i.name === e) return i } return null }, t.prototype.isActiveMesh = function (e) { return -1 !== this._activeMeshes.indexOf(e) }, Object.defineProperty(t.prototype, "uid", { get: function () { return this._uid || (this._uid = xi.RandomId()), this._uid }, enumerable: !1, configurable: !0 }), t.prototype.addExternalData = function (e, t) { return this._externalData || (this._externalData = new Ii), this._externalData.add(e, t) }, t.prototype.getExternalData = function (e) { return this._externalData ? this._externalData.get(e) : null }, t.prototype.getOrAddExternalDataWithFactory = function (e, t) { return this._externalData || (this._externalData = new Ii), this._externalData.getOrAddWithFactory(e, t) }, t.prototype.removeExternalData = function (e) { return this._externalData.remove(e) }, t.prototype._evaluateSubMesh = function (e, t, i, r) { if (r || e.isInFrustum(this._frustumPlanes)) { for (var n = 0, o = this._evaluateSubMeshStage; n < o.length; n++)o[n].action(t, e); var a = e.getMaterial(); null != a && (a.hasRenderTargetTextures && null != a.getRenderTargetTextures && -1 === this._processedMaterials.indexOf(a) && (this._processedMaterials.push(a), this._materialsRenderTargets.concatWithNoDuplicate(a.getRenderTargetTextures())), this._renderingManager.dispatch(e, t, a)) } }, t.prototype.freeProcessedMaterials = function () { this._processedMaterials.dispose() }, Object.defineProperty(t.prototype, "blockfreeActiveMeshesAndRenderingGroups", { get: function () { return this._preventFreeActiveMeshesAndRenderingGroups }, set: function (e) { this._preventFreeActiveMeshesAndRenderingGroups !== e && (e && (this.freeActiveMeshes(), this.freeRenderingGroups()), this._preventFreeActiveMeshesAndRenderingGroups = e) }, enumerable: !1, configurable: !0 }), t.prototype.freeActiveMeshes = function () { if (!this.blockfreeActiveMeshesAndRenderingGroups && (this._activeMeshes.dispose(), this.activeCamera && this.activeCamera._activeMeshes && this.activeCamera._activeMeshes.dispose(), this.activeCameras)) for (var e = 0; e < this.activeCameras.length; e++) { var t = this.activeCameras[e]; t && t._activeMeshes && t._activeMeshes.dispose() } }, t.prototype.freeRenderingGroups = function () { if (!this.blockfreeActiveMeshesAndRenderingGroups && (this._renderingManager && this._renderingManager.freeRenderingGroups(), this.textures)) for (var e = 0; e < this.textures.length; e++) { var t = this.textures[e]; t && t.renderList && t.freeRenderingGroups() } }, t.prototype._isInIntermediateRendering = function () { return this._intermediateRendering }, t.prototype.freezeActiveMeshes = function (e, t, i, r, n) { var o = this; return void 0 === e && (e = !1), void 0 === r && (r = !0), void 0 === n && (n = !1), this.executeWhenReady((function () { if (o.activeCamera) { if (o._frustumPlanes || o.updateTransformMatrix(), o._evaluateActiveMeshes(), o._activeMeshesFrozen = !0, o._activeMeshesFrozenButKeepClipping = n, o._skipEvaluateActiveMeshesCompletely = e, r) for (var a = 0; a < o._activeMeshes.length; a++)o._activeMeshes.data[a]._freeze(); t && t() } else i && i("No active camera found") })), this }, t.prototype.unfreezeActiveMeshes = function () { for (var e = 0; e < this.meshes.length; e++) { var t = this.meshes[e]; t._internalAbstractMeshDataInfo && (t._internalAbstractMeshDataInfo._isActive = !1) } for (e = 0; e < this._activeMeshes.length; e++)this._activeMeshes.data[e]._unFreeze(); return this._activeMeshesFrozen = !1, this }, t.prototype._executeActiveContainerCleanup = function (e) { (!this._engine.snapshotRendering || this._engine.snapshotRenderingMode !== a.SNAPSHOTRENDERING_FAST) && this._activeMeshesFrozen && this._activeMeshes.length || this.onBeforeRenderObservable.addOnce((function () { return e.dispose() })) }, t.prototype._evaluateActiveMeshes = function () { var e; if (this._engine.snapshotRendering && this._engine.snapshotRenderingMode === a.SNAPSHOTRENDERING_FAST) this._activeMeshes.length > 0 && (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; i < t; i++)(c = this._activeMeshes.data[i]).computeWorldMatrix(); if (this._activeParticleSystems) { var r = this._activeParticleSystems.length; for (i = 0; i < r; i++)this._activeParticleSystems.data[i].animate() } this._renderingManager.resetSprites() } else if (this.activeCamera) { this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this), this.activeCamera._activeMeshes.reset(), this._activeMeshes.reset(), this._renderingManager.reset(), this._processedMaterials.reset(), this._activeParticleSystems.reset(), this._activeSkeletons.reset(), this._softwareSkinnedMeshes.reset(), this._materialsRenderTargets.reset(); for (var n = 0, o = this._beforeEvaluateActiveMeshStage; n < o.length; n++)o[n].action(); var s = this.getActiveMeshCandidates(), l = s.length; for (i = 0; i < l; i++) { var c; if ((c = s.data[i])._internalAbstractMeshDataInfo._currentLODIsUpToDate = !1, !c.isBlocked && (this._totalVertices.addCount(c.getTotalVertices(), !1), c.isReady() && c.isEnabled() && !c.scaling.hasAZeroComponent)) { c.computeWorldMatrix(), c.actionManager && c.actionManager.hasSpecificTriggers2(a.ACTION_OnIntersectionEnterTrigger, a.ACTION_OnIntersectionExitTrigger) && this._meshesForIntersections.pushNoDuplicate(c); var u = this.customLODSelector ? this.customLODSelector(c, this.activeCamera) : c.getLOD(this.activeCamera); if (c._internalAbstractMeshDataInfo._currentLOD = u, c._internalAbstractMeshDataInfo._currentLODIsUpToDate = !0, null != u && (u !== c && 0 !== u.billboardMode && u.computeWorldMatrix(), c._preActivate(), c.isVisible && c.visibility > 0 && 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; h < d.length; h++)d[h].action(c); c._activate(this._renderId, !1) && (c.isAnInstance ? c._internalAbstractMeshDataInfo._actAsRegularMesh && (u = c) : u._internalAbstractMeshDataInfo._onlyForInstances = !1, u._internalAbstractMeshDataInfo._isActive = !0, this._activeMesh(c, u)), c._postActivate() } } } if (this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this), this.particlesEnabled) { this.onBeforeParticlesRenderingObservable.notifyObservers(this); for (var p = 0; p < this.particleSystems.length; p++) { var f = this.particleSystems[p]; if (f.isStarted() && f.emitter) { var _ = f.emitter; _.position && !_.isEnabled() || (this._activeParticleSystems.push(f), f.animate(), this._renderingManager.dispatchParticles(f)) } } this.onAfterParticlesRenderingObservable.notifyObservers(this) } } }, t.prototype._activeMesh = function (e, t) { this._skeletonsEnabled && null !== t.skeleton && void 0 !== t.skeleton && (this._activeSkeletons.pushNoDuplicate(t.skeleton) && (t.skeleton.prepare(), this._activeBones.addCount(t.skeleton.bones.length, !1)), t.computeBonesUsingShaders || this._softwareSkinnedMeshes.pushNoDuplicate(t)); var i = e.hasInstances || e.isAnInstance || this.dispatchAllSubMeshesOfActiveMeshes || this._skipFrustumClipping || t.alwaysSelectAsActiveMesh; if (t && t.subMeshes && t.subMeshes.length > 0) { var r = this.getActiveSubMeshCandidates(t), n = r.length; i = i || 1 === n; for (var o = 0; o < n; o++) { var a = r.data[o]; this._evaluateSubMesh(a, t, e, i) } } }, t.prototype.updateTransformMatrix = function (e) { if (this.activeCamera) if (this.activeCamera._renderingMultiview) { var t = this.activeCamera._rigCameras[0], i = this.activeCamera._rigCameras[1]; this.setTransformMatrix(t.getViewMatrix(), t.getProjectionMatrix(e), i.getViewMatrix(), i.getProjectionMatrix(e)) } else this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(e)) }, t.prototype._bindFrameBuffer = function (e, t) { void 0 === t && (t = !0), e && e._multiviewTexture ? e._multiviewTexture._bindFrameBuffer() : e && e.outputRenderTarget ? e.outputRenderTarget._bindFrameBuffer() : this._engine._currentFrameBufferIsDefaultFrameBuffer() || this._engine.restoreDefaultFramebuffer(), t && this._clearFrameBuffer(e) }, t.prototype._clearFrameBuffer = function (e) { if (e && e._multiviewTexture); else if (e && e.outputRenderTarget && !e._renderingMultiview) { var t = e.outputRenderTarget; t.onClearObservable.hasObservers() ? t.onClearObservable.notifyObservers(this._engine) : t.skipInitialClear || (this.autoClear && this._engine.clear(t.clearColor || this.clearColor, !t._cleared, !0, !0), t._cleared = !0) } else this._defaultFrameBufferCleared ? this._engine.clear(null, !1, !0, !0) : (this._defaultFrameBufferCleared = !0, this._clear()) }, t.prototype._renderForCamera = function (e, t, i) { var r, n, o; if (void 0 === i && (i = !0), !e || !e._skipRendering) { var s = this._engine; if (this._activeCamera = e, !this.activeCamera) throw new Error("Active camera not set"); if (s.setViewport(this.activeCamera.viewport), this.resetCachedMaterial(), this._renderId++, !this.prePass && i) { var l = !0; e._renderingMultiview && e.outputRenderTarget && (l = e.outputRenderTarget.skipInitialClear, this.autoClear && (this._defaultFrameBufferCleared = !1, e.outputRenderTarget.skipInitialClear = !1)), this._bindFrameBuffer(this._activeCamera), e._renderingMultiview && e.outputRenderTarget && (e.outputRenderTarget.skipInitialClear = l) } this.updateTransformMatrix(), this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera), this._evaluateActiveMeshes(); for (var c = 0; c < this._softwareSkinnedMeshes.length; c++) { var u = this._softwareSkinnedMeshes.data[c]; u.applySkeleton(u.skeleton) } this.onBeforeRenderTargetsRenderObservable.notifyObservers(this), this._renderTargets.concatWithNoDuplicate(this._materialsRenderTargets), e.customRenderTargets && e.customRenderTargets.length > 0 && 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; h < d.length; h++)d[h].action(this._renderTargets); var p = !1; if (this.renderTargetsEnabled) { if (this._intermediateRendering = !0, this._renderTargets.length > 0) { xi.StartPerformanceCounter("Render targets", this._renderTargets.length > 0); for (var f = 0; f < this._renderTargets.length; f++) { var _ = this._renderTargets.data[f]; if (_._shouldRender()) { this._renderId++; var m = _.activeCamera && _.activeCamera !== this.activeCamera; _.render(m, this.dumpNextRenderTargets), p = !0 } } xi.EndPerformanceCounter("Render targets", this._renderTargets.length > 0), this._renderId++ } for (var g = 0, v = this._cameraDrawRenderTargetStage; g < v.length; g++)p = v[g].action(this.activeCamera) || p; this._intermediateRendering = !1 } this._engine.currentRenderPassId = null !== (o = null !== (n = null === (r = e.outputRenderTarget) || void 0 === r ? void 0 : r.renderPassId) && void 0 !== n ? n : e.renderPassId) && void 0 !== o ? o : a.RENDERPASS_MAIN, p && !this.prePass && this._bindFrameBuffer(this._activeCamera, !1), this.onAfterRenderTargetsRenderObservable.notifyObservers(this), !this.postProcessManager || e._multiviewTexture || this.prePass || this.postProcessManager._prepareFrame(); for (var y = 0, b = this._beforeCameraDrawStage; y < b.length; y++)b[y].action(this.activeCamera); this.onBeforeDrawPhaseObservable.notifyObservers(this), s.snapshotRendering && s.snapshotRenderingMode === a.SNAPSHOTRENDERING_FAST && this.finalizeSceneUbo(), this._renderingManager.render(null, null, !0, !0), this.onAfterDrawPhaseObservable.notifyObservers(this); for (var T = 0, E = this._afterCameraDrawStage; T < E.length; T++)E[T].action(this.activeCamera); if (this.postProcessManager && !e._multiviewTexture) { var S = e.outputRenderTarget ? e.outputRenderTarget.renderTarget : void 0; this.postProcessManager._finalizeFrame(e.isIntermediate, S) } for (var x = 0, A = this._afterCameraPostProcessStage; x < A.length; x++)A[x].action(this.activeCamera); this._renderTargets.reset(), this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera) } }, t.prototype._processSubCameras = function (e, t) { if (void 0 === t && (t = !0), e.cameraRigMode === a.RIG_MODE_NONE || e._renderingMultiview) return e._renderingMultiview && !this._multiviewSceneUbo && this._createMultiviewUbo(), this._renderForCamera(e, void 0, t), void this.onAfterRenderCameraObservable.notifyObservers(e); if (e._useMultiviewToSingleView) this._renderMultiviewToSingleView(e); else { this.onBeforeCameraRenderObservable.notifyObservers(e); for (var i = 0; i < e._rigCameras.length; i++)this._renderForCamera(e._rigCameras[i], e) } this._activeCamera = e, this.updateTransformMatrix(), this.onAfterRenderCameraObservable.notifyObservers(e) }, t.prototype._checkIntersections = function () { for (var e = 0; e < this._meshesForIntersections.length; e++) { var t = this._meshesForIntersections.data[e]; if (t.actionManager) for (var i = function (e) { var i = t.actionManager.actions[e]; if (i.trigger === a.ACTION_OnIntersectionEnterTrigger || i.trigger === a.ACTION_OnIntersectionExitTrigger) { var r = i.getTriggerParameter(), n = r.mesh ? r.mesh : r, o = n.intersectsMesh(t, r.usePreciseIntersection), s = t._intersectionsInProgress.indexOf(n); o && -1 === s ? i.trigger === a.ACTION_OnIntersectionEnterTrigger ? (i._executeCurrent(G.CreateNew(t, void 0, n)), t._intersectionsInProgress.push(n)) : i.trigger === a.ACTION_OnIntersectionExitTrigger && t._intersectionsInProgress.push(n) : !o && s > -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 && r < t.actionManager.actions.length; r++)i(r) } }, t.prototype._advancePhysicsEngineStep = function (e) { }, t.prototype._animate = function () { }, t.prototype.animate = function () { if (this._engine.isDeterministicLockStep()) { var e = Math.max(t.MinDeltaTime, Math.min(this._engine.getDeltaTime(), t.MaxDeltaTime)) + this._timeAccumulator, i = this._engine.getTimeStep(), r = 1e3 / i / 1e3, n = 0, o = this._engine.getLockstepMaxSteps(), a = Math.floor(e / i); for (a = Math.min(a, o); e > 0 && n < a;)this.onBeforeStepObservable.notifyObservers(this), this._animationRatio = i * r, this._animate(), this.onAfterAnimationsObservable.notifyObservers(this), this.physicsEnabled && this._advancePhysicsEngineStep(i), this.onAfterStepObservable.notifyObservers(this), this._currentStepId++, n++, e -= i; this._timeAccumulator = e < 0 ? 0 : e } else e = this.useConstantAnimationDeltaTime ? 16 : Math.max(t.MinDeltaTime, Math.min(this._engine.getDeltaTime(), t.MaxDeltaTime)), this._animationRatio = .06 * e, this._animate(), this.onAfterAnimationsObservable.notifyObservers(this), this.physicsEnabled && this._advancePhysicsEngineStep(e) }, t.prototype._clear = function () { (this.autoClearDepthAndStencil || this.autoClear) && this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil) }, t.prototype._checkCameraRenderTarget = function (e) { var t; if ((null == e ? void 0 : e.outputRenderTarget) && !(null == e ? void 0 : e.isRigCamera) && (e.outputRenderTarget._cleared = !1), null === (t = null == e ? void 0 : e.rigCameras) || void 0 === t ? void 0 : t.length) for (var i = 0; i < e.rigCameras.length; ++i) { var r = e.rigCameras[i].outputRenderTarget; r && (r._cleared = !1) } }, t.prototype.resetDrawCache = function (e) { if (this.meshes) for (var t = 0, i = this.meshes; t < i.length; t++)i[t].resetDrawCache(e) }, t.prototype.render = function (e, t) { var i, r, n; if (void 0 === e && (e = !0), void 0 === t && (t = !1), !this.isDisposed) { this.onReadyObservable.hasObservers() && null === this._executeWhenReadyTimeoutId && this._checkIsReady(), this._frameId++, this._defaultFrameBufferCleared = !1, this._checkCameraRenderTarget(this.activeCamera), (null === (i = this.activeCameras) || void 0 === i ? void 0 : i.length) && this.activeCameras.forEach(this._checkCameraRenderTarget), this._registerTransientComponents(), this._activeParticles.fetchNewFrame(), this._totalVertices.fetchNewFrame(), this._activeIndices.fetchNewFrame(), this._activeBones.fetchNewFrame(), this._meshesForIntersections.reset(), this.resetCachedMaterial(), this.onBeforeAnimationsObservable.notifyObservers(this), this.actionManager && this.actionManager.processTrigger(a.ACTION_OnEveryFrameTrigger), t || this.animate(); for (var o = 0, s = this._beforeCameraUpdateStage; o < s.length; o++)s[o].action(); if (e) if (this.activeCameras && this.activeCameras.length > 0) for (var l = 0; l < this.activeCameras.length; l++) { var c = this.activeCameras[l]; if (c.update(), c.cameraRigMode !== a.RIG_MODE_NONE) for (var u = 0; u < c._rigCameras.length; u++)c._rigCameras[u].update() } else if (this.activeCamera && (this.activeCamera.update(), this.activeCamera.cameraRigMode !== a.RIG_MODE_NONE)) for (u = 0; u < this.activeCamera._rigCameras.length; u++)this.activeCamera._rigCameras[u].update(); this.onBeforeRenderObservable.notifyObservers(this); var h = this.getEngine(); this.onBeforeRenderTargetsRenderObservable.notifyObservers(this); var d = (null === (r = this.activeCameras) || void 0 === r ? void 0 : r.length) ? this.activeCameras[0] : this.activeCamera; if (this.renderTargetsEnabled) { xi.StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0), this._intermediateRendering = !0; for (var p = 0; p < this.customRenderTargets.length; p++) { var f = this.customRenderTargets[p]; if (f._shouldRender()) { if (this._renderId++, this.activeCamera = f.activeCamera || this.activeCamera, !this.activeCamera) throw new Error("Active camera not set"); h.setViewport(this.activeCamera.viewport), this.updateTransformMatrix(), f.render(d !== this.activeCamera, this.dumpNextRenderTargets) } } xi.EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0), 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; _ < m.length; _++)m[_].action(); this._clearFrameBuffer(this.activeCamera); for (var g = 0, v = this._gatherRenderTargetsStage; g < v.length; g++)v[g].action(this._renderTargets); if (this.activeCameras && this.activeCameras.length > 0) for (l = 0; l < this.activeCameras.length; l++)this._processSubCameras(this.activeCameras[l], l > 0); 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 < b.length; y++)b[y].action(); if (this.afterRender && this.afterRender(), this.onAfterRenderObservable.notifyObservers(this), this._toBeDisposed.length) { for (u = 0; u < this._toBeDisposed.length; u++) { var T = this._toBeDisposed[u]; T && T.dispose() } this._toBeDisposed.length = 0 } this.dumpNextRenderTargets && (this.dumpNextRenderTargets = !1), this._activeBones.addCount(0, !0), this._activeIndices.addCount(0, !0), this._activeParticles.addCount(0, !0), this._engine.restoreDefaultFramebuffer() } }, t.prototype.freezeMaterials = function () { for (var e = 0; e < this.materials.length; e++)this.materials[e].freeze() }, t.prototype.unfreezeMaterials = function () { for (var e = 0; e < this.materials.length; e++)this.materials[e].unfreeze() }, t.prototype.dispose = function () { if (!this.isDisposed) { this.beforeRender = null, this.afterRender = null, this.metadata = null, this.skeletons.length = 0, this.morphTargetManagers.length = 0, this._transientComponents.length = 0, this._isReadyForMeshStage.clear(), this._beforeEvaluateActiveMeshStage.clear(), this._evaluateSubMeshStage.clear(), this._preActiveMeshStage.clear(), this._cameraDrawRenderTargetStage.clear(), this._beforeCameraDrawStage.clear(), this._beforeRenderTargetDrawStage.clear(), this._beforeRenderingGroupDrawStage.clear(), this._beforeRenderingMeshStage.clear(), this._afterRenderingMeshStage.clear(), this._afterRenderingGroupDrawStage.clear(), this._afterCameraDrawStage.clear(), this._afterRenderTargetDrawStage.clear(), this._afterRenderStage.clear(), this._beforeCameraUpdateStage.clear(), this._beforeClearStage.clear(), this._gatherRenderTargetsStage.clear(), this._gatherActiveCameraRenderTargetsStage.clear(), this._pointerMoveStage.clear(), this._pointerDownStage.clear(), this._pointerUpStage.clear(), this.importedMeshesFiles = new Array, this.stopAllAnimations && (this._activeAnimatables.forEach((function (e) { e.onAnimationEndObservable.clear(), e.onAnimationEnd = null })), this.stopAllAnimations()), this.resetCachedMaterial(), this.activeCamera && (this.activeCamera._activeMeshes.dispose(), this.activeCamera = null), this.activeCameras = null, this._activeMeshes.dispose(), this._renderingManager.dispose(), this._processedMaterials.dispose(), this._activeParticleSystems.dispose(), this._activeSkeletons.dispose(), this._softwareSkinnedMeshes.dispose(), this._renderTargets.dispose(), this._materialsRenderTargets.dispose(), this._registeredForLateAnimationBindings.dispose(), this._meshesForIntersections.dispose(), this._toBeDisposed.length = 0; for (var e = 0, t = this._activeRequests.slice(); e < t.length; e++)t[e].abort(); this._activeRequests.length = 0; try { this.onDisposeObservable.notifyObservers(this) } catch (e) { console.error("An error occurred while calling onDisposeObservable!", e) } if (this.detachControl(), this._engine.getInputElement()) for (var i = 0; i < this.cameras.length; i++)this.cameras[i].detachControl(); this._disposeList(this.animationGroups), this._disposeList(this.lights), this._disposeList(this.meshes, (function (e) { return e.dispose(!0) })), this._disposeList(this.transformNodes, (function (e) { return e.dispose(!0) })); var r = this.cameras; this._disposeList(r), this._defaultMaterial && this._defaultMaterial.dispose(), this._disposeList(this.multiMaterials), this._disposeList(this.materials), this._disposeList(this.particleSystems), this._disposeList(this.postProcesses), this._disposeList(this.textures), this._disposeList(this.morphTargetManagers), this._sceneUbo.dispose(), this._multiviewSceneUbo && this._multiviewSceneUbo.dispose(), this.postProcessManager.dispose(), this._disposeList(this._components); var n = this._engine.scenes.indexOf(this); n > -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 < r.length; i++)t(r[i]); e.length = 0 }, Object.defineProperty(t.prototype, "isDisposed", { get: function () { return this._isDisposed }, enumerable: !1, configurable: !0 }), t.prototype.clearCachedVertexData = function () { for (var e = 0; e < this.meshes.length; e++) { var t = this.meshes[e].geometry; t && t.clearCachedData() } }, t.prototype.cleanCachedTextureBuffer = function () { for (var e = 0, t = this.textures; e < t.length; e++) { var i = t[e]; i._buffer && (i._buffer = null) } }, t.prototype.getWorldExtends = function (e) { var t = new R(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), i = new R(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE); return e = e || function () { return !0 }, this.meshes.filter(e).forEach((function (e) { if (e.computeWorldMatrix(!0), e.subMeshes && 0 !== e.subMeshes.length && !e.infiniteDistance) { var r = e.getBoundingInfo(), n = r.boundingBox.minimumWorld, o = r.boundingBox.maximumWorld; R.CheckExtends(n, t, i), R.CheckExtends(o, t, i) } })), { min: t, max: i } }, t.prototype.createPickingRay = function (e, t, i, r, n) { throw void 0 === n && (n = !1), ge("Ray") }, t.prototype.createPickingRayToRef = function (e, t, i, r, n, o, a) { throw void 0 === o && (o = !1), void 0 === a && (a = !1), ge("Ray") }, t.prototype.createPickingRayInCameraSpace = function (e, t, i) { throw ge("Ray") }, t.prototype.createPickingRayInCameraSpaceToRef = function (e, t, i, r) { throw ge("Ray") }, Object.defineProperty(t.prototype, "_pickingAvailable", { get: function () { return !1 }, enumerable: !1, configurable: !0 }), t.prototype.pick = function (e, t, i, r, n, o) { return new Xi }, t.prototype.pickWithBoundingInfo = function (e, t, i, r, n) { return new Xi }, t.prototype.pickWithRay = function (e, t, i, r) { throw ge("Ray") }, t.prototype.multiPick = function (e, t, i, r, n) { throw ge("Ray") }, t.prototype.multiPickWithRay = function (e, t, i) { throw ge("Ray") }, t.prototype.setPointerOverMesh = function (e, t, i) { this._inputManager.setPointerOverMesh(e, t, i) }, t.prototype.getPointerOverMesh = function () { return this._inputManager.getPointerOverMesh() }, t.prototype._rebuildGeometries = function () { for (var e = 0, t = this.geometries; e < t.length; e++)t[e]._rebuild(); for (var i = 0, r = this.meshes; i < r.length; i++)r[i]._rebuild(); this.postProcessManager && this.postProcessManager._rebuild(); for (var n = 0, o = this._components; n < o.length; n++)o[n].rebuild(); for (var a = 0, s = this.particleSystems; a < s.length; a++)s[a].rebuild(); if (this.spriteManagers) for (var l = 0, c = this.spriteManagers; l < c.length; l++)c[l].rebuild() }, t.prototype._rebuildTextures = function () { for (var e = 0, t = this.textures; e < t.length; e++)t[e]._rebuild(); this.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag) }, t.prototype._getByTags = function (e, t, i) { if (void 0 === t) return e; var r = []; for (var n in i = i || function (e) { }, e) { var o = e[n]; me && me.MatchesQuery(o, t) && (r.push(o), i(o)) } return r }, t.prototype.getMeshesByTags = function (e, t) { return this._getByTags(this.meshes, e, t) }, t.prototype.getCamerasByTags = function (e, t) { return this._getByTags(this.cameras, e, t) }, t.prototype.getLightsByTags = function (e, t) { return this._getByTags(this.lights, e, t) }, t.prototype.getMaterialByTags = function (e, t) { return this._getByTags(this.materials, e, t).concat(this._getByTags(this.multiMaterials, e, t)) }, t.prototype.getTransformNodesByTags = function (e, t) { return this._getByTags(this.transformNodes, e, t) }, t.prototype.setRenderingOrder = function (e, t, i, r) { void 0 === t && (t = null), void 0 === i && (i = null), void 0 === r && (r = null), this._renderingManager.setRenderingOrder(e, t, i, r) }, t.prototype.setRenderingAutoClearDepthStencil = function (e, t, i, r) { void 0 === i && (i = !0), void 0 === r && (r = !0), this._renderingManager.setRenderingAutoClearDepthStencil(e, t, i, r) }, t.prototype.getAutoClearDepthStencilSetup = function (e) { return this._renderingManager.getAutoClearDepthStencilSetup(e) }, Object.defineProperty(t.prototype, "blockMaterialDirtyMechanism", { get: function () { return this._blockMaterialDirtyMechanism }, set: function (e) { this._blockMaterialDirtyMechanism !== e && (this._blockMaterialDirtyMechanism = e, e || this.markAllMaterialsAsDirty(a.MATERIAL_AllDirtyFlag)) }, enumerable: !1, configurable: !0 }), t.prototype.markAllMaterialsAsDirty = function (e, t) { if (!this._blockMaterialDirtyMechanism) for (var i = 0, r = this.materials; i < r.length; i++) { var n = r[i]; t && !t(n) || n.markAsDirty(e) } }, t.prototype._loadFile = function (e, t, i, r, n, o, a) { var s = this, l = di(e, t, i, r ? this.offlineProvider : void 0, n, o, a); return this._activeRequests.push(l), l.onCompleteObservable.add((function (e) { s._activeRequests.splice(s._activeRequests.indexOf(e), 1) })), l }, t.prototype._loadFileAsync = function (e, t, i, r, n) { var o = this; return new Promise((function (a, s) { o._loadFile(e, (function (e) { a(e) }), t, i, r, (function (e, t) { s(t) }), n) })) }, t.prototype._requestFile = function (e, t, i, r, n, o, a) { var s = this, l = pi(e, t, i, r ? this.offlineProvider : void 0, n, o, a); return this._activeRequests.push(l), l.onCompleteObservable.add((function (e) { s._activeRequests.splice(s._activeRequests.indexOf(e), 1) })), l }, t.prototype._requestFileAsync = function (e, t, i, r, n) { var o = this; return new Promise((function (a, s) { o._requestFile(e, (function (e) { a(e) }), t, i, r, (function (e) { s(e) }), n) })) }, t.prototype._readFile = function (e, t, i, r, n) { var o = this, a = hi(e, t, i, r, n); return this._activeRequests.push(a), a.onCompleteObservable.add((function (e) { o._activeRequests.splice(o._activeRequests.indexOf(e), 1) })), a }, t.prototype._readFileAsync = function (e, t, i) { var r = this; return new Promise((function (n, o) { r._readFile(e, (function (e) { n(e) }), t, i, (function (e) { o(e) })) })) }, t.prototype.getPerfCollector = function () { throw ge("performanceViewerSceneExtension") }, t.prototype.setActiveCameraByID = function (e) { return this.setActiveCameraById(e) }, t.prototype.getMaterialByID = function (e) { return this.getMaterialById(e) }, t.prototype.getLastMaterialByID = function (e) { return this.getLastMaterialById(e) }, t.prototype.getTextureByUniqueID = function (e) { return this.getTextureByUniqueId(e) }, t.prototype.getCameraByID = function (e) { return this.getCameraById(e) }, t.prototype.getCameraByUniqueID = function (e) { return this.getCameraByUniqueId(e) }, t.prototype.getBoneByID = function (e) { return this.getBoneById(e) }, t.prototype.getLightByID = function (e) { return this.getLightById(e) }, t.prototype.getLightByUniqueID = function (e) { return this.getLightByUniqueId(e) }, t.prototype.getParticleSystemByID = function (e) { return this.getParticleSystemById(e) }, t.prototype.getGeometryByID = function (e) { return this.getGeometryById(e) }, t.prototype.getMeshByID = function (e) { return this.getMeshById(e) }, t.prototype.getMeshByUniqueID = function (e) { return this.getMeshByUniqueId(e) }, t.prototype.getLastMeshByID = function (e) { return this.getLastMeshById(e) }, t.prototype.getMeshesByID = function (e) { return this.getMeshesById(e) }, t.prototype.getTransformNodeByID = function (e) { return this.getTransformNodeById(e) }, t.prototype.getTransformNodeByUniqueID = function (e) { return this.getTransformNodeByUniqueId(e) }, t.prototype.getTransformNodesByID = function (e) { return this.getTransformNodesById(e) }, t.prototype.getNodeByID = function (e) { return this.getNodeById(e) }, t.prototype.getLastEntryByID = function (e) { return this.getLastEntryById(e) }, t.prototype.getLastSkeletonByID = function (e) { return this.getLastSkeletonById(e) }, t.FOGMODE_NONE = 0, t.FOGMODE_EXP = 1, t.FOGMODE_EXP2 = 2, t.FOGMODE_LINEAR = 3, t.MinDeltaTime = 1, t.MaxDeltaTime = 1e3, t }(o); !function (e) { e[e.LOCAL = 0] = "LOCAL", e[e.WORLD = 1] = "WORLD", e[e.BONE = 2] = "BONE" }(Er || (Er = {})); var xr, Ar = function () { function e() { } return e.X = new R(1, 0, 0), e.Y = new R(0, 1, 0), e.Z = new R(0, 0, 1), e }(); !function (e) { e[e.X = 0] = "X", e[e.Y = 1] = "Y", e[e.Z = 2] = "Z" }(xr || (xr = {})); var Rr = function (e) { function t(t, i, r, n, o, a, s) { void 0 === r && (r = null), void 0 === n && (n = null), void 0 === o && (o = null), void 0 === a && (a = null), void 0 === s && (s = null); var l, c = this; return (c = e.call(this, t, i.getScene()) || this).name = t, c.children = new Array, c.animations = new Array, c._index = null, c._scalingDeterminant = 1, c._needToDecompose = !0, c._needToCompose = !1, c._linkedTransformNode = null, c._waitingTransformNodeId = null, c._skeleton = i, c._localMatrix = null !== (l = null == n ? void 0 : n.clone()) && void 0 !== l ? l : I.Identity(), c._restMatrix = null != o ? o : c._localMatrix.clone(), c._bindMatrix = null != a ? a : c._localMatrix.clone(), c._index = s, c._absoluteMatrix = new I, c._absoluteBindMatrix = new I, c._absoluteInverseBindMatrix = new I, c._finalMatrix = new I, i.bones.push(c), c.setParent(r, !1), c._updateAbsoluteBindMatrices(), c } return W(t, e), Object.defineProperty(t.prototype, "_matrix", { get: function () { return this._compose(), this._localMatrix }, set: function (e) { (e.updateFlag !== this._localMatrix.updateFlag || this._needToCompose) && (this._needToCompose = !1, this._localMatrix.copyFrom(e), this._markAsDirtyAndDecompose()) }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function () { return "Bone" }, t.prototype.getSkeleton = function () { return this._skeleton }, Object.defineProperty(t.prototype, "parent", { get: function () { return this._parentNode }, set: function (e) { this.setParent(e) }, enumerable: !1, configurable: !0 }), t.prototype.getParent = function () { return this.parent }, t.prototype.getChildren = function () { return this.children }, t.prototype.getIndex = function () { return null === this._index ? this.getSkeleton().bones.indexOf(this) : this._index }, t.prototype.setParent = function (e, t) { if (void 0 === t && (t = !0), this.parent !== e) { if (this.parent) { var i = this.parent.children.indexOf(this); -1 !== i && this.parent.children.splice(i, 1) } this._parentNode = e, this.parent && this.parent.children.push(this), t && this._updateAbsoluteBindMatrices(), this.markAsDirty() } }, t.prototype.getLocalMatrix = function () { return this._compose(), this._localMatrix }, t.prototype.getBindMatrix = function () { return this._bindMatrix }, t.prototype.getBaseMatrix = function () { return this.getBindMatrix() }, t.prototype.getRestMatrix = function () { return this._restMatrix }, t.prototype.getRestPose = function () { return this.getRestMatrix() }, t.prototype.setRestMatrix = function (e) { this._restMatrix.copyFrom(e) }, t.prototype.setRestPose = function (e) { this.setRestMatrix(e) }, t.prototype.getBindPose = function () { return this.getBindMatrix() }, t.prototype.setBindMatrix = function (e) { this.updateMatrix(e) }, t.prototype.setBindPose = function (e) { this.setBindMatrix(e) }, t.prototype.getFinalMatrix = function () { return this._finalMatrix }, t.prototype.getWorldMatrix = function () { return this.getFinalMatrix() }, t.prototype.returnToRest = function () { var e; if (this._linkedTransformNode) { var t = O.Vector3[0], i = O.Quaternion[0], r = O.Vector3[1]; this.getRestMatrix().decompose(t, i, r), this._linkedTransformNode.position.copyFrom(r), this._linkedTransformNode.rotationQuaternion = null !== (e = this._linkedTransformNode.rotationQuaternion) && void 0 !== e ? e : P.Identity(), this._linkedTransformNode.rotationQuaternion.copyFrom(i), this._linkedTransformNode.scaling.copyFrom(t) } else this._matrix = this._restMatrix }, t.prototype.getAbsoluteInverseBindMatrix = function () { return this._absoluteInverseBindMatrix }, t.prototype.getInvertedAbsoluteTransform = function () { return this.getAbsoluteInverseBindMatrix() }, t.prototype.getAbsoluteMatrix = function () { return this._absoluteMatrix }, t.prototype.getAbsoluteTransform = function () { return this._absoluteMatrix }, t.prototype.linkTransformNode = function (e) { this._linkedTransformNode && this._skeleton._numBonesWithLinkedTransformNode--, this._linkedTransformNode = e, this._linkedTransformNode && this._skeleton._numBonesWithLinkedTransformNode++ }, t.prototype.getTransformNode = function () { return this._linkedTransformNode }, Object.defineProperty(t.prototype, "position", { get: function () { return this._decompose(), this._localPosition }, set: function (e) { this._decompose(), this._localPosition.copyFrom(e), this._markAsDirtyAndCompose() }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rotation", { get: function () { return this.getRotation() }, set: function (e) { this.setRotation(e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rotationQuaternion", { get: function () { return this._decompose(), this._localRotation }, set: function (e) { this.setRotationQuaternion(e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "scaling", { get: function () { return this.getScale() }, set: function (e) { this.setScale(e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "animationPropertiesOverride", { get: function () { return this._skeleton.animationPropertiesOverride }, enumerable: !1, configurable: !0 }), t.prototype._decompose = function () { this._needToDecompose && (this._needToDecompose = !1, this._localScaling || (this._localScaling = R.Zero(), this._localRotation = P.Zero(), this._localPosition = R.Zero()), this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition)) }, t.prototype._compose = function () { this._needToCompose && (this._localScaling ? (this._needToCompose = !1, I.ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix)) : this._needToCompose = !1) }, t.prototype.updateMatrix = function (e, t, i) { void 0 === t && (t = !0), void 0 === i && (i = !0), this._bindMatrix.copyFrom(e), t && this._updateAbsoluteBindMatrices(), i ? this._matrix = e : this.markAsDirty() }, t.prototype._updateAbsoluteBindMatrices = function (e, t) { if (void 0 === t && (t = !0), e || (e = this._bindMatrix), this.parent ? e.multiplyToRef(this.parent._absoluteBindMatrix, this._absoluteBindMatrix) : this._absoluteBindMatrix.copyFrom(e), this._absoluteBindMatrix.invertToRef(this._absoluteInverseBindMatrix), t) for (var i = 0; i < this.children.length; i++)this.children[i]._updateAbsoluteBindMatrices(); this._scalingDeterminant = this._absoluteBindMatrix.determinant() < 0 ? -1 : 1 }, t.prototype.markAsDirty = function () { return this._currentRenderId++, this._childUpdateId++, this._skeleton._markAsDirty(), this }, t.prototype._markAsDirtyAndCompose = function () { this.markAsDirty(), this._needToCompose = !0 }, t.prototype._markAsDirtyAndDecompose = function () { this.markAsDirty(), this._needToDecompose = !0 }, t.prototype._updatePosition = function (e, i, r, n) { void 0 === i && (i = Er.LOCAL), void 0 === n && (n = !0); var o = this.getLocalMatrix(); if (i == Er.LOCAL) n ? (o.addAtIndex(12, e.x), o.addAtIndex(13, e.y), o.addAtIndex(14, e.z)) : o.setTranslationFromFloats(e.x, e.y, e.z); else { var a = null; r && (a = r.getWorldMatrix()), this._skeleton.computeAbsoluteMatrices(); var s = t._TmpMats[0], l = t._TmpVecs[0]; this.parent ? r && a ? (s.copyFrom(this.parent.getAbsoluteMatrix()), s.multiplyToRef(a, s)) : s.copyFrom(this.parent.getAbsoluteMatrix()) : I.IdentityToRef(s), n && s.setTranslationFromFloats(0, 0, 0), s.invert(), R.TransformCoordinatesToRef(e, s, l), n ? (o.addAtIndex(12, l.x), o.addAtIndex(13, l.y), o.addAtIndex(14, l.z)) : o.setTranslationFromFloats(l.x, l.y, l.z) } this._markAsDirtyAndDecompose() }, t.prototype.translate = function (e, t, i) { void 0 === t && (t = Er.LOCAL), this._updatePosition(e, t, i, !0) }, t.prototype.setPosition = function (e, t, i) { void 0 === t && (t = Er.LOCAL), this._updatePosition(e, t, i, !1) }, t.prototype.setAbsolutePosition = function (e, t) { this.setPosition(e, Er.WORLD, t) }, t.prototype.scale = function (e, i, r, n) { void 0 === n && (n = !1); var o = this.getLocalMatrix(), a = t._TmpMats[0]; I.ScalingToRef(e, i, r, a), a.multiplyToRef(o, o), a.invert(); for (var s = 0, l = this.children; s < l.length; s++) { var c = (d = l[s]).getLocalMatrix(); c.multiplyToRef(a, c), c.multiplyAtIndex(12, e), c.multiplyAtIndex(13, i), c.multiplyAtIndex(14, r), d._markAsDirtyAndDecompose() } if (this._markAsDirtyAndDecompose(), n) for (var u = 0, h = this.children; u < h.length; u++) { var d; (d = h[u]).scale(e, i, r, n) } }, t.prototype.setScale = function (e) { this._decompose(), this._localScaling.copyFrom(e), this._markAsDirtyAndCompose() }, t.prototype.getScale = function () { return this._decompose(), this._localScaling }, t.prototype.getScaleToRef = function (e) { this._decompose(), e.copyFrom(this._localScaling) }, t.prototype.setYawPitchRoll = function (e, i, r, n, o) { if (void 0 === n && (n = Er.LOCAL), n === Er.LOCAL) { var a = t._TmpQuat; return P.RotationYawPitchRollToRef(e, i, r, a), void this.setRotationQuaternion(a, n, o) } var s = t._TmpMats[0]; if (this._getAbsoluteInverseMatrixUnscaledToRef(s, o)) { var l = t._TmpMats[1]; I.RotationYawPitchRollToRef(e, i, r, l), s.multiplyToRef(l, l), this._rotateWithMatrix(l, n, o) } }, t.prototype.rotate = function (e, i, r, n) { void 0 === r && (r = Er.LOCAL); var o = t._TmpMats[0]; o.setTranslationFromFloats(0, 0, 0), I.RotationAxisToRef(e, i, o), this._rotateWithMatrix(o, r, n) }, t.prototype.setAxisAngle = function (e, i, r, n) { if (void 0 === r && (r = Er.LOCAL), r === Er.LOCAL) { var o = t._TmpQuat; return P.RotationAxisToRef(e, i, o), void this.setRotationQuaternion(o, r, n) } var a = t._TmpMats[0]; if (this._getAbsoluteInverseMatrixUnscaledToRef(a, n)) { var s = t._TmpMats[1]; I.RotationAxisToRef(e, i, s), a.multiplyToRef(s, s), this._rotateWithMatrix(s, r, n) } }, t.prototype.setRotation = function (e, t, i) { void 0 === t && (t = Er.LOCAL), this.setYawPitchRoll(e.y, e.x, e.z, t, i) }, t.prototype.setRotationQuaternion = function (e, i, r) { if (void 0 === i && (i = Er.LOCAL), i === Er.LOCAL) return this._decompose(), this._localRotation.copyFrom(e), void this._markAsDirtyAndCompose(); var n = t._TmpMats[0]; if (this._getAbsoluteInverseMatrixUnscaledToRef(n, r)) { var o = t._TmpMats[1]; I.FromQuaternionToRef(e, o), n.multiplyToRef(o, o), this._rotateWithMatrix(o, i, r) } }, t.prototype.setRotationMatrix = function (e, i, r) { if (void 0 === i && (i = Er.LOCAL), i === Er.LOCAL) { var n = t._TmpQuat; return P.FromRotationMatrixToRef(e, n), void this.setRotationQuaternion(n, i, r) } var o = t._TmpMats[0]; if (this._getAbsoluteInverseMatrixUnscaledToRef(o, r)) { var a = t._TmpMats[1]; a.copyFrom(e), o.multiplyToRef(e, a), this._rotateWithMatrix(a, i, r) } }, t.prototype._rotateWithMatrix = function (e, i, r) { void 0 === i && (i = Er.LOCAL); var n = this.getLocalMatrix(), o = n.m[12], a = n.m[13], s = n.m[14], l = this.getParent(), c = t._TmpMats[3], u = t._TmpMats[4]; l && i == Er.WORLD ? (r ? (c.copyFrom(r.getWorldMatrix()), l.getAbsoluteMatrix().multiplyToRef(c, c)) : c.copyFrom(l.getAbsoluteMatrix()), u.copyFrom(c), u.invert(), n.multiplyToRef(c, n), n.multiplyToRef(e, n), n.multiplyToRef(u, n)) : i == Er.WORLD && r ? (c.copyFrom(r.getWorldMatrix()), u.copyFrom(c), u.invert(), n.multiplyToRef(c, n), n.multiplyToRef(e, n), n.multiplyToRef(u, n)) : n.multiplyToRef(e, n), n.setTranslationFromFloats(o, a, s), this.computeAbsoluteMatrices(), this._markAsDirtyAndDecompose() }, t.prototype._getAbsoluteInverseMatrixUnscaledToRef = function (e, i) { var r = t._TmpMats[2]; return e.copyFrom(this.getAbsoluteMatrix()), i ? (e.multiplyToRef(i.getWorldMatrix(), e), I.ScalingToRef(i.scaling.x, i.scaling.y, i.scaling.z, r)) : I.IdentityToRef(r), e.invert(), !isNaN(e.m[0]) && (r.multiplyAtIndex(0, this._scalingDeterminant), e.multiplyToRef(r, e), !0) }, t.prototype.getPosition = function (e, t) { void 0 === e && (e = Er.LOCAL), void 0 === t && (t = null); var i = R.Zero(); return this.getPositionToRef(e, t, i), i }, t.prototype.getPositionToRef = function (e, i, r) { if (void 0 === e && (e = Er.LOCAL), e == Er.LOCAL) { var n = this.getLocalMatrix(); r.x = n.m[12], r.y = n.m[13], r.z = n.m[14] } else { var o = null; i && (o = i.getWorldMatrix()), this._skeleton.computeAbsoluteMatrices(); var a = t._TmpMats[0]; i && o ? (a.copyFrom(this.getAbsoluteMatrix()), a.multiplyToRef(o, a)) : a = this.getAbsoluteMatrix(), r.x = a.m[12], r.y = a.m[13], r.z = a.m[14] } }, t.prototype.getAbsolutePosition = function (e) { void 0 === e && (e = null); var t = R.Zero(); return this.getPositionToRef(Er.WORLD, e, t), t }, t.prototype.getAbsolutePositionToRef = function (e, t) { this.getPositionToRef(Er.WORLD, e, t) }, t.prototype.computeAbsoluteMatrices = function () { if (this._compose(), this.parent) this._localMatrix.multiplyToRef(this.parent._absoluteMatrix, this._absoluteMatrix); else { this._absoluteMatrix.copyFrom(this._localMatrix); var e = this._skeleton.getPoseMatrix(); e && this._absoluteMatrix.multiplyToRef(e, this._absoluteMatrix) } for (var t = this.children, i = t.length, r = 0; r < i; r++)t[r].computeAbsoluteMatrices() }, t.prototype.computeAbsoluteTransforms = function () { this.computeAbsoluteMatrices() }, t.prototype.getDirection = function (e, t) { void 0 === t && (t = null); var i = R.Zero(); return this.getDirectionToRef(e, t, i), i }, t.prototype.getDirectionToRef = function (e, i, r) { void 0 === i && (i = null); var n = null; i && (n = i.getWorldMatrix()), this._skeleton.computeAbsoluteMatrices(); var o = t._TmpMats[0]; o.copyFrom(this.getAbsoluteMatrix()), i && n && o.multiplyToRef(n, o), R.TransformNormalToRef(e, o, r), r.normalize() }, t.prototype.getRotation = function (e, t) { void 0 === e && (e = Er.LOCAL), void 0 === t && (t = null); var i = R.Zero(); return this.getRotationToRef(e, t, i), i }, t.prototype.getRotationToRef = function (e, i, r) { void 0 === e && (e = Er.LOCAL), void 0 === i && (i = null); var n = t._TmpQuat; this.getRotationQuaternionToRef(e, i, n), n.toEulerAnglesToRef(r) }, t.prototype.getRotationQuaternion = function (e, t) { void 0 === e && (e = Er.LOCAL), void 0 === t && (t = null); var i = P.Identity(); return this.getRotationQuaternionToRef(e, t, i), i }, t.prototype.getRotationQuaternionToRef = function (e, i, r) { if (void 0 === e && (e = Er.LOCAL), void 0 === i && (i = null), e == Er.LOCAL) this._decompose(), r.copyFrom(this._localRotation); else { var n = t._TmpMats[0], o = this.getAbsoluteMatrix(); i ? o.multiplyToRef(i.getWorldMatrix(), n) : n.copyFrom(o), n.multiplyAtIndex(0, this._scalingDeterminant), n.multiplyAtIndex(1, this._scalingDeterminant), n.multiplyAtIndex(2, this._scalingDeterminant), n.decompose(void 0, r, void 0) } }, t.prototype.getRotationMatrix = function (e, t) { void 0 === e && (e = Er.LOCAL); var i = I.Identity(); return this.getRotationMatrixToRef(e, t, i), i }, t.prototype.getRotationMatrixToRef = function (e, i, r) { if (void 0 === e && (e = Er.LOCAL), e == Er.LOCAL) this.getLocalMatrix().getRotationMatrixToRef(r); else { var n = t._TmpMats[0], o = this.getAbsoluteMatrix(); i ? o.multiplyToRef(i.getWorldMatrix(), n) : n.copyFrom(o), n.multiplyAtIndex(0, this._scalingDeterminant), n.multiplyAtIndex(1, this._scalingDeterminant), n.multiplyAtIndex(2, this._scalingDeterminant), n.getRotationMatrixToRef(r) } }, t.prototype.getAbsolutePositionFromLocal = function (e, t) { void 0 === t && (t = null); var i = R.Zero(); return this.getAbsolutePositionFromLocalToRef(e, t, i), i }, t.prototype.getAbsolutePositionFromLocalToRef = function (e, i, r) { void 0 === i && (i = null); var n = null; i && (n = i.getWorldMatrix()), this._skeleton.computeAbsoluteMatrices(); var o = t._TmpMats[0]; o.copyFrom(this.getAbsoluteMatrix()), i && n && o.multiplyToRef(n, o), R.TransformCoordinatesToRef(e, o, r) }, t.prototype.getLocalPositionFromAbsolute = function (e, t) { void 0 === t && (t = null); var i = R.Zero(); return this.getLocalPositionFromAbsoluteToRef(e, t, i), i }, t.prototype.getLocalPositionFromAbsoluteToRef = function (e, i, r) { void 0 === i && (i = null); var n = null; i && (n = i.getWorldMatrix()), this._skeleton.computeAbsoluteMatrices(); var o = t._TmpMats[0]; o.copyFrom(this.getAbsoluteMatrix()), i && n && o.multiplyToRef(n, o), o.invert(), R.TransformCoordinatesToRef(e, o, r) }, t.prototype.setCurrentPoseAsRest = function () { this.setRestMatrix(this.getLocalMatrix()) }, t._TmpVecs = m.BuildArray(2, R.Zero), t._TmpQuat = P.Identity(), t._TmpMats = m.BuildArray(5, I.Identity), t }(ze), Cr = function () { function e(e, t, i, r, n, o, a, s, l, c, h) { void 0 === i && (i = 0), void 0 === r && (r = 100), void 0 === n && (n = !1), void 0 === o && (o = 1), void 0 === c && (c = !1), void 0 === h && (h = 0), this.target = t, this.fromFrame = i, this.toFrame = r, this.loopAnimation = n, this.onAnimationEnd = a, this.onAnimationLoop = l, this.isAdditive = c, this.playOrder = h, this._localDelayOffset = null, this._pausedDelay = null, this._manualJumpDelay = null, this._runtimeAnimations = new Array, this._paused = !1, this._speedRatio = 1, this._weight = -1, this._syncRoot = null, this._frameToSyncFromJump = null, this._goToFrame = null, this.disposeOnEnd = !0, this.animationStarted = !1, this.onAnimationEndObservable = new u, this.onAnimationLoopObservable = new u, this._scene = e, s && this.appendAnimations(t, s), this._speedRatio = o, e._activeAnimatables.push(this) } return Object.defineProperty(e.prototype, "syncRoot", { get: function () { return this._syncRoot }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "masterFrame", { get: function () { return 0 === this._runtimeAnimations.length ? 0 : this._runtimeAnimations[0].currentFrame }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "weight", { get: function () { return this._weight }, set: function (e) { this._weight = -1 !== e ? Math.min(Math.max(e, 0), 1) : -1 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "speedRatio", { get: function () { return this._speedRatio }, set: function (e) { for (var t = 0; t < this._runtimeAnimations.length; t++)this._runtimeAnimations[t]._prepareForSpeedRatioChange(e); this._speedRatio = e, null !== this._goToFrame && this.goToFrame(this._goToFrame) }, enumerable: !1, configurable: !0 }), e.prototype.syncWith = function (e) { if (this._syncRoot = e, e) { var t = this._scene._activeAnimatables.indexOf(this); t > -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 < t.length; r++) { var n = t[r], o = new $e(e, n, this._scene, this); o._onLoop = function () { i.onAnimationLoopObservable.notifyObservers(i), i.onAnimationLoop && i.onAnimationLoop() }, this._runtimeAnimations.push(o) } }, e.prototype.getAnimationByTargetProperty = function (e) { for (var t = this._runtimeAnimations, i = 0; i < t.length; i++)if (t[i].animation.targetProperty === e) return t[i].animation; return null }, e.prototype.getRuntimeAnimationByTargetProperty = function (e) { for (var t = this._runtimeAnimations, i = 0; i < t.length; i++)if (t[i].animation.targetProperty === e) return t[i]; return null }, e.prototype.reset = function () { for (var e = this._runtimeAnimations, t = 0; t < e.length; t++)e[t].reset(!0); this._localDelayOffset = null, this._pausedDelay = null }, e.prototype.enableBlending = function (e) { for (var t = this._runtimeAnimations, i = 0; i < t.length; i++)t[i].animation.enableBlending = !0, t[i].animation.blendingSpeed = e }, e.prototype.disableBlending = function () { for (var e = this._runtimeAnimations, t = 0; t < e.length; t++)e[t].animation.enableBlending = !1 }, e.prototype.goToFrame = function (e) { var t, i = this._runtimeAnimations; if (i[0]) { var r = i[0].animation.framePerSecond; this._frameToSyncFromJump = null !== (t = this._frameToSyncFromJump) && void 0 !== t ? t : i[0].currentFrame; var n = 0 === this.speedRatio ? 0 : (e - this._frameToSyncFromJump) / r * 1e3 / this.speedRatio; this._manualJumpDelay = -n } for (var o = 0; o < i.length; o++)i[o].goToFrame(e); this._goToFrame = e }, e.prototype.pause = function () { this._paused || (this._paused = !0) }, e.prototype.restart = function () { this._paused = !1 }, e.prototype._raiseOnAnimationEnd = function () { this.onAnimationEnd && this.onAnimationEnd(), this.onAnimationEndObservable.notifyObservers(this) }, e.prototype.stop = function (e, t, i) { if (void 0 === i && (i = !1), e || t) { var r = this._scene._activeAnimatables.indexOf(this); if (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; s < a.length; s++)a[s].dispose(); this._runtimeAnimations.length = 0, this._raiseOnAnimationEnd() } }, e.prototype.waitAsync = function () { var e = this; return new Promise((function (t) { e.onAnimationEndObservable.add((function () { t(e) }), void 0, void 0, e, !0) })) }, e.prototype._animate = function (e) { if (this._paused) return this.animationStarted = !1, null === this._pausedDelay && (this._pausedDelay = e), !0; if (null === this._localDelayOffset ? (this._localDelayOffset = e, this._pausedDelay = null) : null !== this._pausedDelay && (this._localDelayOffset += e - this._pausedDelay, this._pausedDelay = null), null !== this._manualJumpDelay && (this._localDelayOffset += this._manualJumpDelay, this._manualJumpDelay = null, this._frameToSyncFromJump = null), this._goToFrame = null, 0 === this._weight) return !0; var t, i = !1, r = this._runtimeAnimations; for (t = 0; t < r.length; t++) { var n = r[t].animate(e - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight); i = i || n } if (this.animationStarted = i, !i) { if (this.disposeOnEnd) for (t = this._scene._activeAnimatables.indexOf(this), this._scene._activeAnimatables.splice(t, 1), t = 0; t < r.length; t++)r[t].dispose(); this._raiseOnAnimationEnd(), this.disposeOnEnd && (this.onAnimationEnd = null, this.onAnimationLoop = null, this.onAnimationLoopObservable.clear(), this.onAnimationEndObservable.clear()) } return i }, e }(); Sr.prototype._animate = function () { if (this.animationsEnabled) { var e = at.Now; if (!this._animationTimeLast) { if (this._pendingData.length > 0) 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; r < t.length; r++) { var n = t[r]; !n._animate(i) && n.disposeOnEnd && r-- } this._processLateAnimationBindings() } } }, Sr.prototype.sortActiveAnimatables = function () { this._activeAnimatables.sort((function (e, t) { return e.playOrder - t.playOrder })) }, Sr.prototype.beginWeightedAnimation = function (e, t, i, r, n, o, a, s, l, c, u) { void 0 === r && (r = 1), void 0 === o && (o = 1), void 0 === u && (u = !1); var h = this.beginAnimation(e, t, i, n, o, a, s, !1, l, c, u); return h.weight = r, h }, Sr.prototype.beginAnimation = function (e, t, i, r, n, o, a, s, l, c, u) { void 0 === n && (n = 1), void 0 === s && (s = !0), void 0 === u && (u = !1), t > i && n > 0 && (n *= -1), s && this.stopAnimation(e, void 0, l), a || (a = new Cr(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; p < d.length; p++)this.beginAnimation(d[p], t, i, r, n, o, a, s, l, c); return a.reset(), a }, Sr.prototype.beginHierarchyAnimation = function (e, t, i, r, n, o, a, s, l, c, u, h) { void 0 === o && (o = 1), void 0 === l && (l = !0), void 0 === h && (h = !1); var d = e.getDescendants(t), p = []; p.push(this.beginAnimation(e, i, r, n, o, a, s, l, c, void 0, h)); for (var f = 0, _ = d; f < _.length; f++) { var m = _[f]; p.push(this.beginAnimation(m, i, r, n, o, a, s, l, c, void 0, h)) } return p }, Sr.prototype.beginDirectAnimation = function (e, t, i, r, n, o, a, s, l) { if (void 0 === l && (l = !1), void 0 === o && (o = 1), i > r && o > 0) o *= -1; else if (r > i && o < 0) { var c = r; r = i, i = c } return new Cr(this, e, i, r, n, o, a, t, s, l) }, Sr.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; d < p.length; d++) { var f = p[d]; h.push(this.beginDirectAnimation(f, i, r, n, o, a, s, l, c)) } return h }, Sr.prototype.getAnimatableByTarget = function (e) { for (var t = 0; t < this._activeAnimatables.length; t++)if (this._activeAnimatables[t].target === e) return this._activeAnimatables[t]; return null }, Sr.prototype.getAllAnimatablesByTarget = function (e) { for (var t = [], i = 0; i < this._activeAnimatables.length; i++)this._activeAnimatables[i].target === e && t.push(this._activeAnimatables[i]); return t }, Sr.prototype.stopAnimation = function (e, t, i) { for (var r = 0, n = this.getAllAnimatablesByTarget(e); r < n.length; r++)n[r].stop(t, i) }, Sr.prototype.stopAllAnimations = function () { if (this._activeAnimatables) { for (var e = 0; e < this._activeAnimatables.length; e++)this._activeAnimatables[e].stop(void 0, void 0, !0); this._activeAnimatables.length = 0 } for (var t = 0, i = this.animationGroups; t < i.length; t++)i[t].stop() }, Sr.prototype._registerTargetForLateAnimationBinding = function (e, t) { var i = e.target; this._registeredForLateAnimationBindings.pushNoDuplicate(i), i._lateAnimationHolders || (i._lateAnimationHolders = {}), i._lateAnimationHolders[e.targetPath] || (i._lateAnimationHolders[e.targetPath] = { totalWeight: 0, totalAdditiveWeight: 0, animations: [], additiveAnimations: [], originalValue: t }), e.isAdditive ? (i._lateAnimationHolders[e.targetPath].additiveAnimations.push(e), i._lateAnimationHolders[e.targetPath].totalAdditiveWeight += e.weight) : (i._lateAnimationHolders[e.targetPath].animations.push(e), i._lateAnimationHolders[e.targetPath].totalWeight += e.weight) }, Sr.prototype._processLateAnimationBindingsForMatrices = function (e) { if (0 === e.totalWeight && 0 === e.totalAdditiveWeight) return e.originalValue; var t = 1, i = O.Vector3[0], r = O.Vector3[1], n = O.Quaternion[0], o = 0, a = e.animations[0], s = e.originalValue, l = 1, c = !1; if (e.totalWeight < 1) l = 1 - e.totalWeight, s.decompose(r, n, i); else { if (o = 1, t = e.totalWeight, 1 == (l = a.weight / t)) { if (!e.totalAdditiveWeight) return a.currentValue; c = !0 } a.currentValue.decompose(r, n, i) } if (!c) { r.scaleInPlace(l), i.scaleInPlace(l), n.scaleInPlace(l); for (var u = o; u < e.animations.length; u++)if (0 !== (f = e.animations[u]).weight) { l = f.weight / t; var h = O.Vector3[2], d = O.Vector3[3], p = O.Quaternion[1]; f.currentValue.decompose(d, p, h), d.scaleAndAddToRef(l, r), p.scaleAndAddToRef(P.Dot(n, p) > 0 ? l : -l, n), h.scaleAndAddToRef(l, i) } n.normalize() } for (u = 0; u < e.additiveAnimations.length; u++) { var f; 0 !== (f = e.additiveAnimations[u]).weight && (h = O.Vector3[2], d = O.Vector3[3], p = O.Quaternion[1], f.currentValue.decompose(d, p, h), d.multiplyToRef(r, d), R.LerpToRef(r, d, f.weight, r), n.multiplyToRef(p, p), P.SlerpToRef(n, p, f.weight, n), h.scaleAndAddToRef(f.weight, i)) } var _ = a ? a._animationState.workValue : O.Matrix[0].clone(); return I.ComposeToRef(r, n, i, _), _ }, Sr.prototype._processLateAnimationBindingsForQuaternions = function (e, t) { if (0 === e.totalWeight && 0 === e.totalAdditiveWeight) return t; var i = e.animations[0], r = e.originalValue, n = t; if (0 === e.totalWeight && e.totalAdditiveWeight > 0) 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 < e.animations.length; c++) { var u = e.animations[c]; a.push(u.currentValue), s.push(u.weight / o) } for (var h = 0, d = 0; d < a.length;)d ? (h += s[d], P.SlerpToRef(n, a[d], s[d] / h, n), d++) : (P.SlerpToRef(a[d], a[d + 1], s[d + 1] / (s[d] + s[d + 1]), t), n = t, h = s[d] + s[d + 1], d += 2) } for (c = 0; c < e.additiveAnimations.length; c++)0 !== (u = e.additiveAnimations[c]).weight && (n.multiplyToRef(u.currentValue, O.Quaternion[0]), P.SlerpToRef(n, O.Quaternion[0], u.weight, n)); return n }, Sr.prototype._processLateAnimationBindings = function () { if (this._registeredForLateAnimationBindings.length) { for (var e = 0; e < this._registeredForLateAnimationBindings.length; e++) { var t = this._registeredForLateAnimationBindings.data[e]; for (var i in t._lateAnimationHolders) { var r = t._lateAnimationHolders[i], n = r.animations[0], o = r.originalValue; if (null != o) { var a = je.AllowMatrixDecomposeForInterpolation && o.m, s = t[i]; if (a) s = this._processLateAnimationBindingsForMatrices(r); else if (void 0 !== o.w) s = this._processLateAnimationBindingsForQuaternions(r, s || P.Identity()); else { var l = 0, c = 1; r.totalWeight < 1 ? s = n && o.scale ? o.scale(1 - r.totalWeight) : n ? o * (1 - r.totalWeight) : o.clone ? o.clone() : o : n && (c = r.totalWeight, s = 1 != (d = n.weight / c) ? n.currentValue.scale ? n.currentValue.scale(d) : n.currentValue * d : n.currentValue, l = 1); for (var u = l; u < r.animations.length; u++)(d = (h = r.animations[u]).weight / c) && (h.currentValue.scaleAndAddToRef ? h.currentValue.scaleAndAddToRef(d, s) : s += h.currentValue * d); for (u = 0; u < r.additiveAnimations.length; u++) { var h, d; (d = (h = r.additiveAnimations[u]).weight) && (h.currentValue.scaleAndAddToRef ? h.currentValue.scaleAndAddToRef(d, s) : s += h.currentValue * d) } } t[i] = s } } t._lateAnimationHolders = {} } this._registeredForLateAnimationBindings.reset() } }, Rr.prototype.copyAnimationRange = function (e, t, i, r, n) { void 0 === r && (r = !1), void 0 === n && (n = null), 0 === this.animations.length && (this.animations.push(new je(this.name, "_matrix", e.animations[0].framePerSecond, je.ANIMATIONTYPE_MATRIX, 0)), this.animations[0].setKeys([])); var o = e.animations[0].getRange(t); if (!o) return !1; for (var a, s, l, c = o.from, u = o.to, h = e.animations[0].getKeys(), d = e.length, p = e.getParent(), f = this.getParent(), _ = r && p && d && this.length && d !== this.length, m = _ && f && p ? f.length / p.length : 1, g = r && !f && n && (1 !== n.x || 1 !== n.y || 1 !== n.z), v = this.animations[0].getKeys(), y = 0, b = h.length; y < b; y++)(a = h[y]).frame >= 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 Pr, Ir = function () { this.enableBlending = !1, this.blendingSpeed = .01, this.loopMode = je.ANIMATIONLOOPMODE_CYCLE }; !function (e) { e[e.CW = 0] = "CW", e[e.CCW = 1] = "CCW" }(Pr || (Pr = {})); var Mr = 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 }(), Or = 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 }(), Dr = 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 = Or.BetweenTwoPoints(this.centerPoint, this.startPoint); var s = this.startAngle.degrees(), l = Or.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees(), c = Or.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 ? Pr.CW : Pr.CCW, this.angle = Or.FromDegrees(this.orientation === Pr.CW ? s - c : c - s) }, Nr = 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 Dr(o, a, s), c = l.angle.radians() / n; l.orientation === Pr.CW && (c *= -1); for (var u = l.startAngle.radians() + c, h = 0; h < n; h++) { var d = Math.cos(u) * l.radius + l.centerPoint.x, p = Math.sin(u) * l.radius + l.centerPoint.y; this.addLineTo(d, p), u += c } return this }, e.prototype.addQuadraticCurveTo = function (e, t, i, r, n) { if (void 0 === n && (n = 36), this.closed) return this; for (var o = function (e, t, i, r) { return (1 - e) * (1 - e) * t + 2 * e * (1 - e) * i + e * e * r }, a = this._points[this._points.length - 1], s = 0; s <= n; s++) { var l = s / n, c = o(l, a.x, e, i), u = o(l, a.y, t, r); this.addLineTo(c, u) } return this }, e.prototype.addBezierCurveTo = function (e, t, i, r, n, o, a) { if (void 0 === a && (a = 36), this.closed) return this; for (var 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 = this._points[this._points.length - 1], c = 0; c <= a; c++) { var u = c / a, h = s(u, l.x, e, i, n), d = s(u, l.y, t, r, o); this.addLineTo(h, d) } return this }, e.prototype.isPointInside = function (e) { for (var t = !1, i = this._points.length, r = i - 1, n = 0; n < i; r = n++) { var o = this._points[r], a = this._points[n], s = a.x - o.x, l = a.y - o.y; if (Math.abs(l) > Number.EPSILON) { if (l < 0 && (o = this._points[n], s = -s, a = this._points[r], l = -l), e.y < o.y || e.y > a.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; r < e; i = r++)t += this._points[i].x * this._points[r].y - this._points[r].x * this._points[i].y; return .5 * t }, e.prototype.getPoints = function () { return this._points }, e.prototype.getPointAtLengthPosition = function (e) { if (e < 0 || e > 1) return A.Zero(); for (var t = e * this.length(), i = 0, r = 0; r < this._points.length; r++) { var n = (r + 1) % this._points.length, o = this._points[r], a = this._points[n].subtract(o), s = a.length() + i; if (t >= 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 }(), Fr = 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; n < e.length; n++)this._curve[n] = e[n].clone(); this._raw = i || !1, this._alignTangentsWithPath = r, this._compute(t, r) } return e.prototype.getCurve = function () { return this._curve }, e.prototype.getPoints = function () { return this._curve }, e.prototype.length = function () { return this._distances[this._distances.length - 1] }, e.prototype.getTangents = function () { return this._tangents }, e.prototype.getNormals = function () { return this._normals }, e.prototype.getBinormals = function () { return this._binormals }, e.prototype.getDistances = function () { return this._distances }, e.prototype.getPointAt = function (e) { return this._updatePointAtData(e).point }, e.prototype.getTangentAt = function (e, t) { return void 0 === t && (t = !1), this._updatePointAtData(e, t), t ? R.TransformCoordinates(R.Forward(), this._pointAtData.interpolationMatrix) : this._tangents[this._pointAtData.previousPointArrayIndex] }, e.prototype.getNormalAt = function (e, t) { return void 0 === t && (t = !1), this._updatePointAtData(e, t), t ? R.TransformCoordinates(R.Right(), this._pointAtData.interpolationMatrix) : this._normals[this._pointAtData.previousPointArrayIndex] }, e.prototype.getBinormalAt = function (e, t) { return void 0 === t && (t = !1), this._updatePointAtData(e, t), t ? R.TransformCoordinates(R.UpReadOnly, this._pointAtData.interpolationMatrix) : this._binormals[this._pointAtData.previousPointArrayIndex] }, e.prototype.getDistanceAt = function (e) { return this.length() * e }, e.prototype.getPreviousPointIndexAt = function (e) { return this._updatePointAtData(e), this._pointAtData.previousPointArrayIndex }, e.prototype.getSubPositionAt = function (e) { return this._updatePointAtData(e), this._pointAtData.subPosition }, e.prototype.getClosestPositionTo = function (e) { for (var t = Number.MAX_VALUE, i = 0, r = 0; r < this._curve.length - 1; r++) { var n = this._curve[r + 0], o = this._curve[r + 1].subtract(n).normalize(), a = this._distances[r + 1] - this._distances[r + 0], s = Math.min(Math.max(R.Dot(o, e.subtract(n).normalize()), 0) * R.Distance(n, e) / a, 1), l = R.Distance(n.add(o.scale(s * a)), e); l < t && (t = l, i = (this._distances[r + 0] + a * s) / this.length()) } return i }, e.prototype.slice = function (t, i) { if (void 0 === t && (t = 0), void 0 === i && (i = 1), t < 0 && (t = 1 - -1 * t % 1), i < 0 && (i = 1 - -1 * i % 1), t > i) { 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; r < e.length; r++)this._curve[r].x = e[r].x, this._curve[r].y = e[r].y, this._curve[r].z = e[r].z; return this._compute(t, i), this }, e.prototype._compute = function (e, t) { void 0 === t && (t = !1); var i = this._curve.length; if (!(i < 2)) { this._tangents[0] = this._getFirstNonNullVector(0), this._raw || this._tangents[0].normalize(), this._tangents[i - 1] = this._curve[i - 1].subtract(this._curve[i - 2]), this._raw || this._tangents[i - 1].normalize(); var r, n, o, a, s, l = this._tangents[0], c = this._normalVector(l, e); this._normals[0] = c, this._raw || this._normals[0].normalize(), this._binormals[0] = R.Cross(l, this._normals[0]), this._raw || this._binormals[0].normalize(), this._distances[0] = 0; for (var u = 1; u < i; u++)r = this._getLastNonNullVector(u), u < i - 1 && (n = this._getFirstNonNullVector(u), this._tangents[u] = t ? n : r.add(n), this._tangents[u].normalize()), this._distances[u] = this._distances[u - 1] + this._curve[u].subtract(this._curve[u - 1]).length(), o = this._tangents[u], s = this._binormals[u - 1], this._normals[u] = R.Cross(s, o), this._raw || (0 === this._normals[u].length() ? (a = this._normals[u - 1], this._normals[u] = a.clone()) : this._normals[u].normalize()), this._binormals[u] = R.Cross(o, this._normals[u]), this._raw || this._binormals[u].normalize(); this._pointAtData.id = NaN } }, e.prototype._getFirstNonNullVector = function (e) { for (var t = 1, i = this._curve[e + t].subtract(this._curve[e]); 0 === i.length() && e + t + 1 < this._curve.length;)t++, i = this._curve[e + t].subtract(this._curve[e]); return i }, e.prototype._getLastNonNullVector = function (e) { for (var t = 1, i = this._curve[e].subtract(this._curve[e - t]); 0 === i.length() && e > t + 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; s < i.length; s++) { r = i[s]; var l = R.Distance(n, r); if ((o += l) === a) return this._setPointAtData(e, 1, r, s, t); if (o > a) { 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 }(), Lr = 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 < s; l++) { a = 0; for (var c = 0; c < i; c++)n.push(R.CatmullRom(t[l % s], t[(l + 1) % s], t[(l + 2) % s], t[(l + 3) % s], a)), a += o } n.push(n[0]) } else { var u = new Array; for (u.push(t[0].clone()), Array.prototype.push.apply(u, t), u.push(t[t.length - 1].clone()), l = 0; l < u.length - 3; l++)for (a = 0, c = 0; c < i; c++)n.push(R.CatmullRom(u[l], u[l + 1], u[l + 2], u[l + 3], a)), a += o; l--, n.push(R.CatmullRom(u[l], u[l + 1], u[l + 2], u[l + 3], a)) } return new e(n) }, e.ArcThru3Points = function (t, i, r, n, o, a) { void 0 === n && (n = 32), void 0 === o && (o = !1), void 0 === a && (a = !1); var s = new Array, l = i.subtract(t), c = r.subtract(i), u = t.subtract(r), h = R.Cross(l, c), d = h.length(); if (d < Math.pow(10, -8)) return new e(s); var p = l.lengthSquared(), f = c.lengthSquared(), _ = u.lengthSquared(), m = h.lengthSquared(), g = .5 * l.length() * c.length() * u.length() / d, v = -.5 * f * R.Dot(l, u) / m, y = -.5 * _ * R.Dot(l, c) / m, b = -.5 * p * R.Dot(c, u) / m, T = t.scale(v).add(i.scale(y)).add(r.scale(b)), E = t.subtract(T).normalize(), S = R.Cross(h, E).normalize(); if (a) { for (var x = 2 * Math.PI / n, A = 0; A <= 2 * Math.PI; A += x)s.push(T.add(E.scale(g * Math.cos(A)).add(S.scale(g * Math.sin(A))))); s.push(t) } else { x = 1 / n, A = 0; var C = R.Zero(); do { C = T.add(E.scale(g * Math.cos(A)).add(S.scale(g * Math.sin(A)))), s.push(C), A += x } while (!C.equalsWithEpsilon(r, g * x * 1.1)); s.push(r), o && s.push(t) } return new e(s) }, e.prototype.getPoints = function () { return this._points }, e.prototype.length = function () { return this._length }, e.prototype.continue = function (t) { for (var i = this._points[this._points.length - 1], r = this._points.slice(), n = t.getPoints(), o = 1; o < n.length; o++)r.push(n[o].subtract(n[0]).add(i)); return new e(r) }, e.prototype._computeLength = function (e) { for (var t = 0, i = 1; i < e.length; i++)t += e[i].subtract(e[i - 1]).length(); return t }, e }(), wr = function () { function e() { this._easingMode = e.EASINGMODE_EASEIN } return e.prototype.setEasingMode = function (e) { var t = Math.min(Math.max(e, 0), 2); this._easingMode = t }, e.prototype.getEasingMode = function () { return this._easingMode }, e.prototype.easeInCore = function (e) { throw new Error("You must implement this method") }, e.prototype.ease = function (t) { switch (this._easingMode) { case e.EASINGMODE_EASEIN: return this.easeInCore(t); case e.EASINGMODE_EASEOUT: return 1 - this.easeInCore(1 - t) }return t >= .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 }(), Br = 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 }(wr), Ur = 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 }(wr), Vr = 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 }(wr), 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 }, t }(wr), Gr = 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 }(wr), zr = 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 }(wr), Wr = 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 }(wr), Hr = 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 }(wr), Xr = 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 }(wr), jr = 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 }(wr), Yr = 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 }(wr), Kr = 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 Mr.Interpolate(e, this.x1, this.y1, this.x2, this.y2) }, t }(wr), Qr = 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 }(), qr = 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 }(), Zr = 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._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 Object.defineProperty(e.prototype, "from", { get: function () { return this._from }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "to", { get: function () { return this._to }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isStarted", { get: function () { return this._isStarted }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isPlaying", { get: function () { return this._isStarted && !this._isPaused }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "speedRatio", { get: function () { return this._speedRatio }, set: function (e) { if (this._speedRatio !== e) { this._speedRatio = e; for (var t = 0; t < this._animatables.length; t++)this._animatables[t].speedRatio = this._speedRatio } }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "loopAnimation", { get: function () { return this._loopAnimation }, set: function (e) { if (this._loopAnimation !== e) { this._loopAnimation = e; for (var t = 0; t < this._animatables.length; t++)this._animatables[t].loopAnimation = this._loopAnimation } }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isAdditive", { get: function () { return this._isAdditive }, set: function (e) { if (this._isAdditive !== e) { this._isAdditive = e; for (var t = 0; t < this._animatables.length; t++)this._animatables[t].isAdditive = this._isAdditive } }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "weight", { get: function () { return this._weight }, set: function (e) { this._weight !== e && (this._weight = e, this.setWeightForAllAnimatables(this._weight)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "targetedAnimations", { get: function () { return this._targetedAnimations }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "animatables", { get: function () { return this._animatables }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "children", { get: function () { return this._targetedAnimations }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "playOrder", { get: function () { return this._playOrder }, set: function (e) { if (this._playOrder !== e && (this._playOrder = e, this._animatables.length > 0)) { for (var t = 0; t < this._animatables.length; t++)this._animatables[t].playOrder = this._playOrder; this._scene.sortActiveAnimatables() } }, enumerable: !1, configurable: !0 }), e.prototype.enableBlending = function (e) { for (var t = 0; t < this._targetedAnimations.length; ++t)this._targetedAnimations[t].animation.enableBlending = !0, this._targetedAnimations[t].animation.blendingSpeed = e }, e.prototype.disableBlending = function () { for (var e = 0; e < this._targetedAnimations.length; ++e)this._targetedAnimations[e].animation.enableBlending = !1 }, e.MergeAnimationGroups = function (t, i, r, n) { if (void 0 === i && (i = !0), void 0 === r && (r = !1), 0 === t.length) return null; n = null != n ? n : t[0].weight; var o = Number.MAX_VALUE, a = Number.MIN_VALUE; if (r) for (var s = 0, l = t; s < l.length; s++)(d = l[s]).from < o && (o = d.from), d.to > a && (a = d.to); for (var c = new e(t[0].name + "_merged", t[0]._scene, n), u = 0, h = t; u < h.length; u++) { var d = h[u]; r && d.normalize(o, a); for (var p = 0, f = d.targetedAnimations; p < f.length; p++) { var _ = f[p]; c.addTargetedAnimation(_.animation, _.target) } i && d.dispose() } return c }, e.prototype.addTargetedAnimation = function (e, t) { var i = new qr; i.animation = e, i.target = t; var r = e.getKeys(); return this._from > r[0].frame && (this._from = r[0].frame), this._to < r[r.length - 1].frame && (this._to = r[r.length - 1].frame), this._targetedAnimations.push(i), i }, e.prototype.removeTargetedAnimation = function (e) { for (var t = this._targetedAnimations.length - 1; t > -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; i < this._targetedAnimations.length; i++) { var r = this._targetedAnimations[i].animation.getKeys(), n = r[0], o = r[r.length - 1]; if (n.frame > e) { var a = { frame: e, value: n.value, inTangent: n.inTangent, outTangent: n.outTangent, interpolation: n.interpolation }; r.splice(0, 0, a) } o.frame < t && (a = { frame: t, value: o.value, inTangent: o.inTangent, outTangent: o.outTangent, interpolation: o.interpolation }, r.push(a)) } return this._from = e, this._to = t, this }, e.prototype._processLoop = function (e, t, i) { var r = this; e.onAnimationLoop = function () { r.onAnimationLoopObservable.notifyObservers(t), r._animationLoopFlags[i] || (r._animationLoopFlags[i] = !0, r._animationLoopCount++, r._animationLoopCount === r._targetedAnimations.length && (r.onAnimationGroupLoopObservable.notifyObservers(r), r._animationLoopCount = 0, r._animationLoopFlags.length = 0)) } }, e.prototype.start = function (e, t, i, r, n) { var o = this; if (void 0 === e && (e = !1), void 0 === t && (t = 1), this._isStarted || 0 === this._targetedAnimations.length) return this; this._loopAnimation = e, this._animationLoopCount = 0, this._animationLoopFlags.length = 0; for (var a = function (a) { var l = s._targetedAnimations[a], c = s._scene.beginDirectAnimation(l.target, [l.animation], void 0 !== i ? i : s._from, void 0 !== r ? r : s._to, e, t, void 0, void 0, void 0 !== n ? n : s._isAdditive); c.weight = s._weight, c.playOrder = s._playOrder, c.onAnimationEnd = function () { o.onAnimationEndObservable.notifyObservers(l), o._checkAnimationGroupEnded(c) }, s._processLoop(c, l, a), s._animatables.push(c) }, s = this, l = 0; l < this._targetedAnimations.length; l++)a(l); return this._scene.sortActiveAnimatables(), this._speedRatio = t, this._isStarted = !0, this._isPaused = !1, this.onAnimationGroupPlayObservable.notifyObservers(this), this }, e.prototype.pause = function () { if (!this._isStarted) return this; this._isPaused = !0; for (var e = 0; e < this._animatables.length; e++)this._animatables[e].pause(); return this.onAnimationGroupPauseObservable.notifyObservers(this), this }, e.prototype.play = function (e) { return this.isStarted && this._animatables.length === this._targetedAnimations.length ? (void 0 !== e && (this.loopAnimation = e), this.restart()) : (this.stop(), this.start(e, this._speedRatio)), this._isPaused = !1, this }, e.prototype.reset = function () { if (!this._isStarted) return this.play(), this.goToFrame(0), this.stop(), this; for (var e = 0; e < this._animatables.length; e++)this._animatables[e].reset(); return this }, e.prototype.restart = function () { if (!this._isStarted) return this; for (var e = 0; e < this._animatables.length; e++)this._animatables[e].restart(); return this.onAnimationGroupPlayObservable.notifyObservers(this), this }, e.prototype.stop = function () { if (!this._isStarted) return this; for (var e = this._animatables.slice(), t = 0; t < e.length; t++)e[t].stop(void 0, void 0, !0); var i = 0; for (t = 0; t < this._scene._activeAnimatables.length; t++) { var r = this._scene._activeAnimatables[t]; r._runtimeAnimations.length > 0 && (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 < this._animatables.length; t++)this._animatables[t].weight = e; return this }, e.prototype.syncAllAnimationsWith = function (e) { for (var t = 0; t < this._animatables.length; t++)this._animatables[t].syncWith(e); return this }, e.prototype.goToFrame = function (e) { if (!this._isStarted) return this; for (var t = 0; t < this._animatables.length; t++)this._animatables[t].goToFrame(e); return this }, e.prototype.dispose = function () { this._targetedAnimations.length = 0, this._animatables.length = 0; var e = this._scene.animationGroups.indexOf(this); if (e > -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); for (var n = new e(t || this.name, this._scene), o = 0, a = this._targetedAnimations; o < a.length; o++) { var s = a[o]; n.addTargetedAnimation(r ? s.animation.clone() : s.animation, i ? i(s.target) : s.target) } return n }, e.prototype.serialize = function () { var e = {}; e.name = this.name, e.from = this.from, e.to = this.to, e.targetedAnimations = []; for (var t = 0; t < this.targetedAnimations.length; t++) { var i = this.targetedAnimations[t]; e.targetedAnimations[t] = i.serialize() } return me && me.HasTags(this) && (e.tags = me.GetTags(this)), this.metadata && (e.metadata = this.metadata), e }, e.Parse = function (t, i) { for (var r = new e(t.name, i), n = 0; n < t.targetedAnimations.length; n++) { var o = t.targetedAnimations[n], a = je.Parse(o.animation), s = o.targetId; if ("influence" === o.animation.property) { var l = i.getMorphTargetById(s); l && r.addTargetedAnimation(a, l) } else { var c = i.getNodeById(s); null != c && r.addTargetedAnimation(a, c) } } return null !== t.from && null !== t.to && r.normalize(t.from, t.to), me && me.AddTagsTo(r, t.tags), void 0 !== t.metadata && (r.metadata = t.metadata), r }, e.MakeAnimationAdditive = function (e, t, i, r, n) { void 0 === t && (t = 0), void 0 === r && (r = !1); var o = e; r && (o = e.clone(n || o.name)); for (var a = o.targetedAnimations, s = 0; s < a.length; s++) { var l = a[s]; je.MakeAnimationAdditive(l.animation, t, i) } return o.isAdditive = !0, o }, e.prototype.getClassName = function () { return "AnimationGroup" }, e.prototype.toString = function (e) { var t = "Name: " + this.name; return t += ", type: " + this.getClassName(), e && (t += ", from: " + this._from, t += ", to: " + this._to, t += ", isStarted: " + this._isStarted, t += ", speedRatio: " + this._speedRatio, t += ", targetedAnimations length: " + this._targetedAnimations.length, t += ", animatables length: " + this._animatables), t }, e }(), Jr = function () { function e(e) { this._path = e, this._onchange = new Array, this.value = 0, this.animations = new Array } return e.prototype.getPoint = function () { var e = this._path.getPointAtLengthPosition(this.value); return new R(e.x, 0, e.y) }, e.prototype.moveAhead = function (e) { return void 0 === e && (e = .002), this.move(e), this }, e.prototype.moveBack = function (e) { return void 0 === e && (e = .002), this.move(-e), this }, e.prototype.move = function (e) { if (Math.abs(e) > 1) 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 $r(e, t, i) { try { var r = e.next(); r.done ? t(r) : r.value ? r.value.then((function () { r.value = void 0, t(r) }), i) : t(r) } catch (e) { i(e) } } function en(e) { var t; return void 0 === e && (e = 25), function (i, r, n) { var o = performance.now(); void 0 === t || o - t > e ? (t = o, setTimeout((function () { $r(i, r, n) }), 0)) : $r(i, r, n) } } function tn(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 rn(e, t) { var i; return tn(e, $r, (function (e) { return i = e }), (function (e) { throw e }), t), i } function nn(e, t, i) { return new Promise((function (r, n) { tn(e, t, r, n, i) })) } function on(e, t) { return function () { for (var i = [], r = 0; r < arguments.length; r++)i[r] = arguments[r]; return rn(e.apply(void 0, i), t) } } function an(e, t, i) { return function () { for (var r = [], n = 0; n < arguments.length; n++)r[n] = arguments[n]; return nn(e.apply(void 0, r), t, i) } } var sn = function () { function e(e, t, i, r) { this.x = e, this.y = t, this.width = i, this.height = r } return e.prototype.toGlobal = function (t, i) { return new e(this.x * t, this.y * i, this.width * t, this.height * i) }, e.prototype.toGlobalToRef = function (e, t, i) { return i.x = this.x * e, i.y = this.y * t, i.width = this.width * e, i.height = this.height * t, this }, e.prototype.clone = function () { return new e(this.x, this.y, this.width, this.height) }, e }(), ln = function (e) { function t(i, r, n, o) { void 0 === o && (o = !0); var a = e.call(this, i, n) || this; return a._position = R.Zero(), a._upVector = R.Up(), a._orthoLeft = null, a._orthoRight = null, a._orthoBottom = null, a._orthoTop = null, a.fov = .8, a.projectionPlaneTilt = 0, a.minZ = 1, a.maxZ = 1e4, a.inertia = .9, a._mode = t.PERSPECTIVE_CAMERA, a.isIntermediate = !1, a.viewport = new sn(0, 0, 1, 1), a.layerMask = 268435455, a.fovMode = t.FOVMODE_VERTICAL_FIXED, a.cameraRigMode = t.RIG_MODE_NONE, a.customRenderTargets = new Array, a.outputRenderTarget = null, a.onViewMatrixChangedObservable = new u, a.onProjectionMatrixChangedObservable = new u, a.onAfterCheckInputsObservable = new u, a.onRestoreStateObservable = new u, a.isRigCamera = !1, a._rigCameras = new Array, a._webvrViewMatrix = I.Identity(), a._skipRendering = !1, a._projectionMatrix = new I, a._postProcesses = new Array, a._activeMeshes = new Ci(256), a._globalPosition = R.Zero(), a._computedViewMatrix = I.Identity(), a._doNotComputeProjectionMatrix = !1, a._transformMatrix = I.Zero(), a._refreshFrustumPlanes = !0, a._absoluteRotation = P.Identity(), a._isCamera = !0, a._isLeftCamera = !1, a._isRightCamera = !1, a.getScene().addCamera(a), o && !a.getScene().activeCamera && (a.getScene().activeCamera = a), a.position = r, a.renderPassId = a.getScene().getEngine().createRenderPassId("Camera ".concat(i)), a } return W(t, e), Object.defineProperty(t.prototype, "position", { get: function () { return this._position }, set: function (e) { this._position = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "upVector", { get: function () { return this._upVector }, set: function (e) { this._upVector = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "screenArea", { get: function () { var e, i, r, n, o = 0, a = 0; if (this.mode === t.PERSPECTIVE_CAMERA) this.fovMode === t.FOVMODE_VERTICAL_FIXED ? (a = 2 * this.minZ * Math.tan(this.fov / 2), o = this.getEngine().getAspectRatio(this) * a) : a = (o = 2 * this.minZ * Math.tan(this.fov / 2)) / this.getEngine().getAspectRatio(this); else { var s = this.getEngine().getRenderWidth() / 2, l = this.getEngine().getRenderHeight() / 2; o = (null !== (e = this.orthoRight) && void 0 !== e ? e : s) - (null !== (i = this.orthoLeft) && void 0 !== i ? i : -s), a = (null !== (r = this.orthoTop) && void 0 !== r ? r : l) - (null !== (n = this.orthoBottom) && void 0 !== n ? n : -l) } return o * a }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "orthoLeft", { get: function () { return this._orthoLeft }, set: function (e) { this._orthoLeft = e; for (var t = 0, i = this._rigCameras; t < i.length; t++)i[t].orthoLeft = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "orthoRight", { get: function () { return this._orthoRight }, set: function (e) { this._orthoRight = e; for (var t = 0, i = this._rigCameras; t < i.length; t++)i[t].orthoRight = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "orthoBottom", { get: function () { return this._orthoBottom }, set: function (e) { this._orthoBottom = e; for (var t = 0, i = this._rigCameras; t < i.length; t++)i[t].orthoBottom = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "orthoTop", { get: function () { return this._orthoTop }, set: function (e) { this._orthoTop = e; for (var t = 0, i = this._rigCameras; t < i.length; t++)i[t].orthoTop = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "mode", { get: function () { return this._mode }, set: function (e) { this._mode = e; for (var t = 0, i = this._rigCameras; t < i.length; t++)i[t].mode = e }, enumerable: !1, configurable: !0 }), t.prototype.storeState = function () { return this._stateStored = !0, this._storedFov = this.fov, this }, t.prototype._restoreStateValues = function () { return !!this._stateStored && (this.fov = this._storedFov, !0) }, t.prototype.restoreState = function () { return !!this._restoreStateValues() && (this.onRestoreStateObservable.notifyObservers(this), !0) }, t.prototype.getClassName = function () { return "Camera" }, t.prototype.toString = function (e) { var t = "Name: " + this.name; if (t += ", type: " + this.getClassName(), this.animations) for (var i = 0; i < this.animations.length; i++)t += ", animation[0]: " + this.animations[i].toString(e); return t }, t.prototype.applyVerticalCorrection = function () { var e = this.absoluteRotation.toEulerAngles(); this.projectionPlaneTilt = this._scene.useRightHandedSystem ? -e.x : e.x }, Object.defineProperty(t.prototype, "globalPosition", { get: function () { return this._globalPosition }, enumerable: !1, configurable: !0 }), t.prototype.getActiveMeshes = function () { return this._activeMeshes }, t.prototype.isActiveMesh = function (e) { return -1 !== this._activeMeshes.indexOf(e) }, t.prototype.isReady = function (t) { if (void 0 === t && (t = !1), t) for (var i = 0, r = this._postProcesses; i < r.length; i++) { var n = r[i]; if (n && !n.isReady()) return !1 } return e.prototype.isReady.call(this, t) }, t.prototype._initCache = function () { e.prototype._initCache.call(this), this._cache.position = new R(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), this._cache.upVector = new R(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), this._cache.mode = void 0, this._cache.minZ = void 0, this._cache.maxZ = void 0, this._cache.fov = void 0, this._cache.fovMode = void 0, this._cache.aspectRatio = void 0, this._cache.orthoLeft = void 0, this._cache.orthoRight = void 0, this._cache.orthoBottom = void 0, this._cache.orthoTop = void 0, this._cache.renderWidth = void 0, this._cache.renderHeight = void 0 }, t.prototype._updateCache = function (t) { t || e.prototype._updateCache.call(this), this._cache.position.copyFrom(this.position), this._cache.upVector.copyFrom(this.upVector) }, t.prototype._isSynchronized = function () { return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix() }, t.prototype._isSynchronizedViewMatrix = function () { return !!e.prototype._isSynchronized.call(this) && this._cache.position.equals(this.position) && this._cache.upVector.equals(this.upVector) && this.isSynchronizedWithParent() }, t.prototype._isSynchronizedProjectionMatrix = function () { var e = this._cache.mode === this.mode && this._cache.minZ === this.minZ && this._cache.maxZ === this.maxZ; if (!e) return !1; var i = this.getEngine(); return this.mode === t.PERSPECTIVE_CAMERA ? this._cache.fov === this.fov && this._cache.fovMode === this.fovMode && this._cache.aspectRatio === i.getAspectRatio(this) && this._cache.projectionPlaneTilt === this.projectionPlaneTilt : this._cache.orthoLeft === this.orthoLeft && this._cache.orthoRight === this.orthoRight && this._cache.orthoBottom === this.orthoBottom && this._cache.orthoTop === this.orthoTop && this._cache.renderWidth === i.getRenderWidth() && this._cache.renderHeight === i.getRenderHeight() }, t.prototype.attachControl = function (e, t) { }, t.prototype.detachControl = function (e) { }, t.prototype.update = function () { this._checkInputs(), this.cameraRigMode !== t.RIG_MODE_NONE && this._updateRigCameras(), this.getViewMatrix(), this.getProjectionMatrix() }, t.prototype._checkInputs = function () { this.onAfterCheckInputsObservable.notifyObservers(this) }, Object.defineProperty(t.prototype, "rigCameras", { get: function () { return this._rigCameras }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rigPostProcess", { get: function () { return this._rigPostProcess }, enumerable: !1, configurable: !0 }), t.prototype._getFirstPostProcess = function () { for (var e = 0; e < this._postProcesses.length; e++)if (null !== this._postProcesses[e]) return this._postProcesses[e]; return null }, t.prototype._cascadePostProcessesToRigCams = function () { var e = this._getFirstPostProcess(); e && e.markTextureDirty(); for (var t = 0, i = this._rigCameras.length; t < i; t++) { var r = this._rigCameras[t], n = r._rigPostProcess; n ? ("pass" === n.getEffectName() && (r.isIntermediate = 0 === this._postProcesses.length), r._postProcesses = this._postProcesses.slice(0).concat(n), n.markTextureDirty()) : r._postProcesses = this._postProcesses.slice(0) } }, t.prototype.attachPostProcess = function (e, t) { return void 0 === t && (t = null), !e.isReusable() && this._postProcesses.indexOf(e) > -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; 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 u = this.getEngine(), h = this.getScene(), d = u.useReverseDepthBuffer; if (this.mode === t.PERSPECTIVE_CAMERA) this._cache.fov = this.fov, this._cache.fovMode = this.fovMode, this._cache.aspectRatio = u.getAspectRatio(this), this._cache.projectionPlaneTilt = this.projectionPlaneTilt, this.minZ <= 0 && (this.minZ = .1), (h.useRightHandedSystem ? I.PerspectiveFovRHToRef : I.PerspectiveFovLHToRef)(this.fov, u.getAspectRatio(this), d ? this.maxZ : this.minZ, d ? this.minZ : this.maxZ, this._projectionMatrix, this.fovMode === t.FOVMODE_VERTICAL_FIXED, u.isNDCHalfZRange, this.projectionPlaneTilt, d); else { var p = u.getRenderWidth() / 2, f = u.getRenderHeight() / 2; h.useRightHandedSystem ? I.OrthoOffCenterRHToRef(null !== (i = this.orthoLeft) && void 0 !== i ? i : -p, null !== (r = this.orthoRight) && void 0 !== r ? r : p, null !== (n = this.orthoBottom) && void 0 !== n ? n : -f, null !== (o = this.orthoTop) && void 0 !== o ? o : f, d ? this.maxZ : this.minZ, d ? this.minZ : this.maxZ, this._projectionMatrix, u.isNDCHalfZRange) : I.OrthoOffCenterLHToRef(null !== (a = this.orthoLeft) && void 0 !== a ? a : -p, null !== (s = this.orthoRight) && void 0 !== s ? s : p, null !== (l = this.orthoBottom) && void 0 !== l ? l : -f, null !== (c = this.orthoTop) && void 0 !== c ? c : f, d ? this.maxZ : this.minZ, d ? this.minZ : this.maxZ, this._projectionMatrix, u.isNDCHalfZRange), this._cache.orthoLeft = this.orthoLeft, this._cache.orthoRight = this.orthoRight, this._cache.orthoBottom = this.orthoBottom, this._cache.orthoTop = this.orthoTop, this._cache.renderWidth = u.getRenderWidth(), this._cache.renderHeight = u.getRenderHeight() } return this.onProjectionMatrixChangedObservable.notifyObservers(this), this._projectionMatrix }, t.prototype.getTransformationMatrix = function () { return this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix), this._transformMatrix }, t.prototype._updateFrustumPlanes = function () { this._refreshFrustumPlanes && (this.getTransformationMatrix(), this._frustumPlanes ? vr.GetPlanesToRef(this._transformMatrix, this._frustumPlanes) : this._frustumPlanes = vr.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), ge("Ray") }, t.prototype.getForwardRayToRef = function (e, t, i, r) { throw void 0 === t && (t = 100), ge("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 = xi.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._updateCameraRotationMatrix = function () { }, t.prototype._updateWebVRCameraRotationMatrix = function () { }, t.prototype._getWebVRProjectionMatrix = function () { return I.Identity() }, t.prototype._getWebVRViewMatrix = function () { return I.Identity() }, t.prototype.setCameraRigParameter = function (e, t) { this._cameraRigParams || (this._cameraRigParams = {}), this._cameraRigParams[e] = t, "interaxialDistance" === e && (this._cameraRigParams.stereoHalfAngle = xi.ToRadians(t / .0637)) }, t.prototype.createRigCamera = function (e, t) { return null }, t.prototype._updateRigCameras = function () { for (var e = 0; e < this._rigCameras.length; e++)this._rigCameras[e].minZ = this.minZ, this._rigCameras[e].maxZ = this.maxZ, this._rigCameras[e].fov = this.fov, this._rigCameras[e].upVector.copyFrom(this.upVector); this.cameraRigMode === t.RIG_MODE_STEREOSCOPIC_ANAGLYPH && (this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport) }, t.prototype._setupInputs = function () { }, t.prototype.serialize = function () { var e = Ue.Serialize(this); return e.uniqueId = this.uniqueId, e.type = this.getClassName(), this.parent && this.parent._serializeAsParent(e), this.inputs && this.inputs.serialize(e), Ue.AppendSerializedAnimations(this, e), e.ranges = this.serializeAnimationRanges(), e.isEnabled = this.isEnabled(), e }, t.prototype.clone = function (e, i) { void 0 === i && (i = null); var r = Ue.Clone(t.GetConstructorFromName(this.getClassName(), e, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this); return r.name = e, r.parent = i, this.onClonedObservable.notifyObservers(r), r }, t.prototype.getDirection = function (e) { var t = R.Zero(); return this.getDirectionToRef(e, t), t }, Object.defineProperty(t.prototype, "absoluteRotation", { get: function () { return this.getWorldMatrix().decompose(void 0, this._absoluteRotation), this._absoluteRotation }, enumerable: !1, configurable: !0 }), t.prototype.getDirectionToRef = function (e, t) { R.TransformNormalToRef(e, this.getWorldMatrix(), t) }, t.GetConstructorFromName = function (e, i, r, n, o) { return void 0 === n && (n = 0), void 0 === o && (o = !0), ze.Construct(e, i, r, { interaxial_distance: n, isStereoscopicSideBySide: o }) || function () { return t._CreateDefaultParsedCamera(i, r) } }, t.prototype.computeWorldMatrix = function () { return this.getWorldMatrix() }, t.Parse = function (e, i) { var r = e.type, n = t.GetConstructorFromName(r, e.name, i, e.interaxial_distance, e.isStereoscopicSideBySide), o = Ue.Parse(n, e, i); if (void 0 !== e.parentId && (o._waitingParentId = e.parentId), void 0 !== e.parentInstanceIndex && (o._waitingParentInstanceIndex = e.parentInstanceIndex), o.inputs && (o.inputs.parse(e), o._setupInputs()), e.upVector && (o.upVector = R.FromArray(e.upVector)), o.setPosition && (o.position.copyFromFloats(0, 0, 0), o.setPosition(R.FromArray(e.position))), e.target && o.setTarget && o.setTarget(R.FromArray(e.target)), e.cameraRigMode) { var a = e.interaxial_distance ? { interaxialDistance: e.interaxial_distance } : {}; o.setCameraRigMode(e.cameraRigMode, a) } if (e.animations) { for (var s = 0; s < e.animations.length; s++) { var l = e.animations[s], c = T("BABYLON.Animation"); c && o.animations.push(c.Parse(l)) } ze.ParseAnimationRanges(o, e, i) } return e.autoAnimate && i.beginAnimation(o, e.autoAnimateFrom, e.autoAnimateTo, e.autoAnimateLoop, e.autoAnimateSpeed || 1), void 0 !== e.isEnabled && o.setEnabled(e.isEnabled), o }, t._CreateDefaultParsedCamera = function (e, t) { throw ge("UniversalCamera") }, t.PERSPECTIVE_CAMERA = a.PERSPECTIVE_CAMERA, t.ORTHOGRAPHIC_CAMERA = a.ORTHOGRAPHIC_CAMERA, t.FOVMODE_VERTICAL_FIXED = a.FOVMODE_VERTICAL_FIXED, t.FOVMODE_HORIZONTAL_FIXED = a.FOVMODE_HORIZONTAL_FIXED, t.RIG_MODE_NONE = a.RIG_MODE_NONE, t.RIG_MODE_STEREOSCOPIC_ANAGLYPH = a.RIG_MODE_STEREOSCOPIC_ANAGLYPH, t.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL, t.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED, t.RIG_MODE_STEREOSCOPIC_OVERUNDER = a.RIG_MODE_STEREOSCOPIC_OVERUNDER, t.RIG_MODE_STEREOSCOPIC_INTERLACED = a.RIG_MODE_STEREOSCOPIC_INTERLACED, t.RIG_MODE_VR = a.RIG_MODE_VR, t.RIG_MODE_WEBVR = a.RIG_MODE_WEBVR, t.RIG_MODE_CUSTOM = a.RIG_MODE_CUSTOM, t.ForceAttachControlToAlwaysPreventDefault = !1, X([Ie("position")], t.prototype, "_position", void 0), X([Ie("upVector")], t.prototype, "_upVector", void 0), X([xe()], t.prototype, "orthoLeft", null), X([xe()], t.prototype, "orthoRight", null), X([xe()], t.prototype, "orthoBottom", null), X([xe()], t.prototype, "orthoTop", null), X([xe()], t.prototype, "fov", void 0), X([xe()], t.prototype, "projectionPlaneTilt", void 0), X([xe()], t.prototype, "minZ", void 0), X([xe()], t.prototype, "maxZ", void 0), X([xe()], t.prototype, "inertia", void 0), X([xe()], t.prototype, "mode", null), X([xe()], t.prototype, "layerMask", void 0), X([xe()], t.prototype, "fovMode", void 0), X([xe()], t.prototype, "cameraRigMode", void 0), X([xe()], t.prototype, "interaxialDistance", void 0), X([xe()], t.prototype, "isStereoscopicSideBySide", void 0), t }(ze), cn = function (e, t, i) { this.bu = e, this.bv = t, this.distance = i, this.faceId = 0, this.subMeshId = 0 }, un = function () { function e(e, t, i) { this.vectors = m.BuildArray(8, R.Zero), this.center = R.Zero(), this.centerWorld = R.Zero(), this.extendSize = R.Zero(), this.extendSizeWorld = R.Zero(), this.directions = m.BuildArray(3, R.Zero), this.vectorsWorld = m.BuildArray(8, R.Zero), this.minimumWorld = R.Zero(), this.maximumWorld = R.Zero(), this.minimum = R.Zero(), this.maximum = R.Zero(), this._drawWrapperFront = null, this._drawWrapperBack = null, this.reConstruct(e, t, i) } return e.prototype.reConstruct = function (e, t, i) { var r = e.x, n = e.y, o = e.z, a = t.x, s = t.y, l = t.z, c = this.vectors; this.minimum.copyFromFloats(r, n, o), this.maximum.copyFromFloats(a, s, l), c[0].copyFromFloats(r, n, o), c[1].copyFromFloats(a, s, l), c[2].copyFromFloats(a, n, o), c[3].copyFromFloats(r, s, o), c[4].copyFromFloats(r, n, l), c[5].copyFromFloats(a, s, o), c[6].copyFromFloats(r, s, l), c[7].copyFromFloats(a, n, l), t.addToRef(e, this.center).scaleInPlace(.5), t.subtractToRef(e, this.extendSize).scaleInPlace(.5), this._worldMatrix = i || I.IdentityReadOnly, this._update(this._worldMatrix) }, e.prototype.scale = function (t) { var i = e._TmpVector3, r = this.maximum.subtractToRef(this.minimum, i[0]), n = r.length(); r.normalizeFromLength(n); var o = n * t, a = r.scaleInPlace(.5 * o), s = this.center.subtractToRef(a, i[1]), l = this.center.addToRef(a, i[2]); return this.reConstruct(s, l, this._worldMatrix), this }, e.prototype.getWorldMatrix = function () { return this._worldMatrix }, e.prototype._update = function (e) { var t = this.minimumWorld, i = this.maximumWorld, r = this.directions, n = this.vectorsWorld, o = this.vectors; if (e.isIdentity()) { for (t.copyFrom(this.minimum), i.copyFrom(this.maximum), a = 0; a < 8; ++a)n[a].copyFrom(o[a]); this.extendSizeWorld.copyFrom(this.extendSize), this.centerWorld.copyFrom(this.center) } else { t.setAll(Number.MAX_VALUE), i.setAll(-Number.MAX_VALUE); for (var a = 0; a < 8; ++a) { var s = n[a]; R.TransformCoordinatesToRef(o[a], e, s), t.minimizeInPlace(s), i.maximizeInPlace(s) } i.subtractToRef(t, this.extendSizeWorld).scaleInPlace(.5), i.addToRef(t, this.centerWorld).scaleInPlace(.5) } R.FromArrayToRef(e.m, 0, r[0]), R.FromArrayToRef(e.m, 4, r[1]), R.FromArrayToRef(e.m, 8, r[2]), this._worldMatrix = e }, e.prototype.isInFrustum = function (t) { return e.IsInFrustum(this.vectorsWorld, t) }, e.prototype.isCompletelyInFrustum = function (t) { return e.IsCompletelyInFrustum(this.vectorsWorld, t) }, e.prototype.intersectsPoint = function (e) { var t = this.minimumWorld, i = this.maximumWorld, r = t.x, n = t.y, o = t.z, a = i.x, s = i.y, l = i.z, c = e.x, u = e.y, h = e.z, d = -_; return !(a - c < d || d > c - r || s - u < d || d > u - n || l - h < d || d > h - 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 !(s < u || n > p || l < h || o > f || c < d || a > _) }, 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 }(), hn = 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.radiusWorld < t) }, e.Intersects = function (e, t) { var i = R.DistanceSquared(e.centerWorld, t.centerWorld), r = e.radiusWorld + t.radiusWorld; return !(r * r < i) }, e.CreateFromCenterAndRadius = function (t, i, r) { this._TmpVector3[0].copyFrom(t), this._TmpVector3[1].copyFromFloats(0, 0, i), this._TmpVector3[2].copyFrom(t), this._TmpVector3[0].addInPlace(this._TmpVector3[1]), this._TmpVector3[2].subtractInPlace(this._TmpVector3[1]); var n = new e(this._TmpVector3[0], this._TmpVector3[2]); return n._worldMatrix = r || I.Identity(), n }, e._TmpVector3 = m.BuildArray(3, R.Zero), e }(), dn = { min: 0, max: 0 }, pn = { min: 0, max: 0 }, fn = function (e, t, i) { var r = R.Dot(t.centerWorld, e), n = Math.abs(R.Dot(t.directions[0], e)) * t.extendSize.x + Math.abs(R.Dot(t.directions[1], e)) * t.extendSize.y + Math.abs(R.Dot(t.directions[2], e)) * t.extendSize.z; i.min = r - n, i.max = r + n }, _n = function (e, t, i) { return fn(e, t, dn), fn(e, i, pn), !(dn.min > pn.max || pn.min > dn.max) }, mn = function () { function e(e, t, i) { this._isLocked = !1, this.boundingBox = new un(e, t, i), this.boundingSphere = new hn(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 (!hn.Intersects(this.boundingSphere, e.boundingSphere)) return !1; if (!un.Intersects(this.boundingBox, e.boundingBox)) return !1; if (!t) return !0; var i = this.boundingBox, r = e.boundingBox; return !!(_n(i.directions[0], i, r) && _n(i.directions[1], i, r) && _n(i.directions[2], i, r) && _n(r.directions[0], i, r) && _n(r.directions[1], i, r) && _n(r.directions[2], i, r) && _n(R.Cross(i.directions[0], r.directions[0]), i, r) && _n(R.Cross(i.directions[0], r.directions[1]), i, r) && _n(R.Cross(i.directions[0], r.directions[2]), i, r) && _n(R.Cross(i.directions[1], r.directions[0]), i, r) && _n(R.Cross(i.directions[1], r.directions[1]), i, r) && _n(R.Cross(i.directions[1], r.directions[2]), i, r) && _n(R.Cross(i.directions[2], r.directions[0]), i, r) && _n(R.Cross(i.directions[2], r.directions[1]), i, r) && _n(R.Cross(i.directions[2], r.directions[2]), i, r)) }, e._TmpVector3 = m.BuildArray(2, R.Zero), e }(), gn = function () { function e() { } return e.extractMinAndMaxIndexed = function (e, t, i, r, n, o) { for (var a = i; a < i + r; a++) { var s = 3 * t[a], l = e[s], c = e[s + 1], u = e[s + 2]; n.minimizeInPlaceFromFloats(l, c, u), o.maximizeInPlaceFromFloats(l, c, u) } }, e.extractMinAndMax = function (e, t, i, r, n, o) { for (var a = t, s = t * r; a < t + i; a++, s += r) { var l = e[s], c = e[s + 1], u = e[s + 2]; n.minimizeInPlaceFromFloats(l, c, u), o.maximizeInPlaceFromFloats(l, c, u) } }, X([Ve.filter((function () { for (var e = [], t = 0; t < arguments.length; t++)e[t] = arguments[t]; var i = e[0], r = e[1]; return !Array.isArray(i) && !Array.isArray(r) }))], e, "extractMinAndMaxIndexed", null), X([Ve.filter((function () { for (var e = [], t = 0; t < arguments.length; t++)e[t] = arguments[t]; var i = e[0]; return !Array.isArray(i) }))], e, "extractMinAndMax", null), e }(); function vn(e, t, i, r, n) { void 0 === n && (n = null); var o = new R(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), a = new R(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE); return gn.extractMinAndMaxIndexed(e, t, i, r, o, a), n && (o.x -= o.x * n.x + n.y, o.y -= o.y * n.x + n.y, o.z -= o.z * n.x + n.y, a.x += a.x * n.x + n.y, a.y += a.y * n.x + n.y, a.z += a.z * n.x + n.y), { minimum: o, maximum: a } } function yn(e, t, i, r, n) { void 0 === r && (r = null); var o = new R(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), a = new R(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE); return n || (n = 3), gn.extractMinAndMax(e, t, i, n, o, a), r && (o.x -= o.x * r.x + r.y, o.y -= o.y * r.x + r.y, o.z -= o.z * r.x + r.y, a.x += a.x * r.x + r.y, a.y += a.y * r.x + r.y, a.z += a.z * r.x + r.y), { minimum: o, maximum: a } } var bn = function () { function e(e, t, i, r, n, o, a, s, l) { void 0 === s && (s = !0), void 0 === l && (l = !0), this.materialIndex = e, this.verticesStart = t, this.verticesCount = i, this.indexStart = r, this.indexCount = n, this._mainDrawWrapperOverride = null, this._linesIndexCount = 0, this._linesIndexBuffer = null, this._lastColliderWorldVertices = null, this._lastColliderTransformMatrix = null, this._wasDispatched = !1, this._renderId = 0, this._alphaIndex = 0, this._distanceToCamera = 0, this._currentMaterial = null, this._mesh = o, this._renderingMesh = a || o, l && o.subMeshes.push(this), this._engine = this._mesh.getScene().getEngine(), this.resetDrawCache(), this._trianglePlanes = [], this._id = o.subMeshes.length - 1, s && (this.refreshBoundingInfo(), o.computeWorldMatrix(!0)) } return Object.defineProperty(e.prototype, "materialDefines", { get: function () { var e; return this._mainDrawWrapperOverride ? this._mainDrawWrapperOverride.defines : null === (e = this._getDrawWrapper()) || void 0 === e ? void 0 : e.defines }, set: function (e) { var t; (null !== (t = this._mainDrawWrapperOverride) && void 0 !== t ? t : this._getDrawWrapper(void 0, !0)).defines = e }, enumerable: !1, configurable: !0 }), e.prototype._getDrawWrapper = function (e, t) { void 0 === t && (t = !1), e = null != e ? e : this._engine.currentRenderPassId; var i = this._drawWrappers[e]; return !i && t && (this._drawWrappers[e] = i = new Jt(this._mesh.getScene().getEngine())), i }, e.prototype._removeDrawWrapper = function (e, t) { var i; void 0 === t && (t = !0), t && (null === (i = this._drawWrappers[e]) || void 0 === i || i.dispose()), this._drawWrappers[e] = void 0 }, Object.defineProperty(e.prototype, "effect", { get: function () { var e, t; return this._mainDrawWrapperOverride ? this._mainDrawWrapperOverride.effect : null !== (t = null === (e = this._getDrawWrapper()) || void 0 === e ? void 0 : e.effect) && void 0 !== t ? t : null }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "_drawWrapper", { get: function () { var e; return null !== (e = this._mainDrawWrapperOverride) && void 0 !== e ? e : this._getDrawWrapper(void 0, !0) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "_drawWrapperOverride", { get: function () { return this._mainDrawWrapperOverride }, enumerable: !1, configurable: !0 }), e.prototype._setMainDrawWrapperOverride = function (e) { this._mainDrawWrapperOverride = e }, e.prototype.setEffect = function (e, t, i, r) { void 0 === t && (t = null), void 0 === r && (r = !0); var n = this._drawWrapper; n.setEffect(e, t, r), void 0 !== i && (n.materialContext = i), e || (n.defines = null, n.materialContext = void 0) }, e.prototype.resetDrawCache = function (e) { if (this._drawWrappers) { if (void 0 !== e) return void this._removeDrawWrapper(e); for (var t = 0, i = this._drawWrappers; t < i.length; t++) { var r = i[t]; null == r || r.dispose() } } this._drawWrappers = [] }, e.AddToMesh = function (t, i, r, n, o, a, s, l) { return void 0 === l && (l = !0), new e(t, i, r, n, o, a, s, l) }, Object.defineProperty(e.prototype, "IsGlobal", { get: function () { return 0 === this.verticesStart && this.verticesCount === this._mesh.getTotalVertices() && 0 === this.indexStart && this.indexCount === this._mesh.getTotalIndices() }, enumerable: !1, configurable: !0 }), e.prototype.getBoundingInfo = function () { return this.IsGlobal ? this._mesh.getBoundingInfo() : this._boundingInfo }, e.prototype.setBoundingInfo = function (e) { return this._boundingInfo = e, this }, e.prototype.getMesh = function () { return this._mesh }, e.prototype.getRenderingMesh = function () { return this._renderingMesh }, e.prototype.getReplacementMesh = function () { return this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null }, e.prototype.getEffectiveMesh = function () { return (this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null) || this._renderingMesh }, e.prototype.getMaterial = function (e) { var t; void 0 === e && (e = !0); var i = null !== (t = this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId)) && void 0 !== t ? t : this._renderingMesh.material; if (!i) return e ? this._mesh.getScene().defaultMaterial : null; if (this._isMultiMaterial(i)) { var r = i.getSubMaterial(this.materialIndex); return this._currentMaterial !== r && (this._currentMaterial = r, this.resetDrawCache()), r } return i }, e.prototype._isMultiMaterial = function (e) { return void 0 !== e.getSubMaterial }, e.prototype.refreshBoundingInfo = function (e) { if (void 0 === e && (e = null), this._lastColliderWorldVertices = null, this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) return this; if (e || (e = this._renderingMesh.getVerticesData(Hi.PositionKind)), !e) return this._boundingInfo = this._mesh.getBoundingInfo(), this; var t, i = this._renderingMesh.getIndices(); if (0 === this.indexStart && this.indexCount === i.length) { var r = this._renderingMesh.getBoundingInfo(); t = { minimum: r.minimum.clone(), maximum: r.maximum.clone() } } else t = vn(e, i, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias); return this._boundingInfo ? this._boundingInfo.reConstruct(t.minimum, t.maximum) : this._boundingInfo = new mn(t.minimum, t.maximum), this }, e.prototype._checkCollision = function (e) { return this.getBoundingInfo()._checkCollision(e) }, e.prototype.updateBoundingInfo = function (e) { var t = this.getBoundingInfo(); return t || (this.refreshBoundingInfo(), t = this.getBoundingInfo()), t && t.update(e), this }, e.prototype.isInFrustum = function (e) { var t = this.getBoundingInfo(); return !!t && t.isInFrustum(e, this._mesh.cullingStrategy) }, e.prototype.isCompletelyInFrustum = function (e) { var t = this.getBoundingInfo(); return !!t && t.isCompletelyInFrustum(e) }, e.prototype.render = function (e) { return this._renderingMesh.render(this, e, this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : void 0), this }, e.prototype._getLinesIndexBuffer = function (e, t) { if (!this._linesIndexBuffer) { for (var i = [], r = this.indexStart; r < this.indexStart + this.indexCount; r += 3)i.push(e[r], e[r + 1], e[r + 1], e[r + 2], e[r + 2], e[r]); this._linesIndexBuffer = t.createIndexBuffer(i), this._linesIndexCount = i.length } return this._linesIndexBuffer }, e.prototype.canIntersects = function (e) { var t = this.getBoundingInfo(); return !!t && e.intersectsBox(t.boundingBox) }, e.prototype.intersects = function (e, t, i, r, n) { var o = this.getMaterial(); if (!o) return null; var s = 3, l = !1; switch (o.fillMode) { case a.MATERIAL_PointListDrawMode: case a.MATERIAL_LineLoopDrawMode: case a.MATERIAL_LineStripDrawMode: case a.MATERIAL_TriangleFanDrawMode: return null; case a.MATERIAL_TriangleStripDrawMode: s = 1, l = !0 }return o.fillMode === a.MATERIAL_LineListDrawMode ? i.length ? this._intersectLines(e, t, i, this._mesh.intersectionThreshold, r) : this._intersectUnIndexedLines(e, t, i, this._mesh.intersectionThreshold, r) : !i.length && this._mesh._unIndexed ? this._intersectUnIndexedTriangles(e, t, i, r, n) : this._intersectTriangles(e, t, i, s, l, r, n) }, e.prototype._intersectLines = function (e, t, i, r, n) { for (var o = null, a = this.indexStart; a < this.indexStart + this.indexCount; a += 2) { var s = t[i[a]], l = t[i[a + 1]], c = e.intersectionSegment(s, l, r); if (!(c < 0) && (n || !o || c < o.distance) && ((o = new cn(null, null, c)).faceId = a / 2, n)) break } return o }, e.prototype._intersectUnIndexedLines = function (e, t, i, r, n) { for (var o = null, a = this.verticesStart; a < this.verticesStart + this.verticesCount; a += 2) { var s = t[a], l = t[a + 1], c = e.intersectionSegment(s, l, r); if (!(c < 0) && (n || !o || c < o.distance) && ((o = new cn(null, null, c)).faceId = a / 2, n)) break } return o }, e.prototype._intersectTriangles = function (e, t, i, r, n, o, a) { for (var s = null, l = -1, c = this.indexStart; c < this.indexStart + this.indexCount - (3 - r); c += r) { l++; var u = i[c], h = i[c + 1], d = i[c + 2]; if (n && 4294967295 === d) c += 2; else { var p = t[u], f = t[h], _ = t[d]; if (p && f && _ && (!a || a(p, f, _, e, u, h, d))) { var m = e.intersectsTriangle(p, f, _); if (m) { if (m.distance < 0) continue; if ((o || !s || m.distance < s.distance) && ((s = m).faceId = l, o)) break } } } } return s }, e.prototype._intersectUnIndexedTriangles = function (e, t, i, r, n) { for (var o = null, a = this.verticesStart; a < this.verticesStart + this.verticesCount; a += 3) { var s = t[a], l = t[a + 1], c = t[a + 2]; if (!n || n(s, l, c, e, -1, -1, -1)) { var u = e.intersectsTriangle(s, l, c); if (u) { if (u.distance < 0) continue; if ((r || !o || u.distance < o.distance) && ((o = u).faceId = a / 3, r)) break } } } return o }, e.prototype._rebuild = function () { this._linesIndexBuffer && (this._linesIndexBuffer = null) }, e.prototype.clone = function (t, i) { var r = new e(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, t, i, !1); if (!this.IsGlobal) { var n = this.getBoundingInfo(); if (!n) return r; r._boundingInfo = new mn(n.minimum, n.maximum) } return r }, e.prototype.dispose = function () { this._linesIndexBuffer && (this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer), this._linesIndexBuffer = null); var e = this._mesh.subMeshes.indexOf(this); this._mesh.subMeshes.splice(e, 1), this.resetDrawCache() }, e.prototype.getClassName = function () { return "SubMesh" }, e.CreateFromIndices = function (t, i, r, n, o, a) { void 0 === a && (a = !0); for (var s = Number.MAX_VALUE, l = -Number.MAX_VALUE, c = (o || n).getIndices(), u = i; u < i + r; u++) { var h = c[u]; h < s && (s = h), h > l && (l = h) } return new e(t, s, l - s + 1, i, r, n, o, a) }, e }(), Tn = function () { }, En = function () { function e() { this._applyTo = on(this._applyToCoroutine.bind(this)) } return e.prototype.set = function (e, t) { switch (e.length || $.Warn("Setting vertex data kind '".concat(t, "' with an empty array")), t) { case Hi.PositionKind: this.positions = e; break; case Hi.NormalKind: this.normals = e; break; case Hi.TangentKind: this.tangents = e; break; case Hi.UVKind: this.uvs = e; break; case Hi.UV2Kind: this.uvs2 = e; break; case Hi.UV3Kind: this.uvs3 = e; break; case Hi.UV4Kind: this.uvs4 = e; break; case Hi.UV5Kind: this.uvs5 = e; break; case Hi.UV6Kind: this.uvs6 = e; break; case Hi.ColorKind: this.colors = e; break; case Hi.MatricesIndicesKind: this.matricesIndices = e; break; case Hi.MatricesWeightsKind: this.matricesWeights = e; break; case Hi.MatricesIndicesExtraKind: this.matricesIndicesExtra = e; break; case Hi.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(Hi.PositionKind, this.positions, t), i ? [4] : [3, 2]) : [3, 2]; case 1: s.sent(), s.label = 2; case 2: return this.normals ? (e.setVerticesData(Hi.NormalKind, this.normals, t), i ? [4] : [3, 4]) : [3, 4]; case 3: s.sent(), s.label = 4; case 4: return this.tangents ? (e.setVerticesData(Hi.TangentKind, this.tangents, t), i ? [4] : [3, 6]) : [3, 6]; case 5: s.sent(), s.label = 6; case 6: return this.uvs ? (e.setVerticesData(Hi.UVKind, this.uvs, t), i ? [4] : [3, 8]) : [3, 8]; case 7: s.sent(), s.label = 8; case 8: return this.uvs2 ? (e.setVerticesData(Hi.UV2Kind, this.uvs2, t), i ? [4] : [3, 10]) : [3, 10]; case 9: s.sent(), s.label = 10; case 10: return this.uvs3 ? (e.setVerticesData(Hi.UV3Kind, this.uvs3, t), i ? [4] : [3, 12]) : [3, 12]; case 11: s.sent(), s.label = 12; case 12: return this.uvs4 ? (e.setVerticesData(Hi.UV4Kind, this.uvs4, t), i ? [4] : [3, 14]) : [3, 14]; case 13: s.sent(), s.label = 14; case 14: return this.uvs5 ? (e.setVerticesData(Hi.UV5Kind, this.uvs5, t), i ? [4] : [3, 16]) : [3, 16]; case 15: s.sent(), s.label = 16; case 16: return this.uvs6 ? (e.setVerticesData(Hi.UV6Kind, this.uvs6, t), i ? [4] : [3, 18]) : [3, 18]; case 17: s.sent(), s.label = 18; case 18: return this.colors ? (e.setVerticesData(Hi.ColorKind, this.colors, t), i ? [4] : [3, 20]) : [3, 20]; case 19: s.sent(), s.label = 20; case 20: return this.matricesIndices ? (e.setVerticesData(Hi.MatricesIndicesKind, this.matricesIndices, t), i ? [4] : [3, 22]) : [3, 22]; case 21: s.sent(), s.label = 22; case 22: return this.matricesWeights ? (e.setVerticesData(Hi.MatricesWeightsKind, this.matricesWeights, t), i ? [4] : [3, 24]) : [3, 24]; case 23: s.sent(), s.label = 24; case 24: return this.matricesIndicesExtra ? (e.setVerticesData(Hi.MatricesIndicesExtraKind, this.matricesIndicesExtra, t), i ? [4] : [3, 26]) : [3, 26]; case 25: s.sent(), s.label = 26; case 26: return this.matricesWeightsExtra ? (e.setVerticesData(Hi.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; n < o.length; n++)a = o[n], new bn(a.materialIndex, a.verticesStart, a.verticesCount, a.indexStart, a.indexCount, r); return [2, this] } })) }, e.prototype._update = function (e, t, i) { return this.positions && e.updateVerticesData(Hi.PositionKind, this.positions, t, i), this.normals && e.updateVerticesData(Hi.NormalKind, this.normals, t, i), this.tangents && e.updateVerticesData(Hi.TangentKind, this.tangents, t, i), this.uvs && e.updateVerticesData(Hi.UVKind, this.uvs, t, i), this.uvs2 && e.updateVerticesData(Hi.UV2Kind, this.uvs2, t, i), this.uvs3 && e.updateVerticesData(Hi.UV3Kind, this.uvs3, t, i), this.uvs4 && e.updateVerticesData(Hi.UV4Kind, this.uvs4, t, i), this.uvs5 && e.updateVerticesData(Hi.UV5Kind, this.uvs5, t, i), this.uvs6 && e.updateVerticesData(Hi.UV6Kind, this.uvs6, t, i), this.colors && e.updateVerticesData(Hi.ColorKind, this.colors, t, i), this.matricesIndices && e.updateVerticesData(Hi.MatricesIndicesKind, this.matricesIndices, t, i), this.matricesWeights && e.updateVerticesData(Hi.MatricesWeightsKind, this.matricesWeights, t, i), this.matricesIndicesExtra && e.updateVerticesData(Hi.MatricesIndicesExtraKind, this.matricesIndicesExtra, t, i), this.matricesWeightsExtra && e.updateVerticesData(Hi.MatricesWeightsExtraKind, this.matricesWeightsExtra, t, i), this.indices && e.setIndices(this.indices, null), this }, e._TransformVector3Coordinates = function (e, t, i, r) { void 0 === i && (i = 0), void 0 === r && (r = e.length); for (var n = O.Vector3[0], o = O.Vector3[1], a = i; a < i + r; a += 3)R.FromArrayToRef(e, a, n), R.TransformCoordinatesToRef(n, t, o), e[a] = o.x, e[a + 1] = o.y, e[a + 2] = o.z }, e._TransformVector3Normals = function (e, t, i, r) { void 0 === i && (i = 0), void 0 === r && (r = e.length); for (var n = O.Vector3[0], o = O.Vector3[1], a = i; a < i + r; a += 3)R.FromArrayToRef(e, a, n), R.TransformNormalToRef(n, t, o), e[a] = o.x, e[a + 1] = o.y, e[a + 2] = o.z }, e._TransformVector4Normals = function (e, t, i, r) { void 0 === i && (i = 0), void 0 === r && (r = e.length); for (var n = O.Vector4[0], o = O.Vector4[1], a = i; a < i + r; a += 4)C.FromArrayToRef(e, a, n), C.TransformNormalToRef(n, t, o), e[a] = o.x, e[a + 1] = o.y, e[a + 2] = o.z, e[a + 3] = o.w }, e._FlipFaces = function (e, t, i) { void 0 === t && (t = 0), void 0 === i && (i = e.length); for (var r = t; r < t + i; r += 3) { var n = e[r + 1]; e[r + 1] = e[r + 2], e[r + 2] = n } }, e.prototype.transform = function (t) { var i = t.determinant() < 0; return this.positions && e._TransformVector3Coordinates(this.positions, t), this.normals && e._TransformVector3Normals(this.normals, t), this.tangents && e._TransformVector4Normals(this.tangents, t), i && this.indices && e._FlipFaces(this.indices), this }, e.prototype.splitBasedOnMaterialID = function () { if (!this.materialInfos || this.materialInfos.length < 2) return [this]; for (var t = new Array, i = 0, r = this.materialInfos; i < r.length; i++) { var n = r[i], o = new e; if (this.positions && (o.positions = this.positions.slice(3 * n.verticesStart, 3 * (n.verticesCount + n.verticesStart))), this.normals && (o.normals = this.normals.slice(3 * n.verticesStart, 3 * (n.verticesCount + n.verticesStart))), this.tangents && (o.tangents = this.tangents.slice(4 * n.verticesStart, 4 * (n.verticesCount + n.verticesStart))), this.colors && (o.colors = this.colors.slice(4 * n.verticesStart, 4 * (n.verticesCount + n.verticesStart))), this.uvs && (o.uvs = this.uvs.slice(2 * n.verticesStart, 2 * (n.verticesCount + n.verticesStart))), this.uvs2 && (o.uvs2 = this.uvs2.slice(2 * n.verticesStart, 2 * (n.verticesCount + n.verticesStart))), this.uvs3 && (o.uvs3 = this.uvs3.slice(2 * n.verticesStart, 2 * (n.verticesCount + n.verticesStart))), this.uvs4 && (o.uvs4 = this.uvs4.slice(2 * n.verticesStart, 2 * (n.verticesCount + n.verticesStart))), this.uvs5 && (o.uvs5 = this.uvs5.slice(2 * n.verticesStart, 2 * (n.verticesCount + n.verticesStart))), this.uvs6 && (o.uvs6 = this.uvs6.slice(2 * n.verticesStart, 2 * (n.verticesCount + n.verticesStart))), this.matricesIndices && (o.matricesIndices = this.matricesIndices.slice(4 * n.verticesStart, 4 * (n.verticesCount + n.verticesStart))), this.matricesIndicesExtra && (o.matricesIndicesExtra = this.matricesIndicesExtra.slice(4 * n.verticesStart, 4 * (n.verticesCount + n.verticesStart))), this.matricesWeights && (o.matricesWeights = this.matricesWeights.slice(4 * n.verticesStart, 4 * (n.verticesCount + n.verticesStart))), this.matricesWeightsExtra && (o.matricesWeightsExtra = this.matricesWeightsExtra.slice(4 * n.verticesStart, 4 * (n.verticesCount + n.verticesStart))), this.indices) { o.indices = []; for (var a = n.indexStart; a < n.indexStart + n.indexCount; a++)o.indices.push(this.indices[a] - n.verticesStart) } var s = new Tn; s.indexStart = 0, s.indexCount = o.indices ? o.indices.length : 0, s.materialIndex = n.materialIndex, s.verticesStart = 0, s.verticesCount = (o.positions ? o.positions.length : 0) / 3, o.materialInfos = [s], t.push(o) } return t }, e.prototype.merge = function (e, t, i, r, n) { void 0 === t && (t = !1), void 0 === i && (i = !1), void 0 === r && (r = !1), void 0 === n && (n = !1); var o = Array.isArray(e) ? e.map((function (e) { return { vertexData: e } })) : [{ vertexData: e }]; return rn(this._mergeCoroutine(void 0, o, t, !1, i, r, n)) }, e.prototype._mergeCoroutine = function (t, 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, F, L, w, B, U, V, k, G, z, W, H, X, j; return void 0 === r && (r = !1), void 0 === a && (a = !1), void 0 === s && (s = !1), Y(this, (function (Y) { switch (Y.label) { case 0: for (this._validate(), l = i.map((function (e) { return e.vertexData })), c = this, u = 0, h = l; u < h.length; u++)if (k = h[u]) if (k._validate(), s) !this.normals != !k.normals && (this.normals ? k.normals = Array.from(this.normals) : this.normals = Array.from(k.normals)), !this.tangents != !k.tangents && (this.tangents ? k.tangents = Array.from(this.tangents) : this.tangents = Array.from(k.tangents)), !this.uvs != !k.uvs && (this.uvs ? k.uvs = Array.from(this.uvs) : this.uvs = Array.from(k.uvs)), !this.uvs2 != !k.uvs2 && (this.uvs2 ? k.uvs2 = Array.from(this.uvs2) : this.uvs2 = Array.from(k.uvs2)), !this.uvs3 != !k.uvs3 && (this.uvs3 ? k.uvs3 = Array.from(this.uvs3) : this.uvs3 = Array.from(k.uvs3)), !this.uvs4 != !k.uvs4 && (this.uvs4 ? k.uvs4 = Array.from(this.uvs4) : this.uvs4 = Array.from(k.uvs4)), !this.uvs5 != !k.uvs5 && (this.uvs5 ? k.uvs5 = Array.from(this.uvs5) : this.uvs5 = Array.from(k.uvs5)), !this.uvs6 != !k.uvs6 && (this.uvs6 ? k.uvs6 = Array.from(this.uvs6) : this.uvs6 = Array.from(k.uvs6)), !this.colors != !k.colors && (this.colors ? k.colors = Array.from(this.colors) : this.colors = Array.from(k.colors)), !this.matricesIndices != !k.matricesIndices && (this.matricesIndices ? k.matricesIndices = Array.from(this.matricesIndices) : this.matricesIndices = Array.from(k.matricesIndices)), !this.matricesWeights != !k.matricesWeights && (this.matricesWeights ? k.matricesWeights = Array.from(this.matricesWeights) : this.matricesWeights = Array.from(k.matricesWeights)), !this.matricesIndicesExtra != !k.matricesIndicesExtra && (this.matricesIndicesExtra ? k.matricesIndicesExtra = Array.from(this.matricesIndicesExtra) : this.matricesIndicesExtra = Array.from(k.matricesIndicesExtra)), !this.matricesWeightsExtra != !k.matricesWeightsExtra && (this.matricesWeightsExtra ? k.matricesWeightsExtra = Array.from(this.matricesWeightsExtra) : this.matricesWeightsExtra = Array.from(k.matricesWeightsExtra)); else if (!this.normals != !k.normals || !this.tangents != !k.tangents || !this.uvs != !k.uvs || !this.uvs2 != !k.uvs2 || !this.uvs3 != !k.uvs3 || !this.uvs4 != !k.uvs4 || !this.uvs5 != !k.uvs5 || !this.uvs6 != !k.uvs6 || !this.colors != !k.colors || !this.matricesIndices != !k.matricesIndices || !this.matricesWeights != !k.matricesWeights || !this.matricesIndicesExtra != !k.matricesIndicesExtra || !this.matricesWeightsExtra != !k.matricesWeightsExtra) throw new Error("Cannot merge vertex data that do not have the same set of attributes"); if (a) { for (d = 0, p = 0, f = 0, _ = [], m = null, g = [], v = 0, y = this.splitBasedOnMaterialID(); v < y.length; v++)x = y[v], g.push({ vertexData: x, transform: t }); for (b = 0, T = i; b < T.length; b++)for (P = T[b], E = 0, S = P.vertexData.splitBasedOnMaterialID(); E < S.length; E++)x = S[E], g.push({ vertexData: x, transform: P.transform }); for (g.sort((function (e, t) { var i = e.vertexData.materialInfos ? e.vertexData.materialInfos[0].materialIndex : 0, r = t.vertexData.materialInfos ? t.vertexData.materialInfos[0].materialIndex : 0; return i > r ? 1 : i === r ? 0 : -1 })), A = 0, R = g; A < R.length; A++)C = R[A], P = C.vertexData, d = P.materialInfos ? P.materialInfos[0].materialIndex : 0, m && m.materialIndex === d ? (m.indexCount += P.indices.length, m.verticesCount += P.positions.length / 3) : ((I = new Tn).materialIndex = d, I.indexStart = p, I.indexCount = P.indices.length, I.verticesStart = f, I.verticesCount = P.positions.length / 3, _.push(I), m = I), p += P.indices.length, f += P.positions.length / 3; M = g.splice(0, 1)[0], c = M.vertexData, t = M.transform, l = g.map((function (e) { return e.vertexData })), i = g, this.materialInfos = _ } if (O = l.reduce((function (e, t) { var i, r; return e + (null !== (r = null === (i = t.indices) || void 0 === i ? void 0 : i.length) && void 0 !== r ? r : 0) }), null !== (H = null === (W = c.indices) || void 0 === W ? void 0 : W.length) && void 0 !== H ? H : 0), D = o || l.some((function (e) { return e.indices === c.indices })), N = D ? null === (X = c.indices) || void 0 === X ? void 0 : X.slice() : c.indices, !(O > 0)) return [3, 4]; F = null !== (j = null == N ? void 0 : N.length) && void 0 !== j ? j : 0, N || (N = new Array(O)), N.length !== O && (Array.isArray(N) ? N.length = O : ((L = r || N instanceof Uint32Array ? new Uint32Array(O) : new Uint16Array(O)).set(N), N = L), t && t.determinant() < 0 && e._FlipFaces(N, 0, F)), w = c.positions ? c.positions.length / 3 : 0, B = 0, U = i, Y.label = 1; case 1: if (!(B < U.length)) return [3, 4]; if (V = U[B], k = V.vertexData, G = V.transform, !k.indices) return [3, 3]; for (z = 0; z < k.indices.length; z++)N[F + z] = k.indices[z] + w; return G && G.determinant() < 0 && e._FlipFaces(N, F, k.indices.length), w += k.positions.length / 3, F += k.indices.length, n ? [4] : [3, 3]; case 2: Y.sent(), Y.label = 3; case 3: return B++, [3, 1]; case 4: return this.indices = N, this.positions = e._MergeElement(Hi.PositionKind, c.positions, t, i.map((function (e) { return [e.vertexData.positions, e.transform] }))), n ? [4] : [3, 6]; case 5: Y.sent(), Y.label = 6; case 6: return c.normals ? (this.normals = e._MergeElement(Hi.NormalKind, c.normals, t, i.map((function (e) { return [e.vertexData.normals, e.transform] }))), n ? [4] : [3, 8]) : [3, 8]; case 7: Y.sent(), Y.label = 8; case 8: return c.tangents ? (this.tangents = e._MergeElement(Hi.TangentKind, c.tangents, t, i.map((function (e) { return [e.vertexData.tangents, e.transform] }))), n ? [4] : [3, 10]) : [3, 10]; case 9: Y.sent(), Y.label = 10; case 10: return c.uvs ? (this.uvs = e._MergeElement(Hi.UVKind, c.uvs, t, i.map((function (e) { return [e.vertexData.uvs, e.transform] }))), n ? [4] : [3, 12]) : [3, 12]; case 11: Y.sent(), Y.label = 12; case 12: return c.uvs2 ? (this.uvs2 = e._MergeElement(Hi.UV2Kind, c.uvs2, t, i.map((function (e) { return [e.vertexData.uvs2, e.transform] }))), n ? [4] : [3, 14]) : [3, 14]; case 13: Y.sent(), Y.label = 14; case 14: return c.uvs3 ? (this.uvs3 = e._MergeElement(Hi.UV3Kind, c.uvs3, t, i.map((function (e) { return [e.vertexData.uvs3, e.transform] }))), n ? [4] : [3, 16]) : [3, 16]; case 15: Y.sent(), Y.label = 16; case 16: return c.uvs4 ? (this.uvs4 = e._MergeElement(Hi.UV4Kind, c.uvs4, t, i.map((function (e) { return [e.vertexData.uvs4, e.transform] }))), n ? [4] : [3, 18]) : [3, 18]; case 17: Y.sent(), Y.label = 18; case 18: return c.uvs5 ? (this.uvs5 = e._MergeElement(Hi.UV5Kind, c.uvs5, t, i.map((function (e) { return [e.vertexData.uvs5, e.transform] }))), n ? [4] : [3, 20]) : [3, 20]; case 19: Y.sent(), Y.label = 20; case 20: return c.uvs6 ? (this.uvs6 = e._MergeElement(Hi.UV6Kind, c.uvs6, t, i.map((function (e) { return [e.vertexData.uvs6, e.transform] }))), n ? [4] : [3, 22]) : [3, 22]; case 21: Y.sent(), Y.label = 22; case 22: return c.colors ? (this.colors = e._MergeElement(Hi.ColorKind, c.colors, t, i.map((function (e) { return [e.vertexData.colors, e.transform] }))), n ? [4] : [3, 24]) : [3, 24]; case 23: Y.sent(), Y.label = 24; case 24: return c.matricesIndices ? (this.matricesIndices = e._MergeElement(Hi.MatricesIndicesKind, c.matricesIndices, t, i.map((function (e) { return [e.vertexData.matricesIndices, e.transform] }))), n ? [4] : [3, 26]) : [3, 26]; case 25: Y.sent(), Y.label = 26; case 26: return c.matricesWeights ? (this.matricesWeights = e._MergeElement(Hi.MatricesWeightsKind, c.matricesWeights, t, i.map((function (e) { return [e.vertexData.matricesWeights, e.transform] }))), n ? [4] : [3, 28]) : [3, 28]; case 27: Y.sent(), Y.label = 28; case 28: return c.matricesIndicesExtra ? (this.matricesIndicesExtra = e._MergeElement(Hi.MatricesIndicesExtraKind, c.matricesIndicesExtra, t, i.map((function (e) { return [e.vertexData.matricesIndicesExtra, e.transform] }))), n ? [4] : [3, 30]) : [3, 30]; case 29: Y.sent(), Y.label = 30; case 30: return c.matricesWeightsExtra && (this.matricesWeightsExtra = e._MergeElement(Hi.MatricesWeightsExtraKind, c.matricesWeightsExtra, t, i.map((function (e) { return [e.vertexData.matricesWeightsExtra, e.transform] })))), [2, this] } })) }, e._MergeElement = function (t, i, r, n) { var o = n.filter((function (e) { return null !== e[0] && void 0 !== e[0] })); if (!i && 0 == o.length) return i; if (!i) return this._MergeElement(t, o[0][0], o[0][1], o.slice(1)); var a = o.reduce((function (e, t) { return e + t[0].length }), i.length), s = t === Hi.PositionKind ? e._TransformVector3Coordinates : t === Hi.NormalKind ? e._TransformVector3Normals : t === Hi.TangentKind ? e._TransformVector4Normals : function () { }; if (i instanceof Float32Array) { var l = new Float32Array(a); l.set(i), r && s(l, r, 0, i.length); for (var c = i.length, u = 0, h = o; u < h.length; u++) { var d = h[u], p = d[0], f = d[1]; l.set(p, c), f && s(l, f, c, p.length), c += p.length } return l } for (var _ = new Array(a), m = 0; m < i.length; m++)_[m] = i[m]; r && s(_, r, 0, i.length), c = i.length; for (var g = 0, v = o; g < v.length; g++) { var y = v[g], b = (p = y[0], y[1]); for (m = 0; m < p.length; m++)_[c + m] = p[m]; b && s(_, b, c, p.length), c += p.length } return _ }, e.prototype._validate = function () { if (!this.positions) throw new ht("Positions are required", ut.MeshInvalidPositionsError); var e = function (e, t) { var i = Hi.DeduceStride(e); if (t.length % i != 0) throw new Error("The " + e + "s array count must be a multiple of " + i); return t.length / i }, t = e(Hi.PositionKind, this.positions), i = function (i, r) { var n = e(i, r); if (n !== t) throw new Error("The " + i + "s element count (" + n + ") does not match the positions count (" + t + ")") }; this.normals && i(Hi.NormalKind, this.normals), this.tangents && i(Hi.TangentKind, this.tangents), this.uvs && i(Hi.UVKind, this.uvs), this.uvs2 && i(Hi.UV2Kind, this.uvs2), this.uvs3 && i(Hi.UV3Kind, this.uvs3), this.uvs4 && i(Hi.UV4Kind, this.uvs4), this.uvs5 && i(Hi.UV5Kind, this.uvs5), this.uvs6 && i(Hi.UV6Kind, this.uvs6), this.colors && i(Hi.ColorKind, this.colors), this.matricesIndices && i(Hi.MatricesIndicesKind, this.matricesIndices), this.matricesWeights && i(Hi.MatricesWeightsKind, this.matricesWeights), this.matricesIndicesExtra && i(Hi.MatricesIndicesExtraKind, this.matricesIndicesExtra), this.matricesWeightsExtra && i(Hi.MatricesWeightsExtraKind, this.matricesWeightsExtra) }, e.prototype.clone = function () { var t = this.serialize(); return e.Parse(t) }, e.prototype.serialize = function () { var e = {}; if (this.positions && (e.positions = Array.from(this.positions)), this.normals && (e.normals = Array.from(this.normals)), this.tangents && (e.tangents = Array.from(this.tangents)), this.uvs && (e.uvs = Array.from(this.uvs)), this.uvs2 && (e.uvs2 = Array.from(this.uvs2)), this.uvs3 && (e.uvs3 = Array.from(this.uvs3)), this.uvs4 && (e.uvs4 = Array.from(this.uvs4)), this.uvs5 && (e.uvs5 = Array.from(this.uvs5)), this.uvs6 && (e.uvs6 = Array.from(this.uvs6)), this.colors && (e.colors = Array.from(this.colors)), this.matricesIndices && (e.matricesIndices = Array.from(this.matricesIndices), e.matricesIndices._isExpanded = !0), this.matricesWeights && (e.matricesWeights = Array.from(this.matricesWeights)), this.matricesIndicesExtra && (e.matricesIndicesExtra = Array.from(this.matricesIndicesExtra), e.matricesIndicesExtra._isExpanded = !0), this.matricesWeightsExtra && (e.matricesWeightsExtra = Array.from(this.matricesWeightsExtra)), e.indices = Array.from(this.indices), this.materialInfos) { e.materialInfos = []; for (var t = 0, i = this.materialInfos; t < i.length; t++) { var r = i[t], n = { indexStart: r.indexStart, indexCount: r.indexCount, materialIndex: r.materialIndex, verticesStart: r.verticesStart, verticesCount: r.verticesCount }; e.materialInfos.push(n) } } return e }, e.ExtractFromMesh = function (t, i, r) { return e._ExtractFrom(t, i, r) }, e.ExtractFromGeometry = function (t, i, r) { return e._ExtractFrom(t, i, r) }, e._ExtractFrom = function (t, i, r) { var n = new e; return t.isVerticesDataPresent(Hi.PositionKind) && (n.positions = t.getVerticesData(Hi.PositionKind, i, r)), t.isVerticesDataPresent(Hi.NormalKind) && (n.normals = t.getVerticesData(Hi.NormalKind, i, r)), t.isVerticesDataPresent(Hi.TangentKind) && (n.tangents = t.getVerticesData(Hi.TangentKind, i, r)), t.isVerticesDataPresent(Hi.UVKind) && (n.uvs = t.getVerticesData(Hi.UVKind, i, r)), t.isVerticesDataPresent(Hi.UV2Kind) && (n.uvs2 = t.getVerticesData(Hi.UV2Kind, i, r)), t.isVerticesDataPresent(Hi.UV3Kind) && (n.uvs3 = t.getVerticesData(Hi.UV3Kind, i, r)), t.isVerticesDataPresent(Hi.UV4Kind) && (n.uvs4 = t.getVerticesData(Hi.UV4Kind, i, r)), t.isVerticesDataPresent(Hi.UV5Kind) && (n.uvs5 = t.getVerticesData(Hi.UV5Kind, i, r)), t.isVerticesDataPresent(Hi.UV6Kind) && (n.uvs6 = t.getVerticesData(Hi.UV6Kind, i, r)), t.isVerticesDataPresent(Hi.ColorKind) && (n.colors = t.getVerticesData(Hi.ColorKind, i, r)), t.isVerticesDataPresent(Hi.MatricesIndicesKind) && (n.matricesIndices = t.getVerticesData(Hi.MatricesIndicesKind, i, r)), t.isVerticesDataPresent(Hi.MatricesWeightsKind) && (n.matricesWeights = t.getVerticesData(Hi.MatricesWeightsKind, i, r)), t.isVerticesDataPresent(Hi.MatricesIndicesExtraKind) && (n.matricesIndicesExtra = t.getVerticesData(Hi.MatricesIndicesExtraKind, i, r)), t.isVerticesDataPresent(Hi.MatricesWeightsExtraKind) && (n.matricesWeightsExtra = t.getVerticesData(Hi.MatricesWeightsExtraKind, i, r)), n.indices = t.getIndices(i, r), n }, e.CreateRibbon = function (e) { throw ge("ribbonBuilder") }, e.CreateBox = function (e) { throw ge("boxBuilder") }, e.CreateTiledBox = function (e) { throw ge("tiledBoxBuilder") }, e.CreateTiledPlane = function (e) { throw ge("tiledPlaneBuilder") }, e.CreateSphere = function (e) { throw ge("sphereBuilder") }, e.CreateCylinder = function (e) { throw ge("cylinderBuilder") }, e.CreateTorus = function (e) { throw ge("torusBuilder") }, e.CreateLineSystem = function (e) { throw ge("linesBuilder") }, e.CreateDashedLines = function (e) { throw ge("linesBuilder") }, e.CreateGround = function (e) { throw ge("groundBuilder") }, e.CreateTiledGround = function (e) { throw ge("groundBuilder") }, e.CreateGroundFromHeightMap = function (e) { throw ge("groundBuilder") }, e.CreatePlane = function (e) { throw ge("planeBuilder") }, e.CreateDisc = function (e) { throw ge("discBuilder") }, e.CreatePolygon = function (e, t, i, r, n, o, a) { throw ge("polygonBuilder") }, e.CreateIcoSphere = function (e) { throw ge("icoSphereBuilder") }, e.CreatePolyhedron = function (e) { throw ge("polyhedronBuilder") }, e.CreateCapsule = function (e) { throw void 0 === e && (e = { orientation: R.Up(), subdivisions: 2, tessellation: 16, height: 1, radius: .25, capSubdivisions: 6 }), ge("capsuleBuilder") }, e.CreateTorusKnot = function (e) { throw ge("torusKnotBuilder") }, e.ComputeNormals = function (e, t, i, r) { var n = 0, o = 0, a = 0, s = 0, l = 0, c = 0, u = 0, h = 0, d = 0, p = 0, f = 0, _ = 0, m = 0, g = 0, v = 0, y = 0, b = 0, T = 0, E = 0, S = 0, x = !1, A = !1, C = !1, P = !1, I = 1, M = 0, O = null; r && (x = !!r.facetNormals, A = !!r.facetPositions, C = !!r.facetPartitioning, I = !0 === r.useRightHandedSystem ? -1 : 1, M = r.ratio || 0, P = !!r.depthSort, O = r.distanceTo, P && void 0 === O && (O = R.Zero())); var D = 0, N = 0, F = 0, L = 0; for (C && r && r.bbSize && (D = r.subDiv.X * M / r.bbSize.x, N = r.subDiv.Y * M / r.bbSize.y, F = r.subDiv.Z * M / r.bbSize.z, L = r.subDiv.max * r.subDiv.max, r.facetPartitioning.length = 0), n = 0; n < e.length; n++)i[n] = 0; var w = t.length / 3 | 0; for (n = 0; n < w; n++) { if (m = 1 + (_ = 3 * t[3 * n]), g = _ + 2, y = 1 + (v = 3 * t[3 * n + 1]), b = v + 2, E = 1 + (T = 3 * t[3 * n + 2]), S = T + 2, o = e[_] - e[v], a = e[m] - e[y], s = e[g] - e[b], l = e[T] - e[v], c = e[E] - e[y], h = I * (a * (u = e[S] - e[b]) - s * c), d = I * (s * l - o * u), p = I * (o * c - a * l), h /= f = 0 === (f = Math.sqrt(h * h + d * d + p * p)) ? 1 : f, d /= f, p /= f, x && r && (r.facetNormals[n].x = h, r.facetNormals[n].y = d, r.facetNormals[n].z = p), A && r && (r.facetPositions[n].x = (e[_] + e[v] + e[T]) / 3, r.facetPositions[n].y = (e[m] + e[y] + e[E]) / 3, r.facetPositions[n].z = (e[g] + e[b] + e[S]) / 3), C && r) { var B = Math.floor((r.facetPositions[n].x - r.bInfo.minimum.x * M) * D), U = Math.floor((r.facetPositions[n].y - r.bInfo.minimum.y * M) * N), V = Math.floor((r.facetPositions[n].z - r.bInfo.minimum.z * M) * F), k = Math.floor((e[_] - r.bInfo.minimum.x * M) * D), G = Math.floor((e[m] - r.bInfo.minimum.y * M) * N), z = Math.floor((e[g] - r.bInfo.minimum.z * M) * F), W = Math.floor((e[v] - r.bInfo.minimum.x * M) * D), H = Math.floor((e[y] - r.bInfo.minimum.y * M) * N), X = Math.floor((e[b] - r.bInfo.minimum.z * M) * F), j = Math.floor((e[T] - r.bInfo.minimum.x * M) * D), Y = Math.floor((e[E] - r.bInfo.minimum.y * M) * N), K = Math.floor((e[S] - r.bInfo.minimum.z * M) * F), Q = k + r.subDiv.max * G + L * z, q = W + r.subDiv.max * H + L * X, Z = j + r.subDiv.max * Y + L * K, J = B + r.subDiv.max * U + L * V; r.facetPartitioning[J] = r.facetPartitioning[J] ? r.facetPartitioning[J] : new Array, r.facetPartitioning[Q] = r.facetPartitioning[Q] ? r.facetPartitioning[Q] : new Array, r.facetPartitioning[q] = r.facetPartitioning[q] ? r.facetPartitioning[q] : new Array, r.facetPartitioning[Z] = r.facetPartitioning[Z] ? r.facetPartitioning[Z] : new Array, r.facetPartitioning[Q].push(n), q != Q && r.facetPartitioning[q].push(n), Z != q && Z != Q && r.facetPartitioning[Z].push(n), J != Q && J != q && J != Z && r.facetPartitioning[J].push(n) } if (P && r && r.facetPositions) { var $ = r.depthSortedFacets[n]; $.ind = 3 * n, $.sqDistance = R.DistanceSquared(r.facetPositions[n], O) } i[_] += h, i[m] += d, i[g] += p, i[v] += h, i[y] += d, i[b] += p, i[T] += h, i[E] += d, i[S] += p } for (n = 0; n < i.length / 3; n++)h = i[3 * n], d = i[3 * n + 1], p = i[3 * n + 2], h /= f = 0 === (f = Math.sqrt(h * h + d * d + p * p)) ? 1 : f, d /= f, p /= f, i[3 * n] = h, i[3 * n + 1] = d, i[3 * n + 2] = p }, e._ComputeSides = function (t, i, r, n, o, a, s) { var l, c, u = r.length, h = n.length; switch (t = t || e.DEFAULTSIDE) { case e.FRONTSIDE: break; case e.BACKSIDE: for (l = 0; l < u; l += 3) { var d = r[l]; r[l] = r[l + 2], r[l + 2] = d } for (c = 0; c < h; c++)n[c] = -n[c]; break; case e.DOUBLESIDE: for (var p = i.length, f = p / 3, _ = 0; _ < p; _++)i[p + _] = i[_]; for (l = 0; l < u; l += 3)r[l + u] = r[l + 2] + f, r[l + 1 + u] = r[l + 1] + f, r[l + 2 + u] = r[l] + f; for (c = 0; c < h; c++)n[h + c] = -n[c]; var m = o.length, g = 0; for (g = 0; g < m; g++)o[g + m] = o[g]; for (a = a || new C(0, 0, 1, 1), s = s || new C(0, 0, 1, 1), g = 0, l = 0; l < m / 2; l++)o[g] = a.x + (a.z - a.x) * o[g], o[g + 1] = a.y + (a.w - a.y) * o[g + 1], o[g + m] = s.x + (s.z - s.x) * o[g + m], o[g + m + 1] = s.y + (s.w - s.y) * o[g + m + 1], g += 2 } }, e.Parse = function (t) { var i = new e, r = t.positions; r && i.set(r, Hi.PositionKind); var n = t.normals; n && i.set(n, Hi.NormalKind); var o = t.tangents; o && i.set(o, Hi.TangentKind); var a = t.uvs; a && i.set(a, Hi.UVKind); var s = t.uvs2; s && i.set(s, Hi.UV2Kind); var l = t.uvs3; l && i.set(l, Hi.UV3Kind); var c = t.uvs4; c && i.set(c, Hi.UV4Kind); var u = t.uvs5; u && i.set(u, Hi.UV5Kind); var h = t.uvs6; h && i.set(h, Hi.UV6Kind); var d = t.colors; d && i.set(U.CheckColors4(d, r.length / 3), Hi.ColorKind); var p = t.matricesIndices; p && i.set(p, Hi.MatricesIndicesKind); var f = t.matricesWeights; f && i.set(f, Hi.MatricesWeightsKind); var _ = t.indices; _ && (i.indices = _); var m = t.materialInfos; if (m) { i.materialInfos = []; for (var g = 0, v = m; g < v.length; g++) { var y = v[g], b = new Tn; b.indexCount = y.indexCount, b.indexStart = y.indexStart, b.verticesCount = y.verticesCount, b.verticesStart = y.verticesStart, b.materialIndex = y.materialIndex, i.materialInfos.push(b) } } return i }, e.ImportVertexData = function (t, i) { var r = e.Parse(t); i.setAllVerticesData(r, t.updatable) }, e.FRONTSIDE = 0, e.BACKSIDE = 1, e.DOUBLESIDE = 2, e.DEFAULTSIDE = 0, X([Ve.filter((function () { for (var e = [], t = 0; t < arguments.length; t++)e[t] = arguments[t]; var i = e[0]; return !Array.isArray(i) }))], e, "_TransformVector3Coordinates", null), X([Ve.filter((function () { for (var e = [], t = 0; t < arguments.length; t++)e[t] = arguments[t]; var i = e[0]; return !Array.isArray(i) }))], e, "_TransformVector3Normals", null), X([Ve.filter((function () { for (var e = [], t = 0; t < arguments.length; t++)e[t] = arguments[t]; var i = e[0]; return !Array.isArray(i) }))], e, "_TransformVector4Normals", null), X([Ve.filter((function () { for (var e = [], t = 0; t < arguments.length; t++)e[t] = arguments[t]; var i = e[0]; return !Array.isArray(i) }))], e, "_FlipFaces", null), e }(), Sn = function () { function e() { } return Object.defineProperty(e, "ForceFullSceneLoadingForIncremental", { get: function () { return e._ForceFullSceneLoadingForIncremental }, set: function (t) { e._ForceFullSceneLoadingForIncremental = t }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "ShowLoadingScreen", { get: function () { return e._ShowLoadingScreen }, set: function (t) { e._ShowLoadingScreen = t }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "loggingLevel", { get: function () { return e._LoggingLevel }, set: function (t) { e._LoggingLevel = t }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "CleanBoneMatrixWeights", { get: function () { return e._CleanBoneMatrixWeights }, set: function (t) { e._CleanBoneMatrixWeights = t }, enumerable: !1, configurable: !0 }), e._ForceFullSceneLoadingForIncremental = !1, e._ShowLoadingScreen = !0, e._CleanBoneMatrixWeights = !1, e._LoggingLevel = a.SCENELOADER_NO_LOGGING, e }(), xn = function () { function e() { } return e.UseOpenGLOrientationForUV = !1, e }(), An = function () { function e(e, t, i, r, n) { void 0 === r && (r = !1), void 0 === n && (n = null), this.delayLoadState = a.DELAYLOADSTATE_NONE, this._totalVertices = 0, this._isDisposed = !1, this._indexBufferIsUpdatable = !1, this._positionsCache = [], this._parentContainer = null, this.useBoundingInfoFromGeometry = !1, this._scene = t || S.LastCreatedScene, this._scene && (this.id = e, this.uniqueId = this._scene.getUniqueId(), this._engine = this._scene.getEngine(), this._meshes = [], this._vertexBuffers = {}, this._indices = [], this._updatable = r, i ? this.setAllVerticesData(i, r) : this._totalVertices = 0, this._engine.getCaps().vertexArrayObject && (this._vertexArrayObjects = {}), n && (this.applyToMesh(n), n.computeWorldMatrix(!0))) } return Object.defineProperty(e.prototype, "boundingBias", { get: function () { return this._boundingBias }, set: function (e) { this._boundingBias ? this._boundingBias.copyFrom(e) : this._boundingBias = e.clone(), this._updateBoundingInfo(!0, null) }, enumerable: !1, configurable: !0 }), e.CreateGeometryForMesh = function (t) { var i = new e(e.RandomId(), t.getScene()); return i.applyToMesh(t), i }, Object.defineProperty(e.prototype, "meshes", { get: function () { return this._meshes }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "extend", { get: function () { return this._extend }, enumerable: !1, configurable: !0 }), e.prototype.getScene = function () { return this._scene }, e.prototype.getEngine = function () { return this._engine }, e.prototype.isReady = function () { return this.delayLoadState === a.DELAYLOADSTATE_LOADED || this.delayLoadState === a.DELAYLOADSTATE_NONE }, Object.defineProperty(e.prototype, "doNotSerialize", { get: function () { for (var e = 0; e < this._meshes.length; e++)if (!this._meshes[e].doNotSerialize) return !1; return !0 }, enumerable: !1, configurable: !0 }), e.prototype._rebuild = function () { for (var e in this._vertexArrayObjects && (this._vertexArrayObjects = {}), 0 !== this._meshes.length && this._indices && (this._indexBuffer = this._engine.createIndexBuffer(this._indices, this._updatable)), this._vertexBuffers) this._vertexBuffers[e]._rebuild() }, e.prototype.setAllVerticesData = function (e, t) { e.applyToGeometry(this, t), this._notifyUpdate() }, e.prototype.setVerticesData = function (e, t, i, r) { void 0 === i && (i = !1), i && Array.isArray(t) && (t = new Float32Array(t)); var n = new Hi(this._engine, t, e, i, 0 === this._meshes.length, r); this.setVerticesBuffer(n) }, e.prototype.removeVerticesData = function (e) { this._vertexBuffers[e] && (this._vertexBuffers[e].dispose(), delete this._vertexBuffers[e]), this._vertexArrayObjects && this._disposeVertexArrayObjects() }, e.prototype.setVerticesBuffer = function (e, t, i) { void 0 === t && (t = null), void 0 === i && (i = !0); var r = e.getKind(); this._vertexBuffers[r] && i && this._vertexBuffers[r].dispose(), e._buffer && e._buffer._increaseReferences(), this._vertexBuffers[r] = e; var n = this._meshes, o = n.length; if (r === Hi.PositionKind) { var a = e.getData(); null != t ? this._totalVertices = t : null != a && (this._totalVertices = a.length / (e.type === Hi.BYTE ? e.byteStride : e.byteStride / 4)), this._updateExtend(a), this._resetPointsArrayCache(); for (var s = 0; s < o; s++) { var l = n[s]; l.buildBoundingInfo(this._extend.minimum, this._extend.maximum), l._createGlobalSubMesh(l.isUnIndexed), l.computeWorldMatrix(!0), l.synchronizeInstances() } } this._notifyUpdate(r) }, e.prototype.updateVerticesDataDirectly = function (e, t, i, r) { void 0 === r && (r = !1); var n = this.getVertexBuffer(e); n && (n.updateDirectly(t, i, r), this._notifyUpdate(e)) }, e.prototype.updateVerticesData = function (e, t, i) { void 0 === i && (i = !1); var r = this.getVertexBuffer(e); r && (r.update(t), e === Hi.PositionKind && this._updateBoundingInfo(i, t), this._notifyUpdate(e)) }, e.prototype._updateBoundingInfo = function (e, t) { if (e && this._updateExtend(t), this._resetPointsArrayCache(), e) for (var i = 0, r = this._meshes; i < r.length; i++) { var n = r[i]; n.hasBoundingInfo ? n.getBoundingInfo().reConstruct(this._extend.minimum, this._extend.maximum) : n.buildBoundingInfo(this._extend.minimum, this._extend.maximum); for (var o = 0, a = n.subMeshes; o < a.length; o++)a[o].refreshBoundingInfo() } }, e.prototype._bind = function (e, t, i, r) { if (e) { void 0 === t && (t = this._indexBuffer); var n = this.getVertexBuffers(); if (n) if (t == this._indexBuffer && (this._vertexArrayObjects || r)) { var o = r || this._vertexArrayObjects; o[e.key] || (o[e.key] = this._engine.recordVertexArrayObject(n, t, e, i)), this._engine.bindVertexArrayObject(o[e.key], t) } else this._engine.bindBuffers(n, t, e, i) } }, e.prototype.getTotalVertices = function () { return this.isReady() ? this._totalVertices : 0 }, e.prototype.getVerticesData = function (e, t, i) { var r = this.getVertexBuffer(e); return r ? r.getFloatData(this._totalVertices, i || t && 1 !== this._meshes.length) : null }, e.prototype.isVertexBufferUpdatable = function (e) { var t = this._vertexBuffers[e]; return !!t && t.isUpdatable() }, e.prototype.getVertexBuffer = function (e) { return this.isReady() ? this._vertexBuffers[e] : null }, e.prototype.getVertexBuffers = function () { return this.isReady() ? this._vertexBuffers : null }, e.prototype.isVerticesDataPresent = function (e) { return this._vertexBuffers ? void 0 !== this._vertexBuffers[e] : !!this._delayInfo && -1 !== this._delayInfo.indexOf(e) }, e.prototype.getVerticesDataKinds = function () { var e, t = []; if (!this._vertexBuffers && this._delayInfo) for (e in this._delayInfo) t.push(e); else for (e in this._vertexBuffers) t.push(e); return t }, e.prototype.updateIndices = function (e, t, i) { if (void 0 === i && (i = !1), this._indexBuffer) if (this._indexBufferIsUpdatable) { var r = e.length !== this._indices.length; if (i || (this._indices = e.slice()), this._engine.updateDynamicIndexBuffer(this._indexBuffer, e, t), r) for (var n = 0, o = this._meshes; n < o.length; n++)o[n]._createGlobalSubMesh(!0) } else this.setIndices(e, null, !0) }, e.prototype.setIndices = function (e, t, i) { void 0 === t && (t = null), void 0 === i && (i = !1), this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer), this._indices = e, this._indexBufferIsUpdatable = i, 0 !== this._meshes.length && this._indices && (this._indexBuffer = this._engine.createIndexBuffer(this._indices, i)), null != t && (this._totalVertices = t); for (var r = 0, n = this._meshes; r < n.length; r++) { var o = n[r]; o._createGlobalSubMesh(!0), o.synchronizeInstances() } this._notifyUpdate() }, e.prototype.getTotalIndices = function () { return this.isReady() ? this._indices.length : 0 }, e.prototype.getIndices = function (e, t) { if (!this.isReady()) return null; var i = this._indices; return t || e && 1 !== this._meshes.length ? i.slice() : i }, e.prototype.getIndexBuffer = function () { return this.isReady() ? this._indexBuffer : null }, e.prototype._releaseVertexArrayObject = function (e) { void 0 === e && (e = null), e && this._vertexArrayObjects && this._vertexArrayObjects[e.key] && (this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e.key]), delete this._vertexArrayObjects[e.key]) }, e.prototype.releaseForMesh = function (e, t) { var i = this._meshes, r = i.indexOf(e); -1 !== r && (i.splice(r, 1), this._vertexArrayObjects && e._invalidateInstanceVertexArrayObject(), e._geometry = null, 0 === i.length && t && this.dispose()) }, e.prototype.applyToMesh = function (e) { if (e._geometry !== this) { var t = e._geometry; t && t.releaseForMesh(e), this._vertexArrayObjects && e._invalidateInstanceVertexArrayObject(); var i = this._meshes; e._geometry = this, e._internalAbstractMeshDataInfo._positions = null, this._scene.pushGeometry(this), i.push(e), this.isReady() ? this._applyToMesh(e) : this._boundingInfo && e.setBoundingInfo(this._boundingInfo) } }, e.prototype._updateExtend = function (e) { if (void 0 === e && (e = null), this.useBoundingInfoFromGeometry && this._boundingInfo) this._extend = { minimum: this._boundingInfo.minimum.clone(), maximum: this._boundingInfo.maximum.clone() }; else { if (!e && !(e = this.getVerticesData(Hi.PositionKind))) return; this._extend = yn(e, 0, this._totalVertices, this.boundingBias, 3) } }, e.prototype._applyToMesh = function (e) { var t = this._meshes.length; for (var i in this._vertexBuffers) 1 === t && this._vertexBuffers[i].create(), i === Hi.PositionKind && (this._extend || this._updateExtend(), e.buildBoundingInfo(this._extend.minimum, this._extend.maximum), e._createGlobalSubMesh(e.isUnIndexed), e._updateBoundingInfo()); 1 === t && this._indices && this._indices.length > 0 && (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; t < i.length; t++)i[t]._markSubMeshesAsAttributesDirty() }, e.prototype.load = function (e, t) { this.delayLoadState !== a.DELAYLOADSTATE_LOADING && (this.isReady() ? t && t() : (this.delayLoadState = a.DELAYLOADSTATE_LOADING, this._queueLoad(e, t))) }, e.prototype._queueLoad = function (e, t) { var i = this; this.delayLoadingFile && (e.addPendingData(this), e._loadFile(this.delayLoadingFile, (function (r) { if (i._delayLoadingFunction) { i._delayLoadingFunction(JSON.parse(r), i), i.delayLoadState = a.DELAYLOADSTATE_LOADED, i._delayInfo = [], e.removePendingData(i); for (var n = i._meshes, o = n.length, s = 0; s < o; s++)i._applyToMesh(n[s]); t && t() } }), void 0, !0)) }, e.prototype.toLeftHanded = function () { var e = this.getIndices(!1); if (null != e && e.length > 0) { for (var t = 0; t < e.length; t += 3) { var i = e[t + 0]; e[t + 0] = e[t + 2], e[t + 2] = i } this.setIndices(e) } var r = this.getVerticesData(Hi.PositionKind, !1); if (null != r && r.length > 0) { for (t = 0; t < r.length; t += 3)r[t + 2] = -r[t + 2]; this.setVerticesData(Hi.PositionKind, r, !1) } var n = this.getVerticesData(Hi.NormalKind, !1); if (null != n && n.length > 0) { for (t = 0; t < n.length; t += 3)n[t + 2] = -n[t + 2]; this.setVerticesData(Hi.NormalKind, n, !1) } }, e.prototype._resetPointsArrayCache = function () { this._positions = null }, e.prototype._generatePointsArray = function () { if (this._positions) return !0; var e = this.getVerticesData(Hi.PositionKind); if (!e || 0 === e.length) return !1; for (var t = 3 * this._positionsCache.length, i = this._positionsCache.length; t < e.length; t += 3, ++i)this._positionsCache[i] = R.FromArray(e, t); for (t = 0, i = 0; t < e.length; t += 3, ++i)this._positionsCache[i].set(e[0 + t], e[1 + t], e[2 + t]); return this._positionsCache.length = e.length / 3, this._positions = this._positionsCache, !0 }, e.prototype.isDisposed = function () { return this._isDisposed }, e.prototype._disposeVertexArrayObjects = function () { if (this._vertexArrayObjects) { for (var e in this._vertexArrayObjects) this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e]); this._vertexArrayObjects = {}; for (var t = this._meshes, i = t.length, r = 0; r < i; r++)t[r]._invalidateInstanceVertexArrayObject() } }, e.prototype.dispose = function () { var e, t = this._meshes, i = t.length; for (e = 0; e < i; e++)this.releaseForMesh(t[e]); for (var r in this._meshes.length = 0, this._disposeVertexArrayObjects(), this._vertexBuffers) this._vertexBuffers[r].dispose(); if (this._vertexBuffers = {}, this._totalVertices = 0, this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer), this._indexBuffer = null, this._indices = [], this.delayLoadState = a.DELAYLOADSTATE_NONE, this.delayLoadingFile = null, this._delayLoadingFunction = null, this._delayInfo = [], this._boundingInfo = null, this._scene.removeGeometry(this), this._parentContainer) { var n = this._parentContainer.geometries.indexOf(this); n > -1 && this._parentContainer.geometries.splice(n, 1), this._parentContainer = null } this._isDisposed = !0 }, e.prototype.copy = function (t) { var i = new En; i.indices = []; var r = this.getIndices(); if (r) for (var n = 0; n < r.length; n++)i.indices.push(r[n]); var o, a = !1, s = !1; for (o in this._vertexBuffers) { var l = this.getVerticesData(o); if (l && (l instanceof Float32Array ? i.set(new Float32Array(l), o) : i.set(l.slice(0), o), !s)) { var c = this.getVertexBuffer(o); c && (s = !(a = c.isUpdatable())) } } var u = new e(t, this._scene, i, a); for (o in u.delayLoadState = this.delayLoadState, u.delayLoadingFile = this.delayLoadingFile, u._delayLoadingFunction = this._delayLoadingFunction, this._delayInfo) u._delayInfo = u._delayInfo || [], u._delayInfo.push(o); return u._boundingInfo = new mn(this._extend.minimum, this._extend.maximum), u }, e.prototype.serialize = function () { var e = {}; return e.id = this.id, e.uniqueId = this.uniqueId, e.updatable = this._updatable, me && me.HasTags(this) && (e.tags = me.GetTags(this)), e }, e.prototype._toNumberArray = function (e) { return Array.isArray(e) ? e : Array.prototype.slice.call(e) }, e.prototype.clearCachedData = function () { for (var e in this._indices = [], this._resetPointsArrayCache(), this._vertexBuffers) Object.prototype.hasOwnProperty.call(this._vertexBuffers, e) && (this._vertexBuffers[e]._buffer._data = null) }, e.prototype.serializeVerticeData = function () { var e = this.serialize(); return this.isVerticesDataPresent(Hi.PositionKind) && (e.positions = this._toNumberArray(this.getVerticesData(Hi.PositionKind)), this.isVertexBufferUpdatable(Hi.PositionKind) && (e.positions._updatable = !0)), this.isVerticesDataPresent(Hi.NormalKind) && (e.normals = this._toNumberArray(this.getVerticesData(Hi.NormalKind)), this.isVertexBufferUpdatable(Hi.NormalKind) && (e.normals._updatable = !0)), this.isVerticesDataPresent(Hi.TangentKind) && (e.tangents = this._toNumberArray(this.getVerticesData(Hi.TangentKind)), this.isVertexBufferUpdatable(Hi.TangentKind) && (e.tangents._updatable = !0)), this.isVerticesDataPresent(Hi.UVKind) && (e.uvs = this._toNumberArray(this.getVerticesData(Hi.UVKind)), this.isVertexBufferUpdatable(Hi.UVKind) && (e.uvs._updatable = !0)), this.isVerticesDataPresent(Hi.UV2Kind) && (e.uv2s = this._toNumberArray(this.getVerticesData(Hi.UV2Kind)), this.isVertexBufferUpdatable(Hi.UV2Kind) && (e.uv2s._updatable = !0)), this.isVerticesDataPresent(Hi.UV3Kind) && (e.uv3s = this._toNumberArray(this.getVerticesData(Hi.UV3Kind)), this.isVertexBufferUpdatable(Hi.UV3Kind) && (e.uv3s._updatable = !0)), this.isVerticesDataPresent(Hi.UV4Kind) && (e.uv4s = this._toNumberArray(this.getVerticesData(Hi.UV4Kind)), this.isVertexBufferUpdatable(Hi.UV4Kind) && (e.uv4s._updatable = !0)), this.isVerticesDataPresent(Hi.UV5Kind) && (e.uv5s = this._toNumberArray(this.getVerticesData(Hi.UV5Kind)), this.isVertexBufferUpdatable(Hi.UV5Kind) && (e.uv5s._updatable = !0)), this.isVerticesDataPresent(Hi.UV6Kind) && (e.uv6s = this._toNumberArray(this.getVerticesData(Hi.UV6Kind)), this.isVertexBufferUpdatable(Hi.UV6Kind) && (e.uv6s._updatable = !0)), this.isVerticesDataPresent(Hi.ColorKind) && (e.colors = this._toNumberArray(this.getVerticesData(Hi.ColorKind)), this.isVertexBufferUpdatable(Hi.ColorKind) && (e.colors._updatable = !0)), this.isVerticesDataPresent(Hi.MatricesIndicesKind) && (e.matricesIndices = this._toNumberArray(this.getVerticesData(Hi.MatricesIndicesKind)), e.matricesIndices._isExpanded = !0, this.isVertexBufferUpdatable(Hi.MatricesIndicesKind) && (e.matricesIndices._updatable = !0)), this.isVerticesDataPresent(Hi.MatricesWeightsKind) && (e.matricesWeights = this._toNumberArray(this.getVerticesData(Hi.MatricesWeightsKind)), this.isVertexBufferUpdatable(Hi.MatricesWeightsKind) && (e.matricesWeights._updatable = !0)), e.indices = this._toNumberArray(this.getIndices()), e }, e.ExtractFromMesh = function (e, t) { var i = e._geometry; return i ? i.copy(t) : null }, e.RandomId = function () { return xi.RandomId() }, e._GetGeometryByLoadedUniqueId = function (e, t) { for (var i = 0; i < t.geometries.length; i++)if (t.geometries[i]._loadedUniqueId === e) return t.geometries[i]; return null }, e._ImportGeometry = function (t, i) { var r = i.getScene(), n = t.geometryUniqueId, o = t.geometryId; if (n || o) { var a = n ? this._GetGeometryByLoadedUniqueId(n, r) : r.getGeometryById(o); a && a.applyToMesh(i) } else if (t instanceof ArrayBuffer) { var s = i._binaryInfo; if (s.positionsAttrDesc && s.positionsAttrDesc.count > 0) { var l = new Float32Array(t, s.positionsAttrDesc.offset, s.positionsAttrDesc.count); i.setVerticesData(Hi.PositionKind, l, !1) } if (s.normalsAttrDesc && s.normalsAttrDesc.count > 0) { var c = new Float32Array(t, s.normalsAttrDesc.offset, s.normalsAttrDesc.count); i.setVerticesData(Hi.NormalKind, c, !1) } if (s.tangetsAttrDesc && s.tangetsAttrDesc.count > 0) { var u = new Float32Array(t, s.tangetsAttrDesc.offset, s.tangetsAttrDesc.count); i.setVerticesData(Hi.TangentKind, u, !1) } if (s.uvsAttrDesc && s.uvsAttrDesc.count > 0) { var h = new Float32Array(t, s.uvsAttrDesc.offset, s.uvsAttrDesc.count); if (xn.UseOpenGLOrientationForUV) for (var d = 1; d < h.length; d += 2)h[d] = 1 - h[d]; i.setVerticesData(Hi.UVKind, h, !1) } if (s.uvs2AttrDesc && s.uvs2AttrDesc.count > 0) { var p = new Float32Array(t, s.uvs2AttrDesc.offset, s.uvs2AttrDesc.count); if (xn.UseOpenGLOrientationForUV) for (d = 1; d < p.length; d += 2)p[d] = 1 - p[d]; i.setVerticesData(Hi.UV2Kind, p, !1) } if (s.uvs3AttrDesc && s.uvs3AttrDesc.count > 0) { var f = new Float32Array(t, s.uvs3AttrDesc.offset, s.uvs3AttrDesc.count); if (xn.UseOpenGLOrientationForUV) for (d = 1; d < f.length; d += 2)f[d] = 1 - f[d]; i.setVerticesData(Hi.UV3Kind, f, !1) } if (s.uvs4AttrDesc && s.uvs4AttrDesc.count > 0) { var _ = new Float32Array(t, s.uvs4AttrDesc.offset, s.uvs4AttrDesc.count); if (xn.UseOpenGLOrientationForUV) for (d = 1; d < _.length; d += 2)_[d] = 1 - _[d]; i.setVerticesData(Hi.UV4Kind, _, !1) } if (s.uvs5AttrDesc && s.uvs5AttrDesc.count > 0) { var m = new Float32Array(t, s.uvs5AttrDesc.offset, s.uvs5AttrDesc.count); if (xn.UseOpenGLOrientationForUV) for (d = 1; d < m.length; d += 2)m[d] = 1 - m[d]; i.setVerticesData(Hi.UV5Kind, m, !1) } if (s.uvs6AttrDesc && s.uvs6AttrDesc.count > 0) { var g = new Float32Array(t, s.uvs6AttrDesc.offset, s.uvs6AttrDesc.count); if (xn.UseOpenGLOrientationForUV) for (d = 1; d < g.length; d += 2)g[d] = 1 - g[d]; i.setVerticesData(Hi.UV6Kind, g, !1) } if (s.colorsAttrDesc && s.colorsAttrDesc.count > 0) { var v = new Float32Array(t, s.colorsAttrDesc.offset, s.colorsAttrDesc.count); i.setVerticesData(Hi.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 < y.length; T++)d = y[T], b.push(255 & d), b.push((65280 & d) >> 8), b.push((16711680 & d) >> 16), b.push(d >> 24 & 255); i.setVerticesData(Hi.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 < y.length; T++)d = y[T], b.push(255 & d), b.push((65280 & d) >> 8), b.push((16711680 & d) >> 16), b.push(d >> 24 & 255); i.setVerticesData(Hi.MatricesIndicesExtraKind, b, !1) } if (s.matricesWeightsAttrDesc && s.matricesWeightsAttrDesc.count > 0) { var E = new Float32Array(t, s.matricesWeightsAttrDesc.offset, s.matricesWeightsAttrDesc.count); i.setVerticesData(Hi.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 < s.subMeshesAttrDesc.count; T++) { var A = x[5 * T + 0], R = x[5 * T + 1], C = x[5 * T + 2], P = x[5 * T + 3], I = x[5 * T + 4]; bn.AddToMesh(A, R, C, P, I, i) } } } else if (t.positions && t.normals && t.indices) { if (i.setVerticesData(Hi.PositionKind, t.positions, t.positions._updatable), i.setVerticesData(Hi.NormalKind, t.normals, t.normals._updatable), t.tangents && i.setVerticesData(Hi.TangentKind, t.tangents, t.tangents._updatable), t.uvs && i.setVerticesData(Hi.UVKind, t.uvs, t.uvs._updatable), t.uvs2 && i.setVerticesData(Hi.UV2Kind, t.uvs2, t.uvs2._updatable), t.uvs3 && i.setVerticesData(Hi.UV3Kind, t.uvs3, t.uvs3._updatable), t.uvs4 && i.setVerticesData(Hi.UV4Kind, t.uvs4, t.uvs4._updatable), t.uvs5 && i.setVerticesData(Hi.UV5Kind, t.uvs5, t.uvs5._updatable), t.uvs6 && i.setVerticesData(Hi.UV6Kind, t.uvs6, t.uvs6._updatable), t.colors && i.setVerticesData(Hi.ColorKind, U.CheckColors4(t.colors, t.positions.length / 3), t.colors._updatable), t.matricesIndices) if (t.matricesIndices._isExpanded) delete t.matricesIndices._isExpanded, i.setVerticesData(Hi.MatricesIndicesKind, t.matricesIndices, t.matricesIndices._updatable); else { for (b = [], T = 0; T < t.matricesIndices.length; T++) { var M = t.matricesIndices[T]; b.push(255 & M), b.push((65280 & M) >> 8), b.push((16711680 & M) >> 16), b.push(M >> 24 & 255) } i.setVerticesData(Hi.MatricesIndicesKind, b, t.matricesIndices._updatable) } if (t.matricesIndicesExtra) if (t.matricesIndicesExtra._isExpanded) delete t.matricesIndices._isExpanded, i.setVerticesData(Hi.MatricesIndicesExtraKind, t.matricesIndicesExtra, t.matricesIndicesExtra._updatable); else { for (b = [], T = 0; T < t.matricesIndicesExtra.length; T++)M = t.matricesIndicesExtra[T], b.push(255 & M), b.push((65280 & M) >> 8), b.push((16711680 & M) >> 16), b.push(M >> 24 & 255); i.setVerticesData(Hi.MatricesIndicesExtraKind, b, t.matricesIndicesExtra._updatable) } t.matricesWeights && (e._CleanMatricesWeights(t, i), i.setVerticesData(Hi.MatricesWeightsKind, t.matricesWeights, t.matricesWeights._updatable)), t.matricesWeightsExtra && i.setVerticesData(Hi.MatricesWeightsExtraKind, t.matricesWeightsExtra, t.matricesWeights._updatable), i.setIndices(t.indices, null) } if (t.subMeshes) { i.subMeshes = []; for (var O = 0; O < t.subMeshes.length; O++) { var D = t.subMeshes[O]; bn.AddToMesh(D.materialIndex, D.verticesStart, D.verticesCount, D.indexStart, D.indexCount, i) } } i._shouldGenerateFlatShading && (i.convertToFlatShadedMesh(), i._shouldGenerateFlatShading = !1), i.computeWorldMatrix(!0), r.onMeshImportedObservable.notifyObservers(i) }, e._CleanMatricesWeights = function (e, t) { var i = .001; if (Sn.CleanBoneMatrixWeights) { var r = 0; if (e.skeletonId > -1) { var n = t.getScene().getLastSkeletonById(e.skeletonId); if (n) { r = n.bones.length; for (var o = t.getVerticesData(Hi.MatricesIndicesKind), a = t.getVerticesData(Hi.MatricesIndicesExtraKind), s = e.matricesWeights, l = e.matricesWeightsExtra, c = e.numBoneInfluencer, u = s.length, h = 0; h < u; h += 4) { for (var d = 0, p = -1, f = 0; f < 4; f++)d += _ = s[h + f], _ < i && p < 0 && (p = f); if (l) for (f = 0; f < 4; f++) { var _; d += _ = l[h + f], _ < i && p < 0 && (p = f + 4) } if ((p < 0 || p > c - 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(Hi.MatricesIndicesKind, o), e.matricesWeightsExtra && t.setVerticesData(Hi.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 mn(R.FromArray(t.boundingBoxMinimum), R.FromArray(t.boundingBoxMaximum)), n._delayInfo = [], t.hasUVs && n._delayInfo.push(Hi.UVKind), t.hasUVs2 && n._delayInfo.push(Hi.UV2Kind), t.hasUVs3 && n._delayInfo.push(Hi.UV3Kind), t.hasUVs4 && n._delayInfo.push(Hi.UV4Kind), t.hasUVs5 && n._delayInfo.push(Hi.UV5Kind), t.hasUVs6 && n._delayInfo.push(Hi.UV6Kind), t.hasColors && n._delayInfo.push(Hi.ColorKind), t.hasMatricesIndices && n._delayInfo.push(Hi.MatricesIndicesKind), t.hasMatricesWeights && n._delayInfo.push(Hi.MatricesWeightsKind), n._delayLoadingFunction = En.ImportVertexData) : En.ImportVertexData(t, n), i.pushGeometry(n, !0), n }, e }(), Rn = function () { function e(e) { void 0 === e && (e = 30), this._enabled = !0, this._rollingFrameTime = new Cn(e) } return e.prototype.sampleFrame = function (e) { if (void 0 === e && (e = at.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 }(), Cn = 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 Pn(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 } ti.prototype.setAlphaConstants = function (e, t, i, r) { this._alphaState.setAlphaBlendConstants(e, t, i, r) }, ti.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) } }, ti.prototype.getAlphaMode = function () { return this._alphaMode }, ti.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 } }, ti.prototype.getAlphaEquation = function () { return this._alphaEquation }, ti.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 = Pn(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 }, ti.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)) }, ti.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() }, ti.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 In = 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 mr, s.canvasTabIndex = 1, s.disablePerformanceMonitorInBackground = !1, s._performanceMonitor = new Rn, 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), s._connectVREvents() } return s._prepareVRComponent(), n.autoEnableWebVR && s.initWebVR(), s } return W(t, e), Object.defineProperty(t, "NpmPackage", { get: function () { return ti.NpmPackage }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "Version", { get: function () { return ti.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; r < t.Instances.length; r++)for (var n = t.Instances[r], o = 0; o < n.scenes.length; o++)n.scenes[o].markAllMaterialsAsDirty(e, i) }, t.DefaultLoadingScreenFactory = function (e) { throw ge("LoadingScreen") }, Object.defineProperty(t.prototype, "_supportsHardwareTextureRescaling", { get: function () { return !!t._RescalePostProcessFactory }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "performanceMonitor", { get: function () { return this._performanceMonitor }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "compatibilityMode", { get: function () { return this._compatibilityMode }, set: function (e) { this._compatibilityMode = !0 }, enumerable: !1, configurable: !0 }), t.prototype.getInputElement = function () { return this._renderingCanvas }, t.prototype._initGLContext = function () { e.prototype._initGLContext.call(this), this._rescalePostProcess = null }, t.prototype._sharedInit = function (i) { var r = this; e.prototype._sharedInit.call(this, i), this._onCanvasFocus = function () { r.onCanvasFocusObservable.notifyObservers(r) }, this._onCanvasBlur = function () { r.onCanvasBlurObservable.notifyObservers(r) }, this._onCanvasContextMenu = function (e) { r.disableContextMenu && e.preventDefault() }, i.addEventListener("focus", this._onCanvasFocus), i.addEventListener("blur", this._onCanvasBlur), i.addEventListener("contextmenu", this._onCanvasContextMenu), this._onBlur = function () { r.disablePerformanceMonitorInBackground && r._performanceMonitor.disable(), r._windowIsBackground = !0 }, this._onFocus = function () { r.disablePerformanceMonitorInBackground && r._performanceMonitor.enable(), r._windowIsBackground = !1 }, this._onCanvasPointerOut = function (e) { document.elementFromPoint(e.clientX, e.clientY) !== i && r.onCanvasPointerOutObservable.notifyObservers(e) }; var n = this.getHostWindow(); n && "function" == typeof n.addEventListener && (n.addEventListener("blur", this._onBlur), n.addEventListener("focus", this._onFocus)), i.addEventListener("pointerout", this._onCanvasPointerOut), this._creationOptions.doNotHandleTouchAction || this._disableTouchAction(), !t.audioEngine && this._creationOptions.audioEngine && t.AudioEngineFactory && (t.audioEngine = t.AudioEngineFactory(this.getRenderingCanvas(), this.getAudioContext(), this.getAudioDestination())), it() && (this._onFullscreenChange = function () { r.isFullscreen = !!document.fullscreenElement, r.isFullscreen && r._pointerLockRequested && i && t._RequestPointerlock(i) }, document.addEventListener("fullscreenchange", this._onFullscreenChange, !1), document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, !1), this._onPointerLockChange = function () { r.isPointerLock = document.pointerLockElement === i }, document.addEventListener("pointerlockchange", this._onPointerLockChange, !1), document.addEventListener("webkitpointerlockchange", this._onPointerLockChange, !1)), this.enableOfflineSupport = void 0 !== t.OfflineProviderFactory, this._deterministicLockstep = !!this._creationOptions.deterministicLockstep, this._lockstepMaxSteps = this._creationOptions.lockstepMaxSteps || 0, this._timeStep = this._creationOptions.timeStep || 1 / 60 }, t.prototype._verifyPointerLock = function () { var e; null === (e = this._onPointerLockChange) || void 0 === e || e.call(this) }, t.prototype.getAspectRatio = function (e, t) { void 0 === t && (t = !1); var i = e.viewport; return this.getRenderWidth(t) * i.width / (this.getRenderHeight(t) * i.height) }, t.prototype.getScreenAspectRatio = function () { return this.getRenderWidth(!0) / this.getRenderHeight(!0) }, t.prototype.getRenderingCanvasClientRect = function () { return this._renderingCanvas ? this._renderingCanvas.getBoundingClientRect() : null }, t.prototype.getInputElementClientRect = function () { return this._renderingCanvas ? this.getInputElement().getBoundingClientRect() : null }, t.prototype.isDeterministicLockStep = function () { return this._deterministicLockstep }, t.prototype.getLockstepMaxSteps = function () { return this._lockstepMaxSteps }, t.prototype.getTimeStep = function () { return 1e3 * this._timeStep }, t.prototype.generateMipMapsForCubemap = function (e, t) { if (void 0 === t && (t = !0), e.generateMipMaps) { var i = this._gl; this._bindTextureDirectly(i.TEXTURE_CUBE_MAP, e, !0), i.generateMipmap(i.TEXTURE_CUBE_MAP), t && this._bindTextureDirectly(i.TEXTURE_CUBE_MAP, null) } }, t.prototype.getDepthWrite = function () { return this._depthCullingState.depthMask }, t.prototype.setDepthWrite = function (e) { this._depthCullingState.depthMask = e }, t.prototype.getStencilBuffer = function () { return this._stencilState.stencilTest }, t.prototype.setStencilBuffer = function (e) { this._stencilState.stencilTest = e }, t.prototype.getStencilMask = function () { return this._stencilState.stencilMask }, t.prototype.setStencilMask = function (e) { this._stencilState.stencilMask = e }, t.prototype.getStencilFunction = function () { return this._stencilState.stencilFunc }, t.prototype.getStencilFunctionReference = function () { return this._stencilState.stencilFuncRef }, t.prototype.getStencilFunctionMask = function () { return this._stencilState.stencilFuncMask }, t.prototype.setStencilFunction = function (e) { this._stencilState.stencilFunc = e }, t.prototype.setStencilFunctionReference = function (e) { this._stencilState.stencilFuncRef = e }, t.prototype.setStencilFunctionMask = function (e) { this._stencilState.stencilFuncMask = e }, t.prototype.getStencilOperationFail = function () { return this._stencilState.stencilOpStencilFail }, t.prototype.getStencilOperationDepthFail = function () { return this._stencilState.stencilOpDepthFail }, t.prototype.getStencilOperationPass = function () { return this._stencilState.stencilOpStencilDepthPass }, t.prototype.setStencilOperationFail = function (e) { this._stencilState.stencilOpStencilFail = e }, t.prototype.setStencilOperationDepthFail = function (e) { this._stencilState.stencilOpDepthFail = e }, t.prototype.setStencilOperationPass = function (e) { this._stencilState.stencilOpStencilDepthPass = e }, t.prototype.setDitheringState = function (e) { e ? this._gl.enable(this._gl.DITHER) : this._gl.disable(this._gl.DITHER) }, t.prototype.setRasterizerState = function (e) { e ? this._gl.disable(this._gl.RASTERIZER_DISCARD) : this._gl.enable(this._gl.RASTERIZER_DISCARD) }, t.prototype.getDepthFunction = function () { return this._depthCullingState.depthFunc }, t.prototype.setDepthFunction = function (e) { this._depthCullingState.depthFunc = e }, t.prototype.setDepthFunctionToGreater = function () { this.setDepthFunction(a.GREATER) }, t.prototype.setDepthFunctionToGreaterOrEqual = function () { this.setDepthFunction(a.GEQUAL) }, t.prototype.setDepthFunctionToLess = function () { this.setDepthFunction(a.LESS) }, t.prototype.setDepthFunctionToLessOrEqual = function () { this.setDepthFunction(a.LEQUAL) }, t.prototype.cacheStencilState = function () { this._cachedStencilBuffer = this.getStencilBuffer(), this._cachedStencilFunction = this.getStencilFunction(), this._cachedStencilMask = this.getStencilMask(), this._cachedStencilOperationPass = this.getStencilOperationPass(), this._cachedStencilOperationFail = this.getStencilOperationFail(), this._cachedStencilOperationDepthFail = this.getStencilOperationDepthFail(), this._cachedStencilReference = this.getStencilFunctionReference() }, t.prototype.restoreStencilState = function () { this.setStencilFunction(this._cachedStencilFunction), this.setStencilMask(this._cachedStencilMask), this.setStencilBuffer(this._cachedStencilBuffer), this.setStencilOperationPass(this._cachedStencilOperationPass), this.setStencilOperationFail(this._cachedStencilOperationFail), this.setStencilOperationDepthFail(this._cachedStencilOperationDepthFail), this.setStencilFunctionReference(this._cachedStencilReference) }, t.prototype.setDirectViewport = function (e, t, i, r) { var n = this._cachedViewport; return this._cachedViewport = null, this._viewport(e, t, i, r), n }, t.prototype.scissorClear = function (e, t, i, r, n) { this.enableScissor(e, t, i, r), this.clear(n, !0, !0, !0), this.disableScissor() }, t.prototype.enableScissor = function (e, t, i, r) { var n = this._gl; n.enable(n.SCISSOR_TEST), n.scissor(e, t, i, r) }, t.prototype.disableScissor = function () { var e = this._gl; e.disable(e.SCISSOR_TEST) }, t.prototype._reportDrawCall = function (e) { void 0 === e && (e = 1), this._drawCalls.addCount(e, !1) }, t.prototype.initWebVR = function () { throw ge("WebVRCamera") }, t.prototype._prepareVRComponent = function () { }, t.prototype._connectVREvents = function (e, t) { }, t.prototype._submitVRFrame = function () { }, t.prototype.disableVR = function () { }, t.prototype.isVRPresenting = function () { return !1 }, t.prototype._requestVRFrame = function () { }, t.prototype._loadFileAsync = function (e, t, i) { var r = this; return new Promise((function (n, o) { r._loadFile(e, (function (e) { n(e) }), void 0, t, i, (function (e, t) { o(t) })) })) }, t.prototype.getVertexShaderSource = function (e) { var t = this._gl.getAttachedShaders(e); return t ? this._gl.getShaderSource(t[0]) : null }, t.prototype.getFragmentShaderSource = function (e) { var t = this._gl.getAttachedShaders(e); return t ? this._gl.getShaderSource(t[1]) : null }, t.prototype.setDepthStencilTexture = function (e, t, i, r) { void 0 !== e && (t && (this._boundUniforms[e] = t), i && i.depthStencilTexture ? this._setTexture(e, i, !1, !0, r) : this._setTexture(e, null, void 0, void 0, r)) }, t.prototype.setTextureFromPostProcess = function (e, t, i) { var r, n = null; t && (t._forcedOutputTexture ? n = t._forcedOutputTexture : t._textures.data[t._currentRenderTextureInd] && (n = t._textures.data[t._currentRenderTextureInd])), this._bindTexture(e, null !== (r = null == n ? void 0 : n.texture) && void 0 !== r ? r : null, i) }, t.prototype.setTextureFromPostProcessOutput = function (e, t, i) { var r, n; this._bindTexture(e, null !== (n = null === (r = null == t ? void 0 : t._outputTexture) || void 0 === r ? void 0 : r.texture) && void 0 !== n ? n : null, i) }, t.prototype._rebuildBuffers = function () { for (var t = 0, i = this.scenes; t < i.length; t++)(o = i[t]).resetCachedMaterial(), o._rebuildGeometries(), o._rebuildTextures(); for (var r = 0, n = this._virtualScenes; r < n.length; r++) { var o; (o = n[r]).resetCachedMaterial(), o._rebuildGeometries(), o._rebuildTextures() } e.prototype._rebuildBuffers.call(this) }, t.prototype._renderFrame = function () { for (var e = 0; e < this._activeRenderLoops.length; e++)(0, this._activeRenderLoops[e])() }, t.prototype._cancelFrame = function () { if (this._renderingQueueLaunched && this.customAnimationFrameRequester) { this._renderingQueueLaunched = !1; var t = this.customAnimationFrameRequester.cancelAnimationFrame; t && t(this.customAnimationFrameRequester.requestID) } else e.prototype._cancelFrame.call(this) }, t.prototype._renderLoop = function () { if (!this._contextWasLost) { var e = !0; (this.isDisposed || !this.renderEvenInBackground && this._windowIsBackground) && (e = !1), e && (this.beginFrame(), this._renderViews() || this._renderFrame(), this.endFrame()) } this._activeRenderLoops.length > 0 ? this.customAnimationFrameRequester ? (this.customAnimationFrameRequester.requestID = this._queueNewFrame(this.customAnimationFrameRequester.renderFunction || this._boundRenderFunction, this.customAnimationFrameRequester), this._frameHandler = this.customAnimationFrameRequester.requestID) : this.isVRPresenting() ? this._requestVRFrame() : 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._submitVRFrame(), this.onEndFrameObservable.notifyObservers(this) }, t.prototype.resize = function (t) { void 0 === t && (t = !1), this.isVRPresenting() || e.prototype.resize.call(this, t) }, 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; n < this.scenes.length; n++)for (var o = this.scenes[n], a = 0; a < o.cameras.length; a++)o.cameras[a]._currentRenderId = 0; this.onResizeObservable.hasObservers() && this.onResizeObservable.notifyObservers(this) } return !0 }, t.prototype._deletePipelineContext = function (t) { var i = t; i && i.program && i.transformFeedback && (this.deleteTransformFeedback(i.transformFeedback), i.transformFeedback = null), e.prototype._deletePipelineContext.call(this, t) }, t.prototype.createShaderProgram = function (t, i, r, n, o, a) { void 0 === a && (a = null), o = o || this._gl, this.onBeforeShaderCompilationObservable.notifyObservers(this); var s = e.prototype.createShaderProgram.call(this, t, i, r, n, o, a); return this.onAfterShaderCompilationObservable.notifyObservers(this), s }, t.prototype._createShaderProgram = function (e, t, i, r, n) { void 0 === n && (n = null); var o = r.createProgram(); if (e.program = o, !o) throw new Error("Unable to create program"); if (r.attachShader(o, t), r.attachShader(o, i), this.webGLVersion > 1 && n) { var a = this.createTransformFeedback(); this.bindTransformFeedback(a), this.setTranformFeedbackVaryings(o, n), e.transformFeedback = a } return r.linkProgram(o), this.webGLVersion > 1 && n && this.bindTransformFeedback(null), e.context = r, e.vertexShader = t, e.fragmentShader = i, e.isParallelCompiled || this._finalizePipelineContext(e), o }, t.prototype._releaseTexture = function (t) { e.prototype._releaseTexture.call(this, t) }, t.prototype._releaseRenderTargetWrapper = function (t) { e.prototype._releaseRenderTargetWrapper.call(this, t), this.scenes.forEach((function (e) { e.postProcesses.forEach((function (e) { e._outputTexture === t && (e._outputTexture = null) })), e.cameras.forEach((function (e) { e._postProcesses.forEach((function (e) { e && e._outputTexture === t && (e._outputTexture = null) })) })) })) }, t.prototype.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 < this.scenes.length; ++t)for (var i = this.scenes[t], r = 0; r < i.meshes.length; ++r) { var n = i.meshes[r]; if (n.subMeshes) for (var o = 0; o < n.subMeshes.length; ++o)n.subMeshes[o]._removeDrawWrapper(e) } }, t.prototype._rescaleTexture = function (e, i, r, n, o) { var s = this; this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, this._gl.LINEAR), this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, this._gl.LINEAR), this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._gl.CLAMP_TO_EDGE), this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._gl.CLAMP_TO_EDGE); var l = this.createRenderTargetTexture({ width: i.width, height: i.height }, { generateMipMaps: !1, type: a.TEXTURETYPE_UNSIGNED_INT, samplingMode: a.TEXTURE_BILINEAR_SAMPLINGMODE, generateDepthBuffer: !1, generateStencilBuffer: !1 }); !this._rescalePostProcess && t._RescalePostProcessFactory && (this._rescalePostProcess = t._RescalePostProcessFactory(this)), this._rescalePostProcess && (this._rescalePostProcess.externalTextureSamplerBinding = !0, this._rescalePostProcess.getEffect().executeWhenCompiled((function () { s._rescalePostProcess.onApply = function (t) { t._bindTexture("textureSampler", e) }; var t = r; t || (t = s.scenes[s.scenes.length - 1]), t.postProcessManager.directRender([s._rescalePostProcess], l, !0), s._bindTextureDirectly(s._gl.TEXTURE_2D, i, !0), s._gl.copyTexImage2D(s._gl.TEXTURE_2D, 0, n, 0, 0, i.width, i.height, 0), s.unBindFramebuffer(l), l.dispose(), o && o() }))) }, t.prototype.getFps = function () { return this._fps }, t.prototype.getDeltaTime = function () { return this._deltaTime }, t.prototype._measureFps = function () { this._performanceMonitor.sampleFrame(), this._fps = this._performanceMonitor.averageFPS, this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0 }, t.prototype.wrapWebGLTexture = function (e, t, i) { void 0 === t && (t = !1), void 0 === i && (i = a.TEXTURE_TRILINEAR_SAMPLINGMODE); var r = new Zt(e, this._gl), n = new Ht(this, It.Unknown, !0); return n._hardwareTexture = r, n.isReady = !0, n.useMipMaps = t, this.updateTextureSamplingMode(i, n), n }, t.prototype._uploadImageToTexture = function (e, t, i, r) { void 0 === i && (i = 0), void 0 === r && (r = 0); var n = this._gl, o = this._getWebGLTextureType(e.type), a = this._getInternalFormat(e.format), s = this._getRGBABufferInternalSizedFormat(e.type, a), l = e.isCube ? n.TEXTURE_CUBE_MAP : n.TEXTURE_2D; this._bindTextureDirectly(l, e, !0), this._unpackFlipY(e.invertY); var c = n.TEXTURE_2D; e.isCube && (c = n.TEXTURE_CUBE_MAP_POSITIVE_X + i), n.texImage2D(c, r, s, a, o, t), this._bindTextureDirectly(l, null, !0) }, t.prototype.updateTextureComparisonFunction = function (e, t) { if (1 !== this.webGLVersion) { var i = this._gl; e.isCube ? (this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, e, !0), 0 === t ? (i.texParameteri(i.TEXTURE_CUBE_MAP, i.TEXTURE_COMPARE_FUNC, a.LEQUAL), i.texParameteri(i.TEXTURE_CUBE_MAP, i.TEXTURE_COMPARE_MODE, i.NONE)) : (i.texParameteri(i.TEXTURE_CUBE_MAP, i.TEXTURE_COMPARE_FUNC, t), i.texParameteri(i.TEXTURE_CUBE_MAP, i.TEXTURE_COMPARE_MODE, i.COMPARE_REF_TO_TEXTURE)), this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null)) : (this._bindTextureDirectly(this._gl.TEXTURE_2D, e, !0), 0 === t ? (i.texParameteri(i.TEXTURE_2D, i.TEXTURE_COMPARE_FUNC, a.LEQUAL), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_COMPARE_MODE, i.NONE)) : (i.texParameteri(i.TEXTURE_2D, i.TEXTURE_COMPARE_FUNC, t), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_COMPARE_MODE, i.COMPARE_REF_TO_TEXTURE)), this._bindTextureDirectly(this._gl.TEXTURE_2D, null)), e._comparisonFunction = t } else $.Error("WebGL 1 does not support texture comparison.") }, t.prototype.createInstancesBuffer = function (e) { var t = this._gl.createBuffer(); if (!t) throw new Error("Unable to create instance buffer"); var i = new Qt(t); return i.capacity = e, this.bindArrayBuffer(i), this._gl.bufferData(this._gl.ARRAY_BUFFER, e, this._gl.DYNAMIC_DRAW), i.references = 1, i }, t.prototype.deleteInstancesBuffer = function (e) { this._gl.deleteBuffer(e) }, t.prototype._clientWaitAsync = function (e, t, i) { void 0 === t && (t = 0), void 0 === i && (i = 10); var r = this._gl; return new Promise((function (n, o) { var a = function () { var s = r.clientWaitSync(e, t, 0); s != r.WAIT_FAILED ? s != r.TIMEOUT_EXPIRED ? n() : setTimeout(a, i) : o() }; a() })) }, t.prototype._readPixelsAsync = function (e, t, i, r, n, o, a) { if (this._webGLVersion < 2) throw new Error("_readPixelsAsync only work on WebGL2+"); var s = this._gl, l = s.createBuffer(); s.bindBuffer(s.PIXEL_PACK_BUFFER, l), s.bufferData(s.PIXEL_PACK_BUFFER, a.byteLength, s.STREAM_READ), s.readPixels(e, t, i, r, n, o, 0), s.bindBuffer(s.PIXEL_PACK_BUFFER, null); var c = s.fenceSync(s.SYNC_GPU_COMMANDS_COMPLETE, 0); return c ? (s.flush(), this._clientWaitAsync(c, 0, 10).then((function () { return s.deleteSync(c), s.bindBuffer(s.PIXEL_PACK_BUFFER, l), s.getBufferSubData(s.PIXEL_PACK_BUFFER, 0, a), s.bindBuffer(s.PIXEL_PACK_BUFFER, null), s.deleteBuffer(l), a }))) : null }, t.prototype.dispose = function () { for (this.hideLoadingUI(), this.onNewSceneAddedObservable.clear(); this.postProcesses.length;)this.postProcesses[0].dispose(); for (this._rescalePostProcess && this._rescalePostProcess.dispose(); this.scenes.length;)this.scenes[0].dispose(); for (; this._virtualScenes.length;)this._virtualScenes[0].dispose(); 1 === S.Instances.length && t.audioEngine && (t.audioEngine.dispose(), t.audioEngine = null), this.disableVR(); var i = this.getHostWindow(); i && "function" == typeof i.removeEventListener && (i.removeEventListener("blur", this._onBlur), i.removeEventListener("focus", this._onFocus)), this._renderingCanvas && (this._renderingCanvas.removeEventListener("focus", this._onCanvasFocus), this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur), this._renderingCanvas.removeEventListener("pointerout", this._onCanvasPointerOut), this._renderingCanvas.removeEventListener("contextmenu", this._onCanvasContextMenu)), it() && (document.removeEventListener("fullscreenchange", this._onFullscreenChange), document.removeEventListener("mozfullscreenchange", this._onFullscreenChange), document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange), document.removeEventListener("msfullscreenchange", this._onFullscreenChange), document.removeEventListener("pointerlockchange", this._onPointerLockChange), document.removeEventListener("mspointerlockchange", this._onPointerLockChange), document.removeEventListener("mozpointerlockchange", this._onPointerLockChange), document.removeEventListener("webkitpointerlockchange", this._onPointerLockChange)), e.prototype.dispose.call(this); var r = S.Instances.indexOf(this); r >= 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 (et()) { var e = this.loadingScreen; e && e.displayLoadingUI() } }, t.prototype.hideLoadingUI = function () { if (et()) { 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 }(ti), Mn = I.Compose(R.One(), P.FromEulerAngles(0, Math.PI, 0), R.Zero()), On = 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 < o.length; n++)o[n].instantiateHierarchy(r, t, i); return r }, t.prototype.freezeWorldMatrix = function (e, t) { return void 0 === e && (e = null), void 0 === t && (t = !1), e ? t ? (this._rotation.setAll(0), this._rotationQuaternion = this._rotationQuaternion || P.Identity(), e.decompose(this._scaling, this._rotationQuaternion, this._position), this.computeWorldMatrix(!0)) : (this._worldMatrix = e, this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]), this._afterComputeWorldMatrix()) : (this._isWorldMatrixFrozen = !1, this.computeWorldMatrix(!0)), this._isDirty = !1, this._isWorldMatrixFrozen = !0, this }, t.prototype.unfreezeWorldMatrix = function () { return this._isWorldMatrixFrozen = !1, this.computeWorldMatrix(!0), this }, Object.defineProperty(t.prototype, "isWorldMatrixFrozen", { get: function () { return this._isWorldMatrixFrozen }, enumerable: !1, configurable: !0 }), t.prototype.getAbsolutePosition = function () { return this.computeWorldMatrix(), this._absolutePosition }, t.prototype.setAbsolutePosition = function (e) { if (!e) return this; var t, i, r; if (void 0 === e.x) { if (arguments.length < 3) return this; t = arguments[0], i = arguments[1], r = arguments[2] } else t = e.x, i = e.y, r = e.z; if (this.parent) { var n = O.Matrix[0]; this.parent.getWorldMatrix().invertToRef(n), R.TransformCoordinatesFromFloatsToRef(t, i, r, n, this.position) } else this.position.x = t, this.position.y = i, this.position.z = r; return this._absolutePosition.copyFrom(e), this }, t.prototype.setPositionWithLocalVector = function (e) { return this.computeWorldMatrix(), this.position = R.TransformNormal(e, this._localMatrix), this }, t.prototype.getPositionExpressedInLocalSpace = function () { this.computeWorldMatrix(); var e = O.Matrix[0]; return this._localMatrix.invertToRef(e), R.TransformNormal(this.position, e) }, t.prototype.locallyTranslate = function (e) { return this.computeWorldMatrix(!0), this.position = R.TransformCoordinates(e, this._localMatrix), this }, t.prototype.lookAt = function (e, i, r, n, o) { void 0 === i && (i = 0), void 0 === r && (r = 0), void 0 === n && (n = 0), void 0 === o && (o = Er.LOCAL); var a = t._LookAtVectorCache, s = o === Er.LOCAL ? this.position : this.getAbsolutePosition(); if (e.subtractToRef(s, a), this.setDirection(a, i, r, n), o === Er.WORLD && this.parent) if (this.rotationQuaternion) { var l = O.Matrix[0]; this.rotationQuaternion.toRotationMatrix(l); var c = O.Matrix[1]; this.parent.getWorldMatrix().getRotationMatrixToRef(c), c.invert(), l.multiplyToRef(c, l), this.rotationQuaternion.fromRotationMatrix(l) } else { var u = O.Quaternion[0]; P.FromEulerVectorToRef(this.rotation, u), l = O.Matrix[0], u.toRotationMatrix(l), c = O.Matrix[1], this.parent.getWorldMatrix().getRotationMatrixToRef(c), c.invert(), l.multiplyToRef(c, l), u.fromRotationMatrix(l), u.toEulerAnglesToRef(this.rotation) } return this }, t.prototype.getDirection = function (e) { var t = R.Zero(); return this.getDirectionToRef(e, t), t }, t.prototype.getDirectionToRef = function (e, t) { return R.TransformNormalToRef(e, this.getWorldMatrix(), t), this }, t.prototype.setDirection = function (e, t, i, r) { void 0 === t && (t = 0), void 0 === i && (i = 0), void 0 === r && (r = 0); var n = -Math.atan2(e.z, e.x) + Math.PI / 2, o = Math.sqrt(e.x * e.x + e.z * e.z), a = -Math.atan2(e.y, o); return this.rotationQuaternion ? P.RotationYawPitchRollToRef(n + t, a + i, r, this.rotationQuaternion) : (this.rotation.x = a + i, this.rotation.y = n + t, this.rotation.z = r), this }, t.prototype.setPivotPoint = function (e, t) { void 0 === t && (t = Er.LOCAL), 0 == this.getScene().getRenderId() && this.computeWorldMatrix(!0); var i = this.getWorldMatrix(); if (t == Er.WORLD) { var r = O.Matrix[0]; i.invertToRef(r), e = R.TransformCoordinates(e, r) } return this.setPivotMatrix(I.Translation(-e.x, -e.y, -e.z), !0) }, t.prototype.getPivotPoint = function () { var e = R.Zero(); return this.getPivotPointToRef(e), e }, t.prototype.getPivotPointToRef = function (e) { return e.x = -this._pivotMatrix.m[12], e.y = -this._pivotMatrix.m[13], e.z = -this._pivotMatrix.m[14], this }, t.prototype.getAbsolutePivotPoint = function () { var e = R.Zero(); return this.getAbsolutePivotPointToRef(e), e }, t.prototype.getAbsolutePivotPointToRef = function (e) { return this.getPivotPointToRef(e), R.TransformCoordinatesToRef(e, this.getWorldMatrix(), e), this }, t.prototype.markAsDirty = function (t) { if (this._isDirty) return this; if (this._children) for (var i = 0, r = this._children; i < r.length; i++)r[i].markAsDirty(t); return e.prototype.markAsDirty.call(this, t) }, t.prototype.setParent = function (e, i, r) { if (void 0 === i && (i = !1), void 0 === r && (r = !1), !e && !this.parent) return this; var n = O.Quaternion[0], o = O.Vector3[0], a = O.Vector3[1], s = O.Matrix[1]; I.IdentityToRef(s); var l = O.Matrix[0]; this.computeWorldMatrix(!0); var c = this.rotationQuaternion; return c || (c = t._TmpRotation, P.RotationYawPitchRollToRef(this._rotation.y, this._rotation.x, this._rotation.z, c)), I.ComposeToRef(this.scaling, c, this.position, l), this.parent && l.multiplyToRef(this.parent.computeWorldMatrix(!0), l), e && (e.computeWorldMatrix(!0).invertToRef(s), l.multiplyToRef(s, l)), l.decompose(a, n, o, i ? this : void 0), this.rotationQuaternion ? this.rotationQuaternion.copyFrom(n) : n.toEulerAnglesToRef(this.rotation), this.scaling.copyFrom(a), this.position.copyFrom(o), this.parent = e, r && this.setPivotMatrix(I.Identity()), this }, Object.defineProperty(t.prototype, "nonUniformScaling", { get: function () { return this._nonUniformScaling }, enumerable: !1, configurable: !0 }), t.prototype._updateNonUniformScalingState = function (e) { return this._nonUniformScaling !== e && (this._nonUniformScaling = e, !0) }, t.prototype.attachToBone = function (e, t) { return this._currentParentWhenAttachingToBone = this.parent, this._transformToBoneReferal = t, this.parent = e, e.getSkeleton().prepare(), e.getFinalMatrix().determinant() < 0 && (this.scalingDeterminant *= -1), this }, t.prototype.detachFromBone = function (e) { return void 0 === e && (e = !1), this.parent ? (this.parent.getWorldMatrix().determinant() < 0 && (this.scalingDeterminant *= -1), this._transformToBoneReferal = null, this.parent = e ? this._currentParentWhenAttachingToBone : null, this) : (e && (this.parent = this._currentParentWhenAttachingToBone), this) }, t.prototype.rotate = function (e, i, r) { var n; if (e.normalize(), this.rotationQuaternion || (this.rotationQuaternion = this.rotation.toQuaternion(), this.rotation.setAll(0)), r && r !== Er.LOCAL) { if (this.parent) { var o = O.Matrix[0]; this.parent.getWorldMatrix().invertToRef(o), e = R.TransformNormal(e, o) } (n = P.RotationAxisToRef(e, i, t._RotationAxisCache)).multiplyToRef(this.rotationQuaternion, this.rotationQuaternion) } else n = P.RotationAxisToRef(e, i, t._RotationAxisCache), this.rotationQuaternion.multiplyToRef(n, this.rotationQuaternion); return this }, t.prototype.rotateAround = function (e, t, i) { t.normalize(), this.rotationQuaternion || (this.rotationQuaternion = P.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z), this.rotation.setAll(0)); var r = O.Vector3[0], n = O.Vector3[1], o = O.Vector3[2], a = O.Quaternion[0], s = O.Matrix[0], l = O.Matrix[1], c = O.Matrix[2], u = O.Matrix[3]; return e.subtractToRef(this.position, r), I.TranslationToRef(r.x, r.y, r.z, s), I.TranslationToRef(-r.x, -r.y, -r.z, l), I.RotationAxisToRef(t, i, c), l.multiplyToRef(c, u), u.multiplyToRef(s, u), u.decompose(n, a, o), this.position.addInPlace(o), a.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion), this }, t.prototype.translate = function (e, t, i) { var r = e.scale(t); if (i && i !== Er.LOCAL) this.setAbsolutePosition(this.getAbsolutePosition().add(r)); else { var n = this.getPositionExpressedInLocalSpace().add(r); this.setPositionWithLocalVector(n) } return this }, t.prototype.addRotation = function (e, t, i) { var r; this.rotationQuaternion ? r = this.rotationQuaternion : (r = O.Quaternion[1], P.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, r)); var n = O.Quaternion[0]; return P.RotationYawPitchRollToRef(t, e, i, n), r.multiplyInPlace(n), this.rotationQuaternion || r.toEulerAnglesToRef(this.rotation), this }, t.prototype._getEffectiveParent = function () { return this.parent }, t.prototype.isWorldMatrixCameraDependent = function () { return this._infiniteDistance && !this.parent || this._billboardMode !== t.BILLBOARDMODE_NONE && !this.preserveParentRotationForBillboard }, t.prototype.computeWorldMatrix = function (e, i) { if (void 0 === e && (e = !1), void 0 === i && (i = null), this._isWorldMatrixFrozen && !this._isDirty) return this._worldMatrix; var r = this.getScene().getRenderId(); if (!this._isDirty && !e && (this._currentRenderId === r || this.isSynchronized())) return this._currentRenderId = r, this._worldMatrix; i = i || this.getScene().activeCamera, this._updateCache(); var n = this._cache; n.pivotMatrixUpdated = !1, n.billboardMode = this.billboardMode, n.infiniteDistance = this.infiniteDistance, n.parent = this._parentNode, this._currentRenderId = r, this._childUpdateId += 1, this._isDirty = !1, this._position._isDirty = !1, this._rotation._isDirty = !1, this._scaling._isDirty = !1; var o, a = this._getEffectiveParent(), s = t._TmpScaling, l = this._position; if (this._infiniteDistance && !this.parent && i) { var c = i.getWorldMatrix(), u = new R(c.m[12], c.m[13], c.m[14]); (l = t._TmpTranslation).copyFromFloats(this._position.x + u.x, this._position.y + u.y, this._position.z + u.z) } if (s.copyFromFloats(this._scaling.x * this.scalingDeterminant, this._scaling.y * this.scalingDeterminant, this._scaling.z * this.scalingDeterminant), this._rotationQuaternion ? (this._rotationQuaternion._isDirty = !1, o = this._rotationQuaternion, this.reIntegrateRotationIntoRotationQuaternion && (T = this.rotation.lengthSquared()) && (this._rotationQuaternion.multiplyInPlace(P.RotationYawPitchRoll(this._rotation.y, this._rotation.x, this._rotation.z)), this._rotation.copyFromFloats(0, 0, 0))) : (o = t._TmpRotation, P.RotationYawPitchRollToRef(this._rotation.y, this._rotation.x, this._rotation.z, o)), this._usePivotMatrix) { var h = O.Matrix[1]; I.ScalingToRef(s.x, s.y, s.z, h); var d = O.Matrix[0]; o.toRotationMatrix(d), this._pivotMatrix.multiplyToRef(h, O.Matrix[4]), O.Matrix[4].multiplyToRef(d, this._localMatrix), this._postMultiplyPivotMatrix && this._localMatrix.multiplyToRef(this._pivotMatrixInverse, this._localMatrix), this._localMatrix.addTranslationFromFloats(l.x, l.y, l.z) } else I.ComposeToRef(s, o, l, this._localMatrix); if (a && a.getWorldMatrix) { if (e && a.computeWorldMatrix(e), n.useBillboardPath) { this._transformToBoneReferal ? a.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), O.Matrix[7]) : O.Matrix[7].copyFrom(a.getWorldMatrix()); var p = O.Vector3[5], f = O.Vector3[6], _ = O.Quaternion[0]; O.Matrix[7].decompose(f, _, p), I.ScalingToRef(f.x, f.y, f.z, O.Matrix[7]), O.Matrix[7].setTranslation(p), t.BillboardUseParentOrientation && (this._position.applyRotationQuaternionToRef(_, p), this._localMatrix.setTranslation(p)), this._localMatrix.multiplyToRef(O.Matrix[7], this._worldMatrix) } else this._transformToBoneReferal ? (this._localMatrix.multiplyToRef(a.getWorldMatrix(), O.Matrix[6]), O.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix)) : this._localMatrix.multiplyToRef(a.getWorldMatrix(), this._worldMatrix); this._markSyncedWithParent() } else this._worldMatrix.copyFrom(this._localMatrix); if (n.useBillboardPath && i && this.billboardMode && !n.useBillboardPosition) { var m = O.Vector3[0]; if (this._worldMatrix.getTranslationToRef(m), O.Matrix[1].copyFrom(i.getViewMatrix()), this._scene.useRightHandedSystem && O.Matrix[1].multiplyToRef(Mn, O.Matrix[1]), O.Matrix[1].setTranslationFromFloats(0, 0, 0), O.Matrix[1].invertToRef(O.Matrix[0]), (this.billboardMode & t.BILLBOARDMODE_ALL) !== t.BILLBOARDMODE_ALL) { O.Matrix[0].decompose(void 0, O.Quaternion[0], void 0); var g = O.Vector3[1]; O.Quaternion[0].toEulerAnglesToRef(g), (this.billboardMode & t.BILLBOARDMODE_X) !== t.BILLBOARDMODE_X && (g.x = 0), (this.billboardMode & t.BILLBOARDMODE_Y) !== t.BILLBOARDMODE_Y && (g.y = 0), (this.billboardMode & t.BILLBOARDMODE_Z) !== t.BILLBOARDMODE_Z && (g.z = 0), I.RotationYawPitchRollToRef(g.y, g.x, g.z, O.Matrix[0]) } this._worldMatrix.setTranslationFromFloats(0, 0, 0), this._worldMatrix.multiplyToRef(O.Matrix[0], this._worldMatrix), this._worldMatrix.setTranslation(O.Vector3[0]) } else if (n.useBillboardPath && i && n.useBillboardPosition) { m = O.Vector3[0], this._worldMatrix.getTranslationToRef(m); var v = i.globalPosition; this._worldMatrix.invertToRef(O.Matrix[1]); var y = O.Vector3[1]; R.TransformCoordinatesToRef(v, O.Matrix[1], y), y.normalize(); var b = -Math.atan2(y.z, y.x) + Math.PI / 2, T = Math.sqrt(y.x * y.x + y.z * y.z), E = -Math.atan2(y.y, T); P.RotationYawPitchRollToRef(b, E, 0, O.Quaternion[0]), (this.billboardMode & t.BILLBOARDMODE_ALL) !== t.BILLBOARDMODE_ALL ? (g = O.Vector3[1], O.Quaternion[0].toEulerAnglesToRef(g), (this.billboardMode & t.BILLBOARDMODE_X) !== t.BILLBOARDMODE_X && (g.x = 0), (this.billboardMode & t.BILLBOARDMODE_Y) !== t.BILLBOARDMODE_Y && (g.y = 0), (this.billboardMode & t.BILLBOARDMODE_Z) !== t.BILLBOARDMODE_Z && (g.z = 0), I.RotationYawPitchRollToRef(g.y, g.x, g.z, O.Matrix[0])) : I.FromQuaternionToRef(O.Quaternion[0], O.Matrix[0]), this._worldMatrix.setTranslationFromFloats(0, 0, 0), this._worldMatrix.multiplyToRef(O.Matrix[0], this._worldMatrix), this._worldMatrix.setTranslation(O.Vector3[0]) } return this.ignoreNonUniformScaling ? this._updateNonUniformScalingState(!1) : this._scaling.isNonUniformWithinEpsilon(1e-6) ? this._updateNonUniformScalingState(!0) : a && a._nonUniformScaling ? this._updateNonUniformScalingState(a._nonUniformScaling) : this._updateNonUniformScalingState(!1), this._afterComputeWorldMatrix(), this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]), this._isAbsoluteSynced = !1, this.onAfterWorldMatrixUpdateObservable.notifyObservers(this), this._poseMatrix || (this._poseMatrix = I.Invert(this._worldMatrix)), this._worldMatrixDeterminantIsDirty = !0, this._worldMatrix }, t.prototype.resetLocalMatrix = function (e) { if (void 0 === e && (e = !0), this.computeWorldMatrix(), e) for (var t = this.getChildren(), i = 0; i < t.length; ++i) { var r = t[i]; if (r) { r.computeWorldMatrix(); var n = O.Matrix[0]; r._localMatrix.multiplyToRef(this._localMatrix, n); var o = O.Quaternion[0]; n.decompose(r.scaling, o, r.position), r.rotationQuaternion ? r.rotationQuaternion.copyFrom(o) : o.toEulerAnglesToRef(r.rotation) } } this.scaling.copyFromFloats(1, 1, 1), this.position.copyFromFloats(0, 0, 0), this.rotation.copyFromFloats(0, 0, 0), this.rotationQuaternion && (this.rotationQuaternion = P.Identity()), this._worldMatrix = I.Identity() }, t.prototype._afterComputeWorldMatrix = function () { }, t.prototype.registerAfterWorldMatrixUpdate = function (e) { return this.onAfterWorldMatrixUpdateObservable.add(e), this }, t.prototype.unregisterAfterWorldMatrixUpdate = function (e) { return this.onAfterWorldMatrixUpdateObservable.removeCallback(e), this }, t.prototype.getPositionInCameraSpace = function (e) { return void 0 === e && (e = null), e || (e = this.getScene().activeCamera), R.TransformCoordinates(this.getAbsolutePosition(), e.getViewMatrix()) }, t.prototype.getDistanceToCamera = function (e) { return void 0 === e && (e = null), e || (e = this.getScene().activeCamera), this.getAbsolutePosition().subtract(e.globalPosition).length() }, t.prototype.clone = function (e, i, r) { var n = this, o = Ue.Clone((function () { return new t(e, n.getScene()) }), this); if (o.name = e, o.id = e, i && (o.parent = i), !r) for (var a = this.getDescendants(!0), s = 0; s < a.length; s++) { var l = a[s]; l.clone && l.clone(e + "." + l.name, o) } return o }, t.prototype.serialize = function (e) { var t = Ue.Serialize(this, e); return t.type = this.getClassName(), t.uniqueId = this.uniqueId, this.parent && this.parent._serializeAsParent(t), t.localMatrix = this.getPivotMatrix().asArray(), t.isEnabled = this.isEnabled(), t }, t.Parse = function (e, i, r) { var n = Ue.Parse((function () { return new t(e.name, i) }), e, i, r); return e.localMatrix ? n.setPreTransformMatrix(I.FromArray(e.localMatrix)) : e.pivotMatrix && n.setPivotMatrix(I.FromArray(e.pivotMatrix)), n.setEnabled(e.isEnabled), n._waitingParsedUniqueId = e.uniqueId, void 0 !== e.parentId && (n._waitingParentId = e.parentId), void 0 !== e.parentInstanceIndex && (n._waitingParentInstanceIndex = e.parentInstanceIndex), n }, t.prototype.getChildTransformNodes = function (e, i) { var r = []; return this._getDescendants(r, e, (function (e) { return (!i || i(e)) && e instanceof t })), r }, t.prototype.dispose = function (t, i) { if (void 0 === i && (i = !1), this.getScene().stopAnimation(this), this.getScene().removeTransformNode(this), this._parentContainer) { var r = this._parentContainer.transformNodes.indexOf(this); r > -1 && this._parentContainer.transformNodes.splice(r, 1), this._parentContainer = null } if (this.onAfterWorldMatrixUpdateObservable.clear(), t) for (var n = 0, o = this.getChildTransformNodes(!0); n < o.length; n++) { var a = o[n]; a.parent = null, a.computeWorldMatrix(!0) } e.prototype.dispose.call(this, t, i) }, t.prototype.normalizeToUnitCube = function (e, t, i) { void 0 === e && (e = !0), void 0 === t && (t = !1); var r = null, n = null; t && (this.rotationQuaternion ? (n = this.rotationQuaternion.clone(), this.rotationQuaternion.copyFromFloats(0, 0, 0, 1)) : this.rotation && (r = this.rotation.clone(), this.rotation.copyFromFloats(0, 0, 0))); var o = this.getHierarchyBoundingVectors(e, i), a = o.max.subtract(o.min), s = Math.max(a.x, a.y, a.z); if (0 === s) return this; var l = 1 / s; return this.scaling.scaleInPlace(l), t && (this.rotationQuaternion && n ? this.rotationQuaternion.copyFrom(n) : this.rotation && r && this.rotation.copyFrom(r)), this }, t.prototype._syncAbsoluteScalingAndRotation = function () { this._isAbsoluteSynced || (this._worldMatrix.decompose(this._absoluteScaling, this._absoluteRotationQuaternion), this._isAbsoluteSynced = !0) }, t.BILLBOARDMODE_NONE = 0, t.BILLBOARDMODE_X = 1, t.BILLBOARDMODE_Y = 2, t.BILLBOARDMODE_Z = 4, t.BILLBOARDMODE_ALL = 7, t.BILLBOARDMODE_USE_POSITION = 128, t.BillboardUseParentOrientation = !1, t._TmpRotation = P.Zero(), t._TmpScaling = R.Zero(), t._TmpTranslation = R.Zero(), t._LookAtVectorCache = new R(0, 0, 0), t._RotationAxisCache = new P, X([Ie("position")], t.prototype, "_position", void 0), X([Ie("rotation")], t.prototype, "_rotation", void 0), X([Fe("rotationQuaternion")], t.prototype, "_rotationQuaternion", void 0), X([Ie("scaling")], t.prototype, "_scaling", void 0), X([xe("billboardMode")], t.prototype, "_billboardMode", void 0), X([xe()], t.prototype, "scalingDeterminant", void 0), X([xe("infiniteDistance")], t.prototype, "_infiniteDistance", void 0), X([xe()], t.prototype, "ignoreNonUniformScaling", void 0), X([xe()], t.prototype, "reIntegrateRotationIntoRotationQuaternion", void 0), t }(ze), Dn = function () { this._checkCollisions = !1, this._collisionMask = -1, this._collisionGroup = -1, this._surroundingMeshes = null, this._collider = null, this._oldPositionForCollisions = new R(0, 0, 0), this._diffPositionForCollisions = new R(0, 0, 0), this._collisionResponse = !0 }, Nn = function () { this.facetNb = 0, this.partitioningSubdivisions = 10, this.partitioningBBoxRatio = 1.01, this.facetDataEnabled = !1, this.facetParameters = {}, this.bbSize = R.Zero(), this.subDiv = { max: 1, X: 1, Y: 1, Z: 1 }, this.facetDepthSort = !1, this.facetDepthSortEnabled = !1 }, Fn = function () { this._hasVertexAlpha = !1, this._useVertexColors = !0, this._numBoneInfluencers = 4, this._applyFog = !0, this._receiveShadows = !1, this._facetData = new Nn, this._visibility = 1, this._skeleton = null, this._layerMask = 268435455, this._computeBonesUsingShaders = !0, this._isActive = !1, this._onlyForInstances = !1, this._isActiveIntermediate = !1, this._onlyForInstancesIntermediate = !1, this._actAsRegularMesh = !1, this._currentLOD = null, this._currentLODIsUpToDate = !1, this._collisionRetryCount = 3, this._morphTargetManager = null, this._renderingGroupId = 0, this._bakedVertexAnimationManager = null, this._material = null, this._positions = null, this._pointerOverDisableMeshTesting = !1, this._meshCollisionData = new Dn, this._enableDistantPicking = !1, this._rawBoundingInfo = null }, Ln = function (e) { function t(i, r) { void 0 === r && (r = null); var n = e.call(this, i, r, !1) || this; switch (n._internalAbstractMeshDataInfo = new Fn, n._waitingMaterialId = null, n.cullingStrategy = t.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY, n.onCollideObservable = new u, n.onCollisionPositionChangeObservable = new u, n.onMaterialChangedObservable = new u, n.definedFacingForward = !0, n._occlusionQuery = null, n._renderingGroup = null, n.alphaIndex = Number.MAX_VALUE, n.isVisible = !0, n.isPickable = !0, n.isNearPickable = !1, n.isNearGrabbable = !1, n.showSubMeshesBoundingBox = !1, n.isBlocker = !1, n.enablePointerMoveEvents = !1, n.outlineColor = B.Red(), n.outlineWidth = .02, n.overlayColor = B.Red(), n.overlayAlpha = .5, n.useOctreeForRenderingSelection = !0, n.useOctreeForPicking = !0, n.useOctreeForCollisions = !0, n.alwaysSelectAsActiveMesh = !1, n.doNotSyncBoundingInfo = !1, n.actionManager = null, n.ellipsoid = new R(.5, 1, .5), n.ellipsoidOffset = new R(0, 0, 0), n.edgesWidth = 1, n.edgesColor = new U(1, 0, 0, 1), n._edgesRenderer = null, n._masterMesh = null, n._boundingInfo = null, n._boundingInfoIsDirty = !0, n._renderId = 0, n._intersectionsInProgress = new Array, n._unIndexed = !1, n._lightSources = new Array, n._waitingData = { lods: null, actions: null, freezeWorldMatrix: null }, n._bonesTransformMatrices = null, n._transformMatrixTexture = null, n.onRebuildObservable = new u, n._onCollisionPositionChange = function (e, t, i) { void 0 === i && (i = null), t.subtractToRef(n._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions, n._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions), n._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions.length() > In.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 zi(n.getScene().getEngine(), void 0, void 0, i, !n.getScene().getEngine().isWebGPU), n._buildUniformLayout(), r.performancePriority) { case or.Aggressive: n.doNotSyncBoundingInfo = !0; case or.Intermediate: n.alwaysSelectAsActiveMesh = !0, n.isPickable = !1 }return n } return W(t, e), Object.defineProperty(t, "BILLBOARDMODE_NONE", { get: function () { return On.BILLBOARDMODE_NONE }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "BILLBOARDMODE_X", { get: function () { return On.BILLBOARDMODE_X }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "BILLBOARDMODE_Y", { get: function () { return On.BILLBOARDMODE_Y }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "BILLBOARDMODE_Z", { get: function () { return On.BILLBOARDMODE_Z }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "BILLBOARDMODE_ALL", { get: function () { return On.BILLBOARDMODE_ALL }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "BILLBOARDMODE_USE_POSITION", { get: function () { return On.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 !== On.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; t < i.length; t++)i[t]._rebuild() }, t.prototype._resyncLightSources = function () { this._lightSources.length = 0; for (var e = 0, t = this.getScene().lights; e < t.length; e++) { var i = t[e]; i.isEnabled() && i.canAffectMesh(this) && this._lightSources.push(i) } this._markSubMeshesAsLightDirty() }, t.prototype._resyncLightSource = function (e) { var t = e.isEnabled() && e.canAffectMesh(this), i = this._lightSources.indexOf(e), r = !1; if (-1 === i) { if (!t) return; this._lightSources.push(e) } else { if (t) return; r = !0, this._lightSources.splice(i, 1) } this._markSubMeshesAsLightDirty(r) }, t.prototype._unBindEffect = function () { for (var e = 0, t = this.subMeshes; e < t.length; e++)t[e].setEffect(null) }, t.prototype._removeLightSource = function (e, t) { var i = this._lightSources.indexOf(e); -1 !== i && (this._lightSources.splice(i, 1), this._markSubMeshesAsLightDirty(t)) }, t.prototype._markSubMeshesAsDirty = function (e) { if (this.subMeshes) for (var t = 0, i = this.subMeshes; t < i.length; t++)for (var r = i[t], n = 0; n < r._drawWrappers.length; ++n) { var o = r._drawWrappers[n]; o && o.defines && o.defines.markAllAsDirty && e(o.defines) } }, t.prototype._markSubMeshesAsLightDirty = function (e) { void 0 === e && (e = !1), this._markSubMeshesAsDirty((function (t) { return t.markAsLightDirty(e) })) }, t.prototype._markSubMeshesAsAttributesDirty = function () { this._markSubMeshesAsDirty((function (e) { return e.markAsAttributesDirty() })) }, t.prototype._markSubMeshesAsMiscDirty = function () { this._markSubMeshesAsDirty((function (e) { return e.markAsMiscDirty() })) }, t.prototype.markAsDirty = function (e) { return this._currentRenderId = Number.MAX_VALUE, this._isDirty = !0, this }, t.prototype.resetDrawCache = function (e) { if (this.subMeshes) for (var t = 0, i = this.subMeshes; t < i.length; t++)i[t].resetDrawCache(e) }, Object.defineProperty(t.prototype, "isBlocked", { get: function () { return !1 }, enumerable: !1, configurable: !0 }), t.prototype.getLOD = function (e) { return this }, t.prototype.getTotalVertices = function () { return 0 }, t.prototype.getTotalIndices = function () { return 0 }, t.prototype.getIndices = function () { return null }, t.prototype.getVerticesData = function (e) { return null }, t.prototype.setVerticesData = function (e, t, i, r) { return this }, t.prototype.updateVerticesData = function (e, t, i, r) { return this }, t.prototype.setIndices = function (e, t) { return this }, t.prototype.isVerticesDataPresent = function (e) { return !1 }, t.prototype.getBoundingInfo = function () { return this._masterMesh ? this._masterMesh.getBoundingInfo() : (this._boundingInfoIsDirty && (this._boundingInfoIsDirty = !1, this._updateBoundingInfo()), this._boundingInfo) }, t.prototype.getRawBoundingInfo = function () { var e; return null !== (e = this.rawBoundingInfo) && void 0 !== e ? e : this.getBoundingInfo() }, t.prototype.setBoundingInfo = function (e) { return this._boundingInfo = e, this }, Object.defineProperty(t.prototype, "hasBoundingInfo", { get: function () { return null !== this._boundingInfo }, enumerable: !1, configurable: !0 }), t.prototype.buildBoundingInfo = function (e, t, i) { return this._boundingInfo = new mn(e, t, i), this._boundingInfo }, t.prototype.normalizeToUnitCube = function (t, i, r) { return void 0 === t && (t = !0), void 0 === i && (i = !1), e.prototype.normalizeToUnitCube.call(this, t, i, r) }, Object.defineProperty(t.prototype, "useBones", { get: function () { return this.skeleton && this.getScene().skeletonsEnabled && this.isVerticesDataPresent(Hi.MatricesIndicesKind) && this.isVerticesDataPresent(Hi.MatricesWeightsKind) }, enumerable: !1, configurable: !0 }), t.prototype._preActivate = function () { }, t.prototype._preActivateForIntermediateRendering = function (e) { }, t.prototype._activate = function (e, t) { return this._renderId = e, !0 }, t.prototype._postActivate = function () { }, t.prototype._freeze = function () { }, t.prototype._unFreeze = function () { }, t.prototype.getWorldMatrix = function () { return this._masterMesh && this.billboardMode === On.BILLBOARDMODE_NONE ? this._masterMesh.getWorldMatrix() : e.prototype.getWorldMatrix.call(this) }, t.prototype._getWorldMatrixDeterminant = function () { return this._masterMesh ? this._masterMesh._getWorldMatrixDeterminant() : e.prototype._getWorldMatrixDeterminant.call(this) }, Object.defineProperty(t.prototype, "isAnInstance", { get: function () { return !1 }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasInstances", { get: function () { return !1 }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasThinInstances", { get: function () { return !1 }, enumerable: !1, configurable: !0 }), t.prototype.movePOV = function (e, t, i) { return this.position.addInPlace(this.calcMovePOV(e, t, i)), this }, t.prototype.calcMovePOV = function (e, t, i) { var r = new I; (this.rotationQuaternion ? this.rotationQuaternion : P.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z)).toRotationMatrix(r); var n = R.Zero(), o = this.definedFacingForward ? -1 : 1; return R.TransformCoordinatesFromFloatsToRef(e * o, t, i * o, r, n), n }, t.prototype.rotatePOV = function (e, t, i) { return this.rotation.addInPlace(this.calcRotatePOV(e, t, i)), this }, t.prototype.calcRotatePOV = function (e, t, i) { var r = this.definedFacingForward ? 1 : -1; return new R(e * r, t, i * r) }, t.prototype.refreshBoundingInfo = function (e, t) { return void 0 === e && (e = !1), void 0 === t && (t = !1), this._boundingInfo && this._boundingInfo.isLocked || this._refreshBoundingInfo(this._getPositionData(e, t), null), this }, t.prototype._refreshBoundingInfo = function (e, t) { if (e) { var i = yn(e, 0, this.getTotalVertices(), t); this._boundingInfo ? this._boundingInfo.reConstruct(i.minimum, i.maximum) : this._boundingInfo = new mn(i.minimum, i.maximum) } if (this.subMeshes) for (var r = 0; r < this.subMeshes.length; r++)this.subMeshes[r].refreshBoundingInfo(e); this._updateBoundingInfo() }, t.prototype._getData = function (e, t, i, r) { if (void 0 === e && (e = !1), void 0 === t && (t = !1), void 0 === r && (r = Hi.PositionKind), (i = null != i ? i : this.getVerticesData(r).slice()) && t && this.morphTargetManager) for (var n = 0, o = 0, a = 0; a < i.length; a++) { for (var s = 0; s < this.morphTargetManager.numTargets; s++) { var l = this.morphTargetManager.getTarget(s), c = l.influence; if (c > 0) { var u = l.getPositions(); u && (i[a] += (u[a] - i[a]) * c) } } if (n++, r === Hi.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(Hi.MatricesIndicesKind), p = this.getVerticesData(Hi.MatricesWeightsKind); if (p && d) { var f = this.numBoneInfluencers > 4, _ = f ? this.getVerticesData(Hi.MatricesIndicesExtraKind) : null, m = f ? this.getVerticesData(Hi.MatricesWeightsExtraKind) : null, g = this.skeleton.getTransformMatrices(this), v = O.Vector3[0], y = O.Matrix[0], b = O.Matrix[1], T = 0; for (h = 0; h < i.length; h += 3, T += 4) { y.reset(); var E = void 0, S = void 0; for (E = 0; E < 4; E++)(S = p[T + E]) > 0 && (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 === Hi.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 === Hi.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, Hi.NormalKind) }, t.prototype.getPositionData = function (e, t, i) { return void 0 === e && (e = !1), void 0 === t && (t = !1), this._getData(e, t, i, Hi.PositionKind) }, t.prototype._getPositionData = function (e, t) { var i, r = this.getVerticesData(Hi.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; o < n.length; o++)this._internalAbstractMeshDataInfo._positions[o] = (null === (i = n[o]) || void 0 === i ? void 0 : i.clone()) || new R } return this.getPositionData(e, t, r) } return r }, t.prototype._updateBoundingInfo = function () { return this._boundingInfo ? this._boundingInfo.update(this.worldMatrixFromCache) : this._boundingInfo = new mn(R.Zero(), R.Zero(), this.worldMatrixFromCache), this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache), this }, t.prototype._updateSubMeshesBoundingInfo = function (e) { if (!this.subMeshes) return this; for (var t = this.subMeshes.length, i = 0; i < t; i++) { var r = this.subMeshes[i]; (t > 1 || !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(); o < a.length; o++)if (a[o].intersectsMesh(e, t, !0)) return !0; return !1 }, t.prototype.intersectsPoint = function (e) { return this.getBoundingInfo().intersectsPoint(e) }, Object.defineProperty(t.prototype, "checkCollisions", { get: function () { return this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions }, set: function (e) { this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "collider", { get: function () { return this._internalAbstractMeshDataInfo._meshCollisionData._collider }, enumerable: !1, configurable: !0 }), t.prototype.moveWithCollisions = function (e) { this.getAbsolutePosition().addToRef(this.ellipsoidOffset, this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions); var t = this.getScene().collisionCoordinator; return this._internalAbstractMeshDataInfo._meshCollisionData._collider || (this._internalAbstractMeshDataInfo._meshCollisionData._collider = t.createCollider()), this._internalAbstractMeshDataInfo._meshCollisionData._collider._radius = this.ellipsoid, t.getNewPosition(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions, e, this._internalAbstractMeshDataInfo._meshCollisionData._collider, this.collisionRetryCount, this, this._onCollisionPositionChange, this.uniqueId), this }, t.prototype._collideForSubMesh = function (e, t, i) { var r; if (this._generatePointsArray(), !this._positions) return this; if (!e._lastColliderWorldVertices || !e._lastColliderTransformMatrix.equals(t)) { e._lastColliderTransformMatrix = t.clone(), e._lastColliderWorldVertices = [], e._trianglePlanes = []; for (var n = e.verticesStart, o = e.verticesStart + e.verticesCount, s = n; s < o; s++)e._lastColliderWorldVertices.push(R.TransformCoordinates(this._positions[s], t)) } return i._collide(e._trianglePlanes, e._lastColliderWorldVertices, this.getIndices(), e.indexStart, e.indexStart + e.indexCount, e.verticesStart, !!e.getMaterial(), this, this._shouldConvertRHS(), (null === (r = e.getMaterial()) || void 0 === r ? void 0 : r.fillMode) === a.MATERIAL_TriangleStripDrawMode), this }, t.prototype._processCollisionsForSubMeshes = function (e, t) { for (var i = this._scene.getCollidingSubMeshCandidates(this, e), r = i.length, n = 0; n < r; n++) { var o = i.data[n]; r > 1 && !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 Xi, 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; _ < p; _++) { var m = (g = d.data[_]).getMaterial(); if (m && (m.fillMode == a.MATERIAL_TriangleStripDrawMode || m.fillMode == a.MATERIAL_TriangleFillMode || m.fillMode == a.MATERIAL_WireFrameFillMode || m.fillMode == a.MATERIAL_PointFillMode || m.fillMode == a.MATERIAL_LineListDrawMode)) { f = !0; break } } if (!f) return s.hit = !0, s.pickedMesh = this, s.distance = R.Distance(e.origin, u.boundingSphere.center), s.subMeshId = -1, s; for (_ = 0; _ < p; _++) { var g = d.data[_]; if (!(p > 1) || g.canIntersects(e)) { var v = g.intersects(e, this._positions, this.getIndices(), t, i); if (v && (t || !h || v.distance < h.distance) && ((h = v).subMeshId = _, t)) break } } if (h) { var y = null != n ? n : this.getWorldMatrix(), b = O.Vector3[0], T = O.Vector3[1]; R.TransformCoordinatesToRef(e.origin, y, b), e.direction.scaleToRef(h.distance, T); var E = R.TransformNormal(T, y).addInPlace(b); return s.hit = !0, s.distance = R.Distance(b, E), s.pickedPoint = E, s.pickedMesh = this, s.bu = h.bu || 0, s.bv = h.bv || 0, s.subMeshFaceId = h.faceId, s.faceId = h.faceId + d.data[h.subMeshId].indexStart / (-1 !== this.getClassName().indexOf("LinesMesh") ? 2 : 3), s.subMeshId = h.subMeshId, s } return s }, t.prototype.clone = function (e, t, i) { return null }, t.prototype.releaseSubMeshes = function () { if (this.subMeshes) for (; this.subMeshes.length;)this.subMeshes[0].dispose(); else this.subMeshes = new Array; return this }, t.prototype.dispose = function (t, i) { var r, n = this; for (void 0 === i && (i = !1), this._scene.useMaterialMeshMap && this._internalAbstractMeshDataInfo._material && this._internalAbstractMeshDataInfo._material.meshMap && (this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId] = void 0), this.getScene().freeActiveMeshes(), this.getScene().freeRenderingGroups(), void 0 !== this.actionManager && null !== this.actionManager && (this.actionManager.dispose(), this.actionManager = null), this._internalAbstractMeshDataInfo._skeleton = null, this._transformMatrixTexture && (this._transformMatrixTexture.dispose(), this._transformMatrixTexture = null), r = 0; r < this._intersectionsInProgress.length; r++) { var o = this._intersectionsInProgress[r], a = o._intersectionsInProgress.indexOf(this); o._intersectionsInProgress.splice(a, 1) } this._intersectionsInProgress.length = 0, this.getScene().lights.forEach((function (e) { var t = e.includedOnlyMeshes.indexOf(n); -1 !== t && e.includedOnlyMeshes.splice(t, 1), -1 !== (t = e.excludedMeshes.indexOf(n)) && e.excludedMeshes.splice(t, 1); var i = e.getShadowGenerators(); if (i) for (var r = i.values(), o = r.next(); !0 !== o.done; o = r.next()) { var a = o.value.getShadowMap(); a && a.renderList && -1 !== (t = a.renderList.indexOf(n)) && a.renderList.splice(t, 1) } })), "InstancedMesh" === this.getClassName() && "InstancedLinesMesh" === this.getClassName() || this.releaseSubMeshes(); var s = this.getScene().getEngine(); if (null !== this._occlusionQuery && (this.isOcclusionQueryInProgress = !1, s.deleteQuery(this._occlusionQuery), this._occlusionQuery = null), s.wipeCaches(), this.getScene().removeMesh(this), this._parentContainer) { var l = this._parentContainer.meshes.indexOf(this); l > -1 && this._parentContainer.meshes.splice(l, 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; r < this.getScene().particleSystems.length; r++)this.getScene().particleSystems[r].emitter === this && (this.getScene().particleSystems[r].dispose(), r--); this._internalAbstractMeshDataInfo._facetData.facetDataEnabled && this.disableFacetData(), this._uniformBuffer.dispose(), this.onAfterWorldMatrixUpdateObservable.clear(), this.onCollideObservable.clear(), this.onCollisionPositionChangeObservable.clear(), this.onRebuildObservable.clear(), e.prototype.dispose.call(this, t, i) }, t.prototype.addChild = function (e, t) { return void 0 === t && (t = !1), e.setParent(this, t), this }, t.prototype.removeChild = function (e, t) { return void 0 === t && (t = !1), e.setParent(null, t), this }, t.prototype._initFacetData = function () { var e = this._internalAbstractMeshDataInfo._facetData; e.facetNormals || (e.facetNormals = new Array), e.facetPositions || (e.facetPositions = new Array), e.facetPartitioning || (e.facetPartitioning = new Array), e.facetNb = this.getIndices().length / 3 | 0, e.partitioningSubdivisions = e.partitioningSubdivisions ? e.partitioningSubdivisions : 10, e.partitioningBBoxRatio = e.partitioningBBoxRatio ? e.partitioningBBoxRatio : 1.01; for (var t = 0; t < e.facetNb; t++)e.facetNormals[t] = R.Zero(), e.facetPositions[t] = R.Zero(); return e.facetDataEnabled = !0, this }, t.prototype.updateFacetData = function () { var e = this._internalAbstractMeshDataInfo._facetData; e.facetDataEnabled || this._initFacetData(); var t = this.getVerticesData(Hi.PositionKind), i = this.getIndices(), r = this.getVerticesData(Hi.NormalKind), n = this.getBoundingInfo(); if (e.facetDepthSort && !e.facetDepthSortEnabled) { if (e.facetDepthSortEnabled = !0, i instanceof Uint16Array) e.depthSortedIndices = new Uint16Array(i); else if (i instanceof Uint32Array) e.depthSortedIndices = new Uint32Array(i); else { for (var o = !1, a = 0; a < i.length; a++)if (i[a] > 65535) { 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 < e.facetNb; l++) { var c = { ind: 3 * l, sqDistance: 0 }; e.depthSortedFacets.push(c) } e.invertedMatrix = I.Identity(), e.facetDepthSortOrigin = R.Zero() } e.bbSize.x = n.maximum.x - n.minimum.x > _ ? 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 && En.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; l < h; l++) { var d = e.depthSortedFacets[l].ind; e.depthSortedIndices[3 * l] = i[d], e.depthSortedIndices[3 * l + 1] = i[d + 1], e.depthSortedIndices[3 * l + 2] = i[d + 2] } this.updateIndices(e.depthSortedIndices, void 0, !0) } return this }, t.prototype.getFacetLocalNormals = function () { var e = this._internalAbstractMeshDataInfo._facetData; return e.facetNormals || this.updateFacetData(), e.facetNormals }, t.prototype.getFacetLocalPositions = function () { var e = this._internalAbstractMeshDataInfo._facetData; return e.facetPositions || this.updateFacetData(), e.facetPositions }, t.prototype.getFacetLocalPartitioning = function () { var e = this._internalAbstractMeshDataInfo._facetData; return e.facetPartitioning || this.updateFacetData(), e.facetPartitioning }, t.prototype.getFacetPosition = function (e) { var t = R.Zero(); return this.getFacetPositionToRef(e, t), t }, t.prototype.getFacetPositionToRef = function (e, t) { var i = this.getFacetLocalPositions()[e], r = this.getWorldMatrix(); return R.TransformCoordinatesToRef(i, r, t), this }, t.prototype.getFacetNormal = function (e) { var t = R.Zero(); return this.getFacetNormalToRef(e, t), t }, t.prototype.getFacetNormalToRef = function (e, t) { var i = this.getFacetLocalNormals()[e]; return R.TransformNormalToRef(i, this.getWorldMatrix(), t), this }, t.prototype.getFacetsAtLocalCoordinates = function (e, t, i) { var r = this.getBoundingInfo(), n = this._internalAbstractMeshDataInfo._facetData, o = Math.floor((e - r.minimum.x * n.partitioningBBoxRatio) * n.subDiv.X * n.partitioningBBoxRatio / n.bbSize.x), a = Math.floor((t - r.minimum.y * n.partitioningBBoxRatio) * n.subDiv.Y * n.partitioningBBoxRatio / n.bbSize.y), s = Math.floor((i - r.minimum.z * n.partitioningBBoxRatio) * n.subDiv.Z * n.partitioningBBoxRatio / n.bbSize.z); return o < 0 || o > n.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 < g.length; S++)y = m[v = g[S]], u = (e - (b = _[v]).x) * y.x + (t - b.y) * y.y + (i - b.z) * y.z, (!n || n && o && u >= 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) < T && (T = E, a = v, r && (r.x = d, r.y = p, r.z = f))); return a }, t.prototype.getFacetDataParameters = function () { return this._internalAbstractMeshDataInfo._facetData.facetParameters }, t.prototype.disableFacetData = function () { var e = this._internalAbstractMeshDataInfo._facetData; return e.facetDataEnabled && (e.facetDataEnabled = !1, e.facetPositions = new Array, e.facetNormals = new Array, e.facetPartitioning = new Array, e.facetParameters = null, e.depthSortedIndices = new Uint32Array(0)), this }, t.prototype.updateIndices = function (e, t, i) { return void 0 === i && (i = !1), this }, t.prototype.createNormals = function (e) { var t, i = this.getVerticesData(Hi.PositionKind), r = this.getIndices(); return t = this.isVerticesDataPresent(Hi.NormalKind) ? this.getVerticesData(Hi.NormalKind) : [], En.ComputeNormals(i, r, t, { useRightHandedSystem: this.getScene().useRightHandedSystem }), this.setVerticesData(Hi.NormalKind, t, e), this }, t.prototype.alignWithNormal = function (e, t) { t || (t = Ar.Y); var i = O.Vector3[0], r = O.Vector3[1]; return R.CrossToRef(t, e, r), R.CrossToRef(e, r, i), this.rotationQuaternion ? P.RotationQuaternionFromAxisToRef(i, e, r, this.rotationQuaternion) : R.RotationFromAxisToRef(i, e, r, this.rotation), this }, t.prototype._checkOcclusionQuery = function () { return !1 }, t.prototype.disableEdgesRendering = function () { throw ge("EdgesRenderer") }, t.prototype.enableEdgesRendering = function (e, t, i) { throw ge("EdgesRenderer") }, t.prototype.getConnectedParticleSystems = function () { var e = this; return this._scene.particleSystems.filter((function (t) { return t.emitter === e })) }, t.OCCLUSION_TYPE_NONE = 0, t.OCCLUSION_TYPE_OPTIMISTIC = 1, t.OCCLUSION_TYPE_STRICT = 2, t.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0, t.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1, t.CULLINGSTRATEGY_STANDARD = a.MESHES_CULLINGSTRATEGY_STANDARD, t.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = a.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY, t.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION, t.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY, t }(On); function wn(e) { -1 === e.indexOf("vClipPlane") && e.push("vClipPlane"), -1 === e.indexOf("vClipPlane2") && e.push("vClipPlane2"), -1 === e.indexOf("vClipPlane3") && e.push("vClipPlane3"), -1 === e.indexOf("vClipPlane4") && e.push("vClipPlane4"), -1 === e.indexOf("vClipPlane5") && e.push("vClipPlane5"), -1 === e.indexOf("vClipPlane6") && e.push("vClipPlane6") } function Bn(e, t, i) { var r, n, o, a, s, l, c = !!(null !== (r = e.clipPlane) && void 0 !== r ? r : t.clipPlane), u = !!(null !== (n = e.clipPlane2) && void 0 !== n ? n : t.clipPlane2), h = !!(null !== (o = e.clipPlane3) && void 0 !== o ? o : t.clipPlane3), d = !!(null !== (a = e.clipPlane4) && void 0 !== a ? a : t.clipPlane4), p = !!(null !== (s = e.clipPlane5) && void 0 !== s ? s : t.clipPlane5), f = !!(null !== (l = e.clipPlane6) && void 0 !== l ? l : t.clipPlane6); c && i.push("#define CLIPPLANE"), u && i.push("#define CLIPPLANE2"), h && i.push("#define CLIPPLANE3"), d && i.push("#define CLIPPLANE4"), p && i.push("#define CLIPPLANE5"), f && i.push("#define CLIPPLANE6") } function Un(e, t, i) { var r, n, o, a, s, l, c = !1, u = !!(null !== (r = e.clipPlane) && void 0 !== r ? r : t.clipPlane), h = !!(null !== (n = e.clipPlane2) && void 0 !== n ? n : t.clipPlane2), d = !!(null !== (o = e.clipPlane3) && void 0 !== o ? o : t.clipPlane3), p = !!(null !== (a = e.clipPlane4) && void 0 !== a ? a : t.clipPlane4), f = !!(null !== (s = e.clipPlane5) && void 0 !== s ? s : t.clipPlane5), _ = !!(null !== (l = e.clipPlane6) && void 0 !== l ? l : t.clipPlane6); return i.CLIPPLANE !== u && (i.CLIPPLANE = u, c = !0), i.CLIPPLANE2 !== h && (i.CLIPPLANE2 = h, c = !0), i.CLIPPLANE3 !== d && (i.CLIPPLANE3 = d, c = !0), i.CLIPPLANE4 !== p && (i.CLIPPLANE4 = p, c = !0), i.CLIPPLANE5 !== f && (i.CLIPPLANE5 = f, c = !0), i.CLIPPLANE6 !== _ && (i.CLIPPLANE6 = _, c = !0), c } function Vn(e, t, i) { var r, n, o, a, s, l, c = null !== (r = t.clipPlane) && void 0 !== r ? r : i.clipPlane; kn(e, "vClipPlane", c), kn(e, "vClipPlane2", c = null !== (n = t.clipPlane2) && void 0 !== n ? n : i.clipPlane2), kn(e, "vClipPlane3", c = null !== (o = t.clipPlane3) && void 0 !== o ? o : i.clipPlane3), kn(e, "vClipPlane4", c = null !== (a = t.clipPlane4) && void 0 !== a ? a : i.clipPlane4), kn(e, "vClipPlane5", c = null !== (s = t.clipPlane5) && void 0 !== s ? s : i.clipPlane5), kn(e, "vClipPlane6", c = null !== (l = t.clipPlane6) && void 0 !== l ? l : i.clipPlane6) } function kn(e, t, i) { i && e.setFloat4(t, i.normal.x, i.normal.y, i.normal.z, i.d) } b("BABYLON.AbstractMesh", Ln); var Gn, zn = function () { function e() { } return e.BindSceneUniformBuffer = function (e, t) { t.bindToEffect(e, "Scene") }, e.PrepareDefinesForMergedUV = function (e, t, i) { t._needUVs = !0, t[i] = !0, e.optimizeUVAllocation && e.getTextureMatrix().isIdentityAs3x2() ? (t[i + "DIRECTUV"] = e.coordinatesIndex + 1, t["MAINUV" + (e.coordinatesIndex + 1)] = !0) : t[i + "DIRECTUV"] = 0 }, e.BindTextureMatrix = function (e, t, i) { var r = e.getTextureMatrix(); t.updateMatrix(i + "Matrix", r) }, e.GetFogState = function (e, t) { return t.fogEnabled && e.applyFog && t.fogMode !== Sr.FOGMODE_NONE }, e.PrepareDefinesForMisc = function (e, t, i, r, n, o, a, s) { void 0 === s && (s = !1), a._areMiscDirty && (a.LOGARITHMICDEPTH = i, a.POINTSIZE = r, a.FOG = n && this.GetFogState(e, t), a.NONUNIFORMSCALING = e.nonUniformScaling, a.ALPHATEST = o, a.DECAL_AFTER_DETAIL = s) }, e.PrepareDefinesForCamera = function (e, t) { var i = !1; if (e.activeCamera) { var r = t.CAMERA_ORTHOGRAPHIC ? 1 : 0, n = t.CAMERA_PERSPECTIVE ? 1 : 0, o = e.activeCamera.mode === ln.ORTHOGRAPHIC_CAMERA ? 1 : 0, a = e.activeCamera.mode === ln.PERSPECTIVE_CAMERA ? 1 : 0; (r ^ o || n ^ a) && (t.CAMERA_ORTHOGRAPHIC = 1 === o, t.CAMERA_PERSPECTIVE = 1 === a, i = !0) } return i }, e.PrepareDefinesForFrameBoundValues = function (t, i, r, n, o, a, s) { void 0 === a && (a = null), void 0 === s && (s = !1); var l = e.PrepareDefinesForCamera(t, n); !1 !== a && (l = Un(r, t, n)), n.DEPTHPREPASS !== !i.getColorWrite() && (n.DEPTHPREPASS = !n.DEPTHPREPASS, l = !0), n.INSTANCES !== o && (n.INSTANCES = o, l = !0), n.THIN_INSTANCES !== s && (n.THIN_INSTANCES = s, l = !0), l && n.markAsUnprocessed() }, e.PrepareDefinesForBones = function (e, t) { if (e.useBones && e.computeBonesUsingShaders && e.skeleton) { t.NUM_BONE_INFLUENCERS = e.numBoneInfluencers; var i = void 0 !== t.BONETEXTURE; if (e.skeleton.isUsingTextureForMatrices && i) t.BONETEXTURE = !0; else { t.BonesPerMesh = e.skeleton.bones.length + 1, t.BONETEXTURE = !i && void 0; var r = e.getScene().prePassRenderer; if (r && r.enabled) { var n = -1 === r.excludedSkinnedMesh.indexOf(e); t.BONES_VELOCITY_ENABLED = n } } } else t.NUM_BONE_INFLUENCERS = 0, t.BonesPerMesh = 0, void 0 !== t.BONETEXTURE && (t.BONETEXTURE = !1) }, e.PrepareDefinesForMorphTargets = function (e, t) { var i = e.morphTargetManager; i ? (t.MORPHTARGETS_UV = i.supportsUVs && t.UV1, t.MORPHTARGETS_TANGENT = i.supportsTangents && t.TANGENT, t.MORPHTARGETS_NORMAL = i.supportsNormals && t.NORMAL, t.MORPHTARGETS = i.numInfluencers > 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(Hi.NormalKind), t._needNormals && e.isVerticesDataPresent(Hi.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(Hi.ColorKind); t.VERTEXCOLOR = c, t.VERTEXALPHA = e.hasVertexAlpha && c && o } return e.isVerticesDataPresent(Hi.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; for (var o = 0; o < n.length; o++) { var s = e.prePassRenderer.getIndex(n[o].type); -1 !== s ? (t[n[o].define] = !0, t[n[o].index] = s) : t[n[o].define] = !1 } } else for (t.PREPASS = !1, o = 0; o < n.length; o++)t[n[o].define] = !1; t.PREPASS != r && (t.markAsUnprocessed(), t.markAsImageProcessingDirty()) } }, e.PrepareDefinesForLight = function (e, t, i, r, n, o, a) { var s; switch (a.needNormals = !0, void 0 === n["LIGHT" + r] && (a.needRebuild = !0), n["LIGHT" + r] = !0, n["SPOTLIGHT" + r] = !1, n["HEMILIGHT" + r] = !1, n["POINTLIGHT" + r] = !1, n["DIRLIGHT" + r] = !1, i.prepareLightSpecificDefines(n, r), n["LIGHT_FALLOFF_PHYSICAL" + r] = !1, n["LIGHT_FALLOFF_GLTF" + r] = !1, n["LIGHT_FALLOFF_STANDARD" + r] = !1, i.falloffType) { case br.FALLOFF_GLTF: n["LIGHT_FALLOFF_GLTF" + r] = !0; break; case br.FALLOFF_PHYSICAL: n["LIGHT_FALLOFF_PHYSICAL" + r] = !0; break; case br.FALLOFF_STANDARD: n["LIGHT_FALLOFF_STANDARD" + r] = !0 }if (o && !i.specular.equalsFloats(0, 0, 0) && (a.specularEnabled = !0), n["SHADOW" + r] = !1, n["SHADOWCSM" + r] = !1, n["SHADOWCSMDEBUG" + r] = !1, n["SHADOWCSMNUM_CASCADES" + r] = !1, n["SHADOWCSMUSESHADOWMAXZ" + r] = !1, n["SHADOWCSMNOBLEND" + r] = !1, n["SHADOWCSM_RIGHTHANDED" + r] = !1, n["SHADOWPCF" + r] = !1, n["SHADOWPCSS" + r] = !1, n["SHADOWPOISSON" + r] = !1, n["SHADOWESM" + r] = !1, n["SHADOWCLOSEESM" + r] = !1, n["SHADOWCUBE" + r] = !1, n["SHADOWLOWQUALITY" + r] = !1, n["SHADOWMEDIUMQUALITY" + r] = !1, t && t.receiveShadows && e.shadowsEnabled && i.shadowEnabled) { var l = null !== (s = i.getShadowGenerator(e.activeCamera)) && void 0 !== s ? s : i.getShadowGenerator(); if (l) { var c = l.getShadowMap(); c && c.renderList && c.renderList.length > 0 && (a.shadowEnabled = !0, l.prepareDefines(n, r)) } } i.lightmapMode != br.LIGHTMAP_DEFAULT ? (a.lightmapMode = !0, n["LIGHTMAPEXCLUDED" + r] = !0, n["LIGHTMAPNOSPECULAR" + r] = i.lightmapMode == br.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; l < c.length; l++) { var u = c[l]; if (this.PrepareDefinesForLight(e, t, u, a, i, r, s), ++a === n) break } i.SPECULARTERM = s.specularEnabled, i.SHADOWS = s.shadowEnabled; for (var h = a; h < n; h++)void 0 !== i["LIGHT" + h] && (i["LIGHT" + h] = !1, i["HEMILIGHT" + h] = !1, i["POINTLIGHT" + h] = !1, i["DIRLIGHT" + h] = !1, i["SPOTLIGHT" + h] = !1, i["SHADOW" + h] = !1, i["SHADOWCSM" + h] = !1, i["SHADOWCSMDEBUG" + h] = !1, i["SHADOWCSMNUM_CASCADES" + h] = !1, i["SHADOWCSMUSESHADOWMAXZ" + h] = !1, i["SHADOWCSMNOBLEND" + h] = !1, i["SHADOWCSM_RIGHTHANDED" + h] = !1, i["SHADOWPCF" + h] = !1, i["SHADOWPCSS" + h] = !1, i["SHADOWPOISSON" + h] = !1, i["SHADOWESM" + h] = !1, i["SHADOWCLOSEESM" + h] = !1, i["SHADOWCUBE" + h] = !1, i["SHADOWLOWQUALITY" + h] = !1, i["SHADOWMEDIUMQUALITY" + h] = !1); var d = e.getEngine().getCaps(); return void 0 === i.SHADOWFLOAT && (s.needRebuild = !0), i.SHADOWFLOAT = s.shadowEnabled && (d.textureFloatRender && d.textureFloatLinearFiltering || d.textureHalfFloatRender && d.textureHalfFloatLinearFiltering), i.LIGHTMAPEXCLUDED = s.lightmapMode, s.needRebuild && i.rebuild(), s.needNormals }, e.PrepareUniformsAndSamplersForLight = function (e, t, i, r, n, o) { void 0 === n && (n = null), void 0 === o && (o = !1), n && n.push("Light" + e), o || (t.push("vLightData" + e, "vLightDiffuse" + e, "vLightSpecular" + e, "vLightDirection" + e, "vLightFalloff" + e, "vLightGround" + e, "lightMatrix" + e, "shadowsInfo" + e, "depthValues" + e), i.push("shadowSampler" + e), i.push("depthSampler" + e), t.push("viewFrustumZ" + e, "cascadeBlendFactor" + e, "lightSizeUVCorrection" + e, "depthCorrection" + e, "penumbraDarkness" + e, "frustumLengths" + e), r && (i.push("projectionLightSampler" + e), t.push("textureProjectionMatrix" + e))) }, e.PrepareUniformsAndSamplersList = function (e, t, i, r) { var n; void 0 === r && (r = 4); var o = null; if (e.uniformsNames) { var a = e; n = a.uniformsNames, o = a.uniformBuffersNames, t = a.samplers, i = a.defines, r = a.maxSimultaneousLights || 0 } else n = e, t || (t = []); for (var s = 0; s < r && i["LIGHT" + s]; s++)this.PrepareUniformsAndSamplersForLight(s, n, t, i["PROJECTEDLIGHTTEXTURE" + s], o); i.NUM_MORPH_INFLUENCERS && n.push("morphTargetInfluences"), i.BAKED_VERTEX_ANIMATION_TEXTURE && (n.push("bakedVertexAnimationSettings"), n.push("bakedVertexAnimationTextureSizeInverted"), n.push("bakedVertexAnimationTime"), t.push("bakedVertexAnimationTexture")) }, e.HandleFallbacksForShadows = function (e, t, i, r) { void 0 === i && (i = 4), void 0 === r && (r = 0); for (var n = 0, o = 0; o < i && e["LIGHT" + o]; o++)o > 0 && (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; c < r; c++)e.push(Hi.PositionKind + c), a && e.push(Hi.NormalKind + c), s && e.push(Hi.TangentKind + c), l && e.push(Hi.UVKind + "_" + c), e.length > n && $.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(Hi.MatricesIndicesKind), e.push(Hi.MatricesWeightsKind), i.NUM_BONE_INFLUENCERS > 4 && (e.push(Hi.MatricesIndicesExtraKind), e.push(Hi.MatricesWeightsExtraKind))) }, e.PrepareAttributesForInstances = function (e, t) { (t.INSTANCES || t.THIN_INSTANCES) && this.PushAttributesForInstances(e, !!t.PREPASS_VELOCITY), t.INSTANCESCOLOR && e.push(Hi.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 < o; a++) { var s = t.lightSources[a]; this.BindLight(s, a, e, i, "boolean" == typeof r ? r : r.SPECULARTERM, t.receiveShadows) } }, e.BindFogParameters = function (e, t, i, r) { void 0 === r && (r = !1), e.fogEnabled && t.applyFog && e.fogMode !== Sr.FOGMODE_NONE && (i.setFloat4("vFogInfos", e.fogMode, e.fogStart, e.fogEnd, e.fogDensity), r ? (e.fogColor.toLinearSpaceToRef(this._TempFogColor, e.getEngine().useExactSrgbConversions), i.setColor3("vFogColor", this._TempFogColor)) : i.setColor3("vFogColor", e.fogColor)) }, e.BindBonesParameters = function (t, i, r) { if (i && t && (t.computeBonesUsingShaders && i._bonesComputationForcedToCPU && (t.computeBonesUsingShaders = !1), t.useBones && t.computeBonesUsingShaders && t.skeleton)) { var n = t.skeleton; if (n.isUsingTextureForMatrices && i.getUniformIndex("boneTextureWidth") > -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 === ln.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 }(), Wn = 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) { Ue.Clone((function () { return e }), this) }, e.prototype.serialize = function () { return Ue.Serialize(this) }, e.prototype.parse = function (e, t, i) { var r = this; Ue.Parse((function () { return r }), e, t, i) }, X([xe()], e.prototype, "func", null), X([xe()], e.prototype, "funcRef", null), X([xe()], e.prototype, "funcMask", null), X([xe()], e.prototype, "opStencilFail", null), X([xe()], e.prototype, "opDepthFail", null), X([xe()], e.prototype, "opStencilDepthPass", null), X([xe()], e.prototype, "mask", null), X([xe()], 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" }(Gn || (Gn = {})); var Hn = 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 Wn, 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 || xi.RandomId(), this.uniqueId = this._scene.getUniqueId(), this._materialContext = this._scene.getEngine().createMaterialContext(), this._drawWrapper = new Jt(this._scene.getEngine(), !1), this._drawWrapper.materialContext = this._materialContext, this._scene.useRightHandedSystem ? this.sideOrientation = e.ClockWiseSideOrientation : this.sideOrientation = e.CounterClockWiseSideOrientation, this._uniformBuffer = new zi(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, Gn.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 < r.length; i++) { var n = r[i]; if (n.subMeshes) for (var o = 0, a = n.subMeshes; o < a.length; o++) { var s = a[o]; s.getMaterial() === this && s.effect && (s.effect._wasPreviouslyReady = !1, s.effect._wasPreviouslyUsingInstances = null, s.effect._forceRebindOnNextCall = t) } } t && this.markAsDirty(e.AllDirtyFlag) }, e.prototype._preBind = function (t, i) { void 0 === i && (i = null); var r = this._scene.getEngine(), n = (null == i ? this.sideOrientation : i) === e.ClockWiseSideOrientation; return r.enableEffect(t || this._getDrawWrapper()), r.setState(this.backFaceCulling, this.zOffset, !1, n, this._scene._mirroredCameraPosition ? !this.cullBackFaces : this.cullBackFaces, this.stencil, this.zOffsetUnits), n }, e.prototype.bind = function (e, t) { }, e.prototype.buildUniformLayout = function () { var e = this._uniformBuffer; this._eventInfo.ubo = e, this._callbackPluginEventGeneric(Gn.PrepareUniformBuffer, this._eventInfo), e.create(), this._uniformBufferLayoutBuilt = !0 }, e.prototype.bindForSubMesh = function (e, t, i) { var r = i.effect; r && (this._eventInfo.subMesh = i, this._callbackPluginEventBindForSubMesh(this._eventInfo), r._forceRebindOnNextCall = !1) }, e.prototype.bindOnlyWorldMatrix = function (e) { }, e.prototype.bindView = function (e) { this._useUBO ? this._needToBindSceneUbo = !0 : e.setMatrix("view", this.getScene().getViewMatrix()) }, e.prototype.bindViewProjection = function (e) { this._useUBO ? this._needToBindSceneUbo = !0 : (e.setMatrix("viewProjection", this.getScene().getTransformMatrix()), e.setMatrix("projection", this.getScene().getProjectionMatrix())) }, e.prototype.bindEyePosition = function (e, t) { this._useUBO ? this._needToBindSceneUbo = !0 : this._scene.bindEyePosition(e, t) }, e.prototype._afterBind = function (e, t) { if (void 0 === t && (t = null), this._scene._cachedMaterial = this, this._needToBindSceneUbo && t && (this._needToBindSceneUbo = !1, zn.BindSceneUniformBuffer(t, this.getScene().getSceneUniformBuffer()), this._scene.finalizeSceneUbo()), this._scene._cachedVisibility = e ? e.visibility : 1, this._onBindObservable && e && this._onBindObservable.notifyObservers(e), this.disableDepthWrite) { var i = this._scene.getEngine(); this._cachedDepthWriteState = i.getDepthWrite(), i.setDepthWrite(!1) } this.disableColorWrite && (i = this._scene.getEngine(), this._cachedColorWriteState = i.getColorWrite(), i.setColorWrite(!1)), 0 !== this.depthFunction && (i = this._scene.getEngine(), this._cachedDepthFunctionState = i.getDepthFunction() || 0, i.setDepthFunction(this.depthFunction)) }, e.prototype.unbind = function () { this._onUnBindObservable && this._onUnBindObservable.notifyObservers(this), 0 !== this.depthFunction && this._scene.getEngine().setDepthFunction(this._cachedDepthFunctionState), this.disableDepthWrite && this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState), this.disableColorWrite && this._scene.getEngine().setColorWrite(this._cachedColorWriteState) }, e.prototype.getAnimatables = function () { return this._eventInfo.animatables = [], this._callbackPluginEventGeneric(Gn.GetAnimatables, this._eventInfo), this._eventInfo.animatables }, e.prototype.getActiveTextures = function () { return this._eventInfo.activeTextures = [], this._callbackPluginEventGeneric(Gn.GetActiveTextures, this._eventInfo), this._eventInfo.activeTextures }, e.prototype.hasTexture = function (e) { return this._eventInfo.hasTexture = !1, this._eventInfo.texture = e, this._callbackPluginEventGeneric(Gn.HasTexture, this._eventInfo), this._eventInfo.hasTexture }, e.prototype.clone = function (e) { return null }, e.prototype._clonePlugins = function (t, i) { var r = {}; if (this._serializePlugins(r), e._parsePlugins(r, t, this._scene, i), this.pluginManager) for (var n = 0, o = this.pluginManager._plugins; n < o.length; n++) { var a = o[n], s = t.pluginManager.getPlugin(a.name); a.copyTo(s) } }, e.prototype.getBindedMeshes = function () { var e = this; if (this.meshMap) { var t = new Array; for (var i in this.meshMap) { var r = this.meshMap[i]; r && t.push(r) } return t } return this._scene.meshes.filter((function (t) { return t.material === e })) }, e.prototype.forceCompilation = function (e, t, i, r) { var n = this, o = H({ clipPlane: !1, useInstances: !1 }, i), a = this.getScene(), s = this.allowShaderHotSwapping; this.allowShaderHotSwapping = !1; var l = function () { if (n._scene && n._scene.getEngine()) { var i = a.clipPlane; if (o.clipPlane && (a.clipPlane = new gr(0, 0, 0, 1)), n._storeEffectOnSubMeshes) { var c = !0, u = null; if (e.subMeshes) { var h = new bn(0, 0, 0, 0, 0, e, void 0, !1, !1); h.materialDefines && (h.materialDefines._renderId = -1), n.isReadyForSubMesh(e, h, o.useInstances) || (h.effect && h.effect.getCompilationError() && h.effect.allFallbacksProcessed() ? u = h.effect.getCompilationError() : (c = !1, setTimeout(l, 16))) } c && (n.allowShaderHotSwapping = s, u && r && r(u), t && t(n)) } else n.isReady() ? (n.allowShaderHotSwapping = s, t && t(n)) : setTimeout(l, 16); o.clipPlane && (a.clipPlane = i) } }; l() }, e.prototype.forceCompilationAsync = function (e, t) { var i = this; return new Promise((function (r, n) { i.forceCompilation(e, (function () { r() }), t, (function (e) { n(e) })) })) }, e.prototype.markAsDirty = function (t) { this.getScene().blockMaterialDirtyMechanism || this._blockDirtyMechanism || (e._DirtyCallbackArray.length = 0, t & e.TextureDirtyFlag && e._DirtyCallbackArray.push(e._TextureDirtyCallBack), t & e.LightDirtyFlag && e._DirtyCallbackArray.push(e._LightsDirtyCallBack), t & e.FresnelDirtyFlag && e._DirtyCallbackArray.push(e._FresnelDirtyCallBack), t & e.AttributesDirtyFlag && e._DirtyCallbackArray.push(e._AttributeDirtyCallBack), t & e.MiscDirtyFlag && e._DirtyCallbackArray.push(e._MiscDirtyCallBack), t & e.PrePassDirtyFlag && e._DirtyCallbackArray.push(e._PrePassDirtyCallBack), e._DirtyCallbackArray.length && this._markAllSubMeshesAsDirty(e._RunDirtyCallBacks), this.getScene().resetCachedMaterial()) }, e.prototype.resetDrawCache = function () { for (var e = 0, t = this.getScene().meshes; e < t.length; e++) { var i = t[e]; if (i.subMeshes) for (var r = 0, n = i.subMeshes; r < n.length; r++) { var o = n[r]; o.getMaterial() === this && o.resetDrawCache() } } }, e.prototype._markAllSubMeshesAsDirty = function (e) { if (!this.getScene().blockMaterialDirtyMechanism && !this._blockDirtyMechanism) for (var t = 0, i = this.getScene().meshes; t < i.length; t++) { var r = i[t]; if (r.subMeshes) for (var n = 0, o = r.subMeshes; n < o.length; n++) { var a = o[n]; if (a.getMaterial(!1) === this) for (var s = 0, l = a._drawWrappers; s < l.length; s++) { var c = l[s]; c && c.defines && c.defines.markAllAsDirty && this._materialContext === c.materialContext && e(c.defines) } } } }, e.prototype._markScenePrePassDirty = function () { if (!this.getScene().blockMaterialDirtyMechanism && !this._blockDirtyMechanism) { var e = this.getScene().enablePrePassRenderer(); e && e.markAsDirty() } }, e.prototype._markAllSubMeshesAsAllDirty = function () { this._markAllSubMeshesAsDirty(e._AllDirtyCallBack) }, e.prototype._markAllSubMeshesAsImageProcessingDirty = function () { this._markAllSubMeshesAsDirty(e._ImageProcessingDirtyCallBack) }, e.prototype._markAllSubMeshesAsTexturesDirty = function () { this._markAllSubMeshesAsDirty(e._TextureDirtyCallBack) }, e.prototype._markAllSubMeshesAsFresnelDirty = function () { this._markAllSubMeshesAsDirty(e._FresnelDirtyCallBack) }, e.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function () { this._markAllSubMeshesAsDirty(e._FresnelAndMiscDirtyCallBack) }, e.prototype._markAllSubMeshesAsLightsDirty = function () { this._markAllSubMeshesAsDirty(e._LightsDirtyCallBack) }, e.prototype._markAllSubMeshesAsAttributesDirty = function () { this._markAllSubMeshesAsDirty(e._AttributeDirtyCallBack) }, e.prototype._markAllSubMeshesAsMiscDirty = function () { this._markAllSubMeshesAsDirty(e._MiscDirtyCallBack) }, e.prototype._markAllSubMeshesAsPrePassDirty = function () { this._markAllSubMeshesAsDirty(e._MiscDirtyCallBack) }, e.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function () { this._markAllSubMeshesAsDirty(e._TextureAndMiscDirtyCallBack) }, e.prototype._checkScenePerformancePriority = function () { var e = this; if (this._scene.performancePriority !== or.BackwardCompatible) { this.checkReadyOnlyOnce = !0; var t = this._scene.onScenePerformancePriorityChangedObservable.addOnce((function () { e.checkReadyOnlyOnce = !1 })); this.onDisposeObservable.add((function () { e._scene.onScenePerformancePriorityChangedObservable.remove(t) })) } }, e.prototype.setPrePassRenderer = function (e) { return !1 }, e.prototype.dispose = function (e, t, i) { var r = this.getScene(); if (r.stopAnimation(this), r.freeProcessedMaterials(), r.removeMaterial(this), this._eventInfo.forceDisposeTextures = t, this._callbackPluginEventGeneric(Gn.Disposed, this._eventInfo), this._parentContainer) { var n = this._parentContainer.materials.indexOf(this); n > -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 < s.length; a++) { var l; (l = s[a]).material !== this || l.sourceMesh || (l.material = null, this.releaseVertexArrayObject(l, e)) } this._uniformBuffer.dispose(), e && this._drawWrapper.effect && (this._storeEffectOnSubMeshes || this._drawWrapper.effect.dispose(), this._drawWrapper.effect = null), this.metadata = null, this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear(), this._onBindObservable && this._onBindObservable.clear(), this._onUnBindObservable && this._onUnBindObservable.clear(), this._onEffectCreatedObservable && this._onEffectCreatedObservable.clear(), this._eventInfo && (this._eventInfo = {}) }, e.prototype.releaseVertexArrayObject = function (e, t) { if (e.geometry) { var i = e.geometry; if (this._storeEffectOnSubMeshes) for (var r = 0, n = e.subMeshes; r < n.length; r++) { var o = n[r]; i._releaseVertexArrayObject(o.effect), t && o.effect && o.effect.dispose() } else i._releaseVertexArrayObject(this._drawWrapper.effect) } }, e.prototype.serialize = function () { var e = Ue.Serialize(this); return e.stencil = this.stencil.serialize(), e.uniqueId = this.uniqueId, this._serializePlugins(e), e }, e.prototype._serializePlugins = function (e) { if (e.plugins = {}, this.pluginManager) for (var t = 0, i = this.pluginManager._plugins; t < i.length; t++) { var r = i[t]; e.plugins[r.getClassName()] = r.serialize() } }, e.Parse = function (e, t, i) { if (e.customType) { if ("BABYLON.PBRMaterial" === e.customType && e.overloadedAlbedo && (e.customType = "BABYLON.LegacyPBRMaterial", !BABYLON.LegacyPBRMaterial)) return $.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library."), null } else e.customType = "BABYLON.StandardMaterial"; var r = xi.Instantiate(e.customType).Parse(e, t, i); return r._loadedUniqueId = e.uniqueId, r }, e._parsePlugins = function (e, t, i, r) { var n; if (e.plugins) for (var o in e.plugins) { var a = e.plugins[o], s = null === (n = t.pluginManager) || void 0 === n ? void 0 : n.getPlugin(a.name); if (!s) { var l = xi.Instantiate("BABYLON." + o); l && (s = new l(t)) } null == s || s.parse(a, i, r) } }, e.TriangleFillMode = a.MATERIAL_TriangleFillMode, e.WireFrameFillMode = a.MATERIAL_WireFrameFillMode, e.PointFillMode = a.MATERIAL_PointFillMode, e.PointListDrawMode = a.MATERIAL_PointListDrawMode, e.LineListDrawMode = a.MATERIAL_LineListDrawMode, e.LineLoopDrawMode = a.MATERIAL_LineLoopDrawMode, e.LineStripDrawMode = a.MATERIAL_LineStripDrawMode, e.TriangleStripDrawMode = a.MATERIAL_TriangleStripDrawMode, e.TriangleFanDrawMode = a.MATERIAL_TriangleFanDrawMode, e.ClockWiseSideOrientation = a.MATERIAL_ClockWiseSideOrientation, e.CounterClockWiseSideOrientation = a.MATERIAL_CounterClockWiseSideOrientation, e.TextureDirtyFlag = a.MATERIAL_TextureDirtyFlag, e.LightDirtyFlag = a.MATERIAL_LightDirtyFlag, e.FresnelDirtyFlag = a.MATERIAL_FresnelDirtyFlag, e.AttributesDirtyFlag = a.MATERIAL_AttributesDirtyFlag, e.MiscDirtyFlag = a.MATERIAL_MiscDirtyFlag, e.PrePassDirtyFlag = a.MATERIAL_PrePassDirtyFlag, e.AllDirtyFlag = a.MATERIAL_AllDirtyFlag, e.MATERIAL_OPAQUE = 0, e.MATERIAL_ALPHATEST = 1, e.MATERIAL_ALPHABLEND = 2, e.MATERIAL_ALPHATESTANDBLEND = 3, e.MATERIAL_NORMALBLENDMETHOD_WHITEOUT = 0, e.MATERIAL_NORMALBLENDMETHOD_RNM = 1, e.OnEventObservable = new u, e._AllDirtyCallBack = function (e) { return e.markAllAsDirty() }, e._ImageProcessingDirtyCallBack = function (e) { return e.markAsImageProcessingDirty() }, e._TextureDirtyCallBack = function (e) { return e.markAsTexturesDirty() }, e._FresnelDirtyCallBack = function (e) { return e.markAsFresnelDirty() }, e._MiscDirtyCallBack = function (e) { return e.markAsMiscDirty() }, e._PrePassDirtyCallBack = function (e) { return e.markAsPrePassDirty() }, e._LightsDirtyCallBack = function (e) { return e.markAsLightDirty() }, e._AttributeDirtyCallBack = function (e) { return e.markAsAttributesDirty() }, e._FresnelAndMiscDirtyCallBack = function (t) { e._FresnelDirtyCallBack(t), e._MiscDirtyCallBack(t) }, e._TextureAndMiscDirtyCallBack = function (t) { e._TextureDirtyCallBack(t), e._MiscDirtyCallBack(t) }, e._DirtyCallbackArray = [], e._RunDirtyCallBacks = function (t) { for (var i = 0, r = e._DirtyCallbackArray; i < r.length; i++)(0, r[i])(t) }, X([xe()], e.prototype, "id", void 0), X([xe()], e.prototype, "uniqueId", void 0), X([xe()], e.prototype, "name", void 0), X([xe()], e.prototype, "metadata", void 0), X([xe()], e.prototype, "checkReadyOnEveryCall", void 0), X([xe()], e.prototype, "checkReadyOnlyOnce", void 0), X([xe()], e.prototype, "state", void 0), X([xe("alpha")], e.prototype, "_alpha", void 0), X([xe("backFaceCulling")], e.prototype, "_backFaceCulling", void 0), X([xe("cullBackFaces")], e.prototype, "_cullBackFaces", void 0), X([xe()], e.prototype, "sideOrientation", void 0), X([xe("alphaMode")], e.prototype, "_alphaMode", void 0), X([xe()], e.prototype, "_needDepthPrePass", void 0), X([xe()], e.prototype, "disableDepthWrite", void 0), X([xe()], e.prototype, "disableColorWrite", void 0), X([xe()], e.prototype, "forceDepthWrite", void 0), X([xe()], e.prototype, "depthFunction", void 0), X([xe()], e.prototype, "separateCullingPass", void 0), X([xe("fogEnabled")], e.prototype, "_fogEnabled", void 0), X([xe()], e.prototype, "pointSize", void 0), X([xe()], e.prototype, "zOffset", void 0), X([xe()], e.prototype, "zOffsetUnits", void 0), X([xe()], e.prototype, "pointsCloud", null), X([xe()], e.prototype, "fillMode", null), X([xe()], e.prototype, "transparencyMode", null), e }(), Xn = function (e) { function t(t, i) { var r = e.call(this, t, i, !0) || this; return r._waitingSubMaterialsUniqueIds = [], r.getScene().addMultiMaterial(r), r.subMaterials = new Array, r._storeEffectOnSubMeshes = !0, r } return W(t, e), Object.defineProperty(t.prototype, "subMaterials", { get: function () { return this._subMaterials }, set: function (e) { this._subMaterials = e, this._hookArray(e) }, enumerable: !1, configurable: !0 }), t.prototype.getChildren = function () { return this.subMaterials }, t.prototype._hookArray = function (e) { var t = this, i = e.push; e.push = function () { for (var r = [], n = 0; n < arguments.length; n++)r[n] = arguments[n]; var o = i.apply(e, r); return t._markAllSubMeshesAsTexturesDirty(), o }; var r = e.splice; e.splice = function (i, n) { var o = r.apply(e, [i, n]); return t._markAllSubMeshesAsTexturesDirty(), o } }, t.prototype.getSubMaterial = function (e) { return e < 0 || e >= 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 < this.subMaterials.length; r++)if (null === (i = this.subMaterials[r]) || void 0 === i ? void 0 : i.hasTexture(t)) return !0; return !1 }, t.prototype.getClassName = function () { return "MultiMaterial" }, t.prototype.isReadyForSubMesh = function (e, t, i) { for (var r = 0; r < this.subMaterials.length; r++) { var n = this.subMaterials[r]; if (n) { if (n._storeEffectOnSubMeshes) { if (!n.isReadyForSubMesh(e, t, i)) return !1; continue } if (!n.isReady(e)) return !1 } } return !0 }, t.prototype.clone = function (e, i) { for (var r = new t(e, this.getScene()), n = 0; n < this.subMaterials.length; n++) { var o, a = this.subMaterials[n]; o = i && a ? a.clone(e + "-" + a.name) : this.subMaterials[n], r.subMaterials.push(o) } return r }, t.prototype.serialize = function () { var e = {}; e.name = this.name, e.id = this.id, e.uniqueId = this.uniqueId, me && (e.tags = me.GetTags(this)), e.materialsUniqueIds = [], e.materials = []; for (var t = 0; t < this.subMaterials.length; t++) { var i = this.subMaterials[t]; i ? (e.materialsUniqueIds.push(i.uniqueId), e.materials.push(i.id)) : (e.materialsUniqueIds.push(null), e.materials.push(null)) } return e }, t.prototype.dispose = function (t, i, r) { var n = this.getScene(); if (n) { if (r) for (var o = 0; o < this.subMaterials.length; o++) { var a = this.subMaterials[o]; a && a.dispose(t, i) } var s = n.multiMaterials.indexOf(this); s >= 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 }(Hn); b("BABYLON.MultiMaterial", Xn); var jn = function (e, t) { this.distanceOrScreenCoverage = e, this.mesh = t }, Yn = function () { }, Kn = function () { this.visibleInstances = {}, this.batchCache = new Qn, this.batchCacheReplacementModeInFrozenMode = new Qn, this.instancesBufferSize = 2048 }, Qn = function () { this.mustReturn = !1, this.visibleInstances = new Array, this.renderSelf = new Array, this.hardwareInstancedRendering = new Array }, qn = function () { this.instancesCount = 0, this.matrixBuffer = null, this.previousMatrixBuffer = null, this.matrixBufferSize = 512, this.matrixData = null, this.boundingVectors = [], this.worldMatrices = null }, Zn = 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 }, Jn = 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 Zn, c.delayLoadState = a.DELAYLOADSTATE_NONE, c.instances = new Array, c._creationDataStorage = null, c._geometry = null, c._instanceDataStorage = new Kn, c._thinInstanceDataStorage = new qn, 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; f < p.length; f++) { var _ = p[f]; _.clone && _.clone(i + "." + _.name, c) } if (o.morphTargetManager && (c.morphTargetManager = o.morphTargetManager), r.getPhysicsEngine) { var m = r.getPhysicsEngine(); if (l && m) if (1 === m.getPluginVersion()) { var g = m.getImpostorForPhysicsObject(o); g && (c.physicsImpostor = g.clone(c)) } else 2 === m.getPluginVersion() && o.physicsBody && o.physicsBody.clone(c) } for (f = 0; f < r.particleSystems.length; f++) { var v = r.particleSystems[f]; v.emitter === o && v.clone(v.name, c) } c.skeleton = o.skeleton, c.refreshBoundingInfo(!0, !0), c.computeWorldMatrix(!0) } return null !== n && (c.parent = n), c._instanceDataStorage.hardwareInstancedRendering = c.getEngine().getCaps().instancedArrays, c._internalMeshDataInfo._onMeshReadyObserverAdded = function (e) { e.unregisterOnNextCall = !0, c.isReady(!0) ? c.onMeshReadyObservable.notifyObservers(c) : c._internalMeshDataInfo._checkReadinessObserver || (c._internalMeshDataInfo._checkReadinessObserver = c._scene.onBeforeRenderObservable.add((function () { c.isReady(!0) && (c._scene.onBeforeRenderObservable.remove(c._internalMeshDataInfo._checkReadinessObserver), c._internalMeshDataInfo._checkReadinessObserver = null, c.onMeshReadyObservable.notifyObservers(c)) }))) }, c.onMeshReadyObservable = new u(c._internalMeshDataInfo._onMeshReadyObserverAdded), o && o.onClonedObservable.notifyObservers(c), c } return W(t, e), t._GetDefaultSideOrientation = function (e) { return e || t.FRONTSIDE }, Object.defineProperty(t.prototype, "useLODScreenCoverage", { get: function () { return this._internalMeshDataInfo._useLODScreenCoverage }, set: function (e) { this._internalMeshDataInfo._useLODScreenCoverage = e, this._sortLODLevels() }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "computeBonesUsingShaders", { get: function () { return this._internalAbstractMeshDataInfo._computeBonesUsingShaders }, set: function (e) { this._internalAbstractMeshDataInfo._computeBonesUsingShaders !== e && (e && this._internalMeshDataInfo._sourcePositions && (this.setVerticesData(Hi.PositionKind, this._internalMeshDataInfo._sourcePositions, !0), this._internalMeshDataInfo._sourceNormals && this.setVerticesData(Hi.NormalKind, this._internalMeshDataInfo._sourceNormals, !0), this._internalMeshDataInfo._sourcePositions = null, this._internalMeshDataInfo._sourceNormals = null), this._internalAbstractMeshDataInfo._computeBonesUsingShaders = e, this._markSubMeshesAsAttributesDirty()) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onBeforeRenderObservable", { get: function () { return this._internalMeshDataInfo._onBeforeRenderObservable || (this._internalMeshDataInfo._onBeforeRenderObservable = new u), this._internalMeshDataInfo._onBeforeRenderObservable }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onBeforeBindObservable", { get: function () { return this._internalMeshDataInfo._onBeforeBindObservable || (this._internalMeshDataInfo._onBeforeBindObservable = new u), this._internalMeshDataInfo._onBeforeBindObservable }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onAfterRenderObservable", { get: function () { return this._internalMeshDataInfo._onAfterRenderObservable || (this._internalMeshDataInfo._onAfterRenderObservable = new u), this._internalMeshDataInfo._onAfterRenderObservable }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onBetweenPassObservable", { get: function () { return this._internalMeshDataInfo._onBetweenPassObservable || (this._internalMeshDataInfo._onBetweenPassObservable = new u), this._internalMeshDataInfo._onBetweenPassObservable }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onBeforeDrawObservable", { get: function () { return this._internalMeshDataInfo._onBeforeDrawObservable || (this._internalMeshDataInfo._onBeforeDrawObservable = new u), this._internalMeshDataInfo._onBeforeDrawObservable }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onBeforeDraw", { set: function (e) { this._onBeforeDrawObserver && this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver), this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasInstances", { get: function () { return this.instances.length > 0 }, 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); n < o.length; n++) { var a = o[n]; "InstancedMesh" === a.getClassName() && "Mesh" === r.getClassName() && a.sourceMesh === this ? a.instantiateHierarchy(r, { doNotInstantiate: t && t.doNotInstantiate || !1, newSourcedMesh: r }, i) : a.instantiateHierarchy(r, t, i) } return r }, t.prototype.getClassName = function () { return "Mesh" }, Object.defineProperty(t.prototype, "_isMesh", { get: function () { return !0 }, enumerable: !1, configurable: !0 }), t.prototype.toString = function (t) { var i = e.prototype.toString.call(this, t); if (i += ", n vertices: " + this.getTotalVertices(), i += ", parent: " + (this._waitingParentId ? this._waitingParentId : this.parent ? this.parent.name : "NONE"), this.animations) for (var r = 0; r < this.animations.length; r++)i += ", animation[0]: " + this.animations[r].toString(t); if (t) if (this._geometry) { var n = this.getIndices(), o = this.getVerticesData(Hi.PositionKind); o && n && (i += ", flat shading: " + (o.length / 3 === n.length ? "YES" : "NO")) } else i += ", flat shading: UNKNOWN"; return i }, t.prototype._unBindEffect = function () { e.prototype._unBindEffect.call(this); for (var t = 0, i = this.instances; t < i.length; t++)i[t]._unBindEffect() }, Object.defineProperty(t.prototype, "hasLODLevels", { get: function () { return this._internalMeshDataInfo._LODLevels.length > 0 }, 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.distanceOrScreenCoverage < i.distanceOrScreenCoverage ? e : t.distanceOrScreenCoverage > i.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 jn(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; i < t._LODLevels.length; i++) { var r = t._LODLevels[i]; if (r.distanceOrScreenCoverage === e) return r.mesh } return null }, t.prototype.removeLODLevel = function (e) { for (var t = this._internalMeshDataInfo, i = 0; i < t._LODLevels.length; i++)t._LODLevels[i].mesh === e && (t._LODLevels.splice(i, 1), e && (e._masterMesh = null)); return this._sortLODLevels(), this }, t.prototype.getLOD = function (e, t) { var i = this._internalMeshDataInfo; if (!i._LODLevels || 0 === i._LODLevels.length) return this; var r = t || this.getBoundingInfo().boundingSphere, n = e.mode === ln.ORTHOGRAPHIC_CAMERA ? e.minZ : r.centerWorld.subtract(e.globalPosition).length(), o = n, s = 1; if (i._useLODScreenCoverage) { var l = e.screenArea, c = r.radiusWorld * e.minZ / n; o = (c = c * c * Math.PI) / l, s = -1 } if (s * i._LODLevels[i._LODLevels.length - 1].distanceOrScreenCoverage > s * o) return this.onLODLevelSelection && this.onLODLevelSelection(o, this, this), this; for (var u = 0; u < i._LODLevels.length; u++) { var h = i._LODLevels[u]; if (s * h.distanceOrScreenCoverage < s * o) { if (h.mesh) { if (h.mesh.delayLoadState === a.DELAYLOADSTATE_NOTLOADED) return h.mesh._checkDelayState(), this; if (h.mesh.delayLoadState === a.DELAYLOADSTATE_LOADING) return this; h.mesh._preActivate(), h.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache) } return this.onLODLevelSelection && this.onLODLevelSelection(o, this, h.mesh), h.mesh } } return this.onLODLevelSelection && this.onLODLevelSelection(o, this, this), this }, Object.defineProperty(t.prototype, "geometry", { get: function () { return this._geometry }, enumerable: !1, configurable: !0 }), t.prototype.getTotalVertices = function () { return null === this._geometry || void 0 === this._geometry ? 0 : this._geometry.getTotalVertices() }, t.prototype.getVerticesData = function (e, t, i, r) { var n, o; if (!this._geometry) return null; var a = r || null === (o = null === (n = this._userInstancedBuffersStorage) || void 0 === n ? void 0 : n.vertexBuffers[e]) || void 0 === o ? void 0 : o.getFloatData(this.instances.length + 1, i || t && 1 !== this._geometry.meshes.length); return a || (a = this._geometry.getVerticesData(e, t, i)), a }, t.prototype.getVertexBuffer = function (e, t) { var i, r; return this._geometry ? null !== (r = t || null === (i = this._userInstancedBuffersStorage) || void 0 === i ? void 0 : i.vertexBuffers[e]) && void 0 !== r ? r : this._geometry.getVertexBuffer(e) : null }, t.prototype.isVerticesDataPresent = function (e, t) { var i; return this._geometry ? !t && void 0 !== (null === (i = this._userInstancedBuffersStorage) || void 0 === i ? void 0 : i.vertexBuffers[e]) || this._geometry.isVerticesDataPresent(e) : !!this._delayInfo && -1 !== this._delayInfo.indexOf(e) }, t.prototype.isVertexBufferUpdatable = function (e, t) { var i; if (!this._geometry) return !!this._delayInfo && -1 !== this._delayInfo.indexOf(e); if (!t) { var r = null === (i = this._userInstancedBuffersStorage) || void 0 === i ? void 0 : i.vertexBuffers[e]; if (r) return r.isUpdatable() } return this._geometry.isVertexBufferUpdatable(e) }, t.prototype.getVerticesDataKinds = function (e) { if (!this._geometry) { var t = new Array; return this._delayInfo && this._delayInfo.forEach((function (e) { t.push(e) })), t } var i = this._geometry.getVerticesDataKinds(); if (!e && this._userInstancedBuffersStorage) for (var r in this._userInstancedBuffersStorage.vertexBuffers) -1 === i.indexOf(r) && i.push(r); return i }, t.prototype.getTotalIndices = function () { return this._geometry ? this._geometry.getTotalIndices() : 0 }, t.prototype.getIndices = function (e, t) { return this._geometry ? this._geometry.getIndices(e, t) : [] }, Object.defineProperty(t.prototype, "isBlocked", { get: function () { return null !== this._masterMesh && void 0 !== this._masterMesh }, enumerable: !1, configurable: !0 }), t.prototype.isReady = function (t, i) { var r, n, o, s, l, c, u; if (void 0 === t && (t = !1), void 0 === i && (i = !1), this.delayLoadState === a.DELAYLOADSTATE_LOADING) return !1; if (!e.prototype.isReady.call(this, t)) return !1; if (!this.subMeshes || 0 === this.subMeshes.length) return !0; if (!t) return !0; var h = this.getEngine(), d = this.getScene(), p = i || h.getCaps().instancedArrays && (this.instances.length > 0 || this.hasThinInstances); this.computeWorldMatrix(); var f = this.material || d.defaultMaterial; if (f) if (f._storeEffectOnSubMeshes) for (var _ = 0, m = this.subMeshes; _ < m.length; _++) { var g = (I = m[_]).getMaterial(); if (g) if (g._storeEffectOnSubMeshes) { if (!g.isReadyForSubMesh(this, I, p)) return !1 } else if (!g.isReady(this, p)) return !1 } else if (!f.isReady(this, p)) return !1; for (var v = h.currentRenderPassId, y = 0, b = this.lightSources; y < b.length; y++) { var T = b[y].getShadowGenerators(); if (T) for (var E = T.values(), S = E.next(); !0 !== S.done; S = E.next()) { var x = S.value; if (x && (!(null === (r = x.getShadowMap()) || void 0 === r ? void 0 : r.renderList) || (null === (n = x.getShadowMap()) || void 0 === n ? void 0 : n.renderList) && -1 !== (null === (s = null === (o = x.getShadowMap()) || void 0 === o ? void 0 : o.renderList) || void 0 === s ? void 0 : s.indexOf(this)))) { for (var A = null !== (l = x.getShadowMap().renderPassIds) && void 0 !== l ? l : [h.currentRenderPassId], R = 0; R < A.length; ++R) { h.currentRenderPassId = A[R]; for (var C = 0, P = this.subMeshes; C < P.length; C++) { var I = P[C]; if (!x.isReady(I, p, null !== (u = null === (c = I.getMaterial()) || void 0 === c ? void 0 : c.needAlphaBlendingForMesh(this)) && void 0 !== u && u)) return h.currentRenderPassId = v, !1 } } h.currentRenderPassId = v } } } for (var M = 0, O = this._internalMeshDataInfo._LODLevels; M < O.length; M++) { var D = O[M]; if (D.mesh && !D.mesh.isReady(p)) return !1 } return !0 }, Object.defineProperty(t.prototype, "areNormalsFrozen", { get: function () { return this._internalMeshDataInfo._areNormalsFrozen }, enumerable: !1, configurable: !0 }), t.prototype.freezeNormals = function () { return this._internalMeshDataInfo._areNormalsFrozen = !0, this }, t.prototype.unfreezeNormals = function () { return this._internalMeshDataInfo._areNormalsFrozen = !1, this }, Object.defineProperty(t.prototype, "overridenInstanceCount", { set: function (e) { this._instanceDataStorage.overridenInstanceCount = e }, enumerable: !1, configurable: !0 }), t.prototype._preActivate = function () { var e = this._internalMeshDataInfo, t = this.getScene().getRenderId(); return e._preActivateId === t || (e._preActivateId = t, this._instanceDataStorage.visibleInstances = null), this }, t.prototype._preActivateForIntermediateRendering = function (e) { return this._instanceDataStorage.visibleInstances && (this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = e), this }, t.prototype._registerInstanceForRenderId = function (e, t) { return this._instanceDataStorage.visibleInstances || (this._instanceDataStorage.visibleInstances = { defaultRenderId: t, selfDefaultRenderId: this._renderId }), this._instanceDataStorage.visibleInstances[t] || (void 0 !== this._instanceDataStorage.previousRenderId && this._instanceDataStorage.isFrozen && (this._instanceDataStorage.visibleInstances[this._instanceDataStorage.previousRenderId] = null), this._instanceDataStorage.previousRenderId = t, this._instanceDataStorage.visibleInstances[t] = new Array), this._instanceDataStorage.visibleInstances[t].push(e), this }, t.prototype._afterComputeWorldMatrix = function () { e.prototype._afterComputeWorldMatrix.call(this), this.hasThinInstances && (this.doNotSyncBoundingInfo || this.thinInstanceRefreshBoundingInfo(!1)) }, t.prototype._postActivate = function () { this.edgesShareWithInstances && this.edgesRenderer && this.edgesRenderer.isEnabled && this._renderingGroup && (this._renderingGroup._edgesRenderers.pushNoDuplicate(this.edgesRenderer), this.edgesRenderer.customInstances.push(this.getWorldMatrix())) }, t.prototype.refreshBoundingInfo = function (e, t) { if (void 0 === e && (e = !1), void 0 === t && (t = !1), this.hasBoundingInfo && this.getBoundingInfo().isLocked) return this; var i = this.geometry ? this.geometry.boundingBias : null; return this._refreshBoundingInfo(this._getPositionData(e, t), i), this }, t.prototype._createGlobalSubMesh = function (e) { var t = this.getTotalVertices(); if (!t || !this.getIndices()) return null; if (this.subMeshes && this.subMeshes.length > 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; o < a.length; o++) { var s = a[o]; if (s.indexStart + s.indexCount > r) { n = !0; break } if (s.verticesStart + s.verticesCount > t) { n = !0; break } } if (!n) return this.subMeshes[0] } return this.releaseSubMeshes(), new bn(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 < e && !(r >= t); n++)bn.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 En; n.set(t, e); var o = this.getScene(); new An(An.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 = An.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(Hi.PositionKind); if (!i) return this; if (e(i), this.updateVerticesData(Hi.PositionKind, i, !1, !1), t) { var r = this.getIndices(), n = this.getVerticesData(Hi.NormalKind); if (!n) return this; En.ComputeNormals(i, r, n), this.updateVerticesData(Hi.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(An.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 En; r.indices = e; var n = this.getScene(); new An(An.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 Hn.PointFillMode: n = null; break; case Hn.WireFrameFillMode: n = e._getLinesIndexBuffer(this.getIndices(), o); break; default: case Hn.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 == Hn.PointFillMode ? r.drawArraysType(t, e.verticesStart, e.verticesCount, this.forcedInstanceCount || i) : t == Hn.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.instancesBufferSize < p;)c.instancesBufferSize *= 2; c.instancesData && u == c.instancesBufferSize || (c.instancesData = new Float32Array(c.instancesBufferSize / 4)), (this._scene.needsPreviousWorldMatrices && !c.instancesPreviousData || u != c.instancesBufferSize) && (c.instancesPreviousData = new Float32Array(c.instancesBufferSize / 4)); var f = 0, _ = 0, m = r.renderSelf[e._id], g = !h || u !== c.instancesBufferSize || this._scene.needsPreviousWorldMatrices && !c.instancesPreviousBuffer; if (this._instanceDataStorage.manualUpdate || c.isFrozen && !g) _ = (m ? 1 : 0) + l; else { var v = this.getWorldMatrix(); if (m && (this._scene.needsPreviousWorldMatrices && (c.masterMeshPreviousWorldMatrix ? (c.masterMeshPreviousWorldMatrix.copyToArray(c.instancesPreviousData, f), c.masterMeshPreviousWorldMatrix.copyFrom(v)) : (c.masterMeshPreviousWorldMatrix = v.clone(), c.masterMeshPreviousWorldMatrix.copyToArray(c.instancesPreviousData, f))), v.copyToArray(c.instancesData, f), f += 16, _++), s) { if (t.INSTANCEDMESH_SORT_TRANSPARENT && this._scene.activeCamera && (null === (a = e.getMaterial()) || void 0 === a ? void 0 : a.needAlphaBlendingForMesh(e.getRenderingMesh()))) { for (var y = this._scene.activeCamera.globalPosition, b = 0; b < s.length; b++) { var T = s[b]; T._distanceToCamera = R.Distance(T.getBoundingInfo().boundingSphere.centerWorld, y) } s.sort((function (e, t) { return e._distanceToCamera > t._distanceToCamera ? -1 : e._distanceToCamera < t._distanceToCamera ? 1 : 0 })) } for (b = 0; b < s.length; b++) { var E = s[b], S = E.getWorldMatrix(); S.copyToArray(c.instancesData, f), this._scene.needsPreviousWorldMatrices && (E._previousWorldMatrix ? (E._previousWorldMatrix.copyToArray(c.instancesPreviousData, f), E._previousWorldMatrix.copyFrom(S)) : (E._previousWorldMatrix = S.clone(), E._previousWorldMatrix.copyToArray(c.instancesPreviousData, f))), f += 16, _++ } } } return g ? (h && h.dispose(), d && d.dispose(), h = new Wi(o, c.instancesData, !0, 16, !1, !0), c.instancesBuffer = h, this._userInstancedBuffersStorage || (this._userInstancedBuffersStorage = { data: {}, vertexBuffers: {}, strides: {}, sizes: {}, vertexArrayObjects: this.getEngine().getCaps().vertexArrayObject ? {} : void 0 }), this._userInstancedBuffersStorage.vertexBuffers.world0 = h.createVertexBuffer("world0", 0, 4), this._userInstancedBuffersStorage.vertexBuffers.world1 = h.createVertexBuffer("world1", 4, 4), this._userInstancedBuffersStorage.vertexBuffers.world2 = h.createVertexBuffer("world2", 8, 4), this._userInstancedBuffersStorage.vertexBuffers.world3 = h.createVertexBuffer("world3", 12, 4), this._scene.needsPreviousWorldMatrices && (d = new Wi(o, c.instancesPreviousData, !0, 16, !1, !0), c.instancesPreviousBuffer = d, this._userInstancedBuffersStorage.vertexBuffers.previousWorld0 = d.createVertexBuffer("previousWorld0", 0, 4), this._userInstancedBuffersStorage.vertexBuffers.previousWorld1 = d.createVertexBuffer("previousWorld1", 4, 4), this._userInstancedBuffersStorage.vertexBuffers.previousWorld2 = d.createVertexBuffer("previousWorld2", 8, 4), this._userInstancedBuffersStorage.vertexBuffers.previousWorld3 = d.createVertexBuffer("previousWorld3", 12, 4)), this._invalidateInstanceVertexArrayObject()) : this._instanceDataStorage.isFrozen && !this._instanceDataStorage.forceMatrixUpdates || (h.updateDirectly(c.instancesData, 0, _), !this._scene.needsPreviousWorldMatrices || this._instanceDataStorage.manualUpdate && !this._instanceDataStorage.previousManualUpdate || d.updateDirectly(c.instancesPreviousData, 0, _)), this._processInstancedBuffers(s, m), this.getScene()._activeIndices.addCount(e.indexCount * _, !1), o._currentDrawContext && (o._currentDrawContext.useInstancing = !0), this._bind(e, n, i), this._draw(e, i, _), !this._scene.needsPreviousWorldMatrices || g || !this._instanceDataStorage.manualUpdate || this._instanceDataStorage.isFrozen && !this._instanceDataStorage.forceMatrixUpdates || this._instanceDataStorage.previousManualUpdate || d.updateDirectly(c.instancesData, 0, _), o.unbindInstanceAttributes(), this }, t.prototype._renderWithThinInstances = function (e, t, i, r) { var n, o, a = null !== (o = null === (n = this._thinInstanceDataStorage) || void 0 === n ? void 0 : n.instancesCount) && void 0 !== o ? o : 0; this.getScene()._activeIndices.addCount(e.indexCount * a, !1), r._currentDrawContext && (r._currentDrawContext.useInstancing = !0), this._bind(e, i, t), this._draw(e, t, a), this._scene.needsPreviousWorldMatrices && !this._thinInstanceDataStorage.previousMatrixData && this._thinInstanceDataStorage.matrixData && (this._thinInstanceDataStorage.previousMatrixBuffer ? this._thinInstanceDataStorage.previousMatrixBuffer.updateDirectly(this._thinInstanceDataStorage.matrixData, 0, a) : this._thinInstanceDataStorage.previousMatrixBuffer = this._thinInstanceCreateMatrixBuffer("previousWorld", this._thinInstanceDataStorage.matrixData, !1)), r.unbindInstanceAttributes() }, t.prototype._processInstancedBuffers = function (e, t) { }, t.prototype._processRendering = function (e, t, i, r, n, o, a, s) { var l = this.getScene(), c = l.getEngine(); if (r = this._getRenderingFillMode(r), o && t.getRenderingMesh().hasThinInstances) return this._renderWithThinInstances(t, r, i, c), this; if (o) this._renderWithInstances(t, r, n, i, c); else { c._currentDrawContext && (c._currentDrawContext.useInstancing = !1); var u = 0; n.renderSelf[t._id] && (a && a(!1, e.getWorldMatrix(), s), u++, this._draw(t, r, this._instanceDataStorage.overridenInstanceCount)); var h = n.visibleInstances[t._id]; if (h) { var d = h.length; u += d; for (var p = 0; p < d; p++) { var f = h[p].getWorldMatrix(); a && a(!0, f, s), this._draw(t, r) } } l._activeIndices.addCount(t.indexCount * u, !1) } return this }, t.prototype._rebuild = function (t) { if (void 0 === t && (t = !1), this._instanceDataStorage.instancesBuffer && (t && this._instanceDataStorage.instancesBuffer.dispose(), this._instanceDataStorage.instancesBuffer = null), this._userInstancedBuffersStorage) { for (var i in this._userInstancedBuffersStorage.vertexBuffers) { var r = this._userInstancedBuffersStorage.vertexBuffers[i]; r && (t && r.dispose(), this._userInstancedBuffersStorage.vertexBuffers[i] = null) } this._userInstancedBuffersStorage.vertexArrayObjects && (this._userInstancedBuffersStorage.vertexArrayObjects = {}) } this._internalMeshDataInfo._effectiveMaterial = null, e.prototype._rebuild.call(this, t) }, t.prototype._freeze = function () { if (this.subMeshes) { for (var e = 0; e < this.subMeshes.length; e++)this._getInstancesRenderList(e); this._internalMeshDataInfo._effectiveMaterial = null, this._instanceDataStorage.isFrozen = !0 } }, t.prototype._unFreeze = function () { this._instanceDataStorage.isFrozen = !1, this._instanceDataStorage.previousBatch = null }, t.prototype.render = function (e, t, i) { var r, n, o, a = this.getScene(); if (this._internalAbstractMeshDataInfo._isActiveIntermediate ? this._internalAbstractMeshDataInfo._isActiveIntermediate = !1 : this._internalAbstractMeshDataInfo._isActive = !1, this._checkOcclusionQuery() && !this._occlusionDataStorage.forceRenderingWhenOccluded) return this; var s = this._getInstancesRenderList(e._id, !!i); if (s.mustReturn) return this; if (!this._geometry || !this._geometry.getVertexBuffers() || !this._unIndexed && !this._geometry.getIndexBuffer()) return this; var l = a.getEngine(), c = 0, u = null; this.ignoreCameraMaxZ && a.activeCamera && !a._isInIntermediateRendering() && (c = a.activeCamera.maxZ, u = a.activeCamera, a.activeCamera.maxZ = 0, a.updateTransformMatrix(!0)), this._internalMeshDataInfo._onBeforeRenderObservable && this._internalMeshDataInfo._onBeforeRenderObservable.notifyObservers(this); var h, d = e.getRenderingMesh(), p = s.hardwareInstancedRendering[e._id] || d.hasThinInstances || !!this._userInstancedBuffersStorage && !e.getMesh()._internalAbstractMeshDataInfo._actAsRegularMesh, f = this._instanceDataStorage, _ = e.getMaterial(); if (!_) return u && (u.maxZ = c, a.updateTransformMatrix(!0)), this; if (f.isFrozen && this._internalMeshDataInfo._effectiveMaterial && this._internalMeshDataInfo._effectiveMaterial === _) { if (_._storeEffectOnSubMeshes && !(null === (r = e.effect) || void 0 === r ? void 0 : r._wasPreviouslyReady) || !_._storeEffectOnSubMeshes && !(null === (n = _.getEffect()) || void 0 === n ? void 0 : n._wasPreviouslyReady)) return u && (u.maxZ = c, a.updateTransformMatrix(!0)), this } else { if (_._storeEffectOnSubMeshes) { if (!_.isReadyForSubMesh(this, e, p)) return u && (u.maxZ = c, a.updateTransformMatrix(!0)), this } else if (!_.isReady(this, p)) return u && (u.maxZ = c, a.updateTransformMatrix(!0)), this; this._internalMeshDataInfo._effectiveMaterial = _ } t && l.setAlphaMode(this._internalMeshDataInfo._effectiveMaterial.alphaMode); for (var m = null !== (o = null == (h = this._internalMeshDataInfo._effectiveMaterial._storeEffectOnSubMeshes ? e._drawWrapper : this._internalMeshDataInfo._effectiveMaterial._getDrawWrapper()) ? void 0 : h.effect) && void 0 !== o ? o : null, g = 0, v = a._beforeRenderingMeshStage; g < v.length; g++)v[g].action(this, e, s, m); if (!h || !m) return u && (u.maxZ = c, a.updateTransformMatrix(!0)), this; var y, b = i || this; if (f.isFrozen || !this._internalMeshDataInfo._effectiveMaterial.backFaceCulling && null === this.overrideMaterialSideOrientation) y = f.sideOrientation; else { var T = b._getWorldMatrixDeterminant(); null == (y = this.overrideMaterialSideOrientation) && (y = this._internalMeshDataInfo._effectiveMaterial.sideOrientation), T < 0 && (y = y === Hn.ClockWiseSideOrientation ? Hn.CounterClockWiseSideOrientation : Hn.ClockWiseSideOrientation), f.sideOrientation = y } var E = this._internalMeshDataInfo._effectiveMaterial._preBind(h, y); this._internalMeshDataInfo._effectiveMaterial.forceDepthWrite && l.setDepthWrite(!0); var S = this._internalMeshDataInfo._effectiveMaterial, x = S.fillMode; this._internalMeshDataInfo._onBeforeBindObservable && this._internalMeshDataInfo._onBeforeBindObservable.notifyObservers(this), p || this._bind(e, m, x, !1); var A = b.getWorldMatrix(); S._storeEffectOnSubMeshes ? S.bindForSubMesh(A, this, e) : S.bind(A, this), !S.backFaceCulling && S.separateCullingPass && (l.setState(!0, S.zOffset, !1, !E, S.cullBackFaces, S.stencil, S.zOffsetUnits), this._processRendering(this, e, m, x, s, p, this._onBeforeDraw, this._internalMeshDataInfo._effectiveMaterial), l.setState(!0, S.zOffset, !1, E, S.cullBackFaces, S.stencil, S.zOffsetUnits), this._internalMeshDataInfo._onBetweenPassObservable && this._internalMeshDataInfo._onBetweenPassObservable.notifyObservers(e)), this._processRendering(this, e, m, x, s, p, this._onBeforeDraw, this._internalMeshDataInfo._effectiveMaterial), this._internalMeshDataInfo._effectiveMaterial.unbind(); for (var R = 0, C = a._afterRenderingMeshStage; R < C.length; R++)C[R].action(this, e, s, m); return this._internalMeshDataInfo._onAfterRenderObservable && this._internalMeshDataInfo._onAfterRenderObservable.notifyObservers(this), u && (u.maxZ = c, a.updateTransformMatrix(!0)), a.performancePriority !== or.Aggressive || f.isFrozen || this._freeze(), this }, t.prototype.cleanMatrixWeights = function () { this.isVerticesDataPresent(Hi.MatricesWeightsKind) && (this.isVerticesDataPresent(Hi.MatricesWeightsExtraKind) ? this._normalizeSkinWeightsAndExtra() : this._normalizeSkinFourWeights()) }, t.prototype._normalizeSkinFourWeights = function () { for (var e = this.getVerticesData(Hi.MatricesWeightsKind), t = e.length, i = 0; i < t; i += 4) { var r = e[i] + e[i + 1] + e[i + 2] + e[i + 3]; if (0 === r) e[i] = 1; else { var n = 1 / r; e[i] *= n, e[i + 1] *= n, e[i + 2] *= n, e[i + 3] *= n } } this.setVerticesData(Hi.MatricesWeightsKind, e) }, t.prototype._normalizeSkinWeightsAndExtra = function () { for (var e = this.getVerticesData(Hi.MatricesWeightsExtraKind), t = this.getVerticesData(Hi.MatricesWeightsKind), i = t.length, r = 0; r < i; r += 4) { var n = t[r] + t[r + 1] + t[r + 2] + t[r + 3]; if (0 === (n += e[r] + e[r + 1] + e[r + 2] + e[r + 3])) t[r] = 1; else { var o = 1 / n; t[r] *= o, t[r + 1] *= o, t[r + 2] *= o, t[r + 3] *= o, e[r] *= o, e[r + 1] *= o, e[r + 2] *= o, e[r + 3] *= o } } this.setVerticesData(Hi.MatricesWeightsKind, t), this.setVerticesData(Hi.MatricesWeightsKind, e) }, t.prototype.validateSkinning = function () { var e = this.getVerticesData(Hi.MatricesWeightsExtraKind), t = this.getVerticesData(Hi.MatricesWeightsKind); if (null === t || null == this.skeleton) return { skinned: !1, valid: !0, report: "not skinned" }; for (var i = t.length, r = 0, n = 0, o = 0, a = 0, s = null === e ? 4 : 8, l = new Array, c = 0; c <= s; c++)l[c] = 0; for (c = 0; c < i; c += 4) { for (var u = t[c], h = u, d = 0 === h ? 0 : 1, p = 1; p < s; p++) { var f = p < 4 ? t[c + p] : e[c + p - 4]; f > u && 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 < s; p++)m += p < 4 ? Math.abs(t[c + p] - t[c + p] * _) : Math.abs(e[c + p - 4] - e[c + p - 4] * _); m > .001 && a++ } } var g = this.skeleton.bones.length, v = this.getVerticesData(Hi.MatricesIndicesKind), y = this.getVerticesData(Hi.MatricesIndicesExtraKind), b = 0; for (c = 0; c < i; c += 4)for (p = 0; p < s; p++) { var T = p < 4 ? v[c + p] : y[c + p - 4]; (T >= 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 xi.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(Hi.PositionKind)) return this; var t = this.subMeshes.splice(0); this._resetPointsArrayCache(); var i, r = this.getVerticesData(Hi.PositionKind), n = R.Zero(); for (i = 0; i < r.length; i += 3)R.TransformCoordinatesFromFloatsToRef(r[i], r[i + 1], r[i + 2], e, n).toArray(r, i); if (this.setVerticesData(Hi.PositionKind, r, this.getVertexBuffer(Hi.PositionKind).isUpdatable()), this.isVerticesDataPresent(Hi.NormalKind)) { for (r = this.getVerticesData(Hi.NormalKind), i = 0; i < r.length; i += 3)R.TransformNormalFromFloatsToRef(r[i], r[i + 1], r[i + 2], e, n).normalize().toArray(r, i); this.setVerticesData(Hi.NormalKind, r, this.getVertexBuffer(Hi.NormalKind).isUpdatable()) } return e.determinant() < 0 && this.flipFaces(), this.releaseSubMeshes(), this.subMeshes = t, this }, t.prototype.bakeCurrentTransformIntoVertices = function (e) { return void 0 === e && (e = !0), this.bakeTransformIntoVertices(this.computeWorldMatrix(!0)), this.resetLocalMatrix(e), this }, Object.defineProperty(t.prototype, "_positions", { get: function () { return this._internalAbstractMeshDataInfo._positions ? this._internalAbstractMeshDataInfo._positions : this._geometry ? this._geometry._positions : null }, enumerable: !1, configurable: !0 }), t.prototype._resetPointsArrayCache = function () { return this._geometry && this._geometry._resetPointsArrayCache(), this }, t.prototype._generatePointsArray = function () { return !!this._geometry && this._geometry._generatePointsArray() }, t.prototype.clone = function (e, i, r, n) { return void 0 === e && (e = ""), void 0 === i && (i = null), void 0 === n && (n = !0), new t(e, this.getScene(), i, this, r, n) }, t.prototype.dispose = function (t, i) { void 0 === i && (i = !1), this.morphTargetManager = null, this._geometry && this._geometry.releaseForMesh(this, !0); var r = this._internalMeshDataInfo; if (r._onBeforeDrawObservable && r._onBeforeDrawObservable.clear(), r._onBeforeBindObservable && r._onBeforeBindObservable.clear(), r._onBeforeRenderObservable && r._onBeforeRenderObservable.clear(), r._onAfterRenderObservable && r._onAfterRenderObservable.clear(), r._onBetweenPassObservable && r._onBetweenPassObservable.clear(), this._scene.useClonedMeshMap) { if (r.meshMap) for (var n in r.meshMap) (s = r.meshMap[n]) && (s._internalMeshDataInfo._source = null, r.meshMap[n] = void 0); r._source && r._source._internalMeshDataInfo.meshMap && (r._source._internalMeshDataInfo.meshMap[this.uniqueId] = void 0) } else for (var o = 0, a = this.getScene().meshes; o < a.length; o++) { var s; (s = a[o])._internalMeshDataInfo && s._internalMeshDataInfo._source && s._internalMeshDataInfo._source === this && (s._internalMeshDataInfo._source = null) } r._source = null, this._instanceDataStorage.visibleInstances = {}, this._disposeInstanceSpecificData(), this._disposeThinInstanceSpecificData(), this._internalMeshDataInfo._checkReadinessObserver && this._scene.onBeforeRenderObservable.remove(this._internalMeshDataInfo._checkReadinessObserver), e.prototype.dispose.call(this, t, i) }, t.prototype._disposeInstanceSpecificData = function () { }, t.prototype._disposeThinInstanceSpecificData = function () { }, t.prototype._invalidateInstanceVertexArrayObject = function () { }, t.prototype.applyDisplacementMap = function (e, t, i, r, n, o, a) { var s = this; void 0 === a && (a = !1); var l = this.getScene(); return xi.LoadImage(e, (function (e) { var l = e.width, c = e.height, u = s.getEngine().createCanvas(l, c).getContext("2d"); u.drawImage(e, 0, 0); var h = u.getImageData(0, 0, l, c).data; s.applyDisplacementMapFromBuffer(h, l, c, t, i, n, o, a), r && r(s) }), (function () { }), l.offlineProvider), this }, t.prototype.applyDisplacementMapFromBuffer = function (e, t, i, r, n, o, a, s) { if (void 0 === s && (s = !1), !this.isVerticesDataPresent(Hi.PositionKind) || !this.isVerticesDataPresent(Hi.NormalKind) || !this.isVerticesDataPresent(Hi.UVKind)) return $.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"), this; var l = this.getVerticesData(Hi.PositionKind, !0, !0), c = this.getVerticesData(Hi.NormalKind), u = this.getVerticesData(Hi.UVKind), h = R.Zero(), d = R.Zero(), p = A.Zero(); o = o || A.Zero(), a = a || new A(1, 1); for (var f = 0; f < l.length; f += 3) { R.FromArrayToRef(l, f, h), R.FromArrayToRef(c, f, d), A.FromArrayToRef(u, f / 3 * 2, p); var _ = 4 * ((Math.abs(p.x * a.x + o.x % 1) * (t - 1) % t | 0) + (Math.abs(p.y * a.y + o.y % 1) * (i - 1) % i | 0) * t), m = e[_] / 255 * .3 + e[_ + 1] / 255 * .59 + e[_ + 2] / 255 * .11; d.normalize(), d.scaleInPlace(r + (n - r) * m), (h = h.add(d)).toArray(l, f) } return En.ComputeNormals(l, this.getIndices(), c), s ? (this.setVerticesData(Hi.PositionKind, l), this.setVerticesData(Hi.NormalKind, c), this.setVerticesData(Hi.UVKind, u)) : (this.updateVerticesData(Hi.PositionKind, l), this.updateVerticesData(Hi.NormalKind, c)), this }, t.prototype._getFlattenedNormals = function (e, t) { for (var i = new Float32Array(3 * e.length), r = 0, n = this.overrideMaterialSideOrientation === (this._scene.useRightHandedSystem ? a.MATERIAL_CounterClockWiseSideOrientation : a.MATERIAL_ClockWiseSideOrientation), o = 0; o < e.length; o += 3) { var s = R.FromArray(t, 3 * e[o]), l = R.FromArray(t, 3 * e[o + 1]), c = R.FromArray(t, 3 * e[o + 2]), u = s.subtract(l), h = c.subtract(l), d = R.Normalize(R.Cross(u, h)); n && d.scaleInPlace(-1); for (var p = 0; p < 3; p++)i[r++] = d.x, i[r++] = d.y, i[r++] = d.z } return i }, t.prototype._convertToUnIndexedMesh = function (e) { void 0 === e && (e = !1); for (var t = this.getVerticesDataKinds(), i = this.getIndices(), r = {}, n = function (e, t) { for (var r = new Float32Array(i.length * t), n = 0, o = 0; o < i.length; o++)for (var a = 0; a < t; a++)r[n++] = e[i[o] * t + a]; return r }, o = this.geometry ? this.subMeshes.slice(0) : [], a = 0, s = t; a < s.length; a++)r[u = s[a]] = this.getVerticesData(u); for (var l = 0, c = t; l < c.length; l++) { var u = c[l], h = this.getVertexBuffer(u), d = h.getStrideSize(); if (e && u === Hi.NormalKind) { var p = this._getFlattenedNormals(i, r[Hi.PositionKind]); this.setVerticesData(Hi.NormalKind, p, h.isUpdatable(), d) } else this.setVerticesData(u, n(r[u], d), h.isUpdatable(), d) } if (this.morphTargetManager) { for (var f = 0; f < this.morphTargetManager.numTargets; f++) { var _ = this.morphTargetManager.getTarget(f), m = _.getPositions(); _.setPositions(n(m, 3)), (p = _.getNormals()) && _.setNormals(e ? this._getFlattenedNormals(i, m) : n(p, 3)); var g = _.getTangents(); g && _.setTangents(n(g, 3)); var v = _.getUVs(); v && _.setUVs(n(v, 2)) } this.morphTargetManager.synchronize() } for (var y = 0; y < i.length; y++)i[y] = y; this.setIndices(i), this._unIndexed = !0, this.releaseSubMeshes(); for (var b = 0, T = o; b < T.length; b++) { var E = T[b]; bn.AddToMesh(E.materialIndex, E.indexStart, E.indexCount, E.indexStart, E.indexCount, this) } return this.synchronizeInstances(), this }, t.prototype.convertToFlatShadedMesh = function () { return this._convertToUnIndexedMesh(!0) }, t.prototype.convertToUnIndexedMesh = function () { return this._convertToUnIndexedMesh() }, t.prototype.flipFaces = function (e) { void 0 === e && (e = !1); var t, i = En.ExtractFromMesh(this); if (e && this.isVerticesDataPresent(Hi.NormalKind) && i.normals) for (t = 0; t < i.normals.length; t++)i.normals[t] *= -1; if (i.indices) { var r = void 0; for (t = 0; t < i.indices.length; t += 3)r = i.indices[t + 1], i.indices[t + 1] = i.indices[t + 2], i.indices[t + 2] = r } return i.applyToMesh(this, this.isVertexBufferUpdatable(Hi.PositionKind)), this }, t.prototype.increaseVertices = function (e) { void 0 === e && (e = 1); var t = En.ExtractFromMesh(this), i = t.indices && !Array.isArray(t.indices) && Array.from ? Array.from(t.indices) : t.indices, r = t.positions && !Array.isArray(t.positions) && Array.from ? Array.from(t.positions) : t.positions, n = t.uvs && !Array.isArray(t.uvs) && Array.from ? Array.from(t.uvs) : t.uvs, o = t.normals && !Array.isArray(t.normals) && Array.from ? Array.from(t.normals) : t.normals; if (i && r) { t.indices = i, t.positions = r, n && (t.uvs = n), o && (t.normals = o); for (var a = e + 1, s = new Array, l = 0; l < a + 1; l++)s[l] = new Array; var c = void 0, u = void 0, h = new R(0, 0, 0), d = new R(0, 0, 0), p = new A(0, 0), f = new Array, _ = new Array, m = new Array, g = void 0, v = r.length, y = void 0; n && (y = n.length); var b = void 0; for (o && (b = o.length), l = 0; l < i.length; l += 3) { _[0] = i[l], _[1] = i[l + 1], _[2] = i[l + 2]; for (var T = 0; T < 3; T++)if (c = _[T], u = _[(T + 1) % 3], void 0 === m[c] && void 0 === m[u] ? (m[c] = new Array, m[u] = new Array) : (void 0 === m[c] && (m[c] = new Array), void 0 === m[u] && (m[u] = new Array)), void 0 === m[c][u] && void 0 === m[u][c]) { m[c][u] = [], h.x = (r[3 * u] - r[3 * c]) / a, h.y = (r[3 * u + 1] - r[3 * c + 1]) / a, h.z = (r[3 * u + 2] - r[3 * c + 2]) / a, o && (d.x = (o[3 * u] - o[3 * c]) / a, d.y = (o[3 * u + 1] - o[3 * c + 1]) / a, d.z = (o[3 * u + 2] - o[3 * c + 2]) / a), n && (p.x = (n[2 * u] - n[2 * c]) / a, p.y = (n[2 * u + 1] - n[2 * c + 1]) / a), m[c][u].push(c); for (var E = 1; E < a; E++)m[c][u].push(r.length / 3), r[v++] = r[3 * c] + E * h.x, r[v++] = r[3 * c + 1] + E * h.y, r[v++] = r[3 * c + 2] + E * h.z, o && (o[b++] = o[3 * c] + E * d.x, o[b++] = o[3 * c + 1] + E * d.y, o[b++] = o[3 * c + 2] + E * d.z), n && (n[y++] = n[2 * c] + E * p.x, n[y++] = n[2 * c + 1] + E * p.y); m[c][u].push(u), m[u][c] = new Array, g = m[c][u].length; for (var S = 0; S < g; S++)m[u][c][S] = m[c][u][g - 1 - S] } for (s[0][0] = i[l], s[1][0] = m[i[l]][i[l + 1]][1], s[1][1] = m[i[l]][i[l + 2]][1], E = 2; E < a; E++)for (s[E][0] = m[i[l]][i[l + 1]][E], s[E][E] = m[i[l]][i[l + 2]][E], h.x = (r[3 * s[E][E]] - r[3 * s[E][0]]) / E, h.y = (r[3 * s[E][E] + 1] - r[3 * s[E][0] + 1]) / E, h.z = (r[3 * s[E][E] + 2] - r[3 * s[E][0] + 2]) / E, o && (d.x = (o[3 * s[E][E]] - o[3 * s[E][0]]) / E, d.y = (o[3 * s[E][E] + 1] - o[3 * s[E][0] + 1]) / E, d.z = (o[3 * s[E][E] + 2] - o[3 * s[E][0] + 2]) / E), n && (p.x = (n[2 * s[E][E]] - n[2 * s[E][0]]) / E, p.y = (n[2 * s[E][E] + 1] - n[2 * s[E][0] + 1]) / E), T = 1; T < E; T++)s[E][T] = r.length / 3, r[v++] = r[3 * s[E][0]] + T * h.x, r[v++] = r[3 * s[E][0] + 1] + T * h.y, r[v++] = r[3 * s[E][0] + 2] + T * h.z, o && (o[b++] = o[3 * s[E][0]] + T * d.x, o[b++] = o[3 * s[E][0] + 1] + T * d.y, o[b++] = o[3 * s[E][0] + 2] + T * d.z), n && (n[y++] = n[2 * s[E][0]] + T * p.x, n[y++] = n[2 * s[E][0] + 1] + T * p.y); for (s[a] = m[i[l + 1]][i[l + 2]], f.push(s[0][0], s[1][0], s[1][1]), E = 1; E < a; E++) { for (T = void 0, T = 0; T < E; T++)f.push(s[E][T], s[E + 1][T], s[E + 1][T + 1]), f.push(s[E][T], s[E + 1][T + 1], s[E][T + 1]); f.push(s[E][T], s[E + 1][T], s[E + 1][T + 1]) } } t.indices = f, t.applyToMesh(this, this.isVertexBufferUpdatable(Hi.PositionKind)) } else $.Warn("Couldn't increase number of vertices : VertexData must contain at least indices and positions") }, t.prototype.forceSharedVertices = function () { var e = En.ExtractFromMesh(this), t = e.uvs, i = e.indices, r = e.positions, n = e.colors, o = e.matricesIndices, a = e.matricesWeights, s = e.matricesIndicesExtra, l = e.matricesWeightsExtra; if (void 0 === i || void 0 === r || null === i || null === r) $.Warn("VertexData contains empty entries"); else { for (var c = new Array, u = new Array, h = new Array, d = new Array, p = new Array, f = new Array, _ = new Array, m = new Array, g = new Array, v = 0, y = {}, b = void 0, T = void 0, E = 0; E < i.length; E += 3) { T = [i[E], i[E + 1], i[E + 2]], g = new Array; for (var S = 0; S < 3; S++) { g[S] = ""; for (var x = 0; x < 3; x++)Math.abs(r[3 * T[S] + x]) < 1e-8 && (r[3 * T[S] + x] = 0), g[S] += r[3 * T[S] + x] + "|" } if (g[0] != g[1] && g[0] != g[2] && g[1] != g[2]) for (S = 0; S < 3; S++) { if (void 0 === (b = y[g[S]])) { for (y[g[S]] = v, b = v++, x = 0; x < 3; x++)c.push(r[3 * T[S] + x]); if (null != n) for (x = 0; x < 4; x++)d.push(n[4 * T[S] + x]); if (null != t) for (x = 0; x < 2; x++)h.push(t[2 * T[S] + x]); if (null != o) for (x = 0; x < 4; x++)p.push(o[4 * T[S] + x]); if (null != a) for (x = 0; x < 4; x++)f.push(a[4 * T[S] + x]); if (null != s) for (x = 0; x < 4; x++)_.push(s[4 * T[S] + x]); if (null != l) for (x = 0; x < 4; x++)m.push(l[4 * T[S] + x]) } u.push(b) } } var A = new Array; En.ComputeNormals(c, u, A), e.positions = c, e.indices = u, e.normals = A, null != t && (e.uvs = h), null != n && (e.colors = d), null != o && (e.matricesIndices = p), null != a && (e.matricesWeights = f), null != s && (e.matricesIndicesExtra = _), null != a && (e.matricesWeightsExtra = m), e.applyToMesh(this, this.isVertexBufferUpdatable(Hi.PositionKind)) } }, t._instancedMeshFactory = function (e, t) { throw ge("InstancedMesh") }, t._PhysicsImpostorParser = function (e, t, i) { throw ge("PhysicsImpostor") }, t.prototype.createInstance = function (e) { return t._instancedMeshFactory(e, this) }, t.prototype.synchronizeInstances = function () { for (var e = 0; e < this.instances.length; e++)this.instances[e]._syncSubMeshes(); return this }, t.prototype.optimizeIndices = function (e) { var t = this, i = this.getIndices(), r = this.getVerticesData(Hi.PositionKind); if (!r || !i) return this; for (var n = new Array, o = 0; o < r.length; o += 3)n.push(R.FromArray(r, o)); var a = new Array; return Ri.SyncAsyncForLoop(n.length, 40, (function (e) { for (var t = n.length - 1 - e, i = n[t], r = 0; r < t; ++r) { var o = n[r]; if (i.equals(o)) { a[t] = r; break } } }), (function () { for (var r = 0; r < i.length; ++r)i[r] = a[i[r]] || i[r]; var n = t.subMeshes.slice(0); t.setIndices(i), t.subMeshes = n, e && e(t) })), this }, t.prototype.serialize = function (e) { void 0 === e && (e = {}), e.name = this.name, e.id = this.id, e.uniqueId = this.uniqueId, e.type = this.getClassName(), me && me.HasTags(this) && (e.tags = me.GetTags(this)), e.position = this.position.asArray(), this.rotationQuaternion ? e.rotationQuaternion = this.rotationQuaternion.asArray() : this.rotation && (e.rotation = this.rotation.asArray()), e.scaling = this.scaling.asArray(), this._postMultiplyPivotMatrix ? e.pivotMatrix = this.getPivotMatrix().asArray() : e.localMatrix = this.getPivotMatrix().asArray(), e.isEnabled = this.isEnabled(!1), e.isVisible = this.isVisible, e.infiniteDistance = this.infiniteDistance, e.pickable = this.isPickable, e.receiveShadows = this.receiveShadows, e.billboardMode = this.billboardMode, e.visibility = this.visibility, e.checkCollisions = this.checkCollisions, e.isBlocker = this.isBlocker, e.overrideMaterialSideOrientation = this.overrideMaterialSideOrientation, this.parent && this.parent._serializeAsParent(e), e.isUnIndexed = this.isUnIndexed; var t = this._geometry; if (t && this.subMeshes) { e.geometryUniqueId = t.uniqueId, e.geometryId = t.id, e.subMeshes = []; for (var i = 0; i < this.subMeshes.length; i++) { var r = this.subMeshes[i]; e.subMeshes.push({ materialIndex: r.materialIndex, verticesStart: r.verticesStart, verticesCount: r.verticesCount, indexStart: r.indexStart, indexCount: r.indexCount }) } } this.material ? this.material.doNotSerialize || (e.materialUniqueId = this.material.uniqueId, e.materialId = this.material.id) : (this.material = null, e.materialUniqueId = this._scene.defaultMaterial.uniqueId, e.materialId = this._scene.defaultMaterial.id), this.morphTargetManager && (e.morphTargetManagerId = this.morphTargetManager.uniqueId), this.skeleton && (e.skeletonId = this.skeleton.id, e.numBoneInfluencers = this.numBoneInfluencers), this.getScene()._getComponent(qi.NAME_PHYSICSENGINE) && (a = this.getPhysicsImpostor()) && (e.physicsMass = a.getParam("mass"), e.physicsFriction = a.getParam("friction"), e.physicsRestitution = a.getParam("mass"), e.physicsImpostor = a.type), this.metadata && (e.metadata = this.metadata), e.instances = []; for (var n = 0; n < this.instances.length; n++) { var o = this.instances[n]; if (!o.doNotSerialize) { var a, s = { name: o.name, id: o.id, isEnabled: o.isEnabled(!1), isVisible: o.isVisible, isPickable: o.isPickable, checkCollisions: o.checkCollisions, position: o.position.asArray(), scaling: o.scaling.asArray() }; o.parent && o.parent._serializeAsParent(s), o.rotationQuaternion ? s.rotationQuaternion = o.rotationQuaternion.asArray() : o.rotation && (s.rotation = o.rotation.asArray()), this.getScene()._getComponent(qi.NAME_PHYSICSENGINE) && (a = o.getPhysicsImpostor()) && (s.physicsMass = a.getParam("mass"), s.physicsFriction = a.getParam("friction"), s.physicsRestitution = a.getParam("mass"), s.physicsImpostor = a.type), o.metadata && (s.metadata = o.metadata), o.actionManager && (s.actions = o.actionManager.serialize(o.name)), e.instances.push(s), Ue.AppendSerializedAnimations(o, s), s.ranges = o.serializeAnimationRanges() } } if (this._thinInstanceDataStorage.instancesCount && this._thinInstanceDataStorage.matrixData && (e.thinInstances = { instancesCount: this._thinInstanceDataStorage.instancesCount, matrixData: Array.from(this._thinInstanceDataStorage.matrixData), matrixBufferSize: this._thinInstanceDataStorage.matrixBufferSize, enablePicking: this.thinInstanceEnablePicking }, this._userThinInstanceBuffersStorage)) { var l = { data: {}, sizes: {}, strides: {} }; for (var c in this._userThinInstanceBuffersStorage.data) l.data[c] = Array.from(this._userThinInstanceBuffersStorage.data[c]), l.sizes[c] = this._userThinInstanceBuffersStorage.sizes[c], l.strides[c] = this._userThinInstanceBuffersStorage.strides[c]; e.thinInstances.userThinInstance = l } return Ue.AppendSerializedAnimations(this, e), e.ranges = this.serializeAnimationRanges(), e.layerMask = this.layerMask, e.alphaIndex = this.alphaIndex, e.hasVertexAlpha = this.hasVertexAlpha, e.overlayAlpha = this.overlayAlpha, e.overlayColor = this.overlayColor.asArray(), e.renderOverlay = this.renderOverlay, e.applyFog = this.applyFog, this.actionManager && (e.actions = this.actionManager.serialize(this.name)), e }, t.prototype._syncGeometryWithMorphTargetManager = function () { if (this.geometry) { this._markSubMeshesAsAttributesDirty(); var e = this._internalAbstractMeshDataInfo._morphTargetManager; if (e && e.vertexCount) { if (e.vertexCount !== this.getTotalVertices()) return $.Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count."), void (this.morphTargetManager = null); if (e.isUsingTextureForTargets) return; for (var t = 0; t < e.numInfluencers; t++) { var i = e.getActiveTarget(t), r = i.getPositions(); if (!r) return void $.Error("Invalid morph target. Target must have positions."); this.geometry.setVerticesData(Hi.PositionKind + t, r, !1, 3); var n = i.getNormals(); n && this.geometry.setVerticesData(Hi.NormalKind + t, n, !1, 3); var o = i.getTangents(); o && this.geometry.setVerticesData(Hi.TangentKind + t, o, !1, 3); var a = i.getUVs(); a && this.geometry.setVerticesData(Hi.UVKind + "_" + t, a, !1, 2) } } else for (t = 0; this.geometry.isVerticesDataPresent(Hi.PositionKind + t);)this.geometry.removeVerticesData(Hi.PositionKind + t), this.geometry.isVerticesDataPresent(Hi.NormalKind + t) && this.geometry.removeVerticesData(Hi.NormalKind + t), this.geometry.isVerticesDataPresent(Hi.TangentKind + t) && this.geometry.removeVerticesData(Hi.TangentKind + t), this.geometry.isVerticesDataPresent(Hi.UVKind + t) && this.geometry.removeVerticesData(Hi.UVKind + "_" + t), t++ } }, t.Parse = function (e, i, r) { var n; if ((n = e.type && "LinesMesh" === e.type ? t._LinesMeshParser(e, i) : e.type && "GroundMesh" === e.type ? t._GroundMeshParser(e, i) : e.type && "GoldbergMesh" === e.type ? t._GoldbergMeshParser(e, i) : e.type && "GreasedLineMesh" === e.type ? t._GreasedLineMeshParser(e, i) : e.type && "TrailMesh" === e.type ? t._TrailMeshParser(e, i) : new t(e.name, i)).id = e.id, n._waitingParsedUniqueId = e.uniqueId, me && me.AddTagsTo(n, e.tags), n.position = R.FromArray(e.position), void 0 !== e.metadata && (n.metadata = e.metadata), e.rotationQuaternion ? n.rotationQuaternion = P.FromArray(e.rotationQuaternion) : e.rotation && (n.rotation = R.FromArray(e.rotation)), n.scaling = R.FromArray(e.scaling), e.localMatrix ? n.setPreTransformMatrix(I.FromArray(e.localMatrix)) : e.pivotMatrix && n.setPivotMatrix(I.FromArray(e.pivotMatrix)), n.setEnabled(e.isEnabled), n.isVisible = e.isVisible, n.infiniteDistance = e.infiniteDistance, n.showBoundingBox = e.showBoundingBox, n.showSubMeshesBoundingBox = e.showSubMeshesBoundingBox, void 0 !== e.applyFog && (n.applyFog = e.applyFog), void 0 !== e.pickable && (n.isPickable = e.pickable), void 0 !== e.alphaIndex && (n.alphaIndex = e.alphaIndex), n.receiveShadows = e.receiveShadows, void 0 !== e.billboardMode && (n.billboardMode = e.billboardMode), void 0 !== e.visibility && (n.visibility = e.visibility), n.checkCollisions = e.checkCollisions, n.overrideMaterialSideOrientation = e.overrideMaterialSideOrientation, void 0 !== e.isBlocker && (n.isBlocker = e.isBlocker), n._shouldGenerateFlatShading = e.useFlatShading, e.freezeWorldMatrix && (n._waitingData.freezeWorldMatrix = e.freezeWorldMatrix), void 0 !== e.parentId && (n._waitingParentId = e.parentId), void 0 !== e.parentInstanceIndex && (n._waitingParentInstanceIndex = e.parentInstanceIndex), void 0 !== e.actions && (n._waitingData.actions = e.actions), void 0 !== e.overlayAlpha && (n.overlayAlpha = e.overlayAlpha), void 0 !== e.overlayColor && (n.overlayColor = B.FromArray(e.overlayColor)), void 0 !== e.renderOverlay && (n.renderOverlay = e.renderOverlay), n.isUnIndexed = !!e.isUnIndexed, n.hasVertexAlpha = e.hasVertexAlpha, e.delayLoadingFile ? (n.delayLoadState = a.DELAYLOADSTATE_NOTLOADED, n.delayLoadingFile = r + e.delayLoadingFile, n.buildBoundingInfo(R.FromArray(e.boundingBoxMinimum), R.FromArray(e.boundingBoxMaximum)), e._binaryInfo && (n._binaryInfo = e._binaryInfo), n._delayInfo = [], e.hasUVs && n._delayInfo.push(Hi.UVKind), e.hasUVs2 && n._delayInfo.push(Hi.UV2Kind), e.hasUVs3 && n._delayInfo.push(Hi.UV3Kind), e.hasUVs4 && n._delayInfo.push(Hi.UV4Kind), e.hasUVs5 && n._delayInfo.push(Hi.UV5Kind), e.hasUVs6 && n._delayInfo.push(Hi.UV6Kind), e.hasColors && n._delayInfo.push(Hi.ColorKind), e.hasMatricesIndices && n._delayInfo.push(Hi.MatricesIndicesKind), e.hasMatricesWeights && n._delayInfo.push(Hi.MatricesWeightsKind), n._delayLoadingFunction = An._ImportGeometry, Sn.ForceFullSceneLoadingForIncremental && n._checkDelayState()) : An._ImportGeometry(e, n), e.materialUniqueId ? n._waitingMaterialId = e.materialUniqueId : e.materialId && (n._waitingMaterialId = e.materialId), e.morphTargetManagerId > -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; o < e.animations.length; o++) { var s = e.animations[o]; (h = T("BABYLON.Animation")) && n.animations.push(h.Parse(s)) } ze.ParseAnimationRanges(n, e, i) } if (e.autoAnimate && i.beginAnimation(n, e.autoAnimateFrom, e.autoAnimateTo, e.autoAnimateLoop, e.autoAnimateSpeed || 1), e.layerMask && !isNaN(e.layerMask) ? n.layerMask = Math.abs(parseInt(e.layerMask)) : n.layerMask = 268435455, e.physicsImpostor && t._PhysicsImpostorParser(i, n, e), e.lodMeshIds && (n._waitingData.lods = { ids: e.lodMeshIds, distances: e.lodDistances ? e.lodDistances : null, coverages: e.lodCoverages ? e.lodCoverages : null }), e.instances) for (var l = 0; l < e.instances.length; l++) { var c = e.instances[l], u = n.createInstance(c.name); if (c.id && (u.id = c.id), me && (c.tags ? me.AddTagsTo(u, c.tags) : me.AddTagsTo(u, e.tags)), u.position = R.FromArray(c.position), void 0 !== c.metadata && (u.metadata = c.metadata), void 0 !== c.parentId && (u._waitingParentId = c.parentId), void 0 !== c.parentInstanceIndex && (u._waitingParentInstanceIndex = c.parentInstanceIndex), void 0 !== c.isEnabled && null !== c.isEnabled && u.setEnabled(c.isEnabled), void 0 !== c.isVisible && null !== c.isVisible && (u.isVisible = c.isVisible), void 0 !== c.isPickable && null !== c.isPickable && (u.isPickable = c.isPickable), c.rotationQuaternion ? u.rotationQuaternion = P.FromArray(c.rotationQuaternion) : c.rotation && (u.rotation = R.FromArray(c.rotation)), u.scaling = R.FromArray(c.scaling), null != c.checkCollisions && null != c.checkCollisions && (u.checkCollisions = c.checkCollisions), null != c.pickable && null != c.pickable && (u.isPickable = c.pickable), null != c.showBoundingBox && null != c.showBoundingBox && (u.showBoundingBox = c.showBoundingBox), null != c.showSubMeshesBoundingBox && null != c.showSubMeshesBoundingBox && (u.showSubMeshesBoundingBox = c.showSubMeshesBoundingBox), null != c.alphaIndex && null != c.showSubMeshesBoundingBox && (u.alphaIndex = c.alphaIndex), c.physicsImpostor && t._PhysicsImpostorParser(i, u, c), void 0 !== c.actions && (u._waitingData.actions = c.actions), c.animations) { for (o = 0; o < c.animations.length; o++) { var h; s = c.animations[o], (h = T("BABYLON.Animation")) && u.animations.push(h.Parse(s)) } ze.ParseAnimationRanges(u, c, i), c.autoAnimate && i.beginAnimation(u, c.autoAnimateFrom, c.autoAnimateTo, c.autoAnimateLoop, c.autoAnimateSpeed || 1) } } if (e.thinInstances) { var d = e.thinInstances; if (n.thinInstanceEnablePicking = !!d.enablePicking, d.matrixData ? (n.thinInstanceSetBuffer("matrix", new Float32Array(d.matrixData), 16, !1), n._thinInstanceDataStorage.matrixBufferSize = d.matrixBufferSize, n._thinInstanceDataStorage.instancesCount = d.instancesCount) : n._thinInstanceDataStorage.matrixBufferSize = d.matrixBufferSize, e.thinInstances.userThinInstance) { var p = e.thinInstances.userThinInstance; for (var f in p.data) n.thinInstanceSetBuffer(f, new Float32Array(p.data[f]), p.strides[f], !1), n._userThinInstanceBuffersStorage.sizes[f] = p.sizes[f] } } return n }, t.prototype.setPositionsForCPUSkinning = function () { var e = this._internalMeshDataInfo; if (!e._sourcePositions) { var t = this.getVerticesData(Hi.PositionKind); if (!t) return e._sourcePositions; e._sourcePositions = new Float32Array(t), this.isVertexBufferUpdatable(Hi.PositionKind) || this.setVerticesData(Hi.PositionKind, t, !0) } return e._sourcePositions }, t.prototype.setNormalsForCPUSkinning = function () { var e = this._internalMeshDataInfo; if (!e._sourceNormals) { var t = this.getVerticesData(Hi.NormalKind); if (!t) return e._sourceNormals; e._sourceNormals = new Float32Array(t), this.isVertexBufferUpdatable(Hi.NormalKind) || this.setVerticesData(Hi.NormalKind, t, !0) } return e._sourceNormals }, t.prototype.applySkeleton = function (e) { if (!this.geometry) return this; if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId()) return this; if (this.geometry._softwareSkinningFrameId = this.getScene().getFrameId(), !this.isVerticesDataPresent(Hi.PositionKind)) return this; if (!this.isVerticesDataPresent(Hi.MatricesIndicesKind)) return this; if (!this.isVerticesDataPresent(Hi.MatricesWeightsKind)) return this; var t = this.isVerticesDataPresent(Hi.NormalKind), i = this._internalMeshDataInfo; if (!i._sourcePositions) { var r = this.subMeshes.slice(); this.setPositionsForCPUSkinning(), this.subMeshes = r } t && !i._sourceNormals && this.setNormalsForCPUSkinning(); var n = this.getVerticesData(Hi.PositionKind); if (!n) return this; n instanceof Float32Array || (n = new Float32Array(n)); var o = this.getVerticesData(Hi.NormalKind); if (t) { if (!o) return this; o instanceof Float32Array || (o = new Float32Array(o)) } var a = this.getVerticesData(Hi.MatricesIndicesKind), s = this.getVerticesData(Hi.MatricesWeightsKind); if (!s || !a) return this; for (var l, c = this.numBoneInfluencers > 4, u = c ? this.getVerticesData(Hi.MatricesIndicesExtraKind) : null, h = c ? this.getVerticesData(Hi.MatricesWeightsExtraKind) : null, d = e.getTransformMatrices(this), p = R.Zero(), f = new I, _ = new I, m = 0, g = 0; g < n.length; g += 3, m += 4) { var v = void 0; for (l = 0; l < 4; l++)(v = s[m + l]) > 0 && (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(Hi.PositionKind, n), t && this.updateVerticesData(Hi.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), rn(t._MergeMeshesCoroutine(e, i, r, n, o, a, !1)) }, t.MergeMeshesAsync = function (e, i, r, n, o, a) { return void 0 === i && (i = !0), nn(t._MergeMeshesCoroutine(e, i, r, n, o, a, !0), en()) }, 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 < e.length; l++)if ((c += e[l].getTotalVertices()) >= 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 < e.length; l++) { if ((f = e[l]).isAnInstance) return $.Warn("Cannot merge instance meshes."), [2, null]; if (p !== f.overrideMaterialSideOrientation) return $.Warn("Cannot merge meshes with different overrideMaterialSideOrientation values."), [2, null]; if (o && d.push(f.getTotalIndices()), a) if (f.material) if ((_ = f.material) instanceof Xn) { for (m = 0; m < _.subMaterials.length; m++)u.indexOf(_.subMaterials[m]) < 0 && u.push(_.subMaterials[m]); for (D = 0; D < f.subMeshes.length; D++)h.push(u.indexOf(_.subMaterials[f.subMeshes[D].materialIndex])), d.push(f.subMeshes[D].indexCount) } else for (u.indexOf(_) < 0 && u.push(_), D = 0; D < f.subMeshes.length; D++)h.push(u.indexOf(_)), d.push(f.subMeshes[D].indexCount); else for (D = 0; D < f.subMeshes.length; D++)h.push(0), d.push(f.subMeshes[D].indexCount) } return g = e[0], v = function (e) { var t = e.computeWorldMatrix(!0); return { vertexData: En.ExtractFromMesh(e, !1, !1), transform: t } }, N = v(g), y = N.vertexData, b = N.transform, s ? [4] : [3, 2]; case 1: F.sent(), F.label = 2; case 2: T = new Array(e.length - 1), E = 1, F.label = 3; case 3: return E < e.length ? (T[E - 1] = v(e[E]), s ? [4] : [3, 5]) : [3, 6]; case 4: F.sent(), F.label = 5; case 5: return E++, [3, 3]; case 6: S = y._mergeCoroutine(b, T, r, s, !i), x = S.next(), F.label = 7; case 7: return x.done ? [3, 10] : s ? [4] : [3, 9]; case 8: F.sent(), F.label = 9; case 9: return x = S.next(), [3, 7]; case 10: A = x.value, n || (n = new t(g.name + "_merged", g.getScene())), R = A._applyToCoroutine(n, void 0, s), C = R.next(), F.label = 11; case 11: return C.done ? [3, 14] : s ? [4] : [3, 13]; case 12: F.sent(), F.label = 13; case 13: return C = R.next(), [3, 11]; case 14: if (n.checkCollisions = g.checkCollisions, n.overrideMaterialSideOrientation = g.overrideMaterialSideOrientation, i) for (l = 0; l < e.length; l++)e[l].dispose(); if (o || a) { for (n.releaseSubMeshes(), l = 0, P = 0; l < d.length;)bn.CreateFromIndices(0, P, d[l], n, void 0, !1), P += d[l], l++; for (I = 0, M = n.subMeshes; I < M.length; I++)M[I].refreshBoundingInfo(); n.computeWorldMatrix(!0) } if (a) { for ((O = new Xn(g.name + "_merged", g.getScene())).subMaterials = u, D = 0; D < n.subMeshes.length; D++)n.subMeshes[D].materialIndex = h[D]; n.material = O } else n.material = g.material; return [2, n] } })) }, t.prototype.addInstance = function (e) { e._indexInSourceMeshInstanceArray = this.instances.length, this.instances.push(e) }, t.prototype.removeInstance = function (e) { var t = e._indexInSourceMeshInstanceArray; if (-1 != t) { if (t !== this.instances.length - 1) { var i = this.instances[this.instances.length - 1]; this.instances[t] = i, i._indexInSourceMeshInstanceArray = t } e._indexInSourceMeshInstanceArray = -1, this.instances.pop() } }, t.prototype._shouldConvertRHS = function () { return this.overrideMaterialSideOrientation === Hn.CounterClockWiseSideOrientation }, t.prototype._getRenderingFillMode = function (e) { var t, i = this.getScene(); return i.forcePointsCloud ? Hn.PointFillMode : i.forceWireframe ? Hn.WireFrameFillMode : null !== (t = this.overrideRenderingFillMode) && void 0 !== t ? t : e }, t.prototype.setMaterialByID = function (e) { return this.setMaterialById(e) }, t.CreateRibbon = function (e, t, i, r, n, o, a, s, l) { throw new Error("Import MeshBuilder to populate this function") }, t.CreateDisc = function (e, t, i, r, n, o) { throw new Error("Import MeshBuilder to populate this function") }, t.CreateBox = function (e, t, i, r, n) { throw new Error("Import MeshBuilder to populate this function") }, t.CreateSphere = function (e, t, i, r, n, o) { throw new Error("Import MeshBuilder to populate this function") }, t.CreateHemisphere = function (e, t, i, r) { throw new Error("Import MeshBuilder to populate this function") }, t.CreateCylinder = function (e, t, i, r, n, o, a, s, l) { throw new Error("Import MeshBuilder to populate this function") }, t.CreateTorus = function (e, t, i, r, n, o, a) { throw new Error("Import MeshBuilder to populate this function") }, t.CreateTorusKnot = function (e, t, i, r, n, o, a, s, l, c) { throw new Error("Import MeshBuilder to populate this function") }, t.CreateLines = function (e, t, i, r, n) { throw new Error("Import MeshBuilder to populate this function") }, t.CreateDashedLines = function (e, t, i, r, n, o, a, s) { throw new Error("Import MeshBuilder to populate this function") }, t.CreatePolygon = function (e, t, i, r, n, o, a) { throw new Error("Import MeshBuilder to populate this function") }, t.ExtrudePolygon = function (e, t, i, r, n, o, a, s) { throw new Error("Import MeshBuilder to populate this function") }, t.ExtrudeShape = function (e, t, i, r, n, o, a, s, l, c) { throw new Error("Import MeshBuilder to populate this function") }, t.ExtrudeShapeCustom = function (e, t, i, r, n, o, a, s, l, c, u, h) { throw new Error("Import MeshBuilder to populate this function") }, t.CreateLathe = function (e, t, i, r, n, o, a) { throw new Error("Import MeshBuilder to populate this function") }, t.CreatePlane = function (e, t, i, r, n) { throw new Error("Import MeshBuilder to populate this function") }, t.CreateGround = function (e, t, i, r, n, o) { throw new Error("Import MeshBuilder to populate this function") }, t.CreateTiledGround = function (e, t, i, r, n, o, a, s, l) { throw new Error("Import MeshBuilder to populate this function") }, t.CreateGroundFromHeightMap = function (e, t, i, r, n, o, a, s, l, c, u) { throw new Error("Import MeshBuilder to populate this function") }, t.CreateTube = function (e, t, i, r, n, o, a, s, l, c) { throw new Error("Import MeshBuilder to populate this function") }, t.CreatePolyhedron = function (e, t, i) { throw new Error("Import MeshBuilder to populate this function") }, t.CreateIcoSphere = function (e, t, i) { throw new Error("Import MeshBuilder to populate this function") }, t.CreateDecal = function (e, t, i, r, n, o) { throw new Error("Import MeshBuilder to populate this function") }, t.CreateCapsule = function (e, t, i) { throw new Error("Import MeshBuilder to populate this function") }, t.ExtendToGoldberg = function (e) { throw new Error("Import MeshBuilder to populate this function") }, t.FRONTSIDE = En.FRONTSIDE, t.BACKSIDE = En.BACKSIDE, t.DOUBLESIDE = En.DOUBLESIDE, t.DEFAULTSIDE = En.DEFAULTSIDE, t.NO_CAP = 0, t.CAP_START = 1, t.CAP_END = 2, t.CAP_ALL = 3, t.NO_FLIP = 0, t.FLIP_TILE = 1, t.ROTATE_TILE = 2, t.FLIP_ROW = 3, t.ROTATE_ROW = 4, t.FLIP_N_ROTATE_TILE = 5, t.FLIP_N_ROTATE_ROW = 6, t.CENTER = 0, t.LEFT = 1, t.RIGHT = 2, t.TOP = 3, t.BOTTOM = 4, t.INSTANCEDMESH_SORT_TRANSPARENT = !1, t._GroundMeshParser = function (e, t) { throw ge("GroundMesh") }, t._GoldbergMeshParser = function (e, t) { throw ge("GoldbergMesh") }, t._LinesMeshParser = function (e, t) { throw ge("LinesMesh") }, t._GreasedLineMeshParser = function (e, t) { throw ge("GreasedLineMesh") }, t._TrailMeshParser = function (e, t) { throw ge("TrailMesh") }, t }(Ln); b("BABYLON.Mesh", Jn), Jn._instancedMeshFactory = function (e, t) { var i = new $n(e, t); if (t.instancedBuffers) for (var r in i.instancedBuffers = {}, t.instancedBuffers) i.instancedBuffers[r] = t.instancedBuffers[r]; return i }; var $n = function (e) { function t(t, i) { var r = e.call(this, t, i.getScene()) || this; r._indexInSourceMeshInstanceArray = -1, r._distanceToCamera = 0, i.addInstance(r), r._sourceMesh = i, r._unIndexed = i._unIndexed, r.position.copyFrom(i.position), r.rotation.copyFrom(i.rotation), r.scaling.copyFrom(i.scaling), i.rotationQuaternion && (r.rotationQuaternion = i.rotationQuaternion.clone()), r.animations = i.animations.slice(); for (var n = 0, o = i.getAnimationRanges(); n < o.length; n++) { var a = o[n]; null != a && r.createAnimationRange(a.name, a.from, a.to) } return r.infiniteDistance = i.infiniteDistance, r.setPivotMatrix(i.getPivotMatrix()), r.refreshBoundingInfo(!0, !0), r._syncSubMeshes(), r } return W(t, e), t.prototype.getClassName = function () { return "InstancedMesh" }, Object.defineProperty(t.prototype, "lightSources", { get: function () { return this._sourceMesh._lightSources }, enumerable: !1, configurable: !0 }), t.prototype._resyncLightSources = function () { }, t.prototype._resyncLightSource = function () { }, t.prototype._removeLightSource = function () { }, Object.defineProperty(t.prototype, "receiveShadows", { get: function () { return this._sourceMesh.receiveShadows }, set: function (e) { var t; (null === (t = this._sourceMesh) || void 0 === t ? void 0 : t.receiveShadows) !== e && xi.Warn("Setting receiveShadows on an instanced mesh has no effect") }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "material", { get: function () { return this._sourceMesh.material }, set: function (e) { var t; (null === (t = this._sourceMesh) || void 0 === t ? void 0 : t.material) !== e && xi.Warn("Setting material on an instanced mesh has no effect") }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "visibility", { get: function () { return this._sourceMesh.visibility }, set: function (e) { var t; (null === (t = this._sourceMesh) || void 0 === t ? void 0 : t.visibility) !== e && xi.Warn("Setting visibility on an instanced mesh has no effect") }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "skeleton", { get: function () { return this._sourceMesh.skeleton }, set: function (e) { var t; (null === (t = this._sourceMesh) || void 0 === t ? void 0 : t.skeleton) !== e && xi.Warn("Setting skeleton on an instanced mesh has no effect") }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "renderingGroupId", { get: function () { return this._sourceMesh.renderingGroupId }, set: function (e) { this._sourceMesh && e !== this._sourceMesh.renderingGroupId && $.Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene") }, enumerable: !1, configurable: !0 }), t.prototype.getTotalVertices = function () { return this._sourceMesh ? this._sourceMesh.getTotalVertices() : 0 }, t.prototype.getTotalIndices = function () { return this._sourceMesh.getTotalIndices() }, Object.defineProperty(t.prototype, "sourceMesh", { get: function () { return this._sourceMesh }, enumerable: !1, configurable: !0 }), t.prototype.createInstance = function (e) { return this._sourceMesh.createInstance(e) }, t.prototype.isReady = function (e) { return void 0 === e && (e = !1), this._sourceMesh.isReady(e, !0) }, t.prototype.getVerticesData = function (e, t, i) { return this._sourceMesh.getVerticesData(e, t, i) }, t.prototype.setVerticesData = function (e, t, i, r) { return this.sourceMesh && this.sourceMesh.setVerticesData(e, t, i, r), this.sourceMesh }, t.prototype.updateVerticesData = function (e, t, i, r) { return this.sourceMesh && this.sourceMesh.updateVerticesData(e, t, i, r), this.sourceMesh }, t.prototype.setIndices = function (e, t) { return void 0 === t && (t = null), this.sourceMesh && this.sourceMesh.setIndices(e, t), this.sourceMesh }, t.prototype.isVerticesDataPresent = function (e) { return this._sourceMesh.isVerticesDataPresent(e) }, t.prototype.getIndices = function () { return this._sourceMesh.getIndices() }, Object.defineProperty(t.prototype, "_positions", { get: function () { return this._sourceMesh._positions }, enumerable: !1, configurable: !0 }), t.prototype.refreshBoundingInfo = function (e, t) { if (void 0 === e && (e = !1), void 0 === t && (t = !1), this.hasBoundingInfo && this.getBoundingInfo().isLocked) return this; var i = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null; return this._refreshBoundingInfo(this._sourceMesh._getPositionData(e, t), i), this }, t.prototype._preActivate = function () { return this._currentLOD && this._currentLOD._preActivate(), this }, t.prototype._activate = function (t, i) { if (e.prototype._activate.call(this, t, i), this._sourceMesh.subMeshes || $.Warn("Instances should only be created for meshes with geometry."), this._currentLOD) { if (this._currentLOD._getWorldMatrixDeterminant() >= 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 !== On.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; e < this._sourceMesh.subMeshes.length; e++)this._sourceMesh.subMeshes[e].clone(this, this._sourceMesh); return this }, t.prototype._generatePointsArray = function () { return this._sourceMesh._generatePointsArray() }, t.prototype._updateBoundingInfo = function () { return this.hasBoundingInfo ? this.getBoundingInfo().update(this.worldMatrixFromCache) : this.buildBoundingInfo(this.absolutePosition, this.absolutePosition, this.worldMatrixFromCache), this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache), this }, t.prototype.clone = function (e, t, i, r) { void 0 === t && (t = null); var n = (r || this._sourceMesh).createInstance(e); if (he.DeepCopy(this, n, ["name", "subMeshes", "uniqueId", "parent", "lightSources", "receiveShadows", "material", "visibility", "skeleton", "sourceMesh", "isAnInstance", "facetNb", "isFacetDataEnabled", "isBlocked", "useBones", "hasInstances", "collider", "edgesRenderer", "forward", "up", "right", "absolutePosition", "absoluteScaling", "absoluteRotationQuaternion", "isWorldMatrixFrozen", "nonUniformScaling", "behaviors", "worldMatrixFromCache", "hasThinInstances", "hasBoundingInfo"], []), this.refreshBoundingInfo(), t && (n.parent = t), !i) for (var o = 0; o < this.getScene().meshes.length; o++) { var a = this.getScene().meshes[o]; a.parent === this && a.clone(a.name, n) } return n.computeWorldMatrix(!0), this.onClonedObservable.notifyObservers(n), n }, t.prototype.dispose = function (t, i) { void 0 === i && (i = !1), this._sourceMesh.removeInstance(this), e.prototype.dispose.call(this, t, i) }, t.prototype._serializeAsParent = function (t) { e.prototype._serializeAsParent.call(this, t), t.parentId = this._sourceMesh.uniqueId, t.parentInstanceIndex = this._indexInSourceMeshInstanceArray }, 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, t && t.newSourcedMesh); r && i && i(this, r); for (var n = 0, o = this.getChildTransformNodes(!0); n < o.length; n++)o[n].instantiateHierarchy(r, t, i); return r }, t }(Ln); Jn.prototype.registerInstancedBuffer = function (e, t) { var i, r; if (null === (r = null === (i = this._userInstancedBuffersStorage) || void 0 === i ? void 0 : i.vertexBuffers[e]) || void 0 === r || r.dispose(), !this.instancedBuffers) { this.instancedBuffers = {}; for (var n = 0, o = this.instances; n < o.length; n++)o[n].instancedBuffers = {}; this._userInstancedBuffersStorage || (this._userInstancedBuffersStorage = { data: {}, vertexBuffers: {}, strides: {}, sizes: {}, vertexArrayObjects: this.getEngine().getCaps().vertexArrayObject ? {} : void 0 }) } this.instancedBuffers[e] = null, this._userInstancedBuffersStorage.strides[e] = t, this._userInstancedBuffersStorage.sizes[e] = 32 * t, this._userInstancedBuffersStorage.data[e] = new Float32Array(this._userInstancedBuffersStorage.sizes[e]), this._userInstancedBuffersStorage.vertexBuffers[e] = new Hi(this.getEngine(), this._userInstancedBuffersStorage.data[e], e, !0, !1, t, !0); for (var a = 0, s = this.instances; a < s.length; a++)s[a].instancedBuffers[e] = null; this._invalidateInstanceVertexArrayObject(), this._markSubMeshesAsAttributesDirty() }, Jn.prototype._processInstancedBuffers = function (e, t) { var i = e ? e.length : 0; for (var r in this.instancedBuffers) { for (var n = this._userInstancedBuffersStorage.sizes[r], o = this._userInstancedBuffersStorage.strides[r], a = (i + 1) * o; n < a;)n *= 2; this._userInstancedBuffersStorage.data[r].length != n && (this._userInstancedBuffersStorage.data[r] = new Float32Array(n), this._userInstancedBuffersStorage.sizes[r] = n, this._userInstancedBuffersStorage.vertexBuffers[r] && (this._userInstancedBuffersStorage.vertexBuffers[r].dispose(), this._userInstancedBuffersStorage.vertexBuffers[r] = null)); var s = this._userInstancedBuffersStorage.data[r], l = 0; t && ((u = this.instancedBuffers[r]).toArray ? u.toArray(s, l) : u.copyToArray ? u.copyToArray(s, l) : s[l] = u, l += o); for (var c = 0; c < i; c++) { var u; (u = e[c].instancedBuffers[r]).toArray ? u.toArray(s, l) : u.copyToArray ? u.copyToArray(s, l) : s[l] = u, l += o } this._userInstancedBuffersStorage.vertexBuffers[r] ? this._userInstancedBuffersStorage.vertexBuffers[r].updateDirectly(s, 0) : (this._userInstancedBuffersStorage.vertexBuffers[r] = new Hi(this.getEngine(), this._userInstancedBuffersStorage.data[r], r, !0, !1, o, !0), this._invalidateInstanceVertexArrayObject()) } }, Jn.prototype._invalidateInstanceVertexArrayObject = function () { if (this._userInstancedBuffersStorage && void 0 !== this._userInstancedBuffersStorage.vertexArrayObjects) { for (var e in this._userInstancedBuffersStorage.vertexArrayObjects) this.getEngine().releaseVertexArrayObject(this._userInstancedBuffersStorage.vertexArrayObjects[e]); this._userInstancedBuffersStorage.vertexArrayObjects = {} } }, Jn.prototype._disposeInstanceSpecificData = function () { for (this._instanceDataStorage.instancesBuffer && (this._instanceDataStorage.instancesBuffer.dispose(), this._instanceDataStorage.instancesBuffer = null); this.instances.length;)this.instances[0].dispose(); for (var e in this.instancedBuffers) this._userInstancedBuffersStorage.vertexBuffers[e] && this._userInstancedBuffersStorage.vertexBuffers[e].dispose(); this._invalidateInstanceVertexArrayObject(), this.instancedBuffers = {} }; var eo = function (e) { function t(i, r) { var n = e.call(this, i, r) || this; return n.diffuse = new B(1, 1, 1), n.specular = new B(1, 1, 1), n.falloffType = t.FALLOFF_DEFAULT, n.intensity = 1, n._range = Number.MAX_VALUE, n._inverseSquaredRange = 0, n._photometricScale = 1, n._intensityMode = t.INTENSITYMODE_AUTOMATIC, n._radius = 1e-5, n.renderPriority = 0, n._shadowEnabled = !0, n._excludeWithLayerMask = 0, n._includeOnlyWithLayerMask = 0, n._lightmapMode = 0, n._shadowGenerators = null, n._excludedMeshesIds = new Array, n._includedOnlyMeshesIds = new Array, n._isLight = !0, n.getScene().addLight(n), n._uniformBuffer = new zi(n.getScene().getEngine(), void 0, void 0, i), n._buildUniformLayout(), n.includedOnlyMeshes = new Array, n.excludedMeshes = new Array, n._resyncMeshes(), n } return W(t, e), Object.defineProperty(t.prototype, "range", { get: function () { return this._range }, set: function (e) { this._range = e, this._inverseSquaredRange = 1 / (this.range * this.range) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "intensityMode", { get: function () { return this._intensityMode }, set: function (e) { this._intensityMode = e, this._computePhotometricScale() }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "radius", { get: function () { return this._radius }, set: function (e) { this._radius = e, this._computePhotometricScale() }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "shadowEnabled", { get: function () { return this._shadowEnabled }, set: function (e) { this._shadowEnabled !== e && (this._shadowEnabled = e, this._markMeshesAsLightDirty()) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "includedOnlyMeshes", { get: function () { return this._includedOnlyMeshes }, set: function (e) { this._includedOnlyMeshes = e, this._hookArrayForIncludedOnly(e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "excludedMeshes", { get: function () { return this._excludedMeshes }, set: function (e) { this._excludedMeshes = e, this._hookArrayForExcluded(e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "excludeWithLayerMask", { get: function () { return this._excludeWithLayerMask }, set: function (e) { this._excludeWithLayerMask = e, this._resyncMeshes() }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "includeOnlyWithLayerMask", { get: function () { return this._includeOnlyWithLayerMask }, set: function (e) { this._includeOnlyWithLayerMask = e, this._resyncMeshes() }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "lightmapMode", { get: function () { return this._lightmapMode }, set: function (e) { this._lightmapMode !== e && (this._lightmapMode = e, this._markMeshesAsLightDirty()) }, enumerable: !1, configurable: !0 }), t.prototype.transferTexturesToEffect = function (e, t) { return this }, t.prototype._bindLight = function (e, t, i, r, n) { var o; void 0 === n && (n = !0); var a = e.toString(), s = !1; if (this._uniformBuffer.bindToEffect(i, "Light" + a), this._renderId !== t.getRenderId() || this._lastUseSpecular !== r || !this._uniformBuffer.useUbo) { this._renderId = t.getRenderId(), this._lastUseSpecular = r; var l = this.getScaledIntensity(); this.transferToEffect(i, a), this.diffuse.scaleToRef(l, V.Color3[0]), this._uniformBuffer.updateColor4("vLightDiffuse", V.Color3[0], this.range, a), r && (this.specular.scaleToRef(l, V.Color3[1]), this._uniformBuffer.updateColor4("vLightSpecular", V.Color3[1], this.radius, a)), s = !0 } if (this.transferTexturesToEffect(i, a), t.shadowsEnabled && this.shadowEnabled && n) { var c = null !== (o = this.getShadowGenerator(t.activeCamera)) && void 0 !== o ? o : this.getShadowGenerator(); c && (c.bindShadowLight(a, i), s = !0) } s ? this._uniformBuffer.update() : this._uniformBuffer.bindUniformBuffer() }, t.prototype.getClassName = function () { return "Light" }, t.prototype.toString = function (e) { var t = "Name: " + this.name; if (t += ", type: " + ["Point", "Directional", "Spot", "Hemispheric"][this.getTypeID()], this.animations) for (var i = 0; i < this.animations.length; i++)t += ", animation[0]: " + this.animations[i].toString(e); return t }, t.prototype._syncParentEnabledState = function () { e.prototype._syncParentEnabledState.call(this), this.isDisposed() || this._resyncMeshes() }, t.prototype.setEnabled = function (t) { e.prototype.setEnabled.call(this, t), this._resyncMeshes() }, t.prototype.getShadowGenerator = function (e) { var t; return void 0 === e && (e = null), null === this._shadowGenerators ? null : null !== (t = this._shadowGenerators.get(e)) && void 0 !== t ? t : null }, t.prototype.getShadowGenerators = function () { return this._shadowGenerators }, t.prototype.getAbsolutePosition = function () { return R.Zero() }, t.prototype.canAffectMesh = function (e) { return !(e && (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && -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; a < s.length; a++)s[a]._removeLightSource(this, !0); this._uniformBuffer.dispose(), this.getScene().removeLight(this), e.prototype.dispose.call(this, t, i) }, t.prototype.getTypeID = function () { return 0 }, t.prototype.getScaledIntensity = function () { return this._photometricScale * this.intensity }, t.prototype.clone = function (e, i) { void 0 === i && (i = null); var r = t.GetConstructorFromName(this.getTypeID(), e, this.getScene()); if (!r) return null; var n = Ue.Clone(r, this); return e && (n.name = e), i && (n.parent = i), n.setEnabled(this.isEnabled()), this.onClonedObservable.notifyObservers(n), n }, t.prototype.serialize = function () { var e = Ue.Serialize(this); return e.uniqueId = this.uniqueId, e.type = this.getTypeID(), this.parent && this.parent._serializeAsParent(e), this.excludedMeshes.length > 0 && (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) }))), Ue.AppendSerializedAnimations(this, e), e.ranges = this.serializeAnimationRanges(), e.isEnabled = this.isEnabled(), e }, t.GetConstructorFromName = function (e, t, i) { return ze.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 = Ue.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; o < e.animations.length; o++) { var a = e.animations[o], s = T("BABYLON.Animation"); s && n.animations.push(s.Parse(a)) } ze.ParseAnimationRanges(n, e, i) } return e.autoAnimate && i.beginAnimation(n, e.autoAnimateFrom, e.autoAnimateTo, e.autoAnimateLoop, e.autoAnimateSpeed || 1), void 0 !== e.isEnabled && n.setEnabled(e.isEnabled), n }, t.prototype._hookArrayForExcluded = function (e) { var t = this, i = e.push; e.push = function () { for (var r = [], n = 0; n < arguments.length; n++)r[n] = arguments[n]; for (var o = i.apply(e, r), a = 0, s = r; a < s.length; a++)s[a]._resyncLightSource(t); return o }; var r = e.splice; e.splice = function (i, n) { for (var o = r.apply(e, [i, n]), a = 0, s = o; a < s.length; a++)s[a]._resyncLightSource(t); return o }; for (var n = 0, o = e; n < o.length; n++)o[n]._resyncLightSource(this) }, t.prototype._hookArrayForIncludedOnly = function (e) { var t = this, i = e.push; e.push = function () { for (var r = [], n = 0; n < arguments.length; n++)r[n] = arguments[n]; var o = i.apply(e, r); return t._resyncMeshes(), o }; var r = e.splice; e.splice = function (i, n) { var o = r.apply(e, [i, n]); return t._resyncMeshes(), o }, this._resyncMeshes() }, t.prototype._resyncMeshes = function () { for (var e = 0, t = this.getScene().meshes; e < t.length; e++)t[e]._resyncLightSource(this) }, t.prototype._markMeshesAsLightDirty = function () { for (var e = 0, t = this.getScene().meshes; e < t.length; e++) { var i = t[e]; -1 !== i.lightSources.indexOf(this) && i._markSubMeshesAsLightDirty() } }, t.prototype._computePhotometricScale = function () { this._photometricScale = this._getPhotometricScale(), this.getScene().resetCachedMaterial() }, t.prototype._getPhotometricScale = function () { var e = 0, i = this.getTypeID(), r = this.intensityMode; switch (r === t.INTENSITYMODE_AUTOMATIC && (r = i === t.LIGHTTYPEID_DIRECTIONALLIGHT ? t.INTENSITYMODE_ILLUMINANCE : t.INTENSITYMODE_LUMINOUSINTENSITY), i) { case t.LIGHTTYPEID_POINTLIGHT: case t.LIGHTTYPEID_SPOTLIGHT: switch (r) { case t.INTENSITYMODE_LUMINOUSPOWER: e = 1 / (4 * Math.PI); break; case t.INTENSITYMODE_LUMINOUSINTENSITY: e = 1; break; case t.INTENSITYMODE_LUMINANCE: e = this.radius * this.radius }break; case t.LIGHTTYPEID_DIRECTIONALLIGHT: switch (r) { case t.INTENSITYMODE_ILLUMINANCE: e = 1; break; case t.INTENSITYMODE_LUMINANCE: var n = this.radius; n = Math.max(n, .001), e = 2 * Math.PI * (1 - Math.cos(n)) }break; case t.LIGHTTYPEID_HEMISPHERICLIGHT: e = 1 }return e }, t.prototype._reorderLightsInScene = function () { var e = this.getScene(); 0 != this._renderPriority && (e.requireLightSorting = !0), this.getScene().sortLightsByPriority() }, t.FALLOFF_DEFAULT = br.FALLOFF_DEFAULT, t.FALLOFF_PHYSICAL = br.FALLOFF_PHYSICAL, t.FALLOFF_GLTF = br.FALLOFF_GLTF, t.FALLOFF_STANDARD = br.FALLOFF_STANDARD, t.LIGHTMAP_DEFAULT = br.LIGHTMAP_DEFAULT, t.LIGHTMAP_SPECULAR = br.LIGHTMAP_SPECULAR, t.LIGHTMAP_SHADOWSONLY = br.LIGHTMAP_SHADOWSONLY, t.INTENSITYMODE_AUTOMATIC = br.INTENSITYMODE_AUTOMATIC, t.INTENSITYMODE_LUMINOUSPOWER = br.INTENSITYMODE_LUMINOUSPOWER, t.INTENSITYMODE_LUMINOUSINTENSITY = br.INTENSITYMODE_LUMINOUSINTENSITY, t.INTENSITYMODE_ILLUMINANCE = br.INTENSITYMODE_ILLUMINANCE, t.INTENSITYMODE_LUMINANCE = br.INTENSITYMODE_LUMINANCE, t.LIGHTTYPEID_POINTLIGHT = br.LIGHTTYPEID_POINTLIGHT, t.LIGHTTYPEID_DIRECTIONALLIGHT = br.LIGHTTYPEID_DIRECTIONALLIGHT, t.LIGHTTYPEID_SPOTLIGHT = br.LIGHTTYPEID_SPOTLIGHT, t.LIGHTTYPEID_HEMISPHERICLIGHT = br.LIGHTTYPEID_HEMISPHERICLIGHT, X([Re()], t.prototype, "diffuse", void 0), X([Re()], t.prototype, "specular", void 0), X([xe()], t.prototype, "falloffType", void 0), X([xe()], t.prototype, "intensity", void 0), X([xe()], t.prototype, "range", null), X([xe()], t.prototype, "intensityMode", null), X([xe()], t.prototype, "radius", null), X([xe()], t.prototype, "_renderPriority", void 0), X([Se("_reorderLightsInScene")], t.prototype, "renderPriority", void 0), X([xe("shadowEnabled")], t.prototype, "_shadowEnabled", void 0), X([xe("excludeWithLayerMask")], t.prototype, "_excludeWithLayerMask", void 0), X([xe("includeOnlyWithLayerMask")], t.prototype, "_includeOnlyWithLayerMask", void 0), X([xe("lightmapMode")], t.prototype, "_lightmapMode", void 0), t }(ze), to = function (e) { function t() { return null !== e && e.apply(this, arguments) || this } return W(t, e), t }(o), io = function () { function e() { this.rootNodes = [], this.skeletons = [], this.animationGroups = [] } return e.prototype.dispose = function () { this.rootNodes.slice(0).forEach((function (e) { e.dispose() })), this.rootNodes.length = 0, this.skeletons.slice(0).forEach((function (e) { e.dispose() })), this.skeletons.length = 0, this.animationGroups.slice(0).forEach((function (e) { e.dispose() })), this.animationGroups.length = 0 }, e }(), ro = function (e) { function t(t) { var i = e.call(this) || this; return i._wasAddedToScene = !1, (t = t || S.LastCreatedScene) ? (i.scene = t, i.sounds = [], i.effectLayers = [], i.layers = [], i.lensFlareSystems = [], i.proceduralTextures = [], i.reflectionProbes = [], t.onDisposeObservable.add((function () { i._wasAddedToScene || i.dispose() })), i._onContextRestoredObserver = t.getEngine().onContextRestoredObservable.add((function () { for (var e = 0, t = i.geometries; e < t.length; e++)t[e]._rebuild(); for (var r = 0, n = i.meshes; r < n.length; r++)n[r]._rebuild(); for (var o = 0, a = i.particleSystems; o < a.length; o++)a[o].rebuild(); for (var s = 0, l = i.textures; s < l.length; s++)l[s]._rebuild() })), i) : i } return W(t, e), t.prototype._topologicalSort = function (e) { for (var t = new Map, i = 0, r = e; i < r.length; i++) { var n = r[i]; t.set(n.uniqueId, n) } for (var o = { dependsOn: new Map, dependedBy: new Map }, a = 0, s = e; a < s.length; a++) { var l = (n = s[a]).uniqueId; o.dependsOn.set(l, new Set), o.dependedBy.set(l, new Set) } for (var c = 0, u = e; c < u.length; c++) { l = (n = u[c]).uniqueId; var h = o.dependsOn.get(l); if (n instanceof $n) { var d = n.sourceMesh; t.has(d.uniqueId) && (h.add(d.uniqueId), o.dependedBy.get(d.uniqueId).add(l)) } for (var p = o.dependedBy.get(l), f = 0, _ = n.getDescendants(); f < _.length; f++) { var m = _[f].uniqueId; t.has(m) && (p.add(m), o.dependsOn.get(m).add(l)) } } for (var g = [], v = [], y = 0, b = e; y < b.length; y++)l = (n = b[y]).uniqueId, 0 === o.dependsOn.get(l).size && (v.push(n), t.delete(l)); for (var T = v; T.length > 0;) { var E = T.shift(); g.push(E); for (var S = o.dependedBy.get(E.uniqueId), x = 0, A = Array.from(S.values()); x < A.length; x++) { var R = A[x], C = o.dependsOn.get(R); C.delete(E.uniqueId), 0 === C.size && t.get(R) && (T.push(t.get(R)), t.delete(R)) } } return t.size > 0 && (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 < o.length; n++) { var a = o[n]; this._addNodeAndDescendantsToList(e, t, a, r) } } }, t.prototype._isNodeInContainer = function (e) { return e instanceof Jn && -1 !== this.meshes.indexOf(e) || e instanceof On && -1 !== this.transformNodes.indexOf(e) || e instanceof eo && -1 !== this.lights.indexOf(e) || e instanceof ln && -1 !== this.cameras.indexOf(e) }, t.prototype._isValidHierarchy = function () { for (var e = 0, t = this.meshes; e < t.length; e++)if ((l = t[e]).parent && !this._isNodeInContainer(l.parent)) return $.Warn("Node ".concat(l.name, " has a parent that is not in the container.")), !1; for (var i = 0, r = this.transformNodes; i < r.length; i++)if ((l = r[i]).parent && !this._isNodeInContainer(l.parent)) return $.Warn("Node ".concat(l.name, " has a parent that is not in the container.")), !1; for (var n = 0, o = this.lights; n < o.length; n++)if ((l = o[n]).parent && !this._isNodeInContainer(l.parent)) return $.Warn("Node ".concat(l.name, " has a parent that is not in the container.")), !1; for (var a = 0, s = this.cameras; a < s.length; a++) { var l; if ((l = s[a]).parent && !this._isNodeInContainer(l.parent)) return $.Warn("Node ".concat(l.name, " has a parent that is not in the container.")), !1 } return !0 }, t.prototype.instantiateModelsToScene = function (e, t, i) { var r = this; void 0 === t && (t = !1), this._isValidHierarchy() || xi.Warn("SceneSerializer.InstantiateModelsToScene: The Asset Container hierarchy is not valid."); for (var n = {}, o = {}, a = new io, s = [], l = [], c = H({ doNotInstantiate: !0 }, i), u = [], h = new Set, d = 0, p = this.transformNodes; d < p.length; d++) { var f = p[d]; null === f.parent && this._addNodeAndDescendantsToList(u, h, f, c.predicate) } for (var _ = 0, m = this.meshes; _ < m.length; _++) { var g = m[_]; null === g.parent && this._addNodeAndDescendantsToList(u, h, g, c.predicate) } var v = this._topologicalSort(u), y = function (i, s) { if (function (t, i) { if (n[t.uniqueId] = i.uniqueId, o[i.uniqueId] = i, e && (i.name = e(t.name)), i instanceof Jn) { var r = i; if (r.morphTargetManager) { var a = t.morphTargetManager; r.morphTargetManager = a.clone(); for (var s = 0; s < a.numTargets; s++) { var l = a.getTarget(s), c = r.morphTargetManager.getTarget(s); n[l.uniqueId] = c.uniqueId, o[c.uniqueId] = c } } } }(i, s), i.parent) { var c = n[i.parent.uniqueId], u = o[c]; s.parent = u || i.parent } if (s.position && i.position && s.position.copyFrom(i.position), s.rotationQuaternion && i.rotationQuaternion && s.rotationQuaternion.copyFrom(i.rotationQuaternion), s.rotation && i.rotation && s.rotation.copyFrom(i.rotation), s.scaling && i.scaling && s.scaling.copyFrom(i.scaling), s.material) { var h = s; if (h.material) if (t) { var d = i.material; if (-1 === l.indexOf(d)) { var p = d.clone(e ? e(d.name) : "Clone of " + d.name); if (l.push(d), n[d.uniqueId] = p.uniqueId, o[p.uniqueId] = p, "MultiMaterial" === d.getClassName()) { for (var f = d, _ = 0, m = f.subMaterials; _ < m.length; _++) { var g = m[_]; g && (p = g.clone(e ? e(g.name) : "Clone of " + g.name), l.push(g), n[g.uniqueId] = p.uniqueId, o[p.uniqueId] = p) } f.subMaterials = f.subMaterials.map((function (e) { return e && o[n[e.uniqueId]] })) } } "InstancedMesh" !== h.getClassName() && (h.material = o[n[d.uniqueId]]) } else "MultiMaterial" === h.material.getClassName() ? -1 === r.scene.multiMaterials.indexOf(h.material) && r.scene.addMultiMaterial(h.material) : -1 === r.scene.materials.indexOf(h.material) && r.scene.addMaterial(h.material) } null === s.parent && a.rootNodes.push(s) }; return v.forEach((function (e) { if ("InstancedMesh" === e.getClassName()) { var t = e, i = t.sourceMesh, r = n[i.uniqueId], a = ("number" == typeof r ? o[r] : i).createInstance(t.name); y(t, a) } else { var s = !0; "TransformNode" === e.getClassName() || "Node" === e.getClassName() || e.skeleton || !e.getTotalVertices || 0 === e.getTotalVertices() ? s = !1 : c.doNotInstantiate && (s = "function" == typeof c.doNotInstantiate ? !c.doNotInstantiate(e) : !c.doNotInstantiate); var l = s ? e.createInstance("instance of ".concat(e.name)) : e.clone("Clone of ".concat(e.name), null, !0); if (!l) throw new Error("Could not clone or instantiate node on Asset Container ".concat(e.name)); y(e, l) } })), this.skeletons.forEach((function (t) { if (!c.predicate || c.predicate(t)) { for (var i = t.clone(e ? e(t.name) : "Clone of " + t.name), l = 0, u = r.meshes; l < u.length; l++) { var h = u[l]; if (h.skeleton === t && !h.isAnInstance) { var d = o[n[h.uniqueId]]; if (!d || d.isAnInstance) continue; if (d.skeleton = i, -1 !== s.indexOf(i)) continue; s.push(i); for (var p = 0, f = i.bones; p < f.length; p++) { var _ = f[p]; _._linkedTransformNode && (_._linkedTransformNode = o[n[_._linkedTransformNode.uniqueId]]) } } } a.skeletons.push(i) } })), this.animationGroups.forEach((function (t) { if (!c.predicate || c.predicate(t)) { var i = t.clone(e ? e(t.name) : "Clone of " + t.name, (function (e) { return o[n[e.uniqueId]] || e })); a.animationGroups.push(i) } })), a }, t.prototype.addAllToScene = function () { if (!this._wasAddedToScene) { this._isValidHierarchy() || xi.Warn("SceneSerializer.addAllToScene: The Asset Container hierarchy is not valid."), this._wasAddedToScene = !0, this.addToScene(null), this.environmentTexture && (this.scene.environmentTexture = this.environmentTexture); for (var e = 0, t = this.scene._serializableComponents; e < t.length; e++)t[e].addFromContainer(this); this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver), this._onContextRestoredObserver = null } }, t.prototype.addToScene = function (e) { var t = this; void 0 === e && (e = null); var i = []; this.cameras.forEach((function (r) { e && !e(r) || (t.scene.addCamera(r), i.push(r)) })), this.lights.forEach((function (r) { e && !e(r) || (t.scene.addLight(r), i.push(r)) })), this.meshes.forEach((function (r) { e && !e(r) || (t.scene.addMesh(r), i.push(r)) })), this.skeletons.forEach((function (i) { e && !e(i) || t.scene.addSkeleton(i) })), this.animations.forEach((function (i) { e && !e(i) || t.scene.addAnimation(i) })), this.animationGroups.forEach((function (i) { e && !e(i) || t.scene.addAnimationGroup(i) })), this.multiMaterials.forEach((function (i) { e && !e(i) || t.scene.addMultiMaterial(i) })), this.materials.forEach((function (i) { e && !e(i) || t.scene.addMaterial(i) })), this.morphTargetManagers.forEach((function (i) { e && !e(i) || t.scene.addMorphTargetManager(i) })), this.geometries.forEach((function (i) { e && !e(i) || t.scene.addGeometry(i) })), this.transformNodes.forEach((function (r) { e && !e(r) || (t.scene.addTransformNode(r), i.push(r)) })), this.actionManagers.forEach((function (i) { e && !e(i) || t.scene.addActionManager(i) })), this.textures.forEach((function (i) { e && !e(i) || t.scene.addTexture(i) })), this.reflectionProbes.forEach((function (i) { e && !e(i) || t.scene.addReflectionProbe(i) })); for (var r = 0, n = i; r < n.length; r++) { var o = n[r]; o.parent && -1 === this.scene.getNodes().indexOf(o.parent) && (o.setParent ? o.setParent(null) : o.parent = null) } }, t.prototype.removeAllFromScene = function () { this._isValidHierarchy() || xi.Warn("SceneSerializer.removeAllFromScene: The Asset Container hierarchy is not valid."), this._wasAddedToScene = !1, this.removeFromScene(null), this.environmentTexture === this.scene.environmentTexture && (this.scene.environmentTexture = null); for (var e = 0, t = this.scene._serializableComponents; e < t.length; e++)t[e].removeFromContainer(this) }, t.prototype.removeFromScene = function (e) { var t = this; void 0 === e && (e = null), this.cameras.forEach((function (i) { e && !e(i) || t.scene.removeCamera(i) })), this.lights.forEach((function (i) { e && !e(i) || t.scene.removeLight(i) })), this.meshes.forEach((function (i) { e && !e(i) || t.scene.removeMesh(i) })), this.skeletons.forEach((function (i) { e && !e(i) || t.scene.removeSkeleton(i) })), this.animations.forEach((function (i) { e && !e(i) || t.scene.removeAnimation(i) })), this.animationGroups.forEach((function (i) { e && !e(i) || t.scene.removeAnimationGroup(i) })), this.multiMaterials.forEach((function (i) { e && !e(i) || t.scene.removeMultiMaterial(i) })), this.materials.forEach((function (i) { e && !e(i) || t.scene.removeMaterial(i) })), this.morphTargetManagers.forEach((function (i) { e && !e(i) || t.scene.removeMorphTargetManager(i) })), this.geometries.forEach((function (i) { e && !e(i) || t.scene.removeGeometry(i) })), this.transformNodes.forEach((function (i) { e && !e(i) || t.scene.removeTransformNode(i) })), this.actionManagers.forEach((function (i) { e && !e(i) || t.scene.removeActionManager(i) })), this.textures.forEach((function (i) { e && !e(i) || t.scene.removeTexture(i) })), this.reflectionProbes.forEach((function (i) { e && !e(i) || t.scene.removeReflectionProbe(i) })) }, t.prototype.dispose = function () { this.cameras.slice(0).forEach((function (e) { e.dispose() })), this.cameras.length = 0, this.lights.slice(0).forEach((function (e) { e.dispose() })), this.lights.length = 0, this.meshes.slice(0).forEach((function (e) { e.dispose() })), this.meshes.length = 0, this.skeletons.slice(0).forEach((function (e) { e.dispose() })), this.skeletons.length = 0, this.animationGroups.slice(0).forEach((function (e) { e.dispose() })), this.animationGroups.length = 0, this.multiMaterials.slice(0).forEach((function (e) { e.dispose() })), this.multiMaterials.length = 0, this.materials.slice(0).forEach((function (e) { e.dispose() })), this.materials.length = 0, this.geometries.slice(0).forEach((function (e) { e.dispose() })), this.geometries.length = 0, this.transformNodes.slice(0).forEach((function (e) { e.dispose() })), this.transformNodes.length = 0, this.actionManagers.slice(0).forEach((function (e) { e.dispose() })), this.actionManagers.length = 0, this.textures.slice(0).forEach((function (e) { e.dispose() })), this.textures.length = 0, this.reflectionProbes.slice(0).forEach((function (e) { e.dispose() })), this.reflectionProbes.length = 0, this.morphTargetManagers.slice(0).forEach((function (e) { e.dispose() })), this.morphTargetManagers.length = 0, this.environmentTexture && (this.environmentTexture.dispose(), this.environmentTexture = null); for (var e = 0, t = this.scene._serializableComponents; e < t.length; e++)t[e].removeFromContainer(this, !0); this._onContextRestoredObserver && (this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver), this._onContextRestoredObserver = null) }, t.prototype._moveAssets = function (e, t, i) { if (e && t) for (var r = 0, n = e; r < n.length; r++) { var o = n[r], a = !0; if (i) for (var s = 0, l = i; s < l.length; s++)if (o === l[s]) { a = !1; break } a && (t.push(o), o._parentContainer = this) } }, t.prototype.moveAllFromScene = function (e) { for (var t in this._wasAddedToScene = !1, void 0 === e && (e = new to), this) Object.prototype.hasOwnProperty.call(this, t) && (this[t] = this[t] || ("_environmentTexture" === t ? null : []), this._moveAssets(this.scene[t], this[t], e[t])); this.environmentTexture = this.scene.environmentTexture, this.removeAllFromScene() }, t.prototype.createRootMesh = function () { var e = new Jn("assetContainerRootMesh", this.scene); return this.meshes.forEach((function (t) { t.parent || e.addChild(t) })), this.meshes.unshift(e), e }, t.prototype.mergeAnimationsTo = function (e, t, i) { if (void 0 === e && (e = S.LastCreatedScene), void 0 === i && (i = null), !e) return $.Error("No scene available to merge animations to"), []; var r = i || function (t) { var i = null, r = t.animations.length ? t.animations[0].targetProperty : "", n = t.name.split(".").join("").split("_primitive")[0]; switch (r) { case "position": case "rotationQuaternion": i = e.getTransformNodeByName(t.name) || e.getTransformNodeByName(n); break; case "influence": i = e.getMorphTargetByName(t.name) || e.getMorphTargetByName(n); break; default: i = e.getNodeByName(t.name) || e.getNodeByName(n) }return i }; this.getNodes().forEach((function (e) { var t = r(e); if (null !== t) { for (var i = function (e) { for (var i = 0, r = t.animations.filter((function (t) { return t.targetProperty === e.targetProperty })); i < r.length; i++) { var n = r[i], o = t.animations.indexOf(n, 0); o > -1 && t.animations.splice(o, 1) } }, n = 0, o = e.animations; n < o.length; n++)i(o[n]); t.animations = t.animations.concat(e.animations) } })); var n = new Array; return this.animationGroups.slice().forEach((function (e) { n.push(e.clone(e.name, r)), e.animatables.forEach((function (e) { e.stop() })) })), t.forEach((function (t) { var i = r(t.target); i && (e.beginAnimation(i, t.fromFrame, t.toFrame, t.loopAnimation, t.speedRatio, t.onAnimationEnd ? t.onAnimationEnd : void 0, void 0, !0, void 0, t.onAnimationLoop ? t.onAnimationLoop : void 0), e.stopAnimation(t.target)) })), n }, t.prototype.populateRootNodes = function () { var e = this; this.rootNodes.length = 0, this.meshes.forEach((function (t) { t.parent || -1 !== e.rootNodes.indexOf(t) || e.rootNodes.push(t) })), this.transformNodes.forEach((function (t) { t.parent || -1 !== e.rootNodes.indexOf(t) || e.rootNodes.push(t) })), this.lights.forEach((function (t) { t.parent || -1 !== e.rootNodes.indexOf(t) || e.rootNodes.push(t) })), this.cameras.forEach((function (t) { t.parent || -1 !== e.rootNodes.indexOf(t) || e.rootNodes.push(t) })) }, t }(o), no = function () { function e(e) { this.SMOOTHING = .75, this.FFT_SIZE = 512, this.BARGRAPHAMPLITUDE = 256, this.DEBUGCANVASPOS = { x: 20, y: 20 }, this.DEBUGCANVASSIZE = { width: 320, height: 200 }, (e = e || S.LastCreatedScene) && (this._scene = e, In.audioEngine ? (this._audioEngine = In.audioEngine, this._audioEngine.canUseWebAudio && this._audioEngine.audioContext && (this._webAudioAnalyser = this._audioEngine.audioContext.createAnalyser(), this._webAudioAnalyser.minDecibels = -140, this._webAudioAnalyser.maxDecibels = 0, this._byteFreqs = new Uint8Array(this._webAudioAnalyser.frequencyBinCount), this._byteTime = new Uint8Array(this._webAudioAnalyser.frequencyBinCount), this._floatFreqs = new Float32Array(this._webAudioAnalyser.frequencyBinCount))) : xi.Warn("No audio engine initialized, failed to create an audio analyser")) } return e.prototype.getFrequencyBinCount = function () { return this._audioEngine.canUseWebAudio ? this._webAudioAnalyser.frequencyBinCount : 0 }, e.prototype.getByteFrequencyData = function () { return this._audioEngine.canUseWebAudio && (this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING, this._webAudioAnalyser.fftSize = this.FFT_SIZE, this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs)), this._byteFreqs }, e.prototype.getByteTimeDomainData = function () { return this._audioEngine.canUseWebAudio && (this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING, this._webAudioAnalyser.fftSize = this.FFT_SIZE, this._webAudioAnalyser.getByteTimeDomainData(this._byteTime)), this._byteTime }, e.prototype.getFloatFrequencyData = function () { return this._audioEngine.canUseWebAudio && (this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING, this._webAudioAnalyser.fftSize = this.FFT_SIZE, this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs)), this._floatFreqs }, e.prototype.drawDebugCanvas = function () { var e = this; if (this._audioEngine.canUseWebAudio && (this._debugCanvas || (this._debugCanvas = document.createElement("canvas"), this._debugCanvas.width = this.DEBUGCANVASSIZE.width, this._debugCanvas.height = this.DEBUGCANVASSIZE.height, this._debugCanvas.style.position = "absolute", this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + "px", this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + "px", this._debugCanvasContext = this._debugCanvas.getContext("2d"), document.body.appendChild(this._debugCanvas), this._registerFunc = function () { e.drawDebugCanvas() }, this._scene.registerBeforeRender(this._registerFunc)), this._registerFunc && this._debugCanvasContext)) { var t = this.getByteFrequencyData(); this._debugCanvasContext.fillStyle = "rgb(0, 0, 0)", this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height); for (var i = 0; i < this.getFrequencyBinCount(); i++) { var r = t[i] / this.BARGRAPHAMPLITUDE, n = this.DEBUGCANVASSIZE.height * r, o = this.DEBUGCANVASSIZE.height - n - 1, a = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount(), s = i / this.getFrequencyBinCount() * 360; this._debugCanvasContext.fillStyle = "hsl(" + s + ", 100%, 50%)", this._debugCanvasContext.fillRect(i * a, o, a, n) } } }, e.prototype.stopDebugCanvas = function () { this._debugCanvas && (this._registerFunc && (this._scene.unregisterBeforeRender(this._registerFunc), this._registerFunc = null), document.body.removeChild(this._debugCanvas), this._debugCanvas = null, this._debugCanvasContext = null) }, e.prototype.connectAudioNodes = function (e, t) { this._audioEngine.canUseWebAudio && (e.connect(this._webAudioAnalyser), this._webAudioAnalyser.connect(t)) }, e.prototype.dispose = function () { this._audioEngine.canUseWebAudio && this._webAudioAnalyser.disconnect() }, e }(); In.AudioEngineFactory = function (e, t, i) { return new oo(e, t, i) }; var oo = function () { function e(e, t, i) { void 0 === e && (e = null), void 0 === t && (t = null), void 0 === i && (i = null); var r = this; if (this._audioContext = null, this._audioContextInitialized = !1, this._muteButton = null, this._audioDestination = null, this.canUseWebAudio = !1, this.WarnedWebAudioUnsupported = !1, this.isMP3supported = !1, this.isOGGsupported = !1, this.unlocked = !0, this.useCustomUnlockedButton = !1, this.onAudioUnlockedObservable = new u, this.onAudioLockedObservable = new u, this._tryToRun = !1, this._onResize = function () { r._moveButtonToTopLeft() }, et()) { void 0 !== window.AudioContext && (this.canUseWebAudio = !0); var n = document.createElement("audio"); this._hostElement = e, this._audioContext = t, this._audioDestination = i; try { n && n.canPlayType && (n.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, "") || n.canPlayType("audio/mp3").replace(/^no$/, "")) && (this.isMP3supported = !0) } catch (e) { } try { n && n.canPlayType && n.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, "") && (this.isOGGsupported = !0) } catch (e) { } } } return Object.defineProperty(e.prototype, "audioContext", { get: function () { return this._audioContextInitialized ? this.unlocked || this._muteButton || this._displayMuteButton() : this._initializeAudioContext(), this._audioContext }, enumerable: !1, configurable: !0 }), e.prototype.lock = function () { this._triggerSuspendedState() }, e.prototype.unlock = function () { this._triggerRunningState() }, e.prototype._resumeAudioContext = function () { var e; return void 0 !== this._audioContext.resume && (e = this._audioContext.resume()), e || Promise.resolve() }, e.prototype._initializeAudioContext = function () { try { this.canUseWebAudio && (this._audioContext || (this._audioContext = new AudioContext), this.masterGain = this._audioContext.createGain(), this.masterGain.gain.value = 1, this._audioDestination || (this._audioDestination = this._audioContext.destination), this.masterGain.connect(this._audioDestination), this._audioContextInitialized = !0, "running" === this._audioContext.state && this._triggerRunningState()) } catch (e) { this.canUseWebAudio = !1, $.Error("Web Audio: " + e.message) } }, e.prototype._triggerRunningState = function () { var e = this; this._tryToRun || (this._tryToRun = !0, this._resumeAudioContext().then((function () { e._tryToRun = !1, e._muteButton && e._hideMuteButton(), e.unlocked = !0, e.onAudioUnlockedObservable.notifyObservers(e) })).catch((function () { e._tryToRun = !1, e.unlocked = !1 }))) }, e.prototype._triggerSuspendedState = function () { this.unlocked = !1, this.onAudioLockedObservable.notifyObservers(this), this._displayMuteButton() }, e.prototype._displayMuteButton = function () { var e = this; if (!this.useCustomUnlockedButton && !this._muteButton) { this._muteButton = document.createElement("BUTTON"), this._muteButton.className = "babylonUnmuteIcon", this._muteButton.id = "babylonUnmuteIconBtn", this._muteButton.title = "Unmute"; var t = ".babylonUnmuteIcon { position: absolute; left: 20px; top: 20px; height: 40px; width: 60px; background-color: rgba(51,51,51,0.7); background-image: url(" + (window.SVGSVGElement ? "data:image/svg+xml;charset=UTF-8,%3Csvg%20version%3D%221.1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2239%22%20height%3D%2232%22%20viewBox%3D%220%200%2039%2032%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22M9.625%2018.938l-0.031%200.016h-4.953q-0.016%200-0.031-0.016v-12.453q0-0.016%200.031-0.016h4.953q0.031%200%200.031%200.016v12.453zM12.125%207.688l8.719-8.703v27.453l-8.719-8.719-0.016-0.047v-9.938zM23.359%207.875l1.406-1.406%204.219%204.203%204.203-4.203%201.422%201.406-4.219%204.219%204.219%204.203-1.484%201.359-4.141-4.156-4.219%204.219-1.406-1.422%204.219-4.203z%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E" : "https://cdn.babylonjs.com/Assets/audio.png") + "); background-size: 80%; background-repeat:no-repeat; background-position: center; background-position-y: 4px; border: none; outline: none; transition: transform 0.125s ease-out; cursor: pointer; z-index: 9999; } .babylonUnmuteIcon:hover { transform: scale(1.05) } .babylonUnmuteIcon:active { background-color: rgba(51,51,51,1) }", i = document.createElement("style"); i.appendChild(document.createTextNode(t)), document.getElementsByTagName("head")[0].appendChild(i), document.body.appendChild(this._muteButton), this._moveButtonToTopLeft(), this._muteButton.addEventListener("touchend", (function () { e._triggerRunningState() }), !0), this._muteButton.addEventListener("click", (function () { e._triggerRunningState() }), !0), window.addEventListener("resize", this._onResize) } }, e.prototype._moveButtonToTopLeft = function () { this._hostElement && this._muteButton && (this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px", this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px") }, e.prototype._hideMuteButton = function () { this._muteButton && (document.body.removeChild(this._muteButton), this._muteButton = null) }, e.prototype.dispose = function () { this.canUseWebAudio && this._audioContextInitialized && (this._connectedAnalyser && this._audioContext && (this._connectedAnalyser.stopDebugCanvas(), this._connectedAnalyser.dispose(), this.masterGain.disconnect(), this.masterGain.connect(this._audioContext.destination), this._connectedAnalyser = null), this.masterGain.gain.value = 1), this.WarnedWebAudioUnsupported = !1, this._hideMuteButton(), window.removeEventListener("resize", this._onResize), this.onAudioUnlockedObservable.clear(), this.onAudioLockedObservable.clear() }, e.prototype.getGlobalVolume = function () { return this.canUseWebAudio && this._audioContextInitialized ? this.masterGain.gain.value : -1 }, e.prototype.setGlobalVolume = function (e) { this.canUseWebAudio && this._audioContextInitialized && (this.masterGain.gain.value = e) }, e.prototype.connectToAnalyser = function (e) { this._connectedAnalyser && this._connectedAnalyser.stopDebugCanvas(), this.canUseWebAudio && this._audioContextInitialized && this._audioContext && (this._connectedAnalyser = e, this.masterGain.disconnect(), this._connectedAnalyser.connectAudioNodes(this.masterGain, this._audioContext.destination)) }, e }(), ao = function () { function e(t, i, r, n, o) { void 0 === n && (n = null); var a, s, l, c, h, d = this; if (this.autoplay = !1, this._loop = !1, this.useCustomAttenuation = !1, this.isPlaying = !1, this.isPaused = !1, this.refDistance = 1, this.rolloffFactor = 1, this.maxDistance = 100, this.distanceModel = "linear", this.metadata = null, this.onEndedObservable = new u, this._spatialSound = !1, this._panningModel = "equalpower", this._playbackRate = 1, this._streaming = !1, this._startTime = 0, this._currentTime = 0, this._position = R.Zero(), this._localDirection = new R(1, 0, 0), this._volume = 1, this._isReadyToPlay = !1, this._isDirectional = !1, this._coneInnerAngle = 360, this._coneOuterAngle = 360, this._coneOuterGain = 0, this._isOutputConnected = !1, this._urlType = "Unknown", this.name = t, r = r || S.LastCreatedScene) if (this._scene = r, e._SceneComponentInitialization(r), this._readyToPlayCallback = n, this._customAttenuationFunction = function (e, t, i, r, n) { return t < i ? e * (1 - t / i) : 0 }, o && (this.autoplay = o.autoplay || !1, this._loop = o.loop || !1, void 0 !== o.volume && (this._volume = o.volume), this._spatialSound = null !== (a = o.spatialSound) && void 0 !== a && a, this.maxDistance = null !== (s = o.maxDistance) && void 0 !== s ? s : 100, this.useCustomAttenuation = null !== (l = o.useCustomAttenuation) && void 0 !== l && l, this.rolloffFactor = o.rolloffFactor || 1, this.refDistance = o.refDistance || 1, this.distanceModel = o.distanceModel || "linear", this._playbackRate = o.playbackRate || 1, this._streaming = null !== (c = o.streaming) && void 0 !== c && c, this._length = o.length, this._offset = o.offset), (null === (h = In.audioEngine) || void 0 === h ? void 0 : h.canUseWebAudio) && In.audioEngine.audioContext) { this._soundGain = In.audioEngine.audioContext.createGain(), this._soundGain.gain.value = this._volume, this._inputAudioNode = this._soundGain, this._outputAudioNode = this._soundGain, this._spatialSound && this._createSpatialParameters(), this._scene.mainSoundTrack.addSound(this); var p = !0; if (i) try { "string" == typeof i ? this._urlType = "String" : i instanceof ArrayBuffer ? this._urlType = "ArrayBuffer" : i instanceof HTMLMediaElement ? this._urlType = "MediaElement" : i instanceof MediaStream ? this._urlType = "MediaStream" : i instanceof AudioBuffer ? this._urlType = "AudioBuffer" : Array.isArray(i) && (this._urlType = "Array"); var f = [], _ = !1; switch (this._urlType) { case "MediaElement": this._streaming = !0, this._isReadyToPlay = !0, this._streamingSource = In.audioEngine.audioContext.createMediaElementSource(i), this.autoplay && this.play(0, this._offset, this._length), this._readyToPlayCallback && this._readyToPlayCallback(); break; case "MediaStream": this._streaming = !0, this._isReadyToPlay = !0, this._streamingSource = In.audioEngine.audioContext.createMediaStreamSource(i), this.autoplay && this.play(0, this._offset, this._length), this._readyToPlayCallback && this._readyToPlayCallback(); break; case "ArrayBuffer": i.byteLength > 0 && (_ = !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) && In.audioEngine.isMP3supported || -1 !== t.indexOf(".ogg", t.length - 4) && In.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, xi.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; v < f.length && "break" !== m(v); v++); break; default: p = !1 }p ? _ || (this._isReadyToPlay = !0, this._readyToPlayCallback && setTimeout((function () { d._readyToPlayCallback && d._readyToPlayCallback() }), 1e3)) : $.Error("Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.") } catch (e) { $.Error("Unexpected error. Sound creation aborted."), this._scene.mainSoundTrack.removeSound(this) } } else this._scene.mainSoundTrack.addSound(this), In.audioEngine && !In.audioEngine.WarnedWebAudioUnsupported && ($.Error("Web Audio is not supported by your browser."), In.audioEngine.WarnedWebAudioUnsupported = !0), this._readyToPlayCallback && setTimeout((function () { d._readyToPlayCallback && d._readyToPlayCallback() }), 1e3) } return Object.defineProperty(e.prototype, "loop", { get: function () { return this._loop }, set: function (e) { e !== this._loop && (this._loop = e, this.updateOptions({ loop: e })) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "currentTime", { get: function () { var e; if (this._htmlAudioElement) return this._htmlAudioElement.currentTime; if ((null === (e = In.audioEngine) || void 0 === e ? void 0 : e.audioContext) && (this.isPlaying || this.isPaused)) { var t = this.isPaused ? 0 : In.audioEngine.audioContext.currentTime - this._startTime; return this._currentTime + t } return 0 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "spatialSound", { get: function () { return this._spatialSound }, set: function (e) { if (e != this._spatialSound) { var t = this.isPlaying; this.pause(), e ? (this._spatialSound = e, this._updateSpatialParameters()) : this._disableSpatialSound(), t && this.play() } }, enumerable: !1, configurable: !0 }), e.prototype.dispose = function () { var e; (null === (e = In.audioEngine) || void 0 === e ? void 0 : e.canUseWebAudio) && (this.isPlaying && this.stop(), this._isReadyToPlay = !1, -1 === this.soundTrackId ? this._scene.mainSoundTrack.removeSound(this) : this._scene.soundTracks && this._scene.soundTracks[this.soundTrackId].removeSound(this), this._soundGain && (this._soundGain.disconnect(), this._soundGain = null), this._soundPanner && (this._soundPanner.disconnect(), this._soundPanner = null), this._soundSource && (this._soundSource.disconnect(), this._soundSource = null), this._audioBuffer = null, this._htmlAudioElement && (this._htmlAudioElement.pause(), this._htmlAudioElement.src = "", document.body.removeChild(this._htmlAudioElement)), this._streamingSource && this._streamingSource.disconnect(), this._connectedTransformNode && this._registerFunc && (this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc), this._connectedTransformNode = null), this._clearTimeoutsAndObservers()) }, e.prototype.isReady = function () { return this._isReadyToPlay }, e.prototype.getClassName = function () { return "Sound" }, e.prototype._audioBufferLoaded = function (e) { var t; (null === (t = In.audioEngine) || void 0 === t ? void 0 : t.audioContext) && (this._audioBuffer = e, this._isReadyToPlay = !0, this.autoplay && this.play(0, this._offset, this._length), this._readyToPlayCallback && this._readyToPlayCallback()) }, e.prototype._soundLoaded = function (e) { var t, i = this; (null === (t = In.audioEngine) || void 0 === t ? void 0 : t.audioContext) && In.audioEngine.audioContext.decodeAudioData(e, (function (e) { i._audioBufferLoaded(e) }), (function (e) { $.Error("Error while decoding audio data for: " + i.name + " / Error: " + e) })) }, e.prototype.setAudioBuffer = function (e) { var t; (null === (t = In.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && (this._audioBuffer = e, this._isReadyToPlay = !0) }, e.prototype.updateOptions = function (e) { var t, i, r, n, o, a, s, l, c, u, h; e && (this.loop = null !== (t = e.loop) && void 0 !== t ? t : this.loop, this.maxDistance = null !== (i = e.maxDistance) && void 0 !== i ? i : this.maxDistance, this.useCustomAttenuation = null !== (r = e.useCustomAttenuation) && void 0 !== r ? r : this.useCustomAttenuation, this.rolloffFactor = null !== (n = e.rolloffFactor) && void 0 !== n ? n : this.rolloffFactor, this.refDistance = null !== (o = e.refDistance) && void 0 !== o ? o : this.refDistance, this.distanceModel = null !== (a = e.distanceModel) && void 0 !== a ? a : this.distanceModel, this._playbackRate = null !== (s = e.playbackRate) && void 0 !== s ? s : this._playbackRate, this._length = null !== (l = e.length) && void 0 !== l ? l : void 0, this.spatialSound = null !== (c = e.spatialSound) && void 0 !== c ? c : this._spatialSound, this._setOffset(null !== (u = e.offset) && void 0 !== u ? u : void 0), this.setVolume(null !== (h = e.volume) && void 0 !== h ? h : this._volume), this._updateSpatialParameters(), this.isPlaying && (this._streaming && this._htmlAudioElement ? (this._htmlAudioElement.playbackRate = this._playbackRate, this._htmlAudioElement.loop !== this.loop && (this._htmlAudioElement.loop = this.loop)) : this._soundSource && (this._soundSource.playbackRate.value = this._playbackRate, this._soundSource.loop !== this.loop && (this._soundSource.loop = this.loop), void 0 !== this._offset && this._soundSource.loopStart !== this._offset && (this._soundSource.loopStart = this._offset), void 0 !== this._length && this._length !== this._soundSource.loopEnd && (this._soundSource.loopEnd = (0 | this._offset) + this._length)))) }, e.prototype._createSpatialParameters = function () { var e, t; (null === (e = In.audioEngine) || void 0 === e ? void 0 : e.canUseWebAudio) && In.audioEngine.audioContext && (this._scene.headphone && (this._panningModel = "HRTF"), this._soundPanner = null !== (t = this._soundPanner) && void 0 !== t ? t : In.audioEngine.audioContext.createPanner(), this._soundPanner && this._outputAudioNode && (this._updateSpatialParameters(), this._soundPanner.connect(this._outputAudioNode), this._inputAudioNode = this._soundPanner)) }, e.prototype._disableSpatialSound = function () { var e; this._spatialSound && (this._inputAudioNode = this._soundGain, null === (e = this._soundPanner) || void 0 === e || e.disconnect(), this._soundPanner = null, this._spatialSound = !1) }, e.prototype._updateSpatialParameters = function () { this._spatialSound && (this._soundPanner ? this.useCustomAttenuation ? (this._soundPanner.distanceModel = "linear", this._soundPanner.maxDistance = Number.MAX_VALUE, this._soundPanner.refDistance = 1, this._soundPanner.rolloffFactor = 1, this._soundPanner.panningModel = this._panningModel) : (this._soundPanner.distanceModel = this.distanceModel, this._soundPanner.maxDistance = this.maxDistance, this._soundPanner.refDistance = this.refDistance, this._soundPanner.rolloffFactor = this.rolloffFactor, this._soundPanner.panningModel = this._panningModel) : this._createSpatialParameters()) }, e.prototype.switchPanningModelToHRTF = function () { this._panningModel = "HRTF", this._switchPanningModel() }, e.prototype.switchPanningModelToEqualPower = function () { this._panningModel = "equalpower", this._switchPanningModel() }, e.prototype._switchPanningModel = function () { var e; (null === (e = In.audioEngine) || void 0 === e ? void 0 : e.canUseWebAudio) && this._spatialSound && this._soundPanner && (this._soundPanner.panningModel = this._panningModel) }, e.prototype.connectToSoundTrackAudioNode = function (e) { var t; (null === (t = In.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._outputAudioNode && (this._isOutputConnected && this._outputAudioNode.disconnect(), this._outputAudioNode.connect(e), this._isOutputConnected = !0) }, e.prototype.setDirectionalCone = function (e, t, i) { t < e ? $.Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.") : (this._coneInnerAngle = e, this._coneOuterAngle = t, this._coneOuterGain = i, this._isDirectional = !0, this.isPlaying && this.loop && (this.stop(), this.play(0, this._offset, this._length))) }, Object.defineProperty(e.prototype, "directionalConeInnerAngle", { get: function () { return this._coneInnerAngle }, set: function (e) { var t; if (e != this._coneInnerAngle) { if (this._coneOuterAngle < e) return void $.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle."); this._coneInnerAngle = e, (null === (t = In.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._spatialSound && this._soundPanner && (this._soundPanner.coneInnerAngle = this._coneInnerAngle) } }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "directionalConeOuterAngle", { get: function () { return this._coneOuterAngle }, set: function (e) { var t; if (e != this._coneOuterAngle) { if (e < this._coneInnerAngle) return void $.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle."); this._coneOuterAngle = e, (null === (t = In.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._spatialSound && this._soundPanner && (this._soundPanner.coneOuterAngle = this._coneOuterAngle) } }, enumerable: !1, configurable: !0 }), e.prototype.setPosition = function (e) { var t; e.equals(this._position) || (this._position.copyFrom(e), (null === (t = In.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._spatialSound && this._soundPanner && !isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z) && (this._soundPanner.positionX.value = this._position.x, this._soundPanner.positionY.value = this._position.y, this._soundPanner.positionZ.value = this._position.z)) }, e.prototype.setLocalDirectionToMesh = function (e) { var t; this._localDirection = e, (null === (t = In.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._connectedTransformNode && this.isPlaying && this._updateDirection() }, e.prototype._updateDirection = function () { if (this._connectedTransformNode && this._soundPanner) { var e = this._connectedTransformNode.getWorldMatrix(), t = R.TransformNormal(this._localDirection, e); t.normalize(), this._soundPanner.orientationX.value = t.x, this._soundPanner.orientationY.value = t.y, this._soundPanner.orientationZ.value = t.z } }, e.prototype.updateDistanceFromListener = function () { var e; if ((null === (e = In.audioEngine) || void 0 === e ? void 0 : e.canUseWebAudio) && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) { var t = this._scene.audioListenerPositionProvider ? this._connectedTransformNode.position.subtract(this._scene.audioListenerPositionProvider()).length() : this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera); this._soundGain.gain.value = this._customAttenuationFunction(this._volume, t, this.maxDistance, this.refDistance, this.rolloffFactor) } }, e.prototype.setAttenuationFunction = function (e) { this._customAttenuationFunction = e }, e.prototype.play = function (e, t, i) { var r, n, o, a, s = this; if (this._isReadyToPlay && this._scene.audioEnabled && (null === (r = In.audioEngine) || void 0 === r ? void 0 : r.audioContext)) try { this._clearTimeoutsAndObservers(); var l = e ? (null === (n = In.audioEngine) || void 0 === n ? void 0 : n.audioContext.currentTime) + e : null === (o = In.audioEngine) || void 0 === o ? void 0 : o.audioContext.currentTime; if (this._soundSource && this._streamingSource || this._spatialSound && this._soundPanner && (isNaN(this._position.x) || isNaN(this._position.y) || isNaN(this._position.z) || (this._soundPanner.positionX.value = this._position.x, this._soundPanner.positionY.value = this._position.y, this._soundPanner.positionZ.value = this._position.z), this._isDirectional && (this._soundPanner.coneInnerAngle = this._coneInnerAngle, this._soundPanner.coneOuterAngle = this._coneOuterAngle, this._soundPanner.coneOuterGain = this._coneOuterGain, this._connectedTransformNode ? this._updateDirection() : this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z))), this._streaming) { if (this._streamingSource || (this._streamingSource = In.audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement), this._htmlAudioElement.onended = function () { s._onended() }, this._htmlAudioElement.playbackRate = this._playbackRate), this._streamingSource.disconnect(), this._inputAudioNode && this._streamingSource.connect(this._inputAudioNode), this._htmlAudioElement) { var c = function () { var e, t; if (null === (e = In.audioEngine) || void 0 === e ? void 0 : e.unlocked) { var i = s._htmlAudioElement.play(); void 0 !== i && i.catch((function () { var e, t; null === (e = In.audioEngine) || void 0 === e || e.lock(), (s.loop || s.autoplay) && (s._audioUnlockedObserver = null === (t = In.audioEngine) || void 0 === t ? void 0 : t.onAudioUnlockedObservable.addOnce((function () { c() }))) })) } else (s.loop || s.autoplay) && (s._audioUnlockedObserver = null === (t = In.audioEngine) || void 0 === t ? void 0 : t.onAudioUnlockedObservable.addOnce((function () { c() }))) }; c() } } else { var u = function () { var r, n, o, a; if (null === (r = In.audioEngine) || void 0 === r ? void 0 : r.audioContext) { if (i = i || s._length, void 0 !== t && s._setOffset(t), s._soundSource) { var c = s._soundSource; c.onended = function () { c.disconnect() } } if (s._soundSource = null === (n = In.audioEngine) || void 0 === n ? void 0 : n.audioContext.createBufferSource(), s._soundSource && s._inputAudioNode) { s._soundSource.buffer = s._audioBuffer, s._soundSource.connect(s._inputAudioNode), s._soundSource.loop = s.loop, void 0 !== t && (s._soundSource.loopStart = t), void 0 !== i && (s._soundSource.loopEnd = (0 | t) + i), s._soundSource.playbackRate.value = s._playbackRate, s._soundSource.onended = function () { s._onended() }, l = e ? (null === (o = In.audioEngine) || void 0 === o ? void 0 : o.audioContext.currentTime) + e : In.audioEngine.audioContext.currentTime; var u = ((s.isPaused ? s.currentTime : 0) + (null !== (a = s._offset) && void 0 !== a ? a : 0)) % s._soundSource.buffer.duration; s._soundSource.start(l, u, s.loop ? void 0 : i) } } }; "suspended" === (null === (a = In.audioEngine) || void 0 === a ? void 0 : a.audioContext.state) ? this._tryToPlayTimeout = setTimeout((function () { var e; "suspended" === (null === (e = In.audioEngine) || void 0 === e ? void 0 : e.audioContext.state) ? (In.audioEngine.lock(), (s.loop || s.autoplay) && (s._audioUnlockedObserver = In.audioEngine.onAudioUnlockedObservable.addOnce((function () { u() })))) : u() }), 500) : u() } this._startTime = l, this.isPlaying = !0, this.isPaused = !1 } catch (e) { $.Error("Error while trying to play audio: " + this.name + ", " + e.message) } }, e.prototype._onended = function () { this.isPlaying = !1, this._startTime = 0, this._currentTime = 0, this.onended && this.onended(), this.onEndedObservable.notifyObservers(this) }, e.prototype.stop = function (e) { var t, i = this; if (this.isPlaying) if (this._clearTimeoutsAndObservers(), this._streaming) this._htmlAudioElement ? (this._htmlAudioElement.pause(), this._htmlAudioElement.currentTime > 0 && (this._htmlAudioElement.currentTime = 0)) : this._streamingSource.disconnect(), this.isPlaying = !1; else if ((null === (t = In.audioEngine) || void 0 === t ? void 0 : t.audioContext) && this._soundSource) { var r = e ? In.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 = In.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 += In.audioEngine.audioContext.currentTime - this._startTime)) }, e.prototype.setVolume = function (e, t) { var i; (null === (i = In.audioEngine) || void 0 === i ? void 0 : i.canUseWebAudio) && this._soundGain && (t && In.audioEngine.audioContext ? (this._soundGain.gain.cancelScheduledValues(In.audioEngine.audioContext.currentTime), this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, In.audioEngine.audioContext.currentTime), this._soundGain.gain.linearRampToValueAtTime(e, In.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 = In.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.name, 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 = In.audioEngine) || void 0 === e || e.onAudioUnlockedObservable.remove(this._audioUnlockedObserver), this._audioUnlockedObserver = null) }, e._SceneComponentInitialization = function (e) { throw ge("AudioSceneComponent") }, e }(), so = 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 = In.audioEngine) || void 0 === e ? void 0 : e.canUseWebAudio) && In.audioEngine.audioContext && (this._outputAudioNode = In.audioEngine.audioContext.createGain(), this._outputAudioNode.connect(In.audioEngine.masterGain), this._options && this._options.volume && (this._outputAudioNode.gain.value = this._options.volume), this._isInitialized = !0) }, e.prototype.dispose = function () { if (In.audioEngine && In.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 = In.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._outputAudioNode && e.connectToSoundTrackAudioNode(this._outputAudioNode), 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 = In.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._outputAudioNode && (this._outputAudioNode.gain.value = e) }, e.prototype.switchPanningModelToHRTF = function () { var e; if (null === (e = In.audioEngine) || void 0 === e ? void 0 : e.canUseWebAudio) for (var t = 0; t < this.soundCollection.length; t++)this.soundCollection[t].switchPanningModelToHRTF() }, e.prototype.switchPanningModelToEqualPower = function () { var e; if (null === (e = In.audioEngine) || void 0 === e ? void 0 : e.canUseWebAudio) for (var t = 0; t < this.soundCollection.length; t++)this.soundCollection[t].switchPanningModelToEqualPower() }, e.prototype.connectToAnalyser = function (e) { var t; this._connectedAnalyser && this._connectedAnalyser.stopDebugCanvas(), this._connectedAnalyser = e, (null === (t = In.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._outputAudioNode && (this._outputAudioNode.disconnect(), this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, In.audioEngine.masterGain)) }, e }(); o.AddParser(qi.NAME_AUDIO, (function (e, t, i, r) { var n, o, a = []; if (i.sounds = i.sounds || [], void 0 !== e.sounds && null !== e.sounds) for (var s = 0, l = e.sounds.length; s < l; s++) { var c = e.sounds[s]; (null === (n = In.audioEngine) || void 0 === n ? void 0 : n.canUseWebAudio) ? (c.url || (c.url = c.name), a[c.url] ? i.sounds.push(ao.Parse(c, t, r, a[c.url])) : (o = ao.Parse(c, t, r), a[c.url] = o, i.sounds.push(o))) : i.sounds.push(new ao(c.name, null, t)) } a = [] })), Object.defineProperty(Sr.prototype, "mainSoundTrack", { get: function () { var e = this._getComponent(qi.NAME_AUDIO); return e || (e = new lo(this), this._addComponent(e)), this._mainSoundTrack || (this._mainSoundTrack = new so(this, { mainTrack: !0 })), this._mainSoundTrack }, enumerable: !0, configurable: !0 }), Sr.prototype.getSoundByName = function (e) { var t; for (t = 0; t < this.mainSoundTrack.soundCollection.length; t++)if (this.mainSoundTrack.soundCollection[t].name === e) return this.mainSoundTrack.soundCollection[t]; if (this.soundTracks) for (var i = 0; i < this.soundTracks.length; i++)for (t = 0; t < this.soundTracks[i].soundCollection.length; t++)if (this.soundTracks[i].soundCollection[t].name === e) return this.soundTracks[i].soundCollection[t]; return null }, Object.defineProperty(Sr.prototype, "audioEnabled", { get: function () { var e = this._getComponent(qi.NAME_AUDIO); return e || (e = new lo(this), this._addComponent(e)), e.audioEnabled }, set: function (e) { var t = this._getComponent(qi.NAME_AUDIO); t || (t = new lo(this), this._addComponent(t)), e ? t.enableAudio() : t.disableAudio() }, enumerable: !0, configurable: !0 }), Object.defineProperty(Sr.prototype, "headphone", { get: function () { var e = this._getComponent(qi.NAME_AUDIO); return e || (e = new lo(this), this._addComponent(e)), e.headphone }, set: function (e) { var t = this._getComponent(qi.NAME_AUDIO); t || (t = new lo(this), this._addComponent(t)), e ? t.switchAudioModeForHeadphones() : t.switchAudioModeForNormalSpeakers() }, enumerable: !0, configurable: !0 }), Object.defineProperty(Sr.prototype, "audioListenerPositionProvider", { get: function () { var e = this._getComponent(qi.NAME_AUDIO); return e || (e = new lo(this), this._addComponent(e)), e.audioListenerPositionProvider }, set: function (e) { var t = this._getComponent(qi.NAME_AUDIO); if (t || (t = new lo(this), this._addComponent(t)), e && "function" != typeof e) throw new Error("The value passed to [Scene.audioListenerPositionProvider] must be a function that returns a Vector3"); t.audioListenerPositionProvider = e }, enumerable: !0, configurable: !0 }), Object.defineProperty(Sr.prototype, "audioListenerRotationProvider", { get: function () { var e = this._getComponent(qi.NAME_AUDIO); return e || (e = new lo(this), this._addComponent(e)), e.audioListenerRotationProvider }, set: function (e) { var t = this._getComponent(qi.NAME_AUDIO); if (t || (t = new lo(this), this._addComponent(t)), e && "function" != typeof e) throw new Error("The value passed to [Scene.audioListenerRotationProvider] must be a function that returns a Vector3"); t.audioListenerRotationProvider = e }, enumerable: !0, configurable: !0 }), Object.defineProperty(Sr.prototype, "audioPositioningRefreshRate", { get: function () { var e = this._getComponent(qi.NAME_AUDIO); return e || (e = new lo(this), this._addComponent(e)), e.audioPositioningRefreshRate }, set: function (e) { var t = this._getComponent(qi.NAME_AUDIO); t || (t = new lo(this), this._addComponent(t)), t.audioPositioningRefreshRate = e }, enumerable: !0, configurable: !0 }); var lo = function () { function e(e) { this.name = qi.NAME_AUDIO, this._audioEnabled = !0, this._headphone = !1, this.audioPositioningRefreshRate = 500, this.audioListenerPositionProvider = null, this.audioListenerRotationProvider = null, this._cachedCameraDirection = new R, this._cachedCameraPosition = new R, this._lastCheck = 0, this._invertMatrixTemp = new I, this._cameraDirectionTemp = new R, (e = e || S.LastCreatedScene) && (this.scene = e, e.soundTracks = new Array, e.sounds = new Array) } return Object.defineProperty(e.prototype, "audioEnabled", { get: function () { return this._audioEnabled }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "headphone", { get: function () { return this._headphone }, enumerable: !1, configurable: !0 }), e.prototype.register = function () { this.scene._afterRenderStage.registerStep(qi.STEP_AFTERRENDER_AUDIO, this, this._afterRender) }, e.prototype.rebuild = function () { }, e.prototype.serialize = function (e) { if (e.sounds = [], this.scene.soundTracks) for (var t = 0; t < this.scene.soundTracks.length; t++)for (var i = this.scene.soundTracks[t], r = 0; r < i.soundCollection.length; r++)e.sounds.push(i.soundCollection[r].serialize()) }, e.prototype.addFromContainer = function (e) { var t = this; e.sounds && e.sounds.forEach((function (e) { e.play(), e.autoplay = !0, t.scene.mainSoundTrack.addSound(e) })) }, e.prototype.removeFromContainer = function (e, t) { var i = this; void 0 === t && (t = !1), e.sounds && e.sounds.forEach((function (e) { e.stop(), e.autoplay = !1, i.scene.mainSoundTrack.removeSound(e), t && e.dispose() })) }, e.prototype.dispose = function () { var e = this.scene; if (e._mainSoundTrack && e.mainSoundTrack.dispose(), e.soundTracks) for (var t = 0; t < e.soundTracks.length; t++)e.soundTracks[t].dispose() }, e.prototype.disableAudio = function () { var e, t = this.scene; for (this._audioEnabled = !1, In.audioEngine && In.audioEngine.audioContext && In.audioEngine.audioContext.suspend(), e = 0; e < t.mainSoundTrack.soundCollection.length; e++)t.mainSoundTrack.soundCollection[e].pause(); if (t.soundTracks) for (e = 0; e < t.soundTracks.length; e++)for (var i = 0; i < t.soundTracks[e].soundCollection.length; i++)t.soundTracks[e].soundCollection[i].pause() }, e.prototype.enableAudio = function () { var e, t = this.scene; for (this._audioEnabled = !0, In.audioEngine && In.audioEngine.audioContext && In.audioEngine.audioContext.resume(), e = 0; e < t.mainSoundTrack.soundCollection.length; e++)t.mainSoundTrack.soundCollection[e].isPaused && t.mainSoundTrack.soundCollection[e].play(); if (t.soundTracks) for (e = 0; e < t.soundTracks.length; e++)for (var i = 0; i < t.soundTracks[e].soundCollection.length; i++)t.soundTracks[e].soundCollection[i].isPaused && t.soundTracks[e].soundCollection[i].play() }, e.prototype.switchAudioModeForHeadphones = function () { var e = this.scene; if (this._headphone = !0, e.mainSoundTrack.switchPanningModelToHRTF(), e.soundTracks) for (var t = 0; t < e.soundTracks.length; t++)e.soundTracks[t].switchPanningModelToHRTF() }, e.prototype.switchAudioModeForNormalSpeakers = function () { var e = this.scene; if (this._headphone = !1, e.mainSoundTrack.switchPanningModelToEqualPower(), e.soundTracks) for (var t = 0; t < e.soundTracks.length; t++)e.soundTracks[t].switchPanningModelToEqualPower() }, e.prototype._afterRender = function () { var t = at.Now; if (!(this._lastCheck && t - this._lastCheck < this.audioPositioningRefreshRate)) { this._lastCheck = t; var i = this.scene; if (this._audioEnabled && i._mainSoundTrack && i.soundTracks && (0 !== i._mainSoundTrack.soundCollection.length || 1 !== i.soundTracks.length)) { var r = In.audioEngine; if (r && r.audioContext) { var n = i.activeCamera; if (i.activeCameras && i.activeCameras.length > 0 && (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; s < i.mainSoundTrack.soundCollection.length; s++)(c = i.mainSoundTrack.soundCollection[s]).useCustomAttenuation && c.updateDistanceFromListener(); if (i.soundTracks) for (s = 0; s < i.soundTracks.length; s++)for (var l = 0; l < i.soundTracks[s].soundCollection.length; l++) { var c; (c = i.soundTracks[s].soundCollection[l]).useCustomAttenuation && c.updateDistanceFromListener() } } } } }, e._CameraDirection = new R(0, 0, -1), e }(); ao._SceneComponentInitialization = function (e) { var t = e._getComponent(qi.NAME_AUDIO); t || (t = new lo(e), e._addComponent(t)) }; var co = function () { function e(e, t, i) { var r = this; if (this.loop = !1, this._coneInnerAngle = 360, this._coneOuterAngle = 360, this._volume = 1, this.isPlaying = !1, this.isPaused = !1, this._sounds = [], this._weights = [], t.length !== i.length) throw new Error("Sounds length does not equal weights length"); this.loop = e, this._weights = i; for (var n = 0, o = 0, a = i; o < a.length; o++)n += a[o]; for (var s = n > 0 ? 1 / n : 0, l = 0; l < this._weights.length; l++)this._weights[l] *= s; this._sounds = t; for (var c = 0, u = this._sounds; c < u.length; c++)u[c].onEndedObservable.add((function () { r._onended() })) } return Object.defineProperty(e.prototype, "directionalConeInnerAngle", { get: function () { return this._coneInnerAngle }, set: function (e) { if (e !== this._coneInnerAngle) { if (this._coneOuterAngle < e) return void $.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle."); this._coneInnerAngle = e; for (var t = 0, i = this._sounds; t < i.length; t++)i[t].directionalConeInnerAngle = e } }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "directionalConeOuterAngle", { get: function () { return this._coneOuterAngle }, set: function (e) { if (e !== this._coneOuterAngle) { if (e < this._coneInnerAngle) return void $.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle."); this._coneOuterAngle = e; for (var t = 0, i = this._sounds; t < i.length; t++)i[t].directionalConeOuterAngle = e } }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "volume", { get: function () { return this._volume }, set: function (e) { if (e !== this._volume) for (var t = 0, i = this._sounds; t < i.length; t++)i[t].setVolume(e) }, enumerable: !1, configurable: !0 }), e.prototype._onended = function () { void 0 !== this._currentIndex && (this._sounds[this._currentIndex].autoplay = !1), this.loop && this.isPlaying ? this.play() : this.isPlaying = !1 }, e.prototype.pause = function () { this.isPaused = !0, void 0 !== this._currentIndex && this._sounds[this._currentIndex].pause() }, e.prototype.stop = function () { this.isPlaying = !1, void 0 !== this._currentIndex && this._sounds[this._currentIndex].stop() }, e.prototype.play = function (e) { if (!this.isPaused) { this.stop(); for (var t = Math.random(), i = 0, r = 0; r < this._weights.length; r++)if (t <= (i += this._weights[r])) { this._currentIndex = r; break } } var n = this._sounds[this._currentIndex]; n.isReady() ? n.play(0, this.isPaused ? void 0 : e) : n.autoplay = !0, this.isPlaying = !0, this.isPaused = !1 }, e }(), uo = function () { function e(e) { this._texture = null, this._isEnabled = !0, this.isEnabled = !0, this.time = 0, (e = e || S.LastCreatedScene) && (this._scene = e, this.animationParameters = new C(0, 0, 0, 30)) } return e.prototype._markSubMeshesAsAttributesDirty = function () { for (var e = 0, t = this._scene.meshes; e < t.length; e++) { var i = t[e]; i.bakedVertexAnimationManager === this && i._markSubMeshesAsAttributesDirty() } }, e.prototype.bind = function (e, t) { if (void 0 === t && (t = !1), this._texture && this._isEnabled) { var i = this._texture.getSize(); e.setFloat2("bakedVertexAnimationTextureSizeInverted", 1 / i.width, 1 / i.height), e.setFloat("bakedVertexAnimationTime", this.time), t || e.setVector4("bakedVertexAnimationSettings", this.animationParameters), e.setTexture("bakedVertexAnimationTexture", this._texture) } }, e.prototype.clone = function () { var t = new e(this._scene); return this.copyTo(t), t }, e.prototype.setAnimationParameters = function (e, t, i, r) { void 0 === i && (i = 0), void 0 === r && (r = 30), this.animationParameters = new C(e, t, i, r) }, e.prototype.dispose = function (e) { var t; e && (null === (t = this._texture) || void 0 === t || t.dispose()) }, e.prototype.getClassName = function () { return "BakedVertexAnimationManager" }, e.prototype.copyTo = function (e) { Ue.Clone((function () { return e }), this) }, e.prototype.serialize = function () { return Ue.Serialize(this) }, e.prototype.parse = function (e, t, i) { var r = this; Ue.Parse((function () { return r }), e, t, i) }, X([Ae(), Se("_markSubMeshesAsAttributesDirty")], e.prototype, "texture", void 0), X([xe(), Se("_markSubMeshesAsAttributesDirty")], e.prototype, "isEnabled", void 0), X([xe()], e.prototype, "animationParameters", void 0), X([xe()], e.prototype, "time", void 0), e }(), ho = function () { function e(t) { this._wrapU = a.TEXTURE_WRAP_ADDRESSMODE, this._wrapV = a.TEXTURE_WRAP_ADDRESSMODE, this.wrapR = a.TEXTURE_WRAP_ADDRESSMODE, this.anisotropicFilteringLevel = 4, this.delayLoadState = a.DELAYLOADSTATE_NONE, this._texture = null, this._engine = null, this._cachedSize = We.Zero(), this._cachedBaseSize = We.Zero(), this._initialSamplingMode = a.TEXTURE_BILINEAR_SAMPLINGMODE, this._texture = e._IsRenderTargetWrapper(t) ? t.texture : t, this._texture && (this._engine = this._texture.getEngine()) } return Object.defineProperty(e.prototype, "wrapU", { get: function () { return this._wrapU }, set: function (e) { this._wrapU = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "wrapV", { get: function () { return this._wrapV }, set: function (e) { this._wrapV = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "coordinatesMode", { get: function () { return 0 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isCube", { get: function () { return !!this._texture && this._texture.isCube }, set: function (e) { this._texture && (this._texture.isCube = e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "is3D", { get: function () { return !!this._texture && this._texture.is3D }, set: function (e) { this._texture && (this._texture.is3D = e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "is2DArray", { get: function () { return !!this._texture && this._texture.is2DArray }, set: function (e) { this._texture && (this._texture.is2DArray = e) }, enumerable: !1, configurable: !0 }), e.prototype.getClassName = function () { return "ThinTexture" }, e._IsRenderTargetWrapper = function (e) { return void 0 !== (null == e ? void 0 : e._shareDepth) }, e.prototype.isReady = function () { return this.delayLoadState === a.DELAYLOADSTATE_NOTLOADED ? (this.delayLoad(), !1) : !!this._texture && this._texture.isReady }, e.prototype.delayLoad = function () { }, e.prototype.getInternalTexture = function () { return this._texture }, e.prototype.getSize = function () { if (this._texture) { if (this._texture.width) return this._cachedSize.width = this._texture.width, this._cachedSize.height = this._texture.height, this._cachedSize; if (this._texture._size) return this._cachedSize.width = this._texture._size, this._cachedSize.height = this._texture._size, this._cachedSize } return this._cachedSize }, e.prototype.getBaseSize = function () { return this.isReady() && this._texture ? this._texture._size ? (this._cachedBaseSize.width = this._texture._size, this._cachedBaseSize.height = this._texture._size, this._cachedBaseSize) : (this._cachedBaseSize.width = this._texture.baseWidth, this._cachedBaseSize.height = this._texture.baseHeight, this._cachedBaseSize) : (this._cachedBaseSize.width = 0, this._cachedBaseSize.height = 0, this._cachedBaseSize) }, Object.defineProperty(e.prototype, "samplingMode", { get: function () { return this._texture ? this._texture.samplingMode : this._initialSamplingMode }, enumerable: !1, configurable: !0 }), e.prototype.updateSamplingMode = function (e) { this._texture && this._engine && this._engine.updateTextureSamplingMode(e, this._texture) }, e.prototype.releaseInternalTexture = function () { this._texture && (this._texture.dispose(), this._texture = null) }, e.prototype.dispose = function () { this._texture && (this.releaseInternalTexture(), this._engine = null) }, e }(), po = function (e) { function t(i, r) { void 0 === r && (r = null); var n = e.call(this, null) || this; return n.metadata = null, n.reservedDataStore = null, n._hasAlpha = !1, n._getAlphaFromRGB = !1, n.level = 1, n._coordinatesIndex = 0, n.optimizeUVAllocation = !0, n._coordinatesMode = a.TEXTURE_EXPLICIT_MODE, n.wrapR = a.TEXTURE_WRAP_ADDRESSMODE, n.anisotropicFilteringLevel = t.DEFAULT_ANISOTROPIC_FILTERING_LEVEL, n._isCube = !1, n._gammaSpace = !0, n.invertZ = !1, n.lodLevelInAlpha = !1, n.isRenderTarget = !1, n._prefiltered = !1, n._forceSerialize = !1, n.animations = new Array, n.onDisposeObservable = new u, n._onDisposeObserver = null, n._scene = null, n._uid = null, n._parentContainer = null, n._loadingError = !1, i ? t._IsScene(i) ? n._scene = i : n._engine = i : n._scene = S.LastCreatedScene, n._scene && (n.uniqueId = n._scene.getUniqueId(), n._scene.addTexture(n), n._engine = n._scene.getEngine()), n._texture = r, n._uid = null, n } return W(t, e), Object.defineProperty(t.prototype, "hasAlpha", { get: function () { return this._hasAlpha }, set: function (e) { var t = this; this._hasAlpha !== e && (this._hasAlpha = e, this._scene && this._scene.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function (e) { return e.hasTexture(t) }))) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "getAlphaFromRGB", { get: function () { return this._getAlphaFromRGB }, set: function (e) { var t = this; this._getAlphaFromRGB !== e && (this._getAlphaFromRGB = e, this._scene && this._scene.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function (e) { return e.hasTexture(t) }))) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "coordinatesIndex", { get: function () { return this._coordinatesIndex }, set: function (e) { var t = this; this._coordinatesIndex !== e && (this._coordinatesIndex = e, this._scene && this._scene.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function (e) { return e.hasTexture(t) }))) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "coordinatesMode", { get: function () { return this._coordinatesMode }, set: function (e) { var t = this; this._coordinatesMode !== e && (this._coordinatesMode = e, this._scene && this._scene.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function (e) { return e.hasTexture(t) }))) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wrapU", { get: function () { return this._wrapU }, set: function (e) { this._wrapU = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wrapV", { get: function () { return this._wrapV }, set: function (e) { this._wrapV = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isCube", { get: function () { return this._texture ? this._texture.isCube : this._isCube }, set: function (e) { this._texture ? this._texture.isCube = e : this._isCube = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "is3D", { get: function () { return !!this._texture && this._texture.is3D }, set: function (e) { this._texture && (this._texture.is3D = e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "is2DArray", { get: function () { return !!this._texture && this._texture.is2DArray }, set: function (e) { this._texture && (this._texture.is2DArray = e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "gammaSpace", { get: function () { return this._texture ? (null === this._texture._gammaSpace && (this._texture._gammaSpace = this._gammaSpace), this._texture._gammaSpace && !this._texture._useSRGBBuffer) : this._gammaSpace }, set: function (e) { if (this._texture) { if (this._texture._gammaSpace === e) return; this._texture._gammaSpace = e } else { if (this._gammaSpace === e) return; this._gammaSpace = e } this._markAllSubMeshesAsTexturesDirty() }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isRGBD", { get: function () { return null != this._texture && this._texture._isRGBD }, set: function (e) { this._texture && (this._texture._isRGBD = e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "noMipmap", { get: function () { return !1 }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "lodGenerationOffset", { get: function () { return this._texture ? this._texture._lodGenerationOffset : 0 }, set: function (e) { this._texture && (this._texture._lodGenerationOffset = e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "lodGenerationScale", { get: function () { return this._texture ? this._texture._lodGenerationScale : 0 }, set: function (e) { this._texture && (this._texture._lodGenerationScale = e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "linearSpecularLOD", { get: function () { return !!this._texture && this._texture._linearSpecularLOD }, set: function (e) { this._texture && (this._texture._linearSpecularLOD = e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "irradianceTexture", { get: function () { return this._texture ? this._texture._irradianceTexture : null }, set: function (e) { this._texture && (this._texture._irradianceTexture = e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "uid", { get: function () { return this._uid || (this._uid = Ei()), this._uid }, enumerable: !1, configurable: !0 }), t.prototype.toString = function () { return this.name }, t.prototype.getClassName = function () { return "BaseTexture" }, 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, "isBlocking", { get: function () { return !0 }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "loadingError", { get: function () { return this._loadingError }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "errorObject", { get: function () { return this._errorObject }, enumerable: !1, configurable: !0 }), t.prototype.getScene = function () { return this._scene }, t.prototype._getEngine = function () { return this._engine }, t.prototype.checkTransformsAreIdentical = function (e) { return null !== e }, t.prototype.getTextureMatrix = function () { return I.IdentityReadOnly }, t.prototype.getReflectionTextureMatrix = function () { return I.IdentityReadOnly }, t.prototype.getRefractionTextureMatrix = function () { return this.getReflectionTextureMatrix() }, t.prototype.isReadyOrNotBlocking = function () { return !this.isBlocking || this.isReady() || this.loadingError }, t.prototype.scale = function (e) { }, Object.defineProperty(t.prototype, "canRescale", { get: function () { return !1 }, enumerable: !1, configurable: !0 }), t.prototype._getFromCache = function (e, t, i, r, n, o) { var a = this._getEngine(); if (!a) return null; for (var s = a._getUseSRGBBuffer(!!n, t), l = a.getLoadedTexturesCache(), c = 0; c < l.length; c++) { var u = l[c]; if (!(void 0 !== n && s !== u._useSRGBBuffer || void 0 !== r && r !== u.invertY || u.url !== e || u.generateMipMaps !== !t || i && i !== u.samplingMode || void 0 !== o && o !== u.isCube)) return u.incrementReferences(), u } return null }, t.prototype._rebuild = function () { }, t.prototype.clone = function () { return null }, Object.defineProperty(t.prototype, "textureType", { get: function () { return this._texture && void 0 !== this._texture.type ? this._texture.type : a.TEXTURETYPE_UNSIGNED_INT }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "textureFormat", { get: function () { return this._texture && void 0 !== this._texture.format ? this._texture.format : a.TEXTUREFORMAT_RGBA }, enumerable: !1, configurable: !0 }), t.prototype._markAllSubMeshesAsTexturesDirty = function () { var e = this.getScene(); e && e.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag) }, t.prototype.readPixels = function (e, t, i, r, n, o, a, s, l) { if (void 0 === e && (e = 0), void 0 === t && (t = 0), void 0 === i && (i = null), void 0 === r && (r = !0), void 0 === n && (n = !1), void 0 === o && (o = 0), void 0 === a && (a = 0), void 0 === s && (s = Number.MAX_VALUE), void 0 === l && (l = Number.MAX_VALUE), !this._texture) return null; var c = this._getEngine(); if (!c) return null; var u = this.getSize(), h = u.width, d = u.height; 0 !== t && (h /= Math.pow(2, t), d /= Math.pow(2, t), h = Math.round(h), d = Math.round(d)), s = Math.min(h, s), l = Math.min(d, l); try { return this._texture.isCube ? c._readTexturePixels(this._texture, s, l, e, t, i, r, n, o, a) : c._readTexturePixels(this._texture, s, l, -1, t, i, r, n, o, a) } catch (e) { return null } }, t.prototype._readPixelsSync = function (e, t, i, r, n) { if (void 0 === e && (e = 0), void 0 === t && (t = 0), void 0 === i && (i = null), void 0 === r && (r = !0), void 0 === n && (n = !1), !this._texture) return null; var o = this.getSize(), a = o.width, s = o.height, l = this._getEngine(); if (!l) return null; 0 != t && (a /= Math.pow(2, t), s /= Math.pow(2, t), a = Math.round(a), s = Math.round(s)); try { return this._texture.isCube ? l._readTexturePixelsSync(this._texture, a, s, e, t, i, r, n) : l._readTexturePixelsSync(this._texture, a, s, -1, t, i, r, n) } catch (e) { return null } }, Object.defineProperty(t.prototype, "_lodTextureHigh", { get: function () { return this._texture ? this._texture._lodTextureHigh : null }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "_lodTextureMid", { get: function () { return this._texture ? this._texture._lodTextureMid : null }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "_lodTextureLow", { get: function () { return this._texture ? this._texture._lodTextureLow : null }, enumerable: !1, configurable: !0 }), t.prototype.dispose = function () { if (this._scene) { this._scene.stopAnimation && this._scene.stopAnimation(this), this._scene.removePendingData(this); var t = this._scene.textures.indexOf(this); if (t >= 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 = Ue.Serialize(this); return Ue.AppendSerializedAnimations(this, t), t }, t.WhenAllReady = function (e, t) { var i = e.length; if (0 !== i) for (var r = 0; r < e.length; r++) { var n = e[r]; if (n.isReady()) 0 == --i && t(); else { var o = n.onLoadObservable; o ? o.addOnce((function () { 0 == --i && t() })) : 0 == --i && t() } } else t() }, t._IsScene = function (e) { return "Scene" === e.getClassName() }, t.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4, X([xe()], t.prototype, "uniqueId", void 0), X([xe()], t.prototype, "name", void 0), X([xe()], t.prototype, "metadata", void 0), X([xe("hasAlpha")], t.prototype, "_hasAlpha", void 0), X([xe("getAlphaFromRGB")], t.prototype, "_getAlphaFromRGB", void 0), X([xe()], t.prototype, "level", void 0), X([xe("coordinatesIndex")], t.prototype, "_coordinatesIndex", void 0), X([xe()], t.prototype, "optimizeUVAllocation", void 0), X([xe("coordinatesMode")], t.prototype, "_coordinatesMode", void 0), X([xe()], t.prototype, "wrapU", null), X([xe()], t.prototype, "wrapV", null), X([xe()], t.prototype, "wrapR", void 0), X([xe()], t.prototype, "anisotropicFilteringLevel", void 0), X([xe()], t.prototype, "isCube", null), X([xe()], t.prototype, "is3D", null), X([xe()], t.prototype, "is2DArray", null), X([xe()], t.prototype, "gammaSpace", null), X([xe()], t.prototype, "invertZ", void 0), X([xe()], t.prototype, "lodLevelInAlpha", void 0), X([xe()], t.prototype, "lodGenerationOffset", null), X([xe()], t.prototype, "lodGenerationScale", null), X([xe()], t.prototype, "linearSpecularLOD", null), X([Ae()], t.prototype, "irradianceTexture", null), X([xe()], t.prototype, "isRenderTarget", void 0), t }(ho); function fo(e, t, i) { void 0 === i && (i = !1); var r = t.width, n = t.height; if (e instanceof Float32Array) { for (var o = e.byteLength / e.BYTES_PER_ELEMENT, a = new Uint8Array(o); --o >= 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 _o(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 ? fo(n, e.getSize(), r.invertY) : null } function mo(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, fo(n, e.getSize(), r.invertY)] : [2, null] } })) })) } var go = { GenerateBase64StringFromPixelData: fo, GenerateBase64StringFromTexture: _o, GenerateBase64StringFromTextureAsync: mo }, vo = 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 = this; (P = e.call(this, r) || this).url = null, P.uOffset = 0, P.vOffset = 0, P.uScale = 1, P.vScale = 1, P.uAng = 0, P.vAng = 0, P.wAng = 0, P.uRotationCenter = .5, P.vRotationCenter = .5, P.wRotationCenter = .5, P.homogeneousRotationInUVTransform = !1, P.inspectableCustomProperties = null, P._noMipmap = !1, P._invertY = !1, P._rowGenerationMatrix = null, P._cachedTextureMatrix = null, P._projectionModeMatrix = null, P._t0 = null, P._t1 = null, P._t2 = null, P._cachedUOffset = -1, P._cachedVOffset = -1, P._cachedUScale = 0, P._cachedVScale = 0, P._cachedUAng = -1, P._cachedVAng = -1, P._cachedWAng = -1, P._cachedReflectionProjectionMatrixId = -1, P._cachedURotationCenter = -1, P._cachedVRotationCenter = -1, P._cachedWRotationCenter = -1, P._cachedHomogeneousRotationInUVTransform = !1, P._cachedReflectionTextureMatrix = null, P._cachedReflectionUOffset = -1, P._cachedReflectionVOffset = -1, P._cachedReflectionUScale = 0, P._cachedReflectionVScale = 0, P._cachedReflectionCoordinatesMode = -1, P._buffer = null, P._deleteBuffer = !1, P._format = null, P._delayedOnLoad = null, P._delayedOnError = null, P.onLoadObservable = new u, P._isBlocking = !0, P.name = i || "", P.url = i; var I = !1, M = null; "object" == typeof n && null !== n ? (C = null !== (v = n.noMipmap) && void 0 !== v && v, o = null !== (y = n.invertY) && void 0 !== y ? y : !xn.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, I = null !== (A = n.useSRGBBuffer) && void 0 !== A && A, M = null !== (R = n.internalTexture) && void 0 !== R ? R : null) : C = !!n, P._noMipmap = C, P._invertY = void 0 === o ? !xn.UseOpenGLOrientationForUV : o, P._initialSamplingMode = s, P._buffer = h, P._deleteBuffer = d, P._mimeType = f, P._loaderOptions = _, P._creationFlags = m, P._useSRGBBuffer = I, P._forcedExtension = g, p && (P._format = p); var O = P.getScene(), D = P._getEngine(); if (!D) return P; D.onBeforeTextureInitObservable.notifyObservers(P); var N = function () { P._texture && (P._texture._invertVScale && (P.vScale *= -1, P.vOffset += 1), null !== P._texture._cachedWrapU && (P.wrapU = P._texture._cachedWrapU, P._texture._cachedWrapU = null), null !== P._texture._cachedWrapV && (P.wrapV = P._texture._cachedWrapV, P._texture._cachedWrapV = null), null !== P._texture._cachedWrapR && (P.wrapR = P._texture._cachedWrapR, P._texture._cachedWrapR = null)), P.onLoadObservable.hasObservers() && P.onLoadObservable.notifyObservers(P), l && l(), !P.isBlocking && O && O.resetCachedMaterial() }, F = function (e, i) { P._loadingError = !0, P._errorObject = { message: e, exception: i }, c && c(e, i), t.OnTextureLoadErrorObservable.notifyObservers(P) }; if (!P.url && !M) return P._delayedOnLoad = N, P._delayedOnError = F, P; if (P._texture = null != M ? M : P._getFromCache(P.url, C, s, P._invertY, I), P._texture) if (P._texture.isReady) ii.SetImmediate((function () { return N() })); else { var L = P._texture.onLoadedObservable.add(N); P._texture.onErrorObservable.add((function (e) { var t; F(e.message, e.exception), null === (t = P._texture) || void 0 === t || t.onLoadedObservable.remove(L) })) } else if (O && O.useDelayedTextureLoading) P.delayLoadState = a.DELAYLOADSTATE_NOTLOADED, P._delayedOnLoad = N, P._delayedOnError = F; else { try { P._texture = D.createTexture(P.url, C, P._invertY, O, s, N, F, P._buffer, void 0, P._format, P._forcedExtension, f, _, m, I) } catch (e) { throw F("error loading", e), e } d && (P._buffer = null) } return P } return W(t, e), 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) { void 0 === t && (t = null), this.url && (this.releaseInternalTexture(), this.getScene().markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)), 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._texture ? this._delayedOnLoad && (this._texture.isReady ? ii.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 -1 !== t.getActiveTextures().indexOf(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 Ue.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," + _t(this._buffer) : (t.ForceSerializeBuffers || this.url && this.url.startsWith("blob:") || this._forceSerialize) && (o.base64String = !this._engine || this._engine._features.supportSyncTextureRead ? _o(this) : mo(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), 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 = Ti.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(); s < l.length; s++) { var c = l[s]; if (c.uniqueId === e.internalTextureUniqueId) { o = c; break } } var u = function (t) { var i; if (t && t._texture && (t._texture._cachedWrapU = null, t._texture._cachedWrapV = null, t._texture._cachedWrapR = null), e.samplingMode) { var r = e.samplingMode; t && t.samplingMode !== r && t.updateSamplingMode(r) } if (t && e.animations) for (var n = 0; n < e.animations.length; n++) { var s = e.animations[n], l = T("BABYLON.Animation"); l && t.animations.push(l.Parse(s)) } a && !o && (null === (i = null == t ? void 0 : t._texture) || void 0 === i || i._setUniqueId(e.internalTextureUniqueId)) }, h = Ue.Parse((function () { var n, a, s, l, c = !0; if (e.noMipmap && (c = !1), e.mirrorPlane) { var h = t._CreateMirror(e.name, e.renderTargetSize, i, c); return h._waitingRenderList = e.renderList, h.mirrorPlane = gr.FromArray(e.mirrorPlane), u(h), h } if (e.isRenderTarget) { var d = null; if (e.isCube) { if (i.reflectionProbes) for (var p = 0; p < i.reflectionProbes.length; p++) { var f = i.reflectionProbes[p]; if (f.name === e.name) return f.cubeTexture } } else (d = t._CreateRenderTargetTexture(e.name, e.renderTargetSize, i, c, null !== (n = e._creationFlags) && void 0 !== n ? n : 0))._waitingRenderList = e.renderList; return u(d), d } if (e.base64String && !o) (l = t.CreateFromBase64String(e.base64String, e.base64String, i, !c, e.invertY, e.samplingMode, (function () { u(l) }), null !== (a = e._creationFlags) && void 0 !== a ? a : 0, null !== (s = e._useSRGBBuffer) && void 0 !== s && s)).name = e.name; else { var _ = void 0; _ = e.name && (e.name.indexOf("://") > 0 || e.name.startsWith("data:")) ? e.name : r + e.name, e.url && (e.url.startsWith("data:") || t.UseSerializedUrlIfAny) && (_ = e.url); var m = { noMipmap: !c, invertY: e.invertY, samplingMode: e.samplingMode, onLoad: function () { u(l) }, internalTexture: o }; l = new t(_, i, m) } 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 ge("CubeTexture") }, t._CreateMirror = function (e, t, i, r) { throw ge("MirrorTexture") }, t._CreateRenderTargetTexture = function (e, t, i, r, n) { throw ge("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([xe()], t.prototype, "url", void 0), X([xe()], t.prototype, "uOffset", void 0), X([xe()], t.prototype, "vOffset", void 0), X([xe()], t.prototype, "uScale", void 0), X([xe()], t.prototype, "vScale", void 0), X([xe()], t.prototype, "uAng", void 0), X([xe()], t.prototype, "vAng", void 0), X([xe()], t.prototype, "wAng", void 0), X([xe()], t.prototype, "uRotationCenter", void 0), X([xe()], t.prototype, "vRotationCenter", void 0), X([xe()], t.prototype, "wRotationCenter", void 0), X([xe()], t.prototype, "homogeneousRotationInUVTransform", void 0), X([xe()], t.prototype, "isBlocking", null), t }(po); function yo(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 < t; s++)for (var l = 0; l < i; l++) { var c = 3 * (l * t + s), u = 4 * (l * t + s); n[u + 0] = e[c + 0], n[u + 1] = e[c + 1], n[u + 2] = e[c + 2], n[u + 3] = o } return n } function bo(e) { return function (t, i, r, n, o, s, l, c, u, h) { void 0 === u && (u = null), void 0 === h && (h = a.TEXTURETYPE_UNSIGNED_INT); var d = e ? this._gl.TEXTURE_3D : this._gl.TEXTURE_2D_ARRAY, p = e ? It.Raw3D : It.Raw2DArray, f = new Ht(this, p); f.baseWidth = i, f.baseHeight = r, f.baseDepth = n, f.width = i, f.height = r, f.depth = n, f.format = o, f.type = h, f.generateMipMaps = s, f.samplingMode = c, e ? f.is3D = !0 : f.is2DArray = !0, this._doNotHandleContextLost || (f._bufferView = t), e ? this.updateRawTexture3D(f, t, o, l, u, h) : this.updateRawTexture2DArray(f, t, o, l, u, h), this._bindTextureDirectly(d, f, !0); var _ = this._getSamplingParameters(c, s); return this._gl.texParameteri(d, this._gl.TEXTURE_MAG_FILTER, _.mag), this._gl.texParameteri(d, this._gl.TEXTURE_MIN_FILTER, _.min), s && this._gl.generateMipmap(d), this._bindTextureDirectly(d, null), this._internalTexturesCache.push(f), f } } function To(e) { return function (t, i, r, n, o, s) { void 0 === o && (o = null), void 0 === s && (s = a.TEXTURETYPE_UNSIGNED_INT); var l = e ? this._gl.TEXTURE_3D : this._gl.TEXTURE_2D_ARRAY, c = this._getWebGLTextureType(s), u = this._getInternalFormat(r), h = this._getRGBABufferInternalSizedFormat(s, r); this._bindTextureDirectly(l, t, !0), this._unpackFlipY(void 0 === n || !!n), this._doNotHandleContextLost || (t._bufferView = i, t.format = r, t.invertY = n, t._compression = o), t.width % 4 != 0 && this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1), o && i ? this._gl.compressedTexImage3D(l, 0, this.getCaps().s3tc[o], t.width, t.height, t.depth, 0, i) : this._gl.texImage3D(l, 0, h, t.width, t.height, t.depth, 0, u, c, i), t.generateMipMaps && this._gl.generateMipmap(l), this._bindTextureDirectly(l, null), t.isReady = !0 } } b("BABYLON.Texture", vo), Ue._TextureParser = vo.Parse, ti.prototype.updateRawTexture = function (e, t, i, r, n, o, s) { if (void 0 === n && (n = null), void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT), void 0 === s && (s = !1), e) { var l = this._getRGBABufferInternalSizedFormat(o, i, s), c = this._getInternalFormat(i), u = this._getWebGLTextureType(o); this._bindTextureDirectly(this._gl.TEXTURE_2D, e, !0), this._unpackFlipY(void 0 === r || !!r), this._doNotHandleContextLost || (e._bufferView = t, e.format = i, e.type = o, e.invertY = r, e._compression = n), e.width % 4 != 0 && this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1), n && t ? this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[n], e.width, e.height, 0, t) : this._gl.texImage2D(this._gl.TEXTURE_2D, 0, l, e.width, e.height, 0, c, u, t), e.generateMipMaps && this._gl.generateMipmap(this._gl.TEXTURE_2D), this._bindTextureDirectly(this._gl.TEXTURE_2D, null), e.isReady = !0 } }, ti.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 Ht(this, It.Raw); 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 = this._getUseSRGBBuffer(h, !n), this._doNotHandleContextLost || (d._bufferView = e), this.updateRawTexture(d, e, r, o, l, c, d._useSRGBBuffer), this._bindTextureDirectly(this._gl.TEXTURE_2D, d, !0); var p = this._getSamplingParameters(s, n); return this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, p.mag), this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, p.min), n && this._gl.generateMipmap(this._gl.TEXTURE_2D), this._bindTextureDirectly(this._gl.TEXTURE_2D, null), this._internalTexturesCache.push(d), d }, ti.prototype.createRawCubeTexture = function (e, t, i, r, n, o, s, l) { void 0 === l && (l = null); var c = this._gl, u = new Ht(this, It.CubeRaw); u.isCube = !0, u.format = i, u.type = r, this._doNotHandleContextLost || (u._bufferViewArray = e); var h = this._getWebGLTextureType(r), d = this._getInternalFormat(i); d === c.RGB && (d = c.RGBA), h !== c.FLOAT || this._caps.textureFloatLinearFiltering ? h !== this._gl.HALF_FLOAT_OES || this._caps.textureHalfFloatLinearFiltering ? h !== c.FLOAT || this._caps.textureFloatRender ? h !== c.HALF_FLOAT || this._caps.colorBufferFloat || (n = !1, $.Warn("Render to half float textures is not supported. Mipmap generation forced to false.")) : (n = !1, $.Warn("Render to float textures is not supported. Mipmap generation forced to false.")) : (n = !1, s = a.TEXTURE_NEAREST_SAMPLINGMODE, $.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")) : (n = !1, s = a.TEXTURE_NEAREST_SAMPLINGMODE, $.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")); var p = t, f = p; if (u.width = p, u.height = f, u.invertY = o, u._compression = l, !this.needPOTTextures || xi.IsExponentOfTwo(u.width) && xi.IsExponentOfTwo(u.height) || (n = !1), e) this.updateRawCubeTexture(u, e, i, r, o, l); else { var _ = this._getRGBABufferInternalSizedFormat(r); this._bindTextureDirectly(c.TEXTURE_CUBE_MAP, u, !0); for (var m = 0; m < 6; m++)l ? c.compressedTexImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X + m, 0, this.getCaps().s3tc[l], u.width, u.height, 0, void 0) : c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X + m, 0, _, u.width, u.height, 0, d, h, null); this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null) } this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, u, !0), e && n && this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP); var g = this._getSamplingParameters(s, n); return c.texParameteri(c.TEXTURE_CUBE_MAP, c.TEXTURE_MAG_FILTER, g.mag), c.texParameteri(c.TEXTURE_CUBE_MAP, c.TEXTURE_MIN_FILTER, g.min), c.texParameteri(c.TEXTURE_CUBE_MAP, c.TEXTURE_WRAP_S, c.CLAMP_TO_EDGE), c.texParameteri(c.TEXTURE_CUBE_MAP, c.TEXTURE_WRAP_T, c.CLAMP_TO_EDGE), this._bindTextureDirectly(c.TEXTURE_CUBE_MAP, null), u.generateMipMaps = n, u.samplingMode = s, u.isReady = !0, u }, ti.prototype.updateRawCubeTexture = function (e, t, i, r, n, o, a) { void 0 === o && (o = null), void 0 === a && (a = 0), e._bufferViewArray = t, e.format = i, e.type = r, e.invertY = n, e._compression = o; var s = this._gl, l = this._getWebGLTextureType(r), c = this._getInternalFormat(i), u = this._getRGBABufferInternalSizedFormat(r), h = !1; c === s.RGB && (c = s.RGBA, h = !0), this._bindTextureDirectly(s.TEXTURE_CUBE_MAP, e, !0), this._unpackFlipY(void 0 === n || !!n), e.width % 4 != 0 && s.pixelStorei(s.UNPACK_ALIGNMENT, 1); for (var d = 0; d < 6; d++) { var p = t[d]; o ? s.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X + d, a, this.getCaps().s3tc[o], e.width, e.height, 0, p) : (h && (p = yo(p, e.width, e.height, r)), s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X + d, a, u, e.width, e.height, 0, c, l, p)) } (!this.needPOTTextures || xi.IsExponentOfTwo(e.width) && xi.IsExponentOfTwo(e.height)) && e.generateMipMaps && 0 === a && this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP), this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null), e.isReady = !0 }, ti.prototype.createRawCubeTextureFromUrl = function (e, t, i, r, n, o, s, l, c, u, h, d) { var p = this; void 0 === c && (c = null), void 0 === u && (u = null), void 0 === h && (h = a.TEXTURE_TRILINEAR_SAMPLINGMODE), void 0 === d && (d = !1); var f = this._gl, _ = this.createRawCubeTexture(null, i, r, n, !o, d, h, null); return null == t || t.addPendingData(_), _.url = e, _.isReady = !1, this._internalTexturesCache.push(_), this._loadFile(e, (function (e) { !function (e) { var i = _.width, o = s(e); if (o) { if (l) { var a = p._getWebGLTextureType(n), u = p._getInternalFormat(r), h = p._getRGBABufferInternalSizedFormat(n), m = !1; u === f.RGB && (u = f.RGBA, m = !0), p._bindTextureDirectly(f.TEXTURE_CUBE_MAP, _, !0), p._unpackFlipY(!1); for (var g = l(o), v = 0; v < g.length; v++)for (var y = i >> v, b = 0; b < 6; b++) { var T = g[v][b]; m && (T = yo(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) })), _ }, ti.prototype.createRawTexture2DArray = bo(!1), ti.prototype.createRawTexture3D = bo(!0), ti.prototype.updateRawTexture2DArray = To(!1), ti.prototype.updateRawTexture3D = To(!0); var Eo = 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 = vo.CLAMP_ADDRESSMODE, p.wrapV = vo.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 = vo.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 = vo.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 }(vo), So = 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 (!(o < a.length)) return [3, 6]; s = a[o], l = s.from, c.label = 2; case 2: return l <= s.to ? [4, this._executeAnimationFrame(n, l, r++)] : [3, 5]; case 3: c.sent(), c.label = 4; case 4: return l++, [3, 2]; case 5: return o++, [3, 1]; case 6: return [2, n] } })) })) }, e.prototype._executeAnimationFrame = function (e, t, i) { return j(this, void 0, void 0, (function () { var r = this; return Y(this, (function (n) { return [2, new Promise((function (n, o) { r._scene.beginAnimation(r._mesh.skeleton, t, t, !1, 1, (function () { var t = r._mesh.skeleton.getTransformMatrices(r._mesh); e.set(t, i * t.length), n() })) }))] })) })) }, e.prototype.textureFromBakedVertexData = function (e) { if (!this._mesh.skeleton) throw new Error("No skeleton in this mesh."); var t = this._mesh.skeleton.bones.length, i = Eo.CreateRGBATexture(e, 4 * (t + 1), e.length / (4 * (t + 1) * 4), this._scene, !1, !1, vo.NEAREST_NEAREST, a.TEXTURETYPE_FLOAT); return i.name = "VAT" + this._mesh.skeleton.name, i }, e.prototype.serializeBakedVertexDataToObject = function (e) { if (!this._mesh.skeleton) throw new Error("No skeleton in this mesh."); var t = this._mesh.skeleton.bones.length, i = 4 * (t + 1), r = e.length / (4 * (t + 1) * 4); return { vertexData: _t(e), width: i, height: r } }, e.prototype.loadBakedVertexDataFromObject = function (e) { return new Float32Array(gt(e.vertexData)) }, e.prototype.serializeBakedVertexDataToJSON = function (e) { return JSON.stringify(this.serializeBakedVertexDataToObject(e)) }, e.prototype.loadBakedVertexDataFromJSON = function (e) { return this.loadBakedVertexDataFromObject(JSON.parse(e)) }, e }(), xo = function () { function e() { this._zoomStopsAnimation = !1, this._idleRotationSpeed = .05, this._idleRotationWaitTime = 2e3, this._idleRotationSpinupTime = 2e3, this.targetAlpha = null, this._isPointerDown = !1, this._lastFrameTime = null, this._lastInteractionTime = -1 / 0, this._cameraRotationSpeed = 0, this._lastFrameRadius = 0 } return Object.defineProperty(e.prototype, "name", { get: function () { return "AutoRotation" }, 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, "idleRotationSpeed", { get: function () { return this._idleRotationSpeed }, set: function (e) { this._idleRotationSpeed = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "idleRotationWaitTime", { get: function () { return this._idleRotationWaitTime }, set: function (e) { this._idleRotationWaitTime = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "idleRotationSpinupTime", { get: function () { return this._idleRotationSpinupTime }, set: function (e) { this._idleRotationSpinupTime = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "rotationInProgress", { get: function () { return Math.abs(this._cameraRotationSpeed) > 0 }, 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 !== Ji.POINTERDOWN ? e.type === Ji.POINTERUP && (t._isPointerDown = !1) : t._isPointerDown = !0 })), this._onAfterCheckInputsObserver = e.onAfterCheckInputsObservable.add((function () { if (!t._reachTargetAlpha()) { var e = at.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 : at.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 = at.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 }(), Ao = 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 = je.CreateAnimation("radius", je.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 = je.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 Ur(.3), e.EasingMode = wr.EASINGMODE_EASEOUT, e }(), Ro = 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 !== Ji.POINTERDOWN ? e.type === Ji.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; o < e.length; o++) { var a = e[o].getHierarchyBoundingVectors(!0); R.CheckExtends(a.min, r, n), R.CheckExtends(a.max, r, n) } this.zoomOnBoundingInfo(r, n, t, i) }, e.prototype.zoomOnBoundingInfo = function (t, i, r, n) { var o, a = this; if (void 0 === r && (r = !1), void 0 === n && (n = null), !this._attachedCamera) return !1; var s = t.y, l = s + (i.y - s) * this._positionScale, c = i.subtract(t).scale(.5); if (r) o = new R(0, l, 0); else { var u = t.add(c); o = new R(u.x, l, u.z) } this._vectorTransition || (this._vectorTransition = je.CreateAnimation("target", je.ANIMATIONTYPE_VECTOR3, 60, e.EasingFunction)), this._betaIsAnimating = !0; var h = je.TransitionTo("target", o, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime); h && this._animatables.push(h); var d = 0; if (this._mode === e.FitFrustumSidesMode) { var p = this._calculateLowerRadiusFromModelBoundingSphere(t, i); this.autoCorrectCameraLimitsAndSensibility && (this._attachedCamera.lowerRadiusLimit = c.length() + this._attachedCamera.minZ), d = p } else this._mode === e.IgnoreBoundsSizeMode && (d = this._calculateLowerRadiusFromModelBoundingSphere(t, i), this.autoCorrectCameraLimitsAndSensibility && null === this._attachedCamera.lowerRadiusLimit && (this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ)); if (this.autoCorrectCameraLimitsAndSensibility) { var f = i.subtract(t).length(); this._attachedCamera.panningSensibility = 5e3 / f, this._attachedCamera.wheelPrecision = 100 / d } return this._radiusTransition || (this._radiusTransition = je.CreateAnimation("radius", je.ANIMATIONTYPE_FLOAT, 60, e.EasingFunction)), (h = je.TransitionTo("radius", d, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, (function () { a.stopAllAnimations(), n && n(), a._attachedCamera && a._attachedCamera.useInputToRestoreState && a._attachedCamera.storeState() }))) && this._animatables.push(h), !0 }, e.prototype._calculateLowerRadiusFromModelBoundingSphere = function (t, i) { var r = i.subtract(t).length(), n = this._getFrustumSlope(), o = .5 * r * this._radiusScale, a = o * Math.sqrt(1 + 1 / (n.x * n.x)), s = o * Math.sqrt(1 + 1 / (n.y * n.y)), l = Math.max(a, s), c = this._attachedCamera; return c ? (c.lowerRadiusLimit && this._mode === e.IgnoreBoundsSizeMode && (l = l < c.lowerRadiusLimit ? c.lowerRadiusLimit : l), c.upperRadiusLimit && (l = l > c.upperRadiusLimit ? c.upperRadiusLimit : l), l) : 0 }, e.prototype._maintainCameraAboveGround = function () { var t = this; if (!(this._elevationReturnTime < 0)) { var i = at.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 = je.CreateAnimation("beta", je.ANIMATIONTYPE_FLOAT, 60, e.EasingFunction)); var o = je.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._getFrustumSlope = function () { var e = this._attachedCamera; if (!e) return A.Zero(); var t = e.getScene().getEngine().getAspectRatio(e), i = Math.tan(e.fov / 2); return new A(i * t, i) }, e.prototype._clearAnimationLocks = function () { this._betaIsAnimating = !1 }, e.prototype._applyUserInteraction = function () { this.isUserIsMoving && (this._lastInteractionTime = at.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 zr, e.EasingMode = wr.EASINGMODE_EASEINOUT, e.IgnoreBoundsSizeMode = 0, e.FitFrustumSidesMode = 1, e }(), Co = 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 }, Po = function () { function e(e) { this._ui = e, this.name = "AttachToBoxBehavior", this.distanceAwayFromFace = .15, this.distanceAwayFromBottomOfFace = .15, this._faceVectors = [new Co(R.Up()), new Co(R.Down()), new Co(R.Left()), new Co(R.Right()), new Co(R.Forward()), new Co(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.diff < t.diff ? e : t }), this._faceVectors[0]) }, e.prototype._lookAtToRef = function (e, t, i) { void 0 === t && (t = new R(0, 1, 0)), I.LookAtLHToRef(this._zeroVector, e, t, this._lookAtTmpMatrix), this._lookAtTmpMatrix.invert(), P.FromRotationMatrixToRef(this._lookAtTmpMatrix, i) }, e.prototype.attach = function (e) { var t = this; this._target = e, this._scene = this._target.getScene(), this._onRenderObserver = this._scene.onBeforeRenderObservable.add((function () { if (t._scene.activeCamera) { var i = t._scene.activeCamera.position; t._scene.activeCamera.devicePosition && (i = t._scene.activeCamera.devicePosition); var r = t._closestFace(i.subtract(e.position)); t._scene.activeCamera.leftCamera ? t._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(t._tmpMatrix) : t._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(t._tmpMatrix), R.TransformCoordinatesToRef(R.Up(), t._tmpMatrix, t._tmpVector), t._faceVectors.forEach((function (e) { r.direction.x && e.direction.x && (e.ignore = !0), r.direction.y && e.direction.y && (e.ignore = !0), r.direction.z && e.direction.z && (e.ignore = !0) })); var n = t._closestFace(t._tmpVector); t._faceVectors.forEach((function (e) { e.ignore = !1 })), t._ui.position.copyFrom(e.position), r.direction.x && (r.rotatedDirection.scaleToRef(e.scaling.x / 2 + t.distanceAwayFromFace, t._tmpVector), t._ui.position.addInPlace(t._tmpVector)), r.direction.y && (r.rotatedDirection.scaleToRef(e.scaling.y / 2 + t.distanceAwayFromFace, t._tmpVector), t._ui.position.addInPlace(t._tmpVector)), r.direction.z && (r.rotatedDirection.scaleToRef(e.scaling.z / 2 + t.distanceAwayFromFace, t._tmpVector), t._ui.position.addInPlace(t._tmpVector)), t._ui.rotationQuaternion || (t._ui.rotationQuaternion = P.RotationYawPitchRoll(t._ui.rotation.y, t._ui.rotation.x, t._ui.rotation.z)), r.rotatedDirection.scaleToRef(-1, t._tmpVector), t._lookAtToRef(t._tmpVector, n.rotatedDirection, t._ui.rotationQuaternion), n.direction.x && t._ui.up.scaleToRef(t.distanceAwayFromBottomOfFace - e.scaling.x / 2, t._tmpVector), n.direction.y && t._ui.up.scaleToRef(t.distanceAwayFromBottomOfFace - e.scaling.y / 2, t._tmpVector), n.direction.z && t._ui.up.scaleToRef(t.distanceAwayFromBottomOfFace - e.scaling.z / 2, t._tmpVector), t._ui.position.addInPlace(t._tmpVector) } })) }, e.prototype.detach = function () { this._scene.onBeforeRenderObservable.remove(this._onRenderObserver) }, e }(), Io = function () { function e() { var e = this; this.fadeInDelay = 0, this.fadeOutDelay = 0, this.fadeInTime = 300, this.fadeOutTime = 300, this._millisecondsPerFrame = 1e3 / 60, this._hovered = !1, this._hoverValue = 0, this._ownerNode = null, this._delay = 0, this._time = 300, this._update = function () { if (e._ownerNode) { if (e._hoverValue += e._hovered ? e._millisecondsPerFrame : -e._millisecondsPerFrame, e._setAllVisibility(e._ownerNode, (e._hoverValue - e._delay) / e._time), e._ownerNode.visibility > 1) { 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 }(), Mo = 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.x < l.x || this.origin.x > c.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.y < l.y || this.origin.y > c.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.z < l.z || this.origin.z > c.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 cn(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; r < e.length; r++) { var n = this.intersectsMesh(e[r], t); n.hit && i.push(n) } return i.sort(this._comparePickingInfo), i }, e.prototype._comparePickingInfo = function (e, t) { return e.distance < t.distance ? -1 : e.distance > t.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; m < e._Smallnum ? (c = 0, g = 1, u = _, v = p) : (u = h * _ - d * f, (c = d * _ - p * f) < 0 ? (c = 0, u = _, v = p) : c > g && (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) < e._Smallnum ? 0 : c / g, b = Math.abs(u) < e._Smallnum ? 0 : u / v, T = O.Vector3[4]; s.scaleToRef(b, T); var E = O.Vector3[5]; o.scaleToRef(y, E), E.addInPlace(l); var S = O.Vector3[6]; return E.subtractToRef(T, S), b > 0 && b <= this.length && S.lengthSquared() < r * r ? E.length() : -1 }, e.prototype.update = function (t, i, r, n, o, a, s, l) { if (void 0 === l && (l = !1), l) { e._RayDistant || (e._RayDistant = e.Zero()), e._RayDistant.unprojectRayToRef(t, i, r, n, I.IdentityReadOnly, a, s); var c = O.Matrix[0]; o.invertToRef(c), e.TransformToRef(e._RayDistant, c, this) } else this.unprojectRayToRef(t, i, r, n, o, a, s); return this }, e.Zero = function () { return new e(R.Zero(), R.Zero()) }, e.CreateNew = function (t, i, r, n, o, a, s) { return e.Zero().update(t, i, r, n, o, a, s) }, e.CreateNewFromTo = function (t, i, r) { void 0 === r && (r = I.IdentityReadOnly); var n = i.subtract(t), o = Math.sqrt(n.x * n.x + n.y * n.y + n.z * n.z); return n.normalize(), e.Transform(new e(t, n, o), r) }, e.Transform = function (t, i) { var r = new e(new R(0, 0, 0), new R(0, 0, 0)); return e.TransformToRef(t, i, r), r }, e.TransformToRef = function (e, t, i) { R.TransformCoordinatesToRef(e.origin, t, i.origin), R.TransformNormalToRef(e.direction, t, i.direction), i.length = e.length; var r = i.direction, n = r.length(); if (0 !== n && 1 !== n) { var o = 1 / n; r.x *= o, r.y *= o, r.z *= o, i.length *= n } }, e.prototype.unprojectRayToRef = function (e, t, i, r, n, o, a) { var s = O.Matrix[0]; n.multiplyToRef(o, s), s.multiplyToRef(a, s), s.invert(); var l = S.LastCreatedEngine, c = O.Vector3[0]; c.x = e / i * 2 - 1, c.y = -(t / r * 2 - 1), c.z = (null == l ? void 0 : l.useReverseDepthBuffer) ? 1 : (null == l ? void 0 : l.isNDCHalfZRange) ? 0 : -1; var u = O.Vector3[1].copyFromFloats(c.x, c.y, 1 - 1e-8), h = O.Vector3[2], d = O.Vector3[3]; R._UnprojectFromInvertedMatrixToRef(c, s, h), R._UnprojectFromInvertedMatrixToRef(u, s, d), this.origin.copyFrom(h), d.subtractToRef(h, this.direction), this.direction.normalize() }, e._TmpVector3 = m.BuildArray(6, R.Zero), e._RayDistant = e.Zero(), e._Smallnum = 1e-8, e._Rayl = 1e9, e }(); Sr.prototype.createPickingRay = function (e, t, i, r, n) { void 0 === n && (n = !1); var o = Mo.Zero(); return this.createPickingRayToRef(e, t, i, o, r, n), o }, Sr.prototype.createPickingRayToRef = function (e, t, i, r, n, o, a) { void 0 === o && (o = !1), void 0 === a && (a = !1); var s = this.getEngine(); if (!n) { if (!this.activeCamera) return this; n = this.activeCamera } var l = n.viewport.toGlobal(s.getRenderWidth(), s.getRenderHeight()); return e = e / s.getHardwareScalingLevel() - l.x, t = t / s.getHardwareScalingLevel() - (s.getRenderHeight() - l.y - l.height), r.update(e, t, l.width, l.height, i || I.IdentityReadOnly, o ? I.IdentityReadOnly : n.getViewMatrix(), n.getProjectionMatrix(), a), this }, Sr.prototype.createPickingRayInCameraSpace = function (e, t, i) { var r = Mo.Zero(); return this.createPickingRayInCameraSpaceToRef(e, t, r, i), r }, Sr.prototype.createPickingRayInCameraSpaceToRef = function (e, t, i, r) { if (!Xi) return this; var n = this.getEngine(); if (!r) { if (!this.activeCamera) throw new Error("Active camera not set"); r = this.activeCamera } var o = r.viewport.toGlobal(n.getRenderWidth(), n.getRenderHeight()), a = I.Identity(); return e = e / n.getHardwareScalingLevel() - o.x, t = t / n.getHardwareScalingLevel() - (n.getRenderHeight() - o.y - o.height), i.update(e, t, o.width, o.height, a, a, r.getProjectionMatrix()), this }, Sr.prototype._internalPickForMesh = function (e, t, i, r, n, o, a, s) { var l = t(r, i.enableDistantPicking), c = i.intersects(l, n, a, o, r, s); return c && c.hit ? !n && null != e && c.distance >= e.distance ? null : c : null }, Sr.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; l < this.meshes.length; l++) { var c = this.meshes[l]; if (t) { if (!t(c)) continue } else if (!c.isEnabled() || !c.isVisible || !c.isPickable) continue; var u, h = a && c.isWorldMatrixCameraDependent(), d = c.computeWorldMatrix(h, s); if (c.hasThinInstances && c.thinInstanceEnablePicking) { if (u = this._internalPickForMesh(o, e, c, d, !0, !0, n)) { if (r) return u; for (var p = O.Matrix[1], f = c.thinInstanceGetWorldMatrices(), _ = 0; _ < f.length; _++) { f[_].multiplyToRef(d, p); var m = this._internalPickForMesh(o, e, c, p, i, r, n, !0); if (m && ((o = m).thinInstanceIndex = _, i)) return o } } } else if ((u = this._internalPickForMesh(o, e, c, d, i, r, n)) && (o = u, i)) return o } return o || new Xi }, Sr.prototype._internalMultiPick = function (e, t, i) { if (!Xi) return null; for (var r = new Array, n = !!(this.activeCameras && this.activeCameras.length > 1 && this.cameraToUseForPointers !== this.activeCamera), o = this.cameraToUseForPointers || this.activeCamera, a = 0; a < this.meshes.length; a++) { var s = this.meshes[a]; if (t) { if (!t(s)) continue } else if (!s.isEnabled() || !s.isVisible || !s.isPickable) continue; var l, c = n && s.isWorldMatrixCameraDependent(), u = s.computeWorldMatrix(c, o); if (s.hasThinInstances && s.thinInstanceEnablePicking) { if (l = this._internalPickForMesh(null, e, s, u, !0, !0, i)) for (var h = O.Matrix[1], d = s.thinInstanceGetWorldMatrices(), p = 0; p < d.length; p++) { d[p].multiplyToRef(u, h); var f = this._internalPickForMesh(null, e, s, h, !1, !1, i, !0); f && (f.thinInstanceIndex = p, r.push(f)) } } else (l = this._internalPickForMesh(null, e, s, u, !1, !1, i)) && r.push(l) } return r }, Sr.prototype.pickWithBoundingInfo = function (e, t, i, r, n) { var o = this; if (!Xi) return null; var a = this._internalPick((function (i) { return o._tempPickingRay || (o._tempPickingRay = Mo.Zero()), o.createPickingRayToRef(e, t, i, o._tempPickingRay, n || null), o._tempPickingRay }), i, r, !0); return a && (a.ray = this.createPickingRay(e, t, I.Identity(), n || null)), a }, Object.defineProperty(Sr.prototype, "_pickingAvailable", { get: function () { return !0 }, enumerable: !1, configurable: !1 }), Sr.prototype.pick = function (e, t, i, r, n, o, a) { var s = this; void 0 === a && (a = !1); var l = this._internalPick((function (i, r) { return s._tempPickingRay || (s._tempPickingRay = Mo.Zero()), s.createPickingRayToRef(e, t, i, s._tempPickingRay, n || null, !1, r), s._tempPickingRay }), i, r, !1, o); return l && (l.ray = this.createPickingRay(e, t, I.Identity(), n || null)), l }, Sr.prototype.pickWithRay = function (e, t, i, r) { var n = this, o = this._internalPick((function (t) { return n._pickWithRayInverseMatrix || (n._pickWithRayInverseMatrix = I.Identity()), t.invertToRef(n._pickWithRayInverseMatrix), n._cachedRayForTransform || (n._cachedRayForTransform = Mo.Zero()), Mo.TransformToRef(e, n._pickWithRayInverseMatrix, n._cachedRayForTransform), n._cachedRayForTransform }), t, i, !1, r); return o && (o.ray = e), o }, Sr.prototype.multiPick = function (e, t, i, r, n) { var o = this; return this._internalMultiPick((function (i) { return o.createPickingRay(e, t, i, r || null) }), i, n) }, Sr.prototype.multiPickWithRay = function (e, t, i) { var r = this; return this._internalMultiPick((function (t) { return r._pickWithRayInverseMatrix || (r._pickWithRayInverseMatrix = I.Identity()), t.invertToRef(r._pickWithRayInverseMatrix), r._cachedRayForTransform || (r._cachedRayForTransform = Mo.Zero()), Mo.TransformToRef(e, r._pickWithRayInverseMatrix, r._cachedRayForTransform), r._cachedRayForTransform }), t, i) }, ln.prototype.getForwardRay = function (e, t, i) { return void 0 === e && (e = 100), this.getForwardRayToRef(new Mo(R.Zero(), R.Zero(), e), e, t, i) }, ln.prototype.getForwardRayToRef = function (e, t, i, r) { return void 0 === t && (t = 100), i || (i = this.getWorldMatrix()), e.length = t, r ? e.origin.copyFrom(r) : e.origin.copyFrom(this.position), O.Vector3[2].set(0, 0, this._scene.useRightHandedSystem ? -1 : 1), R.TransformNormalToRef(O.Vector3[2], i, O.Vector3[3]), R.NormalizeToRef(O.Vector3[3], e.direction), e }; var Oo = function () { function e() { } return e._RemoveAndStorePivotPoint = function (t) { t && 0 === e._PivotCached && (t.getPivotPointToRef(e._OldPivotPoint), e._PivotPostMultiplyPivotMatrix = t._postMultiplyPivotMatrix, e._OldPivotPoint.equalsToFloats(0, 0, 0) || (t.setPivotMatrix(I.IdentityReadOnly), e._OldPivotPoint.subtractToRef(t.getPivotPoint(), e._PivotTranslation), e._PivotTmpVector.copyFromFloats(1, 1, 1), e._PivotTmpVector.subtractInPlace(t.scaling), e._PivotTmpVector.multiplyInPlace(e._PivotTranslation), t.position.addInPlace(e._PivotTmpVector))), e._PivotCached++ }, e._RestorePivotPoint = function (t) { t && !e._OldPivotPoint.equalsToFloats(0, 0, 0) && 1 === e._PivotCached && (t.setPivotPoint(e._OldPivotPoint), t._postMultiplyPivotMatrix = e._PivotPostMultiplyPivotMatrix, e._PivotTmpVector.copyFromFloats(1, 1, 1), e._PivotTmpVector.subtractInPlace(t.scaling), e._PivotTmpVector.multiplyInPlace(e._PivotTranslation), t.position.subtractInPlace(e._PivotTmpVector)), this._PivotCached-- }, e._PivotCached = 0, e._OldPivotPoint = new R, e._PivotTranslation = new R, e._PivotTmpVector = new R, e._PivotPostMultiplyPivotMatrix = !1, e }(); function Do(e) { var t = [], i = [], r = [], n = [], o = e.width || e.size || 1, a = e.height || e.size || 1, s = 0 === e.sideOrientation ? 0 : e.sideOrientation || En.DEFAULTSIDE, l = o / 2, c = a / 2; i.push(-l, -c, 0), r.push(0, 0, -1), n.push(0, xn.UseOpenGLOrientationForUV ? 1 : 0), i.push(l, -c, 0), r.push(0, 0, -1), n.push(1, xn.UseOpenGLOrientationForUV ? 1 : 0), i.push(l, c, 0), r.push(0, 0, -1), n.push(1, xn.UseOpenGLOrientationForUV ? 0 : 1), i.push(-l, c, 0), r.push(0, 0, -1), n.push(0, xn.UseOpenGLOrientationForUV ? 0 : 1), t.push(0), t.push(1), t.push(2), t.push(0), t.push(2), t.push(3), En._ComputeSides(s, i, t, r, n, e.frontUVs, e.backUVs); var u = new En; return u.indices = t, u.positions = i, u.normals = r, u.uvs = n, u } function No(e, t, i) { void 0 === t && (t = {}), void 0 === i && (i = null); var r = new Jn(e, i); return t.sideOrientation = Jn._GetDefaultSideOrientation(t.sideOrientation), r._originalBuilderSideOrientation = t.sideOrientation, Do(t).applyToMesh(r, t.updatable), t.sourcePlane && (r.translate(t.sourcePlane.normal, -t.sourcePlane.d), r.setDirection(t.sourcePlane.normal.scale(-1))), r } var Fo = { CreatePlane: No }; En.CreatePlane = Do, Jn.CreatePlane = function (e, t, i, r, n) { return No(e, { size: t, width: t, height: t, sideOrientation: n, updatable: r }, i) }; var Lo, wo = function () { function e(e) { this._useAlternatePickedPointAboveMaxDragAngleDragSpeed = -1.1, this._activeDragButton = -1, this.maxDragAngle = 0, this.dragButtons = [0, 1, 2], this._useAlternatePickedPointAboveMaxDragAngle = !1, this.currentDraggingPointerId = -1, this.dragging = !1, this.dragDeltaRatio = .2, this.updateDragPlane = !0, this._debugMode = !1, this._moving = !1, this.onDragObservable = new u, this.onDragStartObservable = new u, this.onDragEndObservable = new u, this.onEnabledObservable = new u, this.moveAttached = !0, this._enabled = !0, this.startAndReleaseDragOnPointerEvents = !0, this.detachCameraControls = !0, this.useObjectOrientationForDragging = !0, this.validateDrag = function (e) { return !0 }, this._tmpVector = new R(0, 0, 0), this._alternatePickedPoint = new R(0, 0, 0), this._worldDragAxis = new R(0, 0, 0), this._targetPosition = new R(0, 0, 0), this._attachedToElement = !1, this._startDragRay = new Mo(new R, new R), this._lastPointerRay = {}, this._dragDelta = new R, this._pointA = new R(0, 0, 0), this._pointC = new R(0, 0, 0), this._localAxis = new R(0, 0, 0), this._lookAt = new R(0, 0, 0), this._options = e || {}; var t = 0; if (this._options.dragAxis && t++, this._options.dragPlaneNormal && t++, t > 1) 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 Sr(this._scene.getEngine(), { virtual: !0 }), e._PlaneScene.detachControl(), this._scene.onDisposeObservable.addOnce((function () { e._PlaneScene.dispose(), e._PlaneScene = null })))), this._dragPlane = No("pointerDragPlane", { size: this._debugMode ? 1 : 1e4, updatable: !1, sideOrientation: Jn.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 == Ji.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 == Ji.POINTERUP) !r.startAndReleaseDragOnPointerEvents || r.currentDraggingPointerId != t.event.pointerId || r._activeDragButton !== t.event.button && -1 !== r._activeDragButton || r.releaseDrag(); else if (t.type == Ji.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 Mo(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; Oo._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), Oo._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) { Oo._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(), Oo._RestorePivotPoint(this.attachedNode) } }, e.prototype._moveDrag = function (e) { this._moving = !0; var t = this._pickWithRayOnDragPlane(e); if (t) { Oo._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), Oo._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 }(), Bo = 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 wo({}), this._dragBehaviorA.moveAttached = !1, this._dragBehaviorB = new wo({}), 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 }(), Uo = 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 Ln("", e._virtualScene); t.rotationQuaternion = new P; var i = new Ln("", e._virtualScene); i.rotationQuaternion = new P; var r = new Ln("", 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; e < this.currentDraggingPointerIds.length; e++)this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].pivotMesh.position.copyFrom(this._ownerNode.getAbsolutePivotPoint()), this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].pivotMesh.rotationQuaternion.copyFrom(this._ownerNode.rotationQuaternion), this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].startingPivotPosition.copyFrom(this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].pivotMesh.position), this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].startingPivotOrientation.copyFrom(this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].pivotMesh.rotationQuaternion), this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].startingPosition.copyFrom(this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].dragMesh.position), this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].startingOrientation.copyFrom(this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].dragMesh.rotationQuaternion) }, e.prototype._pointerUpdate2D = function (e, t, i) { !this._pointerCamera || this._pointerCamera.cameraRigMode != ln.RIG_MODE_NONE || this._pointerCamera._isLeftCamera || this._pointerCamera._isRightCamera || (e.origin.copyFrom(this._pointerCamera.globalPosition), i = 0); var r = this._virtualMeshesInfo[t], n = O.Vector3[0]; e.origin.subtractToRef(r.lastOriginPosition, n), r.lastOriginPosition.copyFrom(e.origin); var o = -R.Dot(n, e.direction); r.originMesh.addChild(r.dragMesh), r.originMesh.addChild(r.pivotMesh), this._applyZOffset(r.dragMesh, o, i), this._applyZOffset(r.pivotMesh, o, i), r.originMesh.position.copyFrom(e.origin); var a = O.Vector3[0]; e.origin.addToRef(e.direction, a), r.originMesh.lookAt(a), r.originMesh.removeChild(r.dragMesh), r.originMesh.removeChild(r.pivotMesh) }, e.prototype._pointerUpdateXR = function (e, t, i, r) { var n = this._virtualMeshesInfo[i]; if (n.originMesh.position.copyFrom(e.position), this._dragging === this._dragType.NEAR_DRAG && t ? n.originMesh.rotationQuaternion.copyFrom(t.rotationQuaternion) : n.originMesh.rotationQuaternion.copyFrom(e.rotationQuaternion), n.pivotMesh.computeWorldMatrix(!0), n.dragMesh.computeWorldMatrix(!0), 0 !== r) { var o = O.Vector3[0], a = O.Vector3[1]; o.copyFrom(this._pointerCamera.getForwardRay().direction), n.originMesh.position.subtractToRef(n.lastOriginPosition, a), n.lastOriginPosition.copyFrom(n.originMesh.position); var s = a.length(); a.normalize(); var l = O.Vector3[2], c = O.Vector3[3]; n.dragMesh.absolutePosition.subtractToRef(this._pointerCamera.globalPosition, l), n.dragMesh.absolutePosition.subtractToRef(n.originMesh.position, c); var u = c.length(); l.normalize(), c.normalize(); var h = Math.abs(R.Dot(a, c)) * R.Dot(a, o) * r * s * u; h < 0 && .01 - u > h && (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 Sr(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 == Ji.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 !== ln.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 == Ji.POINTERUP || e.type == Ji.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 == Ji.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 }(), Vo = 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 On("virtual_sixDof", Uo._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), Er.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, Er.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 }(Uo), ko = 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) < this.maxStickingDistance && (this._workingPosition.copyFrom(i.position), this._workingQuaternion.copyFrom(i.quaternion), this._hit = !0) } return this._hit }, e.prototype._getAttachPointOffsetToRef = function (e) { if (this._attachedMesh) { var t = O.Quaternion[0]; t.copyFrom(this._attachedMesh.rotationQuaternion), this._attachedMesh.rotationQuaternion.copyFromFloats(0, 0, 0, 1), this._attachedMesh.computeWorldMatrix(); var i = this._attachedMesh.getHierarchyBoundingVectors(), r = O.Vector3[0]; i.max.addToRef(i.min, r), r.scaleInPlace(.5), r.z = i.max.z; var n = O.Matrix[0]; this._attachedMesh.getWorldMatrix().invertToRef(n), R.TransformCoordinatesToRef(r, n, e), this._attachedMesh.rotationQuaternion.copyFrom(t) } else e.setAll(0) }, e.prototype._updateTransformToGoal = function (e) { if (this._attachedMesh && this._hit) { var t = this._attachedMesh.parent; this._attachedMesh.setParent(null); var i = O.Vector3[0]; if (R.TransformNormalToRef(this._attachPointLocalOffset, this._attachedMesh.getWorldMatrix(), i), !this.interpolatePose) return this._attachedMesh.position.copyFrom(this._workingPosition).subtractInPlace(i), void this._attachedMesh.rotationQuaternion.copyFrom(this._workingQuaternion); var r = new R; R.SmoothToRef(this._attachedMesh.position, this._workingPosition, e, this.lerpTime, r), this._attachedMesh.position.copyFrom(r); var n = new P; n.copyFrom(this._attachedMesh.rotationQuaternion), P.SmoothToRef(n, this._workingQuaternion, e, this.lerpTime, this._attachedMesh.rotationQuaternion), this._attachedMesh.setParent(t) } }, e.prototype._addObservables = function () { var e = this; this._pointerObserver = this._scene.onPointerObservable.add((function (t) { e.enabled && t.type == Ji.POINTERMOVE && t.pickInfo && e.findAndUpdateTarget(t.pickInfo) })), this._lastTick = Date.now(), this._onBeforeRender = this._scene.onBeforeRenderObservable.add((function () { var t = Date.now(); e._updateTransformToGoal(t - e._lastTick), e._lastTick = t })) }, e.prototype._removeObservables = function () { this._scene.onPointerObservable.remove(this._pointerObserver), this._scene.onBeforeRenderObservable.remove(this._onBeforeRender), this._pointerObserver = null, this._onBeforeRender = null }, e }(), Go = function () { function e() { this._tmpQuaternion = new P, this._tmpVectors = [new R, new R, new R, new R, new R, new R, new R], this._tmpMatrix = new I, this._tmpInvertView = new I, this._tmpForward = new R, this._tmpNodeForward = new R, this._tmpPosition = new R, this._workingPosition = new R, this._workingQuaternion = new P, this._lastTick = -1, this._recenterNextUpdate = !0, this.interpolatePose = !0, this.lerpTime = 500, this.ignoreCameraPitchAndRoll = !1, this.pitchOffset = 15, this.maxViewVerticalDegrees = 30, this.maxViewHorizontalDegrees = 30, this.orientToCameraDeadzoneDegrees = 60, this.ignoreDistanceClamp = !1, this.ignoreAngleClamp = !1, this.verticalMaxDistance = 0, this.defaultDistance = .8, this.maximumDistance = 2, this.minimumDistance = .3, this.useFixedVerticalOffset = !1, this.fixedVerticalOffset = 0, this._enabled = !0 } return Object.defineProperty(e.prototype, "followedCamera", { get: function () { return this._followedCamera || this._scene.activeCamera }, set: function (e) { this._followedCamera = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "name", { get: function () { return "Follow" }, enumerable: !1, configurable: !0 }), e.prototype.init = function () { }, e.prototype.attach = function (e, t) { this._scene = e.getScene(), this.attachedNode = e, t && (this.followedCamera = t), this._addObservables() }, e.prototype.detach = function () { this.attachedNode = null, this._removeObservables() }, e.prototype.recenter = function () { this._recenterNextUpdate = !0 }, e.prototype._angleBetweenVectorAndPlane = function (e, t) { return this._tmpVectors[0].copyFrom(e), e = this._tmpVectors[0], this._tmpVectors[1].copyFrom(t), t = this._tmpVectors[1], e.normalize(), t.normalize(), Math.PI / 2 - Math.acos(R.Dot(e, t)) }, e.prototype._length2D = function (e) { return Math.sqrt(e.x * e.x + e.z * e.z) }, e.prototype._distanceClamp = function (e, t) { void 0 === t && (t = !1); var i = this.minimumDistance, r = this.maximumDistance, n = this.defaultDistance, o = this._tmpVectors[0]; o.copyFrom(e); var a = o.length(); if (o.normalizeFromLength(a), this.ignoreCameraPitchAndRoll) { i = this._length2D(o) * i, r = this._length2D(o) * r; var s = this._length2D(e); o.scaleInPlace(a / s), a = s } var l; return l = t ? n : h.Clamp(a, i, r), e.copyFrom(o).scaleInPlace(l), a !== l }, e.prototype._applyVerticalClamp = function (e) { 0 !== this.verticalMaxDistance && (e.y = h.Clamp(e.y, -this.verticalMaxDistance, this.verticalMaxDistance)) }, e.prototype._toOrientationQuatToRef = function (e, t) { P.RotationYawPitchRollToRef(Math.atan2(e.x, e.z), Math.atan2(e.y, Math.sqrt(e.z * e.z + e.x * e.x)), 0, t) }, e.prototype._applyPitchOffset = function (e) { var t = this._tmpVectors[0], i = this._tmpVectors[1]; t.copyFromFloats(0, 0, this._scene.useRightHandedSystem ? -1 : 1), i.copyFromFloats(1, 0, 0), R.TransformNormalToRef(t, e, t), t.y = 0, t.normalize(), R.TransformNormalToRef(i, e, i), P.RotationAxisToRef(i, this.pitchOffset * Math.PI / 180, this._tmpQuaternion), t.rotateByQuaternionToRef(this._tmpQuaternion, t), this._toOrientationQuatToRef(t, this._tmpQuaternion), this._tmpQuaternion.toRotationMatrix(this._tmpMatrix), e.copyFrom(this._tmpMatrix) }, e.prototype._angularClamp = function (e, t) { var i = this._tmpVectors[5]; i.copyFromFloats(0, 0, this._scene.useRightHandedSystem ? -1 : 1); var r = this._tmpVectors[6]; r.copyFromFloats(1, 0, 0), R.TransformNormalToRef(i, e, i), R.TransformNormalToRef(r, e, r); var n = R.UpReadOnly; if (t.length() < _) return !1; var o = !1, a = this._tmpQuaternion; if (this.ignoreCameraPitchAndRoll) { var s = R.GetAngleBetweenVectorsOnPlane(t, i, r); P.RotationAxisToRef(r, s, a), t.rotateByQuaternionToRef(a, t) } else { var l = -R.GetAngleBetweenVectorsOnPlane(t, i, r), c = this.maxViewVerticalDegrees * Math.PI / 180 * .5; l < -c ? (P.RotationAxisToRef(r, -l - c, a), t.rotateByQuaternionToRef(a, t), o = !0) : l > 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 }(), zo = 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 }(), Wo = 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 xi.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 i < r.length ? (n = r[i], o = this._features[n], (a = o.featureImplementation.xrNativeFeatureName) && (o.required ? (e.requiredFeatures = e.requiredFeatures || [], -1 === e.requiredFeatures.indexOf(a) && e.requiredFeatures.push(a)) : (e.optionalFeatures = e.optionalFeatures || [], -1 === e.optionalFeatures.indexOf(a) && e.optionalFeatures.push(a))), o.featureImplementation.getXRSessionInitExtension ? [4, o.featureImplementation.getXRSessionInitExtension()] : [3, 3]) : [3, 4]; case 2: s = l.sent(), e = H(H({}, e), s), l.label = 3; case 3: return i++, [3, 1]; case 4: return [2, e] } })) })) }, e._AvailableFeatures = {}, e._ConflictingFeatures = ((Lo = {})[zo.TELEPORTATION] = zo.MOVEMENT, Lo[zo.MOVEMENT] = zo.TELEPORTATION, Lo), e }(), Ho = function () { function e(e) { this._xrSessionManager = e, this._attached = !1, this._removeOnDetach = [], this.isDisposed = !1, this.disableAutoAttach = !1, this.xrNativeFeatureName = "" } return Object.defineProperty(e.prototype, "attached", { get: function () { return this._attached }, enumerable: !1, configurable: !0 }), e.prototype.attach = function (e) { var t = this; if (this.isDisposed) return !1; if (e) this.attached && this.detach(); else if (this.attached) return !1; return this._attached = !0, this._addNewAttachObserver(this._xrSessionManager.onXRFrameObservable, (function (e) { return t._onXRFrame(e) })), !0 }, e.prototype.detach = function () { return this._attached ? (this._attached = !1, this._removeOnDetach.forEach((function (e) { e.observable.remove(e.observer) })), !0) : (this.disableAutoAttach = !0, !1) }, e.prototype.dispose = function () { this.detach(), this.isDisposed = !0 }, e.prototype.isCompatible = function () { return !0 }, e.prototype._addNewAttachObserver = function (e, t) { this._removeOnDetach.push({ observable: e, observer: e.add(t) }) }, e }(), Xo = function () { function e(e, t) { this.type = e, this.jointData = t, t.nativeParams = t.nativeParams || {} } return Object.defineProperty(e.prototype, "physicsJoint", { get: function () { return this._physicsJoint }, set: function (e) { this._physicsJoint, this._physicsJoint = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "physicsPlugin", { set: function (e) { this._physicsPlugin = e }, enumerable: !1, configurable: !0 }), e.prototype.executeNativeFunction = function (e) { e(this._physicsPlugin.world, this._physicsJoint) }, e.DistanceJoint = 0, e.HingeJoint = 1, e.BallAndSocketJoint = 2, e.WheelJoint = 3, e.SliderJoint = 4, e.PrismaticJoint = 5, e.UniversalJoint = 6, e.Hinge2Joint = e.WheelJoint, e.PointToPointJoint = 8, e.SpringJoint = 9, e.LockJoint = 10, e }(), jo = function (e) { function t(t) { return e.call(this, Xo.DistanceJoint, t) || this } return W(t, e), t.prototype.updateDistance = function (e, t) { this._physicsPlugin.updateDistanceJoint(this, e, t) }, t }(Xo), Yo = function (e) { function t(t, i) { return e.call(this, t, i) || this } return W(t, e), t.prototype.setMotor = function (e, t) { this._physicsPlugin.setMotor(this, e || 0, t) }, t.prototype.setLimit = function (e, t) { this._physicsPlugin.setLimit(this, e, t) }, t }(Xo), Ko = function (e) { function t(t) { return e.call(this, Xo.HingeJoint, t) || this } return W(t, e), t.prototype.setMotor = function (e, t) { this._physicsPlugin.setMotor(this, e || 0, t) }, t.prototype.setLimit = function (e, t) { this._physicsPlugin.setLimit(this, e, t) }, t }(Yo), Qo = function (e) { function t(t) { return e.call(this, Xo.Hinge2Joint, t) || this } return W(t, e), t.prototype.setMotor = function (e, t, i) { void 0 === i && (i = 0), this._physicsPlugin.setMotor(this, e || 0, t, i) }, t.prototype.setLimit = function (e, t, i) { void 0 === i && (i = 0), this._physicsPlugin.setLimit(this, e, t, i) }, t }(Yo); Jn._PhysicsImpostorParser = function (e, t, i) { return new Zo(t, i.physicsImpostor, { mass: i.physicsMass, friction: i.physicsFriction, restitution: i.physicsRestitution }, e) }; var qo, Zo = function () { function e(t, i, r, n) { void 0 === r && (r = { mass: 0 }); var o = this; this.object = t, this.type = i, this._options = r, this._scene = n, this._pluginData = {}, this._bodyUpdateRequired = !1, this._onBeforePhysicsStepCallbacks = new Array, this._onAfterPhysicsStepCallbacks = new Array, this._onPhysicsCollideCallbacks = [], this._deltaPosition = R.Zero(), this._isDisposed = !1, this.soft = !1, this.segments = 0, this._tmpQuat = new P, this._tmpQuat2 = new P, this.beforeStep = function () { o._physicsEngine && (o.object.translate(o._deltaPosition, -1), o._deltaRotationConjugated && o.object.rotationQuaternion && o.object.rotationQuaternion.multiplyToRef(o._deltaRotationConjugated, o.object.rotationQuaternion), o.object.computeWorldMatrix(!1), o.object.parent && o.object.rotationQuaternion ? (o.getParentsRotation(), o._tmpQuat.multiplyToRef(o.object.rotationQuaternion, o._tmpQuat)) : o._tmpQuat.copyFrom(o.object.rotationQuaternion || new P), o._options.disableBidirectionalTransformation || o.object.rotationQuaternion && o._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(o, o.object.getAbsolutePosition(), o._tmpQuat), o._onBeforePhysicsStepCallbacks.forEach((function (e) { e(o) }))) }, this.afterStep = function () { o._physicsEngine && (o._onAfterPhysicsStepCallbacks.forEach((function (e) { e(o) })), o._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(o), o.object.parent && o.object.rotationQuaternion && (o.getParentsRotation(), o._tmpQuat.conjugateInPlace(), o._tmpQuat.multiplyToRef(o.object.rotationQuaternion, o.object.rotationQuaternion)), o.object.setAbsolutePosition(o.object.position), o._deltaRotation ? (o.object.rotationQuaternion && o.object.rotationQuaternion.multiplyToRef(o._deltaRotation, o.object.rotationQuaternion), o._deltaPosition.applyRotationQuaternionToRef(o._deltaRotation, e._TmpVecs[0]), o.object.translate(e._TmpVecs[0], 1)) : o.object.translate(o._deltaPosition, 1), o.object.computeWorldMatrix(!0)) }, this.onCollideEvent = null, this.onCollide = function (e) { if ((o._onPhysicsCollideCallbacks.length || o.onCollideEvent) && o._physicsEngine) { var t = o._physicsEngine.getImpostorWithPhysicsBody(e.body); t && (o.onCollideEvent && o.onCollideEvent(o, t), o._onPhysicsCollideCallbacks.filter((function (e) { return -1 !== e.otherImpostors.indexOf(t) })).forEach((function (i) { i.callback(o, t, e.point, e.distance, e.impulse, e.normal) }))) } }, this.object ? (this.object.parent && 0 !== r.mass && $.Warn("A physics impostor has been created for an object which has a parent. Babylon physics currently works in local space so unexpected issues may occur."), !this._scene && t.getScene && (this._scene = t.getScene()), this._scene && (this.type > 100 && (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 Ln ? 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 Xo(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, Er.WORLD, i) } else t.setRotationQuaternion(s.rotationQuaternion, Er.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(Er.WORLD, i, l), l.multiplyToRef(o, s.rotationQuaternion) } else t.getRotationQuaternionToRef(Er.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" }(qo || (qo = {})); var Jo, $o, ea = function () { function e() { } return Object.defineProperty(e, "ForceFullSceneLoadingForIncremental", { get: function () { return Sn.ForceFullSceneLoadingForIncremental }, set: function (e) { Sn.ForceFullSceneLoadingForIncremental = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "ShowLoadingScreen", { get: function () { return Sn.ShowLoadingScreen }, set: function (e) { Sn.ShowLoadingScreen = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "loggingLevel", { get: function () { return Sn.loggingLevel }, set: function (e) { Sn.loggingLevel = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "CleanBoneMatrixWeights", { get: function () { return Sn.CleanBoneMatrixWeights }, set: function (e) { Sn.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) || !_i(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 < S.length; E++)if (S[E].test(t.url)) { T = !0; break } b = !T } return b && In.OfflineProviderFactory ? i.offlineProvider = In.OfflineProviderFactory(t.url, v, y.disableManifestCheck) : v(), u }, e._GetFileInfo = function (e, t) { var i, r, n = null, o = null; if (t) if (t.name) { var a = t; i = "file:".concat(a.name), r = a.name, n = a } else if (ArrayBuffer.isView(t)) i = "", r = "arrayBuffer", o = t; else if ("string" == typeof t && t.startsWith("data:")) i = t, r = ""; else { var s = t; if ("/" === s.substr(0, 1)) return xi.Error("Wrong sceneFilename parameter"), null; i = e + s, r = s } else i = e, r = xi.GetFilename(e), e = xi.GetFolderPath(e); return { url: i, rootUrl: e, name: r, file: n, rawData: o } }, e.GetPluginForExtension = function (t) { return e._GetPluginForExtension(t).plugin }, e.IsPluginForExtensionAvailable = function (t) { return !!e._RegisteredPlugins[t] }, e.RegisterPlugin = function (t) { if ("string" == typeof t.extensions) { var i = t.extensions; e._RegisteredPlugins[i.toLowerCase()] = { plugin: t, isBinary: !1 } } else { var r = t.extensions; Object.keys(r).forEach((function (i) { e._RegisteredPlugins[i.toLowerCase()] = { plugin: t, isBinary: r[i].isBinary } })) } }, e.ImportMesh = function (t, i, r, n, o, a, s, l, c) { if (void 0 === r && (r = ""), void 0 === n && (n = S.LastCreatedScene), void 0 === o && (o = null), void 0 === a && (a = null), void 0 === s && (s = null), void 0 === l && (l = null), void 0 === c && (c = ""), !n) return $.Error("No scene available to import mesh to"), null; var u = e._GetFileInfo(i, r); if (!u) return null; var h = {}; n.addPendingData(h); var d = function () { n.removePendingData(h) }, p = function (t, i) { var r = e._FormatErrorMessage(u, t, i); s ? s(n, r, new ht(r, ut.SceneLoaderError, i)) : $.Error(r), d() }, f = a ? function (e) { try { a(e) } catch (e) { p("Error in onProgress callback: " + e, e) } } : void 0, _ = function (e, t, i, r, a, s, l) { if (n.importedMeshesFiles.push(u.url), o) try { o(e, t, i, r, a, s, l) } catch (e) { p("Error in onSuccess callback: " + e, e) } n.removePendingData(h) }; return e._LoadData(u, n, (function (e, i, r) { if (e.rewriteRootURL && (u.rootUrl = e.rewriteRootURL(u.rootUrl, r)), e.importMesh) { var o = e, a = new Array, s = new Array, l = new Array; if (!o.importMesh(t, n, i, u.rootUrl, a, s, l, p)) return; n.loadingPluginName = e.name, _(a, s, l, [], [], [], []) } else e.importMeshAsync(t, n, i, u.rootUrl, f, u.name).then((function (t) { n.loadingPluginName = e.name, _(t.meshes, t.particleSystems, t.skeletons, t.animationGroups, t.transformNodes, t.geometries, t.lights) })).catch((function (e) { p(e.message, e) })) }), f, p, d, l, c) }, e.ImportMeshAsync = function (t, i, r, n, o, a, s) { return void 0 === r && (r = ""), void 0 === n && (n = S.LastCreatedScene), void 0 === o && (o = null), void 0 === a && (a = null), void 0 === s && (s = ""), new Promise((function (l, c) { e.ImportMesh(t, i, r, n, (function (e, t, i, r, n, o, a) { l({ meshes: e, particleSystems: t, skeletons: i, animationGroups: r, transformNodes: n, geometries: o, lights: a }) }), o, (function (e, t, i) { c(i || new Error(t)) }), a, s) })) }, e.Load = function (t, i, r, n, o, a, s, l) { return void 0 === i && (i = ""), void 0 === r && (r = S.LastCreatedEngine), void 0 === n && (n = null), void 0 === o && (o = null), void 0 === a && (a = null), void 0 === s && (s = null), void 0 === l && (l = ""), r ? e.Append(t, i, new Sr(r), n, o, a, s, l) : (xi.Error("No engine available"), null) }, e.LoadAsync = function (t, i, r, n, o, a) { return void 0 === i && (i = ""), void 0 === r && (r = S.LastCreatedEngine), void 0 === n && (n = null), void 0 === o && (o = null), void 0 === a && (a = ""), new Promise((function (s, l) { e.Load(t, i, r, (function (e) { s(e) }), n, (function (e, t, i) { l(i || new Error(t)) }), o, a) })) }, e.Append = function (t, i, r, n, o, a, s, l) { var c = this; if (void 0 === i && (i = ""), void 0 === r && (r = S.LastCreatedScene), void 0 === n && (n = null), void 0 === o && (o = null), void 0 === a && (a = null), void 0 === s && (s = null), void 0 === l && (l = ""), !r) return $.Error("No scene available to append to"), null; var u = e._GetFileInfo(t, i); if (!u) return null; var h = {}; r.addPendingData(h); var d = function () { r.removePendingData(h) }; e.ShowLoadingScreen && !this._ShowingLoadingScreen && (this._ShowingLoadingScreen = !0, r.getEngine().displayLoadingUI(), r.executeWhenReady((function () { r.getEngine().hideLoadingUI(), c._ShowingLoadingScreen = !1 }))); var p = function (t, i) { var n = e._FormatErrorMessage(u, t, i); a ? a(r, n, new ht(n, ut.SceneLoaderError, i)) : $.Error(n), d() }, f = o ? function (e) { try { o(e) } catch (e) { p("Error in onProgress callback", e) } } : void 0, _ = function () { if (n) try { n(r) } catch (e) { p("Error in onSuccess callback", e) } r.removePendingData(h) }; return e._LoadData(u, r, (function (e, t) { if (e.load) { if (!e.load(r, t, u.rootUrl, p)) return; r.loadingPluginName = e.name, _() } else e.loadAsync(r, t, u.rootUrl, f, u.name).then((function () { r.loadingPluginName = e.name, _() })).catch((function (e) { p(e.message, e) })) }), f, p, d, s, l) }, e.AppendAsync = function (t, i, r, n, o, a) { return void 0 === i && (i = ""), void 0 === r && (r = S.LastCreatedScene), void 0 === n && (n = null), void 0 === o && (o = null), void 0 === a && (a = ""), new Promise((function (s, l) { e.Append(t, i, r, (function (e) { s(e) }), n, (function (e, t, i) { l(i || new Error(t)) }), o, a) })) }, e.LoadAssetContainer = function (t, i, r, n, o, a, s, l) { if (void 0 === i && (i = ""), void 0 === r && (r = S.LastCreatedScene), void 0 === n && (n = null), void 0 === o && (o = null), void 0 === a && (a = null), void 0 === s && (s = null), void 0 === l && (l = ""), !r) return $.Error("No scene available to load asset container to"), null; var c = e._GetFileInfo(t, i); if (!c) return null; var u = {}; r.addPendingData(u); var h = function () { r.removePendingData(u) }, d = function (t, i) { var n = e._FormatErrorMessage(c, t, i); a ? a(r, n, new ht(n, ut.SceneLoaderError, i)) : $.Error(n), h() }, p = o ? function (e) { try { o(e) } catch (e) { d("Error in onProgress callback", e) } } : void 0, f = function (e) { if (n) try { n(e) } catch (e) { d("Error in onSuccess callback", e) } r.removePendingData(u) }; return e._LoadData(c, r, (function (e, t) { if (e.loadAssetContainer) { var i = e.loadAssetContainer(r, t, c.rootUrl, d); if (!i) return; i.populateRootNodes(), r.loadingPluginName = e.name, f(i) } else e.loadAssetContainerAsync ? e.loadAssetContainerAsync(r, t, c.rootUrl, p, c.name).then((function (t) { t.populateRootNodes(), r.loadingPluginName = e.name, f(t) })).catch((function (e) { d(e.message, e) })) : d("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.") }), p, d, h, s, l) }, e.LoadAssetContainerAsync = function (t, i, r, n, o) { return void 0 === i && (i = ""), void 0 === r && (r = S.LastCreatedScene), void 0 === n && (n = null), void 0 === o && (o = null), new Promise((function (a, s) { e.LoadAssetContainer(t, i, r, (function (e) { a(e) }), n, (function (e, t, i) { s(i || new Error(t)) }), o) })) }, e.ImportAnimations = function (e, t, i, r, n, o, a, s, l, c) { if (void 0 === t && (t = ""), void 0 === i && (i = S.LastCreatedScene), void 0 === r && (r = !0), void 0 === n && (n = qo.Clean), void 0 === o && (o = null), void 0 === a && (a = null), void 0 === s && (s = null), void 0 === l && (l = null), void 0 === c && (c = null), i) { if (r) { for (var u = 0, h = i.animatables; u < h.length; u++)h[u].reset(); i.stopAllAnimations(), i.animationGroups.slice().forEach((function (e) { e.dispose() })), i.getNodes().forEach((function (e) { e.animations && (e.animations = []) })) } else switch (n) { case qo.Clean: i.animationGroups.slice().forEach((function (e) { e.dispose() })); break; case qo.Stop: i.animationGroups.forEach((function (e) { e.stop() })); break; case qo.Sync: i.animationGroups.forEach((function (e) { e.reset(), e.restart() })); break; case qo.NoSync: break; default: return void $.Error("Unknown animation group loading mode value '" + n + "'") }var d = i.animatables.length; this.LoadAssetContainer(e, t, i, (function (e) { e.mergeAnimationsTo(i, i.animatables.slice(d), o), e.dispose(), i.onAnimationFileImportedObservable.notifyObservers(i), a && a(i) }), s, l, c) } else $.Error("No scene available to load animations to") }, e.ImportAnimationsAsync = function (t, i, r, n, o, a, s, l, c, u) { return void 0 === i && (i = ""), void 0 === r && (r = S.LastCreatedScene), void 0 === n && (n = !0), void 0 === o && (o = qo.Clean), void 0 === a && (a = null), void 0 === s && (s = null), void 0 === l && (l = null), void 0 === c && (c = null), void 0 === u && (u = null), new Promise((function (s, c) { e.ImportAnimations(t, i, r, n, o, a, (function (e) { s(e) }), l, (function (e, t, i) { c(i || new Error(t)) }), u) })) }, e.NO_LOGGING = a.SCENELOADER_NO_LOGGING, e.MINIMAL_LOGGING = a.SCENELOADER_MINIMAL_LOGGING, e.SUMMARY_LOGGING = a.SCENELOADER_SUMMARY_LOGGING, e.DETAILED_LOGGING = a.SCENELOADER_DETAILED_LOGGING, e.OnPluginActivatedObservable = new u, e._RegisteredPlugins = {}, e._ShowingLoadingScreen = !1, e }(), ta = function (e) { function t(t, i, r) { void 0 === r && (r = !0); var n = e.call(this, t, i) || this; return n._normalMatrix = new I, n._storeEffectOnSubMeshes = r, n } return W(t, e), t.prototype.getEffect = function () { return this._storeEffectOnSubMeshes ? this._activeEffect : e.prototype.getEffect.call(this) }, t.prototype.isReady = function (e, t) { return !!e && (!this._storeEffectOnSubMeshes || !e.subMeshes || 0 === e.subMeshes.length || this.isReadyForSubMesh(e, e.subMeshes[0], t)) }, t.prototype._isReadyForSubMesh = function (e) { var t = e.materialDefines; return !(this.checkReadyOnEveryCall || !e.effect || !t || t._renderId !== this.getScene().getRenderId()) }, t.prototype.bindOnlyWorldMatrix = function (e) { this._activeEffect.setMatrix("world", e) }, t.prototype.bindOnlyNormalMatrix = function (e) { this._activeEffect.setMatrix("normalMatrix", e) }, t.prototype.bind = function (e, t) { t && this.bindForSubMesh(e, t, t.subMeshes[0]) }, t.prototype._afterBind = function (t, i) { void 0 === i && (i = null), e.prototype._afterBind.call(this, t, i), this.getScene()._cachedEffect = i, i && (i._forceRebindOnNextCall = !1) }, t.prototype._mustRebind = function (e, t, i) { return void 0 === i && (i = 1), e.isCachedMaterialInvalid(this, t, i) }, t.prototype.dispose = function (t, i, r) { this._activeEffect = void 0, e.prototype.dispose.call(this, t, i, r) }, t }(Hn); !function (e) { e[e.Float = 1] = "Float", e[e.Int = 2] = "Int", e[e.Vector2 = 4] = "Vector2", e[e.Vector3 = 8] = "Vector3", e[e.Vector4 = 16] = "Vector4", e[e.Color3 = 32] = "Color3", e[e.Color4 = 64] = "Color4", e[e.Matrix = 128] = "Matrix", e[e.Object = 256] = "Object", e[e.AutoDetect = 1024] = "AutoDetect", e[e.BasedOnInput = 2048] = "BasedOnInput", e[e.All = 4095] = "All" }(Jo || (Jo = {})), function (e) { e[e.Vertex = 1] = "Vertex", e[e.Fragment = 2] = "Fragment", e[e.Neutral = 4] = "Neutral", e[e.VertexAndFragment = 3] = "VertexAndFragment" }($o || ($o = {})); var ia, ra, na = function () { function e() { this.supportUniformBuffers = !1, this.attributes = new Array, this.uniforms = new Array, this.constants = new Array, this.samplers = new Array, this.functions = {}, this.extensions = {}, this.counters = {}, this._attributeDeclaration = "", this._uniformDeclaration = "", this._constantDeclaration = "", this._samplerDeclaration = "", this._varyingTransfer = "", this._injectAtEnd = "", this._repeatableContentAnchorIndex = 0, this._builtCompilationString = "", this.compilationString = "" } return e.prototype.finalize = function (e) { var t = e.sharedData.emitComments, i = this.target === $o.Fragment; this.compilationString = "\n".concat(t ? "//Entry point\n" : "", "void main(void) {\n").concat(this.compilationString), this._constantDeclaration && (this.compilationString = "\n".concat(t ? "//Constants\n" : "").concat(this._constantDeclaration, "\n").concat(this.compilationString)); var r = ""; for (var n in this.functions) r += this.functions[n] + "\n"; for (var o in this.compilationString = "\n".concat(r, "\n").concat(this.compilationString), !i && this._varyingTransfer && (this.compilationString = "".concat(this.compilationString, "\n").concat(this._varyingTransfer)), this._injectAtEnd && (this.compilationString = "".concat(this.compilationString, "\n").concat(this._injectAtEnd)), this.compilationString = "".concat(this.compilationString, "\n}"), this.sharedData.varyingDeclaration && (this.compilationString = "\n".concat(t ? "//Varyings\n" : "").concat(this.sharedData.varyingDeclaration, "\n").concat(this.compilationString)), this._samplerDeclaration && (this.compilationString = "\n".concat(t ? "//Samplers\n" : "").concat(this._samplerDeclaration, "\n").concat(this.compilationString)), this._uniformDeclaration && (this.compilationString = "\n".concat(t ? "//Uniforms\n" : "").concat(this._uniformDeclaration, "\n").concat(this.compilationString)), this._attributeDeclaration && !i && (this.compilationString = "\n".concat(t ? "//Attributes\n" : "").concat(this._attributeDeclaration, "\n").concat(this.compilationString)), this.compilationString = "precision highp float;\n" + this.compilationString, this.compilationString = "#if defined(WEBGL2) || defines(WEBGPU)\nprecision highp sampler2DArray;\n#endif\n" + this.compilationString, this.extensions) { var a = this.extensions[o]; this.compilationString = "\n".concat(a, "\n").concat(this.compilationString) } this._builtCompilationString = this.compilationString }, Object.defineProperty(e.prototype, "_repeatableContentAnchor", { get: function () { return "###___ANCHOR".concat(this._repeatableContentAnchorIndex++, "___###") }, enumerable: !1, configurable: !0 }), e.prototype._getFreeVariableName = function (e) { return e = e.replace(/[^a-zA-Z_]+/g, ""), void 0 === this.sharedData.variableNames[e] ? (this.sharedData.variableNames[e] = 0, "output" === e || "texture" === e ? e + this.sharedData.variableNames[e] : e) : (this.sharedData.variableNames[e]++, e + this.sharedData.variableNames[e]) }, e.prototype._getFreeDefineName = function (e) { return void 0 === this.sharedData.defineNames[e] ? this.sharedData.defineNames[e] = 0 : this.sharedData.defineNames[e]++, e + this.sharedData.defineNames[e] }, e.prototype._excludeVariableName = function (e) { this.sharedData.variableNames[e] = 0 }, e.prototype._emit2DSampler = function (e) { this.samplers.indexOf(e) < 0 && (this._samplerDeclaration += "uniform sampler2D ".concat(e, ";\n"), this.samplers.push(e)) }, e.prototype._emit2DArraySampler = function (e) { this.samplers.indexOf(e) < 0 && (this._samplerDeclaration += "uniform sampler2DArray ".concat(e, ";\n"), this.samplers.push(e)) }, e.prototype._getGLType = function (e) { switch (e) { case Jo.Float: return "float"; case Jo.Int: return "int"; case Jo.Vector2: return "vec2"; case Jo.Color3: case Jo.Vector3: return "vec3"; case Jo.Color4: case Jo.Vector4: return "vec4"; case Jo.Matrix: return "mat4" }return "" }, e.prototype._emitExtension = function (e, t, i) { void 0 === i && (i = ""), this.extensions[e] || (i && (t = "#if ".concat(i, "\n").concat(t, "\n#endif")), this.extensions[e] = t) }, e.prototype._emitFunction = function (e, t, i) { this.functions[e] || (this.sharedData.emitComments && (t = i + "\n" + t), this.functions[e] = t) }, e.prototype._emitCodeFromInclude = function (e, t, i) { if (i && i.repeatKey) return "#include<".concat(e, ">").concat(i.substitutionVars ? "(" + i.substitutionVars + ")" : "", "[0..").concat(i.repeatKey, "]\n"); var r = Vt.IncludesShadersStore[e] + "\n"; if (this.sharedData.emitComments && (r = t + "\n" + r), !i) return r; if (i.replaceStrings) for (var n = 0; n < i.replaceStrings.length; n++) { var o = i.replaceStrings[n]; r = r.replace(o.search, o.replace) } return r }, e.prototype._emitFunctionFromInclude = function (e, t, i, r) { void 0 === r && (r = ""); var n = e + r; if (!this.functions[n]) { if (!i || !(i.removeAttributes || i.removeUniforms || i.removeVaryings || i.removeIfDef || i.replaceStrings)) return i && i.repeatKey ? this.functions[n] = "#include<".concat(e, ">").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] = Vt.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; o < i.replaceStrings.length; o++) { var a = i.replaceStrings[o]; this.functions[n] = this.functions[n].replace(a.search, a.replace) } } }, e.prototype._registerTempVariable = function (e) { return -1 === this.sharedData.temps.indexOf(e) && (this.sharedData.temps.push(e), !0) }, e.prototype._emitVaryingFromString = function (e, t, i, r) { return void 0 === i && (i = ""), void 0 === r && (r = !1), -1 === this.sharedData.varyings.indexOf(e) && (this.sharedData.varyings.push(e), i && (i.startsWith("defined(") ? this.sharedData.varyingDeclaration += "#if ".concat(i, "\n") : this.sharedData.varyingDeclaration += "".concat(r ? "#ifndef" : "#ifdef", " ").concat(i, "\n")), this.sharedData.varyingDeclaration += "varying ".concat(t, " ").concat(e, ";\n"), i && (this.sharedData.varyingDeclaration += "#endif\n"), !0) }, e.prototype._emitUniformFromString = function (e, t, i, r) { void 0 === i && (i = ""), void 0 === r && (r = !1), -1 === this.uniforms.indexOf(e) && (this.uniforms.push(e), i && (i.startsWith("defined(") ? this._uniformDeclaration += "#if ".concat(i, "\n") : this._uniformDeclaration += "".concat(r ? "#ifndef" : "#ifdef", " ").concat(i, "\n")), this._uniformDeclaration += "uniform ".concat(t, " ").concat(e, ";\n"), i && (this._uniformDeclaration += "#endif\n")) }, e.prototype._emitFloat = function (e) { return e.toString() === e.toFixed(0) ? "".concat(e, ".0") : e.toString() }, e }(), oa = function () { function e() { this.temps = new Array, this.varyings = new Array, this.varyingDeclaration = "", this.inputBlocks = new Array, this.textureBlocks = new Array, this.bindableBlocks = new Array, this.forcedBindableBlocks = new Array, this.blocksWithFallbacks = new Array, this.blocksWithDefines = new Array, this.repeatableContentBlocks = new Array, this.dynamicUniformBlocks = new Array, this.blockingBlocks = new Array, this.animatedInputs = new Array, this.variableNames = {}, this.defineNames = {}, this.hints = { needWorldViewMatrix: !1, needWorldViewProjectionMatrix: !1, needAlphaBlending: !1, needAlphaTesting: !1 }, this.checks = { emitVertex: !1, emitFragment: !1, notConnectedNonOptionalInputs: new Array }, this.allowEmptyVertexProgram = !1, this.variableNames.position = 0, this.variableNames.normal = 0, this.variableNames.tangent = 0, this.variableNames.uv = 0, this.variableNames.uv2 = 0, this.variableNames.uv3 = 0, this.variableNames.uv4 = 0, this.variableNames.uv5 = 0, this.variableNames.uv6 = 0, this.variableNames.color = 0, this.variableNames.matricesIndices = 0, this.variableNames.matricesWeights = 0, this.variableNames.matricesIndicesExtra = 0, this.variableNames.matricesWeightsExtra = 0, this.variableNames.diffuseBase = 0, this.variableNames.specularBase = 0, this.variableNames.worldPos = 0, this.variableNames.shadow = 0, this.variableNames.view = 0, this.variableNames.vTBN = 0, this.defineNames.MAINUV0 = 0, this.defineNames.MAINUV1 = 0, this.defineNames.MAINUV2 = 0, this.defineNames.MAINUV3 = 0, this.defineNames.MAINUV4 = 0, this.defineNames.MAINUV5 = 0, this.defineNames.MAINUV6 = 0, this.defineNames.MAINUV7 = 0 } return e.prototype.emitErrors = function () { var e = ""; this.checks.emitVertex || this.allowEmptyVertexProgram || (e += "NodeMaterial does not have a vertex output. You need to at least add a block that generates a glPosition value.\n"), this.checks.emitFragment || (e += "NodeMaterial does not have a fragment output. You need to at least add a block that generates a glFragColor value.\n"); for (var t = 0, i = this.checks.notConnectedNonOptionalInputs; t < i.length; t++) { var r = i[t]; e += "input ".concat(r.name, " from block ").concat(r.ownerBlock.name, "[").concat(r.ownerBlock.getClassName(), "] is not connected and is not optional.\n") } if (e) throw "Build of NodeMaterial failed:\n" + e }, e }(); !function (e) { e[e.Compatible = 0] = "Compatible", e[e.TypeIncompatible = 1] = "TypeIncompatible", e[e.TargetIncompatible = 2] = "TargetIncompatible", e[e.HierarchyIssue = 3] = "HierarchyIssue" }(ia || (ia = {})), function (e) { e[e.Input = 0] = "Input", e[e.Output = 1] = "Output" }(ra || (ra = {})); var aa = function () { function e(e, t, i) { this._connectedPoint = null, this._endpoints = new Array, this._typeConnectionSource = null, this._defaultConnectionPointType = null, this._linkedConnectionSource = null, this._acceptedConnectionPointType = null, this._type = Jo.Float, this._enforceAssociatedVariableName = !1, this.needDualDirectionValidation = !1, this.acceptedConnectionPointTypes = new Array, this.excludedConnectionPointTypes = new Array, this.onConnectionObservable = new u, this.isExposedOnFrame = !1, this.exposedPortPosition = -1, this._prioritizeVertex = !1, this._target = $o.VertexAndFragment, this._ownerBlock = t, this.name = e, this._direction = i } return e.AreEquivalentTypes = function (e, t) { switch (e) { case Jo.Vector3: if (t === Jo.Color3) return !0; break; case Jo.Vector4: if (t === Jo.Color4) return !0; break; case Jo.Color3: if (t === Jo.Vector3) return !0; break; case Jo.Color4: if (t === Jo.Vector4) return !0 }return !1 }, Object.defineProperty(e.prototype, "direction", { get: function () { return this._direction }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "associatedVariableName", { get: function () { return this._ownerBlock.isInput ? this._ownerBlock.associatedVariableName : this._enforceAssociatedVariableName && this._associatedVariableName || !this._connectedPoint ? this._associatedVariableName : this._connectedPoint.associatedVariableName }, set: function (e) { this._associatedVariableName = e }, 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 }), Object.defineProperty(e.prototype, "type", { get: function () { if (this._type === Jo.AutoDetect) { if (this._ownerBlock.isInput) return this._ownerBlock.type; if (this._connectedPoint) return this._connectedPoint.type; if (this._linkedConnectionSource && this._linkedConnectionSource.isConnected) return this._linkedConnectionSource.type } if (this._type === Jo.BasedOnInput) { if (this._typeConnectionSource) return !this._typeConnectionSource.isConnected && this._defaultConnectionPointType ? this._defaultConnectionPointType : this._typeConnectionSource.type; if (this._defaultConnectionPointType) return this._defaultConnectionPointType } return this._type }, set: function (e) { this._type = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "target", { get: function () { return this._prioritizeVertex && this._ownerBlock ? this._target !== $o.VertexAndFragment ? this._target : this._ownerBlock.target === $o.Fragment ? $o.Fragment : $o.Vertex : this._target }, set: function (e) { this._target = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isConnected", { get: function () { return null !== this.connectedPoint || this.hasEndpoints }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isConnectedToInputBlock", { get: function () { return null !== this.connectedPoint && this.connectedPoint.ownerBlock.isInput }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "connectInputBlock", { get: function () { return this.isConnectedToInputBlock ? this.connectedPoint.ownerBlock : null }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "connectedPoint", { get: function () { return this._connectedPoint }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "ownerBlock", { get: function () { return this._ownerBlock }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "sourceBlock", { get: function () { return this._connectedPoint ? this._connectedPoint.ownerBlock : null }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "connectedBlocks", { get: function () { return 0 === this._endpoints.length ? [] : this._endpoints.map((function (e) { return e.ownerBlock })) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "endpoints", { get: function () { return this._endpoints }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "hasEndpoints", { get: function () { return this._endpoints && this._endpoints.length > 0 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isDirectlyConnectedToVertexOutput", { get: function () { if (!this.hasEndpoints) return !1; for (var e = 0, t = this._endpoints; e < t.length; e++) { var i = t[e]; if (i.ownerBlock.target === $o.Vertex) return !0; if ((i.ownerBlock.target === $o.Neutral || i.ownerBlock.target === $o.VertexAndFragment) && i.ownerBlock.outputs.some((function (e) { return e.isDirectlyConnectedToVertexOutput }))) return !0 } return !1 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isConnectedInVertexShader", { get: function () { if (this.target === $o.Vertex) return !0; if (!this.hasEndpoints) return !1; for (var e = 0, t = this._endpoints; e < t.length; e++) { var i = t[e]; if (i.ownerBlock.target === $o.Vertex) return !0; if (i.target === $o.Vertex) return !0; if ((i.ownerBlock.target === $o.Neutral || i.ownerBlock.target === $o.VertexAndFragment) && i.ownerBlock.outputs.some((function (e) { return e.isConnectedInVertexShader }))) return !0 } return !1 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isConnectedInFragmentShader", { get: function () { if (this.target === $o.Fragment) return !0; if (!this.hasEndpoints) return !1; for (var e = 0, t = this._endpoints; e < t.length; e++) { var i = t[e]; if (i.ownerBlock.target === $o.Fragment) return !0; if ((i.ownerBlock.target === $o.Neutral || i.ownerBlock.target === $o.VertexAndFragment) && i.ownerBlock.isConnectedInFragmentShader()) return !0 } return !1 }, enumerable: !1, configurable: !0 }), e.prototype.createCustomInputBlock = function () { return null }, e.prototype.getClassName = function () { return "NodeMaterialConnectionPoint" }, e.prototype.canConnectTo = function (e) { return this.checkCompatibilityState(e) === ia.Compatible }, e.prototype.checkCompatibilityState = function (t) { var i = this._ownerBlock, r = t.ownerBlock; if (i.target === $o.Fragment) { if (r.target === $o.Vertex) return ia.TargetIncompatible; for (var n = 0, o = r.outputs; n < o.length; n++) { var a = o[n]; if (a.ownerBlock.target != $o.Neutral && a.isConnectedInVertexShader) return ia.TargetIncompatible } } if (this.type !== t.type && t.innerType !== Jo.AutoDetect) return e.AreEquivalentTypes(this.type, t.type) || t.acceptedConnectionPointTypes && -1 !== t.acceptedConnectionPointTypes.indexOf(this.type) || t._acceptedConnectionPointType && e.AreEquivalentTypes(t._acceptedConnectionPointType.type, this.type) ? ia.Compatible : ia.TypeIncompatible; if (t.excludedConnectionPointTypes && -1 !== t.excludedConnectionPointTypes.indexOf(this.type)) return ia.TypeIncompatible; var s = r, l = i; return this.direction === ra.Input && (s = i, l = r), s.isAnAncestorOf(l) ? ia.HierarchyIssue : ia.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._enforceAssociatedVariableName = !1, 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._enforceAssociatedVariableName = !1, e._enforceAssociatedVariableName = !1), this }, e.prototype.addExcludedConnectionPointFromAllowedTypes = function (e) { for (var t = 1; t < Jo.All;)e & t || this.excludedConnectionPointTypes.push(t), t <<= 1 }, e.prototype.serialize = function (e) { void 0 === e && (e = !0); var t = {}; return t.name = this.name, t.displayName = this.displayName, e && this.connectedPoint && (t.inputName = this.name, t.targetBlockId = this.connectedPoint.ownerBlock.uniqueId, t.targetConnectionName = this.connectedPoint.name, t.isExposedOnFrame = !0, t.exposedPortPosition = this.exposedPortPosition), (this.isExposedOnFrame || this.exposedPortPosition >= 0) && (t.isExposedOnFrame = !0, t.exposedPortPosition = this.exposedPortPosition), t }, e.prototype.dispose = function () { this.onConnectionObservable.clear() }, e }(), sa = function () { function e(e, t, i) { void 0 === t && (t = $o.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 === $o.Neutral, this._isFinalMerger = i, this._isInput = "InputBlock" === this.getClassName(), this._isTeleportOut = "NodeMaterialTeleportOutBlock" === this.getClassName(), this._isTeleportIn = "NodeMaterialTeleportInBlock" === this.getClassName(), this._name = e, this.uniqueId = yr.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 === $o.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 aa(e, this, ra.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 aa(e, this, ra.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 < i.length; t++) { var r = i[t]; if (!(r.connectedPoint || e && e.type !== r.type && r.type !== Jo.AutoDetect)) return r } return null }, e.prototype.getFirstAvailableOutput = function (e) { void 0 === e && (e = null); for (var t = 0, i = this._outputs; t < i.length; t++) { var r = i[t]; if (!e || !e.target || e.target === $o.Neutral || 0 != (e.target & r.target)) return r } return null }, e.prototype.getSiblingOutput = function (e) { var t = this._outputs.indexOf(e); return -1 === t || t >= this._outputs.length ? null : this._outputs[t + 1] }, e.prototype.isAnAncestorOf = function (e) { for (var t = 0, i = this._outputs; t < i.length; t++) { var r = i[t]; if (r.hasEndpoints) for (var n = 0, o = r.endpoints; n < o.length; n++) { var a = o[n]; if (a.ownerBlock === e) return !0; if (a.ownerBlock.isAnAncestorOf(e)) return !0 } } return !1 }, e.prototype.connectTo = function (e, t) { if (0 !== this._outputs.length) { for (var i = t && t.output ? this.getOutputByName(t.output) : this.getFirstAvailableOutput(e), r = !0; r;) { var n = t && t.input ? e.getInputByName(t.input) : e.getFirstAvailableInput(i); if (i && n && i.canConnectTo(n)) i.connectTo(n), r = !1; else { if (!i) throw "Unable to find a compatible match"; i = this.getSiblingOutput(i) } } return this } }, e.prototype._buildBlock = function (e) { }, e.prototype.updateUniformsAndSamples = function (e, t, i, r) { }, e.prototype.provideFallbacks = function (e, t) { }, e.prototype.initializeDefines = function (e, t, i, r) { void 0 === r && (r = !1) }, e.prototype.prepareDefines = function (e, t, i, r, n) { void 0 === r && (r = !1) }, e.prototype.autoConfigure = function (e) { }, e.prototype.replaceRepeatableContent = function (e, t, i, r) { }, Object.defineProperty(e.prototype, "willBeGeneratedIntoVertexShaderFromFragmentShader", { get: function () { return !(this.isInput || this.isFinalMerger || this._outputs.some((function (e) { return e.isDirectlyConnectedToVertexOutput })) || this.target === $o.Vertex || this.target !== $o.VertexAndFragment && this.target !== $o.Neutral || !this._outputs.some((function (e) { return e.isConnectedInVertexShader }))) }, enumerable: !1, configurable: !0 }), e.prototype.isReady = function (e, t, i, r) { return void 0 === r && (r = !1), !0 }, e.prototype._linkConnectionTypes = function (e, t, i) { void 0 === i && (i = !1), i ? this._inputs[t]._acceptedConnectionPointType = this._inputs[e] : this._inputs[e]._linkedConnectionSource = this._inputs[t], this._inputs[t]._linkedConnectionSource = this._inputs[e] }, e.prototype._processBuild = function (e, t, i, r) { e.build(t, r); var n = null != t._vertexState, o = e._buildTarget === $o.Vertex && e.target !== $o.VertexAndFragment; if (n && (0 == (e.target & e._buildTarget) || 0 == (e.target & i.target) || this.target !== $o.VertexAndFragment && o) && (!e.isInput && t.target !== e._buildTarget || e.isInput && e.isAttribute && !e._noContextSwitch)) { var a = i.connectedPoint; t._vertexState._emitVaryingFromString("v_" + a.associatedVariableName, t._getGLType(a.type)) && (t._vertexState.compilationString += "".concat("v_" + a.associatedVariableName, " = ").concat(a.associatedVariableName, ";\n")), i.associatedVariableName = "v_" + a.associatedVariableName, i._enforceAssociatedVariableName = !0 } }, e.prototype.validateBlockName = function (e) { for (var t = 0, i = ["position", "normal", "tangent", "particle_positionw", "uv", "uv2", "uv3", "uv4", "uv5", "uv6", "position2d", "particle_uv", "matricesIndices", "matricesWeights", "world0", "world1", "world2", "world3", "particle_color", "particle_texturemask"]; t < i.length; t++)if (e === i[t]) return !1; return !0 }, e.prototype._customBuildStep = function (e, t) { }, e.prototype.build = function (e, t) { if (this._buildId === e.sharedData.buildId) return !0; if (!this.isInput) for (var i = 0, r = this._outputs; i < r.length; i++)(c = r[i]).associatedVariableName || (c.associatedVariableName = e._getFreeVariableName(c.name)); for (var n = 0, o = this._inputs; n < o.length; n++) { var a = o[n]; if (a.connectedPoint) { if (this.target !== $o.Neutral) { if (0 == (a.target & this.target)) continue; if (0 == (a.target & e.target)) continue } (d = a.connectedPoint.ownerBlock) && d !== this && this._processBuild(d, e, a, t) } else a.isOptional || e.sharedData.checks.notConnectedNonOptionalInputs.push(a) } if (this._customBuildStep(e, t), this._buildId === e.sharedData.buildId) return !0; if (e.sharedData.verbose && console.log("".concat(e.target === $o.Vertex ? "Vertex shader" : "Fragment shader", ": Building ").concat(this.name, " [").concat(this.getClassName(), "]")), this.isFinalMerger) switch (e.target) { case $o.Vertex: e.sharedData.checks.emitVertex = !0; break; case $o.Fragment: e.sharedData.checks.emitFragment = !0 }!this.isInput && e.sharedData.emitComments && (e.compilationString += "\n//".concat(this.name, "\n")), this._buildBlock(e), this._buildId = e.sharedData.buildId, this._buildTarget = e.target; for (var s = 0, l = this._outputs; s < l.length; s++) { var c; if (0 != ((c = l[s]).target & e.target)) for (var u = 0, h = c.endpoints; u < h.length; u++) { var d, p = h[u]; (d = p.ownerBlock) && 0 != (d.target & e.target) && -1 !== t.indexOf(d) && this._processBuild(d, e, p, t) } } return !1 }, e.prototype._inputRename = function (e) { return e }, e.prototype._outputRename = function (e) { return e }, e.prototype._dumpPropertiesCode = function () { var e = this._codeVariableName; return "".concat(e, ".visibleInInspector = ").concat(this.visibleInInspector, ";\n").concat(e, ".visibleOnFrame = ").concat(this.visibleOnFrame, ";\n").concat(e, ".target = ").concat(this.target, ";\n") }, e.prototype._dumpCode = function (e, t) { t.push(this); var i = this.name.replace(/[^A-Za-z_]+/g, ""); if (this._codeVariableName = i || "".concat(this.getClassName(), "_").concat(this.uniqueId), -1 !== e.indexOf(this._codeVariableName)) { var r = 0; do { r++, this._codeVariableName = i + r } while (-1 !== e.indexOf(this._codeVariableName)) } e.push(this._codeVariableName); var n = "\n// ".concat(this.getClassName(), "\n"); this.comments && (n += "// ".concat(this.comments, "\n")), n += "var ".concat(this._codeVariableName, " = new BABYLON.").concat(this.getClassName(), '("').concat(this.name, '");\n'), n += this._dumpPropertiesCode(); for (var o = 0, a = this.inputs; o < a.length; o++) { var s = a[o]; if (s.isConnected) { var l = s.connectedPoint.ownerBlock; -1 === t.indexOf(l) && (n += l._dumpCode(e, t)) } } for (var c = 0, u = this.outputs; c < u.length; c++) { var h = u[c]; if (h.hasEndpoints) for (var d = 0, p = h.endpoints; d < p.length; d++)(l = p[d].ownerBlock) && -1 === t.indexOf(l) && (n += l._dumpCode(e, t)) } return n }, e.prototype._dumpCodeForOutputConnections = function (e) { var t = ""; if (-1 !== e.indexOf(this)) return t; e.push(this); for (var i = 0, r = this.inputs; i < r.length; i++) { var n = r[i]; if (n.isConnected) { var o = n.connectedPoint, a = o.ownerBlock; t += a._dumpCodeForOutputConnections(e), t += "".concat(a._codeVariableName, ".").concat(a._outputRename(o.name), ".connectTo(").concat(this._codeVariableName, ".").concat(this._inputRename(n.name), ");\n") } } return t }, e.prototype.clone = function (e, t) { void 0 === t && (t = ""); var i = this.serialize(), r = T(i.customType); if (r) { var n = new r; return n._deserialize(i, e, t), n } return null }, e.prototype.serialize = function () { var e = {}; e.customType = "BABYLON." + this.getClassName(), e.id = this.uniqueId, e.name = this.name, e.comments = this.comments, e.visibleInInspector = this.visibleInInspector, e.visibleOnFrame = this.visibleOnFrame, e.target = this.target, e.inputs = [], e.outputs = []; for (var t = 0, i = this.inputs; t < i.length; t++) { var r = i[t]; e.inputs.push(r.serialize()) } for (var n = 0, o = this.outputs; n < o.length; n++) { var a = o[n]; e.outputs.push(a.serialize(!1)) } return e }, e.prototype._deserialize = function (e, t, i) { var r; this.name = e.name, this.comments = e.comments, this.visibleInInspector = !!e.visibleInInspector, this.visibleOnFrame = !!e.visibleOnFrame, this._target = null !== (r = e.target) && void 0 !== r ? r : this.target, this._deserializePortDisplayNamesAndExposedOnFrame(e) }, e.prototype._deserializePortDisplayNamesAndExposedOnFrame = function (e) { var t = this, i = e.inputs, r = e.outputs; i && i.forEach((function (e, i) { e.displayName && (t.inputs[i].displayName = e.displayName), e.isExposedOnFrame && (t.inputs[i].isExposedOnFrame = e.isExposedOnFrame, t.inputs[i].exposedPortPosition = e.exposedPortPosition) })), r && r.forEach((function (e, i) { e.displayName && (t.outputs[i].displayName = e.displayName), e.isExposedOnFrame && (t.outputs[i].isExposedOnFrame = e.isExposedOnFrame, t.outputs[i].exposedPortPosition = e.exposedPortPosition) })) }, e.prototype.dispose = function () { for (var e = 0, t = this.inputs; e < t.length; e++)t[e].dispose(); for (var i = 0, r = this.outputs; i < r.length; i++)r[i].dispose() }, e }(), la = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.complementW = 1, i.complementZ = 0, i.target = $o.Vertex, i.registerInput("vector", Jo.AutoDetect), i.registerInput("transform", Jo.Matrix), i.registerOutput("output", Jo.Vector4), i.registerOutput("xyz", Jo.Vector3), i._inputs[0].onConnectionObservable.add((function (e) { if (e.ownerBlock.isInput) { var t = e.ownerBlock; "normal" !== t.name && "tangent" !== t.name || (i.complementW = 0) } })), i } return W(t, e), t.prototype.getClassName = function () { return "TransformBlock" }, Object.defineProperty(t.prototype, "vector", { 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, "xyz", { get: function () { return this._outputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "transform", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t); var i = this.vector, r = this.transform; if (i.connectedPoint) { if (0 === this.complementW) { var n = "//".concat(this.name); t._emitFunctionFromInclude("helperFunctions", n), t.sharedData.blocksWithDefines.push(this); var o = t._getFreeVariableName("".concat(r.associatedVariableName, "_NUS")); switch (t.compilationString += "mat3 ".concat(o, " = mat3(").concat(r.associatedVariableName, ");\n"), t.compilationString += "#ifdef NONUNIFORMSCALING\n", t.compilationString += "".concat(o, " = transposeMat3(inverseMat3(").concat(o, "));\n"), t.compilationString += "#endif\n", i.connectedPoint.type) { case Jo.Vector2: t.compilationString += this._declareOutput(this.output, t) + " = vec4(".concat(o, " * vec3(").concat(i.associatedVariableName, ", ").concat(this._writeFloat(this.complementZ), "), ").concat(this._writeFloat(this.complementW), ");\n"); break; case Jo.Vector3: case Jo.Color3: t.compilationString += this._declareOutput(this.output, t) + " = vec4(".concat(o, " * ").concat(i.associatedVariableName, ", ").concat(this._writeFloat(this.complementW), ");\n"); break; default: t.compilationString += this._declareOutput(this.output, t) + " = vec4(".concat(o, " * ").concat(i.associatedVariableName, ".xyz, ").concat(this._writeFloat(this.complementW), ");\n") } } else switch (o = r.associatedVariableName, i.connectedPoint.type) { case Jo.Vector2: t.compilationString += this._declareOutput(this.output, t) + " = ".concat(o, " * vec4(").concat(i.associatedVariableName, ", ").concat(this._writeFloat(this.complementZ), ", ").concat(this._writeFloat(this.complementW), ");\n"); break; case Jo.Vector3: case Jo.Color3: t.compilationString += this._declareOutput(this.output, t) + " = ".concat(o, " * vec4(").concat(i.associatedVariableName, ", ").concat(this._writeFloat(this.complementW), ");\n"); break; default: t.compilationString += this._declareOutput(this.output, t) + " = ".concat(o, " * ").concat(i.associatedVariableName, ";\n") }this.xyz.hasEndpoints && (t.compilationString += this._declareOutput(this.xyz, t) + " = ".concat(this.output.associatedVariableName, ".xyz;\n")) } return this }, t.prototype.prepareDefines = function (e, t, i) { e.nonUniformScaling && i.setValue("NONUNIFORMSCALING", !0) }, t.prototype.serialize = function () { var t = e.prototype.serialize.call(this); return t.complementZ = this.complementZ, t.complementW = this.complementW, t }, t.prototype._deserialize = function (t, i, r) { e.prototype._deserialize.call(this, t, i, r), this.complementZ = void 0 !== t.complementZ ? t.complementZ : 0, this.complementW = void 0 !== t.complementW ? t.complementW : 1 }, t.prototype._dumpPropertiesCode = function () { return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".complementZ = ").concat(this.complementZ, ";\n") + "".concat(this._codeVariableName, ".complementW = ").concat(this.complementW, ";\n") }, t }(sa); b("BABYLON.TransformBlock", la); var ca, ua = function (e) { function t(t) { var i = e.call(this, t, $o.Vertex, !0) || this; return i.registerInput("vector", Jo.Vector4), i } return W(t, e), t.prototype.getClassName = function () { return "VertexOutputBlock" }, Object.defineProperty(t.prototype, "vector", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), t.prototype._isLogarithmicDepthEnabled = function (e) { for (var t = 0, i = e; t < i.length; t++)if (i[t].useLogarithmicDepth) return !0; return !1 }, t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t); var i = this.vector; return t.compilationString += "gl_Position = ".concat(i.associatedVariableName, ";\n"), this._isLogarithmicDepthEnabled(t.sharedData.fragmentOutputNodes) && (t._emitUniformFromString("logarithmicDepthConstant", "float"), t._emitVaryingFromString("vFragmentDepth", "float"), t.compilationString += "vFragmentDepth = 1.0 + gl_Position.w;\n", t.compilationString += "gl_Position.z = log2(max(0.000001, vFragmentDepth)) * logarithmicDepthConstant;\n"), this }, t }(sa); function ha(e, t, i, r) { return void 0 === t && (t = ca.Boolean), void 0 === i && (i = "PROPERTIES"), function (n, o) { var a = n._propStore; a || (a = [], n._propStore = a), a.push({ propertyName: o, displayName: e, type: t, groupName: i, options: null != r ? r : {} }) } } b("BABYLON.VertexOutputBlock", ua), function (e) { e[e.Boolean = 0] = "Boolean", e[e.Float = 1] = "Float", e[e.Int = 2] = "Int", e[e.Vector2 = 3] = "Vector2", e[e.List = 4] = "List" }(ca || (ca = {})); var da, pa, fa = function (e) { function t(t) { var i = e.call(this, t, $o.Fragment, !0) || this; return i.convertToGammaSpace = !1, i.convertToLinearSpace = !1, i.useLogarithmicDepth = !1, i.registerInput("rgba", Jo.Color4, !0), i.registerInput("rgb", Jo.AutoDetect, !0), i.registerInput("a", Jo.Float, !0), i.rgb.addExcludedConnectionPointFromAllowedTypes(Jo.Color3 | Jo.Vector3 | Jo.Float), i } return W(t, e), t.prototype.getClassName = function () { return "FragmentOutputBlock" }, t.prototype.initialize = function (e) { e._excludeVariableName("logarithmicDepthConstant"), e._excludeVariableName("vFragmentDepth") }, Object.defineProperty(t.prototype, "rgba", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgb", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "a", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), t.prototype.prepareDefines = function (e, t, i) { i.setValue(this._linearDefineName, this.convertToLinearSpace, !0), i.setValue(this._gammaDefineName, this.convertToGammaSpace, !0) }, t.prototype.bind = function (e, t, i) { this.useLogarithmicDepth && i && zn.BindLogDepth(void 0, e, i.getScene()) }, t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t); var i = this.rgba, r = this.rgb, n = this.a; t.sharedData.hints.needAlphaBlending = i.isConnected || n.isConnected, t.sharedData.blocksWithDefines.push(this), this.useLogarithmicDepth && (t._emitUniformFromString("logarithmicDepthConstant", "float"), t._emitVaryingFromString("vFragmentDepth", "float"), t.sharedData.bindableBlocks.push(this)), this._linearDefineName = t._getFreeDefineName("CONVERTTOLINEAR"), this._gammaDefineName = t._getFreeDefineName("CONVERTTOGAMMA"); var o = "//".concat(this.name); if (t._emitFunctionFromInclude("helperFunctions", o), i.connectedPoint) n.isConnected ? t.compilationString += "gl_FragColor = vec4(".concat(i.associatedVariableName, ".rgb, ").concat(n.associatedVariableName, ");\n") : t.compilationString += "gl_FragColor = ".concat(i.associatedVariableName, ";\n"); else if (r.connectedPoint) { var a = "1.0"; n.connectedPoint && (a = n.associatedVariableName), r.connectedPoint.type === Jo.Float ? t.compilationString += "gl_FragColor = vec4(".concat(r.associatedVariableName, ", ").concat(r.associatedVariableName, ", ").concat(r.associatedVariableName, ", ").concat(a, ");\n") : t.compilationString += "gl_FragColor = vec4(".concat(r.associatedVariableName, ", ").concat(a, ");\n") } else t.sharedData.checks.notConnectedNonOptionalInputs.push(i); return t.compilationString += "#ifdef ".concat(this._linearDefineName, "\n"), t.compilationString += "gl_FragColor = toLinearSpace(gl_FragColor);\n", t.compilationString += "#endif\n", t.compilationString += "#ifdef ".concat(this._gammaDefineName, "\n"), t.compilationString += "gl_FragColor = toGammaSpace(gl_FragColor);\n", t.compilationString += "#endif\n", this.useLogarithmicDepth && (t.compilationString += "gl_FragDepthEXT = log2(vFragmentDepth) * logarithmicDepthConstant * 0.5;\n"), this }, t.prototype._dumpPropertiesCode = function () { var t = e.prototype._dumpPropertiesCode.call(this); return t += "".concat(this._codeVariableName, ".convertToGammaSpace = ").concat(this.convertToGammaSpace, ";\n"), (t += "".concat(this._codeVariableName, ".convertToLinearSpace = ").concat(this.convertToLinearSpace, ";\n")) + "".concat(this._codeVariableName, ".useLogarithmicDepth = ").concat(this.useLogarithmicDepth, ";\n") }, t.prototype.serialize = function () { var t = e.prototype.serialize.call(this); return t.convertToGammaSpace = this.convertToGammaSpace, t.convertToLinearSpace = this.convertToLinearSpace, t.useLogarithmicDepth = this.useLogarithmicDepth, t }, t.prototype._deserialize = function (t, i, r) { var n; e.prototype._deserialize.call(this, t, i, r), this.convertToGammaSpace = t.convertToGammaSpace, this.convertToLinearSpace = t.convertToLinearSpace, this.useLogarithmicDepth = null !== (n = t.useLogarithmicDepth) && void 0 !== n && n }, X([ha("Convert to gamma space", ca.Boolean, "PROPERTIES", { notifiers: { update: !0 } })], t.prototype, "convertToGammaSpace", void 0), X([ha("Convert to linear space", ca.Boolean, "PROPERTIES", { notifiers: { update: !0 } })], t.prototype, "convertToLinearSpace", void 0), X([ha("Use logarithmic depth", ca.Boolean, "PROPERTIES")], t.prototype, "useLogarithmicDepth", void 0), t }(sa); b("BABYLON.FragmentOutputBlock", fa), function (e) { e[e.Uniform = 0] = "Uniform", e[e.Attribute = 1] = "Attribute", e[e.Varying = 2] = "Varying", e[e.Undefined = 3] = "Undefined" }(da || (da = {})), function (e) { e[e.World = 1] = "World", e[e.View = 2] = "View", e[e.Projection = 3] = "Projection", e[e.ViewProjection = 4] = "ViewProjection", e[e.WorldView = 5] = "WorldView", e[e.WorldViewProjection = 6] = "WorldViewProjection", e[e.CameraPosition = 7] = "CameraPosition", e[e.FogColor = 8] = "FogColor", e[e.DeltaTime = 9] = "DeltaTime", e[e.CameraParameters = 10] = "CameraParameters", e[e.MaterialAlpha = 11] = "MaterialAlpha" }(pa || (pa = {})); var _a, ma = function () { function e(e, t) { void 0 === e && (e = R.Zero()), void 0 === t && (t = R.Up()), this.position = e, this.normal = t } return e.prototype.clone = function () { return new e(this.position.clone(), this.normal.clone()) }, e }(), ga = function () { function e(e, t, i) { void 0 === e && (e = R.Zero()), void 0 === t && (t = R.Up()), void 0 === i && (i = A.Zero()), this.position = e, this.normal = t, this.uv = i } return e.prototype.clone = function () { return new e(this.position.clone(), this.normal.clone(), this.uv.clone()) }, e }(); !function (e) { e[e.None = 0] = "None", e[e.Time = 1] = "Time", e[e.RealTime = 2] = "RealTime" }(_a || (_a = {})); var va = { position2d: "position", particle_uv: "vUV", particle_color: "vColor", particle_texturemask: "textureMask", particle_positionw: "vPositionW" }, ya = { particle_uv: !0, particle_color: !0, particle_texturemask: !0, particle_positionw: !0 }, ba = { particle_texturemask: !0 }, Ta = function (e) { function t(t, i, r) { void 0 === i && (i = $o.Vertex), void 0 === r && (r = Jo.AutoDetect); var n = e.call(this, t, i, !1) || this; return n._mode = da.Undefined, n._animationType = _a.None, n.min = 0, n.max = 0, n.isBoolean = !1, n.matrixMode = 0, n._systemValue = null, n.isConstant = !1, n.groupInInspector = "", n.onValueChangedObservable = new u, n.convertToGammaSpace = !1, n.convertToLinearSpace = !1, n._type = r, n.setDefaultValue(), n.registerOutput("output", r), n } return W(t, e), Object.defineProperty(t.prototype, "type", { get: function () { if (this._type === Jo.AutoDetect) { if (this.isUniform && null != this.value) { if (!isNaN(this.value)) return this._type = Jo.Float, this._type; switch (this.value.getClassName()) { case "Vector2": return this._type = Jo.Vector2, this._type; case "Vector3": return this._type = Jo.Vector3, this._type; case "Vector4": return this._type = Jo.Vector4, this._type; case "Color3": return this._type = Jo.Color3, this._type; case "Color4": return this._type = Jo.Color4, this._type; case "Matrix": return this._type = Jo.Matrix, this._type } } if (this.isAttribute) switch (this.name) { case "position": case "normal": case "particle_positionw": return this._type = Jo.Vector3, this._type; case "uv": case "uv2": case "uv3": case "uv4": case "uv5": case "uv6": case "position2d": case "particle_uv": return this._type = Jo.Vector2, this._type; case "matricesIndices": case "matricesWeights": case "matricesIndicesExtra": case "matricesWeightsExtra": case "world0": case "world1": case "world2": case "world3": case "tangent": return this._type = Jo.Vector4, this._type; case "color": case "instanceColor": case "particle_color": case "particle_texturemask": return this._type = Jo.Color4, this._type }if (this.isSystemValue) switch (this._systemValue) { case pa.World: case pa.WorldView: case pa.WorldViewProjection: case pa.View: case pa.ViewProjection: case pa.Projection: return this._type = Jo.Matrix, this._type; case pa.CameraPosition: return this._type = Jo.Vector3, this._type; case pa.FogColor: return this._type = Jo.Color3, this._type; case pa.DeltaTime: case pa.MaterialAlpha: return this._type = Jo.Float, this._type; case pa.CameraParameters: return this._type = Jo.Vector4, this._type } } return this._type }, enumerable: !1, configurable: !0 }), t.prototype.validateBlockName = function (t) { return !!this.isAttribute || e.prototype.validateBlockName.call(this, t) }, Object.defineProperty(t.prototype, "output", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype.setAsAttribute = function (e) { return this._mode = da.Attribute, e && (this.name = e), this }, t.prototype.setAsSystemValue = function (e) { return this.systemValue = e, this }, Object.defineProperty(t.prototype, "value", { get: function () { return this._storedValue }, set: function (e) { this.type === Jo.Float && (this.isBoolean ? e = e ? 1 : 0 : this.min !== this.max && (e = Math.max(this.min, e), e = Math.min(this.max, e))), this._storedValue = e, this._mode = da.Uniform, this.onValueChangedObservable.notifyObservers(this) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "valueCallback", { get: function () { return this._valueCallback }, set: function (e) { this._valueCallback = e, this._mode = da.Uniform }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "associatedVariableName", { get: function () { return this._associatedVariableName }, set: function (e) { this._associatedVariableName = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "animationType", { get: function () { return this._animationType }, set: function (e) { this._animationType = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isUndefined", { get: function () { return this._mode === da.Undefined }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isUniform", { get: function () { return this._mode === da.Uniform }, set: function (e) { this._mode = e ? da.Uniform : da.Undefined, this.associatedVariableName = "" }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isAttribute", { get: function () { return this._mode === da.Attribute }, set: function (e) { this._mode = e ? da.Attribute : da.Undefined, this.associatedVariableName = "" }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isVarying", { get: function () { return this._mode === da.Varying }, set: function (e) { this._mode = e ? da.Varying : da.Undefined, this.associatedVariableName = "" }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isSystemValue", { get: function () { return null != this._systemValue }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "systemValue", { get: function () { return this._systemValue }, set: function (e) { this._mode = da.Uniform, this.associatedVariableName = "", this._systemValue = e }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function () { return "InputBlock" }, t.prototype.animate = function (e) { switch (this._animationType) { case _a.Time: this.type === Jo.Float && (this.value += .01 * e.getAnimationRatio()); break; case _a.RealTime: this.type === Jo.Float && (this.value = (at.Now - e.getEngine().startTime) / 1e3) } }, t.prototype._emitDefine = function (e) { return "!" === e[0] ? "#ifndef ".concat(e.substring(1), "\n") : "#ifdef ".concat(e, "\n") }, t.prototype.initialize = function () { this.associatedVariableName = "" }, t.prototype.setDefaultValue = function () { switch (this.type) { case Jo.Float: this.value = 0; break; case Jo.Vector2: this.value = A.Zero(); break; case Jo.Vector3: this.value = R.Zero(); break; case Jo.Vector4: this.value = C.Zero(); break; case Jo.Color3: this.value = B.White(); break; case Jo.Color4: this.value = new U(1, 1, 1, 1); break; case Jo.Matrix: this.value = I.Identity() } }, t.prototype._emitConstant = function (e) { switch (this.type) { case Jo.Float: return "".concat(e._emitFloat(this.value)); case Jo.Vector2: return "vec2(".concat(this.value.x, ", ").concat(this.value.y, ")"); case Jo.Vector3: return "vec3(".concat(this.value.x, ", ").concat(this.value.y, ", ").concat(this.value.z, ")"); case Jo.Vector4: return "vec4(".concat(this.value.x, ", ").concat(this.value.y, ", ").concat(this.value.z, ", ").concat(this.value.w, ")"); case Jo.Color3: return V.Color3[0].set(this.value.r, this.value.g, this.value.b), this.convertToGammaSpace && V.Color3[0].toGammaSpaceToRef(V.Color3[0], e.sharedData.scene.getEngine().useExactSrgbConversions), this.convertToLinearSpace && V.Color3[0].toLinearSpaceToRef(V.Color3[0], e.sharedData.scene.getEngine().useExactSrgbConversions), "vec3(".concat(V.Color3[0].r, ", ").concat(V.Color3[0].g, ", ").concat(V.Color3[0].b, ")"); case Jo.Color4: return V.Color4[0].set(this.value.r, this.value.g, this.value.b, this.value.a), this.convertToGammaSpace && V.Color4[0].toGammaSpaceToRef(V.Color4[0], e.sharedData.scene.getEngine().useExactSrgbConversions), this.convertToLinearSpace && V.Color4[0].toLinearSpaceToRef(V.Color4[0], e.sharedData.scene.getEngine().useExactSrgbConversions), "vec4(".concat(V.Color4[0].r, ", ").concat(V.Color4[0].g, ", ").concat(V.Color4[0].b, ", ").concat(V.Color4[0].a, ")") }return "" }, Object.defineProperty(t.prototype, "_noContextSwitch", { get: function () { return ya[this.name] }, enumerable: !1, configurable: !0 }), t.prototype._emit = function (e, t) { var i; if (this.isUniform) { if (this.associatedVariableName || (this.associatedVariableName = e._getFreeVariableName("u_" + this.name)), this.isConstant) { if (-1 !== e.constants.indexOf(this.associatedVariableName)) return; return e.constants.push(this.associatedVariableName), void (e._constantDeclaration += this._declareOutput(this.output, e) + " = ".concat(this._emitConstant(e), ";\n")) } if (-1 !== e.uniforms.indexOf(this.associatedVariableName)) return; e.uniforms.push(this.associatedVariableName), t && (e._uniformDeclaration += this._emitDefine(t)), e._uniformDeclaration += "uniform ".concat(e._getGLType(this.type), " ").concat(this.associatedVariableName, ";\n"), t && (e._uniformDeclaration += "#endif\n"); var r = e.sharedData.hints; if (null !== this._systemValue && void 0 !== this._systemValue) switch (this._systemValue) { case pa.WorldView: r.needWorldViewMatrix = !0; break; case pa.WorldViewProjection: r.needWorldViewProjectionMatrix = !0 } else this._animationType !== _a.None && e.sharedData.animatedInputs.push(this) } else if (this.isAttribute) { if (this.associatedVariableName = null !== (i = va[this.name]) && void 0 !== i ? i : this.name, this.target === $o.Vertex && e._vertexState) return void (ya[this.name] ? ba[this.name] ? e._emitUniformFromString(this.associatedVariableName, e._getGLType(this.type), t) : e._emitVaryingFromString(this.associatedVariableName, e._getGLType(this.type), t) : this._emit(e._vertexState, t)); if (-1 !== e.attributes.indexOf(this.associatedVariableName)) return; e.attributes.push(this.associatedVariableName), ya[this.name] ? ba[this.name] ? e._emitUniformFromString(this.associatedVariableName, e._getGLType(this.type), t) : e._emitVaryingFromString(this.associatedVariableName, e._getGLType(this.type), t) : (t && (e._attributeDeclaration += this._emitDefine(t)), e._attributeDeclaration += "attribute ".concat(e._getGLType(this.type), " ").concat(this.associatedVariableName, ";\n"), t && (e._attributeDeclaration += "#endif\n")) } }, t.prototype._transmitWorld = function (e, t, i, r) { if (this._systemValue) { var n = this.associatedVariableName; switch (this._systemValue) { case pa.World: e.setMatrix(n, t); break; case pa.WorldView: e.setMatrix(n, i); break; case pa.WorldViewProjection: e.setMatrix(n, r) } } }, t.prototype._transmit = function (e, t, i) { if (!this.isAttribute) { var r = this.associatedVariableName; if (this._systemValue) switch (this._systemValue) { case pa.World: case pa.WorldView: case pa.WorldViewProjection: return; case pa.View: e.setMatrix(r, t.getViewMatrix()); break; case pa.Projection: e.setMatrix(r, t.getProjectionMatrix()); break; case pa.ViewProjection: e.setMatrix(r, t.getTransformMatrix()); break; case pa.CameraPosition: t.bindEyePosition(e, r, !0); break; case pa.FogColor: e.setColor3(r, t.fogColor); break; case pa.DeltaTime: e.setFloat(r, t.deltaTime / 1e3); break; case pa.CameraParameters: t.activeCamera && e.setFloat4(r, t.getEngine().hasOriginBottomLeft ? -1 : 1, t.activeCamera.minZ, t.activeCamera.maxZ, 1 / t.activeCamera.maxZ); break; case pa.MaterialAlpha: e.setFloat(r, i.alpha) } else { var n = this._valueCallback ? this._valueCallback() : this._storedValue; if (null !== n) switch (this.type) { case Jo.Float: e.setFloat(r, n); break; case Jo.Int: e.setInt(r, n); break; case Jo.Color3: V.Color3[0].set(this.value.r, this.value.g, this.value.b), this.convertToGammaSpace && V.Color3[0].toGammaSpaceToRef(V.Color3[0], t.getEngine().useExactSrgbConversions), this.convertToLinearSpace && V.Color3[0].toLinearSpaceToRef(V.Color3[0], t.getEngine().useExactSrgbConversions), e.setColor3(r, V.Color3[0]); break; case Jo.Color4: V.Color4[0].set(this.value.r, this.value.g, this.value.b, this.value.a), this.convertToGammaSpace && V.Color4[0].toGammaSpaceToRef(V.Color4[0], t.getEngine().useExactSrgbConversions), this.convertToLinearSpace && V.Color4[0].toLinearSpaceToRef(V.Color4[0], t.getEngine().useExactSrgbConversions), e.setDirectColor4(r, V.Color4[0]); break; case Jo.Vector2: e.setVector2(r, n); break; case Jo.Vector3: e.setVector3(r, n); break; case Jo.Vector4: e.setVector4(r, n); break; case Jo.Matrix: e.setMatrix(r, n) } } } }, t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t), (this.isUniform || this.isSystemValue) && t.sharedData.inputBlocks.push(this), this._emit(t) }, t.prototype._dumpPropertiesCode = function () { var t = this._codeVariableName; if (this.isAttribute) return e.prototype._dumpPropertiesCode.call(this) + "".concat(t, '.setAsAttribute("').concat(this.name, '");\n'); if (this.isSystemValue) return e.prototype._dumpPropertiesCode.call(this) + "".concat(t, ".setAsSystemValue(BABYLON.NodeMaterialSystemValues.").concat(pa[this._systemValue], ");\n"); if (this.isUniform) { var i = [], r = ""; switch (this.type) { case Jo.Float: r = "".concat(this.value); break; case Jo.Vector2: r = "new BABYLON.Vector2(".concat(this.value.x, ", ").concat(this.value.y, ")"); break; case Jo.Vector3: r = "new BABYLON.Vector3(".concat(this.value.x, ", ").concat(this.value.y, ", ").concat(this.value.z, ")"); break; case Jo.Vector4: r = "new BABYLON.Vector4(".concat(this.value.x, ", ").concat(this.value.y, ", ").concat(this.value.z, ", ").concat(this.value.w, ")"); break; case Jo.Color3: r = "new BABYLON.Color3(".concat(this.value.r, ", ").concat(this.value.g, ", ").concat(this.value.b, ")"), this.convertToGammaSpace && (r += ".toGammaSpace()"), this.convertToLinearSpace && (r += ".toLinearSpace()"); break; case Jo.Color4: r = "new BABYLON.Color4(".concat(this.value.r, ", ").concat(this.value.g, ", ").concat(this.value.b, ", ").concat(this.value.a, ")"), this.convertToGammaSpace && (r += ".toGammaSpace()"), this.convertToLinearSpace && (r += ".toLinearSpace()"); break; case Jo.Matrix: r = "BABYLON.Matrix.FromArray([".concat(this.value.m, "])") }return i.push("".concat(t, ".value = ").concat(r)), this.type === Jo.Float && i.push("".concat(t, ".min = ").concat(this.min), "".concat(t, ".max = ").concat(this.max), "".concat(t, ".isBoolean = ").concat(this.isBoolean), "".concat(t, ".matrixMode = ").concat(this.matrixMode), "".concat(t, ".animationType = BABYLON.AnimatedInputBlockTypes.").concat(_a[this.animationType])), i.push("".concat(t, ".isConstant = ").concat(this.isConstant)), i.push(""), e.prototype._dumpPropertiesCode.call(this) + i.join(";\n") } return e.prototype._dumpPropertiesCode.call(this) }, t.prototype.dispose = function () { this.onValueChangedObservable.clear(), e.prototype.dispose.call(this) }, t.prototype.serialize = function () { var t = e.prototype.serialize.call(this); return t.type = this.type, t.mode = this._mode, t.systemValue = this._systemValue, t.animationType = this._animationType, t.min = this.min, t.max = this.max, t.isBoolean = this.isBoolean, t.matrixMode = this.matrixMode, t.isConstant = this.isConstant, t.groupInInspector = this.groupInInspector, t.convertToGammaSpace = this.convertToGammaSpace, t.convertToLinearSpace = this.convertToLinearSpace, null != this._storedValue && this._mode === da.Uniform && (this._storedValue.asArray ? (t.valueType = "BABYLON." + this._storedValue.getClassName(), t.value = this._storedValue.asArray()) : (t.valueType = "number", t.value = this._storedValue)), t }, t.prototype._deserialize = function (t, i, r) { if (this._mode = t.mode, e.prototype._deserialize.call(this, t, i, r), this._type = t.type, this._systemValue = t.systemValue || t.wellKnownValue, this._animationType = t.animationType, this.min = t.min || 0, this.max = t.max || 0, this.isBoolean = !!t.isBoolean, this.matrixMode = t.matrixMode || 0, this.isConstant = !!t.isConstant, this.groupInInspector = t.groupInInspector || "", this.convertToGammaSpace = !!t.convertToGammaSpace, this.convertToLinearSpace = !!t.convertToLinearSpace, "tangent" === t.name && t.mode === da.Attribute && t.type === Jo.Vector3 && (this._type = Jo.Vector4), t.valueType) if ("number" === t.valueType) this._storedValue = t.value; else { var n = T(t.valueType); n && (this._storedValue = n.FromArray(t.value)) } }, t }(sa); b("BABYLON.InputBlock", Ta); var Ea = function (e) { function t(t) { var i = e.call(this, t, $o.VertexAndFragment) || this; return i._samplerName = "textureSampler", i.convertToGammaSpace = !1, i.convertToLinearSpace = !1, i._isUnique = !1, i.registerInput("uv", Jo.AutoDetect, !1, $o.VertexAndFragment), i.registerOutput("rgba", Jo.Color4, $o.Neutral), i.registerOutput("rgb", Jo.Color3, $o.Neutral), i.registerOutput("r", Jo.Float, $o.Neutral), i.registerOutput("g", Jo.Float, $o.Neutral), i.registerOutput("b", Jo.Float, $o.Neutral), i.registerOutput("a", Jo.Float, $o.Neutral), i._inputs[0].addExcludedConnectionPointFromAllowedTypes(Jo.Vector2 | Jo.Vector3 | Jo.Vector4), i._inputs[0]._prioritizeVertex = !1, i } return W(t, e), t.prototype.getClassName = function () { return "CurrentScreenBlock" }, Object.defineProperty(t.prototype, "uv", { get: function () { return this._inputs[0] }, 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 }), t.prototype.initialize = function (e) { e._excludeVariableName("textureSampler") }, Object.defineProperty(t.prototype, "target", { get: function () { return this.uv.isConnected ? this.uv.sourceBlock.isInput ? $o.VertexAndFragment : $o.Fragment : $o.VertexAndFragment }, enumerable: !1, configurable: !0 }), t.prototype.prepareDefines = function (e, t, i) { i.setValue(this._linearDefineName, this.convertToGammaSpace, !0), i.setValue(this._gammaDefineName, this.convertToLinearSpace, !0) }, t.prototype.isReady = function () { return !(this.texture && !this.texture.isReadyOrNotBlocking()) }, t.prototype._injectVertexCode = function (e) { var t = this.uv; if (t.connectedPoint.ownerBlock.isInput && (t.connectedPoint.ownerBlock.isAttribute || e._emitUniformFromString(t.associatedVariableName, "vec2")), this._mainUVName = "vMain" + t.associatedVariableName, e._emitVaryingFromString(this._mainUVName, "vec2"), e.compilationString += "".concat(this._mainUVName, " = ").concat(t.associatedVariableName, ".xy;\n"), this._outputs.some((function (e) { return e.isConnectedInVertexShader }))) { this._writeTextureRead(e, !0); for (var i = 0, r = this._outputs; i < r.length; i++) { var n = r[i]; n.hasEndpoints && this._writeOutput(e, n, n.name, !0) } } }, t.prototype._writeTextureRead = function (e, t) { void 0 === t && (t = !1); var i = this.uv; if (t) { if (e.target === $o.Fragment) return; e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(i.associatedVariableName, ");\n") } else this.uv.ownerBlock.target !== $o.Fragment ? e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(this._mainUVName, ");\n") : e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(i.associatedVariableName, ");\n") }, t.prototype._writeOutput = function (e, t, i, r) { if (void 0 === r && (r = !1), r) { if (e.target === $o.Fragment) return; e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\n") } else this.uv.ownerBlock.target !== $o.Fragment ? (e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\n"), e.compilationString += "#ifdef ".concat(this._linearDefineName, "\n"), e.compilationString += "".concat(t.associatedVariableName, " = toGammaSpace(").concat(t.associatedVariableName, ");\n"), e.compilationString += "#endif\n", e.compilationString += "#ifdef ".concat(this._gammaDefineName, "\n"), e.compilationString += "".concat(t.associatedVariableName, " = toLinearSpace(").concat(t.associatedVariableName, ");\n"), e.compilationString += "#endif\n") : e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\n") }, t.prototype._buildBlock = function (t) { if (e.prototype._buildBlock.call(this, t), this._tempTextureRead = t._getFreeVariableName("tempTextureRead"), t.sharedData.blockingBlocks.indexOf(this) < 0 && t.sharedData.blockingBlocks.push(this), t.sharedData.textureBlocks.indexOf(this) < 0 && t.sharedData.textureBlocks.push(this), t.sharedData.blocksWithDefines.indexOf(this) < 0 && t.sharedData.blocksWithDefines.push(this), t.target !== $o.Fragment) return t._emit2DSampler(this._samplerName), void this._injectVertexCode(t); if (this._outputs.some((function (e) { return e.isConnectedInFragmentShader }))) { t._emit2DSampler(this._samplerName), this._linearDefineName = t._getFreeDefineName("ISLINEAR"), this._gammaDefineName = t._getFreeDefineName("ISGAMMA"); var i = "//".concat(this.name); t._emitFunctionFromInclude("helperFunctions", i), this._writeTextureRead(t); for (var r = 0, n = this._outputs; r < n.length; r++) { var o = n[r]; o.hasEndpoints && this._writeOutput(t, o, o.name) } return this } }, t.prototype.serialize = function () { var t = e.prototype.serialize.call(this); return t.convertToGammaSpace = this.convertToGammaSpace, t.convertToLinearSpace = this.convertToLinearSpace, this.texture && !this.texture.isRenderTarget && (t.texture = this.texture.serialize()), t }, t.prototype._deserialize = function (t, i, r) { e.prototype._deserialize.call(this, t, i, r), this.convertToGammaSpace = t.convertToGammaSpace, this.convertToLinearSpace = !!t.convertToLinearSpace, t.texture && (r = 0 === t.texture.url.indexOf("data:") ? "" : r, this.texture = vo.Parse(t.texture, i, r)) }, t }(sa); b("BABYLON.CurrentScreenBlock", Ea); var Sa = function (e) { function t(t) { var i = e.call(this, t, $o.Fragment) || this; return i._samplerName = "diffuseSampler", i.convertToGammaSpace = !1, i.convertToLinearSpace = !1, i._isUnique = !1, i.registerInput("uv", Jo.AutoDetect, !1, $o.VertexAndFragment), i.registerOutput("rgba", Jo.Color4, $o.Neutral), i.registerOutput("rgb", Jo.Color3, $o.Neutral), i.registerOutput("r", Jo.Float, $o.Neutral), i.registerOutput("g", Jo.Float, $o.Neutral), i.registerOutput("b", Jo.Float, $o.Neutral), i.registerOutput("a", Jo.Float, $o.Neutral), i._inputs[0].addExcludedConnectionPointFromAllowedTypes(Jo.Vector2 | Jo.Vector3 | Jo.Vector4), i } return W(t, e), t.prototype.getClassName = function () { return "ParticleTextureBlock" }, Object.defineProperty(t.prototype, "uv", { get: function () { return this._inputs[0] }, 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 }), t.prototype.initialize = function (e) { e._excludeVariableName("diffuseSampler") }, t.prototype.autoConfigure = function (e) { if (!this.uv.isConnected) { var t = e.getInputBlockByPredicate((function (e) { return e.isAttribute && "particle_uv" === e.name })); t || (t = new Ta("uv")).setAsAttribute("particle_uv"), t.output.connectTo(this.uv) } }, t.prototype.prepareDefines = function (e, t, i) { i.setValue(this._linearDefineName, this.convertToGammaSpace, !0), i.setValue(this._gammaDefineName, this.convertToLinearSpace, !0) }, t.prototype.isReady = function () { return !(this.texture && !this.texture.isReadyOrNotBlocking()) }, t.prototype._writeOutput = function (e, t, i) { e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\n"), e.compilationString += "#ifdef ".concat(this._linearDefineName, "\n"), e.compilationString += "".concat(t.associatedVariableName, " = toGammaSpace(").concat(t.associatedVariableName, ");\n"), e.compilationString += "#endif\n", e.compilationString += "#ifdef ".concat(this._gammaDefineName, "\n"), e.compilationString += "".concat(t.associatedVariableName, " = toLinearSpace(").concat(t.associatedVariableName, ");\n"), e.compilationString += "#endif\n" }, t.prototype._buildBlock = function (t) { if (e.prototype._buildBlock.call(this, t), t.target !== $o.Vertex) { this._tempTextureRead = t._getFreeVariableName("tempTextureRead"), t._emit2DSampler(this._samplerName), t.sharedData.blockingBlocks.push(this), t.sharedData.textureBlocks.push(this), t.sharedData.blocksWithDefines.push(this), this._linearDefineName = t._getFreeDefineName("ISLINEAR"), this._gammaDefineName = t._getFreeDefineName("ISGAMMA"); var i = "//".concat(this.name); t._emitFunctionFromInclude("helperFunctions", i), t.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(this.uv.associatedVariableName, ");\n"); for (var r = 0, n = this._outputs; r < n.length; r++) { var o = n[r]; o.hasEndpoints && this._writeOutput(t, o, o.name) } return this } }, t.prototype.serialize = function () { var t = e.prototype.serialize.call(this); return t.convertToGammaSpace = this.convertToGammaSpace, t.convertToLinearSpace = this.convertToLinearSpace, this.texture && !this.texture.isRenderTarget && (t.texture = this.texture.serialize()), t }, t.prototype._deserialize = function (t, i, r) { e.prototype._deserialize.call(this, t, i, r), this.convertToGammaSpace = t.convertToGammaSpace, this.convertToLinearSpace = !!t.convertToLinearSpace, t.texture && (r = 0 === t.texture.url.indexOf("data:") ? "" : r, this.texture = vo.Parse(t.texture, i, r)) }, t }(sa); b("BABYLON.ParticleTextureBlock", Sa); var xa = function (e) { function t(t) { var i = e.call(this, t, $o.Fragment) || this; return i._isUnique = !0, i.registerInput("color", Jo.Color4, !1, $o.Fragment), i.registerOutput("rampColor", Jo.Color4, $o.Fragment), i } return W(t, e), t.prototype.getClassName = function () { return "ParticleRampGradientBlock" }, Object.defineProperty(t.prototype, "color", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rampColor", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype.initialize = function (e) { e._excludeVariableName("remapRanges"), e._excludeVariableName("rampSampler"), e._excludeVariableName("baseColor"), e._excludeVariableName("alpha"), e._excludeVariableName("remappedColorIndex"), e._excludeVariableName("rampColor"), e._excludeVariableName("finalAlpha") }, t.prototype._buildBlock = function (t) { if (e.prototype._buildBlock.call(this, t), t.target !== $o.Vertex) return t._emit2DSampler("rampSampler"), t._emitVaryingFromString("remapRanges", "vec4", "RAMPGRADIENT"), t.compilationString += "\n #ifdef RAMPGRADIENT\n vec4 baseColor = ".concat(this.color.associatedVariableName, ";\n float alpha = ").concat(this.color.associatedVariableName, ".a;\n\n float remappedColorIndex = clamp((alpha - remapRanges.x) / remapRanges.y, 0.0, 1.0);\n\n vec4 rampColor = texture2D(rampSampler, vec2(1.0 - remappedColorIndex, 0.));\n baseColor.rgb *= rampColor.rgb;\n\n // Remapped alpha\n float finalAlpha = baseColor.a;\n baseColor.a = clamp((alpha * rampColor.a - remapRanges.z) / remapRanges.w, 0.0, 1.0);\n\n ").concat(this._declareOutput(this.rampColor, t), " = baseColor;\n #else\n ").concat(this._declareOutput(this.rampColor, t), " = ").concat(this.color.associatedVariableName, ";\n #endif\n "), this }, t }(sa); b("BABYLON.ParticleRampGradientBlock", xa); var Aa = function (e) { function t(t) { var i = e.call(this, t, $o.Fragment) || this; return i._isUnique = !0, i.registerInput("color", Jo.Color4, !1, $o.Fragment), i.registerInput("alphaTexture", Jo.Float, !1, $o.Fragment), i.registerInput("alphaColor", Jo.Float, !1, $o.Fragment), i.registerOutput("blendColor", Jo.Color4, $o.Fragment), i } return W(t, e), t.prototype.getClassName = function () { return "ParticleBlendMultiplyBlock" }, Object.defineProperty(t.prototype, "color", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "alphaTexture", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "alphaColor", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "blendColor", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype.initialize = function (e) { e._excludeVariableName("sourceAlpha") }, t.prototype._buildBlock = function (t) { if (e.prototype._buildBlock.call(this, t), t.target !== $o.Vertex) return t.compilationString += "\n #ifdef BLENDMULTIPLYMODE\n ".concat(this._declareOutput(this.blendColor, t), ";\n float sourceAlpha = ").concat(this.alphaColor.associatedVariableName, " * ").concat(this.alphaTexture.associatedVariableName, ";\n ").concat(this.blendColor.associatedVariableName, ".rgb = ").concat(this.color.associatedVariableName, ".rgb * sourceAlpha + vec3(1.0) * (1.0 - sourceAlpha);\n ").concat(this.blendColor.associatedVariableName, ".a = ").concat(this.color.associatedVariableName, ".a;\n #else\n ").concat(this._declareOutput(this.blendColor, t), " = ").concat(this.color.associatedVariableName, ";\n #endif\n "), this }, t }(sa); b("BABYLON.ParticleBlendMultiplyBlock", Aa); var Ra = function () { function e() { this._defines = {}, this._currentRank = 32, this._maxRank = -1, this._mesh = null } return e.prototype.unBindMesh = function () { this._mesh = null }, e.prototype.addFallback = function (e, t) { this._defines[e] || (e < this._currentRank && (this._currentRank = e), e > this._maxRank && (this._maxRank = e), this._defines[e] = new Array), this._defines[e].push(t) }, e.prototype.addCPUSkinningFallback = function (e, t) { this._mesh = t, e < this._currentRank && (this._currentRank = e), e > this._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; r < i.meshes.length; r++) { var n = i.meshes[r]; if (n.material) { if (n.computeBonesUsingShaders && 0 !== n.numBoneInfluencers) if (n.material.getEffect() === t) n.computeBonesUsingShaders = !1; else if (n.subMeshes) for (var o = 0, a = n.subMeshes; o < a.length; o++)if (a[o].effect === t) { n.computeBonesUsingShaders = !1; break } } else !this._mesh.material && n.computeBonesUsingShaders && n.numBoneInfluencers > 0 && (n.computeBonesUsingShaders = !1) } } else { var s = this._defines[this._currentRank]; if (s) for (r = 0; r < s.length; r++)e = e.replace("#define " + s[r], ""); this._currentRank++ } return e }, e }(); Ut.ShadersStore.postprocessVertexShader = "attribute vec2 position;uniform vec2 scale;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)*scale;gl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}"; var Ca = function () { function e(e, t, i, r) { this._textures = null, this._faceIndices = null, this._layerIndices = null, this._samples = 1, this._attachments = null, this._generateStencilBuffer = !1, this._generateDepthBuffer = !1, this._depthStencilTextureWithStencil = !1, this._isMulti = e, this._isCube = t, this._size = i, this._engine = r, this._depthStencilTexture = null } return Object.defineProperty(e.prototype, "depthStencilTexture", { get: function () { return this._depthStencilTexture }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "depthStencilTextureWithStencil", { get: function () { return this._depthStencilTextureWithStencil }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isCube", { get: function () { return this._isCube }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isMulti", { get: function () { return this._isMulti }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "is2DArray", { get: function () { return this.layers > 0 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "size", { get: function () { return this.width }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "width", { get: function () { return this._size.width || this._size }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "height", { get: function () { return this._size.height || this._size }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "layers", { get: function () { return this._size.layers || 0 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "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] && 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 !== It.Depth && p !== It.DepthStencil || (h = !0, d--); for (var f = [], _ = [], m = [], g = [], v = [], y = [], b = [], T = {}, E = 0; E < d; ++E) { var S = u[E]; f.push(S.samplingMode), _.push(S.type), m.push(S.format), void 0 !== (R = T[S.uniqueId]) ? (g.push(-1), b.push(0)) : (T[S.uniqueId] = E, S.is2DArray ? (g.push(a.TEXTURE_2D_ARRAY), b.push(S.depth)) : S.isCube ? (g.push(a.TEXTURE_CUBE_MAP), b.push(0)) : S.is3D ? (g.push(a.TEXTURE_3D), b.push(S.depth)) : (g.push(a.TEXTURE_2D), b.push(0))), this._faceIndices && v.push(null !== (e = this._faceIndices[E]) && void 0 !== e ? e : 0), this._layerIndices && y.push(null !== (t = this._layerIndices[E]) && void 0 !== t ? t : 0) } var x = { samplingModes: f, generateMipMaps: u[0].generateMipMaps, generateDepthBuffer: this._generateDepthBuffer, generateStencilBuffer: this._generateStencilBuffer, generateDepthTexture: h, types: _, formats: m, textureCount: d, targetTypes: g, faceIndex: v, layerIndex: y, layerCounts: b }, A = { width: this.width, height: this.height }; for (c = this._engine.createMultipleRenderTarget(A, x), E = 0; E < d; ++E)if (-1 === g[E]) { var R = T[u[E].uniqueId]; c.setTexture(c.textures[R], E) } } } else { var C = {}; C.generateDepthBuffer = this._generateDepthBuffer, C.generateMipMaps = null !== (r = null === (i = this.texture) || void 0 === i ? void 0 : i.generateMipMaps) && void 0 !== r && r, C.generateStencilBuffer = this._generateStencilBuffer, C.samplingMode = null === (n = this.texture) || void 0 === n ? void 0 : n.samplingMode, C.type = null === (o = this.texture) || void 0 === o ? void 0 : o.type, C.format = null === (s = this.texture) || void 0 === s ? void 0 : s.format, this.isCube ? c = this._engine.createRenderTargetCubeTexture(this.width, C) : (A = { width: this.width, height: this.height, layers: this.is2DArray ? null === (l = this.texture) || void 0 === l ? void 0 : l.depth : void 0 }, c = this._engine.createRenderTargetTexture(A, C)), c.texture.isReady = !0 } return c }, e.prototype._swapRenderTargetWrapper = function (e) { if (this._textures && e._textures) for (var t = 0; t < this._textures.length; ++t)this._textures[t]._swapAndDie(e._textures[t], !1), e._textures[t].isReady = !0; this._depthStencilTexture && e._depthStencilTexture && (this._depthStencilTexture._swapAndDie(e._depthStencilTexture), e._depthStencilTexture.isReady = !0), this._textures = null, this._depthStencilTexture = null }, e.prototype._rebuild = function () { var e = this._cloneRenderTargetWrapper(); if (e) { if (this._depthStencilTexture) { var t = this._depthStencilTexture.samplingMode, i = t === a.TEXTURE_BILINEAR_SAMPLINGMODE || t === a.TEXTURE_TRILINEAR_SAMPLINGMODE || t === a.TEXTURE_LINEAR_LINEAR_MIPNEAREST; e.createDepthStencilTexture(this._depthStencilTexture._comparisonFunction, i, this._depthStencilTextureWithStencil, this._depthStencilTexture.samples) } this.samples > 1 && 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 }(), Pa = 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._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 && i.deleteRenderbuffer(t._depthStencilBuffer), t._depthStencilBuffer = this._depthStencilBuffer, this._engine._bindUnboundFramebuffer(n), i.framebufferRenderbuffer(i.FRAMEBUFFER, i.DEPTH_ATTACHMENT, 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; a < o; a++) { var s = this.textures[a]; s && (s.is2DArray || s.is3D ? this._bindTextureRenderTarget(s, a, this.layerIndices[a]) : s.isCube ? this._bindTextureRenderTarget(s, a, this.faceIndices[a]) : this._bindTextureRenderTarget(s, a)) } }, t.prototype.setLayerAndFaceIndex = function (t, i, r) { if (void 0 === t && (t = 0), e.prototype.setLayerAndFaceIndex.call(this, t, i, r), this.textures && this.layerIndices && this.faceIndices) { var n = this.textures[t]; n.is2DArray || n.is3D ? this._bindTextureRenderTarget(this.textures[t], t, this.layerIndices[t]) : n.isCube && this._bindTextureRenderTarget(this.textures[t], t, this.faceIndices[t]) } }, t.prototype.dispose = function (t) { void 0 === t && (t = this._disposeOnlyFramebuffers); var i = this._context; t || (this._colorTextureArray && (this._context.deleteTexture(this._colorTextureArray), this._colorTextureArray = null), this._depthStencilTextureArray && (this._context.deleteTexture(this._depthStencilTextureArray), this._depthStencilTextureArray = null)), this._framebuffer && (i.deleteFramebuffer(this._framebuffer), this._framebuffer = null), this._depthStencilBuffer && (i.deleteRenderbuffer(this._depthStencilBuffer), this._depthStencilBuffer = null), this._MSAAFramebuffer && (i.deleteFramebuffer(this._MSAAFramebuffer), this._MSAAFramebuffer = null), e.prototype.dispose.call(this, t) }, t }(Ca); ti.prototype._createHardwareRenderTargetWrapper = function (e, t, i) { var r = new Pa(e, t, i, this, this._gl); return this._renderTargetWrapperCache.push(r), r }, ti.prototype.createRenderTargetTexture = function (e, t) { var i, r, n = this._createHardwareRenderTargetWrapper(!1, !1, e), o = !0, a = !1, s = !1, l = void 0, c = 1; void 0 !== t && "object" == typeof t && (o = null === (i = t.generateDepthBuffer) || void 0 === i || i, a = !!t.generateStencilBuffer, s = !!t.noColorAttachment, l = t.colorAttachment, c = null !== (r = t.samples) && void 0 !== r ? r : 1); var u = l || (s ? null : this._createInternalTexture(e, t, !0, It.RenderTarget)), h = e.width || e, d = e.height || e, p = this._currentFramebuffer, f = this._gl, _ = f.createFramebuffer(); return this._bindUnboundFramebuffer(_), n._depthStencilBuffer = this._setupFramebufferDepthAttachments(a, o, h, d), u && !u.is2DArray && f.framebufferTexture2D(f.FRAMEBUFFER, f.COLOR_ATTACHMENT0, f.TEXTURE_2D, u._hardwareTexture.underlyingResource, 0), this._bindUnboundFramebuffer(p), n._framebuffer = _, n._generateDepthBuffer = o, n._generateStencilBuffer = a, n.setTextures(u), this.updateRenderTargetTextureSampleCount(n, c), n }, ti.prototype.createDepthStencilTexture = function (e, t, i) { if (t.isCube) { var r = e.width || e; return this._createDepthStencilCubeTexture(r, t, i) } return this._createDepthStencilTexture(e, t, i) }, ti.prototype._createDepthStencilTexture = function (e, t, i) { var r = this._gl, n = e.layers || 0, o = 0 !== n ? r.TEXTURE_2D_ARRAY : r.TEXTURE_2D, s = new Ht(this, It.DepthStencil); if (!this._caps.depthTextureExtension) return $.Error("Depth texture is not supported by your browser or hardware."), s; var l = H({ bilinearFiltering: !1, comparisonFunction: 0, generateStencil: !1 }, t); if (this._bindTextureDirectly(o, s, !0), this._setupDepthStencilTexture(s, e, l.generateStencil, 0 !== l.comparisonFunction && l.bilinearFiltering, l.comparisonFunction, l.samples), void 0 !== l.depthTextureFormat) { if (l.depthTextureFormat !== a.TEXTUREFORMAT_DEPTH16 && l.depthTextureFormat !== a.TEXTUREFORMAT_DEPTH24 && l.depthTextureFormat !== a.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8 && l.depthTextureFormat !== a.TEXTUREFORMAT_DEPTH24_STENCIL8 && l.depthTextureFormat !== a.TEXTUREFORMAT_DEPTH32_FLOAT && l.depthTextureFormat !== a.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8) return $.Error("Depth texture format is not supported."), s; s.format = l.depthTextureFormat } else s.format = l.generateStencil ? a.TEXTUREFORMAT_DEPTH24_STENCIL8 : a.TEXTUREFORMAT_DEPTH24; var c = s.format === a.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8 || s.format === a.TEXTUREFORMAT_DEPTH24_STENCIL8 || s.format === a.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8; i._depthStencilTexture = s, i._depthStencilTextureWithStencil = c; var u = r.UNSIGNED_INT; s.format === a.TEXTUREFORMAT_DEPTH16 ? u = r.UNSIGNED_SHORT : s.format === a.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8 || s.format === a.TEXTUREFORMAT_DEPTH24_STENCIL8 ? u = r.UNSIGNED_INT_24_8 : s.format === a.TEXTUREFORMAT_DEPTH32_FLOAT ? u = r.FLOAT : s.format === a.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8 && (u = r.FLOAT_32_UNSIGNED_INT_24_8_REV); var h = c ? r.DEPTH_STENCIL : r.DEPTH_COMPONENT, d = h; this.webGLVersion > 1 && (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 }, ti.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 Ia = 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 = nt.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 Ci(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 Jt(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 Ci(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 < this._textureCache.length; r++)if (this._textureCache[r].texture.width === e.width && this._textureCache[r].texture.height === e.height && this._textureCache[r].postProcessChannel === i && this._textureCache[r].texture._generateDepthBuffer === t.generateDepthBuffer && this._textureCache[r].texture.samples === t.samples) return this._textureCache[r].texture; var n = this._engine.createRenderTargetTexture(e, t); return this._textureCache.push({ texture: n, postProcessChannel: i, lastUsedRenderId: -1 }), n }, e.prototype._flushTextureCache = function () { for (var e = this._renderId, t = this._textureCache.length - 1; t >= 0; t--)if (e - this._textureCache[t].lastUsedRenderId > 100) { for (var i = !1, r = 0; r < this._textures.length; r++)if (this._textures.data[r] === this._textureCache[t].texture) { i = !0; break } i || (this._textureCache[t].texture.dispose(), this._textureCache.splice(t, 1)) } }, e.prototype._resize = function (e, t, i, r, n) { this._textures.length > 0 && this._textures.reset(), this.width = e, this.height = t; for (var o = null, a = 0; a < i._postProcesses.length; a++)if (null !== i._postProcesses[a]) { o = i._postProcesses[a]; break } var s = { width: this.width, height: this.height }, l = { generateMipMaps: r, generateDepthBuffer: n || o === this, generateStencilBuffer: (n || o === this) && this._engine.isStencilEnable, samplingMode: this.renderTargetSamplingMode, type: this._textureType, format: this._textureFormat, samples: this._samples, label: "PostProcessRTT-" + this.name }; this._textures.push(this._createRenderTargetTexture(s, l, 0)), this._reusable && this._textures.push(this._createRenderTargetTexture(s, l, 1)), this._texelSize.copyFromFloats(1 / this.width, 1 / this.height), this.onSizeChangedObservable.notifyObservers(this) }, e.prototype.activate = function (e, t, i) { var r, n, o = this; void 0 === t && (t = null); var s = (e = e || this._camera).getScene(), l = s.getEngine(), c = l.getCaps().maxTextureSize, u = (t ? t.width : this._engine.getRenderWidth(!0)) * this._options | 0, h = (t ? t.height : this._engine.getRenderHeight(!0)) * this._options | 0, d = e.parent; !d || d.leftCamera != e && d.rightCamera != e || (u /= 2); var p, f = this._options.width || u, _ = this._options.height || h, m = this.renderTargetSamplingMode !== a.TEXTURE_NEAREST_LINEAR && this.renderTargetSamplingMode !== a.TEXTURE_NEAREST_NEAREST && this.renderTargetSamplingMode !== a.TEXTURE_LINEAR_LINEAR; if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) { if (this.adaptScaleToCurrentViewport) { var g = l.currentViewport; g && (f *= g.width, _ *= g.height) } (m || this.alwaysForcePOT) && (this._options.width || (f = l.needPOTTextures ? In.GetExponentOfTwo(f, c, this.scaleMode) : f), this._options.height || (_ = l.needPOTTextures ? In.GetExponentOfTwo(_, c, this.scaleMode) : _)), this.width === f && this.height === _ || this._resize(f, _, e, m, i), this._textures.forEach((function (e) { e.samples !== o.samples && o._engine.updateRenderTargetTextureSampleCount(e, o.samples) })), this._flushTextureCache(), this._renderId++ } if (this._shareOutputWithPostProcess) p = this._shareOutputWithPostProcess.inputTexture; else if (this._forcedOutputTexture) p = this._forcedOutputTexture, this.width = this._forcedOutputTexture.width, this.height = this._forcedOutputTexture.height; else { p = this.inputTexture; for (var v = void 0, y = 0; y < this._textureCache.length; y++)if (this._textureCache[y].texture === p) { v = this._textureCache[y]; break } v && (v.lastUsedRenderId = this._renderId) } return this.enablePixelPerfectMode ? (this._scaleRatio.copyFromFloats(u / f, h / _), this._engine.bindFramebuffer(p, 0, u, h, this.forceFullscreenViewport)) : (this._scaleRatio.copyFromFloats(1, 1), this._engine.bindFramebuffer(p, 0, void 0, void 0, this.forceFullscreenViewport)), null === (n = (r = this._engine)._debugInsertMarker) || void 0 === n || n.call(r, "post process ".concat(this.name, " input")), this.onActivateObservable.notifyObservers(e), this.autoClear && (this.alphaMode === a.ALPHA_DISABLE || this.forceAutoClearInAlphaMode) && this._engine.clear(this.clearColor ? this.clearColor : s.clearColor, s._allowPostProcessClearColor, !0, !0), this._reusable && (this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2), p }, Object.defineProperty(e.prototype, "isSupported", { get: function () { return this._drawWrapper.effect.isSupported }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "aspectRatio", { get: function () { return this._shareOutputWithPostProcess ? this._shareOutputWithPostProcess.aspectRatio : this._forcedOutputTexture ? this._forcedOutputTexture.width / this._forcedOutputTexture.height : this.width / this.height }, enumerable: !1, configurable: !0 }), e.prototype.isReady = function () { var e, t; return null !== (t = null === (e = this._drawWrapper.effect) || void 0 === e ? void 0 : e.isReady()) && void 0 !== t && t }, e.prototype.apply = function () { var t, i, r, n; return (null === (t = this._drawWrapper.effect) || void 0 === t ? void 0 : t.isReady()) ? (this._engine.enableEffect(this._drawWrapper), this._engine.setState(!1), this._engine.setDepthBuffer(!1), this._engine.setDepthWrite(!1), this._engine.setAlphaMode(this.alphaMode), this.alphaConstants && this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a), n = this._shareOutputWithPostProcess ? this._shareOutputWithPostProcess.inputTexture : this._forcedOutputTexture ? this._forcedOutputTexture : this.inputTexture, this.externalTextureSamplerBinding || this._drawWrapper.effect._bindTexture("textureSampler", null == n ? void 0 : n.texture), this._drawWrapper.effect.setVector2("scale", this._scaleRatio), this.onApplyObservable.notifyObservers(this._drawWrapper.effect), null === (r = null === (i = e._GetShaderCodeProcessing(this.name)) || void 0 === i ? void 0 : i.bindCustomBindings) || void 0 === r || r.call(i, this.name, this._drawWrapper.effect), this._drawWrapper.effect) : null }, e.prototype._disposeTextures = function () { this._shareOutputWithPostProcess || this._forcedOutputTexture ? this._disposeTextureCache() : (this._disposeTextureCache(), this._textures.dispose()) }, e.prototype._disposeTextureCache = function () { for (var e = this._textureCache.length - 1; e >= 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 = Ue.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 Ue.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([xe()], e.prototype, "uniqueId", void 0), X([xe()], e.prototype, "name", void 0), X([xe()], e.prototype, "width", void 0), X([xe()], e.prototype, "height", void 0), X([xe()], e.prototype, "renderTargetSamplingMode", void 0), X([De()], e.prototype, "clearColor", void 0), X([xe()], e.prototype, "autoClear", void 0), X([xe()], e.prototype, "forceAutoClearInAlphaMode", void 0), X([xe()], e.prototype, "alphaMode", void 0), X([xe()], e.prototype, "alphaConstants", void 0), X([xe()], e.prototype, "enablePixelPerfectMode", void 0), X([xe()], e.prototype, "forceFullscreenViewport", void 0), X([xe()], e.prototype, "scaleMode", void 0), X([xe()], e.prototype, "alwaysForcePOT", void 0), X([xe("samples")], e.prototype, "_samples", void 0), X([xe()], e.prototype, "adaptScaleToCurrentViewport", void 0), e }(); b("BABYLON.PostProcess", Ia); var Ma = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.xSwizzle = "x", i.ySwizzle = "y", i.zSwizzle = "z", i.wSwizzle = "w", i.registerInput("xyzw ", Jo.Vector4, !0), i.registerInput("xyz ", Jo.Vector3, !0), i.registerInput("xy ", Jo.Vector2, !0), i.registerInput("zw ", Jo.Vector2, !0), i.registerInput("x", Jo.Float, !0), i.registerInput("y", Jo.Float, !0), i.registerInput("z", Jo.Float, !0), i.registerInput("w", Jo.Float, !0), i.registerOutput("xyzw", Jo.Vector4), i.registerOutput("xyz", Jo.Vector3), i.registerOutput("xy", Jo.Vector2), i.registerOutput("zw", Jo.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 }(sa); b("BABYLON.VectorMergerBlock", Ma); var Oa = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.sourceRange = new A(-1, 1), i.targetRange = new A(0, 1), i.registerInput("input", Jo.AutoDetect), i.registerInput("sourceMin", Jo.Float, !0), i.registerInput("sourceMax", Jo.Float, !0), i.registerInput("targetMin", Jo.Float, !0), i.registerInput("targetMax", Jo.Float, !0), i.registerOutput("output", Jo.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([ha("From", ca.Vector2)], t.prototype, "sourceRange", void 0), X([ha("To", ca.Vector2)], t.prototype, "targetRange", void 0), t }(sa); b("BABYLON.RemapBlock", Oa); var Da, Na = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("left", Jo.AutoDetect), i.registerInput("right", Jo.AutoDetect), i.registerOutput("output", Jo.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i._inputs[0].acceptedConnectionPointTypes.push(Jo.Float), i._inputs[1].acceptedConnectionPointTypes.push(Jo.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 }(sa); b("BABYLON.MultiplyBlock", Na), function (e) { e[e.Material = 0] = "Material", e[e.PostProcess = 1] = "PostProcess", e[e.Particle = 2] = "Particle", e[e.ProceduralTexture = 3] = "ProceduralTexture" }(Da || (Da = {})); var Fa = 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 }(), La = 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 }(), wa = 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 }(), Ba = 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 }(wa), Ua = 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 }(), Va = 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 }(), ka = 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 }(), Ga = 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 }(ka), za = 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 }(), Wa = 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(Hi.PositionKind), this._normals = e.getVerticesData(Hi.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 }(), Ha = 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 Di, 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; n < o.length; n++) { if (o[n].gradient === e) { t.splice(r, 1); break } r++ } return i && i.dispose(), this }, e.prototype.createPointEmitter = function (e, t) { var i = new Va; return i.direction1 = e, i.direction2 = t, this.particleEmitterType = i, i }, e.prototype.createHemisphericEmitter = function (e, t) { void 0 === e && (e = 1), void 0 === t && (t = 1); var i = new Ua(e, t); return this.particleEmitterType = i, i }, e.prototype.createSphereEmitter = function (e, t) { void 0 === e && (e = 1), void 0 === t && (t = 1); var i = new ka(e, t); return this.particleEmitterType = i, i }, e.prototype.createDirectedSphereEmitter = function (e, t, i) { void 0 === e && (e = 1), void 0 === t && (t = new R(0, 1, 0)), void 0 === i && (i = new R(0, 1, 0)); var r = new Ga(e, t, i); return this.particleEmitterType = r, r }, e.prototype.createCylinderEmitter = function (e, t, i, r) { void 0 === e && (e = 1), void 0 === t && (t = 1), void 0 === i && (i = 1), void 0 === r && (r = 0); var n = new wa(e, t, i, r); return this.particleEmitterType = n, n }, e.prototype.createDirectedCylinderEmitter = function (e, t, i, r, n) { void 0 === e && (e = 1), void 0 === t && (t = 1), void 0 === i && (i = 1), void 0 === r && (r = new R(0, 1, 0)), void 0 === n && (n = new R(0, 1, 0)); var o = new Ba(e, t, i, r, n); return this.particleEmitterType = o, o }, e.prototype.createConeEmitter = function (e, t) { void 0 === e && (e = 1), void 0 === t && (t = Math.PI / 4); var i = new La(e, t); return this.particleEmitterType = i, i }, e.prototype.createBoxEmitter = function (e, t, i, r) { var n = new Fa; return this.particleEmitterType = n, this.direction1 = e, this.direction2 = t, this.minEmitBox = i, this.maxEmitBox = r, n }, e.BLENDMODE_ONEONE = 0, e.BLENDMODE_STANDARD = 1, e.BLENDMODE_ADD = 2, e.BLENDMODE_MULTIPLY = 3, e.BLENDMODE_MULTIPLYADD = 4, e }(), Xa = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("rgba", Jo.Color4, !0), i.registerInput("rgb ", Jo.Color3, !0), i.registerOutput("rgb", Jo.Color3), i.registerOutput("r", Jo.Float), i.registerOutput("g", Jo.Float), i.registerOutput("b", Jo.Float), i.registerOutput("a", Jo.Float), i.inputsAreExclusive = !0, i } return W(t, e), t.prototype.getClassName = function () { return "ColorSplitterBlock" }, Object.defineProperty(t.prototype, "rgba", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgbIn", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgbOut", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "r", { get: function () { return this._outputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "g", { get: function () { return this._outputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "b", { get: function () { return this._outputs[3] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "a", { get: function () { return this._outputs[4] }, enumerable: !1, configurable: !0 }), t.prototype._inputRename = function (e) { return "rgb " === e ? "rgbIn" : e }, t.prototype._outputRename = function (e) { return "rgb" === e ? "rgbOut" : e }, t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t); var i = this.rgba.isConnected ? this.rgba : this.rgbIn; if (i.isConnected) { var r = this._outputs[0], n = this._outputs[1], o = this._outputs[2], a = this._outputs[3], s = this._outputs[4]; return r.hasEndpoints && (t.compilationString += this._declareOutput(r, t) + " = ".concat(i.associatedVariableName, ".rgb;\n")), n.hasEndpoints && (t.compilationString += this._declareOutput(n, t) + " = ".concat(i.associatedVariableName, ".r;\n")), o.hasEndpoints && (t.compilationString += this._declareOutput(o, t) + " = ".concat(i.associatedVariableName, ".g;\n")), a.hasEndpoints && (t.compilationString += this._declareOutput(a, t) + " = ".concat(i.associatedVariableName, ".b;\n")), s.hasEndpoints && (t.compilationString += this._declareOutput(s, t) + " = ".concat(i.associatedVariableName, ".a;\n")), this } }, t }(sa); b("BABYLON.ColorSplitterBlock", Xa), ti.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); var n = this._gl, o = new Ht(this, It.RenderTarget); this._bindTextureDirectly(n.TEXTURE_CUBE_MAP, o, !0); var s = this._getSamplingParameters(r.samplingMode, r.generateMipMaps); r.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloat || (r.type = a.TEXTURETYPE_UNSIGNED_INT, $.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type")), n.texParameteri(n.TEXTURE_CUBE_MAP, n.TEXTURE_MAG_FILTER, s.mag), n.texParameteri(n.TEXTURE_CUBE_MAP, n.TEXTURE_MIN_FILTER, s.min), n.texParameteri(n.TEXTURE_CUBE_MAP, n.TEXTURE_WRAP_S, n.CLAMP_TO_EDGE), n.texParameteri(n.TEXTURE_CUBE_MAP, n.TEXTURE_WRAP_T, n.CLAMP_TO_EDGE); for (var l = 0; l < 6; l++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + l, 0, this._getRGBABufferInternalSizedFormat(r.type, r.format), e, e, 0, this._getInternalFormat(r.format), this._getWebGLTextureType(r.type), null); var c = n.createFramebuffer(); return this._bindUnboundFramebuffer(c), i._depthStencilBuffer = this._setupFramebufferDepthAttachments(r.generateStencilBuffer, r.generateDepthBuffer, e, e), r.generateMipMaps && n.generateMipmap(n.TEXTURE_CUBE_MAP), this._bindTextureDirectly(n.TEXTURE_CUBE_MAP, null), this._bindUnboundFramebuffer(null), i._framebuffer = c, i._generateDepthBuffer = r.generateDepthBuffer, i._generateStencilBuffer = r.generateStencilBuffer, o.width = e, o.height = e, o.isReady = !0, o.isCube = !0, o.samples = 1, o.generateMipMaps = r.generateMipMaps, o.samplingMode = r.samplingMode, o.type = r.type, o.format = r.format, this._internalTexturesCache.push(o), i.setTextures(o), i }; var ja = { positions: [1, 1, -1, 1, -1, -1, 1, -1], indices: [0, 1, 2, 0, 2, 3] }, Ya = function () { function e(e, t) { var i; void 0 === t && (t = ja); var r, n, o = this; this._fullscreenViewport = new sn(0, 0, 1, 1); var a = null !== (r = t.positions) && void 0 !== r ? r : ja.positions, s = null !== (n = t.indices) && void 0 !== n ? n : ja.indices; this.engine = e, this._vertexBuffers = ((i = {})[Hi.PositionKind] = new Hi(e, a, Hi.PositionKind, !1, !1, 2), i), this._indexBuffer = e.createIndexBuffer(s), this._onContextRestoredObserver = e.onContextRestoredObservable.add((function () { for (var t in o._indexBuffer = e.createIndexBuffer(s), o._vertexBuffers) o._vertexBuffers[t]._rebuild() })) } return e.prototype.setViewport = function (e) { void 0 === e && (e = this._fullscreenViewport), this.engine.setViewport(e) }, e.prototype.bindBuffers = function (e) { this.engine.bindBuffers(this._vertexBuffers, this._indexBuffer, e) }, e.prototype.applyEffectWrapper = function (e) { this.engine.setState(!0), this.engine.depthCullingState.depthTest = !1, this.engine.stencilState.stencilTest = !1, this.engine.enableEffect(e._drawWrapper), this.bindBuffers(e.effect), e.onApplyObservable.notifyObservers({}) }, e.prototype.saveStates = function () { this._savedStateDepthTest = this.engine.depthCullingState.depthTest, this._savedStateStencilTest = this.engine.stencilState.stencilTest }, e.prototype.restoreStates = function () { this.engine.depthCullingState.depthTest = this._savedStateDepthTest, this.engine.stencilState.stencilTest = this._savedStateStencilTest }, e.prototype.draw = function () { this.engine.drawElementsType(a.MATERIAL_TriangleFillMode, 0, 6) }, e.prototype._isRenderTargetTexture = function (e) { return void 0 !== e.renderTarget }, e.prototype.render = function (e, t) { if (void 0 === t && (t = null), e.effect.isReady()) { this.saveStates(), this.setViewport(); var i = null === t ? null : this._isRenderTargetTexture(t) ? t.renderTarget : t; i && this.engine.bindFramebuffer(i), this.applyEffectWrapper(e), this.draw(), i && this.engine.unBindFramebuffer(i), this.restoreStates() } }, e.prototype.dispose = function () { var e = this._vertexBuffers[Hi.PositionKind]; e && (e.dispose(), delete this._vertexBuffers[Hi.PositionKind]), this._indexBuffer && this.engine._releaseBuffer(this._indexBuffer), this._onContextRestoredObserver && (this.engine.onContextRestoredObservable.remove(this._onContextRestoredObserver), this._onContextRestoredObserver = null) }, e }(), Ka = function () { function e(e) { var t, i = this; this.onApplyObservable = new u; var r = e.uniformNames || []; e.vertexShader ? t = { fragmentSource: e.fragmentShader, vertexSource: e.vertexShader, spectorName: e.name || "effectWrapper" } : (r.push("scale"), t = { fragmentSource: e.fragmentShader, vertex: "postprocess", spectorName: e.name || "effectWrapper" }, this.onApplyObservable.add((function () { i.effect.setFloat2("scale", 1, 1) }))); var n = e.defines ? e.defines.join("\n") : ""; this._drawWrapper = new Jt(e.engine), e.useShaderStore ? (t.fragment = t.fragmentSource, t.vertex || (t.vertex = t.vertexSource), delete t.fragmentSource, delete t.vertexSource, this.effect = e.engine.createEffect(t, e.attributeNames || ["position"], r, e.samplerNames, n, void 0, e.onCompiled, void 0, void 0, e.shaderLanguage)) : (this.effect = new Vt(t, e.attributeNames || ["position"], r, e.samplerNames, e.engine, n, void 0, e.onCompiled, void 0, void 0, void 0, e.shaderLanguage), this._onContextRestoredObserver = e.engine.onContextRestoredObservable.add((function () { i.effect._pipelineContext = null, i.effect._wasPreviouslyReady = !1, i.effect._prepareEffect() }))) } return Object.defineProperty(e.prototype, "effect", { get: function () { return this._drawWrapper.effect }, set: function (e) { this._drawWrapper.effect = e }, enumerable: !1, configurable: !0 }), e.prototype.dispose = function () { this._onContextRestoredObserver && (this.effect.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver), this._onContextRestoredObserver = null), this.effect.dispose() }, e }(), Qa = "passPixelShader", qa = "varying vec2 vUV;uniform sampler2D textureSampler;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{gl_FragColor=texture2D(textureSampler,vUV);}"; Ut.ShadersStore[Qa] = qa; var Za = Qa, Ja = qa, $a = function () { function e() { } return e._CreateDumpRenderer = function () { if (!e._DumpToolsEngine) { var t = new OffscreenCanvas(100, 100), i = null, r = { preserveDrawingBuffer: !0, depth: !1, stencil: !1, alpha: !0, premultipliedAlpha: !1, antialias: !1, failIfMajorPerformanceCaveat: !1 }; try { i = new ti(t, !1, r) } catch (e) { t = document.createElement("canvas"), i = new ti(t, !1, r) } i.getCaps().parallelShaderCompile = void 0; var n = new Ya(i), o = new Ka({ engine: i, name: Za, fragmentShader: Ja, samplerNames: ["textureSampler"] }); e._DumpToolsEngine = { canvas: t, engine: i, renderer: n, wrapper: o } } return e._DumpToolsEngine }, e.DumpFramebuffer = function (t, i, r, n, o, a, s) { return void 0 === o && (o = "image/png"), j(this, void 0, void 0, (function () { var l, c; return Y(this, (function (u) { switch (u.label) { case 0: return [4, r.readPixels(0, 0, t, i)]; case 1: return l = u.sent(), c = new Uint8Array(l.buffer), e.DumpData(t, i, c, n, o, a, !0, void 0, s), [2] } })) })) }, e.DumpDataAsync = function (t, i, r, n, o, a, s, l) { return void 0 === n && (n = "image/png"), void 0 === a && (a = !1), void 0 === s && (s = !1), new Promise((function (c) { e.DumpData(t, i, r, (function (e) { return c(e) }), n, o, a, s, l) })) }, e.DumpData = function (t, i, r, n, o, s, l, c, u) { void 0 === o && (o = "image/png"), void 0 === l && (l = !1), void 0 === c && (c = !1); var d = e._CreateDumpRenderer(); if (d.engine.setSize(t, i, !0), r instanceof Float32Array) { for (var p = new Uint8Array(r.length), f = r.length; f--;) { var _ = r[f]; p[f] = Math.round(255 * h.Clamp(_)) } r = p } var m = d.engine.createRawTexture(r, t, i, a.TEXTUREFORMAT_RGBA, !1, !l, a.TEXTURE_NEAREST_NEAREST); d.renderer.setViewport(), d.renderer.applyEffectWrapper(d.wrapper), d.wrapper.effect._bindTexture("textureSampler", m), d.renderer.draw(), c ? xi.ToBlob(d.canvas, (function (e) { var t = new FileReader; t.onload = function (e) { var t = e.target.result; n && n(t) }, t.readAsArrayBuffer(e) }), o, u) : xi.EncodeScreenshotCanvasData(d.canvas, n, o, s, u), m.dispose() }, e.Dispose = function () { e._DumpToolsEngine && (e._DumpToolsEngine.wrapper.dispose(), e._DumpToolsEngine.renderer.dispose(), e._DumpToolsEngine.engine.dispose()), e._DumpToolsEngine = null }, e }(); xi.DumpData = $a.DumpData, xi.DumpDataAsync = $a.DumpDataAsync, xi.DumpFramebuffer = $a.DumpFramebuffer; var es = function (e) { function t(t, i, r, n, o, s, l, c, h, d, p, f, _, m, g, v, y) { void 0 === n && (n = !1), void 0 === o && (o = !0), void 0 === s && (s = a.TEXTURETYPE_UNSIGNED_INT), void 0 === l && (l = !1), void 0 === c && (c = vo.TRILINEAR_SAMPLINGMODE), void 0 === h && (h = !0), void 0 === d && (d = !1), void 0 === p && (p = !1), void 0 === f && (f = a.TEXTUREFORMAT_RGBA), void 0 === _ && (_ = !1), void 0 === v && (v = !1), void 0 === y && (y = !1); var b, T, E, S, x, A, C = this, P = void 0; if ("object" == typeof n) { var M = n; n = !!M.generateMipMaps, o = null === (b = M.doNotChangeAspectRatio) || void 0 === b || b, s = null !== (T = M.type) && void 0 !== T ? T : a.TEXTURETYPE_UNSIGNED_BYTE, l = !!M.isCube, c = null !== (E = M.samplingMode) && void 0 !== E ? E : vo.TRILINEAR_SAMPLINGMODE, h = null === (S = M.generateDepthBuffer) || void 0 === S || S, d = !!M.generateStencilBuffer, p = !!M.isMulti, f = null !== (x = M.format) && void 0 !== x ? x : a.TEXTUREFORMAT_RGBA, _ = !!M.delayAllocation, m = M.samples, g = M.creationFlags, v = !!M.noColorAttachment, y = !!M.useSRGBBuffer, P = M.colorAttachment } if ((C = e.call(this, null, r, !n, void 0, c, void 0, void 0, void 0, void 0, f) || this)._unObserveRenderList = null, C._renderListHasChanged = function (e, t) { var i, r = C._renderList ? C._renderList.length : 0; (0 === t && r > 0 || 0 === r) && (null === (i = C.getScene()) || void 0 === i || i.meshes.forEach((function (e) { e._markSubMeshesAsLightDirty() }))) }, C.renderParticles = !0, C.renderSprites = !1, C.forceLayerMaskCheck = !1, C.ignoreCameraViewport = !1, C.onBeforeBindObservable = new u, C.onAfterUnbindObservable = new u, C.onBeforeRenderObservable = new u, C.onAfterRenderObservable = new u, C.onClearObservable = new u, C.onResizeObservable = new u, C._cleared = !1, C.skipInitialClear = !1, C._currentRefreshId = -1, C._refreshRate = 1, C._samples = 1, C._canRescale = !0, C._renderTarget = null, C.boundingBoxPosition = R.Zero(), !(r = C.getScene())) return C; var O = C.getScene().getEngine(); return C._coordinatesMode = vo.PROJECTION_MODE, C.renderList = new Array, C.name = t, C.isRenderTarget = !0, C._initialSizeParameter = i, C._renderPassIds = [], C._isCubeData = l, C._processSizeParameter(i), C.renderPassId = C._renderPassIds[0], C._resizeObserver = O.onResizeObservable.add((function () { })), C._generateMipMaps = !!n, C._doNotChangeAspectRatio = o, C._renderingManager = new Qi(r), C._renderingManager._useSceneAutoClearSetup = !0, p || (C._renderTargetOptions = { generateMipMaps: n, type: s, format: null !== (A = C._format) && void 0 !== A ? A : void 0, samplingMode: C.samplingMode, generateDepthBuffer: h, generateStencilBuffer: d, samples: m, creationFlags: g, noColorAttachment: v, useSRGBBuffer: y, colorAttachment: P, label: C.name }, C.samplingMode === vo.NEAREST_SAMPLINGMODE && (C.wrapU = vo.CLAMP_ADDRESSMODE, C.wrapV = vo.CLAMP_ADDRESSMODE), _ || (l ? (C._renderTarget = r.getEngine().createRenderTargetCubeTexture(C.getRenderSize(), C._renderTargetOptions), C.coordinatesMode = vo.INVCUBIC_MODE, C._textureMatrix = I.Identity()) : C._renderTarget = r.getEngine().createRenderTargetTexture(C._size, C._renderTargetOptions), C._texture = C._renderTarget.texture, void 0 !== m && (C.samples = m))), C } 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; r < i.length; ++r)for (var n = 0; n < this._renderPassIds.length; ++n)i[r].setMaterialForRenderPass(this._renderPassIds[n], void 0 !== t ? Array.isArray(t) ? t[n] : t : void 0) }, Object.defineProperty(t.prototype, "isMulti", { get: function () { var e, t; return null !== (t = null === (e = this._renderTarget) || void 0 === e ? void 0 : e.isMulti) && void 0 !== t && t }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "renderTargetOptions", { get: function () { return this._renderTargetOptions }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "renderTarget", { get: function () { return this._renderTarget }, enumerable: !1, configurable: !0 }), t.prototype._onRatioRescale = function () { this._sizeRatio && this.resize(this._initialSizeParameter) }, 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, "depthStencilTexture", { get: function () { var e, t; return null !== (t = null === (e = this._renderTarget) || void 0 === e ? void 0 : e._depthStencilTexture) && void 0 !== t ? t : null }, enumerable: !1, configurable: !0 }), t.prototype.createDepthStencilTexture = function (e, t, i, r, n) { var o; 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 === (o = this._renderTarget) || void 0 === o || o.createDepthStencilTexture(e, t, i, r, n) }, t.prototype._releaseRenderPassId = function () { if (this._scene) for (var e = this._scene.getEngine(), t = 0; t < this._renderPassIds.length; ++t)e.releaseRenderPassId(this._renderPassIds[t]); this._renderPassIds = [] }, t.prototype._createRenderPassId = function () { this._releaseRenderPassId(); for (var e = this._scene.getEngine(), t = this._isCubeData ? 6 : this.getRenderLayers() || 1, i = 0; i < t; ++i)this._renderPassIds[i] = e.createRenderPassId("RenderTargetTexture - ".concat(this.name, "#").concat(i)) }, t.prototype._processSizeParameter = function (e, t) { if (void 0 === t && (t = !0), e.ratio) { this._sizeRatio = e.ratio; var i = this._getEngine(); this._size = { width: this._bestReflectionRenderTargetDimension(i.getRenderWidth(), this._sizeRatio), height: this._bestReflectionRenderTargetDimension(i.getRenderHeight(), this._sizeRatio) } } else this._size = e; t && this._createRenderPassId() }, Object.defineProperty(t.prototype, "samples", { get: function () { var e, t; return null !== (t = null === (e = this._renderTarget) || void 0 === e ? void 0 : e.samples) && void 0 !== t ? t : this._samples }, set: function (e) { this._renderTarget && (this._samples = this._renderTarget.setSamples(e)) }, enumerable: !1, configurable: !0 }), t.prototype.resetRefreshCounter = function () { this._currentRefreshId = -1 }, Object.defineProperty(t.prototype, "refreshRate", { get: function () { return this._refreshRate }, set: function (e) { this._refreshRate = e, this.resetRefreshCounter() }, enumerable: !1, configurable: !0 }), t.prototype.addPostProcess = function (e) { if (!this._postProcessManager) { var t = this.getScene(); if (!t) return; this._postProcessManager = new ji(t), this._postProcesses = new Array } this._postProcesses.push(e), this._postProcesses[0].autoClear = !1 }, t.prototype.clearPostProcesses = function (e) { if (void 0 === e && (e = !1), this._postProcesses) { if (e) for (var t = 0, i = this._postProcesses; t < i.length; t++)i[t].dispose(); this._postProcesses = [] } }, t.prototype.removePostProcess = function (e) { if (this._postProcesses) { var t = this._postProcesses.indexOf(e); -1 !== t && (this._postProcesses.splice(t, 1), this._postProcesses.length > 0 && (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; a < this._waitingRenderList.length; a++) { var s = this._waitingRenderList[a]; (u = n.getMeshById(s)) && this.renderList.push(u) } this._waitingRenderList = void 0 } if (this.renderListPredicate) { this.renderList ? this.renderList.length = 0 : this.renderList = []; var l = this.getScene(); if (!l) return i; var c = l.meshes; for (a = 0; a < c.length; a++) { var u = c[a]; this.renderListPredicate(u) && this.renderList.push(u) } } var h = o.currentRenderPassId; this.onBeforeBindObservable.notifyObservers(this); var d = null !== (r = this.activeCamera) && void 0 !== r ? r : n.activeCamera, p = n.activeCamera; d && (d !== n.activeCamera && (n.setTransformMatrix(d.getViewMatrix(), d.getProjectionMatrix(!0)), n.activeCamera = d), o.setViewport(d.rigParent ? d.rigParent.viewport : d.viewport, this.getRenderWidth(), this.getRenderHeight())), this._defaultRenderListPrepared = !1; var f = i; if (i) { n.getViewMatrix() || n.updateTransformMatrix(); var _ = this.is2DArray ? this.getRenderLayers() : this.isCube ? 6 : 1; for (b = 0; b < _ && f; b++) { var m = null, g = this.renderList ? this.renderList : n.getActiveMeshes().data, v = this.renderList ? this.renderList.length : n.getActiveMeshes().length; o.currentRenderPassId = this._renderPassIds[b], this.onBeforeRenderObservable.notifyObservers(b), this.getCustomRenderList && (m = this.getCustomRenderList(b, g, v)), m || (m = g), this._doNotChangeAspectRatio || n.updateTransformMatrix(!0); for (var y = 0; y < m.length && f; ++y)if ((u = m[y]).isEnabled() && !u.isBlocked && u.isVisible && u.subMeshes) if (this.customIsReadyFunction) { if (!this.customIsReadyFunction(u, this.refreshRate, i)) { f = !1; continue } } else if (!u.isReady(!0)) { f = !1; continue } this.onAfterRenderObservable.notifyObservers(b), (this.is2DArray || this.isCube) && (n.incrementRenderId(), n.resetCachedMaterial()) } } else if (this.is2DArray && !this.isMulti) for (var b = 0; b < this.getRenderLayers(); b++)this._renderToTarget(0, e, t, b, d), n.incrementRenderId(), n.resetCachedMaterial(); else if (this.isCube && !this.isMulti) for (var T = 0; T < 6; T++)this._renderToTarget(T, e, t, void 0, d), n.incrementRenderId(), n.resetCachedMaterial(); else this._renderToTarget(0, e, t, void 0, d); return this.onAfterUnbindObservable.notifyObservers(this), o.currentRenderPassId = h, p && (n.activeCamera = p, (n.getEngine().scenes.length > 1 || 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 = In.NearestPOT(i + 16384 / (128 + i)); return Math.min(In.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 < t; a++) { var s = e[a]; if (s && !s.isBlocked) { if (this.customIsReadyFunction) { if (!this.customIsReadyFunction(s, this.refreshRate, !1)) { this.resetRefreshCounter(); continue } } else if (!s.isReady(0 === this.refreshRate)) { this.resetRefreshCounter(); continue } if (!s._internalAbstractMeshDataInfo._currentLODIsUpToDate && n.activeCamera && (s._internalAbstractMeshDataInfo._currentLOD = n.customLODSelector ? n.customLODSelector(s, this.activeCamera || n.activeCamera) : s.getLOD(this.activeCamera || n.activeCamera), s._internalAbstractMeshDataInfo._currentLODIsUpToDate = !0), !s._internalAbstractMeshDataInfo._currentLOD) continue; var l = s._internalAbstractMeshDataInfo._currentLOD; l._preActivateForIntermediateRendering(o); var c; if (c = !(!r || !i) && 0 == (s.layerMask & i.layerMask), s.isEnabled() && s.isVisible && s.subMeshes && !c && (l !== s && l._activate(o, !0), s._activate(o, !0) && s.subMeshes.length)) { s.isAnInstance ? s._internalAbstractMeshDataInfo._actAsRegularMesh && (l = s) : l._internalAbstractMeshDataInfo._onlyForInstancesIntermediate = !1, l._internalAbstractMeshDataInfo._isActiveIntermediate = !0; for (var u = 0; u < l.subMeshes.length; u++) { var h = l.subMeshes[u]; this._renderingManager.dispatch(h, l) } } } } for (var d = 0; d < n.particleSystems.length; d++) { var p = n.particleSystems[d], f = p.emitter; p.isStarted() && f && (!f.position || f.isEnabled()) && this._renderingManager.dispatchParticles(p) } } }, t.prototype._bindFrameBuffer = function (e, t) { void 0 === e && (e = 0), void 0 === t && (t = 0); var i = this.getScene(); if (i) { var r = i.getEngine(); this._renderTarget && r.bindFramebuffer(this._renderTarget, this.isCube ? e : void 0, void 0, void 0, this.ignoreCameraViewport, 0, t) } }, t.prototype._unbindFrameBuffer = function (e, t) { var i = this; this._renderTarget && e.unBindFramebuffer(this._renderTarget, this.isCube, (function () { i.onAfterRenderObservable.notifyObservers(t) })) }, t.prototype._prepareFrame = function (e, t, i, r) { this._postProcessManager ? this._prePassEnabled || this._postProcessManager._prepareFrame(this._texture, this._postProcesses) : r && e.postProcessManager._prepareFrame(this._texture) || this._bindFrameBuffer(t, i) }, t.prototype._renderToTarget = function (e, t, i, r, n) { var o, s, l, c, u, h; void 0 === r && (r = 0), void 0 === n && (n = null); var d = this.getScene(); if (d) { var p = d.getEngine(); if (null === (o = p._debugPushGroup) || void 0 === o || o.call(p, "render to face #".concat(e, " layer #").concat(r), 1), this._prepareFrame(d, e, r, t), this.is2DArray ? (p.currentRenderPassId = this._renderPassIds[r], this.onBeforeRenderObservable.notifyObservers(r)) : (p.currentRenderPassId = this._renderPassIds[e], this.onBeforeRenderObservable.notifyObservers(e)), p.snapshotRendering && p.snapshotRenderingMode === a.SNAPSHOTRENDERING_FAST) this.onClearObservable.hasObservers() ? this.onClearObservable.notifyObservers(p) : this.skipInitialClear || p.clear(this.clearColor || d.clearColor, !0, !0, !0); else { var f = null, _ = this.renderList ? this.renderList : d.getActiveMeshes().data, m = this.renderList ? this.renderList.length : d.getActiveMeshes().length; this.getCustomRenderList && (f = this.getCustomRenderList(this.is2DArray ? r : e, _, m)), f ? this._prepareRenderingManager(f, f.length, n, this.forceLayerMaskCheck) : (this._defaultRenderListPrepared || (this._prepareRenderingManager(_, m, n, !this.renderList || this.forceLayerMaskCheck), this._defaultRenderListPrepared = !0), f = _); for (var g = 0, v = d._beforeRenderTargetClearStage; g < v.length; g++)v[g].action(this, e, r); this.onClearObservable.hasObservers() ? this.onClearObservable.notifyObservers(p) : this.skipInitialClear || p.clear(this.clearColor || d.clearColor, !0, !0, !0), this._doNotChangeAspectRatio || d.updateTransformMatrix(!0); for (var y = 0, b = d._beforeRenderTargetDrawStage; y < b.length; y++)b[y].action(this, e, r); this._renderingManager.render(this.customRenderFunction, f, this.renderParticles, this.renderSprites); for (var T = 0, E = d._afterRenderTargetDrawStage; T < E.length; T++)E[T].action(this, e, r); var S = null !== (l = null === (s = this._texture) || void 0 === s ? void 0 : s.generateMipMaps) && void 0 !== l && l; this._texture && (this._texture.generateMipMaps = !1), this._postProcessManager ? this._postProcessManager._finalizeFrame(!1, null !== (c = this._renderTarget) && void 0 !== c ? c : void 0, e, this._postProcesses, this.ignoreCameraViewport) : t && d.postProcessManager._finalizeFrame(!1, null !== (u = this._renderTarget) && void 0 !== u ? u : void 0, e); for (var x = 0, A = d._afterRenderTargetPostProcessStage; x < A.length; x++)A[x].action(this, e, r); this._texture && (this._texture.generateMipMaps = S), this._doNotChangeAspectRatio || d.updateTransformMatrix(!0), i && $a.DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), p) } this._unbindFrameBuffer(p, e), this._texture && this.isCube && 5 === e && p.generateMipMapsForCubemap(this._texture), null === (h = p._debugPopGroup) || void 0 === h || h.call(p, 1) } }, t.prototype.setRenderingOrder = function (e, t, i, r) { void 0 === t && (t = null), void 0 === i && (i = null), void 0 === r && (r = null), this._renderingManager.setRenderingOrder(e, t, i, r) }, t.prototype.setRenderingAutoClearDepthStencil = function (e, t) { this._renderingManager.setRenderingAutoClearDepthStencil(e, t), this._renderingManager._useSceneAutoClearSetup = !1 }, t.prototype.clone = function () { var e = this.getSize(), i = new t(this.name, e, this.getScene(), this._renderTargetOptions.generateMipMaps, this._doNotChangeAspectRatio, this._renderTargetOptions.type, this.isCube, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer, this._renderTargetOptions.generateStencilBuffer, void 0, this._renderTargetOptions.format, void 0, this._renderTargetOptions.samples); return i.hasAlpha = this.hasAlpha, i.level = this.level, i.coordinatesMode = this.coordinatesMode, this.renderList && (i.renderList = this.renderList.slice(0)), i }, t.prototype.serialize = function () { if (!this.name) return null; var t = e.prototype.serialize.call(this); if (t.renderTargetSize = this.getRenderSize(), t.renderList = [], this.renderList) for (var i = 0; i < this.renderList.length; i++)t.renderList.push(this.renderList[i].id); return t }, t.prototype.disposeFramebufferObjects = function () { var e; null === (e = this._renderTarget) || void 0 === e || e.dispose(!0) }, t.prototype.releaseInternalTexture = function () { var e; null === (e = this._renderTarget) || void 0 === e || e.releaseTextures(), this._texture = null }, t.prototype.dispose = function () { var t; this.onResizeObservable.clear(), this.onClearObservable.clear(), this.onAfterRenderObservable.clear(), this.onAfterUnbindObservable.clear(), this.onBeforeBindObservable.clear(), this.onBeforeRenderObservable.clear(), this._postProcessManager && (this._postProcessManager.dispose(), this._postProcessManager = null), this._prePassRenderTarget && this._prePassRenderTarget.dispose(), this._releaseRenderPassId(), this.clearPostProcesses(!0), this._resizeObserver && (this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver), this._resizeObserver = null), this.renderList = null; var i = this.getScene(); if (i) { var r = i.customRenderTargets.indexOf(this); r >= 0 && i.customRenderTargets.splice(r, 1); for (var n = 0, o = i.cameras; n < o.length; n++) { var a = o[n]; (r = a.customRenderTargets.indexOf(this)) >= 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 }(vo); vo._CreateRenderTargetTexture = function (e, t, i, r, n) { return new es(e, t, i, r) }; var ts = function () { function e(e) { this.name = qi.NAME_PROCEDURALTEXTURE, this.scene = e, this.scene.proceduralTextures = new Array } return e.prototype.register = function () { this.scene._beforeClearStage.registerStep(qi.STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear) }, e.prototype.rebuild = function () { }, e.prototype.dispose = function () { }, e.prototype._beforeClear = function () { if (this.scene.proceduralTexturesEnabled) { xi.StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0); for (var e = 0; e < this.scene.proceduralTextures.length; e++) { var t = this.scene.proceduralTextures[e]; t._shouldRender() && t.render() } xi.EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0) } }, e }(); Ut.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 is, rs = 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(qi.NAME_PROCEDURALTEXTURE); d || (d = new ts(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 Jt(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[Hi.PositionKind] = new Hi(h._fullEngine, f, Hi.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[Hi.PositionKind]; e && e._rebuild(), this._createIndexBuffer(), this.refreshRate === es.REFRESHRATE_RENDER_ONCE && (this.refreshRate = es.REFRESHRATE_RENDER_ONCE) }, t.prototype.reset = function () { var e; null === (e = this._drawWrapper.effect) || void 0 === e || e.dispose() }, t.prototype._getDefines = function () { return "" }, t.prototype.isReady = function () { var e, t = this, i = 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 r = this._getDefines(); return !(!this._drawWrapper.effect || r !== this._cachedDefines || !this._drawWrapper.effect.isReady()) || (e = void 0 !== this._fragment.fragmentElement ? { vertex: "procedural", fragmentElement: this._fragment.fragmentElement } : { vertex: "procedural", fragment: this._fragment }, this._cachedDefines !== r && (this._cachedDefines = r, this._drawWrapper.effect = i.createEffect(e, [Hi.PositionKind], this._uniforms, this._samplers, r, void 0, void 0, (function () { var e; null === (e = t._rtWrapper) || void 0 === e || e.dispose(), t._rtWrapper = t._texture = null, t._fallbackTexture && (t._texture = t._fallbackTexture._texture, t._texture && t._texture.incrementReferences()), t._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(Hn.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(Hn.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[Hi.PositionKind]; r && (r.dispose(), this._vertexBuffers[Hi.PositionKind] = null), this._indexBuffer && this._fullEngine._releaseBuffer(this._indexBuffer) && (this._indexBuffer = null), this.onGeneratedObservable.clear(), this.onBeforeGenerationObservable.clear(), e.prototype.dispose.call(this) } }, X([xe()], t.prototype, "isEnabled", void 0), X([xe()], t.prototype, "autoClear", void 0), X([xe()], t.prototype, "_generateMipMaps", void 0), X([xe()], t.prototype, "_size", void 0), X([xe()], t.prototype, "refreshRate", null), t }(vo); b("BABYLON.ProceduralTexture", rs), 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" }(is || (is = {})); var ns = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.operation = is.Cos, i.registerInput("input", Jo.AutoDetect), i.registerOutput("output", Jo.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 is.Cos: r = "cos"; break; case is.Sin: r = "sin"; break; case is.Abs: r = "abs"; break; case is.Exp: r = "exp"; break; case is.Exp2: r = "exp2"; break; case is.Round: r = "round"; break; case is.Floor: r = "floor"; break; case is.Ceiling: r = "ceil"; break; case is.Sqrt: r = "sqrt"; break; case is.Log: r = "log"; break; case is.Tan: r = "tan"; break; case is.ArcTan: r = "atan"; break; case is.ArcCos: r = "acos"; break; case is.ArcSin: r = "asin"; break; case is.Fract: r = "fract"; break; case is.Sign: r = "sign"; break; case is.Radians: r = "radians"; break; case is.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(is[this.operation], ";\n") }, t }(sa); b("BABYLON.TrigonometryBlock", ns); var os = { effect: null, subMesh: null }, as = 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.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 }(Mi), ss = 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 = Da.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() }, 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 < r.length; i++) { var n = r[i]; if (n.name === e) { if (t) return xi.Warn("More than one block was found with the name `" + e + "`"), t; t = n } } return t }, t.prototype.getBlockByPredicate = function (e) { for (var t = 0, i = this.attachedBlocks; t < i.length; t++) { var r = i[t]; if (e(r)) return r } return null }, t.prototype.getInputBlockByPredicate = function (e) { for (var t = 0, i = this.attachedBlocks; t < i.length; t++) { var r = i[t]; if (r.isInput && e(r)) return r } return null }, t.prototype.getInputBlocks = function () { for (var e = [], t = 0, i = this.attachedBlocks; t < i.length; t++) { var r = i[t]; r.isInput && e.push(r) } return e }, t.prototype.registerOptimizer = function (e) { if (!(this._optimizers.indexOf(e) > -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 & $o.Vertex) && this._addVertexOutputNode(e), 0 != (e.target & $o.Fragment) && this._addFragmentOutputNode(e), this }, t.prototype.removeOutputNode = function (e) { return null === e.target || (0 != (e.target & $o.Vertex) && this._removeVertexOutputNode(e), 0 != (e.target & $o.Fragment) && this._removeFragmentOutputNode(e)), this }, t.prototype._addVertexOutputNode = function (e) { if (-1 === this._vertexOutputNodes.indexOf(e)) return e.target = $o.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 = $o.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 === $o.VertexAndFragment || t.target === $o.Fragment && e.target === $o.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 < a.length; o++)if (a[o].getClassName() === n) throw "Cannot have multiple blocks of type ".concat(n, " in the same NodeMaterial"); this.attachedBlocks.push(e) } for (var s = 0, l = e.inputs; s < l.length; s++) { var c = l[s]; c.associatedVariableName = ""; var u = c.connectedPoint; if (u) { var h = u.ownerBlock; h !== e && this._processInitializeOnLink(h, t, i, r) } } if (e.isTeleportOut) { var d = e; d.entryPoint && this._processInitializeOnLink(d.entryPoint, t, i, r) } for (var p = 0, f = e.outputs; p < f.length; p++)f[p].associatedVariableName = "" }, t.prototype._resetDualBlocks = function (e, t) { e.target === $o.VertexAndFragment && (e.buildId = t); for (var i = 0, r = e.inputs; i < r.length; i++) { var n = r[i].connectedPoint; if (n) { var o = n.ownerBlock; o !== e && this._resetDualBlocks(o, t) } } if (e.isTeleportOut) { var a = e; a.entryPoint && this._resetDualBlocks(a.entryPoint, t) } }, t.prototype.removeBlock = function (e) { var t = this.attachedBlocks.indexOf(e); t > -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 === Da.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 na, this._vertexCompilationState.supportUniformBuffers = n.supportsUniformBuffers, this._vertexCompilationState.target = $o.Vertex, this._fragmentCompilationState = new na, this._fragmentCompilationState.supportUniformBuffers = n.supportsUniformBuffers, this._fragmentCompilationState.target = $o.Fragment, this._sharedData = new oa, 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; l < c.length; l++) { var u = c[l]; a.push(u), this._initializeBlock(u, this._vertexCompilationState, s, r) } for (var h = 0, d = this._fragmentOutputNodes; h < d.length; h++) { var p = d[h]; s.push(p), this._initializeBlock(p, this._fragmentCompilationState, a, r) } this.optimize(); for (var f = 0, _ = a; f < _.length; f++)(u = _[f]).build(this._vertexCompilationState, a); this._fragmentCompilationState.uniforms = this._vertexCompilationState.uniforms.slice(0), this._fragmentCompilationState._uniformDeclaration = this._vertexCompilationState._uniformDeclaration, this._fragmentCompilationState._constantDeclaration = this._vertexCompilationState._constantDeclaration, this._fragmentCompilationState._vertexState = this._vertexCompilationState; for (var m = 0, g = s; m < g.length; m++)p = g[m], this._resetDualBlocks(p, this._buildId - 1); for (var v = 0, y = s; v < y.length; v++)(p = y[v]).build(this._fragmentCompilationState, s); this._vertexCompilationState.finalize(this._vertexCompilationState), this._fragmentCompilationState.finalize(this._fragmentCompilationState), i && (this._buildId = t._BuildIdGenerator++), this._sharedData.emitErrors(), e && (console.log("Vertex shader:"), console.log(this._vertexCompilationState.compilationString), console.log("Fragment shader:"), console.log(this._fragmentCompilationState.compilationString)), this._buildWasSuccessful = !0, this.onBuildObservable.notifyObservers(this); for (var b = 0, T = this.getScene().meshes; b < T.length; b++) { var E = T[b]; if (E.subMeshes) for (var S = 0, x = E.subMeshes; S < x.length; S++) { var A = x[S]; if (A.getMaterial() === this && A.materialDefines) { var R = A.materialDefines; R.markAllAsDirty(), R.reset() } } } }, t.prototype.optimize = function () { for (var e = 0, t = this._optimizers; e < t.length; e++)t[e].optimize(this._vertexOutputNodes, this._fragmentOutputNodes) }, t.prototype._prepareDefinesForAttributes = function (e, t) { var i = t.NORMAL, r = t.TANGENT, n = t.VERTEXCOLOR_NME; t.NORMAL = e.isVerticesDataPresent(Hi.NormalKind), t.TANGENT = e.isVerticesDataPresent(Hi.TangentKind); var o = e.useVertexColors && e.isVerticesDataPresent(Hi.ColorKind); t.VERTEXCOLOR_NME = o; for (var s = !1, l = 1; l <= a.MAX_SUPPORTED_UV_SETS; ++l) { var c = t["UV" + l]; t["UV" + l] = e.isVerticesDataPresent("uv".concat(1 === l ? "" : l)), s = s || t["UV" + l] !== c } (i !== t.NORMAL || r !== t.TANGENT || n !== t.VERTEXCOLOR_NME || s) && t.markAsAttributesDirty() }, 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 !== Da.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 as, d = new Ln(u + "PostProcess", this.getScene()), p = this._buildId; return this._processDefines(d, h), Vt.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 Ia(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 Vt.ShadersStore[u + "VertexShader"], delete Vt.ShadersStore[u + "PixelShader"], u = c.name + c._buildId, h.markAllAsDirty(), p = c._buildId), c._processDefines(d, h) && (Vt.RegisterShader(u, c._fragmentCompilationState._builtCompilationString, c._vertexCompilationState._builtCompilationString), ii.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 !== Da.ProceduralTexture) return console.log("Incompatible material mode"), null; var r = this.name + this._buildId, n = new rs(r, e, null, t), o = new Ln(r + "Procedural", this.getScene()); o.reservedDataStore = { hidden: !0 }; var a = new as, s = this._processDefines(o, a); Vt.RegisterShader(r, this._fragmentCompilationState._builtCompilationString, this._vertexCompilationState._builtCompilationString); var l = this.getScene().getEngine().createEffect({ vertexElement: r, fragmentElement: r }, [Hi.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 Vt.ShadersStore[r + "VertexShader"], delete Vt.ShadersStore[r + "PixelShader"], r = i.name + i._buildId, a.markAllAsDirty(), c = i._buildId); var e = i._processDefines(o, a); e && (Vt.RegisterShader(r, i._fragmentCompilationState._builtCompilationString, i._vertexCompilationState._builtCompilationString), ii.SetImmediate((function () { l = i.getScene().getEngine().createEffect({ vertexElement: r, fragmentElement: r }, [Hi.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 as), a || (a = this.getScene().getMeshByName(this.name + "Particle")) || ((a = new Ln(this.name + "Particle", this.getScene())).reservedDataStore = { hidden: !0 }); var u = this._buildId, h = [], d = s; if (!n) { var p = this._processDefines(a, o); Vt.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 Vt.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 Vt.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; r < n.length; r++)n[r].animate(t); this._animationFrame = i } } for (var o = 0, a = this._sharedData.bindableBlocks; o < a.length; o++)a[o].bind(e, this); for (var s = 0, l = this._sharedData.inputBlocks; s < l.length; s++)l[s]._transmit(e, this.getScene(), this) }, t.prototype.createEffectForParticles = function (e, t, i) { this.mode === Da.Particle ? (this._createEffectForParticles(e, Ha.BLENDMODE_ONEONE, t, i), this._createEffectForParticles(e, Ha.BLENDMODE_MULTIPLY, t, i)) : console.log("Incompatible material mode") }, t.prototype.createAsShadowDepthWrapper = function (e) { this.mode === Da.Material ? e.shadowDepthWrapper = new BABYLON.ShadowDepthWrapper(this, this.getScene()) : console.log("Incompatible material mode") }, t.prototype._processDefines = function (e, t, i, r) { var n = this; void 0 === i && (i = !1); var o = null, a = this.getScene(); if (zn.PrepareDefinesForCamera(a, t) && t.markAsMiscDirty(), this._sharedData.blocksWithDefines.forEach((function (r) { r.initializeDefines(e, n, t, i) })), this._sharedData.blocksWithDefines.forEach((function (o) { o.prepareDefines(e, n, t, i, r) })), t.isDirty) { var s = t._areLightsDisposed; t.markAsProcessed(), this._vertexCompilationState.compilationString = this._vertexCompilationState._builtCompilationString, this._fragmentCompilationState.compilationString = this._fragmentCompilationState._builtCompilationString, this._sharedData.repeatableContentBlocks.forEach((function (i) { i.replaceRepeatableContent(n._vertexCompilationState, n._fragmentCompilationState, e, t) })); var l = []; this._sharedData.dynamicUniformBlocks.forEach((function (e) { e.updateUniformsAndSamples(n._vertexCompilationState, n, t, l) })); var c = this._vertexCompilationState.uniforms; this._fragmentCompilationState.uniforms.forEach((function (e) { -1 === c.indexOf(e) && c.push(e) })); var u = this._vertexCompilationState.samplers; this._fragmentCompilationState.samplers.forEach((function (e) { -1 === u.indexOf(e) && u.push(e) })); var h = new Ra; this._sharedData.blocksWithFallbacks.forEach((function (t) { t.provideFallbacks(e, h) })), o = { lightDisposed: s, uniformBuffers: l, mergedUniforms: c, mergedSamplers: u, fallbacks: h } } return o }, t.prototype.isReadyForSubMesh = function (e, t, i) { var r = this; if (void 0 === i && (i = !1), !this._buildWasSuccessful) return !1; var n = this.getScene(); if (this._sharedData.animatedInputs) { var o = n.getFrameId(); if (this._animationFrame !== o) { for (var a = 0, s = this._sharedData.animatedInputs; a < s.length; a++)s[a].animate(n); this._animationFrame = o } } if (t.effect && this.isFrozen && t.effect._wasPreviouslyReady && t.effect._wasPreviouslyUsingInstances === i) return !0; t.materialDefines || (t.materialDefines = new as); var l = t.materialDefines; if (this._isReadyForSubMesh(t)) return !0; var c = n.getEngine(); if (this._prepareDefinesForAttributes(e, l), this._sharedData.blockingBlocks.some((function (t) { return !t.isReady(e, r, l, i) }))) return !1; var u = this._processDefines(e, l, i, t); if (u) { var h = t.effect, d = l.toString(), p = c.createEffect({ vertex: "nodeMaterial" + this._buildId, fragment: "nodeMaterial" + this._buildId, vertexSource: this._vertexCompilationState.compilationString, fragmentSource: this._fragmentCompilationState.compilationString }, { attributes: this._vertexCompilationState.attributes, uniformsNames: u.mergedUniforms, uniformBuffersNames: u.uniformBuffers, samplers: u.mergedSamplers, defines: d, fallbacks: u.fallbacks, onCompiled: this.onCompiled, onError: this.onError, indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights, maxSimultaneousMorphTargets: l.NUM_MORPH_INFLUENCERS } }, c); if (p) if (this._onEffectCreatedObservable && (os.effect = p, os.subMesh = t, this._onEffectCreatedObservable.notifyObservers(os)), this.allowShaderHotSwapping && h && !p.isReady()) { if (p = h, l.markAsUnprocessed(), u.lightDisposed) return l._areLightsDisposed = !0, !1 } else n.resetCachedMaterial(), t.setEffect(p, l, this._materialContext) } return !(!t.effect || !t.effect.isReady() || (l._renderId = n.getRenderId(), t.effect._wasPreviouslyReady = !0, t.effect._wasPreviouslyUsingInstances = i, this._checkScenePerformancePriority(), 0)) }, Object.defineProperty(t.prototype, "compiledShaders", { get: function () { return "// Vertex shader\n".concat(this._vertexCompilationState.compilationString, "\n\n// Fragment shader\n").concat(this._fragmentCompilationState.compilationString) }, enumerable: !1, configurable: !0 }), t.prototype.bindOnlyWorldMatrix = function (e) { var t = this.getScene(); if (this._activeEffect) { var i = this._sharedData.hints; i.needWorldViewMatrix && e.multiplyToRef(t.getViewMatrix(), this._cachedWorldViewMatrix), i.needWorldViewProjectionMatrix && e.multiplyToRef(t.getTransformMatrix(), this._cachedWorldViewProjectionMatrix); for (var r = 0, n = this._sharedData.inputBlocks; r < n.length; r++)n[r]._transmitWorld(this._activeEffect, e, this._cachedWorldViewMatrix, this._cachedWorldViewProjectionMatrix) } }, t.prototype.bindForSubMesh = function (e, t, i) { var r = this.getScene(), n = i.effect; if (n) { this._activeEffect = n, this.bindOnlyWorldMatrix(e); var o = this._mustRebind(r, n, t.visibility), a = this._sharedData; if (o) { for (var s = 0, l = a.bindableBlocks; s < l.length; s++)l[s].bind(n, this, t, i); for (var c = 0, u = a.forcedBindableBlocks; c < u.length; c++)u[c].bind(n, this, t, i); for (var h = 0, d = a.inputBlocks; h < d.length; h++)d[h]._transmit(n, r, this) } else if (!this.isFrozen) for (var p = 0, f = a.forcedBindableBlocks; p < f.length; p++)f[p].bind(n, this, t, i); this._afterBind(t, this._activeEffect) } }, t.prototype.getActiveTextures = function () { var t = e.prototype.getActiveTextures.call(this); return this._sharedData && t.push.apply(t, this._sharedData.textureBlocks.filter((function (e) { return e.texture })).map((function (e) { return e.texture }))), t }, t.prototype.getTextureBlocks = function () { return this._sharedData ? this._sharedData.textureBlocks : [] }, t.prototype.getAllTextureBlocks = function () { for (var e = [], i = 0, r = this.attachedBlocks; i < r.length; i++) { var n = r[i]; t._BlockIsTextureBlock(n) && e.push(n) } return e }, t.prototype.hasTexture = function (t) { if (e.prototype.hasTexture.call(this, t)) return !0; if (!this._sharedData) return !1; for (var i = 0, r = this._sharedData.textureBlocks; i < r.length; i++)if (r[i].texture === t) return !0; return !1 }, t.prototype.dispose = function (t, i, r) { if (i) for (var n = 0, o = this.getTextureBlocks().filter((function (e) { return e.texture })).map((function (e) { return e.texture })); n < o.length; n++)o[n].dispose(); for (var a = 0, s = this.attachedBlocks; a < s.length; a++)s[a].dispose(); this.attachedBlocks.length = 0, this._sharedData = null, this._vertexCompilationState = null, this._fragmentCompilationState = null, this.onBuildObservable.clear(), this._imageProcessingObserver && (this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver), this._imageProcessingObserver = null), e.prototype.dispose.call(this, t, i, r) }, t.prototype._createNodeEditor = function (e) { var t = H({ nodeMaterial: this }, e); this.BJSNODEMATERIALEDITOR.NodeEditor.Show(t) }, t.prototype.edit = function (e) { var i = this; return new Promise((function (r) { if (i.BJSNODEMATERIALEDITOR = i.BJSNODEMATERIALEDITOR || i._getGlobalNodeMaterialEditor(), void 0 === i.BJSNODEMATERIALEDITOR) { var n = e && e.editorURL ? e.editorURL : t.EditorURL; xi.LoadScript(n, (function () { i.BJSNODEMATERIALEDITOR = i.BJSNODEMATERIALEDITOR || i._getGlobalNodeMaterialEditor(), i._createNodeEditor(null == e ? void 0 : e.nodeEditorConfig), r() })) } else i._createNodeEditor(null == e ? void 0 : e.nodeEditorConfig), r() })) }, t.prototype.clear = function () { this._vertexOutputNodes.length = 0, this._fragmentOutputNodes.length = 0, this.attachedBlocks.length = 0 }, t.prototype.setToDefault = function () { this.clear(), this.editorData = null; var e = new Ta("Position"); e.setAsAttribute("position"); var t = new Ta("World"); t.setAsSystemValue(pa.World); var i = new la("WorldPos"); e.connectTo(i), t.connectTo(i); var r = new Ta("ViewProjection"); r.setAsSystemValue(pa.ViewProjection); var n = new la("WorldPos * ViewProjectionTransform"); i.connectTo(n), r.connectTo(n); var o = new ua("VertexOutput"); n.connectTo(o); var a = new Ta("color"); a.value = new U(.8, .8, .8, 1); var s = new fa("FragmentOutput"); a.connectTo(s), this.addOutputNode(o), this.addOutputNode(s), this._mode = Da.Material }, t.prototype.setToDefaultPostProcess = function () { this.clear(), this.editorData = null; var e = new Ta("Position"); e.setAsAttribute("position2d"); var t = new Ta("Constant1"); t.isConstant = !0, t.value = 1; var i = new Ma("Position3D"); e.connectTo(i), t.connectTo(i, { input: "w" }); var r = new ua("VertexOutput"); i.connectTo(r); var n = new Ta("Scale"); n.visibleInInspector = !0, n.value = new A(1, 1); var o = new Oa("uv0"); e.connectTo(o); var a = new Na("UV scale"); o.connectTo(a), n.connectTo(a); var s = new Ea("CurrentScreen"); a.connectTo(s), s.texture = new vo("https://assets.babylonjs.com/nme/currentScreenPostProcess.png", this.getScene()); var l = new fa("FragmentOutput"); s.connectTo(l, { output: "rgba" }), this.addOutputNode(r), this.addOutputNode(l), this._mode = Da.PostProcess }, t.prototype.setToDefaultProceduralTexture = function () { this.clear(), this.editorData = null; var e = new Ta("Position"); e.setAsAttribute("position2d"); var t = new Ta("Constant1"); t.isConstant = !0, t.value = 1; var i = new Ma("Position3D"); e.connectTo(i), t.connectTo(i, { input: "w" }); var r = new ua("VertexOutput"); i.connectTo(r); var n = new Ta("Time"); n.value = 0, n.min = 0, n.max = 0, n.isBoolean = !1, n.matrixMode = 0, n.animationType = _a.Time, n.isConstant = !1; var o = new Ta("Color3"); o.value = new B(1, 1, 1), o.isConstant = !1; var a = new fa("FragmentOutput"), s = new Ma("VectorMerger"); s.visibleInInspector = !1; var l = new ns("Cos"); l.operation = is.Cos, e.connectTo(s), n.output.connectTo(l.input), l.output.connectTo(s.z), s.xyzOut.connectTo(a.rgb), this.addOutputNode(r), this.addOutputNode(a), this._mode = Da.ProceduralTexture }, t.prototype.setToDefaultParticle = function () { this.clear(), this.editorData = null; var e = new Ta("uv"); e.setAsAttribute("particle_uv"); var t = new Sa("ParticleTexture"); e.connectTo(t); var i = new Ta("Color"); i.setAsAttribute("particle_color"); var r = new Na("Texture * Color"); t.connectTo(r), i.connectTo(r); var n = new xa("ParticleRampGradient"); r.connectTo(n); var o = new Xa("ColorSplitter"); i.connectTo(o); var a = new Aa("ParticleBlendMultiply"); n.connectTo(a), t.connectTo(a, { output: "a" }), o.connectTo(a, { output: "a" }); var s = new fa("FragmentOutput"); a.connectTo(s), this.addOutputNode(s), this._mode = Da.Particle }, t.prototype.loadAsync = function (e, i) { return void 0 === i && (i = ""), j(this, void 0, void 0, (function () { return Y(this, (function (r) { return [2, t.ParseFromFileAsync("", e, this.getScene(), i, !0, this)] })) })) }, t.prototype._gatherBlocks = function (e, t) { if (-1 === t.indexOf(e)) { t.push(e); for (var i = 0, r = e.inputs; i < r.length; i++) { var n = r[i].connectedPoint; n && (o = n.ownerBlock) !== e && this._gatherBlocks(o, t) } var o; e.isTeleportOut && (o = e).entryPoint && this._gatherBlocks(o.entryPoint, t) } }, t.prototype.generateCode = function () { for (var e = [], t = [], i = ["const", "var", "let"], r = 0, n = this._vertexOutputNodes; r < n.length; r++) { var o = n[r]; this._gatherBlocks(o, t) } for (var a = [], s = 0, l = this._fragmentOutputNodes; s < l.length; s++)o = l[s], this._gatherBlocks(o, a); var c = 'var nodeMaterial = new BABYLON.NodeMaterial("'.concat(this.name || "node material", '");\n'); c += "nodeMaterial.mode = BABYLON.NodeMaterialModes.".concat(Da[this.mode], ";\n"); for (var u = 0, h = t; u < h.length; u++)(b = h[u]).isInput && -1 === e.indexOf(b) && (c += b._dumpCode(i, e)); for (var d = 0, p = a; d < p.length; d++)(b = p[d]).isInput && -1 === e.indexOf(b) && (c += b._dumpCode(i, e)); e = [], c += "\n// Connections\n"; for (var f = 0, _ = this._vertexOutputNodes; f < _.length; f++)c += (b = _[f])._dumpCodeForOutputConnections(e); for (var m = 0, g = this._fragmentOutputNodes; m < g.length; m++)c += (b = g[m])._dumpCodeForOutputConnections(e); c += "\n// Output nodes\n"; for (var v = 0, y = this._vertexOutputNodes; v < y.length; v++) { var b = y[v]; c += "nodeMaterial.addOutputNode(".concat(b._codeVariableName, ");\n") } for (var T = 0, E = this._fragmentOutputNodes; T < E.length; T++)b = E[T], c += "nodeMaterial.addOutputNode(".concat(b._codeVariableName, ");\n"); return c + "nodeMaterial.build();\n" }, t.prototype.serialize = function (e) { var t = e ? {} : Ue.Serialize(this); t.editorData = JSON.parse(JSON.stringify(this.editorData)); var i = []; if (e) i = e; else { t.customType = "BABYLON.NodeMaterial", t.outputNodes = []; for (var r = 0, n = this._vertexOutputNodes; r < n.length; r++) { var o = n[r]; this._gatherBlocks(o, i), t.outputNodes.push(o.uniqueId) } for (var a = 0, s = this._fragmentOutputNodes; a < s.length; a++)o = s[a], this._gatherBlocks(o, i), -1 === t.outputNodes.indexOf(o.uniqueId) && t.outputNodes.push(o.uniqueId) } t.blocks = []; for (var l = 0, c = i; l < c.length; l++) { var u = c[l]; t.blocks.push(u.serialize()) } if (!e) for (var h = 0, d = this.attachedBlocks; h < d.length; h++)u = d[h], -1 === i.indexOf(u) && t.blocks.push(u.serialize()); return t }, t.prototype._restoreConnections = function (e, t, i) { for (var r = 0, n = e.outputs; r < n.length; r++)for (var o = n[r], a = 0, s = t.blocks; a < s.length; a++) { var l = s[a], c = i[l.id]; if (c) for (var u = 0, h = l.inputs; u < h.length; u++) { var d = h[u]; if (i[d.targetBlockId] !== e || d.targetConnectionName !== o.name); else { var p = c.getInputByName(d.inputName); if (!p || p.isConnected) continue; o.connectTo(p, !0), this._restoreConnections(c, t, i) } } } }, t.prototype.parseSerializedObject = function (e, t, i) { var r; void 0 === t && (t = ""), void 0 === i && (i = !1), i || this.clear(); for (var n = {}, o = 0, a = e.blocks; o < a.length; o++) { var s = T((p = a[o]).customType); s && ((f = new s)._deserialize(p, this.getScene(), t), n[p.id] = f, this.attachedBlocks.push(f)) } for (var l = 0, c = this.attachedBlocks; l < c.length; l++)if ((f = c[l]).isTeleportOut) { var u = f, h = u._tempEntryPointUniqueId; h && n[h].attachToEndpoint(u) } for (var d = 0; d < e.blocks.length; d++) { var p, f; (f = n[(p = e.blocks[d]).id]) && (f.inputs.length && !i || this._restoreConnections(f, e, n)) } if (e.outputNodes) for (var _ = 0, m = e.outputNodes; _ < m.length; _++) { var g = m[_]; this.addOutputNode(n[g]) } if (e.locations || e.editorData && e.editorData.locations) { for (var v = e.locations || e.editorData.locations, y = 0, b = v; y < b.length; y++) { var E = b[y]; n[E.blockId] && (E.blockId = n[E.blockId].uniqueId) } i && this.editorData && this.editorData.locations && v.concat(this.editorData.locations), e.locations ? this.editorData = { locations: v } : (this.editorData = e.editorData, this.editorData.locations = v); var S = []; for (var x in n) S[x] = n[x].uniqueId; this.editorData.map = S } this.comment = e.comment, void 0 !== e.forceAlphaBlending && (this.forceAlphaBlending = e.forceAlphaBlending), i || (this._mode = null !== (r = e.mode) && void 0 !== r ? r : Da.Material) }, t.prototype.loadFromSerialization = function (e, t, i) { void 0 === t && (t = ""), void 0 === i && (i = !1), this.parseSerializedObject(e, t, i) }, t.prototype.clone = function (e, i) { var r = this; void 0 === i && (i = !1); var n = this.serialize(), o = Ue.Clone((function () { return new t(e, r.getScene(), r.options) }), this); return o.id = e, o.name = e, o.parseSerializedObject(n), o._buildId = this._buildId, o.build(!1, !i), o }, t.Parse = function (e, i, r) { void 0 === r && (r = ""); var n = Ue.Parse((function () { return new t(e.name, i) }), e, i, r); return n.parseSerializedObject(e, r), n.build(), n }, t.ParseFromFileAsync = function (e, i, r, n, o, a) { return void 0 === n && (n = ""), void 0 === o && (o = !1), j(this, void 0, void 0, (function () { var s, l, c; return Y(this, (function (u) { switch (u.label) { case 0: return s = null != a ? a : new t(e, r), [4, r._loadFileAsync(i)]; case 1: return l = u.sent(), c = JSON.parse(l), s.parseSerializedObject(c, n), o || s.build(), [2, s] } })) })) }, t.ParseFromSnippetAsync = function (e, i, r, n, o) { var a = this; return void 0 === i && (i = S.LastCreatedScene), void 0 === r && (r = ""), void 0 === o && (o = !1), "_BLANK" === e ? Promise.resolve(t.CreateDefault("blank", i)) : new Promise((function (s, l) { var c = new He; c.addEventListener("readystatechange", (function () { if (4 == c.readyState) if (200 == c.status) { var a = JSON.parse(JSON.parse(c.responseText).jsonPayload), u = JSON.parse(a.nodeMaterial); n || ((n = Ue.Parse((function () { return new t(e, i) }), u, i, r)).uniqueId = i.getUniqueId()), n.parseSerializedObject(u), n.snippetId = e; try { o || n.build(), s(n) } catch (e) { l(e) } } else l("Unable to load the snippet " + e) })), c.open("GET", a.SnippetUrl + "/" + e.replace(/#/g, "/")), c.send() })) }, t.CreateDefault = function (e, i) { var r = new t(e, i); return r.setToDefault(), r.build(), r }, t._BuildIdGenerator = 0, t.EditorURL = "https://unpkg.com/babylonjs-node-editor@".concat(In.Version, "/babylon.nodeEditor.js"), t.SnippetUrl = a.SnippetUrl, t.IgnoreTexturesAtLoadTime = !1, X([xe()], t.prototype, "ignoreAlpha", void 0), X([xe()], t.prototype, "maxSimultaneousLights", void 0), X([xe("mode")], t.prototype, "_mode", void 0), X([xe("comment")], t.prototype, "comment", void 0), X([xe()], t.prototype, "forceAlphaBlending", void 0), t }(ta); function ls(e) { var t, i = e.sideOrientation || En.DEFAULTSIDE, r = e.radius || 1, n = void 0 === e.flat || e.flat, o = 0 | (e.subdivisions || 4), a = e.radiusX || r, s = e.radiusY || r, l = e.radiusZ || r, c = (1 + Math.sqrt(5)) / 2, u = [-1, c, -0, 1, c, 0, -1, -c, 0, 1, -c, 0, 0, -1, -c, 0, 1, -c, 0, -1, c, 0, 1, c, c, 0, 1, c, 0, -1, -c, 0, 1, -c, 0, -1], h = [0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 12, 22, 23, 1, 5, 20, 5, 11, 4, 23, 22, 13, 22, 18, 6, 7, 1, 8, 14, 21, 4, 14, 4, 2, 16, 13, 6, 15, 6, 19, 3, 8, 9, 4, 21, 5, 13, 17, 23, 6, 13, 22, 19, 6, 18, 9, 8, 1], d = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 2, 3, 3, 3, 4, 7, 8, 9, 9, 10, 11], p = [5, 1, 3, 1, 6, 4, 0, 0, 5, 3, 4, 2, 2, 2, 4, 0, 2, 0, 1, 1, 6, 0, 6, 2, 0, 4, 3, 3, 4, 4, 3, 1, 4, 2, 4, 4, 0, 2, 1, 1, 2, 2, 3, 3, 1, 3, 2, 4], f = [0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0], _ = new Array, m = new Array, g = new Array, v = new Array, y = 0, b = new Array(3), T = new Array(3); for (t = 0; t < 3; t++)b[t] = R.Zero(), T[t] = A.Zero(); for (var E = 0; E < 20; E++) { for (t = 0; t < 3; t++) { var S = h[3 * E + t]; b[t].copyFromFloats(u[3 * d[S]], u[3 * d[S] + 1], u[3 * d[S] + 2]), b[t].normalize(), T[t].copyFromFloats(.134765625 * p[2 * S] + .05859375 + -.0390625 * f[E], .2333984375 * p[2 * S + 1] + .025390625 + .01953125 * f[E]) } for (var x = function (e, t, i, r) { var c, u = R.Lerp(b[0], b[2], t / o), h = R.Lerp(b[1], b[2], t / o), d = o === t ? b[2] : R.Lerp(u, h, e / (o - t)); if (d.normalize(), n) { var p = R.Lerp(b[0], b[2], r / o), f = R.Lerp(b[1], b[2], r / o); c = R.Lerp(p, f, i / (o - r)) } else c = new R(d.x, d.y, d.z); c.x /= a, c.y /= s, c.z /= l, c.normalize(); var E = A.Lerp(T[0], T[2], t / o), S = A.Lerp(T[1], T[2], t / o), x = o === t ? T[2] : A.Lerp(E, S, e / (o - t)); m.push(d.x * a, d.y * s, d.z * l), g.push(c.x, c.y, c.z), v.push(x.x, xn.UseOpenGLOrientationForUV ? 1 - x.y : x.y), _.push(y), y++ }, C = 0; C < o; C++)for (var P = 0; P + C < o; P++)x(P, C, P + 1 / 3, C + 1 / 3), x(P + 1, C, P + 1 / 3, C + 1 / 3), x(P, C + 1, P + 1 / 3, C + 1 / 3), P + C + 1 < o && (x(P + 1, C, P + 2 / 3, C + 2 / 3), x(P + 1, C + 1, P + 2 / 3, C + 2 / 3), x(P, C + 1, P + 2 / 3, C + 2 / 3)) } En._ComputeSides(i, m, _, g, v, e.frontUVs, e.backUVs); var I = new En; return I.indices = _, I.positions = m, I.normals = g, I.uvs = v, I } function cs(e, t, i) { void 0 === t && (t = {}), void 0 === i && (i = null); var r = new Jn(e, i); return t.sideOrientation = Jn._GetDefaultSideOrientation(t.sideOrientation), r._originalBuilderSideOrientation = t.sideOrientation, ls(t).applyToMesh(r, t.updatable), r } b("BABYLON.NodeMaterial", ss); var us, hs, ds, ps = { CreateIcoSphere: cs }; En.CreateIcoSphere = ls, Jn.CreateIcoSphere = function (e, t, i) { return cs(e, t, i) }, function (e) { e.WRIST = "wrist", e.THUMB = "thumb", e.INDEX = "index", e.MIDDLE = "middle", e.RING = "ring", e.LITTLE = "little" }(hs || (hs = {})), function (e) { e.WRIST = "wrist", e.THUMB_METACARPAL = "thumb-metacarpal", e.THUMB_PHALANX_PROXIMAL = "thumb-phalanx-proximal", e.THUMB_PHALANX_DISTAL = "thumb-phalanx-distal", e.THUMB_TIP = "thumb-tip", e.INDEX_FINGER_METACARPAL = "index-finger-metacarpal", e.INDEX_FINGER_PHALANX_PROXIMAL = "index-finger-phalanx-proximal", e.INDEX_FINGER_PHALANX_INTERMEDIATE = "index-finger-phalanx-intermediate", e.INDEX_FINGER_PHALANX_DISTAL = "index-finger-phalanx-distal", e.INDEX_FINGER_TIP = "index-finger-tip", e.MIDDLE_FINGER_METACARPAL = "middle-finger-metacarpal", e.MIDDLE_FINGER_PHALANX_PROXIMAL = "middle-finger-phalanx-proximal", e.MIDDLE_FINGER_PHALANX_INTERMEDIATE = "middle-finger-phalanx-intermediate", e.MIDDLE_FINGER_PHALANX_DISTAL = "middle-finger-phalanx-distal", e.MIDDLE_FINGER_TIP = "middle-finger-tip", e.RING_FINGER_METACARPAL = "ring-finger-metacarpal", e.RING_FINGER_PHALANX_PROXIMAL = "ring-finger-phalanx-proximal", e.RING_FINGER_PHALANX_INTERMEDIATE = "ring-finger-phalanx-intermediate", e.RING_FINGER_PHALANX_DISTAL = "ring-finger-phalanx-distal", e.RING_FINGER_TIP = "ring-finger-tip", e.PINKY_FINGER_METACARPAL = "pinky-finger-metacarpal", e.PINKY_FINGER_PHALANX_PROXIMAL = "pinky-finger-phalanx-proximal", e.PINKY_FINGER_PHALANX_INTERMEDIATE = "pinky-finger-phalanx-intermediate", e.PINKY_FINGER_PHALANX_DISTAL = "pinky-finger-phalanx-distal", e.PINKY_FINGER_TIP = "pinky-finger-tip" }(ds || (ds = {})); var fs, _s, ms, gs = [ds.WRIST, ds.THUMB_METACARPAL, ds.THUMB_PHALANX_PROXIMAL, ds.THUMB_PHALANX_DISTAL, ds.THUMB_TIP, ds.INDEX_FINGER_METACARPAL, ds.INDEX_FINGER_PHALANX_PROXIMAL, ds.INDEX_FINGER_PHALANX_INTERMEDIATE, ds.INDEX_FINGER_PHALANX_DISTAL, ds.INDEX_FINGER_TIP, ds.MIDDLE_FINGER_METACARPAL, ds.MIDDLE_FINGER_PHALANX_PROXIMAL, ds.MIDDLE_FINGER_PHALANX_INTERMEDIATE, ds.MIDDLE_FINGER_PHALANX_DISTAL, ds.MIDDLE_FINGER_TIP, ds.RING_FINGER_METACARPAL, ds.RING_FINGER_PHALANX_PROXIMAL, ds.RING_FINGER_PHALANX_INTERMEDIATE, ds.RING_FINGER_PHALANX_DISTAL, ds.RING_FINGER_TIP, ds.PINKY_FINGER_METACARPAL, ds.PINKY_FINGER_PHALANX_PROXIMAL, ds.PINKY_FINGER_PHALANX_INTERMEDIATE, ds.PINKY_FINGER_PHALANX_DISTAL, ds.PINKY_FINGER_TIP], vs = ((us = {})[hs.WRIST] = [ds.WRIST], us[hs.THUMB] = [ds.THUMB_METACARPAL, ds.THUMB_PHALANX_PROXIMAL, ds.THUMB_PHALANX_DISTAL, ds.THUMB_TIP], us[hs.INDEX] = [ds.INDEX_FINGER_METACARPAL, ds.INDEX_FINGER_PHALANX_PROXIMAL, ds.INDEX_FINGER_PHALANX_INTERMEDIATE, ds.INDEX_FINGER_PHALANX_DISTAL, ds.INDEX_FINGER_TIP], us[hs.MIDDLE] = [ds.MIDDLE_FINGER_METACARPAL, ds.MIDDLE_FINGER_PHALANX_PROXIMAL, ds.MIDDLE_FINGER_PHALANX_INTERMEDIATE, ds.MIDDLE_FINGER_PHALANX_DISTAL, ds.MIDDLE_FINGER_TIP], us[hs.RING] = [ds.RING_FINGER_METACARPAL, ds.RING_FINGER_PHALANX_PROXIMAL, ds.RING_FINGER_PHALANX_INTERMEDIATE, ds.RING_FINGER_PHALANX_DISTAL, ds.RING_FINGER_TIP], us[hs.LITTLE] = [ds.PINKY_FINGER_METACARPAL, ds.PINKY_FINGER_PHALANX_PROXIMAL, ds.PINKY_FINGER_PHALANX_INTERMEDIATE, ds.PINKY_FINGER_PHALANX_DISTAL, ds.PINKY_FINGER_TIP], us), ys = function () { function e(e, t, i, r, n, o, a) { void 0 === n && (n = !1), void 0 === o && (o = !1), void 0 === a && (a = 1), this.xrController = e, this._jointMeshes = t, this._handMesh = i, this.rigMapping = r, this._leftHandedMeshes = n, this._jointsInvisible = o, this._jointScaleFactor = a, this._jointTransforms = new Array(gs.length), this._jointTransformMatrices = new Float32Array(16 * gs.length), this._tempJointMatrix = new I, this._jointRadii = new Float32Array(gs.length), this._scene = t[0].getScene(); for (var s = 0; s < this._jointTransforms.length; s++)(this._jointTransforms[s] = new On(gs[s], this._scene)).rotationQuaternion = new P, t[s].rotationQuaternion = new P; i && this.setHandMesh(i, r), this.xrController.motionController && (this.xrController.motionController.rootMesh ? this.xrController.motionController.rootMesh.setEnabled(!1) : this.xrController.motionController.onModelLoadedObservable.add((function (e) { e.rootMesh && e.rootMesh.setEnabled(!1) }))), this.xrController.onMotionControllerInitObservable.add((function (e) { e.onModelLoadedObservable.add((function (e) { e.rootMesh && e.rootMesh.setEnabled(!1) })), e.rootMesh && e.rootMesh.setEnabled(!1) })) } return Object.defineProperty(e.prototype, "handMesh", { get: function () { return this._handMesh }, enumerable: !1, configurable: !0 }), e.prototype.getHandPartMeshes = function (e) { var t = this; return vs[e].map((function (e) { return t._jointMeshes[gs.indexOf(e)] })) }, e.prototype.getJointMesh = function (e) { return this._jointMeshes[gs.indexOf(e)] }, e.prototype.setHandMesh = function (e, t) { var i = this; if (this._handMesh = e, e.alwaysSelectAsActiveMesh = !0, e.getChildMeshes().forEach((function (e) { return e.alwaysSelectAsActiveMesh = !0 })), this._handMesh.skeleton) { var r = this._handMesh.skeleton; gs.forEach((function (e, n) { var o = r.getBoneIndexByName(t ? t[e] : e); -1 !== o && r.bones[o].linkTransformNode(i._jointTransforms[n]) })) } }, e.prototype.updateFromXRFrame = function (e, t) { var i = this, r = this.xrController.inputSource.hand; if (r) { var n = r, o = gs.map((function (e) { return n[e] || r.get(e) })), a = !1; if (e.fillPoses && e.fillJointRadii) a = e.fillPoses(o, t, this._jointTransformMatrices) && e.fillJointRadii(o, this._jointRadii); else if (e.getJointPose) { a = !0; for (var s = 0; s < o.length; s++) { var l = e.getJointPose(o[s], t); if (!l) { a = !1; break } this._jointTransformMatrices.set(l.transform.matrix, 16 * s), this._jointRadii[s] = l.radius || .008 } } a && (gs.forEach((function (e, t) { var r = i._jointTransforms[t]; I.FromArrayToRef(i._jointTransformMatrices, 16 * t, i._tempJointMatrix), i._tempJointMatrix.decompose(void 0, r.rotationQuaternion, r.position); var n = i._jointRadii[t] * i._jointScaleFactor, o = i._jointMeshes[t]; o.isVisible = !i._handMesh && !i._jointsInvisible, o.position.copyFrom(r.position), o.rotationQuaternion.copyFrom(r.rotationQuaternion), o.scaling.setAll(n), i._scene.useRightHandedSystem || (o.position.z *= -1, o.rotationQuaternion.z *= -1, o.rotationQuaternion.w *= -1, i._leftHandedMeshes && i._handMesh && (r.position.z *= -1, r.rotationQuaternion.z *= -1, r.rotationQuaternion.w *= -1)) })), this._handMesh && (this._handMesh.isVisible = !0)) } }, e.prototype.dispose = function () { this._handMesh && (this._handMesh.isVisible = !1) }, e }(), bs = function (e) { function t(t, i) { var r = e.call(this, t) || this; r.options = i, r._attachedHands = {}, r._trackingHands = { left: null, right: null }, r._handResources = { jointMeshes: null, handMeshes: null, rigMappings: null }, r.onHandAddedObservable = new u, r.onHandRemovedObservable = new u, r._attachHand = function (e) { var t, i, n; if (e.inputSource.hand && "none" != e.inputSource.handedness && r._handResources.jointMeshes) { var o = e.inputSource.handedness, a = new ys(e, r._handResources.jointMeshes[o], r._handResources.handMeshes && r._handResources.handMeshes[o], r._handResources.rigMappings && r._handResources.rigMappings[o], null === (t = r.options.handMeshes) || void 0 === t ? void 0 : t.meshesUseLeftHandedCoordinates, null === (i = r.options.jointMeshes) || void 0 === i ? void 0 : i.invisible, null === (n = r.options.jointMeshes) || void 0 === n ? void 0 : n.scaleFactor); r._attachedHands[e.uniqueId] = a, r._trackingHands[o] = a, r.onHandAddedObservable.notifyObservers(a) } }, r._detachHand = function (e) { r._detachHandById(e.uniqueId) }, r.xrNativeFeatureName = "hand-tracking"; var n = i.jointMeshes; if (n && (void 0 !== n.disableDefaultHandMesh && (i.handMeshes = i.handMeshes || {}, i.handMeshes.disableDefaultMeshes = n.disableDefaultHandMesh), void 0 !== n.handMeshes && (i.handMeshes = i.handMeshes || {}, i.handMeshes.customMeshes = n.handMeshes), void 0 !== n.leftHandedSystemMeshes && (i.handMeshes = i.handMeshes || {}, i.handMeshes.meshesUseLeftHandedCoordinates = n.leftHandedSystemMeshes), void 0 !== n.rigMapping)) { i.handMeshes = i.handMeshes || {}; var o = {}, a = {};[[n.rigMapping.left, o], [n.rigMapping.right, a]].forEach((function (e) { var t = e[0], i = e[1]; t.forEach((function (e, t) { i[gs[t]] = e })) })), i.handMeshes.customRigMappings = { left: o, right: a } } return r } return W(t, e), t._GenerateTrackedJointMeshes = function (e) { var i = {}; return ["left", "right"].map((function (r) { var n, o, a, s, l, c = [], u = (null === (n = e.jointMeshes) || void 0 === n ? void 0 : n.sourceMesh) || cs("jointParent", t._ICOSPHERE_PARAMS); u.isVisible = !!(null === (o = e.jointMeshes) || void 0 === o ? void 0 : o.keepOriginalVisible); for (var h = 0; h < gs.length; ++h) { var d = u.createInstance("".concat(r, "-handJoint-").concat(h)); if (null === (a = e.jointMeshes) || void 0 === a ? void 0 : a.onHandJointMeshGenerated) { var p = e.jointMeshes.onHandJointMeshGenerated(d, h, r); p && p !== d && (d.dispose(), d = p) } if (d.isPickable = !1, null === (s = e.jointMeshes) || void 0 === s ? void 0 : s.enablePhysics) { var f = (null === (l = e.jointMeshes) || void 0 === l ? void 0 : l.physicsProps) || {}; d.scaling.setAll(.02); var _ = void 0 !== f.impostorType ? f.impostorType : Zo.SphereImpostor; d.physicsImpostor = new Zo(d, _, H({ mass: 0 }, f)) } d.rotationQuaternion = new P, d.isVisible = !1, c.push(d) } i[r] = c })), { left: i.left, right: i.right } }, t._GenerateDefaultHandMeshesAsync = function (e, i) { var r = this; return new Promise((function (n) { return j(r, void 0, void 0, (function () { var r, o, s, l, c, u, h, d, p, f, _; return Y(this, (function (m) { switch (m.label) { case 0: return r = {}, (null === (d = null === (h = t._RightHandGLB) || void 0 === h ? void 0 : h.meshes[1]) || void 0 === d ? void 0 : d.isDisposed()) && (t._RightHandGLB = null), (null === (f = null === (p = t._LeftHandGLB) || void 0 === p ? void 0 : p.meshes[1]) || void 0 === f ? void 0 : f.isDisposed()) && (t._LeftHandGLB = null), o = !(!t._RightHandGLB || !t._LeftHandGLB), [4, Promise.all([t._RightHandGLB || ea.ImportMeshAsync("", t.DEFAULT_HAND_MODEL_BASE_URL, t.DEFAULT_HAND_MODEL_RIGHT_FILENAME, e), t._LeftHandGLB || ea.ImportMeshAsync("", t.DEFAULT_HAND_MODEL_BASE_URL, t.DEFAULT_HAND_MODEL_LEFT_FILENAME, e)])]; case 1: return s = m.sent(), t._RightHandGLB = s[0], t._LeftHandGLB = s[1], [4, (l = new ss("handShader", e, { emitComments: !1 })).loadAsync(t.DEFAULT_HAND_MODEL_SHADER_URL)]; case 2: return m.sent(), l.needDepthPrePass = !0, l.transparencyMode = Hn.MATERIAL_ALPHABLEND, l.alphaMode = a.ALPHA_COMBINE, l.build(!1), c = H({ base: B.FromInts(116, 63, 203), fresnel: B.FromInts(149, 102, 229), fingerColor: B.FromInts(177, 130, 255), tipFresnel: B.FromInts(220, 200, 255) }, null === (_ = null == i ? void 0 : i.handMeshes) || void 0 === _ ? void 0 : _.customColors), (u = { base: l.getBlockByName("baseColor"), fresnel: l.getBlockByName("fresnelColor"), fingerColor: l.getBlockByName("fingerColor"), tipFresnel: l.getBlockByName("tipFresnelColor") }).base.value = c.base, u.fresnel.value = c.fresnel, u.fingerColor.value = c.fingerColor, u.tipFresnel.value = c.tipFresnel, ["left", "right"].forEach((function (i) { var n = "left" == i ? t._LeftHandGLB : t._RightHandGLB; if (!n) throw new Error("Could not load hand model"); var a = n.meshes[1]; a._internalAbstractMeshDataInfo._computeBonesUsingShaders = !0, a.material = l.clone("".concat(i, "HandShaderClone"), !0), a.isVisible = !1, r[i] = a, o || e.useRightHandedSystem || n.meshes[1].rotate(Ar.Y, Math.PI) })), l.dispose(), n({ left: r.left, right: r.right }), [2] } })) })) })) }, t._GenerateDefaultHandMeshRigMapping = function (e) { var t, i = "right" == e ? "R" : "L"; return (t = {})[ds.WRIST] = "wrist_".concat(i), t[ds.THUMB_METACARPAL] = "thumb_metacarpal_".concat(i), t[ds.THUMB_PHALANX_PROXIMAL] = "thumb_proxPhalanx_".concat(i), t[ds.THUMB_PHALANX_DISTAL] = "thumb_distPhalanx_".concat(i), t[ds.THUMB_TIP] = "thumb_tip_".concat(i), t[ds.INDEX_FINGER_METACARPAL] = "index_metacarpal_".concat(i), t[ds.INDEX_FINGER_PHALANX_PROXIMAL] = "index_proxPhalanx_".concat(i), t[ds.INDEX_FINGER_PHALANX_INTERMEDIATE] = "index_intPhalanx_".concat(i), t[ds.INDEX_FINGER_PHALANX_DISTAL] = "index_distPhalanx_".concat(i), t[ds.INDEX_FINGER_TIP] = "index_tip_".concat(i), t[ds.MIDDLE_FINGER_METACARPAL] = "middle_metacarpal_".concat(i), t[ds.MIDDLE_FINGER_PHALANX_PROXIMAL] = "middle_proxPhalanx_".concat(i), t[ds.MIDDLE_FINGER_PHALANX_INTERMEDIATE] = "middle_intPhalanx_".concat(i), t[ds.MIDDLE_FINGER_PHALANX_DISTAL] = "middle_distPhalanx_".concat(i), t[ds.MIDDLE_FINGER_TIP] = "middle_tip_".concat(i), t[ds.RING_FINGER_METACARPAL] = "ring_metacarpal_".concat(i), t[ds.RING_FINGER_PHALANX_PROXIMAL] = "ring_proxPhalanx_".concat(i), t[ds.RING_FINGER_PHALANX_INTERMEDIATE] = "ring_intPhalanx_".concat(i), t[ds.RING_FINGER_PHALANX_DISTAL] = "ring_distPhalanx_".concat(i), t[ds.RING_FINGER_TIP] = "ring_tip_".concat(i), t[ds.PINKY_FINGER_METACARPAL] = "little_metacarpal_".concat(i), t[ds.PINKY_FINGER_PHALANX_PROXIMAL] = "little_proxPhalanx_".concat(i), t[ds.PINKY_FINGER_PHALANX_INTERMEDIATE] = "little_intPhalanx_".concat(i), t[ds.PINKY_FINGER_PHALANX_DISTAL] = "little_distPhalanx_".concat(i), t[ds.PINKY_FINGER_TIP] = "little_tip_".concat(i), t }, t.prototype.isCompatible = function () { return "undefined" != typeof XRHand }, t.prototype.getHandByControllerId = function (e) { return this._attachedHands[e] }, t.prototype.getHandByHandedness = function (e) { return "none" == e ? null : this._trackingHands[e] }, t.prototype.attach = function () { var i, r, n, o, a = this; return !!e.prototype.attach.call(this) && (this._handResources = { jointMeshes: t._GenerateTrackedJointMeshes(this.options), handMeshes: (null === (i = this.options.handMeshes) || void 0 === i ? void 0 : i.customMeshes) || null, rigMappings: (null === (r = this.options.handMeshes) || void 0 === r ? void 0 : r.customRigMappings) || null }, (null === (n = this.options.handMeshes) || void 0 === n ? void 0 : n.customMeshes) || (null === (o = this.options.handMeshes) || void 0 === o ? void 0 : o.disableDefaultMeshes) || t._GenerateDefaultHandMeshesAsync(S.LastCreatedScene, this.options).then((function (e) { var i, r; a._handResources.handMeshes = e, a._handResources.rigMappings = { left: t._GenerateDefaultHandMeshRigMapping("left"), right: t._GenerateDefaultHandMeshRigMapping("right") }, null === (i = a._trackingHands.left) || void 0 === i || i.setHandMesh(a._handResources.handMeshes.left, a._handResources.rigMappings.left), null === (r = a._trackingHands.right) || void 0 === r || r.setHandMesh(a._handResources.handMeshes.right, a._handResources.rigMappings.right) })), this.options.xrInput.controllers.forEach(this._attachHand), this._addNewAttachObserver(this.options.xrInput.onControllerAddedObservable, this._attachHand), this._addNewAttachObserver(this.options.xrInput.onControllerRemovedObservable, this._detachHand), !0) }, t.prototype._onXRFrame = function (e) { var t, i; null === (t = this._trackingHands.left) || void 0 === t || t.updateFromXRFrame(e, this._xrSessionManager.referenceSpace), null === (i = this._trackingHands.right) || void 0 === i || i.updateFromXRFrame(e, this._xrSessionManager.referenceSpace) }, t.prototype._detachHandById = function (e) { var t, i = this.getHandByControllerId(e); if (i) { var r = "left" == i.xrController.inputSource.handedness ? "left" : "right"; (null === (t = this._trackingHands[r]) || void 0 === t ? void 0 : t.xrController.uniqueId) === e && (this._trackingHands[r] = null), this.onHandRemovedObservable.notifyObservers(i), i.dispose(), delete this._attachedHands[e] } }, t.prototype.detach = function () { var t = this; return !!e.prototype.detach.call(this) && (Object.keys(this._attachedHands).forEach((function (e) { return t._detachHandById(e) })), !0) }, t.prototype.dispose = function () { var i; e.prototype.dispose.call(this), this.onHandAddedObservable.clear(), this.onHandRemovedObservable.clear(), this._handResources.handMeshes && !(null === (i = this.options.handMeshes) || void 0 === i ? void 0 : i.customMeshes) && (this._handResources.handMeshes.left.dispose(), this._handResources.handMeshes.right.dispose(), t._RightHandGLB = null, t._LeftHandGLB = null), this._handResources.jointMeshes && (this._handResources.jointMeshes.left.forEach((function (e) { return e.dispose() })), this._handResources.jointMeshes.right.forEach((function (e) { return e.dispose() }))) }, t.Name = zo.HAND_TRACKING, t.Version = 1, t.DEFAULT_HAND_MODEL_BASE_URL = "https://assets.babylonjs.com/meshes/HandMeshes/", t.DEFAULT_HAND_MODEL_RIGHT_FILENAME = "r_hand_rhs.glb", t.DEFAULT_HAND_MODEL_LEFT_FILENAME = "l_hand_rhs.glb", t.DEFAULT_HAND_MODEL_SHADER_URL = "https://assets.babylonjs.com/meshes/HandMeshes/handsShader.json", t._ICOSPHERE_PARAMS = { radius: .5, flat: !1, subdivisions: 2 }, t._RightHandGLB = null, t._LeftHandGLB = null, t }(Ho); Wo.AddWebXRFeature(bs.Name, (function (e, t) { return function () { return new bs(e, t) } }), bs.Version, !1), function (e) { e[e.ABOVE_FINGER_TIPS = 0] = "ABOVE_FINGER_TIPS", e[e.RADIAL_SIDE = 1] = "RADIAL_SIDE", e[e.ULNAR_SIDE = 2] = "ULNAR_SIDE", e[e.BELOW_WRIST = 3] = "BELOW_WRIST" }(fs || (fs = {})), function (e) { e[e.LOOK_AT_CAMERA = 0] = "LOOK_AT_CAMERA", e[e.HAND_ROTATION = 1] = "HAND_ROTATION" }(_s || (_s = {})), function (e) { e[e.ALWAYS_VISIBLE = 0] = "ALWAYS_VISIBLE", e[e.PALM_UP = 1] = "PALM_UP", e[e.GAZE_FOCUS = 2] = "GAZE_FOCUS", e[e.PALM_AND_GAZE = 3] = "PALM_AND_GAZE" }(ms || (ms = {})); var Ts = function () { function e() { this._sceneRenderObserver = null, this._zoneAxis = {}, this.handConstraintVisibility = ms.PALM_AND_GAZE, this.palmUpStrictness = .95, this.gazeProximityRadius = .15, this.targetOffset = .1, this.targetZone = fs.ULNAR_SIDE, this.zoneOrientationMode = _s.HAND_ROTATION, this.nodeOrientationMode = _s.HAND_ROTATION, this.handedness = "none", this.lerpTime = 100, this._zoneAxis[fs.ABOVE_FINGER_TIPS] = new R(0, 1, 0), this._zoneAxis[fs.RADIAL_SIDE] = new R(-1, 0, 0), this._zoneAxis[fs.ULNAR_SIDE] = new R(1, 0, 0), this._zoneAxis[fs.BELOW_WRIST] = new R(0, -1, 0) } return Object.defineProperty(e.prototype, "name", { get: function () { return "HandConstraint" }, enumerable: !1, configurable: !0 }), e.prototype.enable = function () { this._node.setEnabled(!0) }, e.prototype.disable = function () { this._node.setEnabled(!1) }, e.prototype._getHandPose = function () { if (!this._handTracking) return null; var e; if (e = "none" === this.handedness ? this._handTracking.getHandByHandedness("left") || this._handTracking.getHandByHandedness("right") : this._handTracking.getHandByHandedness(this.handedness)) { var t = e.getJointMesh(ds.PINKY_FINGER_METACARPAL), i = e.getJointMesh(ds.MIDDLE_FINGER_METACARPAL), r = e.getJointMesh(ds.WRIST); if (r && i && t) { var n = { position: i.absolutePosition, quaternion: new P, id: e.xrController.uniqueId }, o = O.Vector3[0], a = O.Vector3[1], s = O.Vector3[2]; return o.copyFrom(i.absolutePosition).subtractInPlace(r.absolutePosition).normalize(), a.copyFrom(t.absolutePosition).subtractInPlace(i.absolutePosition).normalize(), R.CrossToRef(o, a, a), R.CrossToRef(a, o, s), P.FromLookDirectionLHToRef(a, o, n.quaternion), n } } return null }, e.prototype.init = function () { }, e.prototype.attach = function (e) { var t = this; this._node = e, this._scene = e.getScene(), this._node.rotationQuaternion || (this._node.rotationQuaternion = P.RotationYawPitchRoll(this._node.rotation.y, this._node.rotation.x, this._node.rotation.z)); var i = Date.now(); this._sceneRenderObserver = this._scene.onBeforeRenderObservable.add((function () { var e = t._getHandPose(); if (t._node.reservedDataStore = t._node.reservedDataStore || {}, t._node.reservedDataStore.nearInteraction = t._node.reservedDataStore.nearInteraction || {}, t._node.reservedDataStore.nearInteraction.excludedControllerId = null, e) { var r = O.Vector3[0], n = t._scene.activeCamera; r.copyFrom(t._zoneAxis[t.targetZone]); var o = O.Quaternion[0]; if (n && (t.zoneOrientationMode === _s.LOOK_AT_CAMERA || t.nodeOrientationMode === _s.LOOK_AT_CAMERA)) { var a = O.Vector3[1]; a.copyFrom(n.position).subtractInPlace(e.position).normalize(), t._scene.useRightHandedSystem ? P.FromLookDirectionRHToRef(a, R.UpReadOnly, o) : P.FromLookDirectionLHToRef(a, R.UpReadOnly, o) } t.zoneOrientationMode === _s.HAND_ROTATION ? e.quaternion.toRotationMatrix(O.Matrix[0]) : o.toRotationMatrix(O.Matrix[0]), R.TransformNormalToRef(r, O.Matrix[0], r), r.scaleInPlace(t.targetOffset); var s = O.Vector3[2], l = O.Quaternion[1]; s.copyFrom(e.position).addInPlace(r), t.nodeOrientationMode === _s.HAND_ROTATION ? l.copyFrom(e.quaternion) : l.copyFrom(o); var c = Date.now() - i; R.SmoothToRef(t._node.position, s, c, t.lerpTime, t._node.position), P.SmoothToRef(t._node.rotationQuaternion, l, c, t.lerpTime, t._node.rotationQuaternion), t._node.reservedDataStore.nearInteraction.excludedControllerId = e.id } t._setVisibility(e), i = Date.now() })) }, e.prototype._setVisibility = function (e) { var t = !0, i = !0, r = this._scene.activeCamera; if (r) { var n = r.getForwardRay(); if (this.handConstraintVisibility === ms.GAZE_FOCUS || this.handConstraintVisibility === ms.PALM_AND_GAZE) { i = !1; var o = void 0; this._eyeTracking && (o = this._eyeTracking.getEyeGaze()), o = o || n; var a = O.Vector3[0]; e ? e.position.subtractToRef(o.origin, a) : this._node.getAbsolutePosition().subtractToRef(o.origin, a); var s = R.Dot(a, o.direction), l = s * s; s > 0 && a.lengthSquared() - l < this.gazeProximityRadius * this.gazeProximityRadius && (i = !0) } if ((this.handConstraintVisibility === ms.PALM_UP || this.handConstraintVisibility === ms.PALM_AND_GAZE) && (t = !1, e)) { var c = O.Vector3[0]; R.LeftHandedForwardReadOnly.rotateByQuaternionToRef(e.quaternion, c), R.Dot(c, n.direction) > 2 * 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(zo.EYE_TRACKING) } catch (e) { } try { this._handTracking = t.getEnabledFeature(zo.HAND_TRACKING) } catch (e) { xi.Error("Hand tracking must be enabled for the Hand Menu to work") } } else xi.Error("XR features manager must be available or provided directly for the Hand Menu to work") }, e }(), Es = 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(Er.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, Er.WORLD, this.mesh), this._slerping = !0) : (this._bone1.setRotationMatrix(r, Er.WORLD, this.mesh), this._bone1Mat.copyFrom(r), this._slerping = !1), this._updateLinkedTransformRotation(this._bone1)), this._bone2.setAxisAngle(this._bendAxis, v, Er.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(Er.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 }(), Ss = function () { function e(e, t, i, r) { if (this.upAxis = R.Up(), this.upAxisSpace = Er.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 = Ar.Y, o = Ar.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 != Er.BONE || (this.upAxisSpace = Er.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 == Er.BONE && s ? (this._transformYawPitch && R.TransformCoordinatesToRef(l, this._transformYawPitchInv, l), s.getDirectionToRef(l, this.mesh, l)) : this.upAxisSpace == Er.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 == Er.BONE && 1 == l.y && s) s.getRotationMatrixToRef(Er.WORLD, this.mesh, h); else if (this.upAxisSpace != Er.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) : g < this._minPitch && (m.y = this._minPitchTan * _, v = this._minPitch), g != v && (R.TransformCoordinatesToRef(m, h, m), m.addInPlace(i), r = m) } if (c) { m = e._TmpVecs[4], r.subtractToRef(i, m), R.TransformCoordinatesToRef(m, d, m); var y = Math.atan2(m.x, m.z), b = this.useAbsoluteValueForYaw ? Math.abs(y) : y, T = y; if ((b > this._maxYaw || b < this._minYaw) && (null == _ && (_ = Math.sqrt(m.x * m.x + m.z * m.z)), this._yawRange > Math.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) : b < this._minYaw && (m.z = this._minYawCos * _, m.x = this._minYawSin * _, y < 0 && this.useAbsoluteValueForYaw && (m.x *= -1), T = this._minYaw)), this._slerping && this._yawRange > Math.PI) { var E = e._TmpVecs[8]; E.copyFrom(Ar.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) < A ? (T = x + .75 * Math.PI, m.z = Math.cos(T) * _, m.x = Math.sin(T) * _) : (T = x - .75 * Math.PI, m.z = Math.cos(T) * _, m.x = Math.sin(T) * _) } } y != T && (R.TransformCoordinatesToRef(m, h, m), m.addInPlace(i), r = m) } } var C = e._TmpVecs[5], M = e._TmpVecs[6], O = e._TmpVecs[7], D = e._TmpQuat; r.subtractToRef(i, C), C.normalize(), R.CrossToRef(l, C, M), M.normalize(), R.CrossToRef(C, M, O), O.normalize(), I.FromXYZAxesToRef(M, O, C, n), 0 === M.x && 0 === M.y && 0 === M.z || 0 === O.x && 0 === O.y && 0 === O.z || 0 === C.x && 0 === C.y && 0 === C.z || ((this.adjustYaw || this.adjustPitch || this.adjustRoll) && (I.RotationYawPitchRollToRef(this.adjustYaw, this.adjustPitch, this.adjustRoll, o), o.multiplyToRef(n, n)), this.slerpAmount < 1 ? (this._slerping || this.bone.getRotationQuaternionToRef(Er.WORLD, this.mesh, this._boneQuat), this._transformYawPitch && this._transformYawPitch.multiplyToRef(n, n), P.FromRotationMatrixToRef(n, D), P.SlerpToRef(this._boneQuat, D, this.slerpAmount, this._boneQuat), this.bone.setRotationQuaternion(this._boneQuat, Er.WORLD, this.mesh), this._slerping = !0) : (this._transformYawPitch && this._transformYawPitch.multiplyToRef(n, n), this.bone.setRotationMatrix(n, Er.WORLD, this.mesh), this._slerping = !1), this._updateLinkedTransformRotation()) } }, e.prototype._getAngleDiff = function (e, t) { var i = t - e; return (i %= 2 * Math.PI) > 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 && e < i) return !0 } else if (e > i && e < t) return !0; return !1 }, e.prototype._updateLinkedTransformRotation = function () { var e = this.bone; e._linkedTransformNode && (e._linkedTransformNode.rotationQuaternion || (e._linkedTransformNode.rotationQuaternion = new P), e.getRotationQuaternionToRef(Er.LOCAL, null, e._linkedTransformNode.rotationQuaternion)) }, e._TmpVecs = m.BuildArray(10, R.Zero), e._TmpQuat = P.Identity(), e._TmpMats = m.BuildArray(5, I.Identity), e }(), xs = function () { function e(e, t, i) { this.name = e, this.id = t, this.bones = new Array, this.needInitialSkinMatrix = !1, this._isDirty = !0, this._meshesWithPoseMatrix = new Array, this._identity = I.Identity(), this._ranges = {}, this._absoluteTransformIsDirty = !0, this._canUseTextureForBones = !1, this._uniqueId = 0, this._numBonesWithLinkedTransformNode = 0, this._hasWaitingData = null, this._parentContainer = null, this.doNotSerialize = !1, this._useTextureToStoreBoneMatrices = !0, this._animationPropertiesOverride = null, this.onBeforeComputeObservable = new u, this.bones = [], this._scene = i || S.LastCreatedScene, this._uniqueId = this._scene.getUniqueId(), this._scene.addSkeleton(this), this._isDirty = !0; var r = this._scene.getEngine().getCaps(); this._canUseTextureForBones = r.textureFloat && r.maxVertexTextureImageUnits > 0 } return Object.defineProperty(e.prototype, "useTextureToStoreBoneMatrices", { get: function () { return this._useTextureToStoreBoneMatrices }, set: function (e) { this._useTextureToStoreBoneMatrices = e, this._markAsDirty() }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "animationPropertiesOverride", { get: function () { return this._animationPropertiesOverride ? this._animationPropertiesOverride : this._scene.animationPropertiesOverride }, set: function (e) { this._animationPropertiesOverride = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isUsingTextureForMatrices", { get: function () { return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "uniqueId", { get: function () { return this._uniqueId }, enumerable: !1, configurable: !0 }), e.prototype.getClassName = function () { return "Skeleton" }, e.prototype.getChildren = function () { return this.bones.filter((function (e) { return !e.getParent() })) }, e.prototype.getTransformMatrices = function (e) { 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 < i; t++)if (this.bones[t].name === e) return t; return -1 }, e.prototype.createAnimationRange = function (e, t, i) { if (!this._ranges[e]) { this._ranges[e] = new ke(e, t, i); for (var r = 0, n = this.bones.length; r < n; r++)this.bones[r].animations[0] && this.bones[r].animations[0].createRange(e, t, i) } }, e.prototype.deleteAnimationRange = function (e, t) { void 0 === t && (t = !0); for (var i = 0, r = this.bones.length; i < r; i++)this.bones[i].animations[0] && this.bones[i].animations[0].deleteRange(e, t); this._ranges[e] = null }, e.prototype.getAnimationRange = function (e) { return this._ranges[e] || null }, e.prototype.getAnimationRanges = function () { var e, t = []; for (e in this._ranges) t.push(this._ranges[e]); return t }, e.prototype.copyAnimationRange = function (e, t, i) { if (void 0 === i && (i = !1), this._ranges[t] || !e.getAnimationRange(t)) return !1; var r, n, o = !0, a = this._getHighestAnimationFrame() + 1, s = {}, l = e.bones; for (n = 0, r = l.length; n < r; n++)s[l[n].name] = l[n]; this.bones.length !== l.length && ($.Warn("copyAnimationRange: this rig has ".concat(this.bones.length, " bones, while source as ").concat(l.length)), o = !1); var c = i && this.dimensionsAtRest && e.dimensionsAtRest ? this.dimensionsAtRest.divide(e.dimensionsAtRest) : null; for (n = 0, r = this.bones.length; n < r; n++) { var u = this.bones[n].name, h = s[u]; h ? o = o && this.bones[n].copyAnimationRange(h, t, a, i, c) : ($.Warn("copyAnimationRange: not same rig, missing source bone " + u), o = !1) } var d = e.getAnimationRange(t); return d && (this._ranges[t] = new ke(t, d.from + a, d.to + a)), o }, e.prototype.returnToRest = function () { for (var e = 0, t = this.bones; e < t.length; e++) { var i = t[e]; -1 !== i._index && i.returnToRest() } }, e.prototype._getHighestAnimationFrame = function () { for (var e = 0, t = 0, i = this.bones.length; t < i; t++)if (this.bones[t].animations[0]) { var r = this.bones[t].animations[0].getHighestFrame(); e < r && (e = r) } return e }, e.prototype.beginAnimation = function (e, t, i, r) { var n = this.getAnimationRange(e); return n ? this._scene.beginAnimation(this, n.from, n.to, t, i, r) : null }, e.MakeAnimationAdditive = function (e, t, i) { void 0 === t && (t = 0); var r = e.getAnimationRange(i); if (!r) return null; for (var n = e._scene.getAllAnimatablesByTarget(e), o = null, a = 0; a < n.length; a++) { var s = n[a]; if (s.fromFrame === (null == r ? void 0 : r.from) && s.toFrame === (null == r ? void 0 : r.to)) { o = s; break } } var l = e.getAnimatables(); for (a = 0; a < l.length; a++) { var c = l[a].animations; if (c) for (var u = 0; u < c.length; u++)je.MakeAnimationAdditive(c[u], t, i) } return o && (o.isAdditive = !0), e }, e.prototype._markAsDirty = function () { this._isDirty = !0, this._absoluteTransformIsDirty = !0 }, e.prototype._registerMeshWithPoseMatrix = function (e) { this._meshesWithPoseMatrix.push(e) }, e.prototype._unregisterMeshWithPoseMatrix = function (e) { var t = this._meshesWithPoseMatrix.indexOf(e); t > -1 && this._meshesWithPoseMatrix.splice(t, 1) }, e.prototype._computeTransformMatrices = function (e, t) { this.onBeforeComputeObservable.notifyObservers(this); for (var i = 0; i < this.bones.length; i++) { var r = this.bones[i]; r._childUpdateId++; var n = r.getParent(); if (n ? r.getLocalMatrix().multiplyToRef(n.getFinalMatrix(), r.getFinalMatrix()) : t ? r.getLocalMatrix().multiplyToRef(t, r.getFinalMatrix()) : r.getFinalMatrix().copyFrom(r.getLocalMatrix()), -1 !== r._index) { var o = null === r._index ? i : r._index; r.getAbsoluteInverseBindMatrix().multiplyToArray(r.getFinalMatrix(), e, 16 * o) } } this._identity.copyToArray(e, 16 * this.bones.length) }, e.prototype.prepare = function () { if (this._numBonesWithLinkedTransformNode > 0) for (var e = 0, t = this.bones; e < t.length; e++)if ((h = t[e])._linkedTransformNode) { var i = h._linkedTransformNode; h.position = i.position, i.rotationQuaternion ? h.rotationQuaternion = i.rotationQuaternion : h.rotation = i.rotation, h.scaling = i.scaling } if (this.needInitialSkinMatrix) for (var r = 0, n = this._meshesWithPoseMatrix; r < n.length; r++) { var o = n[r], s = o.getPoseMatrix(), l = this._isDirty; if (o._bonesTransformMatrices && o._bonesTransformMatrices.length === 16 * (this.bones.length + 1) || (o._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1)), l = !0), l) { if (this._synchronizedWithMesh !== o) { this._synchronizedWithMesh = o; for (var c = 0, u = this.bones; c < u.length; c++) { var h; (h = u[c]).getParent() || (h.getBindMatrix().multiplyToRef(s, O.Matrix[1]), h._updateAbsoluteBindMatrices(O.Matrix[1])) } if (this.isUsingTextureForMatrices) { var d = 4 * (this.bones.length + 1); o._transformMatrixTexture && o._transformMatrixTexture.getSize().width === d || (o._transformMatrixTexture && o._transformMatrixTexture.dispose(), o._transformMatrixTexture = Eo.CreateRGBATexture(o._bonesTransformMatrices, 4 * (this.bones.length + 1), 1, this._scene, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE, a.TEXTURETYPE_FLOAT)) } } this._computeTransformMatrices(o._bonesTransformMatrices, s), this.isUsingTextureForMatrices && o._transformMatrixTexture && o._transformMatrixTexture.update(o._bonesTransformMatrices) } } else { if (!this._isDirty) return; this._transformMatrices && this._transformMatrices.length === 16 * (this.bones.length + 1) || (this._transformMatrices = new Float32Array(16 * (this.bones.length + 1)), this.isUsingTextureForMatrices && (this._transformMatrixTexture && this._transformMatrixTexture.dispose(), this._transformMatrixTexture = Eo.CreateRGBATexture(this._transformMatrices, 4 * (this.bones.length + 1), 1, this._scene, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE, a.TEXTURETYPE_FLOAT))), this._computeTransformMatrices(this._transformMatrices, null), this.isUsingTextureForMatrices && this._transformMatrixTexture && this._transformMatrixTexture.update(this._transformMatrices) } this._isDirty = !1 }, e.prototype.getAnimatables = function () { if (!this._animatables || this._animatables.length !== this.bones.length) { this._animatables = []; for (var e = 0; e < this.bones.length; e++)this._animatables.push(this.bones[e]) } return this._animatables }, e.prototype.clone = function (t, i) { var r = new e(t, i || t, this._scene); r.needInitialSkinMatrix = this.needInitialSkinMatrix; for (var n = 0; n < this.bones.length; n++) { var o = this.bones[n], a = null, s = o.getParent(); if (s) { var l = this.bones.indexOf(s); a = r.bones[l] } var c = new Rr(o.name, r, a, o.getBindMatrix().clone(), o.getRestMatrix().clone()); c._index = o._index, o._linkedTransformNode && c.linkTransformNode(o._linkedTransformNode), he.DeepCopy(o.animations, c.animations) } if (this._ranges) for (var u in r._ranges = {}, this._ranges) { var h = this._ranges[u]; h && (r._ranges[u] = h.clone()) } return this._isDirty = !0, r.prepare(), r }, e.prototype.enableBlending = function (e) { void 0 === e && (e = .01), this.bones.forEach((function (t) { t.animations.forEach((function (t) { t.enableBlending = !0, t.blendingSpeed = e })) })) }, e.prototype.dispose = function () { if (this._meshesWithPoseMatrix.length = 0, this.getScene().stopAnimation(this), this.getScene().removeSkeleton(this), this._parentContainer) { var e = this._parentContainer.skeletons.indexOf(this); e > -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; i < this.bones.length; i++) { var r = this.bones[i], n = r.getParent(), o = { parentBoneIndex: n ? this.bones.indexOf(n) : -1, index: r.getIndex(), name: r.name, id: r.id, matrix: r.getBindMatrix().toArray(), rest: r.getRestMatrix().toArray(), linkedTransformNodeId: null === (e = r.getTransformNode()) || void 0 === e ? void 0 : e.id }; for (var a in t.bones.push(o), r.length && (o.length = r.length), r.metadata && (o.metadata = r.metadata), r.animations && r.animations.length > 0 && (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 < t.bones.length; r++) { var o = t.bones[r], a = t.bones[r].index, s = null; o.parentBoneIndex > -1 && (s = n.bones[o.parentBoneIndex]); var l = o.rest ? I.FromArray(o.rest) : null, c = new Rr(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(je.Parse(o.animation)), void 0 !== o.linkedTransformNodeId && null !== o.linkedTransformNodeId && (n._hasWaitingData = !0, c._waitingTransformNodeId = o.linkedTransformNodeId) } if (t.ranges) for (r = 0; r < t.ranges.length; r++) { var u = t.ranges[r]; n.createAnimationRange(u.name, u.from, u.to) } return n }, e.prototype.computeAbsoluteMatrices = function (e) { void 0 === e && (e = !1), (this._absoluteTransformIsDirty || e) && (this.bones[0].computeAbsoluteMatrices(), this._absoluteTransformIsDirty = !1) }, e.prototype.computeAbsoluteTransforms = function (e) { void 0 === e && (e = !1), this.computeAbsoluteMatrices(e) }, e.prototype.getPoseMatrix = function () { var e = null; return this._meshesWithPoseMatrix.length > 0 && (e = this._meshesWithPoseMatrix[0].getPoseMatrix()), e }, e.prototype.sortBones = function () { for (var e = new Array, t = new Array(this.bones.length), i = 0; i < this.bones.length; i++)this._sortBones(i, e, t); this.bones = e }, e.prototype._sortBones = function (e, t, i) { if (!i[e]) { i[e] = !0; var r = this.bones[e]; if (r) { void 0 === r._index && (r._index = e); var n = r.getParent(); n && this._sortBones(this.bones.indexOf(n), t, i), t.push(r) } } }, e.prototype.setCurrentPoseAsRest = function () { this.bones.forEach((function (e) { e.setCurrentPoseAsRest() })) }, e }(), As = function () { function e(e, t, i) { void 0 === i && (i = a.BUFFER_CREATIONFLAG_READWRITE), this._engine = e, this._engine._storageBuffers.push(this), this._create(t, i) } return e.prototype._create = function (e, t) { this._bufferSize = e, this._creationFlags = t, this._buffer = this._engine.createStorageBuffer(e, t) }, e.prototype._rebuild = function () { this._create(this._bufferSize, this._creationFlags) }, e.prototype.getBuffer = function () { return this._buffer }, e.prototype.update = function (e, t, i) { this._buffer && this._engine.updateStorageBuffer(this._buffer, e, t, i) }, e.prototype.read = function (e, t, i) { return this._engine.readFromStorageBuffer(this._buffer, e, t, i) }, e.prototype.dispose = function () { var e = this._engine._storageBuffers, t = e.indexOf(this); -1 !== t && (e[t] = e[e.length - 1], e.pop()), this._engine._releaseBuffer(this._buffer), this._buffer = null }, e }(), Rs = function () { function e() { this.wheelPrecisionX = 3, this.wheelPrecisionY = 3, this.wheelPrecisionZ = 3, this.onChangedObservable = new u, this._wheelDeltaX = 0, this._wheelDeltaY = 0, this._wheelDeltaZ = 0, this._ffMultiplier = 12, this._normalize = 120 } return e.prototype.attachControl = function (e) { var t = this; e = xi.BackCompatCameraNoPreventDefault(arguments), this._wheel = function (i) { if (i.type === Ji.POINTERWHEEL) { var r = i.event, n = r.deltaMode === ar.DOM_DELTA_LINE ? t._ffMultiplier : 1; t._wheelDeltaX += t.wheelPrecisionX * n * r.deltaX / t._normalize, t._wheelDeltaY -= t.wheelPrecisionY * n * r.deltaY / t._normalize, t._wheelDeltaZ += t.wheelPrecisionZ * n * r.deltaZ / t._normalize, r.preventDefault && (e || r.preventDefault()) } }, this._observer = this.camera.getScene()._inputManager._addCameraPointerObserver(this._wheel, Ji.POINTERWHEEL) }, e.prototype.detachControl = function () { this._observer && (this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer), this._observer = null, this._wheel = null), this.onChangedObservable && this.onChangedObservable.clear() }, e.prototype.checkInputs = function () { this.onChangedObservable.notifyObservers({ wheelDeltaX: this._wheelDeltaX, wheelDeltaY: this._wheelDeltaY, wheelDeltaZ: this._wheelDeltaZ }), this._wheelDeltaX = 0, this._wheelDeltaY = 0, this._wheelDeltaZ = 0 }, e.prototype.getClassName = function () { return "BaseCameraMouseWheelInput" }, e.prototype.getSimpleName = function () { return "mousewheel" }, X([xe()], e.prototype, "wheelPrecisionX", void 0), X([xe()], e.prototype, "wheelPrecisionY", void 0), X([xe()], e.prototype, "wheelPrecisionZ", void 0), e }(), Cs = function () { function e() { this._currentActiveButton = -1, this.buttons = [0, 1, 2] } return e.prototype.attachControl = function (e) { var t = this; e = xi.BackCompatCameraNoPreventDefault(arguments); var i = this.camera.getEngine(), r = i.getInputElement(), n = 0, o = null; this._pointA = null, this._pointB = null, this._altKey = !1, this._ctrlKey = !1, this._metaKey = !1, this._shiftKey = !1, this._buttonsPressed = 0, this._pointerInput = function (a) { var s, l, c = a.event, u = "touch" === c.pointerType; if (!i.isInVRExclusivePointerMode && (a.type === Ji.POINTERMOVE || -1 !== t.buttons.indexOf(c.button))) { var h = c.target; if (t._altKey = c.altKey, t._ctrlKey = c.ctrlKey, t._metaKey = c.metaKey, t._shiftKey = c.shiftKey, t._buttonsPressed = c.buttons, i.isPointerLock) { var d = c.movementX, p = c.movementY; t.onTouch(null, d, p), t._pointA = null, t._pointB = null } else { if (a.type !== Ji.POINTERDOWN && u && (null === (s = t._pointA) || void 0 === s ? void 0 : s.pointerId) !== c.pointerId && (null === (l = t._pointB) || void 0 === l ? void 0 : l.pointerId) !== c.pointerId) return; if (a.type !== Ji.POINTERDOWN || -1 !== t._currentActiveButton && !u) if (a.type === Ji.POINTERDOUBLETAP) t.onDoubleTap(c.pointerType); else if (a.type !== Ji.POINTERUP || t._currentActiveButton !== c.button && !u) { if (a.type === Ji.POINTERMOVE) if (e || c.preventDefault(), t._pointA && null === t._pointB) d = c.clientX - t._pointA.x, p = c.clientY - t._pointA.y, t.onTouch(t._pointA, d, p), t._pointA.x = c.clientX, t._pointA.y = c.clientY; else if (t._pointA && t._pointB) { var f = t._pointA.pointerId === c.pointerId ? t._pointA : t._pointB; f.x = c.clientX, f.y = c.clientY; var _ = t._pointA.x - t._pointB.x, m = t._pointA.y - t._pointB.y, g = _ * _ + m * m, v = { x: (t._pointA.x + t._pointB.x) / 2, y: (t._pointA.y + t._pointB.y) / 2, pointerId: c.pointerId, type: a.type }; t.onMultiTouch(t._pointA, t._pointB, n, g, o, v), o = v, n = g } } else { try { null == h || h.releasePointerCapture(c.pointerId) } catch (e) { } u || (t._pointB = null), i._badOS ? t._pointA = t._pointB = null : t._pointB && t._pointA && t._pointA.pointerId == c.pointerId ? (t._pointA = t._pointB, t._pointB = null) : t._pointA && t._pointB && t._pointB.pointerId == c.pointerId ? t._pointB = null : t._pointA = t._pointB = null, (0 !== n || o) && (t.onMultiTouch(t._pointA, t._pointB, n, 0, o, null), n = 0, o = null), t._currentActiveButton = -1, t.onButtonUp(c), e || c.preventDefault() } else { try { null == h || h.setPointerCapture(c.pointerId) } catch (e) { } if (null === t._pointA) t._pointA = { x: c.clientX, y: c.clientY, pointerId: c.pointerId, type: c.pointerType }; else { if (null !== t._pointB) return; t._pointB = { x: c.clientX, y: c.clientY, pointerId: c.pointerId, type: c.pointerType } } -1 !== t._currentActiveButton || u || (t._currentActiveButton = c.button), t.onButtonDown(c), e || (c.preventDefault(), r && r.focus()) } } } }, this._observer = this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput, Ji.POINTERDOWN | Ji.POINTERUP | Ji.POINTERMOVE | Ji.POINTERDOUBLETAP), this._onLostFocus = function () { t._pointA = t._pointB = null, n = 0, o = null, t.onLostFocus() }, this._contextMenuBind = this.onContextMenu.bind(this), r && r.addEventListener("contextmenu", this._contextMenuBind, !1); var a = this.camera.getScene().getEngine().getHostWindow(); a && xi.RegisterTopRootEvents(a, [{ name: "blur", handler: this._onLostFocus }]) }, e.prototype.detachControl = function () { if (this._onLostFocus) { var e = this.camera.getScene().getEngine().getHostWindow(); e && xi.UnregisterTopRootEvents(e, [{ name: "blur", handler: this._onLostFocus }]) } if (this._observer) { if (this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer), this._observer = null, this._contextMenuBind) { var t = this.camera.getScene().getEngine().getInputElement(); t && t.removeEventListener("contextmenu", this._contextMenuBind) } this._onLostFocus = null } this._altKey = !1, this._ctrlKey = !1, this._metaKey = !1, this._shiftKey = !1, this._buttonsPressed = 0, this._currentActiveButton = -1 }, e.prototype.getClassName = function () { return "BaseCameraPointersInput" }, e.prototype.getSimpleName = function () { return "pointers" }, e.prototype.onDoubleTap = function (e) { }, e.prototype.onTouch = function (e, t, i) { }, e.prototype.onMultiTouch = function (e, t, i, r, n, o) { }, e.prototype.onContextMenu = function (e) { e.preventDefault() }, e.prototype.onButtonDown = function (e) { }, e.prototype.onButtonUp = function (e) { }, e.prototype.onLostFocus = function () { }, X([xe()], e.prototype, "buttons", void 0), e }(), Ps = {}, Is = function () { function e(e) { this.attachedToElement = !1, this.attached = {}, this.camera = e, this.checkInputs = function () { } } return e.prototype.add = function (e) { var t = e.getSimpleName(); this.attached[t] ? $.Warn("camera input of type " + t + " already exists on camera") : (this.attached[t] = e, e.camera = this.camera, e.checkInputs && (this.checkInputs = this._addCheckInputs(e.checkInputs.bind(e))), this.attachedToElement && e.attachControl(this.noPreventDefault)) }, e.prototype.remove = function (e) { for (var t in this.attached) { var i = this.attached[t]; if (i === e) return i.detachControl(), i.camera = null, delete this.attached[t], void this.rebuildInputCheck() } }, e.prototype.removeByType = function (e) { for (var t in this.attached) { var i = this.attached[t]; i.getClassName() === e && (i.detachControl(), i.camera = null, delete this.attached[t], this.rebuildInputCheck()) } }, e.prototype._addCheckInputs = function (e) { var t = this.checkInputs; return function () { t(), e() } }, e.prototype.attachInput = function (e) { this.attachedToElement && e.attachControl(this.noPreventDefault) }, e.prototype.attachElement = function (e) { if (void 0 === e && (e = !1), !this.attachedToElement) for (var t in e = !ln.ForceAttachControlToAlwaysPreventDefault && e, this.attachedToElement = !0, this.noPreventDefault = e, this.attached) this.attached[t].attachControl(e) }, e.prototype.detachElement = function (e) { for (var t in void 0 === e && (e = !1), this.attached) this.attached[t].detachControl(), e && (this.attached[t].camera = null); this.attachedToElement = !1 }, e.prototype.rebuildInputCheck = function () { for (var e in this.checkInputs = function () { }, this.attached) { var t = this.attached[e]; t.checkInputs && (this.checkInputs = this._addCheckInputs(t.checkInputs.bind(t))) } }, e.prototype.clear = function () { this.attachedToElement && this.detachElement(!0), this.attached = {}, this.attachedToElement = !1, this.checkInputs = function () { } }, e.prototype.serialize = function (e) { var t = {}; for (var i in this.attached) { var r = this.attached[i], n = Ue.Serialize(r); t[r.getClassName()] = n } e.inputsmgr = t }, e.prototype.parse = function (e) { var t = e.inputsmgr; if (t) { this.clear(); var i = function (e) { var i = Ps[e]; if (i) { var n = t[e], o = Ue.Parse((function () { return new i }), n, null); r.add(o) } }, r = this; for (var n in t) i(n) } else { var o = function (t) { var i = Ps[a.attached[t].getClassName()]; if (i) { var r = Ue.Parse((function () { return new i }), e, null); a.remove(a.attached[t]), a.add(r) } }, a = this; for (var n in this.attached) o(n) } }, e }(), Ms = function (e, t) { this.x = e, this.y = t }, Os = function () { function e(t, i, r, n, o, a, s) { void 0 === n && (n = 0), void 0 === o && (o = 1), void 0 === a && (a = 2), void 0 === s && (s = 3), this.id = t, this.index = i, this.browserGamepad = r, this._leftStick = { x: 0, y: 0 }, this._rightStick = { x: 0, y: 0 }, this._isConnected = !0, this._invertLeftStickY = !1, this.type = e.GAMEPAD, this._leftStickAxisX = n, this._leftStickAxisY = o, this._rightStickAxisX = a, this._rightStickAxisY = s, this.browserGamepad.axes.length >= 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 }(), Ds = 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 = Os.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 < this._buttons.length; t++)this._buttons[t] = this._setButtonValue(this.browserGamepad.buttons[t].value, this._buttons[t], t) }, t.prototype.dispose = function () { e.prototype.dispose.call(this), this.onButtonDownObservable.clear(), this.onButtonUpObservable.clear() }, t }(Os), Ns = function () { function e() { this.gamepadRotationSensibility = 80, this.gamepadMoveSensibility = 40, this._yAxisScale = 1 } 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 !== Os.POSE_ENABLED && (e.gamepad && t.type !== Os.XBOX || (e.gamepad = t)) })), this._onGamepadDisconnectedObserver = t.onGamepadDisconnectedObservable.add((function (t) { e.gamepad === t && (e.gamepad = null) })), this.gamepad = t.getGamepadByType(Os.XBOX) }, 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) { var e = this.camera, t = this.gamepad.rightStick; if (t) { if (0 != t.x) { var i = t.x / this.gamepadRotationSensibility; 0 != i && Math.abs(i) > .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([xe()], e.prototype, "gamepadRotationSensibility", void 0), X([xe()], e.prototype, "gamepadMoveSensibility", void 0), e }(); Ps.ArcRotateCameraGamepadInput = Ns; var Fs = 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 = xi.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 === ir.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; t < this._keys.length; t++) { var i = this._keys[t]; -1 !== this.keysLeft.indexOf(i) ? this._ctrlPressed && this.camera._useCtrlForPanning ? e.inertialPanningX -= 1 / this.panningSensibility : e.inertialAlphaOffset -= this.angularSpeed : -1 !== this.keysUp.indexOf(i) ? this._ctrlPressed && this.camera._useCtrlForPanning ? e.inertialPanningY += 1 / this.panningSensibility : this._altPressed && this.useAltToZoom ? e.inertialRadiusOffset += 1 / this.zoomingSensibility : e.inertialBetaOffset -= this.angularSpeed : -1 !== this.keysRight.indexOf(i) ? this._ctrlPressed && this.camera._useCtrlForPanning ? e.inertialPanningX += 1 / this.panningSensibility : e.inertialAlphaOffset += this.angularSpeed : -1 !== this.keysDown.indexOf(i) ? this._ctrlPressed && this.camera._useCtrlForPanning ? e.inertialPanningY -= 1 / this.panningSensibility : this._altPressed && this.useAltToZoom ? e.inertialRadiusOffset -= 1 / this.zoomingSensibility : e.inertialBetaOffset += this.angularSpeed : -1 !== this.keysReset.indexOf(i) && e.useInputToRestoreState && e.restoreState() } }, e.prototype.getClassName = function () { return "ArcRotateCameraKeyboardMoveInput" }, e.prototype.getSimpleName = function () { return "keyboard" }, X([xe()], e.prototype, "keysUp", void 0), X([xe()], e.prototype, "keysDown", void 0), X([xe()], e.prototype, "keysLeft", void 0), X([xe()], e.prototype, "keysRight", void 0), X([xe()], e.prototype, "keysReset", void 0), X([xe()], e.prototype, "panningSensibility", void 0), X([xe()], e.prototype, "zoomingSensibility", void 0), X([xe()], e.prototype, "useAltToZoom", void 0), X([xe()], e.prototype, "angularSpeed", void 0), e }(); Ps.ArcRotateCameraKeyboardMoveInput = Fs; var Ls = function () { function e() { this.wheelPrecision = 3, this.zoomToMouseLocation = !1, this.wheelDeltaPercentage = 0, this.customComputeDeltaFromMouseWheel = null, this._inertialPanning = R.Zero() } return e.prototype._computeDeltaFromMouseWheelLegacyEvent = function (e, t) { var i = .01 * e * this.wheelDeltaPercentage * t; return e > 0 ? i / (1 + this.wheelDeltaPercentage) : i * (1 + this.wheelDeltaPercentage) }, e.prototype.attachControl = function (e) { var t = this; e = xi.BackCompatCameraNoPreventDefault(arguments), this._wheel = function (i) { if (i.type === Ji.POINTERWHEEL) { var r = i.event, n = 0, o = r.deltaMode === ar.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, Ji.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 = gr.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); r.origin.x -= t.targetScreenOffset.x, r.origin.y -= t.targetScreenOffset.y; 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) / n < o && (e = (r.radius - o) * n - r.inertialRadiusOffset) } if (r.upperRadiusLimit) { var a = null !== (i = r.upperRadiusLimit) && void 0 !== i ? i : 0; r.radius - (r.inertialRadiusOffset + e) / n > a && (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([xe()], e.prototype, "wheelPrecision", void 0), X([xe()], e.prototype, "zoomToMouseLocation", void 0), X([xe()], e.prototype, "wheelDeltaPercentage", void 0), e }(); Ps.ArcRotateCameraMouseWheelInput = Ls; var ws = 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 () { this._twoFingerActivityCount = 0, this._isPinching = !1 }, t.prototype.onLostFocus = function () { this._isPanClick = !1, this._twoFingerActivityCount = 0, this._isPinching = !1 }, t.MinimumRadiusForPinch = .001, X([xe()], t.prototype, "buttons", void 0), X([xe()], t.prototype, "angularSensibilityX", void 0), X([xe()], t.prototype, "angularSensibilityY", void 0), X([xe()], t.prototype, "pinchPrecision", void 0), X([xe()], t.prototype, "pinchDeltaPercentage", void 0), X([xe()], t.prototype, "useNaturalPinchZoom", void 0), X([xe()], t.prototype, "pinchZoom", void 0), X([xe()], t.prototype, "panningSensibility", void 0), X([xe()], t.prototype, "multiTouchPanning", void 0), X([xe()], t.prototype, "multiTouchPanAndZoom", void 0), t }(Cs); Ps.ArcRotateCameraPointersInput = ws; var Bs = function (e) { function t(t) { return e.call(this, t) || this } return W(t, e), t.prototype.addMouseWheel = function () { return this.add(new Ls), this }, t.prototype.addPointers = function () { return this.add(new ws), this }, t.prototype.addKeyboard = function () { return this.add(new Fs), this }, t }(Is); Bs.prototype.addVRDeviceOrientation = function () { return this.add(new Us), this }; var Us = function () { function e() { this.alphaCorrection = 1, this.gammaCorrection = 1, this._alpha = 0, this._gamma = 0, this._dirty = !1, this._deviceOrientationHandler = this._onOrientationEvent.bind(this) } return e.prototype.attachControl = function (e) { var t = this; e = xi.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) : xi.Warn("Permission not granted.") })).catch((function (e) { xi.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 }(); Ps.ArcRotateCameraVRDeviceOrientationInput = Us; var Vs = 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 = xi.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 === ir.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 < this._keys.length; t++) { var i = this._keys[t], r = e._computeLocalCameraSpeed(); -1 !== this.keysForward.indexOf(i) ? e._localDirection.copyFromFloats(0, 0, r) : -1 !== this.keysBackward.indexOf(i) ? e._localDirection.copyFromFloats(0, 0, -r) : -1 !== this.keysUp.indexOf(i) ? e._localDirection.copyFromFloats(0, r, 0) : -1 !== this.keysDown.indexOf(i) ? e._localDirection.copyFromFloats(0, -r, 0) : -1 !== this.keysRight.indexOf(i) ? e._localDirection.copyFromFloats(r, 0, 0) : -1 !== this.keysLeft.indexOf(i) && e._localDirection.copyFromFloats(-r, 0, 0), e.getScene().useRightHandedSystem && (e._localDirection.z *= -1), e.getViewMatrix().invertToRef(e._cameraTransformMatrix), R.TransformNormalToRef(e._localDirection, e._cameraTransformMatrix, e._transformedDirection), e.cameraDirection.addInPlace(e._transformedDirection) } }, X([xe()], e.prototype, "keysForward", void 0), X([xe()], e.prototype, "keysBackward", void 0), X([xe()], e.prototype, "keysUp", void 0), X([xe()], e.prototype, "keysDown", void 0), X([xe()], e.prototype, "keysRight", void 0), X([xe()], e.prototype, "keysLeft", void 0), e }(); Ps.FlyCameraKeyboardInput = Vs; var ks = function () { function e() { this.buttons = [0, 1, 2], this.buttonsYaw = [-1, 0, 1], this.buttonsPitch = [-1, 0, 1], this.buttonsRoll = [2], this.activeButton = -1, this.angularSensibility = 1e3, this._previousPosition = null } return e.prototype.attachControl = function (e) { var t = this; e = xi.BackCompatCameraNoPreventDefault(arguments), this._noPreventDefault = e, this._observer = this.camera.getScene()._inputManager._addCameraPointerObserver((function (e) { t._pointerInput(e) }), Ji.POINTERDOWN | Ji.POINTERUP | Ji.POINTERMOVE), this._rollObserver = this.camera.getScene().onBeforeRenderObservable.add((function () { t.camera.rollCorrect && t.camera.restoreRoll(t.camera.rollCorrect) })) }, e.prototype.detachControl = function () { this._observer && (this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer), this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver), this._observer = null, this._rollObserver = null, this._previousPosition = null, this._noPreventDefault = void 0) }, e.prototype.getClassName = function () { return "FlyCameraMouseInput" }, e.prototype.getSimpleName = function () { return "mouse" }, e.prototype._pointerInput = function (e) { var t = e.event, i = this.camera.getEngine(); if (!i.isInVRExclusivePointerMode && (this.touchEnabled || "touch" !== t.pointerType) && (e.type === Ji.POINTERMOVE || -1 !== this.buttons.indexOf(t.button))) { var r = t.target; if (e.type === Ji.POINTERDOWN) { try { null == r || r.setPointerCapture(t.pointerId) } catch (t) { } this._previousPosition = { x: t.clientX, y: t.clientY }, this.activeButton = t.button, this._noPreventDefault || (t.preventDefault(), this._element.focus()), i.isPointerLock && this._onMouseMove(e.event) } else if (e.type === Ji.POINTERUP) { try { null == r || r.releasePointerCapture(t.pointerId) } catch (t) { } this.activeButton = -1, this._previousPosition = null, this._noPreventDefault || t.preventDefault() } else if (e.type === Ji.POINTERMOVE) { if (!this._previousPosition) return void (i.isPointerLock && this._onMouseMove(e.event)); var n = t.clientX - this._previousPosition.x, o = t.clientY - this._previousPosition.y; this._rotateCamera(n, o), this._previousPosition = { x: t.clientX, y: t.clientY }, this._noPreventDefault || t.preventDefault() } } }, e.prototype._onMouseMove = function (e) { var t = this.camera.getEngine(); if (t.isPointerLock && !t.isInVRExclusivePointerMode) { var i = e.movementX, r = e.movementY; this._rotateCamera(i, r), this._previousPosition = null, this._noPreventDefault || e.preventDefault() } }, e.prototype._rotateCamera = function (e, t) { var i = this, r = this.camera; this.camera.getScene().useRightHandedSystem && (e *= -1), r.parent && r.parent._getWorldMatrixDeterminant() < 0 && (e *= -1); var n, o = e / this.angularSensibility, a = t / this.angularSensibility, s = P.RotationYawPitchRoll(r.rotation.y, r.rotation.x, r.rotation.z); if (this.buttonsPitch.some((function (e) { return e === i.activeButton })) && (n = P.RotationAxis(Ar.X, a), s.multiplyInPlace(n)), this.buttonsYaw.some((function (e) { return e === i.activeButton }))) { n = P.RotationAxis(Ar.Y, o), s.multiplyInPlace(n); var l = r.bankedTurnLimit + r._trackRoll; if (r.bankedTurn && -l < r.rotation.z && r.rotation.z < l) { var c = r.bankedTurnMultiplier * -o; n = P.RotationAxis(Ar.Z, c), s.multiplyInPlace(n) } } this.buttonsRoll.some((function (e) { return e === i.activeButton })) && (n = P.RotationAxis(Ar.Z, -o), r._trackRoll -= o, s.multiplyInPlace(n)), s.toEulerAnglesToRef(r.rotation) }, X([xe()], e.prototype, "buttons", void 0), X([xe()], e.prototype, "angularSensibility", void 0), e }(); Ps.FlyCameraMouseInput = ks; var Gs = function () { function e() { this.keysHeightOffsetIncr = [38], this.keysHeightOffsetDecr = [40], this.keysHeightOffsetModifierAlt = !1, this.keysHeightOffsetModifierCtrl = !1, this.keysHeightOffsetModifierShift = !1, this.keysRotationOffsetIncr = [37], this.keysRotationOffsetDecr = [39], this.keysRotationOffsetModifierAlt = !1, this.keysRotationOffsetModifierCtrl = !1, this.keysRotationOffsetModifierShift = !1, this.keysRadiusIncr = [40], this.keysRadiusDecr = [38], this.keysRadiusModifierAlt = !0, this.keysRadiusModifierCtrl = !1, this.keysRadiusModifierShift = !1, this.heightSensibility = 1, this.rotationSensibility = 1, this.radiusSensibility = 1, this._keys = new Array } return e.prototype.attachControl = function (e) { var t = this; e = xi.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 === ir.KEYDOWN ? (t._ctrlPressed = n.ctrlKey, t._altPressed = n.altKey, t._shiftPressed = n.shiftKey, (-1 !== t.keysHeightOffsetIncr.indexOf(n.keyCode) || -1 !== t.keysHeightOffsetDecr.indexOf(n.keyCode) || -1 !== t.keysRotationOffsetIncr.indexOf(n.keyCode) || -1 !== t.keysRotationOffsetDecr.indexOf(n.keyCode) || -1 !== t.keysRadiusIncr.indexOf(n.keyCode) || -1 !== t.keysRadiusDecr.indexOf(n.keyCode)) && (-1 === (r = t._keys.indexOf(n.keyCode)) && t._keys.push(n.keyCode), n.preventDefault && (e || n.preventDefault()))) : -1 === t.keysHeightOffsetIncr.indexOf(n.keyCode) && -1 === t.keysHeightOffsetDecr.indexOf(n.keyCode) && -1 === t.keysRotationOffsetIncr.indexOf(n.keyCode) && -1 === t.keysRotationOffsetDecr.indexOf(n.keyCode) && -1 === t.keysRadiusIncr.indexOf(n.keyCode) && -1 === t.keysRadiusDecr.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 () { 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([xe()], e.prototype, "keysHeightOffsetIncr", void 0), X([xe()], e.prototype, "keysHeightOffsetDecr", void 0), X([xe()], e.prototype, "keysHeightOffsetModifierAlt", void 0), X([xe()], e.prototype, "keysHeightOffsetModifierCtrl", void 0), X([xe()], e.prototype, "keysHeightOffsetModifierShift", void 0), X([xe()], e.prototype, "keysRotationOffsetIncr", void 0), X([xe()], e.prototype, "keysRotationOffsetDecr", void 0), X([xe()], e.prototype, "keysRotationOffsetModifierAlt", void 0), X([xe()], e.prototype, "keysRotationOffsetModifierCtrl", void 0), X([xe()], e.prototype, "keysRotationOffsetModifierShift", void 0), X([xe()], e.prototype, "keysRadiusIncr", void 0), X([xe()], e.prototype, "keysRadiusDecr", void 0), X([xe()], e.prototype, "keysRadiusModifierAlt", void 0), X([xe()], e.prototype, "keysRadiusModifierCtrl", void 0), X([xe()], e.prototype, "keysRadiusModifierShift", void 0), X([xe()], e.prototype, "heightSensibility", void 0), X([xe()], e.prototype, "rotationSensibility", void 0), X([xe()], e.prototype, "radiusSensibility", void 0), e }(); Ps.FollowCameraKeyboardMoveInput = Gs; var zs = 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 = xi.BackCompatCameraNoPreventDefault(arguments), this._wheel = function (i) { if (i.type === Ji.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, Ji.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([xe()], e.prototype, "axisControlRadius", void 0), X([xe()], e.prototype, "axisControlHeight", void 0), X([xe()], e.prototype, "axisControlRotation", void 0), X([xe()], e.prototype, "wheelPrecision", void 0), X([xe()], e.prototype, "wheelDeltaPercentage", void 0), e }(); Ps.FollowCameraMouseWheelInput = zs; var Ws = 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([xe()], t.prototype, "angularSensibilityX", void 0), X([xe()], t.prototype, "angularSensibilityY", void 0), X([xe()], t.prototype, "pinchPrecision", void 0), X([xe()], t.prototype, "pinchDeltaPercentage", void 0), X([xe()], t.prototype, "axisXControlRadius", void 0), X([xe()], t.prototype, "axisXControlHeight", void 0), X([xe()], t.prototype, "axisXControlRotation", void 0), X([xe()], t.prototype, "axisYControlRadius", void 0), X([xe()], t.prototype, "axisYControlHeight", void 0), X([xe()], t.prototype, "axisYControlRotation", void 0), X([xe()], t.prototype, "axisPinchControlRadius", void 0), X([xe()], t.prototype, "axisPinchControlHeight", void 0), X([xe()], t.prototype, "axisPinchControlRotation", void 0), t }(Cs); Ps.FollowCameraPointersInput = Ws; var Hs = 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 = xi.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 === ir.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; t < this._keys.length; t++) { var i = this._keys[t], r = e._computeLocalCameraSpeed(); -1 !== this.keysLeft.indexOf(i) ? e._localDirection.copyFromFloats(-r, 0, 0) : -1 !== this.keysUp.indexOf(i) ? e._localDirection.copyFromFloats(0, 0, r) : -1 !== this.keysRight.indexOf(i) ? e._localDirection.copyFromFloats(r, 0, 0) : -1 !== this.keysDown.indexOf(i) ? e._localDirection.copyFromFloats(0, 0, -r) : -1 !== this.keysUpward.indexOf(i) ? e._localDirection.copyFromFloats(0, r, 0) : -1 !== this.keysDownward.indexOf(i) ? e._localDirection.copyFromFloats(0, -r, 0) : -1 !== this.keysRotateLeft.indexOf(i) ? (e._localDirection.copyFromFloats(0, 0, 0), e.cameraRotation.y -= this._getLocalRotation()) : -1 !== this.keysRotateRight.indexOf(i) ? (e._localDirection.copyFromFloats(0, 0, 0), e.cameraRotation.y += this._getLocalRotation()) : -1 !== this.keysRotateUp.indexOf(i) ? (e._localDirection.copyFromFloats(0, 0, 0), e.cameraRotation.x -= this._getLocalRotation()) : -1 !== this.keysRotateDown.indexOf(i) && (e._localDirection.copyFromFloats(0, 0, 0), e.cameraRotation.x += this._getLocalRotation()), e.getScene().useRightHandedSystem && (e._localDirection.z *= -1), e.getViewMatrix().invertToRef(e._cameraTransformMatrix), R.TransformNormalToRef(e._localDirection, e._cameraTransformMatrix, e._transformedDirection), e.cameraDirection.addInPlace(e._transformedDirection) } }, e.prototype.getClassName = function () { return "FreeCameraKeyboardMoveInput" }, e.prototype._onLostFocus = function () { this._keys.length = 0 }, e.prototype.getSimpleName = function () { return "keyboard" }, e.prototype._getLocalRotation = function () { var e = this.rotationSpeed * this._engine.getDeltaTime() / 1e3; return this.camera.getScene().useRightHandedSystem && (e *= -1), this.camera.parent && this.camera.parent._getWorldMatrixDeterminant() < 0 && (e *= -1), e }, X([xe()], e.prototype, "keysUp", void 0), X([xe()], e.prototype, "keysUpward", void 0), X([xe()], e.prototype, "keysDown", void 0), X([xe()], e.prototype, "keysDownward", void 0), X([xe()], e.prototype, "keysLeft", void 0), X([xe()], e.prototype, "keysRight", void 0), X([xe()], e.prototype, "rotationSpeed", void 0), X([xe()], e.prototype, "keysRotateLeft", void 0), X([xe()], e.prototype, "keysRotateRight", void 0), X([xe()], e.prototype, "keysRotateUp", void 0), X([xe()], e.prototype, "keysRotateDown", void 0), e }(); Ps.FreeCameraKeyboardMoveInput = Hs; var Xs, js = function () { function e(e) { void 0 === e && (e = !0), this.touchEnabled = e, this.buttons = [0, 1, 2], this.angularSensibility = 2e3, this._previousPosition = null, this.onPointerMovedObservable = new u, this._allowCameraRotation = !0, this._currentActiveButton = -1, this._activePointerId = -1 } return e.prototype.attachControl = function (e) { var t = this; e = xi.BackCompatCameraNoPreventDefault(arguments); var i = this.camera.getEngine(), r = i.getInputElement(); this._pointerInput || (this._pointerInput = function (n) { var o = n.event, a = "touch" === o.pointerType; if (!i.isInVRExclusivePointerMode && (t.touchEnabled || !a) && (n.type === Ji.POINTERMOVE || -1 !== t.buttons.indexOf(o.button))) { var s = o.target; if (n.type === Ji.POINTERDOWN) { if (a && -1 !== t._activePointerId || !a && -1 !== t._currentActiveButton) return; t._activePointerId = o.pointerId; try { null == s || s.setPointerCapture(o.pointerId) } catch (e) { } -1 === t._currentActiveButton && (t._currentActiveButton = o.button), t._previousPosition = { x: o.clientX, y: o.clientY }, e || (o.preventDefault(), r && r.focus()), i.isPointerLock && t._onMouseMove && t._onMouseMove(n.event) } else if (n.type === Ji.POINTERUP) { if (a && t._activePointerId !== o.pointerId || !a && t._currentActiveButton !== o.button) return; try { null == s || s.releasePointerCapture(o.pointerId) } catch (e) { } t._currentActiveButton = -1, t._previousPosition = null, e || o.preventDefault(), t._activePointerId = -1 } else if (n.type === Ji.POINTERMOVE && (t._activePointerId === o.pointerId || !a)) if (i.isPointerLock && t._onMouseMove) t._onMouseMove(n.event); else if (t._previousPosition) { var l = o.clientX - t._previousPosition.x, c = o.clientY - t._previousPosition.y; t.camera.getScene().useRightHandedSystem && (l *= -1), t.camera.parent && t.camera.parent._getWorldMatrixDeterminant() < 0 && (l *= -1), t._allowCameraRotation && (t.camera.cameraRotation.y += l / t.angularSensibility, t.camera.cameraRotation.x += c / t.angularSensibility), t.onPointerMovedObservable.notifyObservers({ offsetX: l, offsetY: c }), t._previousPosition = { x: o.clientX, y: o.clientY }, e || o.preventDefault() } } }), this._onMouseMove = function (r) { if (i.isPointerLock && !i.isInVRExclusivePointerMode) { var n = r.movementX; t.camera.getScene().useRightHandedSystem && (n *= -1), t.camera.parent && t.camera.parent._getWorldMatrixDeterminant() < 0 && (n *= -1), t.camera.cameraRotation.y += n / t.angularSensibility; var o = r.movementY; t.camera.cameraRotation.x += o / t.angularSensibility, t._previousPosition = null, e || r.preventDefault() } }, this._observer = this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput, Ji.POINTERDOWN | Ji.POINTERUP | Ji.POINTERMOVE), r && (this._contextMenuBind = this.onContextMenu.bind(this), r.addEventListener("contextmenu", this._contextMenuBind, !1)) }, e.prototype.onContextMenu = function (e) { e.preventDefault() }, e.prototype.detachControl = function () { if (this._observer) { if (this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer), this._contextMenuBind) { var e = this.camera.getEngine().getInputElement(); e && e.removeEventListener("contextmenu", this._contextMenuBind) } this.onPointerMovedObservable && this.onPointerMovedObservable.clear(), this._observer = null, this._onMouseMove = null, this._previousPosition = null } this._activePointerId = -1, this._currentActiveButton = -1 }, e.prototype.getClassName = function () { return "FreeCameraMouseInput" }, e.prototype.getSimpleName = function () { return "mouse" }, X([xe()], e.prototype, "buttons", void 0), X([xe()], e.prototype, "angularSensibility", void 0), e }(); Ps.FreeCameraMouseInput = js, function (e) { e[e.MoveRelative = 0] = "MoveRelative", e[e.RotateRelative = 1] = "RotateRelative", e[e.MoveScene = 2] = "MoveScene" }(Xs || (Xs = {})); var Ys = function (e) { function t() { var t = null !== e && e.apply(this, arguments) || this; return t._moveRelative = R.Zero(), t._rotateRelative = R.Zero(), t._moveScene = R.Zero(), t._wheelXAction = Xs.MoveRelative, t._wheelXActionCoordinate = xr.X, t._wheelYAction = Xs.MoveRelative, t._wheelYActionCoordinate = xr.Z, t._wheelZAction = null, t._wheelZActionCoordinate = null, t } return W(t, e), t.prototype.getClassName = function () { return "FreeCameraMouseWheelInput" }, Object.defineProperty(t.prototype, "wheelXMoveRelative", { get: function () { return this._wheelXAction !== Xs.MoveRelative ? null : this._wheelXActionCoordinate }, set: function (e) { null === e && this._wheelXAction !== Xs.MoveRelative || (this._wheelXAction = Xs.MoveRelative, this._wheelXActionCoordinate = e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelYMoveRelative", { get: function () { return this._wheelYAction !== Xs.MoveRelative ? null : this._wheelYActionCoordinate }, set: function (e) { null === e && this._wheelYAction !== Xs.MoveRelative || (this._wheelYAction = Xs.MoveRelative, this._wheelYActionCoordinate = e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelZMoveRelative", { get: function () { return this._wheelZAction !== Xs.MoveRelative ? null : this._wheelZActionCoordinate }, set: function (e) { null === e && this._wheelZAction !== Xs.MoveRelative || (this._wheelZAction = Xs.MoveRelative, this._wheelZActionCoordinate = e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelXRotateRelative", { get: function () { return this._wheelXAction !== Xs.RotateRelative ? null : this._wheelXActionCoordinate }, set: function (e) { null === e && this._wheelXAction !== Xs.RotateRelative || (this._wheelXAction = Xs.RotateRelative, this._wheelXActionCoordinate = e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelYRotateRelative", { get: function () { return this._wheelYAction !== Xs.RotateRelative ? null : this._wheelYActionCoordinate }, set: function (e) { null === e && this._wheelYAction !== Xs.RotateRelative || (this._wheelYAction = Xs.RotateRelative, this._wheelYActionCoordinate = e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelZRotateRelative", { get: function () { return this._wheelZAction !== Xs.RotateRelative ? null : this._wheelZActionCoordinate }, set: function (e) { null === e && this._wheelZAction !== Xs.RotateRelative || (this._wheelZAction = Xs.RotateRelative, this._wheelZActionCoordinate = e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelXMoveScene", { get: function () { return this._wheelXAction !== Xs.MoveScene ? null : this._wheelXActionCoordinate }, set: function (e) { null === e && this._wheelXAction !== Xs.MoveScene || (this._wheelXAction = Xs.MoveScene, this._wheelXActionCoordinate = e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelYMoveScene", { get: function () { return this._wheelYAction !== Xs.MoveScene ? null : this._wheelYActionCoordinate }, set: function (e) { null === e && this._wheelYAction !== Xs.MoveScene || (this._wheelYAction = Xs.MoveScene, this._wheelYActionCoordinate = e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelZMoveScene", { get: function () { return this._wheelZAction !== Xs.MoveScene ? null : this._wheelZActionCoordinate }, set: function (e) { null === e && this._wheelZAction !== Xs.MoveScene || (this._wheelZAction = Xs.MoveScene, this._wheelZActionCoordinate = e) }, enumerable: !1, configurable: !0 }), t.prototype.checkInputs = function () { if (0 !== this._wheelDeltaX || 0 !== this._wheelDeltaY || 0 != this._wheelDeltaZ) { this._moveRelative.setAll(0), this._rotateRelative.setAll(0), this._moveScene.setAll(0), this._updateCamera(), this.camera.getScene().useRightHandedSystem && (this._moveRelative.z *= -1); var t = I.Zero(); this.camera.getViewMatrix().invertToRef(t); var i = R.Zero(); R.TransformNormalToRef(this._moveRelative, t, i), this.camera.cameraRotation.x += this._rotateRelative.x / 200, this.camera.cameraRotation.y += this._rotateRelative.y / 200, this.camera.cameraDirection.addInPlace(i), this.camera.cameraDirection.addInPlace(this._moveScene), e.prototype.checkInputs.call(this) } }, t.prototype._updateCamera = function () { this._updateCameraProperty(this._wheelDeltaX, this._wheelXAction, this._wheelXActionCoordinate), this._updateCameraProperty(this._wheelDeltaY, this._wheelYAction, this._wheelYActionCoordinate), this._updateCameraProperty(this._wheelDeltaZ, this._wheelZAction, this._wheelZActionCoordinate) }, t.prototype._updateCameraProperty = function (e, t, i) { if (0 !== e && null !== t && null !== i) { var r = null; switch (t) { case Xs.MoveRelative: r = this._moveRelative; break; case Xs.RotateRelative: r = this._rotateRelative; break; case Xs.MoveScene: r = this._moveScene }switch (i) { case xr.X: r.set(e, 0, 0); break; case xr.Y: r.set(0, e, 0); break; case xr.Z: r.set(0, 0, e) } } }, X([xe()], t.prototype, "wheelXMoveRelative", null), X([xe()], t.prototype, "wheelYMoveRelative", null), X([xe()], t.prototype, "wheelZMoveRelative", null), X([xe()], t.prototype, "wheelXRotateRelative", null), X([xe()], t.prototype, "wheelYRotateRelative", null), X([xe()], t.prototype, "wheelZRotateRelative", null), X([xe()], t.prototype, "wheelXMoveScene", null), X([xe()], t.prototype, "wheelYMoveScene", null), X([xe()], t.prototype, "wheelZMoveScene", null), t }(Rs); Ps.FreeCameraMouseWheelInput = Ys; var Ks = function () { function e(e) { void 0 === e && (e = !1), this.allowMouse = e, this.touchAngularSensibility = 2e5, this.touchMoveSensibility = 250, this.singleFingerRotate = !1, this._offsetX = null, this._offsetY = null, this._pointerPressed = new Array, this._isSafari = xi.IsSafari() } return e.prototype.attachControl = function (e) { var t = this; e = xi.BackCompatCameraNoPreventDefault(arguments); var i = null; if (void 0 === this._pointerInput && (this._onLostFocus = function () { t._offsetX = null, t._offsetY = null }, this._pointerInput = function (r) { var n = r.event, o = "mouse" === n.pointerType || t._isSafari && void 0 === n.pointerType; if (t.allowMouse || !o) if (r.type === Ji.POINTERDOWN) { if (e || n.preventDefault(), t._pointerPressed.push(n.pointerId), 1 !== t._pointerPressed.length) return; i = { x: n.clientX, y: n.clientY } } else if (r.type === Ji.POINTERUP) { if (e || n.preventDefault(), -1 === (a = t._pointerPressed.indexOf(n.pointerId))) return; if (t._pointerPressed.splice(a, 1), 0 != a) return; i = null, t._offsetX = null, t._offsetY = null } else if (r.type === Ji.POINTERMOVE) { if (e || n.preventDefault(), !i) return; var a; if (0 != (a = t._pointerPressed.indexOf(n.pointerId))) return; t._offsetX = n.clientX - i.x, t._offsetY = -(n.clientY - i.y) } }), this._observer = this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput, Ji.POINTERDOWN | Ji.POINTERUP | Ji.POINTERMOVE), this._onLostFocus) { var r = this.camera.getEngine().getInputElement(); r && r.addEventListener("blur", this._onLostFocus) } }, e.prototype.detachControl = function () { if (this._pointerInput) { if (this._observer && (this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer), this._observer = null), this._onLostFocus) { var e = this.camera.getEngine().getInputElement(); e && e.removeEventListener("blur", this._onLostFocus), this._onLostFocus = null } this._pointerPressed.length = 0, this._offsetX = null, this._offsetY = null } }, e.prototype.checkInputs = function () { if (null !== this._offsetX && null !== this._offsetY && (0 !== this._offsetX || 0 !== this._offsetY)) { var e = this.camera; if (e.cameraRotation.y = this._offsetX / this.touchAngularSensibility, this.singleFingerRotate && 1 === this._pointerPressed.length || !this.singleFingerRotate && this._pointerPressed.length > 1) e.cameraRotation.x = -this._offsetY / this.touchAngularSensibility; else { var t = e._computeLocalCameraSpeed(), i = new R(0, 0, 0 !== this.touchMoveSensibility ? t * this._offsetY / this.touchMoveSensibility : 0); I.RotationYawPitchRollToRef(e.rotation.y, e.rotation.x, 0, e._cameraRotationMatrix), e.cameraDirection.addInPlace(R.TransformCoordinates(i, e._cameraRotationMatrix)) } } }, e.prototype.getClassName = function () { return "FreeCameraTouchInput" }, e.prototype.getSimpleName = function () { return "touch" }, X([xe()], e.prototype, "touchAngularSensibility", void 0), X([xe()], e.prototype, "touchMoveSensibility", void 0), e }(); Ps.FreeCameraTouchInput = Ks; var Qs = 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 Hs), 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 Ys, 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 Ks), this }, t.prototype.clear = function () { e.prototype.clear.call(this), this._mouseInput = null }, t }(Is); Qs.prototype.addDeviceOrientation = function (e) { return this._deviceOrientationInput || (this._deviceOrientationInput = new qs, e && (this._deviceOrientationInput.smoothFactor = e), this.add(this._deviceOrientationInput)), this }; var qs = 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 = -xi.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 ? xi.SmoothAngleChange(e._alpha, t.alpha, e.smoothFactor) : 0, e._beta = null !== t.beta ? xi.SmoothAngleChange(e._beta, t.beta, e.smoothFactor) : 0, e._gamma = null !== t.gamma ? xi.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) : xi.Warn("Permission not granted.") })).catch((function (e) { xi.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() : xi.Warn("Permission not granted.") })).catch((function (e) { xi.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(xi.ToRadians(this._alpha), xi.ToRadians(this._beta), -xi.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 }(); Ps.FreeCameraDeviceOrientationInput = qs; var Zs, Js = 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 !== Os.POSE_ENABLED && (e.gamepad && t.type !== Os.XBOX || (e.gamepad = t)) })), this._onGamepadDisconnectedObserver = t.onGamepadDisconnectedObservable.add((function (t) { e.gamepad === t && (e.gamepad = null) })), this.gamepad = t.getGamepadByType(Os.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([xe()], e.prototype, "gamepadAngularSensibility", void 0), X([xe()], e.prototype, "gamepadMoveSensibility", void 0), e }(); Ps.FreeCameraGamepadInput = Js, function (e) { e[e.X = 0] = "X", e[e.Y = 1] = "Y", e[e.Z = 2] = "Z" }(Zs || (Zs = {})); var $s = 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 = Zs.X, this._axisTargetedByUpAndDown = Zs.Y, this.reverseLeftRight = !1, this.reverseUpDown = !1, this._touches = new Ii, 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.clientX < e._HalfWidth : t.clientX > e._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 < e._AlwaysVisibleSticks && (this._leftJoystick ? this._joystickPointerPos.x = Math.min(e._HalfWidth, this._joystickPointerPos.x) : this._joystickPointerPos.x = Math.max(e._HalfWidth, this._joystickPointerPos.x)); var n = (this.reverseLeftRight ? -1 : 1) * this._deltaJoystickVector.x / this._inversedSensibility; switch (this._axisTargetedByLeftAndRight) { case Zs.X: this.deltaPosition.x = Math.min(1, Math.max(-1, n)); break; case Zs.Y: this.deltaPosition.y = Math.min(1, Math.max(-1, n)); break; case Zs.Z: this.deltaPosition.z = Math.min(1, Math.max(-1, n)) }var o = (this.reverseUpDown ? 1 : -1) * this._deltaJoystickVector.y / this._inversedSensibility; switch (this._axisTargetedByUpAndDown) { case Zs.X: this.deltaPosition.x = Math.min(1, Math.max(-1, o)); break; case Zs.Y: this.deltaPosition.y = Math.min(1, Math.max(-1, o)); break; case Zs.Z: this.deltaPosition.z = Math.min(1, Math.max(-1, o)) } } else { var a = this._touches.get(t.pointerId.toString()); a && (a.x = t.clientX, a.y = t.clientY) } }, e.prototype._onPointerUp = function (t) { if (this._joystickPointerId == t.pointerId) this._clearPreviousDraw(), this._joystickPointerId = -1, this.pressed = !1; else { var i = this._touches.get(t.pointerId.toString()); i && e._VJCanvasContext.clearRect(i.prevX - 44, i.prevY - 44, 88, 88) } this._deltaJoystickVector.x = 0, this._deltaJoystickVector.y = 0, this._touches.remove(t.pointerId.toString()) }, e.prototype.setJoystickColor = function (e) { this._joystickColor = e }, Object.defineProperty(e.prototype, "containerSize", { get: function () { return this._joystickContainerSize }, set: function (e) { this._joystickContainerSize = e, this._clearContainerSize = ~~(2.1 * this._joystickContainerSize), this._clearContainerSizeOffset = ~~(this._clearContainerSize / 2) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "puckSize", { get: function () { return this._joystickPuckSize }, set: function (e) { this._joystickPuckSize = e, this._clearPuckSize = ~~(2.1 * this._joystickPuckSize), this._clearPuckSizeOffset = ~~(this._clearPuckSize / 2) }, enumerable: !1, configurable: !0 }), e.prototype.clearPosition = function () { this.alwaysVisible = !1, this._joystickPosition = null }, Object.defineProperty(e.prototype, "alwaysVisible", { get: function () { return this._alwaysVisible }, set: function (t) { this._alwaysVisible !== t && (t && this._joystickPosition ? (e._AlwaysVisibleSticks++, this._alwaysVisible = !0) : (e._AlwaysVisibleSticks--, this._alwaysVisible = !1)) }, enumerable: !1, configurable: !0 }), e.prototype.setPosition = function (e, t) { this._joystickPointerStartPos && this._clearPreviousDraw(), this._joystickPosition = new A(e, t) }, e.prototype.setActionOnTouch = function (e) { this._action = e }, e.prototype.setAxisForLeftRight = function (e) { switch (e) { case Zs.X: case Zs.Y: case Zs.Z: this._axisTargetedByLeftAndRight = e; break; default: this._axisTargetedByLeftAndRight = Zs.X } }, e.prototype.setAxisForUpDown = function (e) { switch (e) { case Zs.X: case Zs.Y: case Zs.Z: this._axisTargetedByUpAndDown = e; break; default: this._axisTargetedByUpAndDown = Zs.Y } }, e.prototype._clearPreviousDraw = function () { var t = this._joystickPosition || this._joystickPointerStartPos; e._VJCanvasContext.clearRect(t.x - this._clearContainerSizeOffset, t.y - this._clearContainerSizeOffset, this._clearContainerSize, this._clearContainerSize), e._VJCanvasContext.clearRect(this._joystickPreviousPointerPos.x - this._clearPuckSizeOffset - 1, this._joystickPreviousPointerPos.y - this._clearPuckSizeOffset - 1, this._clearPuckSize + 2, this._clearPuckSize + 2) }, e.prototype.setContainerImage = function (e) { var t = this, i = new Image; i.src = e, i.onload = function () { return t._containerImage = i } }, e.prototype.setPuckImage = function (e) { var t = this, i = new Image; i.src = e, i.onload = function () { return t._puckImage = i } }, e.prototype._drawContainer = function () { var t = this._joystickPosition || this._joystickPointerStartPos; this._clearPreviousDraw(), this._containerImage ? e._VJCanvasContext.drawImage(this._containerImage, t.x - this.containerSize, t.y - this.containerSize, 2 * this.containerSize, 2 * this.containerSize) : (e._VJCanvasContext.beginPath(), e._VJCanvasContext.strokeStyle = this._joystickColor, e._VJCanvasContext.lineWidth = 2, e._VJCanvasContext.arc(t.x, t.y, this.containerSize, 0, 2 * Math.PI, !0), e._VJCanvasContext.stroke(), e._VJCanvasContext.closePath(), e._VJCanvasContext.beginPath(), e._VJCanvasContext.lineWidth = 6, e._VJCanvasContext.strokeStyle = this._joystickColor, e._VJCanvasContext.arc(t.x, t.y, this.puckSize, 0, 2 * Math.PI, !0), e._VJCanvasContext.stroke(), e._VJCanvasContext.closePath()) }, e.prototype._drawPuck = function () { this._puckImage ? e._VJCanvasContext.drawImage(this._puckImage, this._joystickPointerPos.x - this.puckSize, this._joystickPointerPos.y - this.puckSize, 2 * this.puckSize, 2 * this.puckSize) : (e._VJCanvasContext.beginPath(), e._VJCanvasContext.strokeStyle = this._joystickColor, e._VJCanvasContext.lineWidth = 2, e._VJCanvasContext.arc(this._joystickPointerPos.x, this._joystickPointerPos.y, this.puckSize, 0, 2 * Math.PI, !0), e._VJCanvasContext.stroke(), e._VJCanvasContext.closePath()) }, e.prototype._drawVirtualJoystick = function () { var t = this; this._released || (this.alwaysVisible && this._drawContainer(), this.pressed && this._touches.forEach((function (i, r) { r.pointerId === t._joystickPointerId ? (t.alwaysVisible || t._drawContainer(), t._drawPuck(), t._joystickPreviousPointerPos = t._joystickPointerPos.clone()) : (e._VJCanvasContext.clearRect(r.prevX - 44, r.prevY - 44, 88, 88), e._VJCanvasContext.beginPath(), e._VJCanvasContext.fillStyle = "white", e._VJCanvasContext.beginPath(), e._VJCanvasContext.strokeStyle = "red", e._VJCanvasContext.lineWidth = 6, e._VJCanvasContext.arc(r.x, r.y, 40, 0, 2 * Math.PI, !0), e._VJCanvasContext.stroke(), e._VJCanvasContext.closePath(), r.prevX = r.x, r.prevY = r.y) })), requestAnimationFrame((function () { t._drawVirtualJoystick() }))) }, e.prototype.releaseCanvas = function () { e.Canvas && (e.Canvas.removeEventListener("pointerdown", this._onPointerDownHandlerRef), e.Canvas.removeEventListener("pointermove", this._onPointerMoveHandlerRef), e.Canvas.removeEventListener("pointerup", this._onPointerUpHandlerRef), e.Canvas.removeEventListener("pointerout", this._onPointerUpHandlerRef), window.removeEventListener("resize", this._onResize), document.body.removeChild(e.Canvas), e.Canvas = null), this._released = !0 }, e._GlobalJoystickIndex = 0, e._AlwaysVisibleSticks = 0, e }(); Qs.prototype.addVirtualJoystick = function () { return this.add(new el), this }; var el = function () { function e() { } return e.prototype.getLeftJoystick = function () { return this._leftjoystick }, e.prototype.getRightJoystick = function () { return this._rightjoystick }, e.prototype.checkInputs = function () { if (this._leftjoystick) { var e = this.camera, t = 50 * e._computeLocalCameraSpeed(), i = I.RotationYawPitchRoll(e.rotation.y, e.rotation.x, 0), r = R.TransformCoordinates(new R(this._leftjoystick.deltaPosition.x * t, this._leftjoystick.deltaPosition.y * t, this._leftjoystick.deltaPosition.z * t), i); e.cameraDirection = e.cameraDirection.add(r), e.cameraRotation = e.cameraRotation.addVector3(this._rightjoystick.deltaPosition), this._leftjoystick.pressed || (this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(.9)), this._rightjoystick.pressed || (this._rightjoystick.deltaPosition = this._rightjoystick.deltaPosition.scale(.9)) } }, e.prototype.attachControl = function () { this._leftjoystick = new $s(!0), this._leftjoystick.setAxisForUpDown(Zs.Z), this._leftjoystick.setAxisForLeftRight(Zs.X), this._leftjoystick.setJoystickSensibility(.15), this._rightjoystick = new $s(!1), this._rightjoystick.setAxisForUpDown(Zs.X), this._rightjoystick.setAxisForLeftRight(Zs.Y), this._rightjoystick.reverseUpDown = !0, this._rightjoystick.setJoystickSensibility(.05), this._rightjoystick.setJoystickColor("yellow") }, e.prototype.detachControl = function () { this._leftjoystick.releaseCanvas(), this._rightjoystick.releaseCanvas() }, e.prototype.getClassName = function () { return "FreeCameraVirtualJoystickInput" }, e.prototype.getSimpleName = function () { return "virtualJoystick" }, e }(); Ps.FreeCameraVirtualJoystickInput = el; var tl = 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._tmpUpVector = R.Zero(), o._tmpTargetVector = R.Zero(), o.cameraDirection = new R(0, 0, 0), o.cameraRotation = new A(0, 0), o.ignoreParentScaling = !1, o.updateUpVectorFromRotation = !1, o._tmpQuaternion = new P, o.rotation = new R(0, 0, 0), o.speed = 2, o.noRotationConstraint = !1, o.invertRotation = !1, o.inverseRotationSpeed = .2, o.lockedTarget = null, o._currentTarget = R.Zero(), o._initialFocalDistance = 1, o._viewMatrix = I.Zero(), o._camMatrix = I.Zero(), o._cameraTransformMatrix = I.Zero(), o._cameraRotationMatrix = I.Zero(), o._referencePoint = new R(0, 0, 1), o._transformedReferencePoint = R.Zero(), o._deferredPositionUpdate = new R, o._deferredRotationQuaternionUpdate = new P, o._deferredRotationUpdate = new R, o._deferredUpdated = !1, o._deferOnly = !1, o._defaultUp = R.Up(), o._cachedRotationZ = 0, o._cachedQuaternionRotationZ = 0, o } return W(t, e), t.prototype.getFrontPosition = function (e) { this.getWorldMatrix(); var t = this.getTarget().subtract(this.position); return t.normalize(), t.scaleInPlace(e), this.globalPosition.add(t) }, t.prototype._getLockedTargetPosition = function () { if (!this.lockedTarget) return null; if (this.lockedTarget.absolutePosition) { var e = this.lockedTarget; e.computeWorldMatrix().getTranslationToRef(e.absolutePosition) } return this.lockedTarget.absolutePosition || this.lockedTarget }, t.prototype.storeState = function () { return this._storedPosition = this.position.clone(), this._storedRotation = this.rotation.clone(), this.rotationQuaternion && (this._storedRotationQuaternion = this.rotationQuaternion.clone()), e.prototype.storeState.call(this) }, t.prototype._restoreStateValues = function () { return !!e.prototype._restoreStateValues.call(this) && (this.position = this._storedPosition.clone(), this.rotation = this._storedRotation.clone(), this.rotationQuaternion && (this.rotationQuaternion = this._storedRotationQuaternion.clone()), this.cameraDirection.copyFromFloats(0, 0, 0), this.cameraRotation.copyFromFloats(0, 0), !0) }, t.prototype._initCache = function () { e.prototype._initCache.call(this), this._cache.lockedTarget = new R(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), this._cache.rotation = new R(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), this._cache.rotationQuaternion = new P(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE) }, t.prototype._updateCache = function (t) { t || e.prototype._updateCache.call(this); var i = this._getLockedTargetPosition(); i ? this._cache.lockedTarget ? this._cache.lockedTarget.copyFrom(i) : this._cache.lockedTarget = i.clone() : this._cache.lockedTarget = null, this._cache.rotation.copyFrom(this.rotation), this.rotationQuaternion && this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion) }, t.prototype._isSynchronizedViewMatrix = function () { if (!e.prototype._isSynchronizedViewMatrix.call(this)) return !1; var t = this._getLockedTargetPosition(); return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(t) : !t) && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation)) }, t.prototype._computeLocalCameraSpeed = function () { var e = this.getEngine(); return this.speed * Math.sqrt(e.getDeltaTime() / (100 * e.getFps())) }, t.prototype.setTarget = function (e) { this.upVector.normalize(), this._initialFocalDistance = e.subtract(this.position).length(), this.position.z === e.z && (this.position.z += _), this._referencePoint.normalize().scaleInPlace(this._initialFocalDistance), I.LookAtLHToRef(this.position, e, this._defaultUp, this._camMatrix), this._camMatrix.invert(), this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]); var t = e.subtract(this.position); t.x >= 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) < this.speed * _ && (this.cameraDirection.x = 0), Math.abs(this.cameraDirection.y) < this.speed * _ && (this.cameraDirection.y = 0), Math.abs(this.cameraDirection.z) < this.speed * _ && (this.cameraDirection.z = 0), this.cameraDirection.scaleInPlace(this.inertia)), r && (Math.abs(this.cameraRotation.x) < this.speed * _ && (this.cameraRotation.x = 0), Math.abs(this.cameraRotation.y) < this.speed * _ && (this.cameraRotation.y = 0), this.cameraRotation.scaleInPlace(this.inertia)), e.prototype._checkInputs.call(this) }, t.prototype._updateCameraRotationMatrix = function () { this.rotationQuaternion ? this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix) : I.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix) }, t.prototype._rotateUpVectorWithCameraRotationMatrix = function () { return R.TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector), this }, t.prototype._getViewMatrix = function () { return this.lockedTarget && this.setTarget(this._getLockedTargetPosition()), this._updateCameraRotationMatrix(), this.rotationQuaternion && this._cachedQuaternionRotationZ != this.rotationQuaternion.z ? (this._rotateUpVectorWithCameraRotationMatrix(), this._cachedQuaternionRotationZ = this.rotationQuaternion.z) : this._cachedRotationZ !== this.rotation.z && (this._rotateUpVectorWithCameraRotationMatrix(), this._cachedRotationZ = this.rotation.z), R.TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint), this.position.addToRef(this._transformedReferencePoint, this._currentTarget), this.updateUpVectorFromRotation && (this.rotationQuaternion ? Ar.Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector) : (P.FromEulerVectorToRef(this.rotation, this._tmpQuaternion), Ar.Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector))), this._computeViewMatrix(this.position, this._currentTarget, this.upVector), this._viewMatrix }, t.prototype._computeViewMatrix = function (e, t, i) { if (this.ignoreParentScaling) { if (this.parent) { var r = this.parent.getWorldMatrix(); R.TransformCoordinatesToRef(e, r, this._globalPosition), R.TransformCoordinatesToRef(t, r, this._tmpTargetVector), R.TransformNormalToRef(i, r, this._tmpUpVector), this._markSyncedWithParent() } else this._globalPosition.copyFrom(e), this._tmpTargetVector.copyFrom(t), this._tmpUpVector.copyFrom(i); this.getScene().useRightHandedSystem ? I.LookAtRHToRef(this._globalPosition, this._tmpTargetVector, this._tmpUpVector, this._viewMatrix) : I.LookAtLHToRef(this._globalPosition, this._tmpTargetVector, this._tmpUpVector, this._viewMatrix) } else this.getScene().useRightHandedSystem ? I.LookAtRHToRef(e, t, i, this._viewMatrix) : I.LookAtLHToRef(e, t, i, this._viewMatrix), this.parent ? (r = this.parent.getWorldMatrix(), this._viewMatrix.invert(), this._viewMatrix.multiplyToRef(r, this._viewMatrix), this._viewMatrix.getTranslationToRef(this._globalPosition), this._viewMatrix.invert(), this._markSyncedWithParent()) : this._globalPosition.copyFrom(e) }, t.prototype.createRigCamera = function (e, i) { if (this.cameraRigMode !== ln.RIG_MODE_NONE) { var r = new t(e, this.position.clone(), this.getScene()); return r.isRigCamera = !0, r.rigParent = this, this.cameraRigMode !== ln.RIG_MODE_VR && this.cameraRigMode !== ln.RIG_MODE_WEBVR || (this.rotationQuaternion || (this.rotationQuaternion = new P), r._cameraRigParams = {}, r.rotationQuaternion = new P), r.mode = this.mode, r.orthoLeft = this.orthoLeft, r.orthoRight = this.orthoRight, r.orthoTop = this.orthoTop, r.orthoBottom = this.orthoBottom, r } return null }, t.prototype._updateRigCameras = function () { var t = this._rigCameras[0], i = this._rigCameras[1]; switch (this.computeWorldMatrix(), this.cameraRigMode) { case ln.RIG_MODE_STEREOSCOPIC_ANAGLYPH: case ln.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: case ln.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: case ln.RIG_MODE_STEREOSCOPIC_OVERUNDER: case ln.RIG_MODE_STEREOSCOPIC_INTERLACED: var r = this.cameraRigMode === ln.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED ? 1 : -1, n = this.cameraRigMode === ln.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED ? -1 : 1; this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * r, t), this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * n, i); break; case ln.RIG_MODE_VR: t.rotationQuaternion ? (t.rotationQuaternion.copyFrom(this.rotationQuaternion), i.rotationQuaternion.copyFrom(this.rotationQuaternion)) : (t.rotation.copyFrom(this.rotation), i.rotation.copyFrom(this.rotation)), t.position.copyFrom(this.position), i.position.copyFrom(this.position) }e.prototype._updateRigCameras.call(this) }, t.prototype._getRigCamPositionAndTarget = function (e, i) { this.getTarget().subtractToRef(this.position, t._TargetFocalPoint), t._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance); var r = t._TargetFocalPoint.addInPlace(this.position); I.TranslationToRef(-r.x, -r.y, -r.z, t._TargetTransformMatrix), t._TargetTransformMatrix.multiplyToRef(I.RotationAxis(i.upVector, e), t._RigCamTransformMatrix), I.TranslationToRef(r.x, r.y, r.z, t._TargetTransformMatrix), t._RigCamTransformMatrix.multiplyToRef(t._TargetTransformMatrix, t._RigCamTransformMatrix), R.TransformCoordinatesToRef(this.position, t._RigCamTransformMatrix, i.position), i.setTarget(r) }, t.prototype.getClassName = function () { return "TargetCamera" }, t._RigCamTransformMatrix = new I, t._TargetTransformMatrix = new I, t._TargetFocalPoint = new R, X([Ie()], t.prototype, "rotation", void 0), X([xe()], t.prototype, "speed", void 0), X([Me("lockedTargetId")], t.prototype, "lockedTarget", void 0), t }(ln), il = 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(.5, 1, .5), o.ellipsoidOffset = new R(0, 0, 0), o.checkCollisions = !1, o.applyGravity = !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) { void 0 === i && (i = null), o._newPosition.copyFrom(t), o._newPosition.subtractToRef(o._oldPosition, o._diffPosition), o._diffPosition.length() > In.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 Qs(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 = xi.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([Ie()], t.prototype, "ellipsoid", void 0), X([Ie()], t.prototype, "ellipsoidOffset", void 0), X([xe()], t.prototype, "checkCollisions", void 0), X([xe()], t.prototype, "applyGravity", void 0), t }(tl); ze.AddNodeConstructor("TouchCamera", (function (e, t) { return function () { return new rl(e, R.Zero(), t) } })); var rl = 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 }(il); ze.AddNodeConstructor("ArcRotateCamera", (function (e, t) { return function () { return new nl(e, 0, 0, 1, R.Zero(), t) } })); var nl = 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 Bs(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 Ao, 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 Ro, 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 xo, 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 = xi.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.inertialAlphaOffset; this.beta <= 0 && (i *= -1), this.getScene().useRightHandedSystem && (i *= -1), this.parent && this.parent._getWorldMatrixDeterminant() < 0 && (i *= -1), this.alpha += i * 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) < this.speed * _ && (this.inertialRadiusOffset = 0) } if (0 !== this.inertialPanningX || 0 !== this.inertialPanningY) { var r = new R(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY); this._viewMatrix.invertToRef(this._cameraTransformMatrix), r.multiplyInPlace(this.panningAxis), R.TransformNormalToRef(r, this._cameraTransformMatrix, this._transformedDirection), !this.mapPanning && this.panningAxis.y || (this._transformedDirection.y = 0), this._targetHost || (this.panningDistanceLimit ? (this._transformedDirection.addInPlace(this._target), R.DistanceSquared(this._transformedDirection, this.panningOriginTarget) <= this.panningDistanceLimit * this.panningDistanceLimit && this._target.copyFrom(this._transformedDirection)) : this._target.addInPlace(this._transformedDirection)), this.inertialPanningX *= this.panningInertia, this.inertialPanningY *= this.panningInertia, Math.abs(this.inertialPanningX) < this.speed * _ && (this.inertialPanningX = 0), Math.abs(this.inertialPanningY) < this.speed * _ && (this.inertialPanningY = 0) } this._checkLimits(), e.prototype._checkInputs.call(this) } }, t.prototype._checkLimits = function () { null === this.lowerBetaLimit || void 0 === this.lowerBetaLimit ? this.allowUpsideDown && this.beta > Math.PI && (this.beta = this.beta - 2 * Math.PI) : this.beta < this.lowerBetaLimit && (this.beta = this.lowerBetaLimit), null === this.upperBetaLimit || void 0 === this.upperBetaLimit ? this.allowUpsideDown && this.beta < -Math.PI && (this.beta = this.beta + 2 * Math.PI) : this.beta > this.upperBetaLimit && (this.beta = this.upperBetaLimit), null !== this.lowerAlphaLimit && this.alpha < this.lowerAlphaLimit && (this.alpha = this.lowerAlphaLimit), null !== this.upperAlphaLimit && this.alpha > this.upperAlphaLimit && (this.alpha = this.upperAlphaLimit), null !== this.lowerRadiusLimit && this.radius < this.lowerRadiusLimit && (this.radius = this.lowerRadiusLimit, this.inertialRadiusOffset = 0), null !== this.upperRadiusLimit && this.radius > this.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 = Jn.MinMax(e), r = R.Distance(i.min, i.max); 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 = Jn.MinMax(n), r = R.Distance(i.min, i.max) } else i = e, r = e.distance; this._target = Jn.Center(i), t || (this.maxZ = 2 * r) }, t.prototype.createRigCamera = function (e, i) { var r = 0; switch (this.cameraRigMode) { case ln.RIG_MODE_STEREOSCOPIC_ANAGLYPH: case ln.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: case ln.RIG_MODE_STEREOSCOPIC_OVERUNDER: case ln.RIG_MODE_STEREOSCOPIC_INTERLACED: case ln.RIG_MODE_VR: r = this._cameraRigParams.stereoHalfAngle * (0 === i ? 1 : -1); break; case ln.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 ln.RIG_MODE_STEREOSCOPIC_ANAGLYPH: case ln.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: case ln.RIG_MODE_STEREOSCOPIC_OVERUNDER: case ln.RIG_MODE_STEREOSCOPIC_INTERLACED: case ln.RIG_MODE_VR: t.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle, i.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle; break; case ln.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.dispose = function () { this.inputs.clear(), e.prototype.dispose.call(this) }, t.prototype.getClassName = function () { return "ArcRotateCamera" }, X([xe()], t.prototype, "alpha", void 0), X([xe()], t.prototype, "beta", void 0), X([xe()], t.prototype, "radius", void 0), X([xe()], t.prototype, "overrideCloneAlphaBetaRadius", void 0), X([Ie("target")], t.prototype, "_target", void 0), X([Me("targetHost")], t.prototype, "_targetHost", void 0), X([xe()], t.prototype, "inertialAlphaOffset", void 0), X([xe()], t.prototype, "inertialBetaOffset", void 0), X([xe()], t.prototype, "inertialRadiusOffset", void 0), X([xe()], t.prototype, "lowerAlphaLimit", void 0), X([xe()], t.prototype, "upperAlphaLimit", void 0), X([xe()], t.prototype, "lowerBetaLimit", void 0), X([xe()], t.prototype, "upperBetaLimit", void 0), X([xe()], t.prototype, "lowerRadiusLimit", void 0), X([xe()], t.prototype, "upperRadiusLimit", void 0), X([xe()], t.prototype, "inertialPanningX", void 0), X([xe()], t.prototype, "inertialPanningY", void 0), X([xe()], t.prototype, "pinchToPanMaxDistance", void 0), X([xe()], t.prototype, "panningDistanceLimit", void 0), X([Ie()], t.prototype, "panningOriginTarget", void 0), X([xe()], t.prototype, "panningInertia", void 0), X([xe()], t.prototype, "zoomToMouseLocation", null), X([xe()], t.prototype, "zoomOnFactor", void 0), X([Pe()], t.prototype, "targetScreenOffset", void 0), X([xe()], t.prototype, "allowUpsideDown", void 0), X([xe()], t.prototype, "useInputToRestoreState", void 0), t }(tl); ze.AddNodeConstructor("DeviceOrientationCamera", (function (e, t) { return function () { return new ol(e, R.Zero(), t) } })); var ol = 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 = Ar.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 }(il), al = function (e) { function t(t) { return e.call(this, t) || this } return W(t, e), t.prototype.addKeyboard = function () { return this.add(new Vs), this }, t.prototype.addMouse = function () { return this.add(new ks), this }, t }(Is), sl = 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() > In.CollisionsEpsilon && (o.position.addInPlace(o._diffPosition), o.onCollide && i && o.onCollide(i)) }, o.inputs = new al(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 = xi.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([Ie()], t.prototype, "ellipsoid", void 0), X([Ie()], t.prototype, "ellipsoidOffset", void 0), X([xe()], t.prototype, "checkCollisions", void 0), X([xe()], t.prototype, "applyGravity", void 0), t }(tl), ll = function (e) { function t(t) { return e.call(this, t) || this } return W(t, e), t.prototype.addKeyboard = function () { return this.add(new Gs), this }, t.prototype.addMouseWheel = function () { return this.add(new zs), this }, t.prototype.addPointers = function () { return this.add(new Ws), this }, t.prototype.addVRDeviceOrientation = function () { return console.warn("DeviceOrientation support not yet implemented for FollowCamera."), this }, t }(Is); ze.AddNodeConstructor("FollowCamera", (function (e, t) { return function () { return new ul(e, R.Zero(), t) } })), ze.AddNodeConstructor("ArcFollowCamera", (function (e, t) { return function () { return new hl(e, 0, 0, 1, null, t) } })); var cl, ul = 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 ll(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 = xi.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 = xi.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.radius < this.lowerRadiusLimit && (this.radius = this.lowerRadiusLimit), null !== this.upperRadiusLimit && this.radius > this.upperRadiusLimit && (this.radius = this.upperRadiusLimit), null !== this.lowerHeightOffsetLimit && this.heightOffset < this.lowerHeightOffsetLimit && (this.heightOffset = this.lowerHeightOffsetLimit), null !== this.upperHeightOffsetLimit && this.heightOffset > this.upperHeightOffsetLimit && (this.heightOffset = this.upperHeightOffsetLimit), null !== this.lowerRotationOffsetLimit && this.rotationOffset < this.lowerRotationOffsetLimit && (this.rotationOffset = this.lowerRotationOffsetLimit), null !== this.upperRotationOffsetLimit && this.rotationOffset > this.upperRotationOffsetLimit && (this.rotationOffset = this.upperRotationOffsetLimit) }, t.prototype.getClassName = function () { return "FollowCamera" }, X([xe()], t.prototype, "radius", void 0), X([xe()], t.prototype, "lowerRadiusLimit", void 0), X([xe()], t.prototype, "upperRadiusLimit", void 0), X([xe()], t.prototype, "rotationOffset", void 0), X([xe()], t.prototype, "lowerRotationOffsetLimit", void 0), X([xe()], t.prototype, "upperRotationOffsetLimit", void 0), X([xe()], t.prototype, "heightOffset", void 0), X([xe()], t.prototype, "lowerHeightOffsetLimit", void 0), X([xe()], t.prototype, "upperHeightOffsetLimit", void 0), X([xe()], t.prototype, "cameraAcceleration", void 0), X([xe()], t.prototype, "maxCameraSpeed", void 0), X([Me("lockedTargetId")], t.prototype, "lockedTarget", void 0), t }(tl), hl = 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 }(tl); !function (e) { e[e.VIVE = 0] = "VIVE", e[e.OCULUS = 1] = "OCULUS", e[e.WINDOWS = 2] = "WINDOWS", e[e.GEAR_VR = 3] = "GEAR_VR", e[e.DAYDREAM = 4] = "DAYDREAM", e[e.GENERIC = 5] = "GENERIC" }(cl || (cl = {})); var dl, pl, fl = function () { function e() { } return e.InitiateController = function (e) { for (var t = 0, i = this._ControllerFactories; t < i.length; t++) { var r = i[t]; if (r.canCreate(e)) return r.create(e) } if (this._DefaultControllerFactory) return this._DefaultControllerFactory(e); throw "The type of gamepad you are trying to load needs to be imported first or is not supported." }, e._ControllerFactories = [], e._DefaultControllerFactory = null, e }(), _l = function (e) { function t(t) { var i = e.call(this, t.id, t.index, t) || this; return i.isXR = !1, i._deviceRoomPosition = R.Zero(), i._deviceRoomRotationQuaternion = new P, i.devicePosition = R.Zero(), i.deviceRotationQuaternion = new P, i.deviceScaleFactor = 1, i._trackPosition = !0, i._maxRotationDistFromHeadset = Math.PI / 5, i._draggedRoomRotation = 0, i._leftHandSystemQuaternion = new P, i._deviceToWorld = I.Identity(), i._pointingPoseNode = null, i._workingMatrix = I.Identity(), i._meshAttachedObservable = new u, i.type = Os.POSE_ENABLED, i.controllerType = cl.GENERIC, i.position = R.Zero(), i.rotationQuaternion = new P, i._calculatedPosition = R.Zero(), i._calculatedRotation = new P, P.RotationYawPitchRollToRef(Math.PI, 0, 0, i._leftHandSystemQuaternion), i } return W(t, e), t.prototype._disableTrackPosition = function (e) { this._trackPosition && (this._calculatedPosition.copyFrom(e), this._trackPosition = !1) }, t.prototype.update = function () { e.prototype.update.call(this), this._updatePoseAndMesh() }, t.prototype._updatePoseAndMesh = function () { if (!this.isXR) { var e = this.browserGamepad.pose; if (this.updateFromDevice(e), !this._trackPosition && S.LastCreatedScene && S.LastCreatedScene.activeCamera && S.LastCreatedScene.activeCamera.devicePosition) { var t = S.LastCreatedScene.activeCamera; if (t._computeDevicePosition(), this._deviceToWorld.setTranslation(t.devicePosition), t.deviceRotationQuaternion) { t._deviceRoomRotationQuaternion.toEulerAnglesToRef(O.Vector3[0]); var i = Math.atan2(Math.sin(O.Vector3[0].y - this._draggedRoomRotation), Math.cos(O.Vector3[0].y - this._draggedRoomRotation)); if (Math.abs(i) > this._maxRotationDistFromHeadset) { var r = i - (i < 0 ? -this._maxRotationDistFromHeadset : this._maxRotationDistFromHeadset); this._draggedRoomRotation += r; var n = Math.sin(-r), o = Math.cos(-r); this._calculatedPosition.x = this._calculatedPosition.x * o - this._calculatedPosition.z * n, this._calculatedPosition.z = this._calculatedPosition.x * n + this._calculatedPosition.z * o } } } R.TransformCoordinatesToRef(this._calculatedPosition, this._deviceToWorld, this.devicePosition), this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix), P.FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion), this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation), this._mesh && (this._mesh.position.copyFrom(this.devicePosition), this._mesh.rotationQuaternion && this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion)) } }, t.prototype.updateFromDevice = function (e) { if (!this.isXR && e) { this.rawPose = e, e.position && (this._deviceRoomPosition.copyFromFloats(e.position[0], e.position[1], -e.position[2]), this._mesh && this._mesh.getScene().useRightHandedSystem && (this._deviceRoomPosition.z *= -1), this._trackPosition && this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor, this._calculatedPosition), this._calculatedPosition.addInPlace(this.position)); var t = this.rawPose; e.orientation && t.orientation && 4 === t.orientation.length && (this._deviceRoomRotationQuaternion.copyFromFloats(t.orientation[0], t.orientation[1], -t.orientation[2], -t.orientation[3]), this._mesh && (this._mesh.getScene().useRightHandedSystem ? (this._deviceRoomRotationQuaternion.z *= -1, this._deviceRoomRotationQuaternion.w *= -1) : this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion, this._deviceRoomRotationQuaternion)), this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion, this._calculatedRotation)) } }, t.prototype.attachToMesh = function (e) { if (this._mesh && (this._mesh.parent = null), this._mesh = e, this._poseControlledCamera && (this._mesh.parent = this._poseControlledCamera), this._mesh.rotationQuaternion || (this._mesh.rotationQuaternion = new P), !this.isXR && (this._updatePoseAndMesh(), this._pointingPoseNode)) { for (var t = [], i = this._pointingPoseNode; i.parent;)t.push(i.parent), i = i.parent; t.reverse().forEach((function (e) { e.computeWorldMatrix(!0) })) } this._meshAttachedObservable.notifyObservers(e) }, t.prototype.attachToPoseControlledCamera = function (e) { this._poseControlledCamera = e, this._mesh && (this._mesh.parent = this._poseControlledCamera) }, t.prototype.dispose = function () { this._mesh && this._mesh.dispose(), this._mesh = null, e.prototype.dispose.call(this) }, Object.defineProperty(t.prototype, "mesh", { get: function () { return this._mesh }, enumerable: !1, configurable: !0 }), t.prototype.getForwardRay = function (e) { if (void 0 === e && (e = 100), !this.mesh) return new Mo(R.Zero(), new R(0, 0, 1), e); var t = this._pointingPoseNode ? this._pointingPoseNode.getWorldMatrix() : this.mesh.getWorldMatrix(), i = t.getTranslation(), r = new R(0, 0, -1), n = R.TransformNormal(r, t), o = R.Normalize(n); return new Mo(i, o, e) }, t.POINTING_POSE = "POINTING_POSE", t }(Os); !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" }(dl || (dl = {})), function (e) { e[e.Up = 12] = "Up", e[e.Down = 13] = "Down", e[e.Left = 14] = "Left", e[e.Right = 15] = "Right" }(pl || (pl = {})); var ml, gl, vl = 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 = Os.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, dl.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, dl.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, dl.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, dl.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, dl.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, dl.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, dl.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, dl.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, dl.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, dl.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, pl.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, pl.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, pl.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, pl.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 }(Os); !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" }(ml || (ml = {})), function (e) { e[e.Up = 12] = "Up", e[e.Down = 13] = "Down", e[e.Left = 14] = "Left", e[e.Right = 15] = "Right" }(gl || (gl = {})); var yl = 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 = Os.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, ml.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, ml.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, ml.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, ml.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, ml.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, ml.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, ml.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, ml.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, ml.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, ml.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, gl.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, gl.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, gl.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, gl.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 }(Os), bl = function () { function e(e) { var t = this; if (this._scene = e, this._babylonGamepads = [], this._oneGamepadConnected = !1, this._isMonitoring = !1, this.onGamepadDisconnectedObservable = new u, et() ? (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 = Os.XBOX); for (var t = 0, i = this._babylonGamepads; t < i.length; t++) { var r = i[t]; if (r && r.type === e) return r } return null }, e.prototype.dispose = function () { this._gamepadEventSupported && (this._onGamepadConnectedEvent && window.removeEventListener("gamepadconnected", this._onGamepadConnectedEvent), this._onGamepadDisconnectedEvent && window.removeEventListener("gamepaddisconnected", this._onGamepadDisconnectedEvent), this._onGamepadConnectedEvent = null, this._onGamepadDisconnectedEvent = null), this._babylonGamepads.forEach((function (e) { e.dispose() })), this.onGamepadConnectedObservable.clear(), this.onGamepadDisconnectedObservable.clear(), this._oneGamepadConnected = !1, this._stopMonitoringGamepads(), this._babylonGamepads = [] }, e.prototype._addNewGamepad = function (e) { var t; this._oneGamepadConnected || (this._oneGamepadConnected = !0); var i = -1 !== e.id.search("054c") && -1 === e.id.search("0ce6"), r = -1 !== e.id.search("Xbox One"); return t = r || -1 !== e.id.search("Xbox 360") || -1 !== e.id.search("xinput") || -1 !== e.id.search("045e") && -1 === e.id.search("Surface Dock") ? new vl(e.id, e.index, e, r) : i ? new yl(e.id, e.index, e) : e.pose ? fl.InitiateController(e) : new Ds(e.id, e.index, e), this._babylonGamepads[t.index] = t, t }, e.prototype._startMonitoringGamepads = function () { this._isMonitoring || (this._isMonitoring = !0, this._checkGamepadsStatus()) }, e.prototype._stopMonitoringGamepads = function () { this._isMonitoring = !1 }, e.prototype._checkGamepadsStatus = function () { var e = this; for (var t in this._updateGamepadObjects(), this._babylonGamepads) { var i = this._babylonGamepads[t]; if (i && i.isConnected) try { i.update() } catch (e) { -1 === this._loggedErrors.indexOf(i.index) && (xi.Warn("Error updating gamepad ".concat(i.id)), this._loggedErrors.push(i.index)) } } this._isMonitoring && In.QueueNewFrame((function () { e._checkGamepadsStatus() })) }, e.prototype._updateGamepadObjects = function () { for (var e = navigator.getGamepads ? navigator.getGamepads() : [], t = 0; t < e.length; t++) { var i = e[t]; if (i) if (this._babylonGamepads[i.index]) this._babylonGamepads[t].browserGamepad = i, this._babylonGamepads[t].isConnected || (this._babylonGamepads[t]._isConnected = !0, this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[t])); else { var r = this._addNewGamepad(i); this.onGamepadConnectedObservable.notifyObservers(r) } } }, e }(); Object.defineProperty(Sr.prototype, "gamepadManager", { get: function () { if (!this._gamepadManager) { this._gamepadManager = new bl(this); var e = this._getComponent(qi.NAME_GAMEPAD); e || (e = new Tl(this), this._addComponent(e)) } return this._gamepadManager }, enumerable: !0, configurable: !0 }), Qs.prototype.addGamepad = function () { return this.add(new Js), this }, Bs.prototype.addGamepad = function () { return this.add(new Ns), this }; var Tl = function () { function e(e) { this.name = qi.NAME_GAMEPAD, this.scene = e } return e.prototype.register = function () { this.scene._beforeCameraUpdateStage.registerStep(qi.STEP_BEFORECAMERAUPDATE_GAMEPAD, this, this._beforeCameraUpdate) }, e.prototype.rebuild = function () { }, e.prototype.dispose = function () { var e = this.scene._gamepadManager; e && (e.dispose(), this.scene._gamepadManager = null) }, e.prototype._beforeCameraUpdate = function () { var e = this.scene._gamepadManager; e && e._isMonitoring && e._checkGamepadsStatus() }, e }(); ze.AddNodeConstructor("FreeCamera", (function (e, t) { return function () { return new El(e, R.Zero(), t) } })); var El = function (e) { function t(t, i, r) { var n = e.call(this, t, i, r) || this; return n.inputs.addGamepad(), n } return W(t, e), Object.defineProperty(t.prototype, "gamepadAngularSensibility", { get: function () { var e = this.inputs.attached.gamepad; return e ? e.gamepadAngularSensibility : 0 }, set: function (e) { var t = this.inputs.attached.gamepad; t && (t.gamepadAngularSensibility = e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "gamepadMoveSensibility", { get: function () { var e = this.inputs.attached.gamepad; return e ? e.gamepadMoveSensibility : 0 }, set: function (e) { var t = this.inputs.attached.gamepad; t && (t.gamepadMoveSensibility = e) }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function () { return "UniversalCamera" }, t }(rl); ln._CreateDefaultParsedCamera = function (e, t) { return new El(e, R.Zero(), t) }, ze.AddNodeConstructor("GamepadCamera", (function (e, t) { return function () { return new Sl(e, R.Zero(), t) } })); var Sl = function (e) { function t(t, i, r) { return e.call(this, t, i, r) || this } return W(t, e), t.prototype.getClassName = function () { return "GamepadCamera" }, t }(El); Ut.ShadersStore.passCubePixelShader = "varying vec2 vUV;uniform samplerCube textureSampler;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{vec2 uv=vUV*2.0-1.0;\n#ifdef POSITIVEX\ngl_FragColor=textureCube(textureSampler,vec3(1.001,uv.y,uv.x));\n#endif\n#ifdef NEGATIVEX\ngl_FragColor=textureCube(textureSampler,vec3(-1.001,uv.y,uv.x));\n#endif\n#ifdef POSITIVEY\ngl_FragColor=textureCube(textureSampler,vec3(uv.y,1.001,uv.x));\n#endif\n#ifdef NEGATIVEY\ngl_FragColor=textureCube(textureSampler,vec3(uv.y,-1.001,uv.x));\n#endif\n#ifdef POSITIVEZ\ngl_FragColor=textureCube(textureSampler,vec3(uv,1.001));\n#endif\n#ifdef NEGATIVEZ\ngl_FragColor=textureCube(textureSampler,vec3(uv,-1.001));\n#endif\n}"; var xl = function (e) { function t(t, i, r, n, o, s, l, c) { return void 0 === r && (r = null), void 0 === l && (l = a.TEXTURETYPE_UNSIGNED_INT), void 0 === c && (c = !1), e.call(this, t, "pass", null, null, i, r, n, o, s, void 0, l, void 0, null, c) || this } return W(t, e), t.prototype.getClassName = function () { return "PassPostProcess" }, t._Parse = function (e, i, r, n) { return Ue.Parse((function () { return new t(e.name, e.options, i, e.renderTargetSamplingMode, e._engine, e.reusable) }), e, r, n) }, t }(Ia); b("BABYLON.PassPostProcess", xl); var Al = 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), void 0 === c && (c = !1); var u = e.call(this, t, "passCube", null, null, i, r, n, o, s, "#define POSITIVEX", l, void 0, null, c) || this; return u._face = 0, u } return W(t, e), Object.defineProperty(t.prototype, "face", { get: function () { return this._face }, set: function (e) { if (!(e < 0 || e > 5)) 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 Ue.Parse((function () { return new t(e.name, e.options, i, e.renderTargetSamplingMode, e._engine, e.reusable) }), e, r, n) }, t }(Ia); In._RescalePostProcessFactory = function (e) { return new xl("rescale", 1, null, a.TEXTURE_BILINEAR_SAMPLINGMODE, e, !1, a.TEXTURETYPE_UNSIGNED_INT) }; Ut.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 Rl = 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 }(Ia); function Cl(e) { e._rigCameras[0]._rigPostProcess = new xl(e.name + "_passthru", 1, e._rigCameras[0]), e._rigCameras[1]._rigPostProcess = new Rl(e.name + "_anaglyph", 1, e._rigCameras) } b("BABYLON.AnaglyphPostProcess", Rl), ze.AddNodeConstructor("AnaglyphArcRotateCamera", (function (e, t, i) { return function () { return new Pl(e, 0, 0, 1, R.Zero(), i.interaxial_distance, t) } })); var Pl = 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 = Cl.bind(null, l), l.interaxialDistance = a, l.setCameraRigMode(ln.RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: a }), l } return W(t, e), t.prototype.getClassName = function () { return "AnaglyphArcRotateCamera" }, t }(nl); ze.AddNodeConstructor("AnaglyphFreeCamera", (function (e, t, i) { return function () { return new Il(e, R.Zero(), i.interaxial_distance, t) } })); var Il = function (e) { function t(t, i, r, n) { var o = e.call(this, t, i, n) || this; return o._setRigMode = Cl.bind(null, o), o.interaxialDistance = r, o.setCameraRigMode(ln.RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: r }), o } return W(t, e), t.prototype.getClassName = function () { return "AnaglyphFreeCamera" }, t }(il); ze.AddNodeConstructor("AnaglyphGamepadCamera", (function (e, t, i) { return function () { return new Ml(e, R.Zero(), i.interaxial_distance, t) } })); var Ml = function (e) { function t(t, i, r, n) { var o = e.call(this, t, i, n) || this; return o._setRigMode = Cl.bind(null, o), o.interaxialDistance = r, o.setCameraRigMode(ln.RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: r }), o } return W(t, e), t.prototype.getClassName = function () { return "AnaglyphGamepadCamera" }, t }(Sl); ze.AddNodeConstructor("AnaglyphUniversalCamera", (function (e, t, i) { return function () { return new Ol(e, R.Zero(), i.interaxial_distance, t) } })); var Ol = function (e) { function t(t, i, r, n) { var o = e.call(this, t, i, n) || this; return o._setRigMode = Cl.bind(null, o), o.interaxialDistance = r, o.setCameraRigMode(ln.RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: r }), o } return W(t, e), t.prototype.getClassName = function () { return "AnaglyphUniversalCamera" }, t }(El); Ut.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 Dl = 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 }(Ia), Nl = 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 }(Ia); function Fl(e) { var t = e.cameraRigMode === ln.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL || e.cameraRigMode === ln.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED, i = e.cameraRigMode === ln.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED; e.cameraRigMode === ln.RIG_MODE_STEREOSCOPIC_INTERLACED ? (e._rigCameras[0]._rigPostProcess = new xl(e.name + "_passthru", 1, e._rigCameras[0]), e._rigCameras[1]._rigPostProcess = new Dl(e.name + "_stereoInterlace", e._rigCameras, !1, !0)) : (e._rigCameras[i ? 1 : 0].viewport = new sn(0, 0, t ? .5 : 1, t ? 1 : .5), e._rigCameras[i ? 0 : 1].viewport = new sn(t ? .5 : 0, t ? 0 : .5, t ? .5 : 1, t ? 1 : .5)) } ze.AddNodeConstructor("StereoscopicArcRotateCamera", (function (e, t, i) { return function () { return new Ll(e, 0, 0, 1, R.Zero(), i.interaxial_distance, i.isStereoscopicSideBySide, t) } })); var Ll = 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 = Fl.bind(null, c), c.interaxialDistance = a, c.isStereoscopicSideBySide = s, c.setCameraRigMode(s ? ln.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : ln.RIG_MODE_STEREOSCOPIC_OVERUNDER, { interaxialDistance: a }), c } return W(t, e), t.prototype.getClassName = function () { return "StereoscopicArcRotateCamera" }, t }(nl); ze.AddNodeConstructor("StereoscopicFreeCamera", (function (e, t, i) { return function () { return new wl(e, R.Zero(), i.interaxial_distance, i.isStereoscopicSideBySide, t) } })); var wl = function (e) { function t(t, i, r, n, o) { var a = e.call(this, t, i, o) || this; return a._setRigMode = Fl.bind(null, a), a.interaxialDistance = r, a.isStereoscopicSideBySide = n, a.setCameraRigMode(n ? ln.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : ln.RIG_MODE_STEREOSCOPIC_OVERUNDER, { interaxialDistance: r }), a } return W(t, e), t.prototype.getClassName = function () { return "StereoscopicFreeCamera" }, t }(il); ze.AddNodeConstructor("StereoscopicGamepadCamera", (function (e, t, i) { return function () { return new Bl(e, R.Zero(), i.interaxial_distance, i.isStereoscopicSideBySide, t) } })); var Bl = function (e) { function t(t, i, r, n, o) { var a = e.call(this, t, i, o) || this; return a._setRigMode = Fl.bind(null, a), a.interaxialDistance = r, a.isStereoscopicSideBySide = n, a.setCameraRigMode(n ? ln.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : ln.RIG_MODE_STEREOSCOPIC_OVERUNDER, { interaxialDistance: r }), a } return W(t, e), t.prototype.getClassName = function () { return "StereoscopicGamepadCamera" }, t }(Sl); ze.AddNodeConstructor("StereoscopicFreeCamera", (function (e, t, i) { return function () { return new Ul(e, R.Zero(), i.interaxial_distance, i.isStereoscopicSideBySide, t) } })); var Ul = function (e) { function t(t, i, r, n, o) { var a = e.call(this, t, i, o) || this; return a._setRigMode = Fl.bind(null, a), a.interaxialDistance = r, a.isStereoscopicSideBySide = n, a.setCameraRigMode(n ? ln.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : ln.RIG_MODE_STEREOSCOPIC_OVERUNDER, { interaxialDistance: r }), a } return W(t, e), t.prototype.getClassName = function () { return "StereoscopicUniversalCamera" }, t }(El), Vl = 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(ln.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 tl(e, R.Zero(), this.getScene()), i = new On("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; e < this._rigCameras.length; e++) { var t = this._rigCameras[e]; t.minZ = this.minZ, t.maxZ = this.maxZ, t.fov = this.fov, t.upVector.copyFrom(this.upVector), t.rotationQuaternion ? t.rotationQuaternion.copyFrom(this.rotationQuaternion) : t.rotation.copyFrom(this.rotation), this._updateCamera(this._rigCameras[e], e) } }, t.prototype._updateCamera = function (e, t) { var i = this.distanceBetweenEyes / 2, r = i / this.distanceToProjectionPlane; e.position.copyFrom(this.position), e.position.addInPlaceFromFloats(0 === t ? -i : i, 0, -this._distanceToProjectionPlane); var n = e.parent, o = n.getPivotMatrix(); o.setTranslationFromFloats(0 === t ? i : -i, 0, 0), o.setRowFromFloats(2, 0 === t ? r : -r, 0, 1, 0), n.setPivotMatrix(o, !1) }, t.prototype._setRigMode = function () { this._rigCameras[0].viewport = new sn(0, 0, .5, 1), this._rigCameras[1].viewport = new sn(.5, 0, .5, 1); for (var e = 0; e < this._rigCameras.length; e++)this._updateCamera(this._rigCameras[e], e) }, t }(El); ze.AddNodeConstructor("VirtualJoysticksCamera", (function (e, t) { return function () { return new kl(e, R.Zero(), t) } })); var kl = function (e) { function t(t, i, r) { var n = e.call(this, t, i, r) || this; return n.inputs.addVirtualJoystick(), n } return W(t, e), t.prototype.getClassName = function () { return "VirtualJoysticksCamera" }, t }(il), Gl = function () { function e() { this.compensateDistortion = !0, this.multiviewEnabled = !1 } return Object.defineProperty(e.prototype, "aspectRatio", { get: function () { return this.hResolution / (2 * this.vResolution) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "aspectRatioFov", { get: function () { return 2 * Math.atan(this.postProcessScaleFactor * this.vScreenSize / (2 * this.eyeToScreenDistance)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "leftHMatrix", { get: function () { var e = 4 * (this.hScreenSize / 4 - this.lensSeparationDistance / 2) / this.hScreenSize; return I.Translation(e, 0, 0) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "rightHMatrix", { get: function () { var e = 4 * (this.hScreenSize / 4 - this.lensSeparationDistance / 2) / this.hScreenSize; return I.Translation(-e, 0, 0) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "leftPreViewMatrix", { get: function () { return I.Translation(.5 * this.interpupillaryDistance, 0, 0) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "rightPreViewMatrix", { get: function () { return I.Translation(-.5 * this.interpupillaryDistance, 0, 0) }, enumerable: !1, configurable: !0 }), e.GetDefault = function () { var t = new e; return t.hResolution = 1280, t.vResolution = 800, t.hScreenSize = .149759993, t.vScreenSize = .0935999975, t.vScreenCenter = .0467999987, t.eyeToScreenDistance = .0410000011, t.lensSeparationDistance = .063500002, t.interpupillaryDistance = .064000003, t.distortionK = [1, .219999999, .239999995, 0], t.chromaAbCorrection = [.995999992, -.00400000019, 1.01400006, 0], t.postProcessScaleFactor = 1.714605507808412, t.lensCenterOffset = .151976421, t }, e }(); Ut.ShadersStore.vrDistortionCorrectionPixelShader = "varying vec2 vUV;uniform sampler2D textureSampler;uniform vec2 LensCenter;uniform vec2 Scale;uniform vec2 ScaleIn;uniform vec4 HmdWarpParam;vec2 HmdWarp(vec2 in01) {vec2 theta=(in01-LensCenter)*ScaleIn; \nfloat rSq=theta.x*theta.x+theta.y*theta.y;vec2 rvector=theta*(HmdWarpParam.x+HmdWarpParam.y*rSq+HmdWarpParam.z*rSq*rSq+HmdWarpParam.w*rSq*rSq*rSq);return LensCenter+Scale*rvector;}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{vec2 tc=HmdWarp(vUV);if (tc.x <0.0 || tc.x>1.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 zl = function (e) { function t(t, i, r, n) { var o = e.call(this, t, "vrDistortionCorrection", ["LensCenter", "Scale", "ScaleIn", "HmdWarpParam"], null, n.postProcessScaleFactor, i, vo.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 }(Ia); Ut.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 Wl = 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 }(es); function Hl(e, t) { var i = new zi(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 } In.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 Ht(this, It.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 }, In.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)) }, In.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) }, ln.prototype._useMultiviewToSingleView = !1, ln.prototype._multiviewTexture = null, ln.prototype._resizeOrCreateMultiviewTexture = function (e, t) { this._multiviewTexture ? this._multiviewTexture.getRenderWidth() == e && this._multiviewTexture.getRenderHeight() == t || (this._multiviewTexture.dispose(), this._multiviewTexture = new Wl(this.getScene(), { width: e, height: t })) : this._multiviewTexture = new Wl(this.getScene(), { width: e, height: t }) }; var Xl = Sr.prototype.createSceneUniformBuffer; Sr.prototype._transformMatrixR = I.Zero(), Sr.prototype._multiviewSceneUbo = null, Sr.prototype._createMultiviewUbo = function () { this._multiviewSceneUbo = Hl(this.getEngine(), "scene_multiview") }, Sr.prototype.createSceneUniformBuffer = function (e) { return this._multiviewSceneUbo ? Hl(this.getEngine(), e) : Xl.bind(this)(e) }, Sr.prototype._updateMultiviewUbo = function (e, t) { e && t && e.multiplyToRef(t, this._transformMatrixR), e && t && (e.multiplyToRef(t, O.Matrix[0]), vr.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)) }, Sr.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; t < e._rigCameras.length; t++) { var i = this.getEngine(); this._activeCamera = e._rigCameras[t], i.setViewport(this._activeCamera.viewport), this.postProcessManager && (this.postProcessManager._prepareFrame(), this.postProcessManager._finalizeFrame(this._activeCamera.isIntermediate)) } }; var jl = function (e) { function t(t, i, r) { var n = e.call(this, t, "vrMultiviewToSingleview", ["imageIndex"], ["multiviewSampler"], r, i, vo.BILINEAR_SAMPLINGMODE) || this, o = null != i ? i : n.getCamera(); return n.onSizeChangedObservable.add((function () { })), n.onApplyObservable.add((function (e) { o._scene.activeCamera && o._scene.activeCamera.isLeftCamera ? e.setInt("imageIndex", 0) : e.setInt("imageIndex", 1), e.setTexture("multiviewSampler", o._multiviewTexture) })), n } return W(t, e), t.prototype.getClassName = function () { return "VRMultiviewToSingleviewPostProcess" }, t }(Ia); function Yl(e, t) { var i = t.vrCameraMetrics || Gl.GetDefault(); e._rigCameras[0]._cameraRigParams.vrMetrics = i, e._rigCameras[0].viewport = new sn(0, 0, .5, 1), e._rigCameras[0]._cameraRigParams.vrWorkMatrix = new I, e._rigCameras[0]._cameraRigParams.vrHMatrix = i.leftHMatrix, e._rigCameras[0]._cameraRigParams.vrPreViewMatrix = i.leftPreViewMatrix, e._rigCameras[0].getProjectionMatrix = e._rigCameras[0]._getVRProjectionMatrix, e._rigCameras[1]._cameraRigParams.vrMetrics = i, e._rigCameras[1].viewport = new sn(.5, 0, .5, 1), e._rigCameras[1]._cameraRigParams.vrWorkMatrix = new I, e._rigCameras[1]._cameraRigParams.vrHMatrix = i.rightHMatrix, e._rigCameras[1]._cameraRigParams.vrPreViewMatrix = i.rightPreViewMatrix, e._rigCameras[1].getProjectionMatrix = e._rigCameras[1]._getVRProjectionMatrix, i.multiviewEnabled && (e.getScene().getEngine().getCaps().multiview ? (e._useMultiviewToSingleView = !0, e._rigPostProcess = new jl("VRMultiviewToSingleview", e, i.postProcessScaleFactor)) : ($.Warn("Multiview is not supported, falling back to standard rendering"), i.multiviewEnabled = !1)), i.compensateDistortion && (e._rigCameras[0]._rigPostProcess = new zl("VR_Distort_Compensation_Left", e._rigCameras[0], !1, i), e._rigCameras[1]._rigPostProcess = new zl("VR_Distort_Compensation_Right", e._rigCameras[1], !0, i)) } ze.AddNodeConstructor("VRDeviceOrientationArcRotateCamera", (function (e, t) { return function () { return new Kl(e, 0, 0, 1, R.Zero(), t) } })); var Kl = function (e) { function t(t, i, r, n, o, a, s, l) { void 0 === s && (s = !0), void 0 === l && (l = Gl.GetDefault()); var c = e.call(this, t, i, r, n, o, a) || this; return c._setRigMode = Yl.bind(null, c), l.compensateDistortion = s, c.setCameraRigMode(ln.RIG_MODE_VR, { vrCameraMetrics: l }), c.inputs.addVRDeviceOrientation(), c } return W(t, e), t.prototype.getClassName = function () { return "VRDeviceOrientationArcRotateCamera" }, t }(nl); ze.AddNodeConstructor("VRDeviceOrientationFreeCamera", (function (e, t) { return function () { return new Ql(e, R.Zero(), t) } })); var Ql = function (e) { function t(t, i, r, n, o) { void 0 === n && (n = !0), void 0 === o && (o = Gl.GetDefault()); var a = e.call(this, t, i, r) || this; return a._setRigMode = Yl.bind(null, a), o.compensateDistortion = n, a.setCameraRigMode(ln.RIG_MODE_VR, { vrCameraMetrics: o }), a } return W(t, e), t.prototype.getClassName = function () { return "VRDeviceOrientationFreeCamera" }, t }(ol); ze.AddNodeConstructor("VRDeviceOrientationGamepadCamera", (function (e, t) { return function () { return new ql(e, R.Zero(), t) } })); var ql = function (e) { function t(t, i, r, n, o) { void 0 === n && (n = !0), void 0 === o && (o = Gl.GetDefault()); var a = e.call(this, t, i, r, n, o) || this; return a._setRigMode = Yl.bind(null, a), a.inputs.addGamepad(), a } return W(t, e), t.prototype.getClassName = function () { return "VRDeviceOrientationGamepadCamera" }, t }(Ql); ze.AddNodeConstructor("Light_Type_3", (function (e, t) { return function () { return new Zl(e, R.Zero(), t) } })); var Zl = function (e) { function t(t, i, r) { var n = e.call(this, t, r) || this; return n.groundColor = new B(0, 0, 0), n.direction = i || R.Up(), n } return W(t, e), t.prototype._buildUniformLayout = function () { this._uniformBuffer.addUniform("vLightData", 4), this._uniformBuffer.addUniform("vLightDiffuse", 4), this._uniformBuffer.addUniform("vLightSpecular", 4), this._uniformBuffer.addUniform("vLightGround", 3), this._uniformBuffer.addUniform("shadowsInfo", 3), this._uniformBuffer.addUniform("depthValues", 2), this._uniformBuffer.create() }, t.prototype.getClassName = function () { return "HemisphericLight" }, t.prototype.setDirectionToTarget = function (e) { return this.direction = R.Normalize(e.subtract(R.Zero())), this.direction }, t.prototype.getShadowGenerator = function () { return null }, t.prototype.transferToEffect = function (e, t) { var i = R.Normalize(this.direction); return this._uniformBuffer.updateFloat4("vLightData", i.x, i.y, i.z, 0, t), this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), t), this }, t.prototype.transferToNodeMaterialEffect = function (e, t) { var i = R.Normalize(this.direction); return e.setFloat3(t, i.x, i.y, i.z), this }, t.prototype.computeWorldMatrix = function () { return this._worldMatrix || (this._worldMatrix = I.Identity()), this._worldMatrix }, t.prototype.getTypeID = function () { return eo.LIGHTTYPEID_HEMISPHERICLIGHT }, t.prototype.prepareLightSpecificDefines = function (e, t) { e["HEMILIGHT" + t] = !0 }, X([Re()], t.prototype, "groundColor", void 0), X([Ie()], t.prototype, "direction", void 0), t }(eo); function Jl(e, t) { if (t.vrDisplay) { var i = t.vrDisplay.getEyeParameters("left"), r = t.vrDisplay.getEyeParameters("right"); e._rigCameras[0].viewport = new sn(0, 0, .5, 1), e._rigCameras[0].setCameraRigParameter("left", !0), e._rigCameras[0].setCameraRigParameter("specs", t.specs), e._rigCameras[0].setCameraRigParameter("eyeParameters", i), e._rigCameras[0].setCameraRigParameter("frameData", t.frameData), e._rigCameras[0].setCameraRigParameter("parentCamera", t.parentCamera), e._rigCameras[0]._cameraRigParams.vrWorkMatrix = new I, e._rigCameras[0].getProjectionMatrix = e._getWebVRProjectionMatrix, e._rigCameras[0].parent = e, e._rigCameras[0]._getViewMatrix = e._getWebVRViewMatrix, e._rigCameras[1].viewport = new sn(.5, 0, .5, 1), e._rigCameras[1].setCameraRigParameter("eyeParameters", r), e._rigCameras[1].setCameraRigParameter("specs", t.specs), e._rigCameras[1].setCameraRigParameter("frameData", t.frameData), e._rigCameras[1].setCameraRigParameter("parentCamera", t.parentCamera), e._rigCameras[1]._cameraRigParams.vrWorkMatrix = new I, e._rigCameras[1].getProjectionMatrix = e._getWebVRProjectionMatrix, e._rigCameras[1].parent = e, e._rigCameras[1]._getViewMatrix = e._getWebVRViewMatrix } } Object.defineProperty(In.prototype, "isInVRExclusivePointerMode", { get: function () { return this._vrExclusivePointerMode }, enumerable: !0, configurable: !0 }), In.prototype._prepareVRComponent = function () { this._vrSupported = !1, this._vrExclusivePointerMode = !1, this.onVRDisplayChangedObservable = new u, this.onVRRequestPresentComplete = new u, this.onVRRequestPresentStart = new u }, In.prototype.isVRDevicePresent = function () { return !!this._vrDisplay }, In.prototype.getVRDevice = function () { return this._vrDisplay }, In.prototype.initWebVR = function () { return this.initWebVRAsync(), this.onVRDisplayChangedObservable }, In.prototype.initWebVRAsync = function () { var e = this, t = function () { var t = { vrDisplay: e._vrDisplay, vrSupported: e._vrSupported }; e.onVRDisplayChangedObservable.notifyObservers(t), e._webVRInitPromise = new Promise((function (e) { e(t) })) }; if (!this._onVrDisplayConnect) { this._onVrDisplayConnect = function (i) { e._vrDisplay = i.display, t() }, this._onVrDisplayDisconnect = function () { e._vrDisplay.cancelAnimationFrame(e._frameHandler), e._vrDisplay = void 0, e._frameHandler = In.QueueNewFrame(e._boundRenderFunction), t() }, this._onVrDisplayPresentChange = function () { e._vrExclusivePointerMode = e._vrDisplay && e._vrDisplay.isPresenting }; var i = this.getHostWindow(); i && (i.addEventListener("vrdisplayconnect", this._onVrDisplayConnect), i.addEventListener("vrdisplaydisconnect", this._onVrDisplayDisconnect), i.addEventListener("vrdisplaypresentchange", this._onVrDisplayPresentChange)) } return this._webVRInitPromise = this._webVRInitPromise || this._getVRDisplaysAsync(), this._webVRInitPromise.then(t), this._webVRInitPromise }, In.prototype._getVRDisplaysAsync = function () { var e = this; return new Promise((function (t) { navigator.getVRDisplays ? navigator.getVRDisplays().then((function (i) { e._vrSupported = !0, e._vrDisplay = i[0], t({ vrDisplay: e._vrDisplay, vrSupported: e._vrSupported }) })) : (e._vrDisplay = void 0, e._vrSupported = !1, t({ vrDisplay: e._vrDisplay, vrSupported: e._vrSupported })) })) }, In.prototype.enableVR = function (e) { var t = this; if (this._vrDisplay && !this._vrDisplay.isPresenting) { this.onVRRequestPresentStart.notifyObservers(this); var i = { highRefreshRate: !!this.vrPresentationAttributes && this.vrPresentationAttributes.highRefreshRate, foveationLevel: this.vrPresentationAttributes ? this.vrPresentationAttributes.foveationLevel : 1, multiview: (this.getCaps().multiview || this.getCaps().oculusMultiview) && e.useMultiview }; this._vrDisplay.requestPresent([H({ source: this.getRenderingCanvas(), attributes: i }, i)]).then((function () { t.onVRRequestPresentComplete.notifyObservers(!0), t._onVRFullScreenTriggered() })).catch((function () { t.onVRRequestPresentComplete.notifyObservers(!1) })) } }, In.prototype._onVRFullScreenTriggered = function () { if (this._vrDisplay && this._vrDisplay.isPresenting) { this._oldSize = new We(this.getRenderWidth(), this.getRenderHeight()), this._oldHardwareScaleFactor = this.getHardwareScalingLevel(); var e = this._vrDisplay.getEyeParameters("left"); this.setHardwareScalingLevel(1), this.setSize(2 * e.renderWidth, e.renderHeight) } else this.setHardwareScalingLevel(this._oldHardwareScaleFactor), this.setSize(this._oldSize.width, this._oldSize.height) }, In.prototype.disableVR = function () { var e = this; this._vrDisplay && this._vrDisplay.isPresenting && this._vrDisplay.exitPresent().then((function () { return e._onVRFullScreenTriggered() })).catch((function () { return e._onVRFullScreenTriggered() })), et() && (window.removeEventListener("vrdisplaypointerrestricted", this._onVRDisplayPointerRestricted), window.removeEventListener("vrdisplaypointerunrestricted", this._onVRDisplayPointerUnrestricted), this._onVrDisplayConnect && (window.removeEventListener("vrdisplayconnect", this._onVrDisplayConnect), this._onVrDisplayDisconnect && window.removeEventListener("vrdisplaydisconnect", this._onVrDisplayDisconnect), this._onVrDisplayPresentChange && window.removeEventListener("vrdisplaypresentchange", this._onVrDisplayPresentChange), this._onVrDisplayConnect = null, this._onVrDisplayDisconnect = null)) }, In.prototype._connectVREvents = function (e, t) { var i = this; if (this._onVRDisplayPointerRestricted = function () { e && e.requestPointerLock() }, this._onVRDisplayPointerUnrestricted = function () { if (t) t.exitPointerLock && t.exitPointerLock(); else { var e = i.getHostWindow(); e.document && e.document.exitPointerLock && e.document.exitPointerLock() } }, et()) { var r = this.getHostWindow(); r.addEventListener("vrdisplaypointerrestricted", this._onVRDisplayPointerRestricted, !1), r.addEventListener("vrdisplaypointerunrestricted", this._onVRDisplayPointerUnrestricted, !1) } }, In.prototype._submitVRFrame = function () { if (this._vrDisplay && this._vrDisplay.isPresenting) try { this._vrDisplay.submitFrame() } catch (e) { xi.Warn("webVR submitFrame has had an unexpected failure: " + e) } }, In.prototype.isVRPresenting = function () { return this._vrDisplay && this._vrDisplay.isPresenting }, In.prototype._requestVRFrame = function () { this._frameHandler = In.QueueNewFrame(this._boundRenderFunction, this._vrDisplay) }, ze.AddNodeConstructor("WebVRFreeCamera", (function (e, t) { return function () { return new $l(e, R.Zero(), t) } })), ze.AddNodeConstructor("WebVRGamepadCamera", (function (e, t) { return function () { return new $l(e, R.Zero(), t) } })); var $l = function (e) { function t(t, i, r, n) { void 0 === n && (n = {}); var o = e.call(this, t, i, r) || this; o._webVROptions = n, o._vrDevice = null, o.rawPose = null, o._specsVersion = "1.1", o._attached = !1, o._descendants = [], o._deviceRoomPosition = R.Zero(), o._deviceRoomRotationQuaternion = P.Identity(), o._standingMatrix = null, o.devicePosition = R.Zero(), o.deviceRotationQuaternion = P.Identity(), o.deviceScaleFactor = 1, o._deviceToWorld = I.Identity(), o._worldToDevice = I.Identity(), o.controllers = [], o.onControllersAttachedObservable = new u, o.onControllerMeshLoadedObservable = new u, o.onPoseUpdatedFromDeviceObservable = new u, o._poseSet = !1, o.rigParenting = !0, o._defaultHeight = void 0, o._setRigMode = Jl.bind(null, o), o._detachIfAttached = function () { var e = o.getEngine().getVRDevice(); e && !e.isPresenting && o.detachControl() }, o._workingVector = R.Zero(), o._oneVector = R.One(), o._workingMatrix = I.Identity(), o._tmpMatrix = new I, o._cache.position = R.Zero(), n.defaultHeight && (o._defaultHeight = n.defaultHeight, o.position.y = o._defaultHeight), o.minZ = .1, 5 === arguments.length && (o._webVROptions = arguments[4]), null == o._webVROptions.trackPosition && (o._webVROptions.trackPosition = !0), null == o._webVROptions.controllerMeshes && (o._webVROptions.controllerMeshes = !0), null == o._webVROptions.defaultLightingOnControllers && (o._webVROptions.defaultLightingOnControllers = !0), o.rotationQuaternion = new P, o._webVROptions && o._webVROptions.positionScale && (o.deviceScaleFactor = o._webVROptions.positionScale); var a = o.getEngine(); return o._onVREnabled = function (e) { e && o.initControllers() }, a.onVRRequestPresentComplete.add(o._onVREnabled), a.initWebVR().add((function (e) { e.vrDisplay && o._vrDevice !== e.vrDisplay && (o._vrDevice = e.vrDisplay, o.setCameraRigMode(ln.RIG_MODE_WEBVR, { parentCamera: o, vrDisplay: o._vrDevice, frameData: o._frameData, specs: o._specsVersion }), o._attached && o.getEngine().enableVR(o._webVROptions)) })), "undefined" != typeof VRFrameData && (o._frameData = new VRFrameData), n.useMultiview && (o.getScene().getEngine().getCaps().multiview ? (o._useMultiviewToSingleView = !0, o._rigPostProcess = new jl("VRMultiviewToSingleview", o, 1)) : ($.Warn("Multiview is not supported, falling back to standard rendering"), o._useMultiviewToSingleView = !1)), o.getScene().onBeforeCameraRenderObservable.add((function (e) { e.parent === o && o.rigParenting && (o._descendants = o.getDescendants(!0, (function (e) { var t = o.controllers.some((function (t) { return t._mesh === e })), i = -1 !== o._rigCameras.indexOf(e); return !t && !i })), o._descendants.forEach((function (t) { t.parent = e }))) })), o.getScene().onAfterCameraRenderObservable.add((function (e) { e.parent === o && o.rigParenting && o._descendants.forEach((function (e) { e.parent = o })) })), o } return W(t, e), t.prototype.deviceDistanceToRoomGround = function () { return this._standingMatrix ? (this._standingMatrix.getTranslationToRef(this._workingVector), this._deviceRoomPosition.y + this._workingVector.y) : this._defaultHeight || 0 }, t.prototype.useStandingMatrix = function (e) { var t = this; void 0 === e && (e = function (e) { }), this.getEngine().initWebVRAsync().then((function (i) { i.vrDisplay && i.vrDisplay.stageParameters && i.vrDisplay.stageParameters.sittingToStandingTransform && t._webVROptions.trackPosition ? (t._standingMatrix = new I, I.FromFloat32ArrayToRefScaled(i.vrDisplay.stageParameters.sittingToStandingTransform, 0, 1, t._standingMatrix), t.getScene().useRightHandedSystem || t._standingMatrix && t._standingMatrix.toggleModelMatrixHandInPlace(), e(!0)) : e(!1) })) }, t.prototype.useStandingMatrixAsync = function () { var e = this; return new Promise((function (t) { e.useStandingMatrix((function (e) { t(e) })) })) }, t.prototype.dispose = function () { this._detachIfAttached(), this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled), this._updateCacheWhenTrackingDisabledObserver && this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver), e.prototype.dispose.call(this) }, t.prototype.getControllerByName = function (e) { for (var t = 0, i = this.controllers; t < i.length; t++) { var r = i[t]; if (r.hand === e) return r } return null }, Object.defineProperty(t.prototype, "leftController", { get: function () { return this._leftController || (this._leftController = this.getControllerByName("left")), this._leftController }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rightController", { get: function () { return this._rightController || (this._rightController = this.getControllerByName("right")), this._rightController }, enumerable: !1, configurable: !0 }), t.prototype.getForwardRay = function (t) { return void 0 === t && (t = 100), this.leftCamera ? e.prototype.getForwardRay.call(this, t, this.leftCamera.getWorldMatrix(), this.leftCamera.globalPosition) : e.prototype.getForwardRay.call(this, t) }, t.prototype._checkInputs = function () { this._vrDevice && this._vrDevice.isPresenting && (this._vrDevice.getFrameData(this._frameData), this.updateFromDevice(this._frameData.pose)), e.prototype._checkInputs.call(this) }, t.prototype.updateFromDevice = function (e) { e && e.orientation && 4 === e.orientation.length && (this.rawPose = e, this._deviceRoomRotationQuaternion.copyFromFloats(e.orientation[0], e.orientation[1], -e.orientation[2], -e.orientation[3]), this.getScene().useRightHandedSystem && (this._deviceRoomRotationQuaternion.z *= -1, this._deviceRoomRotationQuaternion.w *= -1), this._webVROptions.trackPosition && this.rawPose.position && (this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2]), this.getScene().useRightHandedSystem && (this._deviceRoomPosition.z *= -1)), this._poseSet = !0) }, t.prototype.attachControl = function (t) { t = xi.BackCompatCameraNoPreventDefault(arguments), e.prototype.attachControl.call(this, t), this._attached = !0, t = !ln.ForceAttachControlToAlwaysPreventDefault && t, this._vrDevice && this.getEngine().enableVR(this._webVROptions); var i = this._scene.getEngine().getHostWindow(); i && i.addEventListener("vrdisplaypresentchange", this._detachIfAttached) }, t.prototype.detachControl = function () { this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver), this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver), e.prototype.detachControl.call(this), this._attached = !1, this.getEngine().disableVR(), window.removeEventListener("vrdisplaypresentchange", this._detachIfAttached) }, t.prototype.getClassName = function () { return "WebVRFreeCamera" }, t.prototype.resetToCurrentRotation = function () { this._vrDevice.resetPose() }, t.prototype._updateRigCameras = function () { var e = this._rigCameras[0], t = this._rigCameras[1]; e.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion), t.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion), e.position.copyFrom(this._deviceRoomPosition), t.position.copyFrom(this._deviceRoomPosition) }, t.prototype._correctPositionIfNotTrackPosition = function (e, t) { void 0 === t && (t = !1), this.rawPose && this.rawPose.position && !this._webVROptions.trackPosition && (I.TranslationToRef(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2], this._tmpMatrix), t || this._tmpMatrix.invert(), this._tmpMatrix.multiplyToRef(e, e)) }, t.prototype._updateCache = function (t) { var i = this; this.rotationQuaternion.equals(this._cache.rotationQuaternion) && this.position.equals(this._cache.position) || (this._updateCacheCalled || (this._updateCacheCalled = !0, this.update()), this.rotationQuaternion.toRotationMatrix(this._workingMatrix), R.TransformCoordinatesToRef(this._deviceRoomPosition, this._workingMatrix, this._workingVector), this.devicePosition.subtractToRef(this._workingVector, this._workingVector), I.ComposeToRef(this._oneVector, this.rotationQuaternion, this._workingVector, this._deviceToWorld), this._deviceToWorld.getTranslationToRef(this._workingVector), this._workingVector.addInPlace(this.position), this._workingVector.subtractInPlace(this._cache.position), this._deviceToWorld.setTranslation(this._workingVector), this._deviceToWorld.invertToRef(this._worldToDevice), this.controllers.forEach((function (e) { e._deviceToWorld.copyFrom(i._deviceToWorld), i._correctPositionIfNotTrackPosition(e._deviceToWorld), e.update() }))), t || e.prototype._updateCache.call(this), this._updateCacheCalled = !1 }, t.prototype._computeDevicePosition = function () { R.TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition) }, t.prototype.update = function () { this._computeDevicePosition(), I.FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix), this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix), P.FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion), this._poseSet && this.onPoseUpdatedFromDeviceObservable.notifyObservers(null), e.prototype.update.call(this) }, t.prototype._getViewMatrix = function () { return I.Identity() }, t.prototype._getWebVRViewMatrix = function () { var e = this._cameraRigParams.parentCamera; e._updateCache(); var t = this._cameraRigParams.left ? this._cameraRigParams.frameData.leftViewMatrix : this._cameraRigParams.frameData.rightViewMatrix; return I.FromArrayToRef(t, 0, this._webvrViewMatrix), this.getScene().useRightHandedSystem || this._webvrViewMatrix.toggleModelMatrixHandInPlace(), this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix), R.TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint), this.position.addToRef(this._transformedReferencePoint, this._currentTarget), 1 !== e.deviceScaleFactor && (this._webvrViewMatrix.invert(), e.deviceScaleFactor && (this._webvrViewMatrix.multiplyAtIndex(12, e.deviceScaleFactor), this._webvrViewMatrix.multiplyAtIndex(13, e.deviceScaleFactor), this._webvrViewMatrix.multiplyAtIndex(14, e.deviceScaleFactor)), this._webvrViewMatrix.invert()), e._correctPositionIfNotTrackPosition(this._webvrViewMatrix, !0), e._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix), this._workingMatrix = this._workingMatrix || I.Identity(), this._webvrViewMatrix.invertToRef(this._workingMatrix), this._workingMatrix.multiplyToRef(e.getWorldMatrix(), this._workingMatrix), this._workingMatrix.getTranslationToRef(this._globalPosition), this._markSyncedWithParent(), this._webvrViewMatrix }, t.prototype._getWebVRProjectionMatrix = function () { var e = this.parent; e._vrDevice.depthNear = e.minZ, e._vrDevice.depthFar = e.maxZ; var t = this._cameraRigParams.left ? this._cameraRigParams.frameData.leftProjectionMatrix : this._cameraRigParams.frameData.rightProjectionMatrix; return I.FromArrayToRef(t, 0, this._projectionMatrix), this.getScene().useRightHandedSystem || this._projectionMatrix.toggleProjectionMatrixHandInPlace(), this._projectionMatrix }, t.prototype.initControllers = function () { var e = this; this.controllers.length = 0; var t = this.getScene().gamepadManager; this._onGamepadDisconnectedObserver = t.onGamepadDisconnectedObservable.add((function (t) { if (t.type === Os.POSE_ENABLED) { var i = t; i.defaultModel && i.defaultModel.setEnabled(!1), "right" === i.hand && (e._rightController = null), "left" === i.hand && (e._leftController = null); var r = e.controllers.indexOf(i); -1 !== r && e.controllers.splice(r, 1) } })), this._onGamepadConnectedObserver = t.onGamepadConnectedObservable.add((function (t) { if (t.type === Os.POSE_ENABLED) { var i = t; if (e._webVROptions.trackPosition || (i._disableTrackPosition(new R("left" == i.hand ? -.15 : .15, -.5, .25)), e._updateCacheWhenTrackingDisabledObserver || (e._updateCacheWhenTrackingDisabledObserver = e._scene.onBeforeRenderObservable.add((function () { e._updateCache() })))), i.deviceScaleFactor = e.deviceScaleFactor, i._deviceToWorld.copyFrom(e._deviceToWorld), e._correctPositionIfNotTrackPosition(i._deviceToWorld), e._webVROptions.controllerMeshes && (i.defaultModel ? i.defaultModel.setEnabled(!0) : i.initControllerMesh(e.getScene(), (function (t) { if (t.scaling.scaleInPlace(e.deviceScaleFactor), e.onControllerMeshLoadedObservable.notifyObservers(i), e._webVROptions.defaultLightingOnControllers) { e._lightOnControllers || (e._lightOnControllers = new Zl("vrControllersLight", new R(0, 1, 0), e.getScene())); var r = function (e, t) { var i = e.getChildren(); i && 0 !== i.length && i.forEach((function (e) { t.includedOnlyMeshes.push(e), r(e, t) })) }; e._lightOnControllers.includedOnlyMeshes.push(t), r(t, e._lightOnControllers) } }))), i.attachToPoseControlledCamera(e), -1 === e.controllers.indexOf(i)) { e.controllers.push(i); for (var r = !1, n = 0; n < e.controllers.length; n++)e.controllers[n].controllerType === cl.VIVE && (r ? e.controllers[n].hand = "right" : (r = !0, e.controllers[n].hand = "left")); e.controllers.length >= 2 && e.onControllersAttachedObservable.notifyObservers(e.controllers) } } })) }, t }(il), ec = function (e) { function t(t) { var i = e.call(this, t) || this; return i.onTriggerStateChangedObservable = new u, i.onMainButtonStateChangedObservable = new u, i.onSecondaryButtonStateChangedObservable = new u, i.onPadStateChangedObservable = new u, i.onPadValuesChangedObservable = new u, i.pad = { x: 0, y: 0 }, i._changes = { pressChanged: !1, touchChanged: !1, valueChanged: !1, changed: !1 }, i._buttons = new Array(t.buttons.length), i.hand = t.hand, i } return W(t, e), t.prototype.onButtonStateChange = function (e) { this._onButtonStateChange = e }, Object.defineProperty(t.prototype, "defaultModel", { get: function () { return this._defaultModel }, enumerable: !1, configurable: !0 }), t.prototype.update = function () { e.prototype.update.call(this); for (var t = 0; t < this._buttons.length; t++)this._setButtonValue(this.browserGamepad.buttons[t], this._buttons[t], t); this.leftStick.x === this.pad.x && this.leftStick.y === this.pad.y || (this.pad.x = this.leftStick.x, this.pad.y = this.leftStick.y, this.onPadValuesChangedObservable.notifyObservers(this.pad)) }, t.prototype._setButtonValue = function (e, t, i) { e || (e = { pressed: !1, touched: !1, value: 0 }), t ? (this._checkChanges(e, t), this._changes.changed && (this._onButtonStateChange && this._onButtonStateChange(this.index, i, e), this._handleButtonChange(i, e, this._changes)), this._buttons[i].pressed = e.pressed, this._buttons[i].touched = e.touched, this._buttons[i].value = e.value < 1e-8 ? 0 : e.value) : this._buttons[i] = { pressed: e.pressed, touched: e.touched, value: e.value } }, t.prototype._checkChanges = function (e, t) { return this._changes.pressChanged = e.pressed !== t.pressed, this._changes.touchChanged = e.touched !== t.touched, this._changes.valueChanged = e.value !== t.value, this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged, this._changes }, t.prototype.dispose = function () { e.prototype.dispose.call(this), this._defaultModel = null, this.onTriggerStateChangedObservable.clear(), this.onMainButtonStateChangedObservable.clear(), this.onSecondaryButtonStateChangedObservable.clear(), this.onPadStateChangedObservable.clear(), this.onPadValuesChangedObservable.clear() }, t }(_l), tc = function () { function e() { this.previousWorldMatrices = {}, this.previousBones = {} } return e.AddUniforms = function (e) { e.push("previousWorld", "previousViewProjection", "mPreviousBones") }, e.AddSamplers = function (e) { }, e.prototype.bindForSubMesh = function (e, t, i, r, n) { if (t.prePassRenderer && t.prePassRenderer.enabled && t.prePassRenderer.currentRTisSceneRT && -1 !== t.prePassRenderer.getIndex(a.PREPASS_VELOCITY_TEXTURE_TYPE)) { this.previousWorldMatrices[i.uniqueId] || (this.previousWorldMatrices[i.uniqueId] = r.clone()), this.previousViewProjection || (this.previousViewProjection = t.getTransformMatrix().clone(), this.currentViewProjection = t.getTransformMatrix().clone()); var o = t.getEngine(); this.currentViewProjection.updateFlag !== t.getTransformMatrix().updateFlag ? (this._lastUpdateFrameId = o.frameId, this.previousViewProjection.copyFrom(this.currentViewProjection), this.currentViewProjection.copyFrom(t.getTransformMatrix())) : this._lastUpdateFrameId !== o.frameId && (this._lastUpdateFrameId = o.frameId, this.previousViewProjection.copyFrom(this.currentViewProjection)), e.setMatrix("previousWorld", this.previousWorldMatrices[i.uniqueId]), e.setMatrix("previousViewProjection", this.previousViewProjection), this.previousWorldMatrices[i.uniqueId] = r.clone() } }, e }(), ic = function () { function e() { } return Object.defineProperty(e, "DiffuseTextureEnabled", { get: function () { return this._DiffuseTextureEnabled }, set: function (e) { this._DiffuseTextureEnabled !== e && (this._DiffuseTextureEnabled = e, In.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "DetailTextureEnabled", { get: function () { return this._DetailTextureEnabled }, set: function (e) { this._DetailTextureEnabled !== e && (this._DetailTextureEnabled = e, In.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "DecalMapEnabled", { get: function () { return this._DecalMapEnabled }, set: function (e) { this._DecalMapEnabled !== e && (this._DecalMapEnabled = e, In.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "AmbientTextureEnabled", { get: function () { return this._AmbientTextureEnabled }, set: function (e) { this._AmbientTextureEnabled !== e && (this._AmbientTextureEnabled = e, In.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "OpacityTextureEnabled", { get: function () { return this._OpacityTextureEnabled }, set: function (e) { this._OpacityTextureEnabled !== e && (this._OpacityTextureEnabled = e, In.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "ReflectionTextureEnabled", { get: function () { return this._ReflectionTextureEnabled }, set: function (e) { this._ReflectionTextureEnabled !== e && (this._ReflectionTextureEnabled = e, In.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "EmissiveTextureEnabled", { get: function () { return this._EmissiveTextureEnabled }, set: function (e) { this._EmissiveTextureEnabled !== e && (this._EmissiveTextureEnabled = e, In.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "SpecularTextureEnabled", { get: function () { return this._SpecularTextureEnabled }, set: function (e) { this._SpecularTextureEnabled !== e && (this._SpecularTextureEnabled = e, In.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "BumpTextureEnabled", { get: function () { return this._BumpTextureEnabled }, set: function (e) { this._BumpTextureEnabled !== e && (this._BumpTextureEnabled = e, In.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "LightmapTextureEnabled", { get: function () { return this._LightmapTextureEnabled }, set: function (e) { this._LightmapTextureEnabled !== e && (this._LightmapTextureEnabled = e, In.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "RefractionTextureEnabled", { get: function () { return this._RefractionTextureEnabled }, set: function (e) { this._RefractionTextureEnabled !== e && (this._RefractionTextureEnabled = e, In.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "ColorGradingTextureEnabled", { get: function () { return this._ColorGradingTextureEnabled }, set: function (e) { this._ColorGradingTextureEnabled !== e && (this._ColorGradingTextureEnabled = e, In.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "FresnelEnabled", { get: function () { return this._FresnelEnabled }, set: function (e) { this._FresnelEnabled !== e && (this._FresnelEnabled = e, In.MarkAllMaterialsAsDirty(a.MATERIAL_FresnelDirtyFlag)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "ClearCoatTextureEnabled", { get: function () { return this._ClearCoatTextureEnabled }, set: function (e) { this._ClearCoatTextureEnabled !== e && (this._ClearCoatTextureEnabled = e, In.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "ClearCoatBumpTextureEnabled", { get: function () { return this._ClearCoatBumpTextureEnabled }, set: function (e) { this._ClearCoatBumpTextureEnabled !== e && (this._ClearCoatBumpTextureEnabled = e, In.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "ClearCoatTintTextureEnabled", { get: function () { return this._ClearCoatTintTextureEnabled }, set: function (e) { this._ClearCoatTintTextureEnabled !== e && (this._ClearCoatTintTextureEnabled = e, In.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "SheenTextureEnabled", { get: function () { return this._SheenTextureEnabled }, set: function (e) { this._SheenTextureEnabled !== e && (this._SheenTextureEnabled = e, In.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "AnisotropicTextureEnabled", { get: function () { return this._AnisotropicTextureEnabled }, set: function (e) { this._AnisotropicTextureEnabled !== e && (this._AnisotropicTextureEnabled = e, In.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "ThicknessTextureEnabled", { get: function () { return this._ThicknessTextureEnabled }, set: function (e) { this._ThicknessTextureEnabled !== e && (this._ThicknessTextureEnabled = e, In.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "RefractionIntensityTextureEnabled", { get: function () { return this._ThicknessTextureEnabled }, set: function (e) { this._RefractionIntensityTextureEnabled !== e && (this._RefractionIntensityTextureEnabled = e, In.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "TranslucencyIntensityTextureEnabled", { get: function () { return this._ThicknessTextureEnabled }, set: function (e) { this._TranslucencyIntensityTextureEnabled !== e && (this._TranslucencyIntensityTextureEnabled = e, In.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "IridescenceTextureEnabled", { get: function () { return this._IridescenceTextureEnabled }, set: function (e) { this._IridescenceTextureEnabled !== e && (this._IridescenceTextureEnabled = e, In.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)) }, enumerable: !1, configurable: !0 }), e._DiffuseTextureEnabled = !0, e._DetailTextureEnabled = !0, e._DecalMapEnabled = !0, e._AmbientTextureEnabled = !0, e._OpacityTextureEnabled = !0, e._ReflectionTextureEnabled = !0, e._EmissiveTextureEnabled = !0, e._SpecularTextureEnabled = !0, e._BumpTextureEnabled = !0, e._LightmapTextureEnabled = !0, e._RefractionTextureEnabled = !0, e._ColorGradingTextureEnabled = !0, e._FresnelEnabled = !0, e._ClearCoatTextureEnabled = !0, e._ClearCoatBumpTextureEnabled = !0, e._ClearCoatTintTextureEnabled = !0, e._SheenTextureEnabled = !0, e._AnisotropicTextureEnabled = !0, e._ThicknessTextureEnabled = !0, e._RefractionIntensityTextureEnabled = !0, e._TranslucencyIntensityTextureEnabled = !0, e._IridescenceTextureEnabled = !0, e }(); Ut.IncludesShadersStore.decalFragmentDeclaration = "#ifdef DECAL\nuniform vec4 vDecalInfos;\n#endif\n"; Ut.IncludesShadersStore.defaultFragmentDeclaration = "uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;uniform vec3 vAmbientColor;uniform float visibility;\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY \nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;uniform vec2 vTangentSpaceParams;\n#endif\n#ifdef ALPHATEST\nuniform float alphaCutOff;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION) || defined(PREPASS)\nuniform mat4 view;\n#endif\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\n#ifndef REFRACTIONMAP_3D\nuniform mat4 refractionMatrix;\n#endif\n#ifdef REFRACTIONFRESNEL\nuniform vec4 refractionLeftColor;uniform vec4 refractionRightColor;\n#endif\n#if defined(USE_LOCAL_REFRACTIONMAP_CUBIC) && defined(REFRACTIONMAP_3D)\nuniform vec3 vRefractionPosition;uniform vec3 vRefractionSize; \n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\n#endif\n#ifdef DIFFUSEFRESNEL\nuniform vec4 diffuseLeftColor;uniform vec4 diffuseRightColor;\n#endif\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;uniform vec4 emissiveRightColor;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION) || defined(REFLECTIONMAP_EQUIRECTANGULAR) || defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_SKYBOX)\nuniform mat4 reflectionMatrix;\n#endif\n#ifndef REFLECTIONMAP_SKYBOX\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;uniform vec3 vReflectionSize; \n#endif\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;uniform vec4 reflectionRightColor;\n#endif\n#endif\n#ifdef DETAIL\nuniform vec4 vDetailInfos;\n#endif\n#include\n#define ADDITIONAL_FRAGMENT_DECLARATION\n"; Ut.IncludesShadersStore.sceneUboDeclaration = "layout(std140,column_major) uniform;uniform Scene {mat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif \nmat4 view;mat4 projection;vec4 vEyePosition;};\n"; Ut.IncludesShadersStore.meshUboDeclaration = "#ifdef WEBGL2\nuniform mat4 world;uniform float visibility;\n#else\nlayout(std140,column_major) uniform;uniform Mesh\n{mat4 world;float visibility;};\n#endif\n#define WORLD_UBO\n"; Ut.IncludesShadersStore.defaultUboDeclaration = "layout(std140,column_major) uniform;uniform Material\n{vec4 diffuseLeftColor;vec4 diffuseRightColor;vec4 opacityParts;vec4 reflectionLeftColor;vec4 reflectionRightColor;vec4 refractionLeftColor;vec4 refractionRightColor;vec4 emissiveLeftColor;vec4 emissiveRightColor;vec2 vDiffuseInfos;vec2 vAmbientInfos;vec2 vOpacityInfos;vec2 vReflectionInfos;vec3 vReflectionPosition;vec3 vReflectionSize;vec2 vEmissiveInfos;vec2 vLightmapInfos;vec2 vSpecularInfos;vec3 vBumpInfos;mat4 diffuseMatrix;mat4 ambientMatrix;mat4 opacityMatrix;mat4 reflectionMatrix;mat4 emissiveMatrix;mat4 lightmapMatrix;mat4 specularMatrix;mat4 bumpMatrix;vec2 vTangentSpaceParams;float pointSize;float alphaCutOff;mat4 refractionMatrix;vec4 vRefractionInfos;vec3 vRefractionPosition;vec3 vRefractionSize;vec4 vSpecularColor;vec3 vEmissiveColor;vec4 vDiffuseColor;vec3 vAmbientColor;\n#define ADDITIONAL_UBO_DECLARATION\n};\n#include\n#include\n"; Ut.IncludesShadersStore.prePassDeclaration = "#ifdef PREPASS\n#extension GL_EXT_draw_buffers : require\nlayout(location=0) out highp vec4 glFragData[{X}];highp vec4 gl_FragColor;\n#ifdef PREPASS_DEPTH\nvarying highp vec3 vViewPos;\n#endif\n#ifdef PREPASS_VELOCITY\nvarying highp vec4 vCurrentPosition;varying highp vec4 vPreviousPosition;\n#endif\n#endif\n"; Ut.IncludesShadersStore.oitDeclaration = "#ifdef ORDER_INDEPENDENT_TRANSPARENCY\n#extension GL_EXT_draw_buffers : require\nlayout(location=0) out vec2 depth; \nlayout(location=1) out vec4 frontColor;layout(location=2) out vec4 backColor;\n#define MAX_DEPTH 99999.0\nhighp vec4 gl_FragColor;uniform sampler2D oitDepthSampler;uniform sampler2D oitFrontColorSampler;\n#endif\n"; Ut.IncludesShadersStore.mainUVVaryingDeclaration = "#ifdef MAINUV{X}\nvarying vec2 vMainUV{X};\n#endif\n"; Ut.IncludesShadersStore.helperFunctions = "const float PI=3.1415926535897932384626433832795;const float HALF_MIN=5.96046448e-08; \nconst float LinearEncodePowerApprox=2.2;const float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;const vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);const float Epsilon=0.0000001;\n#define saturate(x) clamp(x,0.0,1.0)\n#define absEps(x) abs(x)+Epsilon\n#define maxEps(x) max(x,Epsilon)\n#define saturateEps(x) clamp(x,Epsilon,1.0)\nmat3 transposeMat3(mat3 inMatrix) {vec3 i0=inMatrix[0];vec3 i1=inMatrix[1];vec3 i2=inMatrix[2];mat3 outMatrix=mat3(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);return outMatrix;}\nmat3 inverseMat3(mat3 inMatrix) {float a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];float a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];float a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];float b01=a22*a11-a12*a21;float b11=-a22*a10+a12*a20;float b21=a21*a10-a11*a20;float det=a00*b01+a01*b11+a02*b21;return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),\nb11,(a22*a00-a02*a20),(-a12*a00+a02*a10),\nb21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;}\n#if USE_EXACT_SRGB_CONVERSIONS\nvec3 toLinearSpaceExact(vec3 color)\n{vec3 nearZeroSection=0.0773993808*color;vec3 remainingSection=pow(0.947867299*(color+vec3(0.055)),vec3(2.4));\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nreturn mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3(0.04045)));\n#else\nreturn\nvec3(\ncolor.r<=0.04045 ? nearZeroSection.r : remainingSection.r,\ncolor.g<=0.04045 ? nearZeroSection.g : remainingSection.g,\ncolor.b<=0.04045 ? nearZeroSection.b : remainingSection.b);\n#endif\n}\nvec3 toGammaSpaceExact(vec3 color)\n{vec3 nearZeroSection=12.92*color;vec3 remainingSection=1.055*pow(color,vec3(0.41666))-vec3(0.055);\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nreturn mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3(0.0031308)));\n#else\nreturn\nvec3(\ncolor.r<=0.0031308 ? nearZeroSection.r : remainingSection.r,\ncolor.g<=0.0031308 ? nearZeroSection.g : remainingSection.g,\ncolor.b<=0.0031308 ? nearZeroSection.b : remainingSection.b);\n#endif\n}\n#endif\nfloat toLinearSpace(float color)\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nfloat nearZeroSection=0.0773993808*color;float remainingSection=pow(0.947867299*(color+0.055),2.4);return color<=0.04045 ? nearZeroSection : remainingSection;\n#else\nreturn pow(color,LinearEncodePowerApprox);\n#endif\n}\nvec3 toLinearSpace(vec3 color)\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nreturn toLinearSpaceExact(color);\n#else\nreturn pow(color,vec3(LinearEncodePowerApprox));\n#endif\n}\nvec4 toLinearSpace(vec4 color)\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nreturn vec4(toLinearSpaceExact(color.rgb),color.a);\n#else\nreturn vec4(pow(color.rgb,vec3(LinearEncodePowerApprox)),color.a);\n#endif\n}\nfloat toGammaSpace(float color)\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nfloat nearZeroSection=12.92*color;float remainingSection=1.055*pow(color,0.41666)-0.055;return color<=0.0031308 ? nearZeroSection : remainingSection;\n#else\nreturn pow(color,GammaEncodePowerApprox);\n#endif\n}\nvec3 toGammaSpace(vec3 color)\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nreturn toGammaSpaceExact(color);\n#else\nreturn pow(color,vec3(GammaEncodePowerApprox));\n#endif\n}\nvec4 toGammaSpace(vec4 color)\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nreturn vec4(toGammaSpaceExact(color.rgb),color.a);\n#else\nreturn vec4(pow(color.rgb,vec3(GammaEncodePowerApprox)),color.a);\n#endif\n}\nfloat square(float value)\n{return value*value;}\nvec3 square(vec3 value)\n{return value*value;}\nfloat pow5(float value) {float sq=value*value;return sq*sq*value;}\nfloat getLuminance(vec3 color)\n{return clamp(dot(color,LuminanceEncodeApprox),0.,1.);}\nfloat getRand(vec2 seed) {return fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);}\nfloat dither(vec2 seed,float varianceAmount) {float rand=getRand(seed);float normVariance=varianceAmount/255.0;float dither=mix(-normVariance,normVariance,rand);return dither;}\nconst float rgbdMaxRange=255.0;vec4 toRGBD(vec3 color) {float maxRGB=maxEps(max(color.r,max(color.g,color.b)));float D =max(rgbdMaxRange/maxRGB,1.);D =clamp(floor(D)/255.0,0.,1.);vec3 rgb=color.rgb*D;rgb=toGammaSpace(rgb);return vec4(clamp(rgb,0.,1.),D); }\nvec3 fromRGBD(vec4 rgbd) {rgbd.rgb=toLinearSpace(rgbd.rgb);return rgbd.rgb/rgbd.a;}\nvec3 parallaxCorrectNormal( vec3 vertexPos,vec3 origVec,vec3 cubeSize,vec3 cubePos ) {vec3 invOrigVec=vec3(1.0,1.0,1.0)/origVec;vec3 halfSize=cubeSize*0.5;vec3 intersecAtMaxPlane=(cubePos+halfSize-vertexPos)*invOrigVec;vec3 intersecAtMinPlane=(cubePos-halfSize-vertexPos)*invOrigVec;vec3 largestIntersec=max(intersecAtMaxPlane,intersecAtMinPlane);float distance=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);vec3 intersectPositionWS=vertexPos+origVec*distance;return intersectPositionWS-cubePos;}\n"; Ut.IncludesShadersStore.lightFragmentDeclaration = "#ifdef LIGHT{X}\nuniform vec4 vLightData{X};uniform vec4 vLightDiffuse{X};\n#ifdef SPECULARTERM\nuniform vec4 vLightSpecular{X};\n#else\nvec4 vLightSpecular{X}=vec4(0.);\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];uniform float cascadeBlendFactor{X};varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};uniform highp sampler2DArray depthSampler{X};uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float penumbraDarkness{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\n#else\nuniform highp sampler2DArray shadowSampler{X};\n#endif\n#ifdef SHADOWCSMDEBUG{X}\nconst vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]\n(\nvec3 ( 1.5,0.0,0.0 ),\nvec3 ( 0.0,1.5,0.0 ),\nvec3 ( 0.0,0.0,5.5 ),\nvec3 ( 1.5,0.0,5.5 ),\nvec3 ( 1.5,1.5,0.0 ),\nvec3 ( 1.0,1.0,1.0 ),\nvec3 ( 0.0,1.0,5.5 ),\nvec3 ( 0.5,3.5,0.75 )\n);vec3 shadowDebug{X};\n#endif\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\nint index{X}=-1;\n#else\nint index{X}=SHADOWCSMNUM_CASCADES{X}-1;\n#endif\nfloat diff{X}=0.;\n#elif defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X};\n#else\nvarying vec4 vPositionFromLight{X};varying float vDepthMetric{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DShadow shadowSampler{X};uniform highp sampler2D depthSampler{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DShadow shadowSampler{X};\n#else\nuniform sampler2D shadowSampler{X};\n#endif\nuniform mat4 lightMatrix{X};\n#endif\nuniform vec4 shadowsInfo{X};uniform vec2 depthValues{X};\n#endif\n#ifdef SPOTLIGHT{X}\nuniform vec4 vLightDirection{X};uniform vec4 vLightFalloff{X};\n#elif defined(POINTLIGHT{X})\nuniform vec4 vLightFalloff{X};\n#elif defined(HEMILIGHT{X})\nuniform vec3 vLightGround{X};\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nuniform mat4 textureProjectionMatrix{X};uniform sampler2D projectionLightSampler{X};\n#endif\n#endif\n"; Ut.IncludesShadersStore.lightUboDeclaration = "#ifdef LIGHT{X}\nuniform Light{X}\n{vec4 vLightData;vec4 vLightDiffuse;vec4 vLightSpecular;\n#ifdef SPOTLIGHT{X}\nvec4 vLightDirection;vec4 vLightFalloff;\n#elif defined(POINTLIGHT{X})\nvec4 vLightFalloff;\n#elif defined(HEMILIGHT{X})\nvec3 vLightGround;\n#endif\nvec4 shadowsInfo;vec2 depthValues;} light{X};\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nuniform mat4 textureProjectionMatrix{X};uniform sampler2D projectionLightSampler{X};\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];uniform float cascadeBlendFactor{X};varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};uniform highp sampler2DArray depthSampler{X};uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float penumbraDarkness{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\n#else\nuniform highp sampler2DArray shadowSampler{X};\n#endif\n#ifdef SHADOWCSMDEBUG{X}\nconst vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]\n(\nvec3 ( 1.5,0.0,0.0 ),\nvec3 ( 0.0,1.5,0.0 ),\nvec3 ( 0.0,0.0,5.5 ),\nvec3 ( 1.5,0.0,5.5 ),\nvec3 ( 1.5,1.5,0.0 ),\nvec3 ( 1.0,1.0,1.0 ),\nvec3 ( 0.0,1.0,5.5 ),\nvec3 ( 0.5,3.5,0.75 )\n);vec3 shadowDebug{X};\n#endif\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\nint index{X}=-1;\n#else\nint index{X}=SHADOWCSMNUM_CASCADES{X}-1;\n#endif\nfloat diff{X}=0.;\n#elif defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X}; \n#else\nvarying vec4 vPositionFromLight{X};varying float vDepthMetric{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DShadow shadowSampler{X};uniform highp sampler2D depthSampler{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DShadow shadowSampler{X};\n#else\nuniform sampler2D shadowSampler{X};\n#endif\nuniform mat4 lightMatrix{X};\n#endif\n#endif\n#endif\n"; Ut.IncludesShadersStore.lightsFragmentFunctions = "struct lightingInfo\n{vec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef NDOTL\nfloat ndl;\n#endif\n};lightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {lightingInfo result;vec3 lightVectorW;float attenuation=1.0;if (lightData.w==0.)\n{vec3 direction=lightData.xyz-vPositionW;attenuation=max(0.,1.0-length(direction)/range);lightVectorW=normalize(direction);}\nelse\n{lightVectorW=normalize(-lightData.xyz);}\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\nvec3 angleW=normalize(viewDirectionW+lightVectorW);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;}\nlightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {lightingInfo result;vec3 direction=lightData.xyz-vPositionW;vec3 lightVectorW=normalize(direction);float attenuation=max(0.,1.0-length(direction)/range);float cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));if (cosAngle>=lightDirection.w)\n{cosAngle=max(0.,pow(cosAngle,lightData.w));attenuation*=cosAngle;float ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\nvec3 angleW=normalize(viewDirectionW+lightVectorW);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;}\nresult.diffuse=vec3(0.);\n#ifdef SPECULARTERM\nresult.specular=vec3(0.);\n#endif\n#ifdef NDOTL\nresult.ndl=0.;\n#endif\nreturn result;}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {lightingInfo result;float ndl=dot(vNormal,lightData.xyz)*0.5+0.5;\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=mix(groundColor,diffuseColor,ndl);\n#ifdef SPECULARTERM\nvec3 angleW=normalize(viewDirectionW+lightData.xyz);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor;\n#endif\nreturn result;}\n#define inline\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){vec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);strq/=strq.w;vec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;return textureColor;}"; Ut.IncludesShadersStore.shadowsFragmentFunctions = "#ifdef SHADOWS\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\n#define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l)\n#else\n#define TEXTUREFUNC(s,c,b) texture2D(s,c,b)\n#endif\n#ifndef SHADOWFLOAT\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);}\n#endif\nfloat computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\n{float mask=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));return mix(value,1.0,mask);}\n#define inline\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)\n{vec3 directionToLight=vPositionW-lightPosition;float depth=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);depth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x;\n#endif\nreturn depth>shadow ? darkness : 1.0;}\n#define inline\nfloat computeShadowWithPoissonSamplingCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)\n{vec3 directionToLight=vPositionW-lightPosition;float depth=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);depth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;float visibility=1.;vec3 poissonDisk[4];poissonDisk[0]=vec3(-1.0,1.0,-1.0);poissonDisk[1]=vec3(1.0,-1.0,-1.0);poissonDisk[2]=vec3(-1.0,-1.0,-1.0);poissonDisk[3]=vec3(1.0,-1.0,1.0);\n#ifndef SHADOWFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;}\n#endif\n#define inline\nfloat computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{return 1.0;}\nelse\n{float shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(TEXTUREFUNC(shadowSampler,uv,0.));\n#else\nfloat shadow=TEXTUREFUNC(shadowSampler,uv,0.).x;\n#endif\nreturn shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;}}\n#define inline\nfloat computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{return 1.0;}\nelse\n{float shadowPixelDepth=clamp(depthMetric,0.,1.0);float visibility=1.;vec2 poissonDisk[4];poissonDisk[0]=vec2(-0.94201624,-0.39906216);poissonDisk[1]=vec2(0.94558609,-0.76890725);poissonDisk[2]=vec2(-0.094184101,-0.92938870);poissonDisk[3]=vec2(0.34495938,0.29387760);\n#ifndef SHADOWFLOAT\nif (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[0]*mapSize,0.))1.0 || uv.y<0. || uv.y>1.0)\n{return 1.0;}\nelse\n{float shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(TEXTUREFUNC(shadowSampler,uv,0.));\n#else\nfloat shadowMapSample=TEXTUREFUNC(shadowSampler,uv,0.).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}}\n#define inline\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{return 1.0;}\nelse\n{float shadowPixelDepth=clamp(depthMetric,0.,1.0); \n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(TEXTUREFUNC(shadowSampler,uv,0.));\n#else\nfloat shadowMapSample=TEXTUREFUNC(shadowSampler,uv,0.).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}}\n#ifdef IS_NDC_HALF_ZRANGE\n#define ZINCLIP clipSpace.z\n#else\n#define ZINCLIP uvDepth.z\n#endif\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\n#define GREATEST_LESS_THAN_ONE 0.99999994\n#define inline\nfloat computeShadowWithCSMPCF1(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);float shadow=texture2D(shadowSampler,uvDepthLayer);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}\n#define inline\nfloat computeShadowWithCSMPCF3(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \nuv+=0.5; \nvec2 st=fract(uv); \nvec2 base_uv=floor(uv)-0.5; \nbase_uv*=shadowMapSizeAndInverse.y; \nvec2 uvw0=3.-2.*st;vec2 uvw1=1.+2.*st;vec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;vec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));shadow=shadow/16.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}\n#define inline\nfloat computeShadowWithCSMPCF5(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \nuv+=0.5; \nvec2 st=fract(uv); \nvec2 base_uv=floor(uv)-0.5; \nbase_uv*=shadowMapSizeAndInverse.y; \nvec2 uvw0=4.-3.*st;vec2 uvw1=vec2(7.);vec2 uvw2=1.+3.*st;vec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;vec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));shadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[0]),layer,uvDepth.z));shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));shadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[1]),layer,uvDepth.z));shadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[2]),layer,uvDepth.z));shadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[2]),layer,uvDepth.z));shadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[2]),layer,uvDepth.z));shadow=shadow/144.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}\n#define inline\nfloat computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;}\nelse\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;float shadow=TEXTUREFUNC(shadowSampler,uvDepth,0.);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}\n#define inline\nfloat computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;}\nelse\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \nuv+=0.5; \nvec2 st=fract(uv); \nvec2 base_uv=floor(uv)-0.5; \nbase_uv*=shadowMapSizeAndInverse.y; \nvec2 uvw0=3.-2.*st;vec2 uvw1=1.+2.*st;vec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;vec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z),0.);shadow+=uvw1.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z),0.);shadow+=uvw0.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z),0.);shadow+=uvw1.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z),0.);shadow=shadow/16.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}\n#define inline\nfloat computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;}\nelse\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \nuv+=0.5; \nvec2 st=fract(uv); \nvec2 base_uv=floor(uv)-0.5; \nbase_uv*=shadowMapSizeAndInverse.y; \nvec2 uvw0=4.-3.*st;vec2 uvw1=vec2(7.);vec2 uvw2=1.+3.*st;vec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;vec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z),0.);shadow+=uvw1.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z),0.);shadow+=uvw2.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z),0.);shadow+=uvw0.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z),0.);shadow+=uvw1.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z),0.);shadow+=uvw2.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z),0.);shadow+=uvw0.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z),0.);shadow+=uvw1.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z),0.);shadow+=uvw2.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z),0.);shadow=shadow/144.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}\nconst vec3 PoissonSamplers32[64]=vec3[64](\nvec3(0.06407013,0.05409927,0.),\nvec3(0.7366577,0.5789394,0.),\nvec3(-0.6270542,-0.5320278,0.),\nvec3(-0.4096107,0.8411095,0.),\nvec3(0.6849564,-0.4990818,0.),\nvec3(-0.874181,-0.04579735,0.),\nvec3(0.9989998,0.0009880066,0.),\nvec3(-0.004920578,-0.9151649,0.),\nvec3(0.1805763,0.9747483,0.),\nvec3(-0.2138451,0.2635818,0.),\nvec3(0.109845,0.3884785,0.),\nvec3(0.06876755,-0.3581074,0.),\nvec3(0.374073,-0.7661266,0.),\nvec3(0.3079132,-0.1216763,0.),\nvec3(-0.3794335,-0.8271583,0.),\nvec3(-0.203878,-0.07715034,0.),\nvec3(0.5912697,0.1469799,0.),\nvec3(-0.88069,0.3031784,0.),\nvec3(0.5040108,0.8283722,0.),\nvec3(-0.5844124,0.5494877,0.),\nvec3(0.6017799,-0.1726654,0.),\nvec3(-0.5554981,0.1559997,0.),\nvec3(-0.3016369,-0.3900928,0.),\nvec3(-0.5550632,-0.1723762,0.),\nvec3(0.925029,0.2995041,0.),\nvec3(-0.2473137,0.5538505,0.),\nvec3(0.9183037,-0.2862392,0.),\nvec3(0.2469421,0.6718712,0.),\nvec3(0.3916397,-0.4328209,0.),\nvec3(-0.03576927,-0.6220032,0.),\nvec3(-0.04661255,0.7995201,0.),\nvec3(0.4402924,0.3640312,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.)\n);const vec3 PoissonSamplers64[64]=vec3[64](\nvec3(-0.613392,0.617481,0.),\nvec3(0.170019,-0.040254,0.),\nvec3(-0.299417,0.791925,0.),\nvec3(0.645680,0.493210,0.),\nvec3(-0.651784,0.717887,0.),\nvec3(0.421003,0.027070,0.),\nvec3(-0.817194,-0.271096,0.),\nvec3(-0.705374,-0.668203,0.),\nvec3(0.977050,-0.108615,0.),\nvec3(0.063326,0.142369,0.),\nvec3(0.203528,0.214331,0.),\nvec3(-0.667531,0.326090,0.),\nvec3(-0.098422,-0.295755,0.),\nvec3(-0.885922,0.215369,0.),\nvec3(0.566637,0.605213,0.),\nvec3(0.039766,-0.396100,0.),\nvec3(0.751946,0.453352,0.),\nvec3(0.078707,-0.715323,0.),\nvec3(-0.075838,-0.529344,0.),\nvec3(0.724479,-0.580798,0.),\nvec3(0.222999,-0.215125,0.),\nvec3(-0.467574,-0.405438,0.),\nvec3(-0.248268,-0.814753,0.),\nvec3(0.354411,-0.887570,0.),\nvec3(0.175817,0.382366,0.),\nvec3(0.487472,-0.063082,0.),\nvec3(-0.084078,0.898312,0.),\nvec3(0.488876,-0.783441,0.),\nvec3(0.470016,0.217933,0.),\nvec3(-0.696890,-0.549791,0.),\nvec3(-0.149693,0.605762,0.),\nvec3(0.034211,0.979980,0.),\nvec3(0.503098,-0.308878,0.),\nvec3(-0.016205,-0.872921,0.),\nvec3(0.385784,-0.393902,0.),\nvec3(-0.146886,-0.859249,0.),\nvec3(0.643361,0.164098,0.),\nvec3(0.634388,-0.049471,0.),\nvec3(-0.688894,0.007843,0.),\nvec3(0.464034,-0.188818,0.),\nvec3(-0.440840,0.137486,0.),\nvec3(0.364483,0.511704,0.),\nvec3(0.034028,0.325968,0.),\nvec3(0.099094,-0.308023,0.),\nvec3(0.693960,-0.366253,0.),\nvec3(0.678884,-0.204688,0.),\nvec3(0.001801,0.780328,0.),\nvec3(0.145177,-0.898984,0.),\nvec3(0.062655,-0.611866,0.),\nvec3(0.315226,-0.604297,0.),\nvec3(-0.780145,0.486251,0.),\nvec3(-0.371868,0.882138,0.),\nvec3(0.200476,0.494430,0.),\nvec3(-0.494552,-0.711051,0.),\nvec3(0.612476,0.705252,0.),\nvec3(-0.578845,-0.768792,0.),\nvec3(-0.772454,-0.090976,0.),\nvec3(0.504440,0.372295,0.),\nvec3(0.155736,0.065157,0.),\nvec3(0.391522,0.849605,0.),\nvec3(-0.620106,-0.328104,0.),\nvec3(0.789239,-0.419965,0.),\nvec3(-0.545396,0.538133,0.),\nvec3(-0.178564,-0.596057,0.)\n);\n#define inline\nfloat computeShadowWithCSMPCSS(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);float blockerDepth=0.0;float sumBlockerDepth=0.0;float numBlocker=0.0;for (int i=0; i1.0 || depthMetric<0.0) {return 1.0;}\nelse\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;float blockerDepth=0.0;float sumBlockerDepth=0.0;float numBlocker=0.0;for (int i=0; i 0 && (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 Gn.PrepareUniformBuffer: a = t, this._uboDeclaration = "", this._vertexDeclaration = "", this._fragmentDeclaration = "", this._uniformList = [], this._samplerList = [], this._uboList = []; for (var y = 0, b = this._plugins; y < b.length; y++) { var T = (v = b[y]).getUniforms(); if (T) { if (T.ubo) for (var E = 0, S = T.ubo; E < S.length; E++) { var x = S[E]; if (x.size && x.type) { var A = null !== (o = x.arraySize) && void 0 !== o ? o : 0; a.ubo.addUniform(x.name, x.size, A), this._uboDeclaration += "".concat(x.type, " ").concat(x.name).concat(A > 0 ? "[".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 = nt.GLSL; l = { defines: [], indexParameters: e.indexParameters, isFragment: !1, shouldUseHighPrecisionShader: i._engine._shouldUseHighPrecisionShader, processor: void 0, supportsUniformBuffers: i._engine.supportsUniformBuffers, shadersRepository: Ut.GetShadersRepository(o), includesShadersStore: Ut.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, Bt._ProcessIncludes(n, l, (function (e) { return n = e })) } u += n + "\n" }, d = 0, p = i._activePlugins; d < p.length; d++)h(p[d]); if (u.length > 0) if ("!" === c.charAt(0)) { var f = "g"; if ("!" === (c = c.substring(1)).charAt(0)) f = "", c = c.substring(1); else { var _ = rc.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; b < v.length; ++b)y = y.replace("$" + b, v[b]); n = n.replace(v[0], y), v = g.exec(m) } } else { var T = "#define " + c; n = n.replace(T, "\n" + u + "\n" + T) } } return n } }, e._MaterialPluginClassToMainDefine = {}, e._MaterialPluginCounter = 0, S.OnEnginesDisposedObservable.add((function () { uc() })), e }(), oc = [], ac = !1, sc = null; function lc(e, t) { ac || (sc = Hn.OnEventObservable.add((function (e) { for (var t = 0, i = oc; t < i.length; t++)(0, i[t][1])(e) }), Gn.Created), ac = !0); var i = oc.filter((function (t) { var i = t[0]; return t[1], i === e })); i.length > 0 ? i[0][1] = t : oc.push([e, t]) } function cc(e) { for (var t = 0; t < oc.length; ++t)if (oc[t][0] === e) return oc.splice(t, 1), 0 === oc.length && uc(), !0; return !1 } function uc() { oc.length = 0, ac = !1, Hn.OnEventObservable.remove(sc), sc = null } var hc = function () { function e(e, t, i, r, n, o, s) { void 0 === n && (n = !0), void 0 === o && (o = !1), void 0 === s && (s = !1), this.priority = 500, this.resolveIncludes = !1, this.registerForExtraEvents = !1, this._material = e, this.name = t, this.priority = i, this.resolveIncludes = s, e.pluginManager || (e.pluginManager = new nc(e), e.onDisposeObservable.add((function () { e.pluginManager = void 0 }))), this._pluginDefineNames = r, this._pluginManager = e.pluginManager, n && this._pluginManager._addPlugin(this), o && this._enable(!0), this.markAllDefinesAsDirty = e._dirtyCallbacks[a.MATERIAL_AllDirtyFlag] } return e.prototype._enable = function (e) { e && this._pluginManager._activatePlugin(this) }, e.prototype.getClassName = function () { return "MaterialPluginBase" }, e.prototype.isReadyForSubMesh = function (e, t, i, r) { return !0 }, e.prototype.hardBindForSubMesh = function (e, t, i, r) { }, e.prototype.bindForSubMesh = function (e, t, i, r) { }, e.prototype.dispose = function (e) { }, e.prototype.getCustomCode = function (e) { return null }, e.prototype.collectDefines = function (e) { if (this._pluginDefineNames) for (var t = 0, i = Object.keys(this._pluginDefineNames); t < i.length; t++) { var r = i[t]; if ("_" !== r[0]) { var n = typeof this._pluginDefineNames[r]; e[r] = { type: "number" === n ? "number" : "string" === n ? "string" : "boolean" === n ? "boolean" : "object", default: this._pluginDefineNames[r] } } } }, e.prototype.prepareDefinesBeforeAttributes = function (e, t, i) { }, e.prototype.prepareDefines = function (e, t, i) { }, e.prototype.hasTexture = function (e) { return !1 }, e.prototype.hasRenderTargetTextures = function () { return !1 }, e.prototype.fillRenderTargetTextures = function (e) { }, e.prototype.getActiveTextures = function (e) { }, e.prototype.getAnimatables = function (e) { }, e.prototype.addFallbacks = function (e, t, i) { return i }, e.prototype.getSamplers = function (e) { }, e.prototype.getAttributes = function (e, t, i) { }, e.prototype.getUniformBuffersNames = function (e) { }, e.prototype.getUniforms = function () { return {} }, e.prototype.copyTo = function (e) { Ue.Clone((function () { return e }), this) }, e.prototype.serialize = function () { return Ue.Serialize(this) }, e.prototype.parse = function (e, t, i) { var r = this; Ue.Parse((function () { return r }), e, t, i) }, X([xe()], e.prototype, "name", void 0), X([xe()], e.prototype, "priority", void 0), X([xe()], e.prototype, "resolveIncludes", void 0), X([xe()], e.prototype, "registerForExtraEvents", void 0), e }(), dc = function (e) { function t() { var t = null !== e && e.apply(this, arguments) || this; return t.DETAIL = !1, t.DETAILDIRECTUV = 0, t.DETAIL_NORMALBLENDMETHOD = 0, t } return W(t, e), t }(Mi), pc = function (e) { function t(t, i) { void 0 === i && (i = !0); var r = e.call(this, t, "DetailMap", 140, new dc, i) || this; return r._texture = null, r.diffuseBlendLevel = 1, r.roughnessBlendLevel = 1, r.bumpLevel = 1, r._normalBlendMethod = Hn.MATERIAL_NORMALBLENDMETHOD_WHITEOUT, r._isEnabled = !1, r.isEnabled = !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, i) { return !this._isEnabled || !(e._areTexturesDirty && t.texturesEnabled && i.getCaps().standardDerivatives && this._texture && ic.DetailTextureEnabled && !this._texture.isReady()) }, t.prototype.prepareDefines = function (e, t) { if (this._isEnabled) { e.DETAIL_NORMALBLENDMETHOD = this._normalBlendMethod; var i = t.getEngine(); e._areTexturesDirty && (i.getCaps().standardDerivatives && this._texture && ic.DetailTextureEnabled && this._isEnabled ? (zn.PrepareDefinesForMergedUV(this._texture, e, "DETAIL"), e.DETAIL_NORMALBLENDMETHOD = this._normalBlendMethod) : e.DETAIL = !1) } else e.DETAIL = !1 }, t.prototype.bindForSubMesh = function (e, t) { if (this._isEnabled) { var i = this._material.isFrozen; e.useUbo && i && e.isSync || this._texture && ic.DetailTextureEnabled && (e.updateFloat4("vDetailInfos", this._texture.coordinatesIndex, this.diffuseBlendLevel, this.bumpLevel, this.roughnessBlendLevel), zn.BindTextureMatrix(this._texture, e, "detail")), t.texturesEnabled && this._texture && ic.DetailTextureEnabled && e.setTexture("detailSampler", 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) { 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([Ae("detailTexture"), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "texture", void 0), X([xe()], t.prototype, "diffuseBlendLevel", void 0), X([xe()], t.prototype, "roughnessBlendLevel", void 0), X([xe()], t.prototype, "bumpLevel", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "normalBlendMethod", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isEnabled", void 0), t }(hc), fc = { effect: null, subMesh: null }, _c = 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.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_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"]; t < i.length; t++) { var r = i[t]; this[r] = r === e } }, t }(Mi), mc = function (e) { function t(i, r) { var n = e.call(this, i, r) || this; return n._diffuseTexture = null, n._ambientTexture = null, n._opacityTexture = null, n._reflectionTexture = null, n._emissiveTexture = null, n._specularTexture = null, n._bumpTexture = null, n._lightmapTexture = null, n._refractionTexture = null, n.ambientColor = new B(0, 0, 0), n.diffuseColor = new B(1, 1, 1), n.specularColor = new B(1, 1, 1), n.emissiveColor = new B(0, 0, 0), n.specularPower = 64, n._useAlphaFromDiffuseTexture = !1, n._useEmissiveAsIllumination = !1, n._linkEmissiveWithDiffuse = !1, n._useSpecularOverAlpha = !1, n._useReflectionOverAlpha = !1, n._disableLighting = !1, n._useObjectSpaceNormalMap = !1, n._useParallax = !1, n._useParallaxOcclusion = !1, n.parallaxScaleBias = .05, n._roughness = 0, n.indexOfRefraction = .98, n.invertRefractionY = !0, n.alphaCutOff = .4, n._useLightmapAsShadowmap = !1, n._useReflectionFresnelFromSpecular = !1, n._useGlossinessFromSpecularMapAlpha = !1, n._maxSimultaneousLights = 4, n._invertNormalMapX = !1, n._invertNormalMapY = !1, n._twoSidedLighting = !1, n._applyDecalMapAfterDetailMap = !1, n._renderTargets = new Ci(16), n._worldViewProjectionMatrix = I.Zero(), n._globalAmbientColor = new B(0, 0, 0), n._cacheHasRenderTargetTextures = !1, n.detailMap = new pc(n), n._attachImageProcessingConfiguration(null), n.prePassConfiguration = new tc, n.getRenderTargetTextures = function () { return n._renderTargets.reset(), t.ReflectionTextureEnabled && n._reflectionTexture && n._reflectionTexture.isRenderTarget && n._renderTargets.push(n._reflectionTexture), t.RefractionTextureEnabled && n._refractionTexture && n._refractionTexture.isRenderTarget && n._renderTargets.push(n._refractionTexture), n._eventInfo.renderTargets = n._renderTargets, n._callbackPluginEventFillRenderTargetTextures(n._eventInfo), n._renderTargets }, n } return W(t, e), Object.defineProperty(t.prototype, "imageProcessingConfiguration", { get: function () { return this._imageProcessingConfiguration }, set: function (e) { this._attachImageProcessingConfiguration(e), this._markAllSubMeshesAsTexturesDirty() }, 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, "isPrePassCapable", { get: function () { return !this.disableDepthWrite }, 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 }), Object.defineProperty(t.prototype, "canRenderToMRT", { get: function () { return !0 }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasRenderTargetTextures", { get: function () { return !!(t.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) || !!(t.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) || this._cacheHasRenderTargetTextures }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function () { return "StandardMaterial" }, Object.defineProperty(t.prototype, "useLogarithmicDepth", { get: function () { return this._useLogarithmicDepth }, set: function (e) { this._useLogarithmicDepth = e && this.getScene().getEngine().getCaps().fragmentDepthSupported, this._markAllSubMeshesAsMiscDirty() }, enumerable: !1, configurable: !0 }), t.prototype.needAlphaBlending = function () { return !this._disableAlphaBlending && (this.alpha < 1 || null != this._opacityTexture || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled) }, t.prototype.needAlphaTesting = function () { return !!this._forceAlphaTest || this._hasAlphaChannel() && (null == this._transparencyMode || this._transparencyMode === Hn.MATERIAL_ALPHATEST) }, t.prototype._shouldUseAlphaFromDiffuseTexture = function () { return null != this._diffuseTexture && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture && this._transparencyMode !== Hn.MATERIAL_OPAQUE }, t.prototype._hasAlphaChannel = function () { return null != this._diffuseTexture && this._diffuseTexture.hasAlpha || null != this._opacityTexture }, t.prototype.getAlphaTestTexture = function () { return this._diffuseTexture }, t.prototype.isReadyForSubMesh = function (e, i, r) { if (void 0 === r && (r = !1), this._uniformBufferLayoutBuilt || this.buildUniformLayout(), i.effect && this.isFrozen && i.effect._wasPreviouslyReady && i.effect._wasPreviouslyUsingInstances === r) return !0; i.materialDefines || (this._callbackPluginEventGeneric(Gn.GetDefineNames, this._eventInfo), i.materialDefines = new _c(this._eventInfo.defineNames)); var n = this.getScene(), o = i.materialDefines; if (this._isReadyForSubMesh(i)) return !0; var s = n.getEngine(); o._needNormals = zn.PrepareDefinesForLights(n, e, o, !0, this._maxSimultaneousLights, this._disableLighting), zn.PrepareDefinesForMultiview(n, o); var l = this.needAlphaBlendingForMesh(e) && this.getScene().useOrderIndependentTransparency; if (zn.PrepareDefinesForPrePass(n, o, this.canRenderToMRT && !l), zn.PrepareDefinesForOIT(n, o, l), o._areTexturesDirty) { this._eventInfo.hasRenderTargetTextures = !1, this._callbackPluginEventHasRenderTargetTextures(this._eventInfo), this._cacheHasRenderTargetTextures = this._eventInfo.hasRenderTargetTextures, o._needUVs = !1; for (var c = 1; c <= a.MAX_SUPPORTED_UV_SETS; ++c)o["MAINUV" + c] = !1; if (n.texturesEnabled) { if (o.DIFFUSEDIRECTUV = 0, o.BUMPDIRECTUV = 0, o.AMBIENTDIRECTUV = 0, o.OPACITYDIRECTUV = 0, o.EMISSIVEDIRECTUV = 0, o.SPECULARDIRECTUV = 0, o.LIGHTMAPDIRECTUV = 0, this._diffuseTexture && t.DiffuseTextureEnabled) { if (!this._diffuseTexture.isReadyOrNotBlocking()) return !1; zn.PrepareDefinesForMergedUV(this._diffuseTexture, o, "DIFFUSE") } else o.DIFFUSE = !1; if (this._ambientTexture && t.AmbientTextureEnabled) { if (!this._ambientTexture.isReadyOrNotBlocking()) return !1; zn.PrepareDefinesForMergedUV(this._ambientTexture, o, "AMBIENT") } else o.AMBIENT = !1; if (this._opacityTexture && t.OpacityTextureEnabled) { if (!this._opacityTexture.isReadyOrNotBlocking()) return !1; zn.PrepareDefinesForMergedUV(this._opacityTexture, o, "OPACITY"), o.OPACITYRGB = this._opacityTexture.getAlphaFromRGB } else o.OPACITY = !1; if (this._reflectionTexture && t.ReflectionTextureEnabled) { if (!this._reflectionTexture.isReadyOrNotBlocking()) return !1; switch (o._needNormals = !0, o.REFLECTION = !0, o.ROUGHNESS = this._roughness > 0, o.REFLECTIONOVERALPHA = this._useReflectionOverAlpha, o.INVERTCUBICMAP = this._reflectionTexture.coordinatesMode === vo.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 vo.EXPLICIT_MODE: o.setReflectionMode("REFLECTIONMAP_EXPLICIT"); break; case vo.PLANAR_MODE: o.setReflectionMode("REFLECTIONMAP_PLANAR"); break; case vo.PROJECTION_MODE: o.setReflectionMode("REFLECTIONMAP_PROJECTION"); break; case vo.SKYBOX_MODE: o.setReflectionMode("REFLECTIONMAP_SKYBOX"); break; case vo.SPHERICAL_MODE: o.setReflectionMode("REFLECTIONMAP_SPHERICAL"); break; case vo.EQUIRECTANGULAR_MODE: o.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR"); break; case vo.FIXED_EQUIRECTANGULAR_MODE: o.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED"); break; case vo.FIXED_EQUIRECTANGULAR_MIRRORED_MODE: o.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"); break; case vo.CUBIC_MODE: case vo.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; zn.PrepareDefinesForMergedUV(this._emissiveTexture, o, "EMISSIVE") } else o.EMISSIVE = !1; if (this._lightmapTexture && t.LightmapTextureEnabled) { if (!this._lightmapTexture.isReadyOrNotBlocking()) return !1; zn.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; zn.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; zn.PrepareDefinesForMergedUV(this._bumpTexture, o, "BUMP"), o.PARALLAX = this._useParallax, o.PARALLAXOCCLUSION = this._useParallaxOcclusion, o.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap } else o.BUMP = !1, o.PARALLAX = !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), zn.PrepareDefinesForMisc(e, n, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(e) || this._forceAlphaTest, o, this._applyDecalMapAfterDetailMap), zn.PrepareDefinesForFrameBoundValues(n, s, this, o, r, null, i.getRenderingMesh().hasThinInstances), this._eventInfo.defines = o, this._eventInfo.mesh = e, this._callbackPluginEventPrepareDefinesBeforeAttributes(this._eventInfo), zn.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 Ra; 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.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"), zn.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 = [Hi.PositionKind]; for (o.NORMAL && p.push(Hi.NormalKind), o.TANGENT && p.push(Hi.TangentKind), c = 1; c <= a.MAX_SUPPORTED_UV_SETS; ++c)o["UV" + c] && p.push("uv".concat(1 === c ? "" : c)); o.VERTEXCOLOR && p.push(Hi.ColorKind), zn.PrepareAttributesForBones(p, e, o, d), zn.PrepareAttributesForInstances(p, o), zn.PrepareAttributesForMorphTargets(p, e, o), zn.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(Gn.PrepareEffect, this._eventInfo), tc.AddUniforms(_), tc.AddSamplers(m), Ni && (Ni.PrepareUniforms(_, o), Ni.PrepareSamplers(m, o)), zn.PrepareUniformsAndSamplersList({ uniformsNames: _, uniformBuffersNames: g, samplers: m, defines: o, maxSimultaneousLights: this._maxSimultaneousLights }), wn(_); 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 && (fc.effect = E, fc.subMesh = i, this._onEffectCreatedObservable.notifyObservers(fc)), 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); zn.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), zn.BindTextureMatrix(this._diffuseTexture, c, "diffuse")), this._ambientTexture && t.AmbientTextureEnabled && (c.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level), zn.BindTextureMatrix(this._ambientTexture, c, "ambient")), this._opacityTexture && t.OpacityTextureEnabled && (c.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level), zn.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), zn.BindTextureMatrix(this._emissiveTexture, c, "emissive")), this._lightmapTexture && t.LightmapTextureEnabled && (c.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level), zn.BindTextureMatrix(this._lightmapTexture, c, "lightmap")), this._specularTexture && t.SpecularTextureEnabled && (c.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level), zn.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), zn.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), Vn(s, this, o), this.bindEyePosition(s) } else o.getEngine()._features.needToAlwaysBindUniformBuffers && (this._needToBindSceneUbo = !0); !l && this.isFrozen || (o.lightsEnabled && !this._disableLighting && zn.BindLights(o, i, s, a, this._maxSimultaneousLights), (o.fogEnabled && i.applyFog && o.fogMode !== Sr.FOGMODE_NONE || this._reflectionTexture || this._refractionTexture || i.receiveShadows || a.PREPASS) && this.bindView(s), zn.BindFogParameters(o, i, s), a.NUM_MORPH_INFLUENCERS && zn.BindMorphTargetParameters(i, s), a.BAKED_VERTEX_ANIMATION_TEXTURE && (null === (n = i.bakedVertexAnimationManager) || void 0 === n || n.bind(s, a.INSTANCES)), this.useLogarithmicDepth && zn.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 = Ue.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 = Ue.Parse((function () { return new t(e.name, i) }), e, i, r); return e.stencil && n.stencil.parse(e.stencil, i, r), Hn._parsePlugins(e, n, i, r), n }, Object.defineProperty(t, "DiffuseTextureEnabled", { get: function () { return ic.DiffuseTextureEnabled }, set: function (e) { ic.DiffuseTextureEnabled = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "DetailTextureEnabled", { get: function () { return ic.DetailTextureEnabled }, set: function (e) { ic.DetailTextureEnabled = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "AmbientTextureEnabled", { get: function () { return ic.AmbientTextureEnabled }, set: function (e) { ic.AmbientTextureEnabled = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "OpacityTextureEnabled", { get: function () { return ic.OpacityTextureEnabled }, set: function (e) { ic.OpacityTextureEnabled = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "ReflectionTextureEnabled", { get: function () { return ic.ReflectionTextureEnabled }, set: function (e) { ic.ReflectionTextureEnabled = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "EmissiveTextureEnabled", { get: function () { return ic.EmissiveTextureEnabled }, set: function (e) { ic.EmissiveTextureEnabled = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "SpecularTextureEnabled", { get: function () { return ic.SpecularTextureEnabled }, set: function (e) { ic.SpecularTextureEnabled = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "BumpTextureEnabled", { get: function () { return ic.BumpTextureEnabled }, set: function (e) { ic.BumpTextureEnabled = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "LightmapTextureEnabled", { get: function () { return ic.LightmapTextureEnabled }, set: function (e) { ic.LightmapTextureEnabled = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "RefractionTextureEnabled", { get: function () { return ic.RefractionTextureEnabled }, set: function (e) { ic.RefractionTextureEnabled = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "ColorGradingTextureEnabled", { get: function () { return ic.ColorGradingTextureEnabled }, set: function (e) { ic.ColorGradingTextureEnabled = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "FresnelEnabled", { get: function () { return ic.FresnelEnabled }, set: function (e) { ic.FresnelEnabled = e }, enumerable: !1, configurable: !0 }), X([Ae("diffuseTexture")], t.prototype, "_diffuseTexture", void 0), X([Se("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "diffuseTexture", void 0), X([Ae("ambientTexture")], t.prototype, "_ambientTexture", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientTexture", void 0), X([Ae("opacityTexture")], t.prototype, "_opacityTexture", void 0), X([Se("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "opacityTexture", void 0), X([Ae("reflectionTexture")], t.prototype, "_reflectionTexture", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionTexture", void 0), X([Ae("emissiveTexture")], t.prototype, "_emissiveTexture", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveTexture", void 0), X([Ae("specularTexture")], t.prototype, "_specularTexture", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "specularTexture", void 0), X([Ae("bumpTexture")], t.prototype, "_bumpTexture", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "bumpTexture", void 0), X([Ae("lightmapTexture")], t.prototype, "_lightmapTexture", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "lightmapTexture", void 0), X([Ae("refractionTexture")], t.prototype, "_refractionTexture", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "refractionTexture", void 0), X([Re("ambient")], t.prototype, "ambientColor", void 0), X([Re("diffuse")], t.prototype, "diffuseColor", void 0), X([Re("specular")], t.prototype, "specularColor", void 0), X([Re("emissive")], t.prototype, "emissiveColor", void 0), X([xe()], t.prototype, "specularPower", void 0), X([xe("useAlphaFromDiffuseTexture")], t.prototype, "_useAlphaFromDiffuseTexture", void 0), X([Se("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "useAlphaFromDiffuseTexture", void 0), X([xe("useEmissiveAsIllumination")], t.prototype, "_useEmissiveAsIllumination", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useEmissiveAsIllumination", void 0), X([xe("linkEmissiveWithDiffuse")], t.prototype, "_linkEmissiveWithDiffuse", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "linkEmissiveWithDiffuse", void 0), X([xe("useSpecularOverAlpha")], t.prototype, "_useSpecularOverAlpha", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useSpecularOverAlpha", void 0), X([xe("useReflectionOverAlpha")], t.prototype, "_useReflectionOverAlpha", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useReflectionOverAlpha", void 0), X([xe("disableLighting")], t.prototype, "_disableLighting", void 0), X([Se("_markAllSubMeshesAsLightsDirty")], t.prototype, "disableLighting", void 0), X([xe("useObjectSpaceNormalMap")], t.prototype, "_useObjectSpaceNormalMap", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useObjectSpaceNormalMap", void 0), X([xe("useParallax")], t.prototype, "_useParallax", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useParallax", void 0), X([xe("useParallaxOcclusion")], t.prototype, "_useParallaxOcclusion", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useParallaxOcclusion", void 0), X([xe()], t.prototype, "parallaxScaleBias", void 0), X([xe("roughness")], t.prototype, "_roughness", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "roughness", void 0), X([xe()], t.prototype, "indexOfRefraction", void 0), X([xe()], t.prototype, "invertRefractionY", void 0), X([xe()], t.prototype, "alphaCutOff", void 0), X([xe("useLightmapAsShadowmap")], t.prototype, "_useLightmapAsShadowmap", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useLightmapAsShadowmap", void 0), X([Ce("diffuseFresnelParameters")], t.prototype, "_diffuseFresnelParameters", void 0), X([Se("_markAllSubMeshesAsFresnelDirty")], t.prototype, "diffuseFresnelParameters", void 0), X([Ce("opacityFresnelParameters")], t.prototype, "_opacityFresnelParameters", void 0), X([Se("_markAllSubMeshesAsFresnelAndMiscDirty")], t.prototype, "opacityFresnelParameters", void 0), X([Ce("reflectionFresnelParameters")], t.prototype, "_reflectionFresnelParameters", void 0), X([Se("_markAllSubMeshesAsFresnelDirty")], t.prototype, "reflectionFresnelParameters", void 0), X([Ce("refractionFresnelParameters")], t.prototype, "_refractionFresnelParameters", void 0), X([Se("_markAllSubMeshesAsFresnelDirty")], t.prototype, "refractionFresnelParameters", void 0), X([Ce("emissiveFresnelParameters")], t.prototype, "_emissiveFresnelParameters", void 0), X([Se("_markAllSubMeshesAsFresnelDirty")], t.prototype, "emissiveFresnelParameters", void 0), X([xe("useReflectionFresnelFromSpecular")], t.prototype, "_useReflectionFresnelFromSpecular", void 0), X([Se("_markAllSubMeshesAsFresnelDirty")], t.prototype, "useReflectionFresnelFromSpecular", void 0), X([xe("useGlossinessFromSpecularMapAlpha")], t.prototype, "_useGlossinessFromSpecularMapAlpha", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useGlossinessFromSpecularMapAlpha", void 0), X([xe("maxSimultaneousLights")], t.prototype, "_maxSimultaneousLights", void 0), X([Se("_markAllSubMeshesAsLightsDirty")], t.prototype, "maxSimultaneousLights", void 0), X([xe("invertNormalMapX")], t.prototype, "_invertNormalMapX", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapX", void 0), X([xe("invertNormalMapY")], t.prototype, "_invertNormalMapY", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapY", void 0), X([xe("twoSidedLighting")], t.prototype, "_twoSidedLighting", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "twoSidedLighting", void 0), X([xe("applyDecalMapAfterDetailMap")], t.prototype, "_applyDecalMapAfterDetailMap", void 0), X([Se("_markAllSubMeshesAsMiscDirty")], t.prototype, "applyDecalMapAfterDetailMap", void 0), X([xe()], t.prototype, "useLogarithmicDepth", null), t }(ta); b("BABYLON.StandardMaterial", mc), Sr.DefaultMaterialFactory = function (e) { return new mc("default material", e) }, ti.prototype.createDynamicTexture = function (e, t, i, r) { var n = new Ht(this, It.Dynamic); return n.baseWidth = e, n.baseHeight = t, i && (e = this.needPOTTextures ? ti.GetExponentOfTwo(e, this._caps.maxTextureSize) : e, t = this.needPOTTextures ? ti.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 }, ti.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 gc = 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 = vo.CLAMP_ADDRESSMODE, c.wrapV = vo.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 }(vo); Ut.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 vc, yc, bc = 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 Ni } 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"]; Ni && (Ni.PrepareSamplers(i, this._defines), Ni.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([xe()], t.prototype, "_fromLinearSpace", void 0), t }(Ia), Tc = 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 }(), Ec = 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 Ht(this._engine, It.Unknown, !0); return i.width = e.width, i.height = e.height, i._hardwareTexture = new Zt(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 Wl(this._scene, a) : new es("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 }(), Sc = function (e) { function t(t) { var i = e.call(this, (function () { return t.framebufferWidth }), (function () { return t.framebufferHeight }), t, "XRWebGLLayer", (function (e) { return new xc(e.scene, i) })) || this; return i.layer = t, i } return W(t, e), t }(Tc), xc = 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 }(Ec), Ac = 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 }(), Rc = function () { function e(e, t) { void 0 === t && (t = Ac.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 Sc(i.xrLayer), i.onXRLayerInitObservable.notifyObservers(i.xrLayer), i.xrLayer }, this.canvasContext.makeXRCompatible ? [2, this.canvasContext.makeXRCompatible().then((function () { }), (function () { xi.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 }(), Cc = function (e) { function t(t) { var i = e.call(this, (function () { return t.framebufferWidth }), (function () { return t.framebufferHeight }), t, "XRWebGLLayer", (function (e) { return new Pc(e, i) })) || this; return i.layer = t, i } return W(t, e), t }(Tc), Pc = 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 }(Ec), Ic = 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 }(), Mc = 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 Ic(this) : ((e = e || Ac.GetDefaults(t)).canvasElement = e.canvasElement || t.getRenderingCanvas() || void 0, new Rc(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: this.session.requestAnimationFrame.bind(this.session), 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 Cc(e.baseLayer) : new Sc(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 Oc(e) { var t = e.height || 2, i = 0 === e.diameterTop ? 0 : e.diameterTop || e.diameter || 1, r = 0 === e.diameterBottom ? 0 : e.diameterBottom || e.diameter || 1; i = i || 1e-5, r = r || 1e-5; var n, o = 0 | (e.tessellation || 24), a = 0 | (e.subdivisions || 1), s = !!e.hasRings, l = !!e.enclose, c = 0 === e.cap ? 0 : e.cap || Jn.CAP_ALL, u = e.arc && (e.arc <= 0 || e.arc > 1) ? 1 : e.arc || 1, h = 0 === e.sideOrientation ? 0 : e.sideOrientation || En.DEFAULTSIDE, d = e.faceUV || new Array(3), p = e.faceColors, f = 2 + (1 + (1 !== u && l ? 2 : 0)) * (s ? a : 1); for (n = 0; n < f; n++)p && void 0 === p[n] && (p[n] = new U(1, 1, 1, 1)); for (n = 0; n < f; n++)d && void 0 === d[n] && (d[n] = new C(0, 0, 1, 1)); var _, m, g, v, y, b, T = new Array, E = new Array, S = new Array, x = new Array, P = new Array, I = 2 * Math.PI * u / o, M = (r - i) / 2 / t, O = R.Zero(), D = R.Zero(), N = R.Zero(), F = R.Zero(), L = R.Zero(), w = Ar.Y, B = 1, V = 1, k = 0, G = 0; for (v = 0; v <= a; v++)for (g = ((m = v / a) * (i - r) + r) / 2, B = s && 0 !== v && v !== a ? 2 : 1, b = 0; b < B; b++) { for (s && (V += b), l && (V += 2 * b), y = 0; y <= o; y++)_ = y * I, O.x = Math.cos(-_) * g, O.y = -t / 2 + m * t, O.z = Math.sin(-_) * g, 0 === i && v === a ? (D.x = S[S.length - 3 * (o + 1)], D.y = S[S.length - 3 * (o + 1) + 1], D.z = S[S.length - 3 * (o + 1) + 2]) : (D.x = O.x, D.z = O.z, D.y = Math.sqrt(D.x * D.x + D.z * D.z) * M, D.normalize()), 0 === y && (N.copyFrom(O), F.copyFrom(D)), E.push(O.x, O.y, O.z), S.push(D.x, D.y, D.z), G = s ? k !== V ? d[V].y : d[V].w : d[V].y + (d[V].w - d[V].y) * m, x.push(d[V].x + (d[V].z - d[V].x) * y / o, xn.UseOpenGLOrientationForUV ? 1 - G : G), p && P.push(p[V].r, p[V].g, p[V].b, p[V].a); 1 !== u && l && (E.push(O.x, O.y, O.z), E.push(0, O.y, 0), E.push(0, O.y, 0), E.push(N.x, N.y, N.z), R.CrossToRef(w, D, L), L.normalize(), S.push(L.x, L.y, L.z, L.x, L.y, L.z), R.CrossToRef(F, w, L), L.normalize(), S.push(L.x, L.y, L.z, L.x, L.y, L.z), G = s ? k !== V ? d[V + 1].y : d[V + 1].w : d[V + 1].y + (d[V + 1].w - d[V + 1].y) * m, x.push(d[V + 1].x, xn.UseOpenGLOrientationForUV ? 1 - G : G), x.push(d[V + 1].z, xn.UseOpenGLOrientationForUV ? 1 - G : G), G = s ? k !== V ? d[V + 2].y : d[V + 2].w : d[V + 2].y + (d[V + 2].w - d[V + 2].y) * m, x.push(d[V + 2].x, xn.UseOpenGLOrientationForUV ? 1 - G : G), x.push(d[V + 2].z, xn.UseOpenGLOrientationForUV ? 1 - G : G), p && (P.push(p[V + 1].r, p[V + 1].g, p[V + 1].b, p[V + 1].a), P.push(p[V + 1].r, p[V + 1].g, p[V + 1].b, p[V + 1].a), P.push(p[V + 2].r, p[V + 2].g, p[V + 2].b, p[V + 2].a), P.push(p[V + 2].r, p[V + 2].g, p[V + 2].b, p[V + 2].a))), k !== V && (k = V) } var z = 1 !== u && l ? o + 4 : o; for (v = 0, V = 0; V < a; V++) { var W = 0, H = 0, X = 0, j = 0; for (y = 0; y < o; y++)W = v * (z + 1) + y, H = (v + 1) * (z + 1) + y, X = v * (z + 1) + (y + 1), j = (v + 1) * (z + 1) + (y + 1), T.push(W, H, X), T.push(j, X, H); 1 !== u && l && (T.push(W + 2, H + 2, X + 2), T.push(j + 2, X + 2, H + 2), T.push(W + 4, H + 4, X + 4), T.push(j + 4, X + 4, H + 4)), v = s ? v + 2 : v + 1 } var Y = function (e) { var n = e ? i / 2 : r / 2; if (0 !== n) { var a, s, l, c = e ? d[f - 1] : d[0], h = null; p && (h = e ? p[f - 1] : p[0]); var _ = E.length / 3, m = e ? t / 2 : -t / 2, g = new R(0, m, 0); E.push(g.x, g.y, g.z), S.push(0, e ? 1 : -1, 0); var v = c.y + .5 * (c.w - c.y); x.push(c.x + .5 * (c.z - c.x), xn.UseOpenGLOrientationForUV ? 1 - v : v), h && P.push(h.r, h.g, h.b, h.a); var y = new A(.5, .5); for (l = 0; l <= o; l++) { a = 2 * Math.PI * l * u / o; var b = Math.cos(-a), C = Math.sin(-a); s = new R(b * n, m, C * n); var I = new A(b * y.x + .5, C * y.y + .5); E.push(s.x, s.y, s.z), S.push(0, e ? 1 : -1, 0); var M = c.y + (c.w - c.y) * I.y; x.push(c.x + (c.z - c.x) * I.x, xn.UseOpenGLOrientationForUV ? 1 - M : M), h && P.push(h.r, h.g, h.b, h.a) } for (l = 0; l < o; l++)e ? (T.push(_), T.push(_ + (l + 2)), T.push(_ + (l + 1))) : (T.push(_), T.push(_ + (l + 1)), T.push(_ + (l + 2))) } }; c !== Jn.CAP_START && c !== Jn.CAP_ALL || Y(!1), c !== Jn.CAP_END && c !== Jn.CAP_ALL || Y(!0), En._ComputeSides(h, E, T, S, x, e.frontUVs, e.backUVs); var K = new En; return K.indices = T, K.positions = E, K.normals = S, K.uvs = x, p && (K.colors = P), K } function Dc(e, t, i) { void 0 === t && (t = {}); var r = new Jn(e, i); return t.sideOrientation = Jn._GetDefaultSideOrientation(t.sideOrientation), r._originalBuilderSideOrientation = t.sideOrientation, Oc(t).applyToMesh(r, t.updatable), r } !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" }(vc || (vc = {})), function (e) { e[e.NOT_TRACKING = 0] = "NOT_TRACKING", e[e.TRACKING_LOST = 1] = "TRACKING_LOST", e[e.TRACKING = 2] = "TRACKING" }(yc || (yc = {})); var Nc = { CreateCylinder: Dc }; function Fc(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 || En.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, xn.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) } En._ComputeSides(l, i, t, r, n, e.frontUVs, e.backUVs); var x = new En; return x.indices = t, x.positions = i, x.normals = r, x.uvs = n, x } function Lc(e, t, i) { void 0 === t && (t = {}); var r = new Jn(e, i); return t.sideOrientation = Jn._GetDefaultSideOrientation(t.sideOrientation), r._originalBuilderSideOrientation = t.sideOrientation, Fc(t).applyToMesh(r, t.updatable), r } En.CreateCylinder = Oc, Jn.CreateCylinder = function (e, t, i, r, n, o, a, s, l) { return void 0 !== a && a instanceof Sr || (void 0 !== a && (l = s || Jn.DEFAULTSIDE, s = a), a = o, o = 1), Dc(e, { height: t, diameterTop: i, diameterBottom: r, tessellation: n, subdivisions: o, sideOrientation: l, updatable: s }, a) }; var wc = { CreateTorus: Lc }; En.CreateTorus = Fc, Jn.CreateTorus = function (e, t, i, r, n, o, a) { return Lc(e, { diameter: t, thickness: i, tessellation: r, sideOrientation: a, updatable: o }, n) }, Jn._GroundMeshParser = function (e, t) { return Bc.Parse(e, t) }; var Bc = 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._minX || 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, e < this._minX || e > this._maxX || t < this._minZ || t > this._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 t < n.slope.x * e + n.slope.y ? n.facet1 : n.facet2 }, t.prototype._initHeightQuads = function () { var e = this._subdivisionsX, t = this._subdivisionsY; this._heightQuads = new Array; for (var i = 0; i < t; i++)for (var r = 0; r < e; r++) { var n = { slope: A.Zero(), facet1: new C(0, 0, 0, 0), facet2: new C(0, 0, 0, 0) }; this._heightQuads[i * e + r] = n } return this }, t.prototype._computeHeightQuads = function () { var e = this.getVerticesData(Hi.PositionKind); if (!e) return this; for (var t = O.Vector3[3], i = O.Vector3[2], r = O.Vector3[1], n = O.Vector3[0], o = O.Vector3[4], a = O.Vector3[5], s = O.Vector3[6], l = O.Vector3[7], c = O.Vector3[8], u = 0, h = 0, d = 0, p = 0, f = 0, _ = 0, m = 0, g = this._subdivisionsX, v = this._subdivisionsY, y = 0; y < v; y++)for (var b = 0; b < g; b++) { u = 3 * b, h = y * (g + 1) * 3, d = (y + 1) * (g + 1) * 3, t.x = e[h + u], t.y = e[h + u + 1], t.z = e[h + u + 2], i.x = e[h + u + 3], i.y = e[h + u + 4], i.z = e[h + u + 5], r.x = e[d + u], r.y = e[d + u + 1], r.z = e[d + u + 2], n.x = e[d + u + 3], n.y = e[d + u + 4], n.z = e[d + u + 5], p = (n.z - t.z) / (n.x - t.x), f = t.z - p * t.x, i.subtractToRef(t, o), r.subtractToRef(t, a), n.subtractToRef(t, s), R.CrossToRef(s, a, l), R.CrossToRef(o, s, c), l.normalize(), c.normalize(), _ = -(l.x * t.x + l.y * t.y + l.z * t.z), m = -(c.x * i.x + c.y * i.y + c.z * i.z); var T = this._heightQuads[y * g + b]; T.slope.copyFromFloats(p, f), T.facet1.copyFromFloats(l.x, l.y, l.z, _), T.facet2.copyFromFloats(c.x, c.y, c.z, m) } return this }, t.prototype.serialize = function (t) { e.prototype.serialize.call(this, t), t.subdivisionsX = this._subdivisionsX, t.subdivisionsY = this._subdivisionsY, t.minX = this._minX, t.maxX = this._maxX, t.minZ = this._minZ, t.maxZ = this._maxZ, t.width = this._width, t.height = this._height }, t.Parse = function (e, i) { var r = new t(e.name, i); return r._subdivisionsX = e.subdivisionsX || 1, r._subdivisionsY = e.subdivisionsY || 1, r._minX = e.minX, r._maxX = e.maxX, r._minZ = e.minZ, r._maxZ = e.maxZ, r._width = e.width, r._height = e.height, r }, t }(Jn); function Uc(e) { var t, i, r = [], n = [], o = [], a = [], s = e.width || 1, l = e.height || 1, c = 0 | (e.subdivisionsX || e.subdivisions || 1), u = 0 | (e.subdivisionsY || e.subdivisions || 1); for (t = 0; t <= u; t++)for (i = 0; i <= c; i++) { var h = new R(i * s / c - s / 2, 0, (u - t) * l / u - l / 2), d = new R(0, 1, 0); n.push(h.x, h.y, h.z), o.push(d.x, d.y, d.z), a.push(i / c, xn.UseOpenGLOrientationForUV ? t / u : 1 - t / u) } for (t = 0; t < u; t++)for (i = 0; i < c; i++)r.push(i + 1 + (t + 1) * (c + 1)), r.push(i + 1 + t * (c + 1)), r.push(i + t * (c + 1)), r.push(i + (t + 1) * (c + 1)), r.push(i + 1 + (t + 1) * (c + 1)), r.push(i + t * (c + 1)); var p = new En; return p.indices = r, p.positions = n, p.normals = o, p.uvs = a, p } function Vc(e) { var t, i, r, n, o = void 0 !== e.xmin && null !== e.xmin ? e.xmin : -1, a = void 0 !== e.zmin && null !== e.zmin ? e.zmin : -1, s = void 0 !== e.xmax && null !== e.xmax ? e.xmax : 1, l = void 0 !== e.zmax && null !== e.zmax ? e.zmax : 1, c = e.subdivisions || { w: 1, h: 1 }, u = e.precision || { w: 1, h: 1 }, h = new Array, d = new Array, p = new Array, f = new Array; c.h = c.h < 1 ? 1 : c.h, c.w = c.w < 1 ? 1 : c.w, u.w = u.w < 1 ? 1 : u.w, u.h = u.h < 1 ? 1 : u.h; var _ = (s - o) / c.w, m = (l - a) / c.h; function g(e, r, n, o) { var a = d.length / 3, s = u.w + 1; for (t = 0; t < u.h; t++)for (i = 0; i < u.w; i++) { var l = [a + i + t * s, a + (i + 1) + t * s, a + (i + 1) + (t + 1) * s, a + i + (t + 1) * s]; h.push(l[1]), h.push(l[2]), h.push(l[3]), h.push(l[0]), h.push(l[1]), h.push(l[3]) } var c = R.Zero(), _ = new R(0, 1, 0); for (t = 0; t <= u.h; t++)for (c.z = t * (o - r) / u.h + r, i = 0; i <= u.w; i++)c.x = i * (n - e) / u.w + e, c.y = 0, d.push(c.x, c.y, c.z), p.push(_.x, _.y, _.z), f.push(i / u.w, t / u.h) } for (r = 0; r < c.h; r++)for (n = 0; n < c.w; n++)g(o + n * _, a + r * m, o + (n + 1) * _, a + (r + 1) * m); var v = new En; return v.indices = h, v.positions = d, v.normals = p, v.uvs = f, v } function kc(e) { var t, i, r = [], n = [], o = [], a = [], s = e.colorFilter || new B(.3, .59, .11), l = e.alphaFilter || 0, c = !1; if (e.minHeight > e.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.subdivisions; t++)for (i = 0; i < e.subdivisions; i++) { var y = i + 1 + (t + 1) * (e.subdivisions + 1), b = i + 1 + t * (e.subdivisions + 1), T = i + t * (e.subdivisions + 1), E = i + (t + 1) * (e.subdivisions + 1), S = n[3 * y + 1] >= 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)) } En.ComputeNormals(n, r, o); var C = new En; return C.indices = r, C.positions = n, C.normals = o, C.uvs = a, C } function Gc(e, t, i) { void 0 === t && (t = {}); var r = new Bc(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, Uc(t).applyToMesh(r, t.updatable), r._setReady(!0), r } function zc(e, t, i) { void 0 === i && (i = null); var r = new Jn(e, i); return Vc(t).applyToMesh(r, t.updatable), r } function Wc(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 Bc(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), xi.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); kc({ 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 Hc = { CreateGround: Gc, CreateGroundFromHeightMap: Wc, CreateTiledGround: zc }; En.CreateGround = Uc, En.CreateTiledGround = Vc, En.CreateGroundFromHeightMap = kc, Jn.CreateGround = function (e, t, i, r, n, o) { return Gc(e, { width: t, height: i, subdivisions: r, updatable: o }, n) }, Jn.CreateTiledGround = function (e, t, i, r, n, o, a, s, l) { return zc(e, { xmin: t, zmin: i, xmax: r, zmax: n, subdivisions: o, precision: a, updatable: l }, s) }, Jn.CreateGroundFromHeightMap = function (e, t, i, r, n, o, a, s, l, c, u) { return Wc(e, t, { width: i, height: r, subdivisions: n, minHeight: o, maxHeight: a, updatable: l, onReady: c, alphaFilter: u }, s) }; var Xc, jc = 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 = Lc("gazeTracker", { diameter: .0035, thickness: .0025, tessellation: 20, updatable: !1 }, t), this._gazeTracker.bakeCurrentTransformIntoVertices(), this._gazeTracker.isPickable = !1, this._gazeTracker.isVisible = !1; var r = new mc("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 Mo(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 }(), Yc = function (e) { function t(t, i, r) { var n = e.call(this, i, r) || this; n.webVRController = t, n._laserPointer = Dc("laserPointer", { updatable: !1, height: 1, diameterTop: .004, diameterBottom: 2e-4, tessellation: 20, subdivisions: 1 }, i); var o = new mc("laserPointerMat", i); if (o.emissiveColor = new B(.7, .7, .7), o.alpha = .6, n._laserPointer.material = o, n._laserPointer.rotation.x = Math.PI / 2, n._laserPointer.position.z = -.5, n._laserPointer.isVisible = !1, n._laserPointer.isPickable = !1, !t.mesh) { var a = new Jn("preloadControllerMesh", i), s = new Jn(_l.POINTING_POSE, i); s.rotation.x = -.7, a.addChild(s), t.attachToMesh(a) } return n._setLaserPointerParent(t.mesh), n._meshAttachedObserver = t._meshAttachedObservable.add((function (e) { n._setLaserPointerParent(e) })), n } return W(t, e), t.prototype._getForwardRay = function (e) { return this.webVRController.getForwardRay(e) }, t.prototype._activatePointer = function () { e.prototype._activatePointer.call(this), this._laserPointer.isVisible = !0 }, t.prototype._deactivatePointer = function () { e.prototype._deactivatePointer.call(this), this._laserPointer.isVisible = !1 }, t.prototype._setLaserPointerColor = function (e) { this._laserPointer.material.emissiveColor = e }, t.prototype._setLaserPointerLightingDisabled = function (e) { this._laserPointer.material.disableLighting = e }, t.prototype._setLaserPointerParent = function (e) { var t = function (e) { e.isPickable = !1, e.getChildMeshes().forEach((function (e) { t(e) })) }; t(e); var i = e.getChildren(void 0, !1), r = e; this.webVRController._pointingPoseNode = null; for (var n = 0; n < i.length; n++)if (i[n].name && i[n].name.indexOf(_l.POINTING_POSE) >= 0) { r = i[n], this.webVRController._pointingPoseNode = r; break } this._laserPointer.parent = r }, t.prototype._updatePointerDistance = function (e) { void 0 === e && (e = 100), this._laserPointer.scaling.y = e, this._laserPointer.position.z = -e / 2 }, t.prototype.dispose = function () { e.prototype.dispose.call(this), this._laserPointer.dispose(), this._meshAttachedObserver && this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver) }, t }(jc), Kc = 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 Mo(R.Zero(), R.Forward()) }, t }(jc), Qc = function () { }, qc = function () { function e(t, i) { void 0 === i && (i = {}); var r = this; if (this.webVROptions = i, this._webVRsupported = !1, this._webVRready = !1, this._webVRrequesting = !1, this._webVRpresenting = !1, this._fullscreenVRpresenting = !1, this.enableGazeEvenWhenNoPointerLock = !1, this.exitVROnDoubleTap = !0, this.onEnteringVRObservable = new u, this.onAfterEnteringVRObservable = new u, this.onExitingVRObservable = new u, this.onControllerMeshLoadedObservable = new u, this._useCustomVRButton = !1, this._teleportationRequested = !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._leftController = null, this._rightController = null, this._gazeColor = new B(.7, .7, .7), this._laserColor = new B(.7, .7, .7), this._pickedLaserColor = new B(.2, .2, 1), this._pickedGazeColor = new B(0, 0, 1), this.onNewMeshSelected = new u, this.onMeshSelectedWithController = 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._interactionsRequested = !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(), r._fullscreenVRpresenting && r._webVRready && r.exitVR() }, 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._leftController && r._leftController._activePointer && r._castRayAndSelectObject(r._leftController), r._rightController && r._rightController._activePointer && r._castRayAndSelectObject(r._rightController), r._noControllerIsActive && (r._scene.getEngine().isPointerLock || r.enableGazeEvenWhenNoPointerLock) ? r._castRayAndSelectObject(r._cameraGazer) : r._cameraGazer._gazeTracker.isVisible = !1 }, this._onNewGamepadConnected = function (e) { if (e.type !== Os.POSE_ENABLED) e.leftStick && e.onleftstickchanged((function (e) { r._teleportationInitialized && r.teleportationEnabled && (!r._leftController && !r._rightController || r._leftController && !r._leftController._activePointer && r._rightController && !r._rightController._activePointer) && (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 === Os.XBOX && (e.onbuttondown((function (e) { r._interactionsEnabled && e === dl.A && r._cameraGazer._selectionPointerDown() })), e.onbuttonup((function (e) { r._interactionsEnabled && e === dl.A && r._cameraGazer._selectionPointerUp() }))); else { var t = e, i = new Yc(t, r._scene, r._cameraGazer._gazeTracker); "right" === t.hand || r._leftController && r._leftController.webVRController != t ? r._rightController = i : r._leftController = i, r._tryEnableInteractionOnController(i) } }, this._tryEnableInteractionOnController = function (e) { r._interactionsRequested && !e._interactionsEnabled && r._enableInteractionOnController(e), r._teleportationRequested && !e._teleportationEnabled && r._enableTeleportationOnController(e) }, this._onNewGamepadDisconnected = function (e) { e instanceof ec && ("left" === e.hand && null != r._leftController && (r._leftController.dispose(), r._leftController = null), "right" === e.hand && null != r._rightController && (r._rightController.dispose(), r._rightController = null)) }, 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), void 0 === i.defaultHeight && (i.defaultHeight = 1.7), i.useCustomVRButton && (this._useCustomVRButton = !0, i.customVRButton && (this._btnVR = i.customVRButton)), i.rayLength && (this._rayLength = i.rayLength), this._defaultHeight = i.defaultHeight, i.positionScale && (this._rayLength *= i.positionScale, this._defaultHeight *= i.positionScale), 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 ol("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 tl && 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 ? Mc.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 Kc((function () { return r.xr.baseExperience.camera }), t), r.xr.baseExperience.onStateChangedObservable.add((function (e) { switch (e) { case vc.ENTERING_XR: r.onEnteringVRObservable.notifyObservers(r), r._interactionsEnabled || r.xr.pointerSelection.detach(), r.xr.pointerSelection.displayLaserPointer = r._displayLaserPointer; break; case vc.EXITING_XR: r.onExitingVRObservable.notifyObservers(r), r._scene.getEngine().resize(); break; case vc.IN_XR: r._hasEnteredVR = !0; break; case vc.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, "onControllerMeshLoaded", { get: function () { return this.onControllerMeshLoadedObservable }, 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._leftController && this._leftController._gazeTracker && this._leftController._gazeTracker.dispose(), this._rightController && this._rightController._gazeTracker && this._rightController._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", this._leftController && (this._leftController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker")), this._rightController && (this._rightController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker"))) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "leftControllerGazeTrackerMesh", { get: function () { return this._leftController ? this._leftController._gazeTracker : null }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "rightControllerGazeTrackerMesh", { get: function () { return this._rightController ? this._rightController._gazeTracker : null }, 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, this._leftController && (this._leftController._gazeTracker.isVisible = !1), this._rightController && (this._rightController._gazeTracker.isVisible = !1)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "displayLaserPointer", { get: function () { return this._displayLaserPointer }, set: function (e) { this._displayLaserPointer = e, e ? (this._rightController && this._rightController._activatePointer(), this._leftController && this._leftController._activatePointer()) : (this._rightController && (this._rightController._deactivatePointer(), this._rightController._gazeTracker.isVisible = !1), this._leftController && (this._leftController._deactivatePointer(), this._leftController._gazeTracker.isVisible = !1)) }, 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._webVRready ? this._webVRCamera : this._scene.activeCamera }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "webVRCamera", { get: function () { return this._webVRCamera }, 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 || null !== this._leftController && this._leftController._teleportationRequestInitiated || null !== this._rightController && this._rightController._teleportationRequestInitiated }, enumerable: !1, configurable: !0 }), e.prototype._completeVRInit = function (e, t) { var i = this; if (this.xrTestDone = !0, t.createFallbackVRDeviceOrientationFreeCamera && (t.useMultiview && (t.vrDeviceOrientationCameraMetrics || (t.vrDeviceOrientationCameraMetrics = Gl.GetDefault()), t.vrDeviceOrientationCameraMetrics.multiviewEnabled = !0), this._vrDeviceOrientationCamera = new Ql("VRDeviceOrientationVRHelper", this._position, this._scene, !0, t.vrDeviceOrientationCameraMetrics), this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE), this._webVRCamera = new $l("WebVRHelper", this._position, this._scene, t), this._webVRCamera.useStandingMatrix(), this._cameraGazer = new Kc((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._scene.getEngine().disableVR() : 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._scene.getEngine().onVRDisplayChangedObservable.add((function (e) { e.vrDisplay && i._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()) }), Ji.POINTERDOUBLETAP, !1), this._onVRDisplayChangedBind = function (e) { return i._onVRDisplayChanged(e) }, this._onVrDisplayPresentChangeBind = function () { return i._onVrDisplayPresentChange() }, this._onVRRequestPresentStart = function () { i._webVRrequesting = !0, i._updateButtonVisibility() }, this._onVRRequestPresentComplete = function () { i._webVRrequesting = !1, i._updateButtonVisibility() }, e.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChangedBind), e.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart), e.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete), o.addEventListener("vrdisplaypresentchange", this._onVrDisplayPresentChangeBind), e.onDisposeObservable.add((function () { i.dispose() })), this._webVRCamera.onControllerMeshLoadedObservable.add((function (e) { return i._onDefaultMeshLoaded(e) })), this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected), this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected), this._updateButtonVisibility(), this._circleEase = new Br, this._circleEase.setEasingMode(wr.EASINGMODE_EASEINOUT), this._teleportationEasing = this._circleEase, e.onPointerObservable.add((function (t) { i._interactionsEnabled && e.activeCamera === i.vrDeviceOrientationCamera && "mouse" === t.event.pointerType && (t.type === Ji.POINTERDOWN ? i._cameraGazer._selectionPointerDown() : t.type === Ji.POINTERUP && i._cameraGazer._selectionPointerUp()) })), this.webVROptions.floorMeshes && this.enableTeleportation({ floorMeshes: this.webVROptions.floorMeshes })) }, e.prototype._onDefaultMeshLoaded = function (e) { this._leftController && this._leftController.webVRController == e && e.mesh && this._leftController._setLaserPointerParent(e.mesh), this._rightController && this._rightController.webVRController == e && e.mesh && this._rightController._setLaserPointerParent(e.mesh); try { this.onControllerMeshLoadedObservable.notifyObservers(e) } catch (e) { $.Warn("Error in your custom logic onControllerMeshLoaded: " + e) } }, Object.defineProperty(e.prototype, "isInVRMode", { get: function () { return this.xr && this.webVROptions.useXR && this.xr.baseExperience.state === vc.IN_XR || this._webVRpresenting || this._fullscreenVRpresenting }, enumerable: !1, configurable: !0 }), e.prototype._onVrDisplayPresentChange = function () { var e = this._scene.getEngine().getVRDevice(); if (e) { var t = this._webVRpresenting; this._webVRpresenting = e.isPresenting, t && !this._webVRpresenting && this.exitVR() } else $.Warn("Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?"); this._updateButtonVisibility() }, e.prototype._onVRDisplayChanged = function (e) { this._webVRsupported = e.vrSupported, this._webVRready = !!e.vrDisplay, this._webVRpresenting = e.vrDisplay && e.vrDisplay.isPresenting, this._updateButtonVisibility() }, 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" : (this._webVRready && (this._btnVR.className += " vrdisplayready"), this._webVRsupported && (this._btnVR.className += " vrdisplaysupported"), this._webVRrequesting && (this._btnVR.className += " vrdisplayrequesting"))) }, 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) } if (this._scene.activeCamera) { if (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.webVRCamera) { var t = this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y, i = P.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y - t, r = this.webVRCamera.rotationQuaternion.toEulerAngles().y; this.webVRCamera.rotationQuaternion = P.FromEulerAngles(0, r + i, 0) } 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._webVRrequesting || (this._webVRready ? this._webVRpresenting || (this._scene.getEngine().onVRRequestPresentComplete.addOnce((function (t) { e.onAfterEnteringVRObservable.notifyObservers({ success: t }) })), this._webVRCamera.position = this._position, this._scene.activeCamera = this._webVRCamera) : 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._displayLaserPointer && [this._leftController, this._rightController].forEach((function (e) { e && e._activatePointer() })), 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._webVRpresenting && this._scene.getEngine().disableVR(), 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._leftController && (this._leftController._gazeTracker.isVisible = !1), this._rightController && (this._rightController._gazeTracker.isVisible = !1)), this._scene.getEngine().resize(), [this._leftController, this._rightController].forEach((function (e) { e && e._deactivatePointer() })), this._hasEnteredVR = !1; var e = this._scene.getEngine(); e._onVrDisplayPresentChange && e._onVrDisplayPresentChange() } }, 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._interactionsRequested = !0, this.xr) return void (this.xr.baseExperience.state === vc.IN_XR && this.xr.pointerSelection.attach()); this._leftController && this._enableInteractionOnController(this._leftController), this._rightController && this._enableInteractionOnController(this._rightController), 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 } }, Object.defineProperty(e.prototype, "_noControllerIsActive", { get: function () { return !(this._leftController && this._leftController._activePointer || this._rightController && this._rightController._activePointer) }, enumerable: !1, configurable: !0 }), e.prototype._isTeleportationFloor = function (e) { for (var t = 0; t < this._floorMeshesCollection.length; t++)if (this._floorMeshesCollection[t].id === e.id) return !0; return !(!this._floorMeshName || e.name !== this._floorMeshName) }, e.prototype.addFloorMesh = function (e) { this._floorMeshesCollection && (this._floorMeshesCollection.indexOf(e) > -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._teleportationRequested = !0, 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), null != this._leftController && this._enableTeleportationOnController(this._leftController), null != this._rightController && this._enableTeleportationOnController(this._rightController); var o = new Ni; o.vignetteColor = new U(0, 0, 0, 0), o.vignetteEnabled = !0, this._postProcessMove = new bc("postProcessMove", 1, this._webVRCamera, void 0, void 0, void 0, void 0, o), this._webVRCamera.detachPostProcess(this._postProcessMove), this._teleportationInitialized = !0, this._isDefaultTeleportationTarget && (this._createTeleportationCircles(), this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor)) } }, e.prototype._enableInteractionOnController = function (e) { var t = this; e.webVRController.mesh && (e._interactionsEnabled = !0, this.isInVRMode && this._displayLaserPointer && e._activatePointer(), this.webVROptions.laserToggle && e.webVRController.onMainButtonStateChangedObservable.add((function (i) { t._displayLaserPointer && 1 === i.value && (e._activePointer ? e._deactivatePointer() : e._activatePointer(), t.displayGaze && (e._gazeTracker.isVisible = e._activePointer)) })), e.webVRController.onTriggerStateChangedObservable.add((function (i) { var r = e; t._noControllerIsActive && (r = t._cameraGazer), r._pointerDownOnMeshAsked ? i.value < t._padSensibilityDown && r._selectionPointerUp() : i.value > t._padSensibilityUp && r._selectionPointerDown() }))) }, e.prototype._checkTeleportWithRay = function (e, t) { this._teleportationRequestInitiated && !t._teleportationRequestInitiated || (t._teleportationRequestInitiated ? Math.sqrt(e.y * e.y + e.x * e.x) < this._padSensibilityDown && (this._teleportActive && this.teleportCamera(this._haloCenter), t._teleportationRequestInitiated = !1) : e.y < -this._padSensibilityUp && t._dpadPressed && (t._activatePointer(), t._teleportationRequestInitiated = !0)) }, e.prototype._checkRotate = function (e, t) { t._teleportationRequestInitiated || (t._rotationLeftAsked ? e.x > -this._padSensibilityDown && (t._rotationLeftAsked = !1) : e.x < -this._padSensibilityUp && t._dpadPressed && (t._rotationLeftAsked = !0, this._rotationAllowed && this._rotateCamera(!1)), t._rotationRightAsked ? e.x < this._padSensibilityDown && (t._rotationRightAsked = !1) : e.x > this._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; this.currentVRCamera.devicePosition && this.currentVRCamera.deviceRotationQuaternion && (i = this.currentVRCamera.deviceRotationQuaternion, r = this.currentVRCamera.devicePosition), 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 Mo(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._enableTeleportationOnController = function (e) { var t = this; e.webVRController.mesh && (e._interactionsEnabled || this._enableInteractionOnController(e), e._interactionsEnabled = !0, e._teleportationEnabled = !0, e.webVRController.controllerType === cl.VIVE && (e._dpadPressed = !1, e.webVRController.onPadStateChangedObservable.add((function (t) { e._dpadPressed = t.pressed, e._dpadPressed || (e._rotationLeftAsked = !1, e._rotationRightAsked = !1, e._teleportationBackRequestInitiated = !1) }))), e.webVRController.onPadValuesChangedObservable.add((function (i) { t.teleportationEnabled && (t._checkTeleportBackwards(i, e), t._checkTeleportWithRay(i, e)), t._checkRotate(i, e) }))) }, e.prototype._createTeleportationCircles = function () { this._teleportationTarget = Gc("teleportationTarget", { width: 2, height: 2, subdivisions: 2 }, this._scene), this._teleportationTarget.isPickable = !1; var e = new gc("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 mc("TextPlaneMaterial", this._scene); i.diffuseTexture = e, this._teleportationTarget.material = i; var r = Lc("torusTeleportation", { diameter: .75, thickness: .1, tessellation: 25, updatable: !1 }, this._scene); r.isPickable = !1, r.parent = this._teleportationTarget; var n = new je("animationInnerCircle", "position.y", 30, je.ANIMATIONTYPE_FLOAT, je.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 Yr; a.setEasingMode(wr.EASINGMODE_EASEINOUT), n.setEasingFunction(a), r.animations = [], r.animations.push(n), this._scene.beginAnimation(r, 0, 60, !0), this._hideTeleportationTarget() }, e.prototype._displayTeleportationTarget = function () { this._teleportActive = !0, this._teleportationInitialized && (this._teleportationTarget.isVisible = !0, this._isDefaultTeleportationTarget && (this._teleportationTarget.getChildren()[0].isVisible = !0)) }, 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) { var t = this; if (this.currentVRCamera instanceof il) { e ? this._rotationAngle++ : this._rotationAngle--, this.currentVRCamera.animations = []; var i = P.FromRotationMatrix(I.RotationY(Math.PI / 4 * this._rotationAngle)), r = new je("animationRotation", "rotationQuaternion", 90, je.ANIMATIONTYPE_QUATERNION, je.ANIMATIONLOOPMODE_CONSTANT), n = []; n.push({ frame: 0, value: this.currentVRCamera.rotationQuaternion }), n.push({ frame: 6, value: i }), r.setKeys(n), r.setEasingFunction(this._circleEase), this.currentVRCamera.animations.push(r), this._postProcessMove.animations = []; var o = new je("animationPP", "vignetteWeight", 90, je.ANIMATIONTYPE_FLOAT, je.ANIMATIONLOOPMODE_CONSTANT), a = []; a.push({ frame: 0, value: 0 }), a.push({ frame: 3, value: 4 }), a.push({ frame: 6, value: 0 }), o.setKeys(a), o.setEasingFunction(this._circleEase), this._postProcessMove.animations.push(o); var s = new je("animationPP2", "vignetteStretch", 90, je.ANIMATIONTYPE_FLOAT, je.ANIMATIONLOOPMODE_CONSTANT), l = []; l.push({ frame: 0, value: 0 }), l.push({ frame: 3, value: 10 }), l.push({ frame: 6, value: 0 }), s.setKeys(l), s.setEasingFunction(this._circleEase), this._postProcessMove.animations.push(s), this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0, this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0, this._postProcessMove.samples = 4, this._webVRCamera.attachPostProcess(this._postProcessMove), this._scene.beginAnimation(this._postProcessMove, 0, 6, !1, 1, (function () { t._webVRCamera.detachPostProcess(t._postProcessMove) })), this._scene.beginAnimation(this.currentVRCamera, 0, 6, !1, 1) } }, e.prototype._moveTeleportationSelectorTo = function (e, t, i) { if (e.pickedPoint) { t._teleportationRequestInitiated && (this._displayTeleportationTarget(), this._haloCenter.copyFrom(e.pickedPoint), this._teleportationTarget.position.copyFrom(e.pickedPoint)); var r = this._convertNormalToDirectionOfRay(e.getNormal(!0, !1), i); if (r) { var n = R.Cross(Ar.Y, r), o = R.Cross(r, n); R.RotationFromAxisToRef(o, r, n, this._teleportationTarget.rotation) } this._teleportationTarget.position.y += .1 } }, e.prototype.teleportCamera = function (t) { var i = this; if (this.currentVRCamera instanceof il) { var r, n; if (this.webVRCamera.leftCamera ? (this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition), this._workingVector.subtractInPlace(this.webVRCamera.position), t.subtractToRef(this._workingVector, this._workingVector)) : this._workingVector.copyFrom(t), this.isInVRMode ? this._workingVector.y += this.webVRCamera.deviceDistanceToRoomGround() * this._webVRCamera.deviceScaleFactor : 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 je("animationCameraTeleportation", "position", 90, je.ANIMATIONTYPE_VECTOR3, je.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 je("animationPP", "vignetteWeight", 90, je.ANIMATIONTYPE_FLOAT, je.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 je("animationPP2", "vignetteStretch", 90, je.ANIMATIONTYPE_FLOAT, je.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._webVRCamera.attachPostProcess(this._postProcessMove), this._scene.beginAnimation(this._postProcessMove, 0, n, !1, r, (function () { i._webVRCamera.detachPostProcess(i._postProcessMove) })), this._scene.beginAnimation(this.currentVRCamera, 0, n, !1, r, (function () { i.onAfterCameraTeleport.notifyObservers(i._workingVector) })), this._hideTeleportationTarget() } }, e.prototype._convertNormalToDirectionOfRay = function (e, t) { return e && Math.acos(R.Dot(e, t.direction)) < Math.PI / 2 && e.scaleInPlace(-1), e }, e.prototype._castRayAndSelectObject = function (e) { if (this.currentVRCamera instanceof il) { var t = e._getForwardRay(this._rayLength), i = this._scene.pickWithRay(t, this._raySelectionPredicate); if (i && this._scene.simulatePointerMove(i, { pointerId: e._id }), e._currentHit = i, i && i.pickedPoint) { if (this._displayGaze) { var r = 1; e._gazeTracker.isVisible = !0, e._isActionableMesh && (r = 3), this.updateGazeTrackerScale && (e._gazeTracker.scaling.x = i.distance * r, e._gazeTracker.scaling.y = i.distance * r, e._gazeTracker.scaling.z = i.distance * r); var n = this._convertNormalToDirectionOfRay(i.getNormal(), t), o = .002; if (n) { var a = R.Cross(Ar.Y, n), s = R.Cross(n, a); R.RotationFromAxisToRef(s, n, a, e._gazeTracker.rotation) } e._gazeTracker.position.copyFrom(i.pickedPoint), e._gazeTracker.position.x < 0 ? e._gazeTracker.position.x += o : e._gazeTracker.position.x -= o, e._gazeTracker.position.y < 0 ? e._gazeTracker.position.y += o : e._gazeTracker.position.y -= o, e._gazeTracker.position.z < 0 ? e._gazeTracker.position.z += o : e._gazeTracker.position.z -= o } e._updatePointerDistance(i.distance) } else e._updatePointerDistance(), e._gazeTracker.isVisible = !1; if (i && i.pickedMesh) { if (this._teleportationInitialized && this._isTeleportationFloor(i.pickedMesh) && i.pickedPoint) return e._currentMeshSelected && !this._isTeleportationFloor(e._currentMeshSelected) && this._notifySelectedMeshUnselected(e._currentMeshSelected), e._currentMeshSelected = null, void (e._teleportationRequestInitiated && this._moveTeleportationSelectorTo(i, e, t)); if (i.pickedMesh !== e._currentMeshSelected) if (this.meshSelectionPredicate(i.pickedMesh)) { this.onNewMeshPicked.notifyObservers(i), e._currentMeshSelected = i.pickedMesh, i.pickedMesh.isPickable && i.pickedMesh.actionManager ? (this.changeGazeColor(this._pickedGazeColor), this.changeLaserColor(this._pickedLaserColor), e._isActionableMesh = !0) : (this.changeGazeColor(this._gazeColor), this.changeLaserColor(this._laserColor), e._isActionableMesh = !1); try { this.onNewMeshSelected.notifyObservers(i.pickedMesh); var l = e; l.webVRController && this.onMeshSelectedWithController.notifyObservers({ mesh: i.pickedMesh, controller: l.webVRController }) } catch (e) { $.Warn("Error while raising onNewMeshSelected or onMeshSelectedWithController: " + e) } } else this._notifySelectedMeshUnselected(e._currentMeshSelected), e._currentMeshSelected = null, this.changeGazeColor(this._gazeColor), this.changeLaserColor(this._laserColor) } else this._notifySelectedMeshUnselected(e._currentMeshSelected), e._currentMeshSelected = null, this.changeGazeColor(this._gazeColor), this.changeLaserColor(this._laserColor) } }, e.prototype._notifySelectedMeshUnselected = function (e) { e && this.onSelectedMeshUnselected.notifyObservers(e) }, e.prototype.setLaserColor = function (e, t) { void 0 === t && (t = this._pickedLaserColor), this._laserColor = e, this._pickedLaserColor = t }, e.prototype.setLaserLightingState = function (e) { void 0 === e && (e = !0), this._leftController && this._leftController._setLaserPointerLightingDisabled(!e), this._rightController && this._rightController._setLaserPointerLightingDisabled(!e) }, e.prototype.setGazeColor = function (e, t) { void 0 === t && (t = this._pickedGazeColor), this._gazeColor = e, this._pickedGazeColor = t }, e.prototype.changeLaserColor = function (e) { this.updateControllerLaserColor && (this._leftController && this._leftController._setLaserPointerColor(e), this._rightController && this._rightController._setLaserPointerColor(e)) }, e.prototype.changeGazeColor = function (e) { this.updateGazeTrackerColor && this._cameraGazer._gazeTracker.material && (this._cameraGazer._gazeTracker.material.emissiveColor = e, this._leftController && (this._leftController._gazeTracker.material.emissiveColor = e), this._rightController && (this._rightController._gazeTracker.material.emissiveColor = e)) }, e.prototype.dispose = function () { this.isInVRMode && this.exitVR(), this._postProcessMove && this._postProcessMove.dispose(), this._webVRCamera && this._webVRCamera.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._leftController && this._leftController.dispose(), this._rightController && this._rightController.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.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChangedBind), this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart), this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete), this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected), this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected), this._scene.unregisterBeforeRender(this._beforeRender) }, e.prototype.getClassName = function () { return "VRExperienceHelper" }, e.TELEPORTATIONMODE_CONSTANTTIME = 0, e.TELEPORTATIONMODE_CONSTANTSPEED = 1, e }(), Zc = (Xc = { root: 0, found: !1 }, function (e, t, i, r) { Xc.root = 0, Xc.found = !1; var n = t * t - 4 * e * i; if (n < 0) return Xc; 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 && a < r ? (Xc.root = a, Xc.found = !0, Xc) : s > 0 && s < r ? (Xc.root = s, Xc.found = !0, Xc) : Xc }), Jc = function () { function e() { this._collisionPoint = R.Zero(), this._planeIntersectionPoint = R.Zero(), this._tempVector = R.Zero(), this._tempVector2 = R.Zero(), this._tempVector3 = R.Zero(), this._tempVector4 = R.Zero(), this._edge = R.Zero(), this._baseToVertex = R.Zero(), this._destinationPoint = R.Zero(), this._slidePlaneNormal = R.Zero(), this._displacementVector = R.Zero(), this._radius = R.One(), this._retry = 0, this._basePointWorld = R.Zero(), this._velocityWorld = R.Zero(), this._normalizedVelocity = R.Zero(), this._collisionMask = -1 } return Object.defineProperty(e.prototype, "collisionMask", { get: function () { return this._collisionMask }, set: function (e) { this._collisionMask = isNaN(e) ? -1 : e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "slidePlaneNormal", { get: function () { return this._slidePlaneNormal }, enumerable: !1, configurable: !0 }), e.prototype._initialize = function (e, t, i) { this._velocity = t, this._velocitySquaredLength = this._velocity.lengthSquared(); var r = Math.sqrt(this._velocitySquaredLength); 0 === r || 1 === r ? this._normalizedVelocity.copyFromFloats(t._x, t._y, t._z) : t.scaleToRef(1 / r, this._normalizedVelocity), this._basePoint = e, e.multiplyToRef(this._radius, this._basePointWorld), t.multiplyToRef(this._radius, this._velocityWorld), this._velocityWorldLength = this._velocityWorld.length(), this._epsilon = i, this.collisionFound = !1 }, e.prototype._checkPointInTriangle = function (e, t, i, r, n) { t.subtractToRef(e, this._tempVector), i.subtractToRef(e, this._tempVector2), R.CrossToRef(this._tempVector, this._tempVector2, this._tempVector4); var o = R.Dot(this._tempVector4, n); return !(o < 0) && (r.subtractToRef(e, this._tempVector3), R.CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4), !((o = R.Dot(this._tempVector4, n)) < 0) && (R.CrossToRef(this._tempVector3, this._tempVector, this._tempVector4), (o = R.Dot(this._tempVector4, n)) >= 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 gr(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 = Zc(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 = Zc(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 = Zc(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 = Zc(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 = Zc(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 = Zc(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 < this._nearestDistanceSquared) && (s.collisionResponse && (this.intersectionPoint ? this.intersectionPoint.copyFrom(this._collisionPoint) : this.intersectionPoint = this._collisionPoint.clone(), this._nearestDistanceSquared = A, this._nearestDistance = Math.sqrt(A), this.collisionFound = !0), this.collidedMesh = s) } } } }, e.prototype._collide = function (e, t, i, r, n, o, a, s, l, c) { if (void 0 === c && (c = !1), c) if (i && 0 !== i.length) for (p = r; p < n - 2; p += 1) { var u = i[p], h = i[p + 1], d = i[p + 2]; 4294967295 !== d ? (f = t[u], _ = t[h], m = t[d], f && _ && m && ((l ? 1 : 0) ^ p % 2 ? this._testTriangle(p, e, f, _, m, a, s) : this._testTriangle(p, e, _, f, m, a, s))) : p += 2 } else for (var p = 0; p < t.length - 2; p += 1) { var f = t[p], _ = t[p + 1], m = t[p + 2]; f && _ && m && ((l ? 1 : 0) ^ p % 2 ? this._testTriangle(p, e, f, _, m, a, s) : this._testTriangle(p, e, _, f, m, a, s)) } else if (i && 0 !== i.length) for (p = r; p < n; p += 3)f = t[i[p] - o], _ = t[i[p + 1] - o], m = t[i[p + 2] - o], l ? this._testTriangle(p, e, f, _, m, a, s) : this._testTriangle(p, e, m, _, f, a, s); else for (p = 0; p < t.length; p += 3) { f = t[p], _ = t[p + 1], m = t[p + 2]; l ? this._testTriangle(p, e, f, _, m, a, s) : this._testTriangle(p, e, m, _, f, a, s) } }, e.prototype._getResponse = function (e, t) { e.addToRef(t, this._destinationPoint), t.scaleInPlace(this._nearestDistance / t.length()), this._basePoint.addToRef(t, e), e.subtractToRef(this.intersectionPoint, this._slidePlaneNormal), this._slidePlaneNormal.normalize(), this._slidePlaneNormal.scaleToRef(this._epsilon, this._displacementVector), e.addInPlace(this._displacementVector), this.intersectionPoint.addInPlace(this._displacementVector), this._slidePlaneNormal.scaleInPlace(gr.SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint)), this._destinationPoint.subtractInPlace(this._slidePlaneNormal), this._destinationPoint.subtractToRef(this.intersectionPoint, t) }, e.DoubleSidedCheck = !1, e }(), $c = function () { function e() { this._scaledPosition = R.Zero(), this._scaledVelocity = R.Zero(), this._finalPosition = R.Zero() } return e.prototype.getNewPosition = function (e, t, i, r, n, o, a) { e.divideToRef(i._radius, this._scaledPosition), t.divideToRef(i._radius, this._scaledVelocity), i.collidedMesh = null, i._retry = 0, i._initialVelocity = this._scaledVelocity, i._initialPosition = this._scaledPosition, this._collideWithWorld(this._scaledPosition, this._scaledVelocity, i, r, this._finalPosition, n), this._finalPosition.multiplyInPlace(i._radius), o(a, this._finalPosition, i.collidedMesh) }, e.prototype.createCollider = function () { return new Jc }, e.prototype.init = function (e) { this._scene = e }, e.prototype._collideWithWorld = function (e, t, i, r, n, o) { void 0 === o && (o = null); var a = 10 * In.CollisionsEpsilon; if (i._retry >= 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 < l.length; c++) { var u = l[c]; u.isEnabled() && u.checkCollisions && u.subMeshes && u !== o && 0 != (s & u.collisionGroup) && u._checkCollision(i) } i.collisionFound ? (0 === t.x && 0 === t.y && 0 === t.z || i._getResponse(e, t), t.length() <= a ? n.copyFrom(e) : (i._retry++, this._collideWithWorld(e, t, i, r, n, o))) : e.addToRef(t, n) } }, e }(); Sr.CollisionCoordinatorFactory = function () { return new $c }; var eu, tu = function () { function e(t, i, r, n) { void 0 === n && (n = ""); var o, a, s, l = this; this.name = null, this.defines = "", this.onCompiled = null, this.onError = null, this.uniqueId = 0, this.onCompileObservable = new u, this.onErrorObservable = new u, this.onBindObservable = new u, this._wasPreviouslyReady = !1, this._isReady = !1, this._compilationError = "", this._key = "", this._computeSourceCodeOverride = "", this._pipelineContext = null, this._computeSourceCode = "", this._rawComputeSourceCode = "", this._shaderLanguage = nt.WGSL, this.name = t, this._key = n, this._engine = r, this.uniqueId = e._UniqueIdSeed++, this.defines = null !== (o = i.defines) && void 0 !== o ? o : "", this.onError = i.onError, this.onCompiled = i.onCompiled, this._entryPoint = null !== (a = i.entryPoint) && void 0 !== a ? a : "main", this._shaderStore = Ut.GetShadersStore(this._shaderLanguage), this._shaderRepository = Ut.GetShadersRepository(this._shaderLanguage), this._includeShaderStore = Ut.GetIncludesShadersStore(this._shaderLanguage); var c = et() ? this._engine.getHostDocument() : null; t.computeSource ? s = "source:" + t.computeSource : t.computeElement ? (s = c ? c.getElementById(t.computeElement) : null) || (s = t.computeElement) : s = t.compute || t; var h = { defines: this.defines.split("\n"), indexParameters: void 0, isFragment: !1, shouldUseHighPrecisionShader: !1, processor: null, supportsUniformBuffers: this._engine.supportsUniformBuffers, shadersRepository: this._shaderRepository, includesShadersStore: this._includeShaderStore, version: (100 * this._engine.version).toString(), platformName: this._engine.shaderPlatformName, processingContext: null, isNDCHalfZRange: this._engine.isNDCHalfZRange, useReverseDepthBuffer: this._engine.useReverseDepthBuffer }; this._loadShader(s, "Compute", "", (function (e) { Bt.Initialize(h), Bt.PreProcess(e, h, (function (r) { l._rawComputeSourceCode = e, i.processFinalCode && (r = i.processFinalCode(r)); var n = Bt.Finalize(r, "", h); l._useFinalCode(n.vertexCode, t) }), l._engine) })) } return e.prototype._useFinalCode = function (e, t) { if (t) { var i = t.computeElement || t.compute || t.spectorName || t; this._computeSourceCode = "//#define SHADER_NAME compute:" + i + "\n" + e } else this._computeSourceCode = e; this._prepareEffect() }, Object.defineProperty(e.prototype, "key", { get: function () { return this._key }, enumerable: !1, configurable: !0 }), e.prototype.isReady = function () { try { return this._isReadyInternal() } catch (e) { return !1 } }, e.prototype._isReadyInternal = function () { return !!this._isReady || !!this._pipelineContext && this._pipelineContext.isReady }, e.prototype.getEngine = function () { return this._engine }, e.prototype.getPipelineContext = function () { return this._pipelineContext }, e.prototype.getCompilationError = function () { return this._compilationError }, e.prototype.executeWhenCompiled = function (e) { var t = this; this.isReady() ? e(this) : (this.onCompileObservable.add((function (t) { e(t) })), this._pipelineContext && !this._pipelineContext.isAsync || setTimeout((function () { t._checkIsReady(null) }), 16)) }, e.prototype._checkIsReady = function (e) { var t = this; try { if (this._isReadyInternal()) return } catch (t) { return void this._processCompilationErrors(t, e) } setTimeout((function () { t._checkIsReady(e) }), 16) }, e.prototype._loadShader = function (e, t, i, r) { var n; "undefined" != typeof HTMLElement && e instanceof HTMLElement ? r(rt(e)) : "source:" !== e.substr(0, 7) ? "base64:" !== e.substr(0, 7) ? this._shaderStore[e + t + "Shader"] ? r(this._shaderStore[e + t + "Shader"]) : i && this._shaderStore[e + i + "Shader"] ? r(this._shaderStore[e + i + "Shader"]) : (n = "." === e[0] || "/" === e[0] || e.indexOf("http") > -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) { Ut.GetShadersStore(nt.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" }(eu || (eu = {})), ti.prototype.createComputeEffect = function (e, t) { throw new Error("createComputeEffect: This engine does not support compute shaders!") }, ti.prototype.createComputePipelineContext = function () { throw new Error("createComputePipelineContext: This engine does not support compute shaders!") }, ti.prototype.createComputeContext = function () { }, ti.prototype.computeDispatch = function (e, t, i, r, n, o, a) { throw new Error("computeDispatch: This engine does not support compute shaders!") }, ti.prototype.areAllComputeEffectsReady = function () { return !0 }, ti.prototype.releaseComputeEffects = function () { }, ti.prototype._prepareComputePipelineContext = function (e, t, i, r, n) { }, ti.prototype._rebuildComputeEffects = function () { }, ti.prototype._executeWhenComputeStateIsCompiled = function (e, t) { t() }, ti.prototype._releaseComputeEffect = function (e) { }, ti.prototype._deleteComputePipelineContext = function (e) { }; var iu = 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 = yr.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 ? eu.Texture : eu.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: eu.StorageTexture, object: t, indexInGroupEntries: null == i ? void 0 : i.indexInGroupEntries } }, e.prototype.setUniformBuffer = function (e, t) { var i = this._bindings[e]; this._contextIsDirty || (this._contextIsDirty = !i || i.object !== t), this._bindings[e] = { type: eu.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: eu.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: eu.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 eu.Texture: case eu.TextureWithoutSampler: case eu.StorageTexture: if (!n.isReady()) return !1 } } var o = [], a = this._shaderPath; if (this._options.defines) for (var s = 0; s < this._options.defines.length; s++)o.push(this._options.defines[s]); var l = o.join("\n"); return this._cachedDefines !== l && (this._cachedDefines = l, e = this._engine.createComputeEffect(a, { defines: l, entryPoint: this._options.entryPoint, onCompiled: this.onCompiled, onError: this.onError }), this._effect = e), !!e.isReady() }, e.prototype.dispatch = function (e, t, i) { var r; if (!this.isReady()) return !1; for (var n in this._bindings) { var o = this._bindings[n]; if (!this._options.bindingsMapping[n]) throw new Error("ComputeShader ('" + this.name + "'): No binding mapping has been provided for the property '" + n + "'"); switch (o.type) { case eu.Texture: var a = this._samplers[n], s = o.object; a && s._texture && a.compareSampler(s._texture) || (this._samplers[n] = (new Wt).setParameters(s.wrapU, s.wrapV, s.wrapR, s.anisotropicFilteringLevel, s._texture.samplingMode, null === (r = s._texture) || void 0 === r ? void 0 : r._comparisonFunction), this._contextIsDirty = !0); break; case eu.UniformBuffer: var l = o.object; l.getBuffer() !== o.buffer && (o.buffer = l.getBuffer(), this._contextIsDirty = !0) } } return this._contextIsDirty && (this._contextIsDirty = !1, this._context.clear()), this._engine.computeDispatch(this._effect, this._context, this._bindings, e, t, i, this._options.bindingsMapping), !0 }, e.prototype.dispatchWhenReady = function (e, t, i, r) { var n = this; return void 0 === r && (r = 10), new Promise((function (o) { var a = function () { n.dispatch(e, t, i) ? o() : setTimeout(a, r) }; a() })) }, e.prototype.serialize = function () { var e = Ue.Serialize(this); for (var t in e.options = this._options, e.shaderPath = this._shaderPath, e.bindings = {}, e.textures = {}, this._bindings) { var i = this._bindings[t], r = i.object; switch (i.type) { case eu.Texture: case eu.TextureWithoutSampler: case eu.StorageTexture: var n = r.serialize(); n && (e.textures[t] = n, e.bindings[t] = { type: i.type }); case eu.UniformBuffer: } } return e }, e.Parse = function (t, i, r) { var n = Ue.Parse((function () { return new e(t.name, i.getEngine(), t.shaderPath, t.options) }), t, i, r); for (var o in t.textures) { var a = t.bindings[o], s = vo.Parse(t.textures[o], i, r); a.type === eu.Texture ? n.setTexture(o, s) : a.type === eu.TextureWithoutSampler ? n.setTexture(o, s, !1) : n.setStorageTexture(o, s) } return n }, X([xe()], e.prototype, "name", void 0), e }(); b("BABYLON.ComputeShader", iu); var ru = function () { function e(e, t, i, r, n, o) { this.entries = new Array, this._boundingVectors = new Array, this._capacity = i, this._depth = r, this._maxDepth = n, this._creationFunc = o, this._minPoint = e, this._maxPoint = t, this._boundingVectors.push(e.clone()), this._boundingVectors.push(t.clone()), this._boundingVectors.push(e.clone()), this._boundingVectors[2].x = t.x, this._boundingVectors.push(e.clone()), this._boundingVectors[3].y = t.y, this._boundingVectors.push(e.clone()), this._boundingVectors[4].z = t.z, this._boundingVectors.push(t.clone()), this._boundingVectors[5].z = e.z, this._boundingVectors.push(t.clone()), this._boundingVectors[6].x = e.x, this._boundingVectors.push(t.clone()), this._boundingVectors[7].y = e.y } return Object.defineProperty(e.prototype, "capacity", { get: function () { return this._capacity }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "minPoint", { get: function () { return this._minPoint }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "maxPoint", { get: function () { return this._maxPoint }, enumerable: !1, configurable: !0 }), e.prototype.addEntry = function (e) { if (this.blocks) for (var t = 0; t < this.blocks.length; t++)this.blocks[t].addEntry(e); else this._creationFunc(e, this), this.entries.length > this.capacity && this._depth < this._maxDepth && this.createInnerBlocks() }, e.prototype.removeEntry = function (e) { if (this.blocks) for (var t = 0; t < this.blocks.length; t++)this.blocks[t].removeEntry(e); else { var i = this.entries.indexOf(e); i > -1 && this.entries.splice(i, 1) } }, e.prototype.addEntries = function (e) { for (var t = 0; t < e.length; t++) { var i = e[t]; this.addEntry(i) } }, e.prototype.select = function (e, t, i) { if (un.IsInFrustum(this._boundingVectors, e)) { if (this.blocks) { for (var r = 0; r < this.blocks.length; r++)this.blocks[r].select(e, t, i); return } i ? t.concat(this.entries) : t.concatWithNoDuplicate(this.entries) } }, e.prototype.intersects = function (e, t, i, r) { if (un.IntersectsSphere(this._minPoint, this._maxPoint, e, t)) { if (this.blocks) { for (var n = 0; n < this.blocks.length; n++)this.blocks[n].intersects(e, t, i, r); return } r ? i.concat(this.entries) : i.concatWithNoDuplicate(this.entries) } }, e.prototype.intersectsRay = function (e, t) { if (e.intersectsBoxMinMax(this._minPoint, this._maxPoint)) { if (this.blocks) { for (var i = 0; i < this.blocks.length; i++)this.blocks[i].intersectsRay(e, t); return } t.concatWithNoDuplicate(this.entries) } }, e.prototype.createInnerBlocks = function () { e._CreateBlocks(this._minPoint, this._maxPoint, this.entries, this._capacity, this._depth, this._maxDepth, this, this._creationFunc), this.entries.splice(0) }, e._CreateBlocks = function (t, i, r, n, o, a, s, l) { s.blocks = new Array; for (var c = new R((i.x - t.x) / 2, (i.y - t.y) / 2, (i.z - t.z) / 2), u = 0; u < 2; u++)for (var h = 0; h < 2; h++)for (var d = 0; d < 2; d++) { var p = new e(t.add(c.multiplyByFloats(u, h, d)), t.add(c.multiplyByFloats(u + 1, h + 1, d + 1)), n, o + 1, a, l); p.addEntries(r), s.blocks.push(p) } }, e }(), nu = function () { function e(e, t, i) { void 0 === i && (i = 2), this.maxDepth = i, this.dynamicContent = new Array, this._maxBlockCapacity = t || 64, this._selectionContent = new Pi(1024), this._creationFunc = e } return e.prototype.update = function (e, t, i) { ru._CreateBlocks(e, t, i, this._maxBlockCapacity, 0, this.maxDepth, this, this._creationFunc) }, e.prototype.addMesh = function (e) { for (var t = 0; t < this.blocks.length; t++)this.blocks[t].addEntry(e) }, e.prototype.removeMesh = function (e) { for (var t = 0; t < this.blocks.length; t++)this.blocks[t].removeEntry(e) }, e.prototype.select = function (e, t) { this._selectionContent.reset(); for (var i = 0; i < this.blocks.length; i++)this.blocks[i].select(e, this._selectionContent, t); return t ? this._selectionContent.concat(this.dynamicContent) : this._selectionContent.concatWithNoDuplicate(this.dynamicContent), this._selectionContent }, e.prototype.intersects = function (e, t, i) { this._selectionContent.reset(); for (var r = 0; r < this.blocks.length; r++)this.blocks[r].intersects(e, t, this._selectionContent, i); return i ? this._selectionContent.concat(this.dynamicContent) : this._selectionContent.concatWithNoDuplicate(this.dynamicContent), this._selectionContent }, e.prototype.intersectsRay = function (e) { this._selectionContent.reset(); for (var t = 0; t < this.blocks.length; t++)this.blocks[t].intersectsRay(e, this._selectionContent); return this._selectionContent.concatWithNoDuplicate(this.dynamicContent), this._selectionContent }, e.CreationFuncForMeshes = function (e, t) { var i = e.getBoundingInfo(); !e.isBlocked && i.boundingBox.intersectsMinMax(t.minPoint, t.maxPoint) && t.entries.push(e) }, e.CreationFuncForSubMeshes = function (e, t) { e.getBoundingInfo().boundingBox.intersectsMinMax(t.minPoint, t.maxPoint) && t.entries.push(e) }, e }(); Sr.prototype.createOrUpdateSelectionOctree = function (e, t) { void 0 === e && (e = 64), void 0 === t && (t = 2); var i = this._getComponent(qi.NAME_OCTREE); i || (i = new su(this), this._addComponent(i)), this._selectionOctree || (this._selectionOctree = new nu(nu.CreationFuncForMeshes, e, t)); var r = this.getWorldExtends(); return this._selectionOctree.update(r.min, r.max, this.meshes), this._selectionOctree }, Object.defineProperty(Sr.prototype, "selectionOctree", { get: function () { return this._selectionOctree }, enumerable: !0, configurable: !0 }), Ln.prototype.createOrUpdateSubmeshesOctree = function (e, t) { void 0 === e && (e = 64), void 0 === t && (t = 2); var i = this.getScene(), r = i._getComponent(qi.NAME_OCTREE); r || (r = new su(i), i._addComponent(r)), this._submeshesOctree || (this._submeshesOctree = new nu(nu.CreationFuncForSubMeshes, e, t)), this.computeWorldMatrix(!0); var n = this.getBoundingInfo().boundingBox; return this._submeshesOctree.update(n.minimumWorld, n.maximumWorld, this.subMeshes), this._submeshesOctree }; var ou, au, su = function () { function e(e) { this.name = qi.NAME_OCTREE, this.checksIsEnabled = !0, this._tempRay = new Mo(R.Zero(), new R(1, 1, 1)), (e = e || S.LastCreatedScene) && (this.scene = e, this.scene.getActiveMeshCandidates = this.getActiveMeshCandidates.bind(this), this.scene.getActiveSubMeshCandidates = this.getActiveSubMeshCandidates.bind(this), this.scene.getCollidingSubMeshCandidates = this.getCollidingSubMeshCandidates.bind(this), this.scene.getIntersectingSubMeshCandidates = this.getIntersectingSubMeshCandidates.bind(this)) } return e.prototype.register = function () { var e = this; this.scene.onMeshRemovedObservable.add((function (t) { var i = e.scene.selectionOctree; if (null != i) { var r = i.dynamicContent.indexOf(t); -1 !== r && i.dynamicContent.splice(r, 1) } })), this.scene.onMeshImportedObservable.add((function (t) { var i = e.scene.selectionOctree; null != i && i.addMesh(t) })) }, e.prototype.getActiveMeshCandidates = function () { var e; return (null === (e = this.scene._selectionOctree) || void 0 === e ? void 0 : e.select(this.scene.frustumPlanes)) || this.scene._getDefaultMeshCandidates() }, e.prototype.getActiveSubMeshCandidates = function (e) { return e._submeshesOctree && e.useOctreeForRenderingSelection ? e._submeshesOctree.select(this.scene.frustumPlanes) : this.scene._getDefaultSubMeshCandidates(e) }, e.prototype.getIntersectingSubMeshCandidates = function (e, t) { return e._submeshesOctree && e.useOctreeForPicking ? (Mo.TransformToRef(t, e.getWorldMatrix(), this._tempRay), e._submeshesOctree.intersectsRay(this._tempRay)) : this.scene._getDefaultSubMeshCandidates(e) }, e.prototype.getCollidingSubMeshCandidates = function (e, t) { if (e._submeshesOctree && e.useOctreeForCollisions) { var i = t._velocityWorldLength + Math.max(t._radius.x, t._radius.y, t._radius.z); return e._submeshesOctree.intersects(t._basePointWorld, i) } return this.scene._getDefaultSubMeshCandidates(e) }, e.prototype.rebuild = function () { }, e.prototype.dispose = function () { }, e }(), lu = function () { function e(e, t) { void 0 === t && (t = !0); var i = this; this.originalScene = e, this._pointerCaptures = {}, this._lastPointerEvents = {}, this._sharedGizmoLight = null, this._renderCamera = null, this.pickUtilitySceneFirst = !0, this.shouldRender = !0, this.onlyCheckPointerDownEvents = !0, this.processAllEvents = !1, this.pickingEnabled = !0, this.onPointerOutObservable = new u, this.utilityLayerScene = new Sr(e.getEngine(), { virtual: !0 }), this.utilityLayerScene.useRightHandedSystem = e.useRightHandedSystem, this.utilityLayerScene._allowPostProcessClearColor = !1, this.utilityLayerScene.postProcessesEnabled = !1, this.utilityLayerScene.detachControl(), t && (this._originalPointerObserver = e.onPrePointerObservable.add((function (t) { if (i.utilityLayerScene.activeCamera && i.pickingEnabled && (i.processAllEvents || t.type === Ji.POINTERMOVE || t.type === Ji.POINTERUP || t.type === Ji.POINTERDOWN || t.type === Ji.POINTERDOUBLETAP)) { i.utilityLayerScene.pointerX = e.pointerX, i.utilityLayerScene.pointerY = e.pointerY; var r = t.event; if (e.isPointerCaptured(r.pointerId)) i._pointerCaptures[r.pointerId] = !1; else { var n = function (r) { var n = null; if (t.nearInteractionPickingInfo) n = t.nearInteractionPickingInfo.pickedMesh.getScene() == r ? t.nearInteractionPickingInfo : new Xi; else if (r !== i.utilityLayerScene && t.originalPickingInfo) n = t.originalPickingInfo; else { var o = null; i._renderCamera && (o = r._activeCamera, r._activeCamera = i._renderCamera, t.ray = null), n = t.ray ? r.pickWithRay(t.ray) : r.pick(e.pointerX, e.pointerY), o && (r._activeCamera = o) } return n }, o = n(i.utilityLayerScene); if (!t.ray && o && (t.ray = o.ray), i.utilityLayerScene.onPrePointerObservable.notifyObservers(t), i.onlyCheckPointerDownEvents && t.type != Ji.POINTERDOWN) return t.skipOnPointerObservable || i.utilityLayerScene.onPointerObservable.notifyObservers(new tr(t.type, t.event, o), t.type), void (t.type === Ji.POINTERUP && i._pointerCaptures[r.pointerId] && (i._pointerCaptures[r.pointerId] = !1)); if (i.utilityLayerScene.autoClearDepthAndStencil || i.pickUtilitySceneFirst) o && o.hit && (t.skipOnPointerObservable || i.utilityLayerScene.onPointerObservable.notifyObservers(new tr(t.type, t.event, o), t.type), t.skipOnPointerObservable = !0); else { var a = n(e), s = t.event; a && o && (0 === o.distance && a.pickedMesh ? i.mainSceneTrackerPredicate && i.mainSceneTrackerPredicate(a.pickedMesh) ? (i._notifyObservers(t, a, s), t.skipOnPointerObservable = !0) : t.type === Ji.POINTERDOWN ? i._pointerCaptures[s.pointerId] = !0 : t.type !== Ji.POINTERMOVE && t.type !== Ji.POINTERUP || (i._lastPointerEvents[s.pointerId] && (i.onPointerOutObservable.notifyObservers(s.pointerId), delete i._lastPointerEvents[s.pointerId]), i._notifyObservers(t, a, s)) : !i._pointerCaptures[s.pointerId] && (o.distance < a.distance || 0 === a.distance) ? (i._notifyObservers(t, o, s), t.skipOnPointerObservable || (t.skipOnPointerObservable = o.distance > 0)) : !i._pointerCaptures[s.pointerId] && o.distance >= a.distance && (i.mainSceneTrackerPredicate && i.mainSceneTrackerPredicate(a.pickedMesh) ? (i._notifyObservers(t, a, s), t.skipOnPointerObservable = !0) : (t.type !== Ji.POINTERMOVE && t.type !== Ji.POINTERUP || i._lastPointerEvents[s.pointerId] && (i.onPointerOutObservable.notifyObservers(s.pointerId), delete i._lastPointerEvents[s.pointerId]), i._notifyObservers(t, o, s))), t.type === Ji.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 Zl("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 tr(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" }(ou || (ou = {})), function (e) { e[e.World = 0] = "World", e[e.Local = 1] = "Local" }(au || (au = {})); var cu, uu = function () { function e(e) { void 0 === e && (e = lu.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 = ou.Origin, this._updateScale = !0, this._coordinatesMode = au.Local, this._interactionsEnabled = !0, this._rightHandtoLeftHandMatrix = I.RotationY(Math.PI), this._rootMesh = new Jn("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 == au.Local; this.updateGizmoRotationToMatchAttachedMesh = t, this.updateGizmoPositionToMatchAttachedMesh = t }, 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 == ou.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) } 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; o.devicePosition && (a = o.devicePosition), this._rootMesh.position.subtractToRef(a, O.Vector3[0]); var s = this.scaleRatio; if (o.mode == ln.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._handlePivot = function () { var e = this._attachedNode; e.isUsingPivotMatrix && e.isUsingPivotMatrix() && e.position && e.getWorldMatrix().setTranslation(e.position) }, 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]; a.parent.getWorldMatrix().invertToRef(n), this._attachedNode.getWorldMatrix().multiplyToRef(n, s), s.decompose(O.Vector3[0], O.Quaternion[0], a.position, e.PreserveScaling ? a : void 0) } 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 l = this._attachedNode, c = l.getParent(); if (c) { var u = O.Matrix[0], h = O.Matrix[1]; c.getFinalMatrix().invertToRef(u), l.getFinalMatrix().multiplyToRef(u, h), l.getLocalMatrix().copyFrom(h) } else l.getLocalMatrix().copyFrom(l.getFinalMatrix()); l.markAsDirty() } else { var d = this._attachedNode; if (d.getTypeID) { var p = d.getTypeID(); if (p === eo.LIGHTTYPEID_DIRECTIONALLIGHT || p === eo.LIGHTTYPEID_SPOTLIGHT || p === eo.LIGHTTYPEID_POINTLIGHT) { var f = d.parent; if (f) { u = O.Matrix[0]; var _ = O.Matrix[1]; f.getWorldMatrix().invertToRef(u), d.getWorldMatrix().multiplyToRef(u, _), _.decompose(void 0, O.Quaternion[0], O.Vector3[0]) } else this._attachedNode._worldMatrix.decompose(void 0, O.Quaternion[0], O.Vector3[0]); d.position = new R(O.Vector3[0].x, O.Vector3[0].y, O.Vector3[0].z), d.direction && (d.direction = new R(d.direction.x, d.direction.y, d.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 === Ji.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 === Ji.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 === Ji.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 }(), hu = function (e) { function t(i, r, n, o, a) { void 0 === r && (r = B.Gray()), void 0 === n && (n = lu.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 mc("", n.utilityLayerScene), l._coloredMaterial.diffuseColor = r, l._coloredMaterial.specularColor = r.subtract(new B(.1, .1, .1)), l._hoverMaterial = new mc("", n.utilityLayerScene), l._hoverMaterial.diffuseColor = B.Yellow(), l._disableMaterial = new mc("", 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 Jn("", 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 wo({ dragAxis: i }), l.dragBehavior.moveAttached = !1, l.dragBehavior.updateDragPlane = !1, l._rootMesh.addBehavior(l.dragBehavior), l.dragBehavior.onDragObservable.add((function (e) { if (l.attachedNode) { l._handlePivot(); 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 On("arrow", e), o = Dc("cylinder", { diameterTop: 0, height: .075, diameterBottom: .0375 * (1 + (i - 1) / 4), tessellation: 96 }, e), a = Dc("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 On("arrow", e), r = 0, n = t.getChildMeshes(); r < n.length; r++) { var o = n[r]; o.createInstance(o.name).parent = i } return 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.attachedMesh = this._parent.attachedMesh, this.attachedNode = this._parent.attachedNode) : (this.attachedMesh = null, this.attachedNode = 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._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach((function (e) { e && e.dispose() })), e.prototype.dispose.call(this) }, t }(uu), du = function () { function e(t, i, r, n, o, a, s) { if (void 0 === i && (i = 1), void 0 === r && (r = 2), void 0 === s && (s = 1), this._scaleLinesFactor = 4, this._instanced = !1, this.scene = null, this.scaleLines = 1, t = t || S.LastCreatedScene) { if (this.scaleLines = i, !n) { var l = new mc("", t); l.disableLighting = !0, l.emissiveColor = B.Red().scale(.5), n = hu._CreateArrow(t, l, s) } if (!o) { var c = new mc("", t); c.disableLighting = !0, c.emissiveColor = B.Green().scale(.5), o = hu._CreateArrow(t, c, s) } if (!a) { var u = new mc("", t); u.disableLighting = !0, u.emissiveColor = B.Blue().scale(.5), a = hu._CreateArrow(t, u, s) } this._xAxis = n, this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor), this._yAxis = o, this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor), this._zAxis = a, this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor), null != r && (e._SetRenderingGroupId(this._xAxis, r), e._SetRenderingGroupId(this._yAxis, r), e._SetRenderingGroupId(this._zAxis, r)), this.scene = t, this.update(new R, R.Right(), R.Up(), R.Forward()) } } return Object.defineProperty(e.prototype, "xAxis", { get: function () { return this._xAxis }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "yAxis", { get: function () { return this._yAxis }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "zAxis", { get: function () { return this._zAxis }, enumerable: !1, configurable: !0 }), e.prototype.update = function (e, t, i, r) { this._xAxis.position.copyFrom(e), this._xAxis.setDirection(t), this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor), this._yAxis.position.copyFrom(e), this._yAxis.setDirection(i), this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor), this._zAxis.position.copyFrom(e), this._zAxis.setDirection(r), this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor) }, e.prototype.createInstance = function () { var t = hu._CreateArrowInstance(this.scene, this._xAxis), i = hu._CreateArrowInstance(this.scene, this._yAxis), r = hu._CreateArrowInstance(this.scene, this._zAxis), n = new e(this.scene, this.scaleLines, null, t, i, r); return n._instanced = !0, n }, e.prototype.dispose = function () { this._xAxis && this._xAxis.dispose(!1, !this._instanced), this._yAxis && this._yAxis.dispose(!1, !this._instanced), this._zAxis && this._zAxis.dispose(!1, !this._instanced), this.scene = null }, e._SetRenderingGroupId = function (e, t) { e.getChildMeshes().forEach((function (e) { e.renderingGroupId = t })) }, e }(), pu = function (e) { function t(t, i, r, n) { void 0 === n && (n = 1); var o = e.call(this, t, n) || this; return o.pos = R.Zero(), o.xaxis = R.Zero(), o.yaxis = R.Zero(), o.zaxis = R.Zero(), o.mesh = r, o.bone = i, o } return W(t, e), t.prototype.update = function () { if (this.mesh && this.bone) { var t = this.bone; t.getAbsolutePositionToRef(this.mesh, this.pos), t.getDirectionToRef(Ar.X, this.mesh, this.xaxis), t.getDirectionToRef(Ar.Y, this.mesh, this.yaxis), t.getDirectionToRef(Ar.Z, this.mesh, this.zaxis), e.prototype.update.call(this, this.pos, this.xaxis, this.yaxis, this.zaxis) } }, t.prototype.dispose = function () { this.mesh && (this.mesh = null, this.bone = null, e.prototype.dispose.call(this)) }, t }(du); Object.defineProperty(Sr.prototype, "debugLayer", { get: function () { return this._debugLayer || (this._debugLayer = new fu(this)), this._debugLayer }, enumerable: !0, configurable: !0 }), function (e) { e[e.Properties = 0] = "Properties", e[e.Debug = 1] = "Debug", e[e.Statistics = 2] = "Statistics", e[e.Tools = 3] = "Tools", e[e.Settings = 4] = "Settings" }(cu || (cu = {})); var fu = function () { function e(e) { var t = this; this.BJSINSPECTOR = this._getGlobalInspector(), this._scene = e || S.LastCreatedScene, this._scene && this._scene.onDisposeObservable.add((function () { t._scene._debugLayer && t._scene._debugLayer.hide() })) } return Object.defineProperty(e.prototype, "onPropertyChangedObservable", { get: function () { return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector ? this.BJSINSPECTOR.Inspector.OnPropertyChangedObservable : (this._onPropertyChangedObservable || (this._onPropertyChangedObservable = new u), this._onPropertyChangedObservable) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "onSelectionChangedObservable", { get: function () { return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector ? this.BJSINSPECTOR.Inspector.OnSelectionChangeObservable : (this._onSelectionChangedObservable || (this._onSelectionChangedObservable = new u), this._onSelectionChangedObservable) }, enumerable: !1, configurable: !0 }), e.prototype._createInspector = function (e) { if (!this.isVisible()) { if (this._onPropertyChangedObservable) { for (var t = 0, i = this._onPropertyChangedObservable.observers; t < i.length; t++) { var r = i[t]; this.BJSINSPECTOR.Inspector.OnPropertyChangedObservable.add(r) } this._onPropertyChangedObservable.clear(), this._onPropertyChangedObservable = void 0 } if (this._onSelectionChangedObservable) { for (var n = 0, o = this._onSelectionChangedObservable.observers; n < o.length; n++)r = o[n], this.BJSINSPECTOR.Inspector.OnSelectionChangedObservable.add(r); this._onSelectionChangedObservable.clear(), this._onSelectionChangedObservable = void 0 } var a = H({ overlay: !1, showExplorer: !0, showInspector: !0, embedMode: !1, handleResize: !0, enablePopup: !0 }, e); this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector(), this.BJSINSPECTOR.Inspector.Show(this._scene, a) } }, e.prototype.select = function (e, t) { this.BJSINSPECTOR && (t && ("[object String]" == Object.prototype.toString.call(t) ? this.BJSINSPECTOR.Inspector.MarkLineContainerTitleForHighlighting(t) : this.BJSINSPECTOR.Inspector.MarkMultipleLineContainerTitlesForHighlighting(t)), this.BJSINSPECTOR.Inspector.OnSelectionChangeObservable.notifyObservers(e)) }, e.prototype._getGlobalInspector = function () { return "undefined" != typeof INSPECTOR ? INSPECTOR : "undefined" != typeof BABYLON && void 0 !== BABYLON.Inspector ? BABYLON : void 0 }, e.prototype.isVisible = function () { return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible }, e.prototype.hide = function () { this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.Hide() }, e.prototype.setAsActiveScene = function () { this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector._SetNewScene(this._scene) }, e.prototype.show = function (t) { var i = this; return new Promise((function (r) { if (void 0 === i.BJSINSPECTOR) { var n = t && t.inspectorURL ? t.inspectorURL : e.InspectorURL; xi.LoadScript(n, (function () { i._createInspector(t), r(i) })) } else i._createInspector(t), r(i) })) }, e.InspectorURL = "https://unpkg.com/babylonjs-inspector@".concat(In.Version, "/babylon.inspector.bundle.js"), e }(); function _u(e) { var t, i = [0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11, 12, 13, 14, 12, 14, 15, 16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23], r = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0], n = [], o = e.width || e.size || 1, a = e.height || e.size || 1, s = e.depth || e.size || 1, l = e.wrap || !1, c = void 0 === e.topBaseAt ? 1 : e.topBaseAt, u = void 0 === e.bottomBaseAt ? 0 : e.bottomBaseAt, h = [2, 0, 3, 1][c = (c + 4) % 4], d = [2, 0, 1, 3][u = (u + 4) % 4], p = [1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1]; if (l) { i = [2, 3, 0, 2, 0, 1, 4, 5, 6, 4, 6, 7, 9, 10, 11, 9, 11, 8, 12, 14, 15, 12, 13, 14], p = [-1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1]; for (var f = [[1, 1, 1], [-1, 1, 1], [-1, 1, -1], [1, 1, -1]], _ = [[-1, -1, 1], [1, -1, 1], [1, -1, -1], [-1, -1, -1]], m = [17, 18, 19, 16], g = [22, 23, 20, 21]; h > 0;)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 || En.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, xn.UseOpenGLOrientationForUV ? 1 - b[x].w : b[x].w), n.push(b[x].x, xn.UseOpenGLOrientationForUV ? 1 - b[x].w : b[x].w), n.push(b[x].x, xn.UseOpenGLOrientationForUV ? 1 - b[x].y : b[x].y), n.push(b[x].z, xn.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); En._ComputeSides(y, t, i, r, n, e.frontUVs, e.backUVs); var R = new En; if (R.indices = i, R.positions = t, R.normals = r, R.uvs = n, T) { var P = y === En.DOUBLESIDE ? E.concat(E) : E; R.colors = P } return R } function mu(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 = Uc({ 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 = Uc({ width: t, height: r, subdivisionsX: n, subdivisionsY: a }); I.TranslationToRef(0, i / 2, 0, c), h.transform(c); var d = Uc({ 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 = Uc({ 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 = Uc({ 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 _ = Uc({ 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 gu(e, t, i) { void 0 === t && (t = {}), void 0 === i && (i = null); var r = new Jn(e, i); return t.sideOrientation = Jn._GetDefaultSideOrientation(t.sideOrientation), r._originalBuilderSideOrientation = t.sideOrientation, _u(t).applyToMesh(r, t.updatable), r } var vu = { CreateBox: gu }; function yu(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 || En.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, xn.UseOpenGLOrientationForUV ? 1 - g : g) } if (m > 0) for (var M = p.length / 3, O = M - 2 * (h + 1); O + h + 2 < M; O++)l ? (m > 1 && (d.push(O), d.push(O + 1), d.push(O + h + 1)), (m < u || a < 1) && (d.push(O + h + 1), d.push(O + 1), d.push(O + h + 2))) : (d.push(O), d.push(O + 1), d.push(O + h + 1), d.push(O + h + 1), d.push(O + 1), d.push(O + h + 2)) } En._ComputeSides(s, p, d, f, _, e.frontUVs, e.backUVs); var D = new En; return D.indices = d, D.positions = p, D.normals = f, D.uvs = _, D } function bu(e, t, i) { void 0 === t && (t = {}), void 0 === i && (i = null); var r = new Jn(e, i); return t.sideOrientation = Jn._GetDefaultSideOrientation(t.sideOrientation), r._originalBuilderSideOrientation = t.sideOrientation, yu(t).applyToMesh(r, t.updatable), r } En.CreateBox = _u, Jn.CreateBox = function (e, t, i, r, n) { return void 0 === i && (i = null), gu(e, { size: t, sideOrientation: n, updatable: r }, i) }; var Tu = { CreateSphere: bu }; function Eu(e) { void 0 === e && (e = { subdivisions: 2, tessellation: 16, height: 1, radius: .25, capSubdivisions: 6 }); var t, i, r = 0 | Math.max(e.subdivisions ? e.subdivisions : 2, 1), n = 0 | Math.max(e.tessellation ? e.tessellation : 16, 3), o = Math.max(e.height ? e.height : 1, 0), a = Math.max(e.radius ? e.radius : .25, 0), s = 0 | Math.max(e.capSubdivisions ? e.capSubdivisions : 6, 1), l = n, c = r, u = Math.max(e.radiusTop ? e.radiusTop : a, 0), h = Math.max(e.radiusBottom ? e.radiusBottom : a, 0), d = o - (u + h), p = 2 * Math.PI, f = Math.max(e.topCapSubdivisions ? e.topCapSubdivisions : s, 1), _ = Math.max(e.bottomCapSubdivisions ? e.bottomCapSubdivisions : s, 1), m = Math.acos((h - u) / o), g = [], v = [], y = [], b = [], T = 0, E = [], S = .5 * d, x = .5 * Math.PI, C = R.Zero(), P = R.Zero(), M = Math.cos(m), O = Math.sin(m), D = new A(u * O, S + u * M).subtract(new A(h * O, h * M - S)).length(), N = u * m + D + h * (x - m), F = 0; for (i = 0; i <= f; i++) { var L = [], w = x - m * (i / f); F += u * m / f; var B = Math.cos(w), U = Math.sin(w), V = B * u; for (t = 0; t <= l; t++) { var k = (X = t / l) * p + 0, G = Math.sin(k), z = Math.cos(k); P.x = V * G, P.y = S + U * u, P.z = V * z, v.push(P.x, P.y, P.z), C.set(B * G, U, B * z), y.push(C.x, C.y, C.z), b.push(X, xn.UseOpenGLOrientationForUV ? F / N : 1 - F / N), L.push(T), T++ } E.push(L) } var W = o - u - h + M * u - M * h, H = O * (h - u) / W; for (i = 1; i <= c; i++) { for (L = [], F += D / c, V = O * (i * (h - u) / c + u), t = 0; t <= l; t++)k = (X = t / l) * p + 0, G = Math.sin(k), z = Math.cos(k), P.x = V * G, P.y = S + M * u - i * W / c, P.z = V * z, v.push(P.x, P.y, P.z), C.set(G, H, z).normalize(), y.push(C.x, C.y, C.z), b.push(X, xn.UseOpenGLOrientationForUV ? F / N : 1 - F / N), L.push(T), T++; E.push(L) } for (i = 1; i <= _; i++) { for (L = [], w = x - m - (Math.PI - m) * (i / _), F += h * m / _, B = Math.cos(w), U = Math.sin(w), V = B * h, t = 0; t <= l; t++) { var X; k = (X = t / l) * p + 0, G = Math.sin(k), z = Math.cos(k), P.x = V * G, P.y = U * h - S, P.z = V * z, v.push(P.x, P.y, P.z), C.set(B * G, U, B * z), y.push(C.x, C.y, C.z), b.push(X, xn.UseOpenGLOrientationForUV ? F / N : 1 - F / N), L.push(T), T++ } E.push(L) } for (t = 0; t < l; t++)for (i = 0; i < f + c + _; i++) { var j = E[i][t], Y = E[i + 1][t], K = E[i + 1][t + 1], Q = E[i][t + 1]; g.push(j), g.push(Y), g.push(Q), g.push(Y), g.push(K), g.push(Q) } if (g = g.reverse(), e.orientation && !e.orientation.equals(R.Up())) { var q = new I; e.orientation.clone().scale(.5 * Math.PI).cross(R.Up()).toQuaternion().toRotationMatrix(q); for (var Z = R.Zero(), J = 0; J < v.length; J += 3)Z.set(v[J], v[J + 1], v[J + 2]), R.TransformCoordinatesToRef(Z.clone(), q, Z), v[J] = Z.x, v[J + 1] = Z.y, v[J + 2] = Z.z } var $ = new En; return $.positions = v, $.normals = y, $.uvs = b, $.indices = g, $ } function Su(e, t, i) { void 0 === t && (t = { orientation: R.Up(), subdivisions: 2, tessellation: 16, height: 1, radius: .25, capSubdivisions: 6, updatable: !1 }), void 0 === i && (i = null); var r = new Jn(e, i); return Eu(t).applyToMesh(r, t.updatable), r } En.CreateSphere = yu, Jn.CreateSphere = function (e, t, i, r, n, o) { return bu(e, { segments: t, diameterX: i, diameterY: i, diameterZ: i, sideOrientation: o, updatable: n }, r) }; var xu = { CreateCapsule: Su }; function Au(e) { var t = e.pathArray, i = e.closeArray || !1, r = e.closePath || !1, n = e.invertUV || !1, o = Math.floor(t[0].length / 2), a = e.offset || o; a = a > o ? o : Math.floor(a); var s, l, c, u, h = 0 === e.sideOrientation ? 0 : e.sideOrientation || En.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; c < t[0].length - a; c++)x.push(t[0][c]), A.push(t[0][c + a]); t = [x, A] } var R, C, P, I, M, O = 0, D = r ? 1 : 0; for (s = t[0].length, l = 0; l < t.length; l++) { for (b[l] = 0, v[l] = [0], s = s < (C = (R = t[l]).length) ? s : C, u = 0; u < C;)f.push(R[u].x, R[u].y, R[u].z), u > 0 && (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; c < s + D; c++) { for (T[c] = 0, y[c] = [0], l = 0; l < t.length - 1; l++)I = t[l], M = t[l + 1], c === s ? (L = I[0], w = M[0]) : (L = I[c], w = M[c]), P = w.subtract(L).length() + T[c], y[c].push(P), T[c] = P; i && w && L && (I = t[l], M = t[0], c === s && (w = M[0]), P = w.subtract(L).length() + T[c], T[c] = P) } if (d) for (l = 0; l < d.length; l++)g.push(d[l].x, xn.UseOpenGLOrientationForUV ? 1 - d[l].y : d[l].y); else for (l = 0; l < t.length; l++)for (c = 0; c < s + D; c++)N = 0 != b[l] ? v[l][c] / b[l] : 0, F = 0 != T[c] ? y[c][l] / T[c] : 0, n ? g.push(F, N) : g.push(N, xn.UseOpenGLOrientationForUV ? 1 - F : F); for (var B = 0, U = E[l = 0] - 1, V = E[l + 1] - 1, k = U < V ? U : V, G = S[1] - S[0], z = i ? E.length : E.length - 1; B <= k && l < z;)_.push(B, B + G, B + 1), _.push(B + G + 1, B + 1, B + G), (B += 1) === k && (++l == E.length - 1 ? (G = S[0] - S[l], U = E[l] - 1, V = E[0] - 1) : (G = S[l + 1] - S[l], U = E[l] - 1, V = E[l + 1] - 1), B = S[l], k = U < V ? U + B : V + B); if (En.ComputeNormals(f, _, m), r) { var W = 0, H = 0; for (l = 0; l < t.length; l++)W = 3 * S[l], H = l + 1 < t.length ? 3 * (S[l + 1] - 1) : m.length - 3, m[W] = .5 * (m[W] + m[H]), m[W + 1] = .5 * (m[W + 1] + m[H + 1]), m[W + 2] = .5 * (m[W + 2] + m[H + 2]), m[H] = m[W], m[H + 1] = m[W + 1], m[H + 2] = m[W + 2] } En._ComputeSides(h, f, _, m, g, e.frontUVs, e.backUVs); var X = null; if (p) { X = new Float32Array(4 * p.length); for (var j = 0; j < p.length; j++)X[4 * j] = p[j].r, X[4 * j + 1] = p[j].g, X[4 * j + 2] = p[j].b, X[4 * j + 3] = p[j].a } var Y = new En, K = new Float32Array(f), Q = new Float32Array(m), q = new Float32Array(g); return Y.indices = _, Y.positions = K, Y.normals = Q, Y.uvs = q, X && Y.set(X, Hi.ColorKind), r && (Y._idx = S), Y } function Ru(e, t, i) { void 0 === i && (i = null); var r = t.pathArray, n = t.closeArray, o = t.closePath, a = Jn._GetDefaultSideOrientation(t.sideOrientation), s = t.instance, l = t.updatable; if (s) { var c = O.Vector3[0].setAll(Number.MAX_VALUE), u = O.Vector3[1].setAll(-Number.MAX_VALUE), h = s.getVerticesData(Hi.PositionKind); if (function (e) { for (var t = r[0].length, i = s, n = 0, o = i._originalBuilderSideOrientation === Jn.DOUBLESIDE ? 2 : 1, a = 1; a <= o; ++a)for (var l = 0; l < r.length; ++l) { var h = r[l], d = h.length; t = t < d ? t : d; for (var p = 0; p < t; ++p) { var f = h[p]; e[n] = f.x, e[n + 1] = f.y, e[n + 2] = f.z, c.minimizeInPlaceFromFloats(f.x, f.y, f.z), u.maximizeInPlaceFromFloats(f.x, f.y, f.z), n += 3 } i._creationDataStorage && i._creationDataStorage.closePath && (f = h[0], e[n] = f.x, e[n + 1] = f.y, e[n + 2] = f.z, n += 3) } }(h), s.hasBoundingInfo ? s.getBoundingInfo().reConstruct(c, u, s._worldMatrix) : s.buildBoundingInfo(c, u, s._worldMatrix), s.updateVerticesData(Hi.PositionKind, h, !1, !1), t.colors) { for (var d = s.getVerticesData(Hi.ColorKind), p = 0, f = 0; p < t.colors.length; p++, f += 4) { var _ = t.colors[p]; d[f] = _.r, d[f + 1] = _.g, d[f + 2] = _.b, d[f + 3] = _.a } s.updateVerticesData(Hi.ColorKind, d, !1, !1) } if (t.uvs) { for (var m = s.getVerticesData(Hi.UVKind), g = 0; g < t.uvs.length; g++)m[2 * g] = t.uvs[g].x, m[2 * g + 1] = xn.UseOpenGLOrientationForUV ? 1 - t.uvs[g].y : t.uvs[g].y; s.updateVerticesData(Hi.UVKind, m, !1, !1) } if (!s.areNormalsFrozen || s.isFacetDataEnabled) { var v = s.getIndices(), y = s.getVerticesData(Hi.NormalKind), b = s.isFacetDataEnabled ? s.getFacetDataParameters() : null; if (En.ComputeNormals(h, v, y, b), s._creationDataStorage && s._creationDataStorage.closePath) for (var T = 0, E = 0, S = 0; S < r.length; S++)T = 3 * s._creationDataStorage.idx[S], E = S + 1 < r.length ? 3 * (s._creationDataStorage.idx[S + 1] - 1) : y.length - 3, y[T] = .5 * (y[T] + y[E]), y[T + 1] = .5 * (y[T + 1] + y[E + 1]), y[T + 2] = .5 * (y[T + 2] + y[E + 2]), y[E] = y[T], y[E + 1] = y[T + 1], y[E + 2] = y[T + 2]; s.areNormalsFrozen || s.updateVerticesData(Hi.NormalKind, y, !1, !1) } return s } var x = new Jn(e, i); x._originalBuilderSideOrientation = a, x._creationDataStorage = new Yn; var A = Au(t); return o && (x._creationDataStorage.idx = A._idx), x._creationDataStorage.closePath = o, x._creationDataStorage.closeArray = n, A.applyToMesh(x, l), x } Jn.CreateCapsule = function (e, t, i) { return Su(e, t, i) }, En.CreateCapsule = Eu; var Cu = { CreateRibbon: Ru }; function Pu(e) { var t = new Array, i = new Array, r = new Array, n = new Array, o = e.radius || .5, a = e.tessellation || 64, s = e.arc && (e.arc <= 0 || e.arc > 1) ? 1 : e.arc || 1, l = 0 === e.sideOrientation ? 0 : e.sideOrientation || En.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; d < a; d++) { var p = Math.cos(h), f = Math.sin(h), _ = (p + 1) / 2, m = (1 - f) / 2; t.push(o * p, o * f, 0), n.push(_, xn.UseOpenGLOrientationForUV ? 1 - m : m), h += u } 1 === s && (t.push(t[3], t[4], t[5]), n.push(n[2], xn.UseOpenGLOrientationForUV ? 1 - n[3] : n[3])); for (var g = t.length / 3, v = 1; v < g - 1; v++)i.push(v + 1, 0, v); En.ComputeNormals(t, i, r), En._ComputeSides(l, t, i, r, n, e.frontUVs, e.backUVs); var y = new En; return y.indices = i, y.positions = t, y.normals = r, y.uvs = n, y } function Iu(e, t, i) { void 0 === t && (t = {}), void 0 === i && (i = null); var r = new Jn(e, i); return t.sideOrientation = Jn._GetDefaultSideOrientation(t.sideOrientation), r._originalBuilderSideOrientation = t.sideOrientation, Pu(t).applyToMesh(r, t.updatable), r } En.CreateRibbon = Au, Jn.CreateRibbon = function (e, t, i, r, n, o, a, s, l) { return void 0 === i && (i = !1), void 0 === a && (a = !1), Ru(e, { pathArray: t, closeArray: i, closePath: r, offset: n, updatable: a, sideOrientation: s, instance: l }, o) }; var Mu = { CreateDisc: Iu }; function Ou(e) { var t = e.pattern || Jn.NO_FLIP, i = e.tileWidth || e.tileSize || 1, r = e.tileHeight || e.tileSize || 1, n = e.alignHorizontal || 0, o = e.alignVertical || 0, a = e.width || e.size || 1, s = Math.floor(a / i), l = a - s * i, c = e.height || e.size || 1, u = Math.floor(c / r), h = c - u * r, d = i * s / 2, p = r * u / 2, f = 0, _ = 0, m = 0, g = 0, v = 0, y = 0; if (l > 0 || h > 0) { switch (m = -d, g = -p, v = d, y = p, n) { case Jn.CENTER: m -= l /= 2, v += l; break; case Jn.LEFT: v += l, f = -l / 2; break; case Jn.RIGHT: m -= l, f = l / 2 }switch (o) { case Jn.CENTER: g -= h /= 2, y += h; break; case Jn.BOTTOM: y += h, _ = -h / 2; break; case Jn.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 !== Jn.ROTATE_TILE && t !== Jn.ROTATE_ROW || (E[1] = [1, 1, 0, 1, 0, 0, 1, 0]), t !== Jn.FLIP_TILE && t !== Jn.FLIP_ROW || (E[1] = [1, 0, 0, 0, 0, 1, 1, 1]), t !== Jn.FLIP_N_ROTATE_TILE && t !== Jn.FLIP_N_ROTATE_ROW || (E[1] = [0, 1, 1, 1, 1, 0, 0, 0]); for (var S = [], x = [], A = [], R = 0, C = 0; C < u; C++)for (var P = 0; P < s; P++)b.push(P * i - d + f, C * r - p + _, 0), b.push((P + 1) * i - d + f, C * r - p + _, 0), b.push((P + 1) * i - d + f, (C + 1) * r - p + _, 0), b.push(P * i - d + f, (C + 1) * r - p + _, 0), A.push(R, R + 1, R + 3, R + 1, R + 2, R + 3), S = t === Jn.FLIP_TILE || t === Jn.ROTATE_TILE || t === Jn.FLIP_N_ROTATE_TILE ? S.concat(E[(P % 2 + C % 2) % 2]) : t === Jn.FLIP_ROW || t === Jn.ROTATE_ROW || t === Jn.FLIP_N_ROTATE_ROW ? S.concat(E[C % 2]) : S.concat(E[0]), 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), R += 4; if (l > 0 || h > 0) { var I = h > 0 && (o === Jn.CENTER || o === Jn.TOP), M = h > 0 && (o === Jn.CENTER || o === Jn.BOTTOM), O = l > 0 && (n === Jn.CENTER || n === Jn.RIGHT), D = l > 0 && (n === Jn.CENTER || n === Jn.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 === Jn.ROTATE_ROW && (N = [1 - F, 1 - L, 1 - w, 1 - L, 1 - w, 1 - B, 1 - F, 1 - B]), t === Jn.FLIP_ROW && (N = [1 - F, L, 1 - w, L, 1 - w, B, 1 - F, B]), t === Jn.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 === Jn.ROTATE_ROW || t === Jn.ROTATE_TILE && s % 2 == 0) && (N = [1 - F, 1 - L, 1 - w, 1 - L, 1 - w, 1 - B, 1 - F, 1 - B]), (t === Jn.FLIP_ROW || t === Jn.FLIP_TILE && s % 2 == 0) && (N = [1 - F, L, 1 - w, L, 1 - w, B, 1 - F, B]), (t === Jn.FLIP_N_ROTATE_ROW || t === Jn.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 === Jn.ROTATE_ROW && u % 2 == 1 || t === Jn.ROTATE_TILE && u % 1 == 0) && (N = [1 - F, 1 - L, 1 - w, 1 - L, 1 - w, 1 - B, 1 - F, 1 - B]), (t === Jn.FLIP_ROW && u % 2 == 1 || t === Jn.FLIP_TILE && u % 2 == 0) && (N = [1 - F, L, 1 - w, L, 1 - w, B, 1 - F, B]), (t === Jn.FLIP_N_ROTATE_ROW && u % 2 == 1 || t === Jn.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 === Jn.ROTATE_ROW && u % 2 == 1 || t === Jn.ROTATE_TILE && (u + s) % 2 == 1) && (N = [1 - F, 1 - L, 1 - w, 1 - L, 1 - w, 1 - B, 1 - F, 1 - B]), (t === Jn.FLIP_ROW && u % 2 == 1 || t === Jn.FLIP_TILE && (u + s) % 2 == 1) && (N = [1 - F, L, 1 - w, L, 1 - w, B, 1 - F, B]), (t === Jn.FLIP_N_ROTATE_ROW && u % 2 == 1 || t === Jn.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 !== Jn.ROTATE_TILE && t !== Jn.ROTATE_ROW || (U[1] = [1 - F, 1 - L, 1 - w, 1 - L, 1 - w, 1 - B, 1 - F, 1 - B]), t !== Jn.FLIP_TILE && t !== Jn.FLIP_ROW || (U[1] = [1 - F, L, 1 - w, L, 1 - w, B, 1 - F, B]), t !== Jn.FLIP_N_ROTATE_TILE && t !== Jn.FLIP_N_ROTATE_ROW || (U[1] = [F, 1 - L, w, 1 - L, w, 1 - B, F, 1 - B]), P = 0; P < s; P++)b.push(P * i - d + f, g + _, 0), b.push((P + 1) * i - d + f, g + _, 0), b.push((P + 1) * i - d + f, g + h + _, 0), b.push(P * i - d + f, g + h + _, 0), A.push(R, R + 1, R + 3, R + 1, R + 2, R + 3), R += 4, S = t === Jn.FLIP_TILE || t === Jn.ROTATE_TILE || t === Jn.FLIP_N_ROTATE_TILE ? S.concat(U[(P + 1) % 2]) : t === Jn.FLIP_ROW || t === Jn.ROTATE_ROW || t === Jn.FLIP_N_ROTATE_ROW ? S.concat(U[1]) : S.concat(U[0]), 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) } if (M) { var V = []; for (F = 0, L = 0, w = 1, B = h / r, V[0] = [F, L, w, L, w, B, F, B], V[1] = [F, L, w, L, w, B, F, B], t !== Jn.ROTATE_TILE && t !== Jn.ROTATE_ROW || (V[1] = [1 - F, 1 - L, 1 - w, 1 - L, 1 - w, 1 - B, 1 - F, 1 - B]), t !== Jn.FLIP_TILE && t !== Jn.FLIP_ROW || (V[1] = [1 - F, L, 1 - w, L, 1 - w, B, 1 - F, B]), t !== Jn.FLIP_N_ROTATE_TILE && t !== Jn.FLIP_N_ROTATE_ROW || (V[1] = [F, 1 - L, w, 1 - L, w, 1 - B, F, 1 - B]), P = 0; P < s; P++)b.push(P * i - d + f, y - h + _, 0), b.push((P + 1) * i - d + f, y - h + _, 0), b.push((P + 1) * i - d + f, y + _, 0), b.push(P * i - d + f, y + _, 0), A.push(R, R + 1, R + 3, R + 1, R + 2, R + 3), R += 4, S = t === Jn.FLIP_TILE || t === Jn.ROTATE_TILE || t === Jn.FLIP_N_ROTATE_TILE ? S.concat(V[(P + u) % 2]) : t === Jn.FLIP_ROW || t === Jn.ROTATE_ROW || t === Jn.FLIP_N_ROTATE_ROW ? S.concat(V[u % 2]) : S.concat(V[0]), 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) } if (O) { var k = []; for (F = 1 - l / i, L = 0, w = 1, B = 1, k[0] = [F, L, w, L, w, B, F, B], k[1] = [F, L, w, L, w, B, F, B], t !== Jn.ROTATE_TILE && t !== Jn.ROTATE_ROW || (k[1] = [1 - F, 1 - L, 1 - w, 1 - L, 1 - w, 1 - B, 1 - F, 1 - B]), t !== Jn.FLIP_TILE && t !== Jn.FLIP_ROW || (k[1] = [1 - F, L, 1 - w, L, 1 - w, B, 1 - F, B]), t !== Jn.FLIP_N_ROTATE_TILE && t !== Jn.FLIP_N_ROTATE_ROW || (k[1] = [F, 1 - L, w, 1 - L, w, 1 - B, F, 1 - B]), C = 0; C < u; C++)b.push(m + f, C * r - p + _, 0), b.push(m + l + f, C * r - p + _, 0), b.push(m + l + f, (C + 1) * r - p + _, 0), b.push(m + f, (C + 1) * r - p + _, 0), A.push(R, R + 1, R + 3, R + 1, R + 2, R + 3), R += 4, S = t === Jn.FLIP_TILE || t === Jn.ROTATE_TILE || t === Jn.FLIP_N_ROTATE_TILE ? S.concat(k[(C + 1) % 2]) : t === Jn.FLIP_ROW || t === Jn.ROTATE_ROW || t === Jn.FLIP_N_ROTATE_ROW ? S.concat(k[C % 2]) : S.concat(k[0]), 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) } if (D) { var G = []; for (F = 0, L = 0, w = l / r, B = 1, G[0] = [F, L, w, L, w, B, F, B], G[1] = [F, L, w, L, w, B, F, B], t !== Jn.ROTATE_TILE && t !== Jn.ROTATE_ROW || (G[1] = [1 - F, 1 - L, 1 - w, 1 - L, 1 - w, 1 - B, 1 - F, 1 - B]), t !== Jn.FLIP_TILE && t !== Jn.FLIP_ROW || (G[1] = [1 - F, L, 1 - w, L, 1 - w, B, 1 - F, B]), t !== Jn.FLIP_N_ROTATE_TILE && t !== Jn.FLIP_N_ROTATE_ROW || (G[1] = [F, 1 - L, w, 1 - L, w, 1 - B, F, 1 - B]), C = 0; C < u; C++)b.push(v - l + f, C * r - p + _, 0), b.push(v + f, C * r - p + _, 0), b.push(v + f, (C + 1) * r - p + _, 0), b.push(v - l + f, (C + 1) * r - p + _, 0), A.push(R, R + 1, R + 3, R + 1, R + 2, R + 3), R += 4, S = t === Jn.FLIP_TILE || t === Jn.ROTATE_TILE || t === Jn.FLIP_N_ROTATE_TILE ? S.concat(G[(C + s) % 2]) : t === Jn.FLIP_ROW || t === Jn.ROTATE_ROW || t === Jn.FLIP_N_ROTATE_ROW ? S.concat(G[C % 2]) : S.concat(G[0]), 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) } } var z = 0 === e.sideOrientation ? 0 : e.sideOrientation || En.DEFAULTSIDE; En._ComputeSides(z, b, A, T, S, e.frontUVs, e.backUVs); var W = new En; W.indices = A, W.positions = b, W.normals = T, W.uvs = S; var H = z === En.DOUBLESIDE ? x.concat(x) : x; return W.colors = H, W } function Du(e, t, i) { void 0 === i && (i = null); var r = new Jn(e, i); return t.sideOrientation = Jn._GetDefaultSideOrientation(t.sideOrientation), r._originalBuilderSideOrientation = t.sideOrientation, Ou(t).applyToMesh(r, t.updatable), r } En.CreateDisc = Pu, Jn.CreateDisc = function (e, t, i, r, n, o) { return void 0 === r && (r = null), Iu(e, { radius: t, tessellation: i, sideOrientation: o, updatable: n }, r) }; var Nu = { CreateTiledPlane: Du }; function Fu(e) { for (var t = e.faceUV || new Array(6), i = e.faceColors, r = e.pattern || Jn.NO_FLIP, n = e.width || e.size || 1, o = e.height || e.size || 1, a = e.depth || e.size || 1, s = e.tileWidth || e.tileSize || 1, l = e.tileHeight || e.tileSize || 1, c = e.alignHorizontal || 0, u = e.alignVertical || 0, h = 0 === e.sideOrientation ? 0 : e.sideOrientation || En.DEFAULTSIDE, d = 0; d < 6; d++)void 0 === t[d] && (t[d] = new C(0, 0, 1, 1)), i && void 0 === i[d] && (i[d] = new U(1, 1, 1, 1)); var p = n / 2, f = o / 2, _ = a / 2, m = []; for (d = 0; d < 2; d++)m[d] = Ou({ pattern: r, tileWidth: s, tileHeight: l, width: n, height: o, alignVertical: u, alignHorizontal: c, sideOrientation: h }); for (d = 2; d < 4; d++)m[d] = Ou({ pattern: r, tileWidth: s, tileHeight: l, width: a, height: o, alignVertical: u, alignHorizontal: c, sideOrientation: h }); var g = u; for (u === Jn.BOTTOM ? g = Jn.TOP : u === Jn.TOP && (g = Jn.BOTTOM), d = 4; d < 6; d++)m[d] = Ou({ pattern: r, tileWidth: s, tileHeight: l, width: n, height: a, alignVertical: g, alignHorizontal: c, sideOrientation: h }); var v = [], y = [], b = [], T = [], E = [], S = [], x = [], A = [], P = 0, M = 0; for (d = 0; d < 6; d++) { var O = m[d].positions.length; S[d] = [], x[d] = []; for (var D = 0; D < O / 3; D++)S[d].push(new R(m[d].positions[3 * D], m[d].positions[3 * D + 1], m[d].positions[3 * D + 2])), x[d].push(new R(m[d].normals[3 * D], m[d].normals[3 * D + 1], m[d].normals[3 * D + 2])); P = m[d].uvs.length, A[d] = []; for (var N = 0; N < P; N += 2)A[d][N] = t[d].x + (t[d].z - t[d].x) * m[d].uvs[N], A[d][N + 1] = t[d].y + (t[d].w - t[d].y) * m[d].uvs[N + 1], xn.UseOpenGLOrientationForUV && (A[d][N + 1] = 1 - A[d][N + 1]); if (b = b.concat(A[d]), T = T.concat(m[d].indices.map((function (e) { return e + M }))), M += S[d].length, i) for (var F = 0; F < 4; F++)E.push(i[d].r, i[d].g, i[d].b, i[d].a) } var L = new R(0, 0, _), w = I.RotationY(Math.PI); v = S[0].map((function (e) { return R.TransformNormal(e, w).add(L) })).map((function (e) { return [e.x, e.y, e.z] })).reduce((function (e, t) { return e.concat(t) }), []), y = x[0].map((function (e) { return R.TransformNormal(e, w) })).map((function (e) { return [e.x, e.y, e.z] })).reduce((function (e, t) { return e.concat(t) }), []), v = v.concat(S[1].map((function (e) { return e.subtract(L) })).map((function (e) { return [e.x, e.y, e.z] })).reduce((function (e, t) { return e.concat(t) }), [])), y = y.concat(x[1].map((function (e) { return [e.x, e.y, e.z] })).reduce((function (e, t) { return e.concat(t) }), [])); var B = new R(p, 0, 0), V = I.RotationY(-Math.PI / 2); v = v.concat(S[2].map((function (e) { return R.TransformNormal(e, V).add(B) })).map((function (e) { return [e.x, e.y, e.z] })).reduce((function (e, t) { return e.concat(t) }), [])), y = y.concat(x[2].map((function (e) { return R.TransformNormal(e, V) })).map((function (e) { return [e.x, e.y, e.z] })).reduce((function (e, t) { return e.concat(t) }), [])); var k = I.RotationY(Math.PI / 2); v = v.concat(S[3].map((function (e) { return R.TransformNormal(e, k).subtract(B) })).map((function (e) { return [e.x, e.y, e.z] })).reduce((function (e, t) { return e.concat(t) }), [])), y = y.concat(x[3].map((function (e) { return R.TransformNormal(e, k) })).map((function (e) { return [e.x, e.y, e.z] })).reduce((function (e, t) { return e.concat(t) }), [])); var G = new R(0, f, 0), z = I.RotationX(Math.PI / 2); v = v.concat(S[4].map((function (e) { return R.TransformNormal(e, z).add(G) })).map((function (e) { return [e.x, e.y, e.z] })).reduce((function (e, t) { return e.concat(t) }), [])), y = y.concat(x[4].map((function (e) { return R.TransformNormal(e, z) })).map((function (e) { return [e.x, e.y, e.z] })).reduce((function (e, t) { return e.concat(t) }), [])); var W = I.RotationX(-Math.PI / 2); v = v.concat(S[5].map((function (e) { return R.TransformNormal(e, W).subtract(G) })).map((function (e) { return [e.x, e.y, e.z] })).reduce((function (e, t) { return e.concat(t) }), [])), y = y.concat(x[5].map((function (e) { return R.TransformNormal(e, W) })).map((function (e) { return [e.x, e.y, e.z] })).reduce((function (e, t) { return e.concat(t) }), [])), En._ComputeSides(h, v, T, y, b); var H = new En; if (H.indices = T, H.positions = v, H.normals = y, H.uvs = b, i) { var X = h === En.DOUBLESIDE ? E.concat(E) : E; H.colors = X } return H } function Lu(e, t, i) { void 0 === i && (i = null); var r = new Jn(e, i); return t.sideOrientation = Jn._GetDefaultSideOrientation(t.sideOrientation), r._originalBuilderSideOrientation = t.sideOrientation, Fu(t).applyToMesh(r, t.updatable), r } En.CreateTiledPlane = Ou; var wu = { CreateTiledBox: Lu }; function Bu(e) { var t, i, r = new Array, n = new Array, o = new Array, a = new Array, s = e.radius || 2, l = e.tube || .5, c = e.radialSegments || 32, u = e.tubularSegments || 32, h = e.p || 2, d = e.q || 3, p = 0 === e.sideOrientation ? 0 : e.sideOrientation || En.DEFAULTSIDE, f = function (e) { var t = Math.cos(e), i = Math.sin(e), r = d / h * e, n = Math.cos(r), o = s * (2 + n) * .5 * t, a = s * (2 + n) * i * .5, l = s * Math.sin(r) * .5; return new R(o, a, l) }; for (t = 0; t <= c; t++) { var _ = t % c / c * 2 * h * Math.PI, m = f(_), g = f(_ + .01), v = g.subtract(m), y = g.add(m), b = R.Cross(v, y); for (y = R.Cross(b, v), b.normalize(), y.normalize(), i = 0; i < u; i++) { var T = i % u / u * 2 * Math.PI, E = -l * Math.cos(T), S = l * Math.sin(T); n.push(m.x + E * y.x + S * b.x), n.push(m.y + E * y.y + S * b.y), n.push(m.z + E * y.z + S * b.z), a.push(t / c), a.push(xn.UseOpenGLOrientationForUV ? 1 - i / u : i / u) } } for (t = 0; t < c; t++)for (i = 0; i < u; i++) { var x = (i + 1) % u, A = t * u + i, C = (t + 1) * u + i, P = (t + 1) * u + x, I = t * u + x; r.push(I), r.push(C), r.push(A), r.push(I), r.push(P), r.push(C) } En.ComputeNormals(n, r, o), En._ComputeSides(p, n, r, o, a, e.frontUVs, e.backUVs); var M = new En; return M.indices = r, M.positions = n, M.normals = o, M.uvs = a, M } function Uu(e, t, i) { void 0 === t && (t = {}); var r = new Jn(e, i); return t.sideOrientation = Jn._GetDefaultSideOrientation(t.sideOrientation), r._originalBuilderSideOrientation = t.sideOrientation, Bu(t).applyToMesh(r, t.updatable), r } En.CreateTiledBox = Fu; var Vu = { CreateTorusKnot: Uu }; En.CreateTorusKnot = Bu, Jn.CreateTorusKnot = function (e, t, i, r, n, o, a, s, l, c) { return Uu(e, { radius: t, tube: i, radialSegments: r, tubularSegments: n, p: o, q: a, sideOrientation: c, updatable: l }, s) }; var ku = { effect: null, subMesh: null }, Gu = function (e) { function t(t, i, r, n, o) { void 0 === n && (n = {}), void 0 === o && (o = !0); var a = e.call(this, t, i, o) || this; return a._textures = {}, a._textureArrays = {}, a._externalTextures = {}, a._floats = {}, a._ints = {}, a._uints = {}, a._floatsArrays = {}, a._colors3 = {}, a._colors3Arrays = {}, a._colors4 = {}, a._colors4Arrays = {}, a._vectors2 = {}, a._vectors3 = {}, a._vectors4 = {}, a._quaternions = {}, a._quaternionsArrays = {}, a._matrices = {}, a._matrixArrays = {}, a._matrices3x3 = {}, a._matrices2x2 = {}, a._vectors2Arrays = {}, a._vectors3Arrays = {}, a._vectors4Arrays = {}, a._uniformBuffers = {}, a._textureSamplers = {}, a._storageBuffers = {}, a._cachedWorldViewMatrix = new I, a._cachedWorldViewProjectionMatrix = new I, a._multiview = !1, a._materialHelperNeedsPreviousMatrices = !1, a._shaderPath = r, a._options = H({ needAlphaBlending: !1, needAlphaTesting: !1, attributes: ["position", "normal", "uv"], uniforms: ["worldViewProjection"], uniformBuffers: [], samplers: [], externalTextures: [], samplerObjects: [], storageBuffers: [], defines: [], useClipPlane: !1 }, n), a } return W(t, e), Object.defineProperty(t.prototype, "shaderPath", { get: function () { return this._shaderPath }, set: function (e) { this._shaderPath = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "options", { get: function () { return this._options }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isMultiview", { get: function () { return this._multiview }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function () { return "ShaderMaterial" }, t.prototype.needAlphaBlending = function () { return this.alpha < 1 || this._options.needAlphaBlending }, t.prototype.needAlphaTesting = function () { return this._options.needAlphaTesting }, t.prototype._checkUniform = function (e) { -1 === this._options.uniforms.indexOf(e) && this._options.uniforms.push(e) }, t.prototype.setTexture = function (e, t) { return -1 === this._options.samplers.indexOf(e) && this._options.samplers.push(e), this._textures[e] = t, this }, t.prototype.setTextureArray = function (e, t) { return -1 === this._options.samplers.indexOf(e) && this._options.samplers.push(e), this._checkUniform(e), this._textureArrays[e] = t, this }, t.prototype.setExternalTexture = function (e, t) { return -1 === this._options.externalTextures.indexOf(e) && this._options.externalTextures.push(e), this._externalTextures[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.setUInt = function (e, t) { return this._checkUniform(e), this._uints[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.setColor3Array = function (e, t) { return this._checkUniform(e), this._colors3Arrays[e] = t.reduce((function (e, t) { return t.toArray(e, e.length), e }), []), this }, t.prototype.setColor4 = function (e, t) { return this._checkUniform(e), this._colors4[e] = t, this }, t.prototype.setColor4Array = function (e, t) { return this._checkUniform(e), this._colors4Arrays[e] = t.reduce((function (e, t) { return t.toArray(e, e.length), e }), []), this }, t.prototype.setVector2 = function (e, t) { return this._checkUniform(e), this._vectors2[e] = t, this }, t.prototype.setVector3 = function (e, t) { return this._checkUniform(e), this._vectors3[e] = t, this }, t.prototype.setVector4 = function (e, t) { return this._checkUniform(e), this._vectors4[e] = t, this }, t.prototype.setQuaternion = function (e, t) { return this._checkUniform(e), this._quaternions[e] = t, this }, t.prototype.setQuaternionArray = function (e, t) { return this._checkUniform(e), this._quaternionsArrays[e] = t.reduce((function (e, t) { return t.toArray(e, e.length), e }), []), this }, t.prototype.setMatrix = function (e, t) { return this._checkUniform(e), this._matrices[e] = t, this }, t.prototype.setMatrices = function (e, t) { this._checkUniform(e); for (var i = new Float32Array(16 * t.length), r = 0; r < t.length; r++)t[r].copyToArray(i, 16 * r); return this._matrixArrays[e] = i, this }, t.prototype.setMatrix3x3 = function (e, t) { return this._checkUniform(e), this._matrices3x3[e] = t, this }, t.prototype.setMatrix2x2 = function (e, t) { return this._checkUniform(e), this._matrices2x2[e] = t, this }, t.prototype.setArray2 = function (e, t) { return this._checkUniform(e), this._vectors2Arrays[e] = t, this }, t.prototype.setArray3 = function (e, t) { return this._checkUniform(e), this._vectors3Arrays[e] = t, this }, t.prototype.setArray4 = function (e, t) { return this._checkUniform(e), this._vectors4Arrays[e] = t, this }, t.prototype.setUniformBuffer = function (e, t) { return -1 === this._options.uniformBuffers.indexOf(e) && this._options.uniformBuffers.push(e), this._uniformBuffers[e] = t, this }, t.prototype.setTextureSampler = function (e, t) { return -1 === this._options.samplerObjects.indexOf(e) && this._options.samplerObjects.push(e), this._textureSamplers[e] = t, this }, t.prototype.setStorageBuffer = function (e, t) { return -1 === this._options.storageBuffers.indexOf(e) && this._options.storageBuffers.push(e), this._storageBuffers[e] = t, this }, t.prototype.setDefine = function (e, t) { var i = e.trimEnd() + " ", r = this.options.defines.findIndex((function (t) { return t === e || t.startsWith(i) })); return r >= 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 Ra, 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; v < this._options.defines.length; v++) { var y = 0 === this._options.defines[v].indexOf("#define") ? this._options.defines[v] : "#define ".concat(this._options.defines[v]); h.push(y) } for (v = 0; v < this._options.attributes.length; v++)d.push(this._options.attributes[v]); if (e && e.isVerticesDataPresent(Hi.ColorKind) && (d.push(Hi.ColorKind), h.push("#define VERTEXCOLOR")), t && (h.push("#define INSTANCES"), zn.PushAttributesForInstances(d, this._materialHelperNeedsPreviousMatrices), (null == e ? void 0 : e.hasThinInstances) && (h.push("#define THIN_INSTANCES"), e && e.isVerticesDataPresent(Hi.ColorInstanceKind) && (d.push(Hi.ColorInstanceKind), h.push("#define INSTANCESCOLOR")))), e && e.useBones && e.computeBonesUsingShaders && e.skeleton) { d.push(Hi.MatricesIndicesKind), d.push(Hi.MatricesWeightsKind), e.numBoneInfluencers > 4 && (d.push(Hi.MatricesIndicesExtraKind), d.push(Hi.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; v < T; v++)d.push(Hi.PositionKind + v), A && d.push(Hi.NormalKind + v), x && d.push(Hi.TangentKind + v), S && d.push(Hi.UVKind + "_" + v); T > 0 && ((_ = _.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")), zn.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 && (wn(_), Bn(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 && (ku.effect = D, ku.subMesh = null !== (o = null != i ? i : null == e ? void 0 : e.subMeshes[0]) && void 0 !== o ? o : null, this._onEffectCreatedObservable.notifyObservers(ku))), 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; c < s.length; ++c)switch (s[c]) { case "Mesh": t && (t.getMeshUniformBuffer().bindToEffect(a, "Mesh"), t.transferToEffect(e)); break; case "Scene": zn.BindSceneUniformBuffer(a, this.getScene().getSceneUniformBuffer()), this.getScene().finalizeSceneUbo(), l = !0 }var u = t && o ? this._mustRebind(this.getScene(), a, t.visibility) : this.getScene().getCachedMaterial() !== this; if (a && u) { var h; for (h in l || -1 === this._options.uniforms.indexOf("view") || a.setMatrix("view", this.getScene().getViewMatrix()), l || -1 === this._options.uniforms.indexOf("projection") || a.setMatrix("projection", this.getScene().getProjectionMatrix()), l || -1 === this._options.uniforms.indexOf("viewProjection") || (a.setMatrix("viewProjection", this.getScene().getTransformMatrix()), this._multiview && a.setMatrix("viewProjectionR", this.getScene()._transformMatrixR)), this.getScene().activeCamera && -1 !== this._options.uniforms.indexOf("cameraPosition") && a.setVector3("cameraPosition", this.getScene().activeCamera.globalPosition), zn.BindBonesParameters(t, a), Vn(a, this, this.getScene()), this._textures) a.setTexture(h, this._textures[h]); for (h in this._textureArrays) a.setTextureArray(h, this._textureArrays[h]); for (h in this._externalTextures) a.setExternalTexture(h, this._externalTextures[h]); for (h in this._ints) a.setInt(h, this._ints[h]); for (h in this._uints) a.setUInt(h, this._uints[h]); for (h in this._floats) a.setFloat(h, this._floats[h]); for (h in this._floatsArrays) a.setArray(h, this._floatsArrays[h]); for (h in this._colors3) a.setColor3(h, this._colors3[h]); for (h in this._colors3Arrays) a.setArray3(h, this._colors3Arrays[h]); for (h in this._colors4) { var d = this._colors4[h]; a.setFloat4(h, d.r, d.g, d.b, d.a) } for (h in this._colors4Arrays) a.setArray4(h, this._colors4Arrays[h]); for (h in this._vectors2) a.setVector2(h, this._vectors2[h]); for (h in this._vectors3) a.setVector3(h, this._vectors3[h]); for (h in this._vectors4) a.setVector4(h, this._vectors4[h]); for (h in this._quaternions) a.setQuaternion(h, this._quaternions[h]); for (h in this._matrices) a.setMatrix(h, this._matrices[h]); for (h in this._matrixArrays) a.setMatrices(h, this._matrixArrays[h]); for (h in this._matrices3x3) a.setMatrix3x3(h, this._matrices3x3[h]); for (h in this._matrices2x2) a.setMatrix2x2(h, this._matrices2x2[h]); for (h in this._vectors2Arrays) a.setArray2(h, this._vectors2Arrays[h]); for (h in this._vectors3Arrays) a.setArray3(h, this._vectors3Arrays[h]); for (h in this._vectors4Arrays) a.setArray4(h, this._vectors4Arrays[h]); for (h in this._quaternionsArrays) a.setArray4(h, this._quaternionsArrays[h]); for (h in this._uniformBuffers) { var p = this._uniformBuffers[h].getBuffer(); p && a.bindUniformBuffer(p, h) } for (h in this._textureSamplers) a.setTextureSampler(h, this._textureSamplers[h]); for (h in this._storageBuffers) a.setStorageBuffer(h, this._storageBuffers[h]) } if (a && t && (u || !this.isFrozen)) { var f = t.morphTargetManager; f && f.numInfluencers > 0 && zn.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.length; o++)t.push(n[o]); return t }, t.prototype.hasTexture = function (t) { if (e.prototype.hasTexture.call(this, t)) return !0; for (var i in this._textures) if (this._textures[i] === t) return !0; for (var r in this._textureArrays) for (var n = this._textureArrays[r], o = 0; o < n.length; o++)if (n[o] === t) return !0; return !1 }, t.prototype.clone = function (e) { var i = this, r = Ue.Clone((function () { return new t(e, i.getScene(), i._shaderPath, i._options, i._storeEffectOnSubMeshes) }), this); for (var n in r.name = e, r.id = e, "object" == typeof r._shaderPath && (r._shaderPath = H({}, r._shaderPath)), this._options = H({}, this._options), Object.keys(this._options).forEach((function (e) { var t = i._options[e]; Array.isArray(t) && (i._options[e] = t.slice(0)) })), this.stencil.copyTo(r.stencil), this._textures) r.setTexture(n, this._textures[n]); for (var n in this._textureArrays) r.setTextureArray(n, this._textureArrays[n]); for (var n in this._externalTextures) r.setExternalTexture(n, this._externalTextures[n]); for (var n in this._ints) r.setInt(n, this._ints[n]); for (var n in this._uints) r.setUInt(n, this._uints[n]); for (var n in this._floats) r.setFloat(n, this._floats[n]); for (var n in this._floatsArrays) r.setFloats(n, this._floatsArrays[n]); for (var n in this._colors3) r.setColor3(n, this._colors3[n]); for (var n in this._colors3Arrays) r._colors3Arrays[n] = this._colors3Arrays[n]; for (var n in this._colors4) r.setColor4(n, this._colors4[n]); for (var n in this._colors4Arrays) r._colors4Arrays[n] = this._colors4Arrays[n]; for (var n in this._vectors2) r.setVector2(n, this._vectors2[n]); for (var n in this._vectors3) r.setVector3(n, this._vectors3[n]); for (var n in this._vectors4) r.setVector4(n, this._vectors4[n]); for (var n in this._quaternions) r.setQuaternion(n, this._quaternions[n]); for (var n in this._quaternionsArrays) r._quaternionsArrays[n] = this._quaternionsArrays[n]; for (var n in this._matrices) r.setMatrix(n, this._matrices[n]); for (var n in this._matrixArrays) r._matrixArrays[n] = this._matrixArrays[n].slice(); for (var n in this._matrices3x3) r.setMatrix3x3(n, this._matrices3x3[n]); for (var n in this._matrices2x2) r.setMatrix2x2(n, this._matrices2x2[n]); for (var n in this._vectors2Arrays) r.setArray2(n, this._vectors2Arrays[n]); for (var n in this._vectors3Arrays) r.setArray3(n, this._vectors3Arrays[n]); for (var n in this._vectors4Arrays) r.setArray4(n, this._vectors4Arrays[n]); for (var n in this._uniformBuffers) r.setUniformBuffer(n, this._uniformBuffers[n]); for (var n in this._textureSamplers) r.setTextureSampler(n, this._textureSamplers[n]); for (var n in this._storageBuffers) r.setStorageBuffer(n, this._storageBuffers[n]); return r }, t.prototype.dispose = function (t, i, r) { if (i) { var n; for (n in this._textures) this._textures[n].dispose(); for (n in this._textureArrays) for (var o = this._textureArrays[n], a = 0; a < o.length; a++)o[a].dispose() } this._textures = {}, e.prototype.dispose.call(this, t, i, r) }, t.prototype.serialize = function () { var e, t = Ue.Serialize(this); for (e in t.customType = "BABYLON.ShaderMaterial", t.uniqueId = this.uniqueId, t.options = this._options, t.shaderPath = this._shaderPath, t.storeEffectOnSubMeshes = this._storeEffectOnSubMeshes, t.stencil = this.stencil.serialize(), t.textures = {}, this._textures) t.textures[e] = this._textures[e].serialize(); for (e in t.textureArrays = {}, this._textureArrays) { t.textureArrays[e] = []; for (var i = this._textureArrays[e], r = 0; r < i.length; r++)t.textureArrays[e].push(i[r].serialize()) } for (e in t.ints = {}, this._ints) t.ints[e] = this._ints[e]; for (e in t.uints = {}, this._uints) t.uints[e] = this._uints[e]; for (e in t.floats = {}, this._floats) t.floats[e] = this._floats[e]; for (e in t.FloatArrays = {}, this._floatsArrays) t.FloatArrays[e] = this._floatsArrays[e]; for (e in t.colors3 = {}, this._colors3) t.colors3[e] = this._colors3[e].asArray(); for (e in t.colors3Arrays = {}, this._colors3Arrays) t.colors3Arrays[e] = this._colors3Arrays[e]; for (e in t.colors4 = {}, this._colors4) t.colors4[e] = this._colors4[e].asArray(); for (e in t.colors4Arrays = {}, this._colors4Arrays) t.colors4Arrays[e] = this._colors4Arrays[e]; for (e in t.vectors2 = {}, this._vectors2) t.vectors2[e] = this._vectors2[e].asArray(); for (e in t.vectors3 = {}, this._vectors3) t.vectors3[e] = this._vectors3[e].asArray(); for (e in t.vectors4 = {}, this._vectors4) t.vectors4[e] = this._vectors4[e].asArray(); for (e in t.quaternions = {}, this._quaternions) t.quaternions[e] = this._quaternions[e].asArray(); for (e in t.matrices = {}, this._matrices) t.matrices[e] = this._matrices[e].asArray(); for (e in t.matrixArray = {}, this._matrixArrays) t.matrixArray[e] = this._matrixArrays[e]; for (e in t.matrices3x3 = {}, this._matrices3x3) t.matrices3x3[e] = this._matrices3x3[e]; for (e in t.matrices2x2 = {}, this._matrices2x2) t.matrices2x2[e] = this._matrices2x2[e]; for (e in t.vectors2Arrays = {}, this._vectors2Arrays) t.vectors2Arrays[e] = this._vectors2Arrays[e]; for (e in t.vectors3Arrays = {}, this._vectors3Arrays) t.vectors3Arrays[e] = this._vectors3Arrays[e]; for (e in t.vectors4Arrays = {}, this._vectors4Arrays) t.vectors4Arrays[e] = this._vectors4Arrays[e]; for (e in t.quaternionsArrays = {}, this._quaternionsArrays) t.quaternionsArrays[e] = this._quaternionsArrays[e]; return t }, t.Parse = function (e, i, r) { var n, o = Ue.Parse((function () { return new t(e.name, i, e.shaderPath, e.options, e.storeEffectOnSubMeshes) }), e, i, r); for (n in e.stencil && o.stencil.parse(e.stencil, i, r), e.textures) o.setTexture(n, vo.Parse(e.textures[n], i, r)); for (n in e.textureArrays) { for (var a = e.textureArrays[n], s = new Array, l = 0; l < a.length; l++)s.push(vo.Parse(a[l], i, r)); o.setTextureArray(n, s) } for (n in e.ints) o.setInt(n, e.ints[n]); for (n in e.uints) o.setUInt(n, e.uints[n]); for (n in e.floats) o.setFloat(n, e.floats[n]); for (n in e.floatsArrays) o.setFloats(n, e.floatsArrays[n]); for (n in e.colors3) o.setColor3(n, B.FromArray(e.colors3[n])); for (n in e.colors3Arrays) { var c = e.colors3Arrays[n].reduce((function (e, t, i) { return i % 3 == 0 ? e.push([t]) : e[e.length - 1].push(t), e }), []).map((function (e) { return B.FromArray(e) })); o.setColor3Array(n, c) } for (n in e.colors4) o.setColor4(n, U.FromArray(e.colors4[n])); for (n in e.colors4Arrays) c = e.colors4Arrays[n].reduce((function (e, t, i) { return i % 4 == 0 ? e.push([t]) : e[e.length - 1].push(t), e }), []).map((function (e) { return U.FromArray(e) })), o.setColor4Array(n, c); for (n in e.vectors2) o.setVector2(n, A.FromArray(e.vectors2[n])); for (n in e.vectors3) o.setVector3(n, R.FromArray(e.vectors3[n])); for (n in e.vectors4) o.setVector4(n, C.FromArray(e.vectors4[n])); for (n in e.quaternions) o.setQuaternion(n, P.FromArray(e.quaternions[n])); for (n in e.matrices) o.setMatrix(n, I.FromArray(e.matrices[n])); for (n in e.matrixArray) o._matrixArrays[n] = new Float32Array(e.matrixArray[n]); for (n in e.matrices3x3) o.setMatrix3x3(n, e.matrices3x3[n]); for (n in e.matrices2x2) o.setMatrix2x2(n, e.matrices2x2[n]); for (n in e.vectors2Arrays) o.setArray2(n, e.vectors2Arrays[n]); for (n in e.vectors3Arrays) o.setArray3(n, e.vectors3Arrays[n]); for (n in e.vectors4Arrays) o.setArray4(n, e.vectors4Arrays[n]); for (n in e.quaternionsArrays) o.setArray4(n, e.quaternionsArrays[n]); return o }, t.ParseFromFileAsync = function (e, t, i, r) { var n = this; return void 0 === r && (r = ""), new Promise((function (o, a) { var s = new He; s.addEventListener("readystatechange", (function () { if (4 == s.readyState) if (200 == s.status) { var t = JSON.parse(s.responseText), l = n.Parse(t, i || S.LastCreatedScene, r); e && (l.name = e), o(l) } else a("Unable to load the ShaderMaterial") })), s.open("GET", t), s.send() })) }, t.ParseFromSnippetAsync = function (e, t, i) { var r = this; return void 0 === i && (i = ""), new Promise((function (n, o) { var a = new He; a.addEventListener("readystatechange", (function () { if (4 == a.readyState) if (200 == a.status) { var s = JSON.parse(JSON.parse(a.responseText).jsonPayload), l = JSON.parse(s.shaderMaterial), c = r.Parse(l, t || S.LastCreatedScene, i); c.snippetId = e, n(c) } else o("Unable to load the snippet " + e) })), a.open("GET", r.SnippetUrl + "/" + e.replace(/#/g, "/")), a.send() })) }, t.SnippetUrl = a.SnippetUrl, t.CreateFromSnippetAsync = t.ParseFromSnippetAsync, t }(ta); b("BABYLON.ShaderMaterial", Gu); Ut.ShadersStore.colorPixelShader = "#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\n#define VERTEXCOLOR\nvarying vec4 vColor;\n#else\nuniform vec4 color;\n#endif\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\ngl_FragColor=vColor;\n#else\ngl_FragColor=color;\n#endif\n#define CUSTOM_FRAGMENT_MAIN_END\n}"; Ut.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}", Jn._LinesMeshParser = function (e, t) { return zu.Parse(e, t) }; var zu = 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: [Hi.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(Hi.ColorKind)) : (u.uniforms.push("color"), c._color4 = new U), l ? c.material = l : (c.material = new Gu("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) && 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 = Hn.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._geometry._bind(t, i, this._userInstancedBuffersStorage.vertexBuffers, this._userInstancedBuffersStorage.vertexArrayObjects) : this._geometry._bind(t, i), !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(Hn.LineListDrawMode, e.verticesStart, e.verticesCount, i) : r.drawElementsType(Hn.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 Wu(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 }(Jn), Wu = 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 }($n); function Hu(e) { for (var t = [], i = [], r = e.lines, n = e.colors, o = [], a = 0, s = 0; s < r.length; s++)for (var l = r[s], c = 0; c < l.length; c++) { if (i.push(l[c].x, l[c].y, l[c].z), n) { var u = n[s]; o.push(u[c].r, u[c].g, u[c].b, u[c].a) } c > 0 && (t.push(a - 1), t.push(a)), a++ } var h = new En; return h.indices = t, h.positions = i, n && (h.colors = o), h } function Xu(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; f < a.length - 1; f++)a[f + 1].subtractToRef(a[f], c), u += c.length(); for (i = r * (t = u / o) / (r + n), f = 0; f < a.length - 1; f++) { a[f + 1].subtractToRef(a[f], c), h = Math.floor(c.length() / t), c.normalize(); for (var _ = 0; _ < h; _++)d = t * _, s.push(a[f].x + d * c.x, a[f].y + d * c.y, a[f].z + d * c.z), s.push(a[f].x + (d + i) * c.x, a[f].y + (d + i) * c.y, a[f].z + (d + i) * c.z), l.push(p, p + 1), p += 2 } var m = new En; return m.positions = s, m.indices = l, m } function ju(e, t, i) { void 0 === i && (i = null); var r = t.instance, n = t.lines, o = t.colors; if (r) { var a = r.getVerticesData(Hi.PositionKind), s = void 0, l = void 0; o && (s = r.getVerticesData(Hi.ColorKind)); for (var c = 0, u = 0, h = 0; h < n.length; h++)for (var d = n[h], p = 0; p < d.length; p++)a[c] = d[p].x, a[c + 1] = d[p].y, a[c + 2] = d[p].z, o && s && (l = o[h], s[u] = l[p].r, s[u + 1] = l[p].g, s[u + 2] = l[p].b, s[u + 3] = l[p].a, u += 4), c += 3; return r.updateVerticesData(Hi.PositionKind, a, !1, !1), o && s && r.updateVerticesData(Hi.ColorKind, s, !1, !1), r } var f = new zu(e, i, null, void 0, void 0, !!o, t.useVertexAlpha, t.material); return Hu(t).applyToMesh(f, t.updatable), f } function Yu(e, t, i) { void 0 === i && (i = null); var r = t.colors ? [t.colors] : null; return ju(e, { lines: [t.points], updatable: t.updatable, instance: t.instance, colors: r, useVertexAlpha: t.useVertexAlpha, material: t.material }, i) } function Ku(e, t, i) { void 0 === i && (i = null); var r = t.points, n = t.instance, o = t.gapSize || 1, a = t.dashSize || 3; if (n) return (t.dashNb || t.dashSize || t.gapSize || t.useVertexAlpha || t.material) && $.Warn("You have used an option other than points with the instance option. Please be aware that these other options will be ignored."), n.updateMeshPositions((function (e) { var t, i, o = R.Zero(), a = e.length / 6, s = 0, l = 0, c = 0, u = 0, h = 0, d = 0; for (h = 0; h < r.length - 1; h++)r[h + 1].subtractToRef(r[h], o), s += o.length(); t = s / a; var p = n._creationDataStorage.dashSize; for (i = p * t / (p + n._creationDataStorage.gapSize), h = 0; h < r.length - 1; h++)for (r[h + 1].subtractToRef(r[h], o), l = Math.floor(o.length() / t), o.normalize(), d = 0; d < l && u < e.length;)c = t * d, e[u] = r[h].x + c * o.x, e[u + 1] = r[h].y + c * o.y, e[u + 2] = r[h].z + c * o.z, e[u + 3] = r[h].x + (c + i) * o.x, e[u + 4] = r[h].y + (c + i) * o.y, e[u + 5] = r[h].z + (c + i) * o.z, u += 6, d++; for (; u < e.length;)e[u] = r[h].x, e[u + 1] = r[h].y, e[u + 2] = r[h].z, u += 3 }), !1), n; var s = new zu(e, i, null, void 0, void 0, void 0, t.useVertexAlpha, t.material); return Xu(t).applyToMesh(s, t.updatable), s._creationDataStorage = new Yn, s._creationDataStorage.dashSize = a, s._creationDataStorage.gapSize = o, s } var Qu = { CreateDashedLines: Ku, CreateLineSystem: ju, CreateLines: Yu }; En.CreateLineSystem = Hu, En.CreateDashedLines = Xu, Jn.CreateLines = function (e, t, i, r, n) { return void 0 === i && (i = null), void 0 === r && (r = !1), void 0 === n && (n = null), Yu(e, { points: t, updatable: r, instance: n }, i) }, Jn.CreateDashedLines = function (e, t, i, r, n, o, a, s) { return void 0 === o && (o = null), Ku(e, { points: t, dashSize: i, gapSize: r, dashNb: n, updatable: a, instance: s }, o) }; var qu = function (e) { function t(t, i) { var r = e.call(this, t.x, t.y) || this; return r.index = i, r } return W(t, e), t }(A), Zu = function () { function e() { this.elements = new Array } return e.prototype.add = function (e) { var t = this, i = new Array; return e.forEach((function (e) { var r = new qu(e, t.elements.length); i.push(r), t.elements.push(r) })), i }, e.prototype.computeBounds = function () { var e = new A(this.elements[0].x, this.elements[0].y), t = new A(this.elements[0].x, this.elements[0].y); return this.elements.forEach((function (i) { i.x < e.x ? e.x = i.x : i.x > t.x && (t.x = i.x), i.y < e.y ? e.y = i.y : i.y > t.y && (t.y = i.y) })), { min: e, max: t, width: t.x - e.x, height: t.y - e.y } }, e }(), Ju = 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; s < r; s++)n.push(new A(t + Math.cos(o) * e, i + Math.sin(o) * e)), o -= a; return n }, e.Parse = function (e) { var t, i = e.split(/[^-+eE.\d]+/).map(parseFloat).filter((function (e) { return !isNaN(e) })), r = []; for (t = 0; t < (2147483646 & i.length); t += 2)r.push(new A(i[t], i[t + 1])); return r }, e.StartingAt = function (e, t) { return Nr.StartingAt(e, t) }, e }(), $u = function () { function e(e, t, i, r) { var n; void 0 === r && (r = earcut), this._points = new Zu, this._outlinepoints = new Zu, this._holes = new Array, this._epoints = new Array, this._eholes = new Array, this.bjsEarcut = r, this._name = e, this._scene = i || S.LastCreatedScene, n = t instanceof Nr ? t.getPoints() : t, this._addToepoint(n), this._points.add(n), this._outlinepoints.add(n), void 0 === this.bjsEarcut && $.Warn("Earcut was not found, the polygon will not be built.") } return e.prototype._addToepoint = function (e) { for (var t = 0, i = e; t < i.length; t++) { var r = i[t]; this._epoints.push(r.x, r.y) } }, e.prototype.addHole = function (e) { this._points.add(e); var t = new Zu; return t.add(e), this._holes.push(t), this._eholes.push(this._epoints.length / 2), this._addToepoint(e), this }, e.prototype.build = function (e, t, i) { void 0 === e && (e = !1), void 0 === t && (t = 0), void 0 === i && (i = 2); var r = new Jn(this._name, this._scene), n = this.buildVertexData(t, i); return r.setVerticesData(Hi.PositionKind, n.positions, e), r.setVerticesData(Hi.NormalKind, n.normals, e), r.setVerticesData(Hi.UVKind, n.uvs, e), r.setIndices(n.indices), r }, e.prototype.buildVertexData = function (e, t) { var i = this; void 0 === e && (e = 0), void 0 === t && (t = 2); var r = new En, n = new Array, o = new Array, a = new Array, s = this._points.computeBounds(); this._points.elements.forEach((function (e) { n.push(0, 1, 0), o.push(e.x, 0, e.y), a.push((e.x - s.min.x) / s.width, (e.y - s.min.y) / s.height) })); for (var l = new Array, c = this.bjsEarcut(this._epoints, this._eholes, 2), u = 0; u < c.length; u++)l.push(c[u]); if (e > 0) { 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; u < d; u += 3) { var p = l[u + 0], f = l[u + 1], _ = l[u + 2]; l.push(_ + h), l.push(f + h), l.push(p + h) } this._addSide(o, n, a, l, s, this._outlinepoints, e, !1, t), this._holes.forEach((function (r) { i._addSide(o, n, a, l, s, r, e, !0, t) })) } return r.indices = l, r.positions = o, r.normals = n, r.uvs = a, r }, e.prototype._addSide = function (e, t, i, r, n, o, a, s, l) { for (var c = e.length / 3, u = 0, h = 0; h < o.elements.length; h++) { var d = o.elements[h], p = o.elements[(h + 1) % o.elements.length]; e.push(d.x, 0, d.y), e.push(d.x, -a, d.y), e.push(p.x, 0, p.y), e.push(p.x, -a, p.y); var f = o.elements[(h + o.elements.length - 1) % o.elements.length], m = o.elements[(h + 2) % o.elements.length], g = new R(-(p.y - d.y), 0, p.x - d.x), v = new R(-(d.y - f.y), 0, d.x - f.x), y = new R(-(m.y - p.y), 0, m.x - p.x); s || (g = g.scale(-1), v = v.scale(-1), y = y.scale(-1)); var b = g.normalizeToNew(), T = v.normalizeToNew(), E = y.normalizeToNew(), S = R.Dot(T, b); T = S > l ? 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 eh(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(Hi.PositionKind), p = e.getVerticesData(Hi.NormalKind), f = e.getVerticesData(Hi.UVKind), _ = e.getIndices(), m = d.length / 9, g = 0, v = 0, y = 0, b = 0, T = [0]; if (u) for (var E = m; E < d.length / 3; E += 4)v = d[3 * (E + 2)] - d[3 * E], y = d[3 * (E + 2) + 2] - d[3 * E + 2], b += Math.sqrt(v * v + y * y), T.push(b); for (var S = 0, x = 0, A = 0; A < p.length; A += 3)Math.abs(p[A + 1]) < .001 && (x = 1), Math.abs(p[A + 1] - 1) < .001 && (x = 0), Math.abs(p[A + 1] + 1) < .001 && (x = 2), S = A / 3, 1 === x ? (g = S - m, f[2 * S] = g % 4 < 1.5 ? u ? s[x].x + (s[x].z - s[x].x) * T[Math.floor(g / 4)] / b : s[x].x : u ? s[x].x + (s[x].z - s[x].x) * T[Math.floor(g / 4) + 1] / b : s[x].z, f[2 * S + 1] = g % 2 == 0 ? xn.UseOpenGLOrientationForUV ? 1 - s[x].w : s[x].w : xn.UseOpenGLOrientationForUV ? 1 - s[x].y : s[x].y) : (f[2 * S] = (1 - f[2 * S]) * s[x].x + f[2 * S] * s[x].z, f[2 * S + 1] = (1 - f[2 * S + 1]) * s[x].y + f[2 * S + 1] * s[x].w, xn.UseOpenGLOrientationForUV && (f[2 * S + 1] = 1 - f[2 * S + 1])), l && c.push(l[x].r, l[x].g, l[x].b, l[x].a); En._ComputeSides(t, d, _, p, f, n, o); var R = new En; if (R.indices = _, R.positions = d, R.normals = p, R.uvs = f, l) { var P = t === En.DOUBLESIDE ? c.concat(c) : c; R.colors = P } return R } function th(e, t, i, r) { void 0 === i && (i = null), void 0 === r && (r = earcut), t.sideOrientation = Jn._GetDefaultSideOrientation(t.sideOrientation); for (var n = t.shape, o = t.holes || [], a = t.depth || 0, s = t.smoothingThreshold || 2, l = [], c = [], u = 0; u < n.length; u++)l[u] = new A(n[u].x, n[u].z); l[0].equalsWithEpsilon(l[l.length - 1], 1e-8) && l.pop(); for (var h = new $u(e, l, i || S.LastCreatedScene, r), d = 0; d < o.length; d++) { c = []; for (var p = 0; p < o[d].length; p++)c.push(new A(o[d][p].x, o[d][p].z)); h.addHole(c) } var f = h.build(!1, a, s); return f._originalBuilderSideOrientation = t.sideOrientation, eh(f, t.sideOrientation, t.faceUV, t.faceColors, t.frontUVs, t.backUVs, t.wrap).applyToMesh(f, t.updatable), f } function ih(e, t, i, r) { return void 0 === i && (i = null), void 0 === r && (r = earcut), th(e, t, i, r) } var rh = { ExtrudePolygon: ih, CreatePolygon: th }; function nh(e, t, i) { void 0 === i && (i = null); var r = t.path, n = t.shape, o = t.scale || 1, a = t.rotation || 0, s = 0 === t.cap ? 0 : t.cap || Jn.NO_CAP, l = t.updatable, c = Jn._GetDefaultSideOrientation(t.sideOrientation), u = t.instance || null, h = t.invertUV || !1, d = t.closeShape || !1; return ah(e, n, r, o, a, null, null, t.closePath || !1, d, s, !1, i, !!l, c, u, h, t.frontUVs || null, t.backUVs || null, t.firstNormal || null, !!t.adjustFrame) } function oh(e, t, i) { void 0 === i && (i = null); var r = t.path, n = t.shape, o = t.scaleFunction || function () { return 1 }, a = t.rotationFunction || function () { return 0 }, s = t.closePath || t.ribbonCloseArray || !1, l = t.closeShape || t.ribbonClosePath || !1, c = 0 === t.cap ? 0 : t.cap || Jn.NO_CAP, u = t.updatable, h = t.firstNormal || null, d = t.adjustFrame || !1; return ah(e, n, r, null, null, o, a, s, l, c, !0, i, !!u, Jn._GetDefaultSideOrientation(t.sideOrientation), t.instance || null, t.invertUV || !1, t.frontUVs || null, t.backUVs || null, h, d) } function ah(e, t, i, r, n, o, a, s, l, c, u, h, d, p, f, _, m, g, v, y) { var b, T, E = function (e, t, i, r, n, o, a, s, l, c, u) { var h = i.getTangents(), d = i.getNormals(), p = i.getBinormals(), f = i.getDistances(); if (u) for (var _ = 0; _ < h.length; _++)if (0 == h[_].x && 0 == h[_].y && 0 == h[_].z && h[_].copyFrom(h[_ - 1]), 0 == d[_].x && 0 == d[_].y && 0 == d[_].z && d[_].copyFrom(d[_ - 1]), 0 == p[_].x && 0 == p[_].y && 0 == p[_].z && p[_].copyFrom(p[_ - 1]), _ > 0) { 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 === Jn.NO_CAP || l === Jn.CAP_END ? 0 : 2, T = O.Matrix[0]; for (_ = 0; _ < t.length; _++) { var E = new Array, S = v(_, f[_]), x = y(_, f[_]); I.RotationAxisToRef(h[_], g, T); for (var A = 0; A < e.length; A++) { var C = h[_].scale(e[A].z).add(d[_].scale(e[A].x)).add(p[_].scale(e[A].y)), P = R.Zero(); R.TransformCoordinatesToRef(C, T, P), P.scaleInPlace(x).addInPlace(t[_]), E[A] = P } r[b] = E, g += S, b++ } var M = function (e) { var t, i = Array(), r = R.Zero(); for (t = 0; t < e.length; t++)r.addInPlace(e[t]); for (r.scaleInPlace(1 / e.length), t = 0; t < e.length; t++)i.push(r); return i }; switch (l) { case Jn.NO_CAP: break; case Jn.CAP_START: r[0] = M(r[2]), r[1] = r[2]; break; case Jn.CAP_END: r[b] = r[b - 1], r[b + 1] = M(r[b - 1]); break; case Jn.CAP_ALL: r[0] = M(r[2]), r[1] = r[2], r[b] = r[b - 1], r[b + 1] = M(r[b - 1]) }return r }; if (f) { var S = f._creationDataStorage; return b = v ? S.path3D.update(i, v) : S.path3D.update(i), Ru("", { pathArray: T = E(t, i, S.path3D, S.pathArray, r, n, o, a, S.cap, u, y), closeArray: !1, closePath: !1, offset: 0, updatable: !1, sideOrientation: 0, instance: f }, h || void 0) } c = c < 0 || c > 3 ? 0 : c; var x = Ru(e, { pathArray: T = E(t, i, b = v ? new Fr(i, v) : new Fr(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 } En.CreatePolygon = eh, Jn.CreatePolygon = function (e, t, i, r, n, o, a) { return void 0 === a && (a = earcut), th(e, { shape: t, holes: r, updatable: n, sideOrientation: o }, i, a) }, Jn.ExtrudePolygon = function (e, t, i, r, n, o, a, s) { return void 0 === s && (s = earcut), ih(e, { shape: t, holes: n, depth: i, updatable: o, sideOrientation: a }, r, s) }; var sh = { ExtrudeShape: nh, ExtrudeShapeCustom: oh }; function lh(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 = Jn._GetDefaultSideOrientation(t.sideOrientation), p = t.cap || Jn.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 != Jn.CAP_START && p != Jn.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; v < s.length; v++)r = new R(Math.cos(g * y) * s[v].x * l, s[v].y, Math.sin(g * y) * s[v].x * l), n.push(r); p != Jn.CAP_END && p != Jn.CAP_ALL || (n.push(new R(Math.cos(g * y) * s[s.length - 1].x * l, s[s.length - 1].y, Math.sin(g * y) * s[s.length - 1].x * l)), n.push(new R(0, s[s.length - 1].y, 0))), _.push(n) } return Ru(e, { pathArray: _, closeArray: a, sideOrientation: d, updatable: h, invertUV: m, frontUVs: t.frontUVs, backUVs: t.backUVs }, i) } Jn.ExtrudeShape = function (e, t, i, r, n, o, a, s, l, c) { return void 0 === a && (a = null), nh(e, { shape: t, path: i, scale: r, rotation: n, cap: 0 === o ? 0 : o || Jn.NO_CAP, sideOrientation: l, instance: c, updatable: s }, a) }, Jn.ExtrudeShapeCustom = function (e, t, i, r, n, o, a, s, l, c, u, h) { return oh(e, { shape: t, path: i, scaleFunction: r, rotationFunction: n, ribbonCloseArray: o, ribbonClosePath: a, cap: 0 === s ? 0 : s || Jn.NO_CAP, sideOrientation: u, instance: h, updatable: c }, l) }; var ch = { CreateLathe: lh }; function uh(e, t, i) { void 0 === i && (i = null); var r = t.path, n = t.instance, o = 1; void 0 !== t.radius ? o = t.radius : n && (o = n._creationDataStorage.radius); var a = t.tessellation || 64, s = t.radiusFunction || null, l = t.cap || Jn.NO_CAP, c = t.invertUV || !1, u = t.updatable, h = Jn._GetDefaultSideOrientation(t.sideOrientation); t.arc = t.arc && (t.arc <= 0 || t.arc > 1) ? 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 === Jn.NO_CAP || a === Jn.CAP_END ? 0 : 2, y = 0; y < e.length; y++) { c = m(y, f[y]), l = Array(), u = p[y]; for (var b = 0; b < n; b++)I.RotationAxisToRef(d[y], _ * b, g), h = l[b] ? l[b] : R.Zero(), R.TransformCoordinatesToRef(u, g, h), h.scaleInPlace(c).addInPlace(e[y]), l[b] = h; i[v] = l, v++ } var T = function (t, i) { for (var r = Array(), n = 0; n < t; n++)r.push(e[i]); return r }; switch (a) { case Jn.NO_CAP: break; case Jn.CAP_START: i[0] = T(n, 0), i[1] = i[2].slice(0); break; case Jn.CAP_END: i[v] = i[v - 1].slice(0), i[v + 1] = T(n, e.length - 1); break; case Jn.CAP_ALL: i[0] = T(n, 0), i[1] = i[2].slice(0), i[v] = i[v - 1].slice(0), i[v + 1] = T(n, e.length - 1) }return i }; if (n) { var _ = n._creationDataStorage, m = t.arc || _.arc; return n = Ru("", { pathArray: p = f(r, d = _.path3D.update(r), _.pathArray, o, _.tessellation, s, _.cap, m), instance: n }), _.path3D = d, _.pathArray = p, _.arc = m, _.radius = o, n } l = l < 0 || l > 3 ? 0 : l; var g = Ru(e, { pathArray: p = f(r, d = new Fr(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 } Jn.CreateLathe = function (e, t, i, r, n, o, a) { return lh(e, { shape: t, radius: i, tessellation: r, sideOrientation: a, updatable: o }, n) }; var hh = { CreateTube: uh }; function dh(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 || En.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; I < f; I++)m && void 0 === m[I] && (m[I] = new U(1, 1, 1, 1)), _ && void 0 === _[I] && (_[I] = new C(0, 0, 1, 1)); if (g) for (I = 0; I < f; I++) { var M = p.face[I].length; for (n = 2 * Math.PI / M, o = .5 * Math.tan(n / 2), a = .5, P = 0; P < M; P++)y.push(p.vertex[p.face[I][P]][0] * u, p.vertex[p.face[I][P]][1] * h, p.vertex[p.face[I][P]][2] * d), R.push(x), x++, i = _[I].x + (_[I].z - _[I].x) * (.5 + o), r = _[I].y + (_[I].w - _[I].y) * (a - .5), E.push(i, xn.UseOpenGLOrientationForUV ? 1 - r : r), s = o * Math.cos(n) - a * Math.sin(n), a = o * Math.sin(n) + a * Math.cos(n), o = s, m && S.push(m[I].r, m[I].g, m[I].b, m[I].a); for (P = 0; P < M - 2; P++)b.push(R[0 + A], R[P + 2 + A], R[P + 1 + A]); A += M } else { for (P = 0; P < p.vertex.length; P++)y.push(p.vertex[P][0] * u, p.vertex[P][1] * h, p.vertex[P][2] * d), E.push(0, xn.UseOpenGLOrientationForUV ? 1 : 0); for (I = 0; I < f; I++)for (P = 0; P < p.face[I].length - 2; P++)b.push(p.face[I][0], p.face[I][P + 2], p.face[I][P + 1]) } En.ComputeNormals(y, b, T), En._ComputeSides(v, y, b, T, E, e.frontUVs, e.backUVs); var O = new En; return O.positions = y, O.indices = b, O.normals = T, O.uvs = E, m && g && (O.colors = S), O } function ph(e, t, i) { void 0 === t && (t = {}), void 0 === i && (i = null); var r = new Jn(e, i); return t.sideOrientation = Jn._GetDefaultSideOrientation(t.sideOrientation), r._originalBuilderSideOrientation = t.sideOrientation, dh(t).applyToMesh(r, t.updatable), r } Jn.CreateTube = function (e, t, i, r, n, o, a, s, l, c) { return uh(e, { path: t, radius: i, tessellation: r, radiusFunction: n, arc: 1, cap: o, updatable: s, sideOrientation: l, instance: c }, a) }; var fh = { CreatePolyhedron: ph }; En.CreatePolyhedron = dh, Jn.CreatePolyhedron = function (e, t, i) { return ph(e, t, i) }; var _h = new R(1, 0, 0), mh = new R(-1, 0, 0), gh = new R(0, 1, 0), vh = new R(0, -1, 0), yh = new R(0, 0, 1), bh = new R(0, 0, -1), Th = function () { function e(e, t, i, r, n, o, a, s, l) { void 0 === e && (e = R.Zero()), void 0 === t && (t = R.Up()), void 0 === i && (i = A.Zero()), void 0 === r && (r = 0), void 0 === n && (n = 0), void 0 === o && (o = null), void 0 === a && (a = null), void 0 === s && (s = null), void 0 === l && (l = null), this.position = e, this.normal = t, this.uv = i, this.vertexIdx = r, this.vertexIdxForBones = n, this.localPositionOverride = o, this.localNormalOverride = a, this.matrixIndicesOverride = s, this.matrixWeightsOverride = l } return e.prototype.clone = function () { var t, i, r, n; return new e(this.position.clone(), this.normal.clone(), this.uv.clone(), this.vertexIdx, this.vertexIdxForBones, null === (t = this.localPositionOverride) || void 0 === t ? void 0 : t.slice(), null === (i = this.localNormalOverride) || void 0 === i ? void 0 : i.slice(), null === (r = this.matrixIndicesOverride) || void 0 === r ? void 0 : r.slice(), null === (n = this.matrixWeightsOverride) || void 0 === n ? void 0 : n.slice()) }, e }(); function Eh(e, t, i) { var r, n, o, a, s = !!t.skeleton, l = i.localMode || s, c = null !== t.overrideMaterialSideOrientation && void 0 !== t.overrideMaterialSideOrientation, u = t.getIndices(), d = s ? t.getPositionData(!0, !0) : t.getVerticesData(Hi.PositionKind), p = s ? t.getNormalsData(!0, !0) : t.getVerticesData(Hi.NormalKind), f = l ? s ? t.getVerticesData(Hi.PositionKind) : d : null, _ = l ? s ? t.getVerticesData(Hi.NormalKind) : p : null, m = t.getVerticesData(Hi.UVKind), g = s ? t.getVerticesData(Hi.MatricesIndicesKind) : null, v = s ? t.getVerticesData(Hi.MatricesWeightsKind) : null, y = s ? t.getVerticesData(Hi.MatricesIndicesExtraKind) : null, b = s ? t.getVerticesData(Hi.MatricesWeightsExtraKind) : null, T = i.position || R.Zero(), E = i.normal || R.Up(), S = i.size || R.One(), x = i.angle || 0; if (!E) { var C = new R(0, 0, 1), P = t.getScene().activeCamera, M = R.TransformCoordinates(C, P.getWorldMatrix()); E = P.globalPosition.subtract(M) } var D = -Math.atan2(E.z, E.x) - Math.PI / 2, N = Math.sqrt(E.x * E.x + E.z * E.z), F = Math.atan2(E.y, N), L = new En; L.indices = [], L.positions = [], L.normals = [], L.uvs = [], L.matricesIndices = s ? [] : null, L.matricesWeights = s ? [] : null, L.matricesIndicesExtra = y ? [] : null, L.matricesWeightsExtra = b ? [] : null; var w = 0, B = function (e, t) { var r = new Th; if (!u || !d || !p) return r; var n = u[e]; if (r.vertexIdx = 3 * n, r.vertexIdxForBones = 4 * n, r.position = new R(d[3 * n], d[3 * n + 1], d[3 * n + 2]), R.TransformCoordinatesToRef(r.position, t, r.position), r.normal = new R(p[3 * n], p[3 * n + 1], p[3 * n + 2]), R.TransformNormalToRef(r.normal, t, r.normal), i.captureUVS && m) { var o = m[2 * n + 1]; r.uv = new A(m[2 * n], xn.UseOpenGLOrientationForUV ? 1 - o : o) } return r }, U = [0, 0, 0, 0], V = function (e, t) { if (0 === e.length) return e; var i = .5 * Math.abs(R.Dot(S, t)), r = function (e, t, i, r) { for (var n = 0; n < r; ++n)if (e[i + n] === t) return i + n; return -1 }, n = function (e, n) { var o, a, s, l, c, u, d, p, m, y, b, T, E, S, x, C, P = R.GetClipFactor(e.position, n.position, t, i), I = U, M = U; if (g && v) { var O = e.matrixIndicesOverride ? 0 : e.vertexIdxForBones, D = null !== (o = e.matrixIndicesOverride) && void 0 !== o ? o : g, N = null !== (a = e.matrixWeightsOverride) && void 0 !== a ? a : v, F = n.matrixIndicesOverride ? 0 : n.vertexIdxForBones, L = null !== (s = n.matrixIndicesOverride) && void 0 !== s ? s : g, w = null !== (l = n.matrixWeightsOverride) && void 0 !== l ? l : v; I = [0, 0, 0, 0], M = [0, 0, 0, 0]; for (var B = 0, V = 0; V < 4; ++V)if (N[O + V] > 0) { 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 Th(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; a < e.length; a += 3) { var s = null, l = null, c = null, u = null, d = R.Dot(e[a].position, t) - i > 0, 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 Jn ? 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; H < z; ++H) { if ((null == k ? void 0 : k.hasThinInstances) && G) { var X = 16 * H; W.setRowFromFloats(0, G[X + 0], G[X + 1], G[X + 2], G[X + 3]), W.setRowFromFloats(1, G[X + 4], G[X + 5], G[X + 6], G[X + 7]), W.setRowFromFloats(2, G[X + 8], G[X + 9], G[X + 10], G[X + 11]), W.setRowFromFloats(3, G[X + 12], G[X + 13], G[X + 14], G[X + 15]) } for (var j = I.RotationYawPitchRoll(D, F, x).multiply(I.Translation(T.x, T.y, T.z)), Y = I.Invert(j), K = t.getWorldMatrix(), Q = W.multiply(K).multiply(Y), q = new Array(3), Z = 0; Z < u.length; Z += 3) { var J = q; if (J[0] = B(Z, Q), c && l ? (J[1] = B(Z + 2, Q), J[2] = B(Z + 1, Q)) : (J[1] = B(Z + 1, Q), J[2] = B(Z + 2, Q)), !(i.cullBackFaces && -J[0].normal.z <= 0 && -J[1].normal.z <= 0 && -J[2].normal.z <= 0) && (J = V(J, _h)) && (J = V(J, mh)) && (J = V(J, gh)) && (J = V(J, vh)) && (J = V(J, yh)) && (J = V(J, bh))) for (var $ = 0; $ < J.length; $++) { var ee = J[$]; if (L.indices.push(w), l ? (ee.localPositionOverride ? (L.positions[3 * w] = ee.localPositionOverride[0], L.positions[3 * w + 1] = ee.localPositionOverride[1], L.positions[3 * w + 2] = ee.localPositionOverride[2]) : f && (L.positions[3 * w] = f[ee.vertexIdx], L.positions[3 * w + 1] = f[ee.vertexIdx + 1], L.positions[3 * w + 2] = f[ee.vertexIdx + 2]), ee.localNormalOverride ? (L.normals[3 * w] = ee.localNormalOverride[0], L.normals[3 * w + 1] = ee.localNormalOverride[1], L.normals[3 * w + 2] = ee.localNormalOverride[2]) : _ && (L.normals[3 * w] = _[ee.vertexIdx], L.normals[3 * w + 1] = _[ee.vertexIdx + 1], L.normals[3 * w + 2] = _[ee.vertexIdx + 2])) : (ee.position.toArray(L.positions, 3 * w), ee.normal.toArray(L.normals, 3 * w)), L.matricesIndices && L.matricesWeights && (ee.matrixIndicesOverride ? (L.matricesIndices[4 * w] = ee.matrixIndicesOverride[0], L.matricesIndices[4 * w + 1] = ee.matrixIndicesOverride[1], L.matricesIndices[4 * w + 2] = ee.matrixIndicesOverride[2], L.matricesIndices[4 * w + 3] = ee.matrixIndicesOverride[3]) : (g && (L.matricesIndices[4 * w] = g[ee.vertexIdxForBones], L.matricesIndices[4 * w + 1] = g[ee.vertexIdxForBones + 1], L.matricesIndices[4 * w + 2] = g[ee.vertexIdxForBones + 2], L.matricesIndices[4 * w + 3] = g[ee.vertexIdxForBones + 3]), y && L.matricesIndicesExtra && (L.matricesIndicesExtra[4 * w] = y[ee.vertexIdxForBones], L.matricesIndicesExtra[4 * w + 1] = y[ee.vertexIdxForBones + 1], L.matricesIndicesExtra[4 * w + 2] = y[ee.vertexIdxForBones + 2], L.matricesIndicesExtra[4 * w + 3] = y[ee.vertexIdxForBones + 3])), ee.matrixWeightsOverride ? (L.matricesWeights[4 * w] = ee.matrixWeightsOverride[0], L.matricesWeights[4 * w + 1] = ee.matrixWeightsOverride[1], L.matricesWeights[4 * w + 2] = ee.matrixWeightsOverride[2], L.matricesWeights[4 * w + 3] = ee.matrixWeightsOverride[3]) : (v && (L.matricesWeights[4 * w] = v[ee.vertexIdxForBones], L.matricesWeights[4 * w + 1] = v[ee.vertexIdxForBones + 1], L.matricesWeights[4 * w + 2] = v[ee.vertexIdxForBones + 2], L.matricesWeights[4 * w + 3] = v[ee.vertexIdxForBones + 3]), b && L.matricesWeightsExtra && (L.matricesWeightsExtra[4 * w] = b[ee.vertexIdxForBones], L.matricesWeightsExtra[4 * w + 1] = b[ee.vertexIdxForBones + 1], L.matricesWeightsExtra[4 * w + 2] = b[ee.vertexIdxForBones + 2], L.matricesWeightsExtra[4 * w + 3] = b[ee.vertexIdxForBones + 3]))), i.captureUVS) ee.uv.toArray(L.uvs, 2 * w); else { L.uvs.push(.5 + ee.position.x / S.x); var te = .5 + ee.position.y / S.y; L.uvs.push(xn.UseOpenGLOrientationForUV ? 1 - te : te) } w++ } } } 0 === L.indices.length && (L.indices = null), 0 === L.positions.length && (L.positions = null), 0 === L.normals.length && (L.normals = null), 0 === L.uvs.length && (L.uvs = null), 0 === (null === (r = L.matricesIndices) || void 0 === r ? void 0 : r.length) && (L.matricesIndices = null), 0 === (null === (n = L.matricesWeights) || void 0 === n ? void 0 : n.length) && (L.matricesWeights = null), 0 === (null === (o = L.matricesIndicesExtra) || void 0 === o ? void 0 : o.length) && (L.matricesIndicesExtra = null), 0 === (null === (a = L.matricesWeightsExtra) || void 0 === a ? void 0 : a.length) && (L.matricesWeightsExtra = null); var ie = new Jn(e, t.getScene()); return L.applyToMesh(ie), l ? (ie.skeleton = t.skeleton, ie.parent = t) : (ie.position = T.clone(), ie.rotation = new R(F, D, x)), ie.computeWorldMatrix(!0), ie.refreshBoundingInfo(!0, !0), ie } var Sh = { CreateDecal: Eh }; Jn.CreateDecal = function (e, t, i, r, n, o) { return Eh(e, t, { position: i, normal: r, size: n, angle: o }) }; var xh = function () { function e(e, t) { void 0 === e && (e = 0), void 0 === t && (t = 0), this.x = e, this.y = t, e !== Math.floor(e) && (Math.floor(e), $.Warn("x is not an integer, floor(x) used")), t !== Math.floor(t) && (Math.floor(t), $.Warn("y is not an integer, floor(y) used")) } return e.prototype.clone = function () { return new e(this.x, this.y) }, e.prototype.rotate60About = function (e) { var t = this.x; return this.x = e.x + e.y - this.y, this.y = t + this.y - e.x, this }, e.prototype.rotateNeg60About = function (e) { var t = this.x; return this.x = t + this.y - e.y, this.y = e.x + e.y - t, this }, e.prototype.rotate120 = function (e, t) { e !== Math.floor(e) && (Math.floor(e), $.Warn("m not an integer only floor(m) used")), t !== Math.floor(t) && (Math.floor(t), $.Warn("n not an integer only floor(n) used")); var i = this.x; return this.x = e - i - this.y, this.y = t + i, this }, e.prototype.rotateNeg120 = function (e, t) { e !== Math.floor(e) && (Math.floor(e), $.Warn("m is not an integer, floor(m) used")), t !== Math.floor(t) && (Math.floor(t), $.Warn("n is not an integer, floor(n) used")); var i = this.x; return this.x = this.y - t, this.y = e + t - i - this.y, this }, e.prototype.toCartesianOrigin = function (e, t) { var i = R.Zero(); return i.x = e.x + 2 * this.x * t + this.y * t, i.y = e.y + Math.sqrt(3) * this.y * t, i }, e.Zero = function () { return new e(0, 0) }, e }(), Ah = function () { function e() { this.cartesian = [], this.vertices = [], this.max = [], this.min = [], this.closestTo = [], this.innerFacets = [], this.isoVecsABOB = [], this.isoVecsOBOA = [], this.isoVecsBAOA = [], this.vertexTypes = [], this.IDATA = new Rh("icosahedron", "Regular", [[0, f, -1], [-f, 1, 0], [-1, 0, -f], [1, 0, -f], [f, 1, 0], [0, f, 1], [-1, 0, f], [-f, -1, 0], [0, -f, -1], [f, -1, 0], [1, 0, f], [0, -f, 1]], [[0, 2, 1], [0, 3, 2], [0, 4, 3], [0, 5, 4], [0, 1, 5], [7, 6, 1], [8, 7, 2], [9, 8, 3], [10, 9, 4], [6, 10, 5], [2, 7, 1], [3, 8, 2], [4, 9, 3], [5, 10, 4], [1, 6, 5], [11, 6, 7], [11, 7, 8], [11, 8, 9], [11, 9, 10], [11, 10, 6]]) } return e.prototype.setIndices = function () { var e, t, i, r, n, o, a, s = 12, l = {}, c = this.m, u = this.n, d = c; 0 !== u && (d = h.HCF(c, u)), e = c / d, t = u / d; var p, f, _, m = xh.Zero(), g = new xh(c, u), v = new xh(-u, c + u), y = xh.Zero(), b = xh.Zero(), T = xh.Zero(), E = [], S = [], x = this.vertByDist, A = function (e, t, i, r) { f = t + "|" + r, (p = e + "|" + i) in l || f in l ? p in l && !(f in l) ? l[f] = l[p] : f in l && !(p in l) && (l[p] = l[f]) : (l[p] = s, l[f] = s, s++), x[i][0] > 2 ? 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; C < d; C++)b.x = c - C * (e + t), b.y = u + C * e, T.x = -C * t, T.y = C * (e + t), A(R, i, _ = b.x + "|" + b.y, T.x + "|" + T.y); if ("O" === r) for (C = 1; C < d; C++)T.x = -C * t, T.y = C * (e + t), y.x = C * e, y.y = C * t, A(R, i, _ = T.x + "|" + T.y, y.x + "|" + y.y); if (i = this.IDATA.edgematch[R][2], (r = this.IDATA.edgematch[R][3]) && "A" === r) for (C = 1; C < d; C++)y.x = C * e, y.y = C * t, b.x = c - (d - C) * (e + t), b.y = u + (d - C) * e, A(R, i, _ = y.x + "|" + y.y, b.x + "|" + b.y); for (C = 0; C < this.vertices.length; C++)_ = this.vertices[C].x + "|" + this.vertices[C].y, (p = R + "|" + _) in l || (l[p] = s++, x[_][0] > 2 ? 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; i < t + e + 1; i++)for (var r = this.min[i]; r < this.max[i] + 1; r++)r < this.max[i] && r < this.max[i + 1] + 1 && this.innerFacets.push(["|" + r + "|" + i, "|" + r + "|" + (i + 1), "|" + (r + 1) + "|" + i]), i > 0 && r < this.max[i - 1] && r + 1 < this.max[i] + 1 && this.innerFacets.push(["|" + r + "|" + i, "|" + (r + 1) + "|" + i, "|" + (r + 1) + "|" + (i - 1)]) }, e.prototype.edgeVecsABOB = function () { for (var e = this.m, t = this.n, i = new xh(-t, e + t), r = 1; r < e + t; r++) { var n = new xh(this.min[r], r), o = new xh(this.min[r - 1], r - 1), a = new xh(this.min[r + 1], r + 1), s = n.clone(), l = o.clone(), c = a.clone(); s.rotate60About(i), l.rotate60About(i), c.rotate60About(i); var u = new xh(this.max[s.y], s.y), h = new xh(this.max[s.y - 1], s.y - 1), d = new xh(this.max[s.y - 1] - 1, s.y - 1); s.x === u.x && s.y === u.y || (s.x !== h.x ? (this.vertexTypes.push([1, 0, 0]), this.isoVecsABOB.push([n, h, d]), this.vertexTypes.push([1, 0, 0]), this.isoVecsABOB.push([n, d, u])) : s.y === c.y ? (this.vertexTypes.push([1, 1, 0]), this.isoVecsABOB.push([n, o, h]), this.vertexTypes.push([1, 0, 1]), this.isoVecsABOB.push([n, h, a])) : (this.vertexTypes.push([1, 1, 0]), this.isoVecsABOB.push([n, o, h]), this.vertexTypes.push([1, 0, 0]), this.isoVecsABOB.push([n, h, u]))) } }, e.prototype.mapABOBtoOBOA = function () { for (var e = new xh(0, 0), t = 0; t < this.isoVecsABOB.length; t++) { for (var i = [], r = 0; r < 3; r++)e.x = this.isoVecsABOB[t][r].x, e.y = this.isoVecsABOB[t][r].y, 0 === this.vertexTypes[t][r] && e.rotateNeg120(this.m, this.n), i.push(e.clone()); this.isoVecsOBOA.push(i) } }, e.prototype.mapABOBtoBAOA = function () { for (var e = new xh(0, 0), t = 0; t < this.isoVecsABOB.length; t++) { for (var i = [], r = 0; r < 3; r++)e.x = this.isoVecsABOB[t][r].x, e.y = this.isoVecsABOB[t][r].y, 1 === this.vertexTypes[t][r] && e.rotate120(this.m, this.n), i.push(e.clone()); this.isoVecsBAOA.push(i) } }, e.prototype.MapToFace = function (e, t) { for (var i, r = this.IDATA.face[e], n = r[2], o = r[1], a = r[0], s = R.FromArray(this.IDATA.vertex[n]), l = R.FromArray(this.IDATA.vertex[o]), c = R.FromArray(this.IDATA.vertex[a]), u = l.subtract(s), h = c.subtract(s), d = u.scale(this.coau).add(h.scale(this.cobu)), p = u.scale(this.coav).add(h.scale(this.cobv)), f = [], _ = O.Vector3[0], m = 0; m < this.cartesian.length; m++)_ = d.scale(this.cartesian[m].x).add(p.scale(this.cartesian[m].y)).add(s), f[m] = [_.x, _.y, _.z], i = e + "|" + this.vertices[m].x + "|" + this.vertices[m].y, t.vertex[this.vecToidx[i]] = [_.x, _.y, _.z] }, e.prototype.build = function (e, t) { var i = new Array, r = xh.Zero(), n = new xh(e, t), o = new xh(-t, e + t); i.push(r, n, o); for (var a = t; a < e + 1; a++)for (var s = 0; s < e + 1 - a; s++)i.push(new xh(s, a)); if (t > 0) { for (var l = h.HCF(e, t), c = e / l, u = t / l, d = 1; d < l; d++)i.push(new xh(d * c, d * u)), i.push(new xh(-d * u, d * (c + u))), i.push(new xh(e - d * (c + u), t + d * c)); for (var p = e / t, f = 1; f < t; f++)for (var _ = 0; _ < f * p; _++)i.push(new xh(_, f)), i.push(new xh(_, f).rotate120(e, t)), i.push(new xh(_, f).rotateNeg120(e, t)) } i.sort((function (e, t) { return e.x - t.x })), i.sort((function (e, t) { return e.y - t.y })); var m = new Array(e + t + 1), g = new Array(e + t + 1); for (d = 0; d < m.length; d++)m[d] = 1 / 0, g[d] = -1 / 0; var v = 0, y = 0, b = i.length; for (d = 0; d < b; d++)y = i[d].x, m[v = i[d].y] = Math.min(y, m[v]), g[v] = Math.max(y, g[v]); var T = function (i, r) { var n = i.clone(); return "A" === r && n.rotateNeg120(e, t), "B" === r && n.rotate120(e, t), n.x < 0 ? n.y : n.x + n.y }, E = [], S = [], x = [], A = [], R = {}, C = [], P = -1, I = -1; for (d = 0; d < b; d++)E[d] = i[d].toCartesianOrigin(new xh(0, 0), .5), S[d] = T(i[d], "O"), x[d] = T(i[d], "A"), A[d] = T(i[d], "B"), S[d] === x[d] && x[d] === A[d] ? (P = 3, I = S[d]) : S[d] === x[d] ? (P = 4, I = S[d]) : x[d] === A[d] ? (P = 5, I = x[d]) : A[d] === S[d] && (P = 6, I = S[d]), S[d] < x[d] && S[d] < A[d] && (P = 2, I = S[d]), x[d] < S[d] && x[d] < A[d] && (P = 1, I = x[d]), A[d] < x[d] && A[d] < S[d] && (P = 0, I = A[d]), C.push([P, I, i[d].x, i[d].y]); C.sort((function (e, t) { return e[2] - t[2] })), C.sort((function (e, t) { return e[3] - t[3] })), C.sort((function (e, t) { return e[1] - t[1] })), C.sort((function (e, t) { return e[0] - t[0] })); for (var M = 0; M < C.length; M++)R[C[M][2] + "|" + C[M][3]] = [C[M][0], C[M][1], M]; return this.m = e, this.n = t, this.vertices = i, this.vertByDist = R, this.cartesian = E, this.min = m, this.max = g, this }, e }(), Rh = function (e, t, i, r) { this.name = e, this.category = t, this.vertex = i, this.face = r }, Ch = function (e) { function t() { return null !== e && e.apply(this, arguments) || this } return W(t, e), t.prototype.innerToData = function (e, t) { for (var i = 0; i < t.innerFacets.length; i++)this.face.push(t.innerFacets[i].map((function (i) { return t.vecToidx[e + i] }))) }, t.prototype.mapABOBtoDATA = function (e, t) { for (var i = t.IDATA.edgematch[e][0], r = 0; r < t.isoVecsABOB.length; r++) { for (var n = [], o = 0; o < 3; o++)0 === t.vertexTypes[r][o] ? n.push(e + "|" + t.isoVecsABOB[r][o].x + "|" + t.isoVecsABOB[r][o].y) : n.push(i + "|" + t.isoVecsABOB[r][o].x + "|" + t.isoVecsABOB[r][o].y); this.face.push([t.vecToidx[n[0]], t.vecToidx[n[1]], t.vecToidx[n[2]]]) } }, t.prototype.mapOBOAtoDATA = function (e, t) { for (var i = t.IDATA.edgematch[e][0], r = 0; r < t.isoVecsOBOA.length; r++) { for (var n = [], o = 0; o < 3; o++)1 === t.vertexTypes[r][o] ? n.push(e + "|" + t.isoVecsOBOA[r][o].x + "|" + t.isoVecsOBOA[r][o].y) : n.push(i + "|" + t.isoVecsOBOA[r][o].x + "|" + t.isoVecsOBOA[r][o].y); this.face.push([t.vecToidx[n[0]], t.vecToidx[n[1]], t.vecToidx[n[2]]]) } }, t.prototype.mapBAOAtoDATA = function (e, t) { for (var i = t.IDATA.edgematch[e][2], r = 0; r < t.isoVecsBAOA.length; r++) { for (var n = [], o = 0; o < 3; o++)1 === t.vertexTypes[r][o] ? n.push(e + "|" + t.isoVecsBAOA[r][o].x + "|" + t.isoVecsBAOA[r][o].y) : n.push(i + "|" + t.isoVecsBAOA[r][o].x + "|" + t.isoVecsBAOA[r][o].y); this.face.push([t.vecToidx[n[0]], t.vecToidx[n[1]], t.vecToidx[n[2]]]) } }, t.prototype.orderData = function (e) { for (var t = [], i = 0; i < 13; i++)t[i] = []; var r = e.closestTo; for (i = 0; i < r.length; i++)r[i][0] > -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; a < t[i].length; a++)n[t[i][a][0]] = o++ } for (a = 0; a < t[12].length; a++)n[t[12][a][0]] = o++; for (i = 0; i < this.vertex.length; i++)this.vertex[i].push(n[i]); for (this.vertex.sort((function (e, t) { return e[3] - t[3] })), i = 0; i < this.vertex.length; i++)this.vertex[i].pop(); for (i = 0; i < this.face.length; i++)for (a = 0; a < this.face[i].length; a++)this.face[i][a] = n[this.face[i][a]]; this.sharedNodes = t[12].length, this.poleNodes = this.vertex.length - this.sharedNodes }, t.prototype.setOrder = function (e, t) { var i = [], r = [], n = t.pop(); r.push(n); var o = this.face[n].indexOf(e); o = (o + 2) % 3; var a = this.face[n][o]; i.push(a); for (var s = 0; t.length > 0;)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 Rh("GeoDual", "Goldberg", [], []); t.name = "GD dual"; for (var i = this.vertex.length, r = new Array(i), n = 0; n < i; n++)r[n] = []; for (var o = 0; o < this.face.length; o++)for (var a = 0; a < 3; a++)r[this.face[o][a]].push(o); var s = 0, l = 0, c = 0, u = [], h = []; this.adjacentFaces = []; for (var d = 0; d < r.length; d++)t.face[d] = this.setOrder(d, r[d].concat([])), r[d].forEach((function (i) { s = 0, l = 0, c = 0, u = e.face[i]; for (var r = 0; r < 3; r++)h = e.vertex[u[r]], s += h[0], l += h[1], c += h[2]; t.vertex[i] = [s / 3, l / 3, c / 3] })); return t }, t.BuildGeodesicData = function (e) { var i = new t("Geodesic-m-n", "Geodesic", [[0, f, -1], [-f, 1, 0], [-1, 0, -f], [1, 0, -f], [f, 1, 0], [0, f, 1], [-1, 0, f], [-f, -1, 0], [0, -f, -1], [f, -1, 0], [1, 0, f], [0, -f, 1]], []); e.setIndices(), e.calcCoeffs(), e.createInnerFacets(), e.edgeVecsABOB(), e.mapABOBtoOBOA(), e.mapABOBtoBAOA(); for (var r = 0; r < e.IDATA.face.length; r++)e.MapToFace(r, i), i.innerToData(r, e), "B" === e.IDATA.edgematch[r][1] && i.mapABOBtoDATA(r, e), "O" === e.IDATA.edgematch[r][1] && i.mapOBOAtoDATA(r, e), "A" === e.IDATA.edgematch[r][3] && i.mapBAOAtoDATA(r, e); return i.orderData(e), i.vertex = i.vertex.map((function (e) { var t = e[0], i = e[1], r = e[2], n = Math.sqrt(t * t + i * i + r * r); return e[0] *= 1 / n, e[1] *= 1 / n, e[2] *= 1 / n, e })), i }, t }(Rh); function Ph(e, t, i) { void 0 === i && (i = null); var r = t.m || 1; r !== Math.floor(r) && (Math.floor(r), $.Warn("m not an integer only floor(m) used")); var n = t.n || 0; if (n !== Math.floor(n) && (Math.floor(n), $.Warn("n not an integer only floor(n) used")), n > r) { var o = n; n = r, r = o, $.Warn("n > m therefore m and n swapped") } var a = new Ah; return a.build(r, n), ph(e, { custom: Ch.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) } Jn._GoldbergMeshParser = function (e, t) { return Ih.Parse(e, t) }; var Ih = 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; t < e.length; t++)for (var i = e[t][0], r = e[t][1], n = e[t][2], o = i; o < r + 1; o++)this.goldbergData.faceColors[o] = n; var a = []; for (o = 0; o < 12; o++)for (t = 0; t < 5; t++)a.push(this.goldbergData.faceColors[o].r, this.goldbergData.faceColors[o].g, this.goldbergData.faceColors[o].b, this.goldbergData.faceColors[o].a); for (o = 12; o < this.goldbergData.faceColors.length; o++)for (t = 0; t < 6; t++)a.push(this.goldbergData.faceColors[o].r, this.goldbergData.faceColors[o].g, this.goldbergData.faceColors[o].b, this.goldbergData.faceColors[o].a); return a }, t.prototype.setGoldbergFaceColors = function (e) { var t = this._changeGoldbergFaceColors(e); this.setVerticesData(Hi.ColorKind, t) }, t.prototype.updateGoldbergFaceColors = function (e) { var t = this._changeGoldbergFaceColors(e); this.updateVerticesData(Hi.ColorKind, t) }, t.prototype._changeGoldbergFaceUVs = function (e) { for (var t = this.getVerticesData(Hi.UVKind), i = 0; i < e.length; i++) { for (var r = e[i][0], n = e[i][1], o = e[i][2], a = e[i][3], s = e[i][4], l = [], c = [], u = void 0, h = void 0, d = 0; d < 5; d++)u = o.x + a * Math.cos(s + d * Math.PI / 2.5), h = o.y + a * Math.sin(s + d * Math.PI / 2.5), u < 0 && (u = 0), u > 1 && (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; p < Math.min(12, n + 1); p++)for (d = 0; d < 5; d++)t[10 * p + 2 * d] = l[2 * d], t[10 * p + 2 * d + 1] = l[2 * d + 1]; for (p = Math.max(12, r); p < n + 1; p++)for (d = 0; d < 6; d++)t[12 * p - 24 + 2 * d] = c[2 * d], t[12 * p - 23 + 2 * d] = c[2 * d + 1] } return t }, t.prototype.setGoldbergFaceUVs = function (e) { var t = this._changeGoldbergFaceUVs(e); this.setVerticesData(Hi.UVKind, t) }, t.prototype.updateGoldbergFaceUVs = function (e) { var t = this._changeGoldbergFaceUVs(e); this.updateVerticesData(Hi.UVKind, t) }, t.prototype.placeOnGoldbergFaceAt = function (e, t, i) { var r = R.RotationFromAxis(this.goldbergData.faceXaxis[t], this.goldbergData.faceYaxis[t], this.goldbergData.faceZaxis[t]); e.rotation = r, e.position = this.goldbergData.faceCenters[t].add(this.goldbergData.faceXaxis[t].scale(i.x)).add(this.goldbergData.faceYaxis[t].scale(i.y)).add(this.goldbergData.faceZaxis[t].scale(i.z)) }, t.prototype.serialize = function (t) { e.prototype.serialize.call(this, t), t.type = "GoldbergMesh"; var i = {}; if (i.adjacentFaces = this.goldbergData.adjacentFaces, i.nbSharedFaces = this.goldbergData.nbSharedFaces, i.nbUnsharedFaces = this.goldbergData.nbUnsharedFaces, i.nbFaces = this.goldbergData.nbFaces, i.nbFacesAtPole = this.goldbergData.nbFacesAtPole, this.goldbergData.faceColors) { i.faceColors = []; for (var r = 0, n = this.goldbergData.faceColors; r < n.length; r++) { var o = n[r]; i.faceColors.push(o.asArray()) } } if (this.goldbergData.faceCenters) { i.faceCenters = []; for (var a = 0, s = this.goldbergData.faceCenters; a < s.length; a++) { var l = s[a]; i.faceCenters.push(l.asArray()) } } if (this.goldbergData.faceZaxis) { i.faceZaxis = []; for (var c = 0, u = this.goldbergData.faceZaxis; c < u.length; c++)l = u[c], i.faceZaxis.push(l.asArray()) } if (this.goldbergData.faceYaxis) { i.faceYaxis = []; for (var h = 0, d = this.goldbergData.faceYaxis; h < d.length; h++)l = d[h], i.faceYaxis.push(l.asArray()) } if (this.goldbergData.faceXaxis) { i.faceXaxis = []; for (var p = 0, f = this.goldbergData.faceXaxis; p < f.length; p++)l = f[p], i.faceXaxis.push(l.asArray()) } t.goldbergData = i }, t.Parse = function (e, i) { var r = e.goldbergData; r.faceColors = r.faceColors.map((function (e) { return U.FromArray(e) })), r.faceCenters = r.faceCenters.map((function (e) { return R.FromArray(e) })), r.faceZaxis = r.faceZaxis.map((function (e) { return R.FromArray(e) })), r.faceXaxis = r.faceXaxis.map((function (e) { return R.FromArray(e) })), r.faceYaxis = r.faceYaxis.map((function (e) { return R.FromArray(e) })); var n = new t(e.name, i); return n.goldbergData = r, n }, t }(Jn); function Mh(e, t) { for (var i = e.size, r = e.sizeX || i || 1, n = e.sizeY || i || 1, o = e.sizeZ || i || 1, a = 0 === e.sideOrientation ? 0 : e.sideOrientation || En.DEFAULTSIDE, s = new Array, l = new Array, c = new Array, u = new Array, h = 1 / 0, d = -1 / 0, p = 1 / 0, f = -1 / 0, _ = 0; _ < t.vertex.length; _++)h = Math.min(h, t.vertex[_][0] * r), d = Math.max(d, t.vertex[_][0] * r), p = Math.min(p, t.vertex[_][1] * n), f = Math.max(f, t.vertex[_][1] * n); for (var m = 0, g = 0; g < t.face.length; g++) { var v = t.face[g], y = R.FromArray(t.vertex[v[0]]), b = R.FromArray(t.vertex[v[2]]), T = R.FromArray(t.vertex[v[1]]), E = b.subtract(y), S = T.subtract(y), x = R.Cross(S, E).normalize(); for (_ = 0; _ < v.length; _++) { c.push(x.x, x.y, x.z); var A = t.vertex[v[_]]; s.push(A[0] * r, A[1] * n, A[2] * o); var C = (A[1] * n - p) / (f - p); u.push((A[0] * r - h) / (d - h), xn.UseOpenGLOrientationForUV ? 1 - C : C) } for (_ = 0; _ < v.length - 2; _++)l.push(m, m + _ + 2, m + _ + 1); m += v.length } En._ComputeSides(a, s, l, c, u); var P = new En; return P.positions = s, P.indices = l, P.normals = c, P.uvs = u, P } function Oh(e, t, i) { void 0 === i && (i = null); var r = t.size, n = t.sizeX || r || 1, o = t.sizeY || r || 1, a = t.sizeZ || r || 1, s = t.m || 1; s !== Math.floor(s) && (Math.floor(s), $.Warn("m not an integer only floor(m) used")); var l = t.n || 0; if (l !== Math.floor(l) && (Math.floor(l), $.Warn("n not an integer only floor(n) used")), l > s) { var c = l; l = s, s = c, $.Warn("n > m therefore m and n swapped") } var u = new Ah; u.build(s, l); var h = Ch.BuildGeodesicData(u), d = h.toGoldbergPolyhedronData(), p = new Ih(e, i); t.sideOrientation = Jn._GetDefaultSideOrientation(t.sideOrientation), p._originalBuilderSideOrientation = t.sideOrientation, Mh(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; f < h.vertex.length; f++)p.goldbergData.faceCenters.push(R.FromArray(h.vertex[f])), p.goldbergData.faceCenters[f].x *= n, p.goldbergData.faceCenters[f].y *= o, p.goldbergData.faceCenters[f].z *= a, p.goldbergData.faceColors.push(new U(1, 1, 1, 1)); for (f = 0; f < d.face.length; f++) { var _ = d.face[f], m = R.FromArray(d.vertex[_[0]]), g = R.FromArray(d.vertex[_[2]]), v = R.FromArray(d.vertex[_[1]]), y = g.subtract(m), b = v.subtract(m), T = R.Cross(b, y).normalize(), E = R.Cross(b, T).normalize(); p.goldbergData.faceXaxis.push(b.normalize()), p.goldbergData.faceYaxis.push(T), p.goldbergData.faceZaxis.push(E) } return p } var Dh = function () { function e(e) { this._paths = [], this._tempPaths = [], this._holes = [], this._resolution = e } return e.prototype.moveTo = function (e, t) { this._currentPath = new Nr(e, t), this._tempPaths.push(this._currentPath) }, e.prototype.lineTo = function (e, t) { this._currentPath.addLineTo(e, t) }, e.prototype.quadraticCurveTo = function (e, t, i, r) { this._currentPath.addQuadraticCurveTo(e, t, i, r, this._resolution) }, e.prototype.bezierCurveTo = function (e, t, i, r, n, o) { this._currentPath.addBezierCurveTo(e, t, i, r, n, o, this._resolution) }, e.prototype.extractHoles = function () { for (var e = 0, t = this._tempPaths; e < t.length; e++) { var i = t[e]; i.area() > 0 ? 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 Nh(e, t, i, r, n, o) { var a = o.glyphs[e] || o.glyphs["?"]; if (!a) return null; var s = new Dh(n); if (a.o) for (var l = a.o.split(" "), c = 0, u = l.length; c < u;)switch (l[c++]) { case "m": var h = parseInt(l[c++]) * t + i, d = parseInt(l[c++]) * t + r; s.moveTo(h, d); break; case "l": h = parseInt(l[c++]) * t + i, d = parseInt(l[c++]) * t + r, s.lineTo(h, d); break; case "q": var p = parseInt(l[c++]) * t + i, f = parseInt(l[c++]) * t + r, _ = parseInt(l[c++]) * t + i, m = parseInt(l[c++]) * t + r; s.quadraticCurveTo(_, m, p, f); break; case "b": p = parseInt(l[c++]) * t + i, f = parseInt(l[c++]) * t + r, _ = parseInt(l[c++]) * t + i, m = parseInt(l[c++]) * t + r; var g = parseInt(l[c++]) * t + i, v = parseInt(l[c++]) * t + r; s.bezierCurveTo(_, m, g, v, p, f) }return s.extractHoles(), { offsetX: a.ha * t, shapePath: s } } function Fh(e, t, i, r) { for (var n = Array.from(e), o = t / r.resolution, a = (r.boundingBox.yMax - r.boundingBox.yMin + r.underlineThickness) * o, s = [], l = 0, c = 0, u = 0; u < n.length; u++) { var h = n[u]; if ("\n" === h) l = 0, c -= a; else { var d = Nh(h, o, l, c, i, r); d && (l += d.offsetX, s.push(d.shapePath)) } } return s } function Lh(e, t, i, r, n, o) { void 0 === r && (r = { size: 50, resolution: 8, depth: 1 }), void 0 === n && (n = null), void 0 === o && (o = earcut); for (var a = [], s = 0, l = Fh(t, r.size || 50, r.resolution || 8, i); s < l.length; s++) { var c = l[s]; if (c.paths.length) for (var u = c.holes.slice(), h = 0, d = c.paths; h < d.length; h++) { for (var p = d[h], f = [], _ = [], m = 0, g = p.getPoints(); m < g.length; m++) { var v = g[m]; _.push(new R(v.x, 0, v.y)) } for (var y = 0, b = u.slice(); y < b.length; y++) { for (var T = (O = b[y]).getPoints(), E = !1, S = 0, x = T; S < x.length; S++)if (v = x[S], p.isPointInside(v)) { E = !0; break } if (E) { for (var A = [], C = 0, P = T; C < P.length; C++)v = P[C], A.push(new R(v.x, 0, v.y)); f.push(A), u.splice(u.indexOf(O), 1) } } if (!f.length && u.length) for (var I = 0, M = u; I < M.length; I++) { A = []; for (var O, D = 0, N = (O = M[I]).getPoints(); D < N.length; D++)v = N[D], A.push(new R(v.x, 0, v.y)); f.push(A) } var F = ih(e, { shape: _, holes: f.length ? f : void 0, depth: r.depth || 1, faceUV: r.faceUV, faceColors: r.faceColors, sideOrientation: Jn._GetDefaultSideOrientation(r.sideOrientation || Jn.DOUBLESIDE) }, n, o); a.push(F) } } var L = Jn.MergeMeshes(a, !0, !0); if (L) { var w = null == L ? void 0 : L.getBoundingInfo(); L.position.x = -(null == w ? void 0 : w.boundingBox.extendSizeWorld._x), L.position.y = -(null == w ? void 0 : w.boundingBox.extendSizeWorld._y), L.position.z = -(null == w ? void 0 : w.boundingBox.extendSizeWorld._z), L.name = e, L.rotation.x = -Math.PI / 2, L.bakeCurrentTransformIntoVertices() } return L } var wh = { CreateBox: gu, CreateTiledBox: Lu, CreateSphere: bu, CreateDisc: Iu, CreateIcoSphere: cs, CreateRibbon: Ru, CreateCylinder: Dc, CreateTorus: Lc, CreateTorusKnot: Uu, CreateLineSystem: ju, CreateLines: Yu, CreateDashedLines: Ku, ExtrudeShape: nh, ExtrudeShapeCustom: oh, CreateLathe: lh, CreateTiledPlane: Du, CreatePlane: No, CreateGround: Gc, CreateTiledGround: zc, CreateGroundFromHeightMap: Wc, CreatePolygon: th, ExtrudePolygon: ih, CreateTube: uh, CreatePolyhedron: ph, CreateGeodesic: Ph, CreateGoldberg: Oh, CreateDecal: Eh, CreateCapsule: Su, CreateText: Lh }, Bh = function () { function e(e) { if (this._impostors = [], this._meshes = [], this._bodies = [], this._inertiaBodies = [], this._bodyMeshes = [], this._inertiaMeshes = [], this._numMeshes = 0, this._numBodies = 0, this._numInertiaBodies = 0, this._debugMeshMeshes = new Array, this._scene = e || S.LastCreatedScene, this._scene) { var t = this._scene.getPhysicsEngine(); t && (this._physicsEnginePlugin = t.getPhysicsPlugin()), this._utilityLayer = new lu(this._scene, !1), this._utilityLayer.pickUtilitySceneFirst = !1, this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = !0 } } return e.prototype._updateDebugMeshes = function () { var e = this._physicsEnginePlugin; 1 === (null == e ? void 0 : e.getPluginVersion()) ? this._updateDebugMeshesV1() : this._updateDebugMeshesV2() }, e.prototype._updateDebugMeshesV1 = function () { for (var e = this._physicsEnginePlugin, t = 0; t < this._numMeshes; t++) { var i = this._impostors[t]; if (i) if (i.isDisposed) this.hideImpostor(this._impostors[t--]); else { if (i.type === Zo.MeshImpostor) continue; var r = this._meshes[t]; r && e && e.syncMeshWithImpostor(r, i) } } }, e.prototype._updateDebugMeshesV2 = function () { for (var e = this._physicsEnginePlugin, t = 0; t < this._numBodies; t++) { var i = this._bodies[t], r = this._bodyMeshes[t]; i && r && e.syncTransform(i, r) } }, e.prototype._updateInertiaMeshes = function () { for (var e = 0; e < this._numInertiaBodies; e++) { var t = this._inertiaBodies[e], i = this._inertiaMeshes[e]; t && i && this._updateDebugInertia(t, i) } }, e.prototype._updateDebugInertia = function (e, t) { var i, r = I.Identity(), n = I.Identity(), o = I.Identity(); if (e._pluginDataInstances.length) { for (var a = t, s = a._thinInstanceDataStorage.matrixData, l = e.transformNode._thinInstanceDataStorage.matrixData, c = 0; c < e._pluginDataInstances.length; c++) { var u = e.getMassProperties(c); this._getMeshDebugInertiaMatrixToRef(u, r), I.FromArrayToRef(l, 16 * c, n), r.multiplyToRef(n, o), o.copyToArray(s, 16 * c) } a.thinInstanceBufferUpdated("matrix") } else { if (u = e.getMassProperties(), this._getMeshDebugInertiaMatrixToRef(u, r), null === (i = e.transformNode.rotationQuaternion) || void 0 === i || i.toRotationMatrix(n), n.setTranslation(e.transformNode.position), e.transformNode.parent) { var h = e.transformNode.parent.computeWorldMatrix(!0); n.multiplyToRef(h, n) } r.multiplyToRef(n, r), r.decomposeToTransformNode(t) } }, e.prototype.showImpostor = function (e, t) { if (!this._scene) return null; for (var i = 0; i < this._numMeshes; i++)if (this._impostors[i] == e) return null; var r = this._getDebugMesh(e, t); return r && (this._impostors[this._numMeshes] = e, this._meshes[this._numMeshes] = r, 0 === this._numMeshes && (this._renderFunction = this._updateDebugMeshes.bind(this), this._scene.registerBeforeRender(this._renderFunction)), this._numMeshes++), r }, e.prototype.showBody = function (e) { if (!this._scene) return null; for (var t = 0; t < this._numBodies; t++)if (this._bodies[t] == e) return null; var i = this._getDebugBodyMesh(e); return i && (this._bodies[this._numBodies] = e, this._bodyMeshes[this._numBodies] = i, 0 === this._numBodies && (this._renderFunction = this._updateDebugMeshes.bind(this), this._scene.registerBeforeRender(this._renderFunction)), this._numBodies++), i }, e.prototype.showInertia = function (e) { if (!this._scene) return null; for (var t = 0; t < this._numInertiaBodies; t++)if (this._inertiaBodies[t] == e) return null; var i = this._getDebugInertiaMesh(e); return i && (this._inertiaBodies[this._numInertiaBodies] = e, this._inertiaMeshes[this._numInertiaBodies] = i, 0 === this._numInertiaBodies && (this._inertiaRenderFunction = this._updateInertiaMeshes.bind(this), this._scene.registerBeforeRender(this._inertiaRenderFunction)), this._numInertiaBodies++), i }, e.prototype.hideImpostor = function (e) { if (e && this._scene && this._utilityLayer) { for (var t = !1, i = this._utilityLayer.utilityLayerScene, r = 0; r < this._numMeshes; r++)if (this._impostors[r] == e) { var n = this._meshes[r]; if (!n) continue; i.removeMesh(n), n.dispose(); var o = this._debugMeshMeshes.indexOf(n); o > -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; r < this._numBodies; r++)if (this._bodies[r] === e) { var n = this._bodyMeshes[r]; if (!n) continue; i.removeMesh(n), n.dispose(), this._numBodies--, this._numBodies > 0 ? (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; r < this._numInertiaBodies; r++)if (this._inertiaBodies[r] === e) { var n = this._inertiaMeshes[r]; if (!n) continue; i.removeMesh(n), n.dispose(), this._inertiaBodies.splice(r, 1), this._inertiaMeshes.splice(r, 1), this._numInertiaBodies--, t = !0; break } t && 0 === this._numInertiaBodies && this._scene.unregisterBeforeRender(this._inertiaRenderFunction) } }, e.prototype._getDebugMaterial = function (e) { return this._debugMaterial || (this._debugMaterial = new mc("", 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 mc("", e), this._debugInertiaMaterial.disableLighting = !0, this._debugInertiaMaterial.alpha = 0), this._debugInertiaMaterial }, e.prototype._getDebugBoxMesh = function (e) { return this._debugBoxMesh || (this._debugBoxMesh = gu("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 = bu("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 = Su("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 = Dc("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 Jn(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 Zo.BoxImpostor: r = this._getDebugBoxMesh(n), e.getBoxSizeToRef(r.scaling); break; case Zo.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 Zo.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 Zo.MeshImpostor: t && (r = this._getDebugMeshMesh(t, n)); break; case Zo.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 Zo.BoxImpostor: (r = i._getDebugBoxMesh(n)).position.copyFrom(o), r.position.addInPlace(a), r.position.scaleInPlace(.5); break; case Zo.SphereImpostor: r = i._getDebugSphereMesh(n); break; case Zo.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 Zo.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 Jn("custom", t), r = new En, 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 = wh.CreateBox("custom", { size: 1 }, t), r = I.Identity(); if (e._pluginDataInstances.length) { for (var n = new Float32Array(16 * e._pluginDataInstances.length), o = 0; o < e._pluginDataInstances.length; ++o) { var a = e.getMassProperties(o); this._getMeshDebugInertiaMatrixToRef(a, r), r.copyToArray(n, 16 * o) } i.thinInstanceSetBuffer("matrix", n, 16) } else a = e.getMassProperties(), this._getMeshDebugInertiaMatrixToRef(a, r), r.decomposeToTransformNode(i); return i.enableEdgesRendering(), i.edgesWidth = 2, i.edgesColor = new U(1, 0, 1, 1), i.material = this._getDebugInertiaMaterial(t), i }, e.prototype.dispose = function () { for (var e = this._numMeshes - 1; e >= 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 }(), Uh = 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) { if (!this._renderFunction && this.ray) { var i = this.ray; this._renderFunction = this._render.bind(this), this._scene = e, this._renderPoints = [i.origin, i.origin.add(i.direction.scale(i.length))], this._renderLine = Yu("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), Yu("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 }(), Vh = 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(Hi.MatricesIndicesKind), E = i.getVerticesData(Hi.MatricesWeightsKind); if (this._boneIndices = new Set, !a.useAllBones && T && E) for (var S = 0; S < T.length; ++S) { var x = T[S]; 0 !== E[S] && this._boneIndices.add(x) } this._utilityLayer = new lu(this._scene, !1), this._utilityLayer.pickUtilitySceneFirst = !1, this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = !0; var A = this.options.displayMode || 0; A > e.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; Vt.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 }", Vt.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 Gu("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 = Hn.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 Gu("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 = Hn.MATERIAL_OPAQUE, l }, e._CreateBoneMapColorBuffer = function (e, t, i) { var r = new gc("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; l < s.length; l++)a.push(.00392156862745098 * s[l]); return r.dispose(), a }, Object.defineProperty(e.prototype, "scene", { get: function () { return this._scene }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "utilityLayer", { get: function () { return this._utilityLayer }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isReady", { get: function () { return this._ready }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "ready", { set: function (e) { this._ready = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "debugMesh", { get: function () { return this._debugMesh }, set: function (e) { this._debugMesh = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "displayMode", { get: function () { return this.options.displayMode || e.DISPLAY_LINES }, set: function (t) { t > e.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 < i; o++) { var a = e[o], s = this._debugLines[n]; -1 !== a._index && (this._boneIndices.has(a.getIndex()) || this.options.useAllBones) && (s || (s = [R.Zero(), R.Zero()], this._debugLines[n] = s), this._getBonePosition(s[0], a, t), this._getBonePosition(s[1], a, t, 0, a.length, 0), s[0].subtractInPlace(r), s[1].subtractInPlace(r), n++) } }, e.prototype._getLinesForBonesNoLength = function (e) { for (var t = e.length, i = 0, r = this.mesh, n = r.position, o = t - 1; 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 = oh("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: Jn.DEFAULTSIDE, updatable: !1 }, n), y = v.getTotalVertices(), b = [], T = [], E = 0; E < y; E++)b.push(1, 0, 0, 0), u.spurFollowsChild && E > 9 ? T.push(t.getIndex(), 0, 0, 0) : T.push(i.getIndex(), 0, 0, 0); v.position = l.clone(), v.setVerticesData(Hi.MatricesWeightsKind, b, !1), v.setVerticesData(Hi.MatricesIndicesKind, T, !1), v.convertToFlatShadedMesh(), s.push(v) } })); for (var h = bu("skeletonViewer", { segments: 6, diameter: u.sphereBaseSize || .2, updatable: !0 }, n), p = h.getTotalVertices(), f = [], _ = [], m = 0; m < p; m++)f.push(1, 0, 0, 0), _.push(i.getIndex(), 0, 0, 0); h.setVerticesData(Hi.MatricesWeightsKind, f, !1), h.setVerticesData(Hi.MatricesIndicesKind, _, !1), h.position = l.clone(), a.push([h, i]) }, d = this, p = 0; p < o.length; p++)h(p); var f = u.sphereScaleUnit || 2, _ = u.sphereFactor || .85, m = []; for (p = 0; p < a.length; p++) { for (var g = (t = a[p])[0], v = t[1], y = 1 / (f / c), b = 0, T = v; T.getParent() && -1 !== T.getParent().getIndex();)b++, T = T.getParent(); g.scaling.scaleInPlace(y * Math.pow(_, b)), m.push(g) } this.debugMesh = Jn.MergeMeshes(m.concat(s), !0, !0), this.debugMesh && (this.debugMesh.renderingGroupId = this.renderingGroupId, this.debugMesh.skeleton = this.skeleton, this.debugMesh.parent = this.mesh, this.debugMesh.computeBonesUsingShaders = null === (r = this.options.computeBonesUsingShaders) || void 0 === r || r, this.debugMesh.alwaysSelectAsActiveMesh = !0), this.utilityLayer._getSharedGizmoLight().intensity = .7, this._revert(l), this.ready = !0 } catch (e) { console.error(e), this._revert(l), this.dispose() } }, e.prototype._buildLocalAxes = function () { var e; this._localAxes && this._localAxes.dispose(), this._localAxes = null; var t = this.options.displayOptions || {}; if (t.showLocalAxes) { var i = this._utilityLayer.utilityLayerScene, r = t.localAxesSize || .075, n = [], o = [], a = new U(1, 0, 0, 1), s = new U(0, 1, 0, 1), l = new U(0, 0, 1, 1), c = [], u = []; for (var h in this.skeleton.bones) { var d = this.skeleton.bones[h]; if (-1 !== d._index && (this._boneIndices.has(d.getIndex()) || this.options.useAllBones)) { var p = new I, f = new R; this._getAbsoluteBindPoseToRef(d, p), p.decompose(void 0, O.Quaternion[0], f); var _ = new I; O.Quaternion[0].toRotationMatrix(_); var m = R.TransformCoordinates(new R(0 + r, 0, 0), _), g = R.TransformCoordinates(new R(0, 0 + r, 0), _), v = R.TransformCoordinates(new R(0, 0, 0 + r), _), y = [[f, f.add(m)], [f, f.add(g)], [f, f.add(v)]], b = [[a, a], [s, s], [l, l]]; n.push.apply(n, y), o.push.apply(o, b); for (var T = 0; T < 6; T++)c.push(1, 0, 0, 0), u.push(d.getIndex(), 0, 0, 0) } } this._localAxes = ju("localAxes", { lines: n, colors: o, updatable: !0 }, i), this._localAxes.setVerticesData(Hi.MatricesWeightsKind, c, !1), this._localAxes.setVerticesData(Hi.MatricesIndicesKind, u, !1), this._localAxes.skeleton = this.skeleton, this._localAxes.renderingGroupId = this.renderingGroupId + 1, this._localAxes.parent = this.mesh, this._localAxes.computeBonesUsingShaders = null === (e = this.options.computeBonesUsingShaders) || void 0 === e || e } }, e.prototype._displayLinesUpdate = function () { if (this._utilityLayer) { this.autoUpdateBonesMatrices && this.skeleton.computeAbsoluteMatrices(), void 0 === this.skeleton.bones[0].length ? this._getLinesForBonesNoLength(this.skeleton.bones) : this._getLinesForBonesWithLength(this.skeleton.bones, this.mesh.getWorldMatrix()); var e = this._utilityLayer.utilityLayerScene; e && (this._debugMesh ? ju("", { lines: this._debugLines, updatable: !0, instance: this._debugMesh }, e) : (this._debugMesh = ju("", { lines: this._debugLines, updatable: !0, instance: null }, e), this._debugMesh.renderingGroupId = this.renderingGroupId), this._debugMesh.position.copyFrom(this.mesh.position), this._debugMesh.color = this.color) } }, e.prototype.changeDisplayMode = function (e) { var t = !!this.isEnabled; this.displayMode !== e && (this.isEnabled = !1, this._debugMesh && (this._debugMesh.dispose(), this._debugMesh = null, this.ready = !1), this.displayMode = e, this.update(), this._bindObs(), this.isEnabled = t) }, e.prototype.changeDisplayOptions = function (e, t) { var i = !!this.isEnabled; this.options.displayOptions[e] = t, this.isEnabled = !1, this._debugMesh && (this._debugMesh.dispose(), this._debugMesh = null, this.ready = !1), this.update(), this._bindObs(), this.isEnabled = i }, e.prototype.dispose = function () { this.isEnabled = !1, this._debugMesh && (this._debugMesh.dispose(), this._debugMesh = null), this._utilityLayer && (this._utilityLayer.dispose(), this._utilityLayer = null), this.ready = !1 }, e.DISPLAY_LINES = 0, e.DISPLAY_SPHERES = 1, e.DISPLAY_SPHERE_AND_SPURS = 2, e }(), kh = function () { function e(e, t) { this._oldPosition = new R(Number.NaN, Number.NaN, Number.NaN), this._oldDirection = new R(Number.NaN, Number.NaN, Number.NaN), this._transparency = .3, this._showLines = !0, this._showPlanes = !0, this._scene = e.getScene(), this._light = e, this._camera = t, this._inverseViewMatrix = I.Identity(), this._lightHelperFrustumMeshes = [], this._createGeometry(), this.show(), this.update() } return Object.defineProperty(e.prototype, "transparency", { get: function () { return this._transparency }, set: function (e) { this._transparency = e; for (var t = 6; t < 12; ++t)this._lightHelperFrustumMeshes[t].material.alpha = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "showLines", { get: function () { return this._showLines }, set: function (e) { if (this._showLines !== e) { this._showLines = e; for (var t = 0; t < 6; ++t)this._lightHelperFrustumMeshes[t].setEnabled(e) } }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "showPlanes", { get: function () { return this._showPlanes }, set: function (e) { if (this._showPlanes !== e) { this._showPlanes = e; for (var t = 6; t < 12; ++t)this._lightHelperFrustumMeshes[t].setEnabled(e) } }, enumerable: !1, configurable: !0 }), e.prototype.show = function () { var e = this; this._lightHelperFrustumMeshes.forEach((function (t, i) { t.setEnabled(i < 6 && e._showLines || i >= 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]), Yu("nearlines", { updatable: !0, points: this._nearLinesPoints, instance: this._lightHelperFrustumMeshes[0] }, this._scene), Yu("farlines", { updatable: !0, points: this._farLinesPoints, instance: this._lightHelperFrustumMeshes[1] }, this._scene), Yu("trlines", { updatable: !0, points: this._trLinesPoints, instance: this._lightHelperFrustumMeshes[2] }, this._scene), Yu("brlines", { updatable: !0, points: this._brLinesPoints, instance: this._lightHelperFrustumMeshes[3] }, this._scene), Yu("tllines", { updatable: !0, points: this._tlLinesPoints, instance: this._lightHelperFrustumMeshes[4] }, this._scene), Yu("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 On("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 = Yu("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 = Yu("farlines", { updatable: !0, points: this._farLinesPoints }, this._scene); i.parent = this._rootNode, i.alwaysSelectAsActiveMesh = !0, this._trLinesPoints = [R.ZeroReadOnly, R.ZeroReadOnly]; var r = Yu("trlines", { updatable: !0, points: this._trLinesPoints }, this._scene); r.parent = this._rootNode, r.alwaysSelectAsActiveMesh = !0, this._brLinesPoints = [R.ZeroReadOnly, R.ZeroReadOnly]; var n = Yu("brlines", { updatable: !0, points: this._brLinesPoints }, this._scene); n.parent = this._rootNode, n.alwaysSelectAsActiveMesh = !0, this._tlLinesPoints = [R.ZeroReadOnly, R.ZeroReadOnly]; var o = Yu("tllines", { updatable: !0, points: this._tlLinesPoints }, this._scene); o.parent = this._rootNode, o.alwaysSelectAsActiveMesh = !0, this._blLinesPoints = [R.ZeroReadOnly, R.ZeroReadOnly]; var a = Yu("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 Jn(t + "plane", e._scene), o = new mc(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 En; 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 }(), Gh = function () { this.renderWidth = 512, this.renderHeight = 256, this.textureSize = 512, this.deterministicLockstep = !1, this.lockstepMaxSteps = 4 }, zh = function (t) { function i(i) { void 0 === i && (i = new Gh); var r = t.call(this, null) || this; In.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, _collectUbosUpdatedInFrame: !1 }, $.Log("Babylon.js v".concat(In.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 Kt; return t.references = 1, t }, i.prototype.createIndexBuffer = function (e) { var t = new Kt; 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 && Jt.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 Ht(this, It.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 Ca(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 Ht(this, It.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 Ht(this, It.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 Ht(this, It.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 Kt; 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 }(In); ti.prototype._debugPushGroup = function (e, t) { }, ti.prototype._debugPopGroup = function (e) { }, ti.prototype._debugInsertMarker = function (e, t) { }, ti.prototype._debugFlushPendingCommands = function () { }; var Wh = function () { this._timeElapsedQueryEnded = !1 }, Hh = function () { this.occlusionInternalRetryCounter = 0, this.isOcclusionQueryInProgress = !1, this.isOccluded = !1, this.occlusionRetryCount = -1, this.occlusionType = Ln.OCCLUSION_TYPE_NONE, this.occlusionQueryAlgorithmType = Ln.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE, this.forceRenderingWhenOccluded = !1 }; In.prototype.createQuery = function () { var e = this._gl.createQuery(); if (!e) throw new Error("Unable to create Occlusion Query"); return e }, In.prototype.deleteQuery = function (e) { return this._gl.deleteQuery(e), this }, In.prototype.isQueryResultAvailable = function (e) { return this._gl.getQueryParameter(e, this._gl.QUERY_RESULT_AVAILABLE) }, In.prototype.getQueryResult = function (e) { return this._gl.getQueryParameter(e, this._gl.QUERY_RESULT) }, In.prototype.beginOcclusionQuery = function (e, t) { var i = this._getGlAlgorithmType(e); return this._gl.beginQuery(i, t), !0 }, In.prototype.endOcclusionQuery = function (e) { var t = this._getGlAlgorithmType(e); return this._gl.endQuery(t), this }, In.prototype._createTimeQuery = function () { var e = this.getCaps().timerQuery; return e.createQueryEXT ? e.createQueryEXT() : this.createQuery() }, In.prototype._deleteTimeQuery = function (e) { var t = this.getCaps().timerQuery; t.deleteQueryEXT ? t.deleteQueryEXT(e) : this.deleteQuery(e) }, In.prototype._getTimeQueryResult = function (e) { var t = this.getCaps().timerQuery; return t.getQueryObjectEXT ? t.getQueryObjectEXT(e, t.QUERY_RESULT_EXT) : this.getQueryResult(e) }, In.prototype._getTimeQueryAvailability = function (e) { var t = this.getCaps().timerQuery; return t.getQueryObjectEXT ? t.getQueryObjectEXT(e, t.QUERY_RESULT_AVAILABLE_EXT) : this.isQueryResultAvailable(e) }, In.prototype.startTimeQuery = function () { var e = this.getCaps(), t = e.timerQuery; if (!t) return null; var i = new Wh; 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 }, In.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 }, In.prototype._captureGPUFrameTime = !1, In.prototype._gpuFrameTime = new mr, In.prototype.getGPUFrameTimeCounter = function () { return this._gpuFrameTime }, In.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)) }, In.prototype._getGlAlgorithmType = function (e) { return e === Ln.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED }, Object.defineProperty(Ln.prototype, "isOcclusionQueryInProgress", { get: function () { return this._occlusionDataStorage.isOcclusionQueryInProgress }, set: function (e) { this._occlusionDataStorage.isOcclusionQueryInProgress = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(Ln.prototype, "_occlusionDataStorage", { get: function () { return this.__occlusionDataStorage || (this.__occlusionDataStorage = new Hh), this.__occlusionDataStorage }, enumerable: !1, configurable: !0 }), Object.defineProperty(Ln.prototype, "isOccluded", { get: function () { return this._occlusionDataStorage.isOccluded }, set: function (e) { this._occlusionDataStorage.isOccluded = e }, enumerable: !0, configurable: !0 }), Object.defineProperty(Ln.prototype, "occlusionQueryAlgorithmType", { get: function () { return this._occlusionDataStorage.occlusionQueryAlgorithmType }, set: function (e) { this._occlusionDataStorage.occlusionQueryAlgorithmType = e }, enumerable: !0, configurable: !0 }), Object.defineProperty(Ln.prototype, "occlusionType", { get: function () { return this._occlusionDataStorage.occlusionType }, set: function (e) { this._occlusionDataStorage.occlusionType = e }, enumerable: !0, configurable: !0 }), Object.defineProperty(Ln.prototype, "occlusionRetryCount", { get: function () { return this._occlusionDataStorage.occlusionRetryCount }, set: function (e) { this._occlusionDataStorage.occlusionRetryCount = e }, enumerable: !0, configurable: !0 }), Object.defineProperty(Ln.prototype, "forceRenderingWhenOccluded", { get: function () { return this._occlusionDataStorage.forceRenderingWhenOccluded }, set: function (e) { this._occlusionDataStorage.forceRenderingWhenOccluded = e }, enumerable: !0, configurable: !0 }), Ln.prototype._checkOcclusionQuery = function () { var e = this._occlusionDataStorage; if (e.occlusionType === Ln.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 && 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 !== Ln.OCCLUSION_TYPE_OPTIMISTIC && e.isOccluded; e.isOcclusionQueryInProgress = !1, e.occlusionInternalRetryCounter = 0, e.isOccluded = e.occlusionType !== Ln.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 Xh = !0; In.prototype.createTransformFeedback = function () { var e = this._gl.createTransformFeedback(); if (!e) throw new Error("Unable to create Transform Feedback"); return e }, In.prototype.deleteTransformFeedback = function (e) { this._gl.deleteTransformFeedback(e) }, In.prototype.bindTransformFeedback = function (e) { this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, e) }, In.prototype.beginTransformFeedback = function (e) { void 0 === e && (e = !0), this._gl.beginTransformFeedback(e ? this._gl.POINTS : this._gl.TRIANGLES) }, In.prototype.endTransformFeedback = function () { this._gl.endTransformFeedback() }, In.prototype.setTranformFeedbackVaryings = function (e, t) { this._gl.transformFeedbackVaryings(e, t, this._gl.INTERLEAVED_ATTRIBS) }, In.prototype.bindTransformFeedbackBuffer = function (e) { this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, e ? e.underlyingResource : null) }, ti.prototype.createExternalTexture = function (e) { return null }, ti.prototype.setExternalTexture = function (e, t) { throw new Error("setExternalTexture: This engine does not support external textures!") }, ti.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 } } }, ti.prototype.restoreSingleAttachment = function () { var e = this._gl; this.bindAttachments([e.BACK]) }, ti.prototype.restoreSingleAttachmentForRenderTarget = function () { var e = this._gl; this.bindAttachments([e.COLOR_ATTACHMENT0]) }, ti.prototype.buildTextureLayout = function (e) { for (var t = this._gl, i = [], r = 0; r < e.length; r++)e[r] ? i.push(t["COLOR_ATTACHMENT" + r]) : i.push(t.NONE); return i }, ti.prototype.bindAttachments = function (e) { this._gl.drawBuffers(e) }, ti.prototype.unBindMultiColorAttachmentFramebuffer = function (e, t, i) { void 0 === t && (t = !1), this._currentRenderTarget = null; var r = this._gl, n = e._attachments, o = n.length; if (e._MSAAFramebuffer) { r.bindFramebuffer(r.READ_FRAMEBUFFER, e._MSAAFramebuffer), r.bindFramebuffer(r.DRAW_FRAMEBUFFER, e._framebuffer); for (var a = 0; a < o; a++) { for (var s = e.textures[a], l = 0; l < o; l++)n[l] = r.NONE; n[a] = r[this.webGLVersion > 1 ? "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; a < o; a++)n[a] = r[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + a : "COLOR_ATTACHMENT" + a + "_WEBGL"]; r.drawBuffers(n) } for (a = 0; a < o; a++)!(null == (s = e.textures[a]) ? void 0 : s.generateMipMaps) || t || s.isCube || (this._bindTextureDirectly(r.TEXTURE_2D, s, !0), r.generateMipmap(r.TEXTURE_2D), this._bindTextureDirectly(r.TEXTURE_2D, null)); i && (e._MSAAFramebuffer && this._bindUnboundFramebuffer(e._framebuffer), i()), this._bindUnboundFramebuffer(null) }, ti.prototype.createMultipleRenderTarget = function (e, t, i) { var r; void 0 === i && (i = !0); var n = !1, o = !0, s = !1, l = !1, c = a.TEXTUREFORMAT_DEPTH16, u = 1, h = a.TEXTURETYPE_UNSIGNED_INT, d = a.TEXTURE_TRILINEAR_SAMPLINGMODE, p = a.TEXTUREFORMAT_RGBA, f = a.TEXTURE_2D, _ = new Array, m = new Array, g = new Array, v = new Array, y = new Array, b = new Array, T = new Array, E = new Array, S = this._createHardwareRenderTargetWrapper(!0, !1, e); void 0 !== t && (n = void 0 !== t.generateMipMaps && t.generateMipMaps, o = void 0 === t.generateDepthBuffer || t.generateDepthBuffer, s = void 0 !== t.generateStencilBuffer && t.generateStencilBuffer, l = void 0 !== t.generateDepthTexture && t.generateDepthTexture, u = t.textureCount || 1, t.types && (_ = t.types), t.samplingModes && (m = t.samplingModes), t.useSRGBBuffers && (g = t.useSRGBBuffers), t.formats && (v = t.formats), t.targetTypes && (y = t.targetTypes), t.faceIndex && (b = t.faceIndex), t.layerIndex && (T = t.layerIndex), t.layerCounts && (E = t.layerCounts), this.webGLVersion > 1 && (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; D < u; D++) { var N = m[D] || d, F = _[D] || h, L = g[D] || !1, w = v[D] || p, B = y[D] || f, U = null !== (r = E[D]) && void 0 !== r ? r : 1; (F !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (F !== a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (N = a.TEXTURE_NEAREST_SAMPLINGMODE); var V = this._getSamplingParameters(N, n); F !== a.TEXTURETYPE_FLOAT || this._caps.textureFloat || (F = a.TEXTURETYPE_UNSIGNED_INT, $.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")), L = L && this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || 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 Ht(this, It.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 Ht(this, It.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 }, ti.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; l < r; l++)(u = (c = e.textures[l])._hardwareTexture).releaseMSAARenderBuffers(); for (l = 0; l < r; l++) { var c, u = (c = e.textures[l])._hardwareTexture, h = n[this.webGLVersion > 1 ? "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 }, ti.prototype._createDepthStencilCubeTexture = function (e, t, i) { var r = new Ht(this, It.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 }, ti.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) })) }, ti.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) }, ti.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) }, ti.prototype._partialLoadImg = function (e, t, i, r, n, o, a, s) { void 0 === a && (a = null); var l = Ei(); ui(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) }, ti.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) }, ti.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 Ht(this, It.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 = ti._TextureLoaders; E < S.length; E++) { var x = S[E]; if (x.canLoad(b)) { T = x; break } } if (T) { var A = function (e) { d && d(m, e), T.loadCubeData(e, m, l, n, o) }; i && 6 === i.length ? T.supportCascades ? this._cascadeLoadFiles(t, (function (e) { return A(e.map((function (e) { return new Uint8Array(e) }))) }), i, o) : o ? o("Textures type does not support cascades.") : $.Warn("Texture loader does not support cascades.") : this._loadFile(e, (function (e) { return A(new Uint8Array(e)) }), void 0, void 0, !0, (function (h, v) { e === g ? o && h && o(h.status + " " + h.statusText, v) : ($.Warn("Failed to load ".concat(e, ", falling back to the ").concat(g)), _.createCubeTextureBase(g, t, i, !!r, n, o, a, s, l, c, u, m, d, p, f)) })) } else { if (!i) throw new Error("Cannot load cubemap because files were not defined"); this._cascadeLoadImgs(t, m, (function (e, t) { p && p(e, t) }), i, o) } return this._internalTexturesCache.push(m), m }, ti.prototype.createCubeTexture = function (e, t, i, r, n, o, a, s, l, c, u, h, d, p) { var f = this; void 0 === n && (n = null), void 0 === o && (o = null), void 0 === s && (s = null), void 0 === l && (l = !1), void 0 === c && (c = 0), void 0 === u && (u = 0), void 0 === h && (h = null), void 0 === p && (p = !1); var _ = this._gl; return this.createCubeTextureBase(e, t, i, !!r, n, o, a, s, l, c, u, h, (function (e) { return f._bindTextureDirectly(_.TEXTURE_CUBE_MAP, e, !0) }), (function (e, t) { var i = f.needPOTTextures ? ti.GetExponentOfTwo(t[0].width, f._caps.maxCubemapTextureSize) : t[0].width, o = i, s = [_.TEXTURE_CUBE_MAP_POSITIVE_X, _.TEXTURE_CUBE_MAP_POSITIVE_Y, _.TEXTURE_CUBE_MAP_POSITIVE_Z, _.TEXTURE_CUBE_MAP_NEGATIVE_X, _.TEXTURE_CUBE_MAP_NEGATIVE_Y, _.TEXTURE_CUBE_MAP_NEGATIVE_Z]; f._bindTextureDirectly(_.TEXTURE_CUBE_MAP, e, !0), f._unpackFlipY(!1); var l = a ? f._getInternalFormat(a, e._useSRGBBuffer) : e._useSRGBBuffer ? f._glSRGBExtensionValues.SRGB8_ALPHA8 : _.RGBA, c = a ? f._getInternalFormat(a) : _.RGBA; e._useSRGBBuffer && 1 === f.webGLVersion && (c = l); for (var u = 0; u < s.length; u++)if (t[u].width !== i || t[u].height !== o) { if (f._prepareWorkingCanvas(), !f._workingCanvas || !f._workingContext) return void $.Warn("Cannot create canvas to resize texture."); f._workingCanvas.width = i, f._workingCanvas.height = o, f._workingContext.drawImage(t[u], 0, 0, t[u].width, t[u].height, 0, 0, i, o), _.texImage2D(s[u], 0, l, c, _.UNSIGNED_BYTE, f._workingCanvas) } else _.texImage2D(s[u], 0, l, c, _.UNSIGNED_BYTE, t[u]); r || _.generateMipmap(_.TEXTURE_CUBE_MAP), f._setCubeMapTextureParams(e, !r), e.width = i, e.height = o, e.isReady = !0, a && (e.format = a), e.onLoadedObservable.notifyObservers(e), e.onLoadedObservable.clear(), n && n() }), !!p) }, ti.prototype.setTextureSampler = function (e, t) { throw new Error("setTextureSampler: This engine does not support separate texture sampler objects!") }; var jh = function () { }, Yh = new u, Kh = new u; function Qh(e) { if (this._excludedCompressedTextures && this._excludedCompressedTextures.some((function (t) { var i = "\\b" + t + "\\b"; return e && (e === t || e.match(new RegExp(i, "g"))) }))) return e; var t = e.lastIndexOf("."), i = e.lastIndexOf("?"), r = i > -1 ? e.substring(i, e.length) : ""; return (t > -1 ? e.substring(0, t) : e) + this._textureFormatInUse + r } Object.defineProperty(In.prototype, "onBeforeViewRenderObservable", { get: function () { return Yh } }), Object.defineProperty(In.prototype, "onAfterViewRenderObservable", { get: function () { return Kh } }), Object.defineProperty(In.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)) } }), In.prototype.getInputElement = function () { return this.inputElement || this.getRenderingCanvas() }, In.prototype.registerView = function (e, t, i) { var r = this; this.views || (this.views = []); for (var n = 0, o = this.views; n < o.length; n++) { var a = o[n]; if (a.target === e) return a } var s = this.getRenderingCanvas(); s && (e.width = s.width, e.height = s.height); var l = { target: e, camera: t, clearBeforeCopy: i, enabled: !0, id: (1e5 * Math.random()).toFixed() }; return this.views.push(l), t && t.onDisposeObservable.add((function () { r.unRegisterView(e) })), l }, In.prototype.unRegisterView = function (e) { if (!this.views || 0 === this.views.length) return this; for (var t = 0, i = this.views; t < i.length; t++) { var r = i[t]; if (r.target === e) { var n = this.views.indexOf(r); -1 !== n && this.views.splice(n, 1); break } } return this }, In.prototype._renderViewStep = function (e) { var t = e.target, i = t.getContext("2d"); if (!i) return !0; var r = this.getRenderingCanvas(); Yh.notifyObservers(e); var n = e.camera, o = null, a = null; if (n) { if (!(a = n.getScene()) || a.activeCameras && a.activeCameras.length) return !0; this.activeView = e, o = a.activeCamera, a.activeCamera = n } if (e.customResize) e.customResize(t); else { var s = Math.floor(t.clientWidth / this._hardwareScalingLevel), l = Math.floor(t.clientHeight / this._hardwareScalingLevel), c = s !== t.width || r.width !== t.width || l !== t.height || r.height !== t.height; t.clientWidth && t.clientHeight && c && (t.width = s, t.height = l, this.setSize(s, l)) } return !(!r.width || !r.height || (this._renderFrame(), this.flushFramebuffer(), e.clearBeforeCopy && i.clearRect(0, 0, r.width, r.height), i.drawImage(r, 0, 0), o && a && (a.activeCamera = o), Kh.notifyObservers(e), 0)) }, In.prototype._renderViews = function () { if (!this.views || 0 === this.views.length) return !1; var e; if (!this.getRenderingCanvas()) return !1; for (var t = 0, i = this.views; t < i.length; t++) { var r = i[t]; if (r.enabled) if (r.target !== this.inputElement) { if (!this._renderViewStep(r)) return !1 } else e = r } return !(e && !this._renderViewStep(e) || (this.activeView = null, 0)) }, ti.prototype.createStorageBuffer = function (e, t) { throw new Error("createStorageBuffer: Unsupported method in this engine!") }, ti.prototype.updateStorageBuffer = function (e, t, i, r) { }, ti.prototype.readFromStorageBuffer = function (e, t, i, r) { throw new Error("readFromStorageBuffer: Unsupported method in this engine!") }, ti.prototype.setStorageBuffer = function (e, t) { throw new Error("setStorageBuffer: Unsupported method in this engine!") }, Object.defineProperty(In.prototype, "texturesSupported", { get: function () { var e = new Array; return this._caps.astc && e.push("-astc.ktx"), this._caps.s3tc && e.push("-dxt.ktx"), this._caps.pvrtc && e.push("-pvrtc.ktx"), this._caps.etc2 && e.push("-etc2.ktx"), this._caps.etc1 && e.push("-etc1.ktx"), e }, enumerable: !0, configurable: !0 }), Object.defineProperty(In.prototype, "textureFormatInUse", { get: function () { return this._textureFormatInUse || null }, enumerable: !0, configurable: !0 }), In.prototype.setCompressedTextureExclusions = function (e) { this._excludedCompressedTextures = e }, In.prototype.setTextureFormatToUse = function (e) { for (var t = this.texturesSupported, i = 0, r = t.length; i < r; i++)for (var n = 0, o = e.length; n < o; n++)if (t[i] === e[n].toLowerCase()) return this._transformTextureUrl = Qh.bind(this), this._textureFormatInUse = t[i]; return this._textureFormatInUse = "", this._transformTextureUrl = null, null }; var qh, Zh, Jh = function () { function e() { var t = this, i = new ArrayBuffer(e.DEFAULT_BUFFER_SIZE); this._uint32s = new Uint32Array(i), this._int32s = new Int32Array(i), this._float32s = new Float32Array(i), this._length = e.DEFAULT_BUFFER_SIZE / 4, this._position = 0, this._nativeDataStream = new _native.NativeDataStream((function () { t._flush() })) } return e.prototype.writeUint32 = function (e) { this._flushIfNecessary(1), this._uint32s[this._position++] = e }, e.prototype.writeInt32 = function (e) { this._flushIfNecessary(1), this._int32s[this._position++] = e }, e.prototype.writeFloat32 = function (e) { this._flushIfNecessary(1), this._float32s[this._position++] = e }, e.prototype.writeUint32Array = function (e) { this._flushIfNecessary(1 + e.length), this._uint32s[this._position++] = e.length, this._uint32s.set(e, this._position), this._position += e.length }, e.prototype.writeInt32Array = function (e) { this._flushIfNecessary(1 + e.length), this._uint32s[this._position++] = e.length, this._int32s.set(e, this._position), this._position += e.length }, e.prototype.writeFloat32Array = function (e) { this._flushIfNecessary(1 + e.length), this._uint32s[this._position++] = e.length, this._float32s.set(e, this._position), this._position += e.length }, e.prototype.writeNativeData = function (e) { this._flushIfNecessary(e.length), this._uint32s.set(e, this._position), this._position += e.length }, e.prototype.writeBoolean = function (e) { this.writeUint32(e ? 1 : 0) }, e.prototype._flushIfNecessary = function (e) { this._position + e > this._length && this._flush() }, e.prototype._flush = function () { this._nativeDataStream.writeBuffer(this._uint32s.buffer, this._position), this._position = 0 }, e.DEFAULT_BUFFER_SIZE = 65536, e }(), $h = [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))], ed = [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 }], td = function (e, t) { return $h[e] * ed[e](t) }, id = [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], rd = 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(td(0, e), O.Vector3[2]), this.l00.addInPlace(O.Vector3[2]), n.scaleToRef(td(1, e), O.Vector3[2]), this.l1_1.addInPlace(O.Vector3[2]), n.scaleToRef(td(2, e), O.Vector3[2]), this.l10.addInPlace(O.Vector3[2]), n.scaleToRef(td(3, e), O.Vector3[2]), this.l11.addInPlace(O.Vector3[2]), n.scaleToRef(td(4, e), O.Vector3[2]), this.l2_2.addInPlace(O.Vector3[2]), n.scaleToRef(td(5, e), O.Vector3[2]), this.l2_1.addInPlace(O.Vector3[2]), n.scaleToRef(td(6, e), O.Vector3[2]), this.l20.addInPlace(O.Vector3[2]), n.scaleToRef(td(7, e), O.Vector3[2]), this.l21.addInPlace(O.Vector3[2]), n.scaleToRef(td(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(id[0]), this.l1_1.scaleInPlace(id[1]), this.l10.scaleInPlace(id[2]), this.l11.scaleInPlace(id[3]), this.l2_2.scaleInPlace(id[4]), this.l2_1.scaleInPlace(id[5]), this.l20.scaleInPlace(id[6]), this.l21.scaleInPlace(id[7]), this.l22.scaleInPlace(id[8]) }, e.prototype.convertIrradianceToLambertianRadiance = function () { this.scaleInPlace(1 / Math.PI) }, e.prototype.preScaleForRendering = function () { this.preScaled = !0, 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.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 }(), nd = 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 = rd.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 od(e, t, i, r) { void 0 === r && (r = !0); var n = e.getScene(), o = n.getEngine(), s = new es("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 = vo.CLAMP_ADDRESSMODE, e.wrapV = vo.CLAMP_ADDRESSMODE; var l = new xl("pass", 1, null, r ? vo.BILINEAR_SAMPLINGMODE : vo.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 ad(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 Ia("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 sd(e) { qh || (qh = new Float32Array(1), Zh = new Int32Array(qh.buffer)), qh[0] = e; var t = Zh[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 ld(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)) } Ut.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 cd = { CreateResizedCopy: od, ApplyPostProcess: ad, ToHalfFloat: sd, FromHalfFloat: ld }, ud = 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 Ia("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), ad("rgbdEncode", e, t, i, a.TEXTURE_NEAREST_SAMPLINGMODE, a.TEXTUREFORMAT_RGBA) }, e }(), hd = function (e, t, i, r) { this.name = e, this.worldAxisForNormal = t, this.worldAxisForFileX = i, this.worldAxisForFileY = r }, dd = 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 rd, 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; _ < e.size; _++) { for (var m = s, g = 0; g < e.size; g++) { var v = c.worldAxisForFileX.scale(m).add(c.worldAxisForFileY.scale(d)).add(c.worldAxisForNormal); v.normalize(); var y = this._AreaElement(m - o, d - o) - this._AreaElement(m - o, d + o) - this._AreaElement(m + o, d - o) + this._AreaElement(m + o, d + o), b = u[_ * e.size * f + g * f + 0], T = u[_ * e.size * f + g * f + 1], E = u[_ * e.size * f + g * f + 2]; isNaN(b) && (b = 0), isNaN(T) && (T = 0), isNaN(E) && (E = 0), e.type === a.TEXTURETYPE_UNSIGNED_INT && (b /= 255, T /= 255, E /= 255), e.gammaSpace && (b = Math.pow(h.Clamp(b), p), T = Math.pow(h.Clamp(T), p), E = Math.pow(h.Clamp(E), p)); var S = this.MAX_HDRI_VALUE; if (this.PRESERVE_CLAMPED_COLORS) { var x = Math.max(b, T, E); if (x > 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(), nd.FromHarmonics(t) }, e._FileFaces = [new hd("right", new R(1, 0, 0), new R(0, 0, -1), new R(0, -1, 0)), new hd("left", new R(-1, 0, 0), new R(0, 0, 1), new R(0, -1, 0)), new hd("up", new R(0, 1, 0), new R(1, 0, 0), new R(0, 0, 1)), new hd("down", new R(0, -1, 0), new R(1, 0, 0), new R(0, 0, -1)), new hd("front", new R(0, 0, 1), new R(1, 0, 0), new R(0, -1, 0)), new hd("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 }(); po.prototype.forceSphericalPolynomialsRecompute = function () { this._texture && (this._texture._sphericalPolynomial = null, this._texture._sphericalPolynomialPromise = null, this._texture._sphericalPolynomialComputed = !1) }, Object.defineProperty(po.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 = dd.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 }); Ut.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 pd = "image/png", fd = 2, _d = [134, 22, 135, 150, 246, 214, 150, 54]; function md(e) { for (var t = new DataView(e.buffer, e.byteOffset, e.byteLength), i = 0, r = 0; r < _d.length; r++)if (t.getUint8(i++) !== _d[r]) return $.Error("Not a babylon environment map"), null; for (var n = "", o = 0; o = t.getUint8(i++);)n += String.fromCharCode(o); var a = JSON.parse(n); return (a = gd(a)).specular && (a.specular.specularDataPosition = i, a.specular.lodGenerationScale = a.specular.lodGenerationScale || .8), a } function gd(e) { if (e.version > fd) throw new Error('Unsupported babylon environment map version "'.concat(e.version, '". Latest supported version is "').concat(fd, '".')); return 2 === e.version ? e : e = H(H({}, e), { version: 2, imageType: pd }) } function vd(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 : pd, 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 Sr(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 < m.byteLength; v++)g[v] = m[v] / 255, g[v] = Math.pow(g[v], 2.2); m = g } else if (m && e.gammaSpace) for (y = m, b = 0; b < y.length; b++)y[b] = Math.pow(y[b], 2.2); return T = s.createRawTexture(m, _, _, a.TEXTUREFORMAT_RGBA, !1, !0, a.TEXTURE_NEAREST_SAMPLINGMODE, null, l), [4, ud.EncodeTextureToRGBD(T, d, l)]; case 4: return V.sent(), [4, s._readTexturePixels(T, _, _)]; case 5: return E = V.sent(), [4, $a.DumpDataAsync(_, _, E, o, void 0, !1, !0, t.imageQuality)]; case 6: S = V.sent(), p[6 * w + B] = S, T.dispose(), V.label = 7; case 7: return B++, [3, 2]; case 8: return w++, [3, 1]; case 9: return d.dispose(), c ? [4, c] : [3, 11]; case 10: V.sent(), V.label = 11; case 11: for (x = { version: fd, width: u, imageType: o, irradiance: yd(e), specular: { mipmaps: [], lodGenerationScale: e.lodGenerationScale } }, A = 0, w = 0; w <= f; w++)for (B = 0; B < 6; B++)R = p[6 * w + B].byteLength, x.specular.mipmaps.push({ length: R, position: A }), A += R; for (C = JSON.stringify(x), P = new ArrayBuffer(C.length + 1), I = new Uint8Array(P), w = 0, M = C.length; w < M; w++)I[w] = C.charCodeAt(w); for (I[C.length] = 0, O = _d.length + A + P.byteLength, D = new ArrayBuffer(O), N = new Uint8Array(D), F = new DataView(D), L = 0, w = 0; w < _d.length; w++)F.setUint8(L++, _d[w]); for (N.set(new Uint8Array(P), L), L += P.byteLength, w = 0; w <= f; w++)for (B = 0; B < 6; B++)U = p[6 * w + B], N.set(new Uint8Array(U), L), L += U.byteLength; return [2, D] } })) })) } function yd(e) { var t = e.sphericalPolynomial; return null == t ? null : { x: [t.x.x, t.x.y, t.x.z], y: [t.y.x, t.y.y, t.y.z], z: [t.z.x, t.z.y, t.z.z], xx: [t.xx.x, t.xx.y, t.xx.z], yy: [t.yy.x, t.yy.y, t.yy.z], zz: [t.zz.x, t.zz.y, t.zz.z], yz: [t.yz.x, t.yz.y, t.yz.z], zx: [t.zx.x, t.zx.y, t.zx.z], xy: [t.xy.x, t.xy.y, t.xy.z] } } function bd(e, t) { var i = (t = gd(t)).specular, r = h.Log2(t.width); if (r = Math.round(r) + 1, i.mipmaps.length !== 6 * r) throw new Error('Unsupported specular mipmaps number "'.concat(i.mipmaps.length, '"')); for (var n = new Array(r), o = 0; o < r; o++) { n[o] = new Array(6); for (var a = 0; a < 6; a++) { var s = i.mipmaps[6 * o + a]; n[o][a] = new Uint8Array(e.buffer, e.byteOffset + i.specularDataPosition + s.position, s.length) } } return n } function Td(e, t, i) { var r = (i = gd(i)).specular; return r ? (e._lodGenerationScale = r.lodGenerationScale, Sd(e, bd(t, i), i.imageType)) : Promise.resolve() } function Ed(e, t, i, r, n, o, s, l, c, u, h) { return new Promise((function (d, p) { if (i) { var f = t.createTexture(null, !0, !0, null, a.TEXTURE_NEAREST_SAMPLINGMODE, null, (function (e) { p(e) }), e); r.getEffect().executeWhenCompiled((function () { r.externalTextureSamplerBinding = !0, r.onApply = function (i) { i._bindTexture("textureSampler", f), i.setFloat2("scale", 1, t._features.needsInvertingBitmap && e instanceof ImageBitmap ? -1 : 1) }, t.scenes.length && (t.scenes[0].postProcessManager.directRender([r], u, !0, o, s), t.restoreDefaultFramebuffer(), f.dispose(), URL.revokeObjectURL(n), d()) })) } else { if (t._uploadImageToTexture(h, e, o, s), l) { var _ = c[s]; _ && t._uploadImageToTexture(_._texture, e, o, 0) } d() } })) } function Sd(e, t, i) { if (void 0 === i && (i = pd), !xi.IsExponentOfTwo(e.width)) throw new Error("Texture size must be a power of two"); var r = h.ILog2(e.width) + 1, n = e.getEngine(), o = !1, s = !1, l = null, c = null, u = null, d = n.getCaps(); if (e.format = a.TEXTUREFORMAT_RGBA, e.type = a.TEXTURETYPE_UNSIGNED_INT, e.generateMipMaps = !0, e._cachedAnisotropicFilteringLevel = null, n.updateTextureSamplingMode(a.TEXTURE_TRILINEAR_SAMPLINGMODE, e), d.textureLOD ? n._features.supportRenderAndCopyToLodForFloatTextures ? d.textureHalfFloatRender && d.textureHalfFloatLinearFiltering ? (o = !0, e.type = a.TEXTURETYPE_HALF_FLOAT) : d.textureFloatRender && d.textureFloatLinearFiltering && (o = !0, e.type = a.TEXTURETYPE_FLOAT) : o = !1 : (o = !1, s = !0, u = {}), o) l = new Ia("rgbdDecode", "rgbdDecode", null, null, 1, null, a.TEXTURE_TRILINEAR_SAMPLINGMODE, n, !1, void 0, e.type, void 0, null, !1), e._isRGBD = !1, e.invertY = !1, c = n.createRenderTargetCubeTexture(e.width, { generateDepthBuffer: !1, generateMipMaps: !0, generateStencilBuffer: !1, samplingMode: a.TEXTURE_TRILINEAR_SAMPLINGMODE, type: e.type, format: a.TEXTUREFORMAT_RGBA }); else if (e._isRGBD = !0, e.invertY = !0, s) for (var p = e._lodGenerationScale, f = e._lodGenerationOffset, _ = 0; _ < 3; _++) { var m = (r - 1) * p + f, g = f + (m - f) * (1 - _ / 2), v = Math.round(Math.min(Math.max(g, 0), m)), y = new Ht(n, It.Temp); y.isCube = !0, y.invertY = !0, y.generateMipMaps = !1, n.updateTextureSamplingMode(a.TEXTURE_LINEAR_LINEAR, y); var b = new po(null); switch (b._isCube = !0, b._texture = y, u[v] = b, _) { case 0: e._lodTextureLow = b; break; case 1: e._lodTextureMid = b; break; case 2: e._lodTextureHigh = b } } var T = [], E = function (r) { for (var a = function (a) { var h = t[r][a], d = new Blob([h], { type: i }), p = URL.createObjectURL(d), f = void 0; if ("undefined" == typeof Image || n._features.forceBitmapOverHTMLImageElement) f = n.createImageBitmap(d, { premultiplyAlpha: "none" }).then((function (t) { return Ed(t, n, o, l, p, a, r, s, u, c, e) })); else { var _ = new Image; _.src = p, f = new Promise((function (t, i) { _.onload = function () { Ed(_, n, o, l, p, a, r, s, u, c, e).then((function () { return t() })).catch((function (e) { i(e) })) }, _.onerror = function (e) { i(e) } })) } T.push(f) }, h = 0; h < 6; h++)a(h) }; for (_ = 0; _ < t.length; _++)E(_); if (t.length < r) { var S = void 0, x = Math.pow(2, r - 1 - t.length), A = x * x * 4; switch (e.type) { case a.TEXTURETYPE_UNSIGNED_INT: S = new Uint8Array(A); break; case a.TEXTURETYPE_HALF_FLOAT: S = new Uint16Array(A); break; case a.TEXTURETYPE_FLOAT: S = new Float32Array(A) }for (_ = t.length; _ < r; _++)for (var R = 0; R < 6; R++)n._uploadArrayBufferViewToTexture(e, S, R, _) } return Promise.all(T).then((function () { c && (n._releaseTexture(e), c._swapAndDie(e)), l && l.dispose(), s && (e._lodTextureHigh && e._lodTextureHigh._texture && (e._lodTextureHigh._texture.isReady = !0), e._lodTextureMid && e._lodTextureMid._texture && (e._lodTextureMid._texture.isReady = !0), e._lodTextureLow && e._lodTextureLow._texture && (e._lodTextureLow._texture.isReady = !0)) })) } function xd(e, t) { var i = (t = gd(t)).irradiance; if (i) { var r = new nd; R.FromArrayToRef(i.x, 0, r.x), R.FromArrayToRef(i.y, 0, r.y), R.FromArrayToRef(i.z, 0, r.z), R.FromArrayToRef(i.xx, 0, r.xx), R.FromArrayToRef(i.yy, 0, r.yy), R.FromArrayToRef(i.zz, 0, r.zz), R.FromArrayToRef(i.yz, 0, r.yz), R.FromArrayToRef(i.zx, 0, r.zx), R.FromArrayToRef(i.xy, 0, r.xy), e._sphericalPolynomial = r } } function Ad(e, t, i, r, n) { var o = Sd(e.getEngine().createRawCubeTexture(null, e.width, e.format, e.type, e.generateMipMaps, e.invertY, e.samplingMode, e._compression), t).then((function () { return e })); return e.onRebuildCallback = function (e) { return { proxy: o, isReady: !0, isAsync: !0 } }, e._source = It.CubeRawRGBD, e._bufferViewArrayArray = t, e._lodGenerationScale = r, e._lodGenerationOffset = n, e._sphericalPolynomial = i, Sd(e, t).then((function () { return e.isReady = !0, e })) } var Rd = { GetEnvInfo: md, CreateEnvTextureAsync: vd, CreateImageDataArrayBufferViews: bd, UploadEnvLevelsAsync: Td, UploadLevelsAsync: Sd, UploadEnvSpherical: xd }; function Cd(e, t, i, r) { for (var n = r, o = 0, a = ""; n < i.length;) { var s = i.charAt(n); if (a) s === a ? '"' === a || "'" === a ? "\\" !== i.charAt(n - 1) && (a = "") : a = "" : "*/" === a && "*" === s && n + 1 < i.length && ("/" === i.charAt(n + 1) && (a = ""), "" === a && n++); else switch (s) { case e: o++; break; case t: o--; break; case '"': case "'": case "`": a = s; break; case "/": if (n + 1 < i.length) { var l = i.charAt(n + 1); "/" === l ? a = "\n" : "*" === l && (a = "*/") } }if (n++, 0 === o) break } return 0 === o ? n - 1 : -1 } function Pd(e, t) { for (; t < e.length;) { var i = e[t]; if (" " !== i && "\n" !== i && "\r" !== i && "\t" !== i && "\n" !== i && "Â " !== i) break; t++ } return t } function Id(e) { var t = e.charCodeAt(0); return t >= 48 && t <= 57 || t >= 65 && t <= 90 || t >= 97 && t <= 122 || 95 == t } function Md(e) { for (var t = 0, i = "", r = !1, n = []; t < e.length;) { var o = e.charAt(t); if (i) o === i ? '"' === i || "'" === i ? ("\\" !== e.charAt(t - 1) && (i = ""), n.push(o)) : (i = "", r = !1) : "*/" === i && "*" === o && t + 1 < e.length ? ("/" === e.charAt(t + 1) && (i = ""), "" === i && (r = !1, t++)) : r || n.push(o); else { switch (o) { case '"': case "'": case "`": i = o; break; case "/": if (t + 1 < e.length) { var a = e.charAt(t + 1); "/" === a ? (i = "\n", r = !0) : "*" === a && (i = "*/", r = !0) } }r || n.push(o) } t++ } return n.join("") } function Od(e, t, i) { for (; t >= 0 && e.charAt(t) !== i;)t--; return t } var Dd, Nd = 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 < this._sourceCode.length;) { var r = this._sourceCode.indexOf(this.inlineToken, i); if (r < 0) break; var n = this._sourceCode.indexOf("(", r + this.inlineToken.length); if (n < 0) this.debug && console.warn("Could not find the opening parenthesis after the token. startIndex=".concat(i)), i = r + this.inlineToken.length; else { var o = e._RegexpFindFunctionNameAndType.exec(this._sourceCode.substring(r + this.inlineToken.length, n)); if (o) { var a = (t = [o[3], o[4]])[0], s = t[1], l = Cd("(", ")", this._sourceCode, n); if (l < 0) this.debug && console.warn("Could not extract the parameters the function '".concat(s, "' (type=").concat(a, "). funcParamsStartIndex=").concat(n)), i = r + this.inlineToken.length; else { var c = this._sourceCode.substring(n + 1, l), u = Pd(this._sourceCode, l + 1); if (u !== this._sourceCode.length) { var h = Cd("{", "}", this._sourceCode, u); if (h < 0) this.debug && console.warn("Could not extract the body of the function '".concat(s, "' (type=").concat(a, "). funcBodyStartIndex=").concat(u)), i = r + this.inlineToken.length; else { for (var d = this._sourceCode.substring(u, h + 1), p = Md(c).split(","), f = [], _ = 0; _ < p.length; ++_) { var m = p[_].trim(), g = m.lastIndexOf(" "); g >= 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 < this._sourceCode.length - 1 ? this._sourceCode.substring(h + 1) : ""; this._sourceCode = v + y, i -= h + 1 - r } } else this.debug && console.warn("Could not extract the body of the function '".concat(s, "' (type=").concat(a, "). funcParamsEndIndex=").concat(l)), i = r + this.inlineToken.length } } else this.debug && console.warn("Could not extract the name/type of the function from: ".concat(this._sourceCode.substring(r + this.inlineToken.length, n))), i = r + this.inlineToken.length } } this.debug && console.log("Collect functions: ".concat(this._functionDescr.length, " functions found. functionDescr="), this._functionDescr) }, e.prototype._processInlining = function (e) { for (void 0 === e && (e = 20); e-- >= 0 && this._replaceFunctionCallsByCode();); return this.debug && console.log("numMaxIterations is ".concat(e, " after inlining process")), e >= 0 }, e.prototype._replaceFunctionCallsByCode = function () { for (var e = !1, t = 0, i = this._functionDescr; t < i.length; t++)for (var r = i[t], n = r.name, o = r.type, a = r.parameters, s = r.body, l = 0; l < this._sourceCode.length;) { var c = this._sourceCode.indexOf(n, l); if (c < 0) break; if (0 === c || Id(this._sourceCode.charAt(c - 1))) l = c + n.length; else { var u = Pd(this._sourceCode, c + n.length); if (u !== this._sourceCode.length && "(" === this._sourceCode.charAt(u)) { var h = Cd("(", ")", this._sourceCode, u); if (h < 0) this.debug && console.warn("Could not extract the parameters of the function call. Function '".concat(n, "' (type=").concat(o, "). callParamsStartIndex=").concat(u)), l = c + n.length; else { var d = this._sourceCode.substring(u + 1, h), p = function (e) { for (var t = [], i = 0, r = 0; i < e.length;) { if ("(" === e.charAt(i)) { var n = Cd("(", ")", e, i); if (n < 0) return null; i = n } else "," === e.charAt(i) && (t.push(e.substring(r, i)), r = i + 1); i++ } return r < i && t.push(e.substring(r, i)), t }(Md(d)); if (null !== p) { for (var f = [], _ = 0; _ < p.length; ++_) { var m = p[_].trim(); f.push(m) } var g = "void" !== o ? n + "_" + r.callIndex++ : null; if (g && f.push(g + " ="), f.length === a.length) { l = h + 1; var v = this._replaceNames(s, a, f), y = c > 0 ? this._sourceCode.substring(0, c) : "", b = h + 1 < this._sourceCode.length - 1 ? this._sourceCode.substring(h + 1) : ""; if (g) { var T = Od(this._sourceCode, c - 1, "\n"); y = this._sourceCode.substring(0, T + 1); var E = this._sourceCode.substring(T + 1, c); this._sourceCode = y + o + " " + g + ";\n" + v + "\n" + E + g + b, this.debug && console.log("Replace function call by code. Function '".concat(n, "' (type=").concat(o, "). injectDeclarationIndex=").concat(T, ", call parameters=").concat(f)) } else this._sourceCode = y + v + b, l += v.length - (h + 1 - c), this.debug && console.log("Replace function call by code. Function '".concat(n, "' (type=").concat(o, "). functionCallIndex=").concat(c, ", call parameters=").concat(f)); e = !0 } else this.debug && console.warn("Invalid function call: not the same number of parameters for the call than the number expected by the function. Function '".concat(n, "' (type=").concat(o, "). function parameters=").concat(a, ", call parameters=").concat(f)), l = c + n.length } else this.debug && console.warn("Invalid function call: can't extract the parameters of the function call. Function '".concat(n, "' (type=").concat(o, "). callParamsStartIndex=").concat(u, ", callParams=") + d), l = c + n.length } } else l = c + n.length } } return e }, e.prototype._replaceNames = function (e, t, i) { for (var r = function (r) { var n = new RegExp(t[r].replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"), o = t[r].length, a = i[r]; e = e.replace(n, (function (i) { for (var n = [], s = 1; s < arguments.length; s++)n[s - 1] = arguments[s]; var l = n[0]; return Id(e.charAt(l - 1)) || Id(e.charAt(l + o)) ? t[r] : a })) }, n = 0; n < t.length; ++n)r(n); return e }, e._RegexpFindFunctionNameAndType = /((\s+?)(\w+)\s+(\w+)\s*?)$/, e }(), Fd = function () { function e(e) { this.isParallelCompiled = !0, this.isCompiled = !1, this._valueCache = {}, this._engine = e } return Object.defineProperty(e.prototype, "isAsync", { get: function () { return this.isParallelCompiled }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isReady", { get: function () { if (this.compilationError) { var e = this.compilationError.message; throw new Error("SHADER ERROR" + ("string" == typeof e ? "\n" + e : "")) } return this.isCompiled }, enumerable: !1, configurable: !0 }), e.prototype._getVertexShaderCode = function () { return null }, e.prototype._getFragmentShaderCode = function () { return null }, e.prototype._handlesSpectorRebuildCallback = function (e) { throw new Error("Not implemented") }, e.prototype._fillEffectInformation = function (e, t, i, r, n, o, a, s) { var l, c = this._engine; if (c.supportsUniformBuffers) for (var u in t) e.bindUniformBlock(u, t[u]); for (this._engine.getUniforms(this, i).forEach((function (e, t) { r[i[t]] = e })), this._uniforms = r, l = 0; l < n.length; l++)null == e.getUniform(n[l]) && (n.splice(l, 1), l--); n.forEach((function (e, t) { o[e] = t })), s.push.apply(s, c.getAttributes(this, a)) }, e.prototype.dispose = function () { this._uniforms = {} }, e.prototype._cacheMatrix = function (e, t) { var i = this._valueCache[e], r = t.updateFlag; return (void 0 === i || i !== r) && (this._valueCache[e] = r, !0) }, e.prototype._cacheFloat2 = function (e, t, i) { var r = this._valueCache[e]; if (!r) return r = [t, i], this._valueCache[e] = r, !0; var n = !1; return r[0] !== t && (r[0] = t, n = !0), r[1] !== i && (r[1] = i, n = !0), n }, e.prototype._cacheFloat3 = function (e, t, i, r) { var n = this._valueCache[e]; if (!n) return n = [t, i, r], this._valueCache[e] = n, !0; var o = !1; return n[0] !== t && (n[0] = t, o = !0), n[1] !== i && (n[1] = i, o = !0), n[2] !== r && (n[2] = r, o = !0), o }, e.prototype._cacheFloat4 = function (e, t, i, r, n) { var o = this._valueCache[e]; if (!o) return o = [t, i, r, n], this._valueCache[e] = o, !0; var a = !1; return o[0] !== t && (o[0] = t, a = !0), o[1] !== i && (o[1] = i, a = !0), o[2] !== r && (o[2] = r, a = !0), o[3] !== n && (o[3] = n, a = !0), a }, e.prototype.setInt = function (e, t) { var i = this._valueCache[e]; void 0 !== i && i === t || this._engine.setInt(this._uniforms[e], t) && (this._valueCache[e] = t) }, e.prototype.setInt2 = function (e, t, i) { this._cacheFloat2(e, t, i) && (this._engine.setInt2(this._uniforms[e], t, i) || (this._valueCache[e] = null)) }, e.prototype.setInt3 = function (e, t, i, r) { this._cacheFloat3(e, t, i, r) && (this._engine.setInt3(this._uniforms[e], t, i, r) || (this._valueCache[e] = null)) }, e.prototype.setInt4 = function (e, t, i, r, n) { this._cacheFloat4(e, t, i, r, n) && (this._engine.setInt4(this._uniforms[e], t, i, r, n) || (this._valueCache[e] = null)) }, e.prototype.setIntArray = function (e, t) { this._valueCache[e] = null, this._engine.setIntArray(this._uniforms[e], t) }, e.prototype.setIntArray2 = function (e, t) { this._valueCache[e] = null, this._engine.setIntArray2(this._uniforms[e], t) }, e.prototype.setIntArray3 = function (e, t) { this._valueCache[e] = null, this._engine.setIntArray3(this._uniforms[e], t) }, e.prototype.setIntArray4 = function (e, t) { this._valueCache[e] = null, this._engine.setIntArray4(this._uniforms[e], t) }, e.prototype.setUInt = function (e, t) { var i = this._valueCache[e]; void 0 !== i && i === t || this._engine.setUInt(this._uniforms[e], t) && (this._valueCache[e] = t) }, e.prototype.setUInt2 = function (e, t, i) { this._cacheFloat2(e, t, i) && (this._engine.setUInt2(this._uniforms[e], t, i) || (this._valueCache[e] = null)) }, e.prototype.setUInt3 = function (e, t, i, r) { this._cacheFloat3(e, t, i, r) && (this._engine.setUInt3(this._uniforms[e], t, i, r) || (this._valueCache[e] = null)) }, e.prototype.setUInt4 = function (e, t, i, r, n) { this._cacheFloat4(e, t, i, r, n) && (this._engine.setUInt4(this._uniforms[e], t, i, r, n) || (this._valueCache[e] = null)) }, e.prototype.setUIntArray = function (e, t) { this._valueCache[e] = null, this._engine.setUIntArray(this._uniforms[e], t) }, e.prototype.setUIntArray2 = function (e, t) { this._valueCache[e] = null, this._engine.setUIntArray2(this._uniforms[e], t) }, e.prototype.setUIntArray3 = function (e, t) { this._valueCache[e] = null, this._engine.setUIntArray3(this._uniforms[e], t) }, e.prototype.setUIntArray4 = function (e, t) { this._valueCache[e] = null, this._engine.setUIntArray4(this._uniforms[e], t) }, e.prototype.setFloatArray = function (e, t) { this._valueCache[e] = null, this._engine.setFloatArray(this._uniforms[e], t) }, e.prototype.setFloatArray2 = function (e, t) { this._valueCache[e] = null, this._engine.setFloatArray2(this._uniforms[e], t) }, e.prototype.setFloatArray3 = function (e, t) { this._valueCache[e] = null, this._engine.setFloatArray3(this._uniforms[e], t) }, e.prototype.setFloatArray4 = function (e, t) { this._valueCache[e] = null, this._engine.setFloatArray4(this._uniforms[e], t) }, e.prototype.setArray = function (e, t) { this._valueCache[e] = null, this._engine.setArray(this._uniforms[e], t) }, e.prototype.setArray2 = function (e, t) { this._valueCache[e] = null, this._engine.setArray2(this._uniforms[e], t) }, e.prototype.setArray3 = function (e, t) { this._valueCache[e] = null, this._engine.setArray3(this._uniforms[e], t) }, e.prototype.setArray4 = function (e, t) { this._valueCache[e] = null, this._engine.setArray4(this._uniforms[e], t) }, e.prototype.setMatrices = function (e, t) { t && (this._valueCache[e] = null, this._engine.setMatrices(this._uniforms[e], t)) }, e.prototype.setMatrix = function (e, t) { this._cacheMatrix(e, t) && (this._engine.setMatrices(this._uniforms[e], t.toArray()) || (this._valueCache[e] = null)) }, e.prototype.setMatrix3x3 = function (e, t) { this._valueCache[e] = null, this._engine.setMatrix3x3(this._uniforms[e], t) }, e.prototype.setMatrix2x2 = function (e, t) { this._valueCache[e] = null, this._engine.setMatrix2x2(this._uniforms[e], t) }, e.prototype.setFloat = function (e, t) { var i = this._valueCache[e]; void 0 !== i && i === t || this._engine.setFloat(this._uniforms[e], t) && (this._valueCache[e] = t) }, e.prototype.setBool = function (e, t) { var i = this._valueCache[e]; void 0 !== i && i === t || this._engine.setInt(this._uniforms[e], t ? 1 : 0) && (this._valueCache[e] = t ? 1 : 0) }, e.prototype.setVector2 = function (e, t) { this._cacheFloat2(e, t.x, t.y) && (this._engine.setFloat2(this._uniforms[e], t.x, t.y) || (this._valueCache[e] = null)) }, e.prototype.setFloat2 = function (e, t, i) { this._cacheFloat2(e, t, i) && (this._engine.setFloat2(this._uniforms[e], t, i) || (this._valueCache[e] = null)) }, e.prototype.setVector3 = function (e, t) { this._cacheFloat3(e, t.x, t.y, t.z) && (this._engine.setFloat3(this._uniforms[e], t.x, t.y, t.z) || (this._valueCache[e] = null)) }, e.prototype.setFloat3 = function (e, t, i, r) { this._cacheFloat3(e, t, i, r) && (this._engine.setFloat3(this._uniforms[e], t, i, r) || (this._valueCache[e] = null)) }, e.prototype.setVector4 = function (e, t) { this._cacheFloat4(e, t.x, t.y, t.z, t.w) && (this._engine.setFloat4(this._uniforms[e], t.x, t.y, t.z, t.w) || (this._valueCache[e] = null)) }, e.prototype.setQuaternion = function (e, t) { this._cacheFloat4(e, t.x, t.y, t.z, t.w) && (this._engine.setFloat4(this._uniforms[e], t.x, t.y, t.z, t.w) || (this._valueCache[e] = null)) }, e.prototype.setFloat4 = function (e, t, i, r, n) { this._cacheFloat4(e, t, i, r, n) && (this._engine.setFloat4(this._uniforms[e], t, i, r, n) || (this._valueCache[e] = null)) }, e.prototype.setColor3 = function (e, t) { this._cacheFloat3(e, t.r, t.g, t.b) && (this._engine.setFloat3(this._uniforms[e], t.r, t.g, t.b) || (this._valueCache[e] = null)) }, e.prototype.setColor4 = function (e, t, i) { this._cacheFloat4(e, t.r, t.g, t.b, i) && (this._engine.setFloat4(this._uniforms[e], t.r, t.g, t.b, i) || (this._valueCache[e] = null)) }, e.prototype.setDirectColor4 = function (e, t) { this._cacheFloat4(e, t.r, t.g, t.b, t.a) && (this._engine.setFloat4(this._uniforms[e], t.r, t.g, t.b, t.a) || (this._valueCache[e] = null)) }, e }(), Ld = function (e) { function t(t, i, r, n) { var o = e.call(this, t, i, r, n) || this; return o.__framebuffer = null, o.__framebufferDepthStencil = null, o._engine = n, o } return W(t, e), Object.defineProperty(t.prototype, "_framebuffer", { get: function () { return this.__framebuffer }, set: function (e) { this.__framebuffer && this._engine._releaseFramebufferObjects(this.__framebuffer), this.__framebuffer = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "_framebufferDepthStencil", { get: function () { return this.__framebufferDepthStencil }, set: function (e) { this.__framebufferDepthStencil && this._engine._releaseFramebufferObjects(this.__framebufferDepthStencil), this.__framebufferDepthStencil = e }, enumerable: !1, configurable: !0 }), t.prototype.dispose = function (t) { void 0 === t && (t = !1), this._framebuffer = null, this._framebufferDepthStencil = null, e.prototype.dispose.call(this, t) }, t }(Ca), wd = function () { function e(e, t) { this._engine = t, this.set(e) } return Object.defineProperty(e.prototype, "underlyingResource", { get: function () { return this._nativeTexture }, enumerable: !1, configurable: !0 }), e.prototype.setUsage = function () { }, e.prototype.set = function (e) { this._nativeTexture = e }, e.prototype.reset = function () { this._nativeTexture = null }, e.prototype.release = function () { this._nativeTexture && this._engine.deleteTexture(this._nativeTexture), this.reset() }, e }(), Bd = new u; function Ud() { return new Promise((function (e) { "undefined" == typeof _native ? Bd.addOnce((function (t) { return e(t) })) : e(_native) })) } function Vd(e, t) { return j(this, void 0, void 0, (function () { return Y(this, (function (i) { switch (i.label) { case 0: return [4, Ud()]; case 1: return i.sent()[e] = t, [2] } })) })) } "undefined" == typeof self || Object.prototype.hasOwnProperty.call(self, "_native") || Object.defineProperty(self, "_native", { get: function () { return Dd }, set: function (e) { (Dd = e) && Bd.notifyObservers(Dd) } }); var kd = function (e) { function t() { return null !== e && e.apply(this, arguments) || this } return W(t, e), t }(Kt), Gd = function () { function e(e) { this._engine = e, this._pending = new Array, this._isCommandBufferScopeActive = !1, this._commandStream = zd._createNativeDataStream(), this._engine.setCommandDataStream(this._commandStream) } return e.prototype.beginCommandScope = function () { if (this._isCommandBufferScopeActive) throw new Error("Command scope already active."); this._isCommandBufferScopeActive = !0 }, e.prototype.endCommandScope = function () { if (!this._isCommandBufferScopeActive) throw new Error("Command scope is not active."); this._isCommandBufferScopeActive = !1, this._submit() }, e.prototype.startEncodingCommand = function (e) { this._commandStream.writeNativeData(e) }, e.prototype.encodeCommandArgAsUInt32 = function (e) { this._commandStream.writeUint32(e) }, e.prototype.encodeCommandArgAsUInt32s = function (e) { this._commandStream.writeUint32Array(e) }, e.prototype.encodeCommandArgAsInt32 = function (e) { this._commandStream.writeInt32(e) }, e.prototype.encodeCommandArgAsInt32s = function (e) { this._commandStream.writeInt32Array(e) }, e.prototype.encodeCommandArgAsFloat32 = function (e) { this._commandStream.writeFloat32(e) }, e.prototype.encodeCommandArgAsFloat32s = function (e) { this._commandStream.writeFloat32Array(e) }, e.prototype.encodeCommandArgAsNativeData = function (e) { this._commandStream.writeNativeData(e), this._pending.push(e) }, e.prototype.finishEncodingCommand = function () { this._isCommandBufferScopeActive || this._submit() }, e.prototype._submit = function () { this._engine.submitCommands(), this._pending.length = 0 }, e }(), zd = function (e) { function t(i) { void 0 === i && (i = {}); var r = e.call(this, null, !1, void 0, i.adaptToDeviceRatio) || this; if (r._engine = new _native.Engine, r._camera = _native.Camera ? new _native.Camera : null, r._commandBufferEncoder = new Gd(r._engine), r._boundBuffersVertexArray = null, r._currentDepthTest = _native.Engine.DEPTH_TEST_LEQUAL, r._stencilTest = !1, r._stencilMask = 255, r._stencilFunc = a.ALWAYS, r._stencilFuncRef = 0, r._stencilFuncMask = 255, r._stencilOpStencilFail = a.KEEP, r._stencilOpDepthFail = a.KEEP, r._stencilOpStencilDepthPass = a.REPLACE, r._zOffset = 0, r._zOffsetUnits = 0, r._depthWrite = !0, _native.Engine.PROTOCOL_VERSION !== t.PROTOCOL_VERSION) throw new Error("Protocol version mismatch: ".concat(_native.Engine.PROTOCOL_VERSION, " (Native) !== ").concat(t.PROTOCOL_VERSION, " (JS)")); r._webGLVersion = 2, r.disableUniformBuffers = !0, r._shaderPlatformName = "NATIVE", r._caps = { maxTexturesImageUnits: 16, maxVertexTextureImageUnits: 16, maxCombinedTexturesImageUnits: 32, maxTextureSize: _native.Engine.CAPS_LIMITS_MAX_TEXTURE_SIZE, maxCubemapTextureSize: 512, maxRenderTextureSize: 512, maxVertexAttribs: 16, maxVaryingVectors: 16, maxFragmentUniformVectors: 16, maxVertexUniformVectors: 16, standardDerivatives: !0, astc: null, pvrtc: null, etc1: null, etc2: null, bptc: null, maxAnisotropy: 16, uintIndices: !0, fragmentDepthSupported: !1, highPrecisionShaderSupported: !0, colorBufferFloat: !1, textureFloat: !0, textureFloatLinearFiltering: !1, textureFloatRender: !0, textureHalfFloat: !0, textureHalfFloatLinearFiltering: !1, textureHalfFloatRender: !0, textureLOD: !0, texelFetch: !1, drawBuffersExtension: !1, depthTextureExtension: !1, vertexArrayObject: !0, instancedArrays: !0, supportOcclusionQuery: !1, canUseTimestampForTimerQuery: !1, blendMinMax: !1, maxMSAASamples: 16, canUseGLInstanceID: !0, canUseGLVertexID: !0, supportComputeShaders: !1, supportSRGBBuffers: !0, supportTransformFeedbacks: !1, textureMaxLevel: !1, texture2DArrayMaxLayerCount: _native.Engine.CAPS_LIMITS_MAX_TEXTURE_LAYERS, 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: !0, useUBOBindingCache: !0, needShaderCodeInlining: !0, needToAlwaysBindUniformBuffers: !1, supportRenderPasses: !0, supportSpriteInstancing: !1, _collectUbosUpdatedInFrame: !1 }, xi.Log("Babylon Native (v" + In.Version + ") launched"), xi.LoadScript = function (e, t, i, r) { xi.LoadFile(e, (function (e) { Function(e).apply(null), t && t() }), void 0, void 0, !1, (function (e, t) { i && i("LoadScript Error", t) })) }, "undefined" == typeof URL && (window.URL = { createObjectURL: function () { }, revokeObjectURL: function () { } }), "undefined" == typeof Blob && (window.Blob = function (e) { return e }), Array.prototype.flat || Object.defineProperty(Array.prototype, "flat", { configurable: !0, value: function e() { var t = isNaN(arguments[0]) ? 1 : Number(arguments[0]); return t ? Array.prototype.reduce.call(this, (function (i, r) { return Array.isArray(r) ? i.push.apply(i, e.call(r, t - 1)) : i.push(r), i }), []) : Array.prototype.slice.call(this) }, writable: !0 }); var n = window && window.devicePixelRatio || 1; r._hardwareScalingLevel = i.adaptToDeviceRatio ? 1 / n : 1, r._engine.setHardwareScalingLevel(r._hardwareScalingLevel), r._lastDevicePixelRatio = n, r.resize(); var o = r.getDepthFunction(); return o && r.setDepthFunction(o), r._shaderProcessor = new Yt, r.onNewSceneAddedObservable.add((function (e) { var t = e.render; e.render = function () { for (var i = [], n = 0; n < arguments.length; n++)i[n] = arguments[n]; r._commandBufferEncoder.beginCommandScope(), t.apply(e, i), r._commandBufferEncoder.endCommandScope() } })), r } return W(t, e), t.prototype.setHardwareScalingLevel = function (t) { e.prototype.setHardwareScalingLevel.call(this, t), this._engine.setHardwareScalingLevel(t) }, t.prototype.dispose = function () { e.prototype.dispose.call(this), this._boundBuffersVertexArray && this._deleteVertexArray(this._boundBuffersVertexArray), this._engine.dispose() }, t._createNativeDataStream = function () { return new Jh }, t.prototype._queueNewFrame = function (e, t) { return t.requestAnimationFrame && t !== window ? t.requestAnimationFrame(e) : this._engine.requestAnimationFrame(e), 0 }, t.prototype._bindUnboundFramebuffer = function (e) { this._currentFramebuffer !== e && (this._currentFramebuffer && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_UNBINDFRAMEBUFFER), this._commandBufferEncoder.encodeCommandArgAsNativeData(this._currentFramebuffer), this._commandBufferEncoder.finishEncodingCommand()), e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_BINDFRAMEBUFFER), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.finishEncodingCommand()), this._currentFramebuffer = e) }, t.prototype.getHostDocument = function () { return null }, t.prototype.clear = function (e, t, i, r) { if (void 0 === r && (r = !1), this.useReverseDepthBuffer) throw new Error("reverse depth buffer is not currently implemented"); this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_CLEAR), this._commandBufferEncoder.encodeCommandArgAsUInt32(t && e ? 1 : 0), this._commandBufferEncoder.encodeCommandArgAsFloat32(e ? e.r : 0), this._commandBufferEncoder.encodeCommandArgAsFloat32(e ? e.g : 0), this._commandBufferEncoder.encodeCommandArgAsFloat32(e ? e.b : 0), this._commandBufferEncoder.encodeCommandArgAsFloat32(e ? e.a : 1), this._commandBufferEncoder.encodeCommandArgAsUInt32(i ? 1 : 0), this._commandBufferEncoder.encodeCommandArgAsFloat32(1), this._commandBufferEncoder.encodeCommandArgAsUInt32(r ? 1 : 0), this._commandBufferEncoder.encodeCommandArgAsUInt32(0), this._commandBufferEncoder.finishEncodingCommand() }, t.prototype.createIndexBuffer = function (e, t) { var i = this._normalizeIndexData(e), r = new kd; return r.references = 1, r.is32Bits = 4 === i.BYTES_PER_ELEMENT, i.byteLength && (r.nativeIndexBuffer = this._engine.createIndexBuffer(i.buffer, i.byteOffset, i.byteLength, r.is32Bits, null != t && t)), r }, t.prototype.createVertexBuffer = function (e, t) { var i = ArrayBuffer.isView(e) ? e : new Float32Array(e), r = new kd; return r.references = 1, i.byteLength && (r.nativeVertexBuffer = this._engine.createVertexBuffer(i.buffer, i.byteOffset, i.byteLength, null != t && t)), r }, t.prototype._recordVertexArrayObject = function (e, t, i, r, n) { i && this._engine.recordIndexBuffer(e, i.nativeIndexBuffer); for (var o = r.getAttributesNames(), a = 0; a < o.length; a++) { var s = r.getAttributeLocation(a); if (s >= 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(), this._getNativeAttribType(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), 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), 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 Fd(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 Nd(t); a.processCode(), t = a.code; var s = new Nd(i); s.processCode(), i = s.code, t = ti._ConcatenateShader(t, r), i = ti._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 Nd(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 < i.length; r++) { var n = e.getUniform(i[r]); n && (this._boundUniforms[r] = n) } this._currentEffect = null }, t.prototype.getRenderWidth = function (e) { return void 0 === e && (e = !1), !e && this._currentRenderTarget ? this._currentRenderTarget.width : this._engine.getRenderWidth() }, t.prototype.getRenderHeight = function (e) { return void 0 === e && (e = !1), !e && this._currentRenderTarget ? this._currentRenderTarget.height : this._engine.getRenderHeight() }, t.prototype.setViewport = function (e, t, i) { this._cachedViewport = e, this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETVIEWPORT), this._commandBufferEncoder.encodeCommandArgAsFloat32(e.x), this._commandBufferEncoder.encodeCommandArgAsFloat32(e.y), this._commandBufferEncoder.encodeCommandArgAsFloat32(e.width), this._commandBufferEncoder.encodeCommandArgAsFloat32(e.height), this._commandBufferEncoder.finishEncodingCommand() }, t.prototype.enableScissor = function (e, t, i, r) { this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETSCISSOR), this._commandBufferEncoder.encodeCommandArgAsFloat32(e), this._commandBufferEncoder.encodeCommandArgAsFloat32(t), this._commandBufferEncoder.encodeCommandArgAsFloat32(i), this._commandBufferEncoder.encodeCommandArgAsFloat32(r), this._commandBufferEncoder.finishEncodingCommand() }, t.prototype.disableScissor = function () { this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETSCISSOR), this._commandBufferEncoder.encodeCommandArgAsFloat32(0), this._commandBufferEncoder.encodeCommandArgAsFloat32(0), this._commandBufferEncoder.encodeCommandArgAsFloat32(0), this._commandBufferEncoder.encodeCommandArgAsFloat32(0), this._commandBufferEncoder.finishEncodingCommand() }, t.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._zOffset = t, this._zOffsetUnits = a, this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETSTATE), this._commandBufferEncoder.encodeCommandArgAsUInt32(e ? 1 : 0), this._commandBufferEncoder.encodeCommandArgAsFloat32(t), this._commandBufferEncoder.encodeCommandArgAsFloat32(a), this._commandBufferEncoder.encodeCommandArgAsUInt32(null === (l = null !== (s = this.cullBackFaces) && void 0 !== s ? s : n) || void 0 === l || l ? 1 : 0), this._commandBufferEncoder.encodeCommandArgAsUInt32(r ? 1 : 0), this._commandBufferEncoder.finishEncodingCommand() }, t.prototype.getInputElementClientRect = function () { return { bottom: this.getRenderHeight(), height: this.getRenderHeight(), left: 0, right: this.getRenderWidth(), top: 0, width: this.getRenderWidth(), x: 0, y: 0, toJSON: function () { } } }, t.prototype.setZOffset = function (e) { e !== this._zOffset && (this._zOffset = e, this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETZOFFSET), this._commandBufferEncoder.encodeCommandArgAsFloat32(this.useReverseDepthBuffer ? -e : e), this._commandBufferEncoder.finishEncodingCommand()) }, t.prototype.getZOffset = function () { return this._zOffset }, t.prototype.setZOffsetUnits = function (e) { e !== this._zOffsetUnits && (this._zOffsetUnits = e, this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETZOFFSETUNITS), this._commandBufferEncoder.encodeCommandArgAsFloat32(this.useReverseDepthBuffer ? -e : e), this._commandBufferEncoder.finishEncodingCommand()) }, t.prototype.getZOffsetUnits = function () { return this._zOffsetUnits }, t.prototype.setDepthBuffer = function (e) { this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETDEPTHTEST), this._commandBufferEncoder.encodeCommandArgAsUInt32(e ? this._currentDepthTest : _native.Engine.DEPTH_TEST_ALWAYS), this._commandBufferEncoder.finishEncodingCommand() }, t.prototype.getDepthWrite = function () { return this._depthWrite }, t.prototype.getDepthFunction = function () { switch (this._currentDepthTest) { case _native.Engine.DEPTH_TEST_NEVER: return a.NEVER; case _native.Engine.DEPTH_TEST_ALWAYS: return a.ALWAYS; case _native.Engine.DEPTH_TEST_GREATER: return a.GREATER; case _native.Engine.DEPTH_TEST_GEQUAL: return a.GEQUAL; case _native.Engine.DEPTH_TEST_NOTEQUAL: return a.NOTEQUAL; case _native.Engine.DEPTH_TEST_EQUAL: return a.EQUAL; case _native.Engine.DEPTH_TEST_LESS: return a.LESS; case _native.Engine.DEPTH_TEST_LEQUAL: return a.LEQUAL }return null }, t.prototype.setDepthFunction = function (e) { var t = 0; switch (e) { case a.NEVER: t = _native.Engine.DEPTH_TEST_NEVER; break; case a.ALWAYS: t = _native.Engine.DEPTH_TEST_ALWAYS; break; case a.GREATER: t = _native.Engine.DEPTH_TEST_GREATER; break; case a.GEQUAL: t = _native.Engine.DEPTH_TEST_GEQUAL; break; case a.NOTEQUAL: t = _native.Engine.DEPTH_TEST_NOTEQUAL; break; case a.EQUAL: t = _native.Engine.DEPTH_TEST_EQUAL; break; case a.LESS: t = _native.Engine.DEPTH_TEST_LESS; break; case a.LEQUAL: t = _native.Engine.DEPTH_TEST_LEQUAL }this._currentDepthTest = t, this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETDEPTHTEST), this._commandBufferEncoder.encodeCommandArgAsUInt32(this._currentDepthTest), this._commandBufferEncoder.finishEncodingCommand() }, t.prototype.setDepthWrite = function (e) { this._depthWrite = e, this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETDEPTHWRITE), this._commandBufferEncoder.encodeCommandArgAsUInt32(Number(e)), this._commandBufferEncoder.finishEncodingCommand() }, t.prototype.setColorWrite = function (e) { this._colorWrite = e, this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETCOLORWRITE), this._commandBufferEncoder.encodeCommandArgAsUInt32(Number(e)), this._commandBufferEncoder.finishEncodingCommand() }, t.prototype.getColorWrite = function () { return this._colorWrite }, t.prototype.applyStencil = function () { this._setStencil(this._stencilMask, this._getStencilOpFail(this._stencilOpStencilFail), this._getStencilDepthFail(this._stencilOpDepthFail), this._getStencilDepthPass(this._stencilOpStencilDepthPass), this._getStencilFunc(this._stencilFunc), this._stencilFuncRef) }, t.prototype._setStencil = function (e, t, i, r, n, o) { this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETSTENCIL), this._commandBufferEncoder.encodeCommandArgAsUInt32(e), this._commandBufferEncoder.encodeCommandArgAsUInt32(t), this._commandBufferEncoder.encodeCommandArgAsUInt32(i), this._commandBufferEncoder.encodeCommandArgAsUInt32(r), this._commandBufferEncoder.encodeCommandArgAsUInt32(n), this._commandBufferEncoder.encodeCommandArgAsUInt32(o), this._commandBufferEncoder.finishEncodingCommand() }, t.prototype.setStencilBuffer = function (e) { this._stencilTest = e, e ? this.applyStencil() : this._setStencil(255, _native.Engine.STENCIL_OP_FAIL_S_KEEP, _native.Engine.STENCIL_OP_FAIL_Z_KEEP, _native.Engine.STENCIL_OP_PASS_Z_KEEP, _native.Engine.STENCIL_TEST_ALWAYS, 0) }, t.prototype.getStencilBuffer = function () { return this._stencilTest }, t.prototype.getStencilOperationPass = function () { return this._stencilOpStencilDepthPass }, t.prototype.setStencilOperationPass = function (e) { this._stencilOpStencilDepthPass = e, this.applyStencil() }, t.prototype.setStencilMask = function (e) { this._stencilMask = e, this.applyStencil() }, t.prototype.setStencilFunction = function (e) { this._stencilFunc = e, this.applyStencil() }, t.prototype.setStencilFunctionReference = function (e) { this._stencilFuncRef = e, this.applyStencil() }, t.prototype.setStencilFunctionMask = function (e) { this._stencilFuncMask = e }, t.prototype.setStencilOperationFail = function (e) { this._stencilOpStencilFail = e, this.applyStencil() }, t.prototype.setStencilOperationDepthFail = function (e) { this._stencilOpDepthFail = e, this.applyStencil() }, t.prototype.getStencilMask = function () { return this._stencilMask }, t.prototype.getStencilFunction = function () { return this._stencilFunc }, t.prototype.getStencilFunctionReference = function () { return this._stencilFuncRef }, t.prototype.getStencilFunctionMask = function () { return this._stencilFuncMask }, t.prototype.getStencilOperationFail = function () { return this._stencilOpStencilFail }, t.prototype.getStencilOperationDepthFail = function () { return this._stencilOpDepthFail }, t.prototype.setAlphaConstants = function (e, t, i, r) { throw new Error("Setting alpha blend constant color not yet implemented.") }, t.prototype.setAlphaMode = function (e, t) { if (void 0 === t && (t = !1), this._alphaMode !== e) { var i = this._getNativeAlphaMode(e); this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETBLENDMODE), this._commandBufferEncoder.encodeCommandArgAsUInt32(i), this._commandBufferEncoder.finishEncodingCommand(), t || this.setDepthWrite(e === a.ALPHA_DISABLE), this._alphaMode = e } }, t.prototype.getAlphaMode = function () { return this._alphaMode }, t.prototype.setInt = function (e, t) { return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINT), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsInt32(t), this._commandBufferEncoder.finishEncodingCommand(), !0) }, t.prototype.setIntArray = function (e, t) { return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsInt32s(t), this._commandBufferEncoder.finishEncodingCommand(), !0) }, t.prototype.setIntArray2 = function (e, t) { return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY2), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsInt32s(t), this._commandBufferEncoder.finishEncodingCommand(), !0) }, t.prototype.setIntArray3 = function (e, t) { return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY3), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsInt32s(t), this._commandBufferEncoder.finishEncodingCommand(), !0) }, t.prototype.setIntArray4 = function (e, t) { return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY4), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsInt32s(t), this._commandBufferEncoder.finishEncodingCommand(), !0) }, t.prototype.setFloatArray = function (e, t) { return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsFloat32s(t), this._commandBufferEncoder.finishEncodingCommand(), !0) }, t.prototype.setFloatArray2 = function (e, t) { return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY2), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsFloat32s(t), this._commandBufferEncoder.finishEncodingCommand(), !0) }, t.prototype.setFloatArray3 = function (e, t) { return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY3), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsFloat32s(t), this._commandBufferEncoder.finishEncodingCommand(), !0) }, t.prototype.setFloatArray4 = function (e, t) { return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY4), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsFloat32s(t), this._commandBufferEncoder.finishEncodingCommand(), !0) }, t.prototype.setArray = function (e, t) { return !!e && this.setFloatArray(e, new Float32Array(t)) }, t.prototype.setArray2 = function (e, t) { return !!e && this.setFloatArray2(e, new Float32Array(t)) }, t.prototype.setArray3 = function (e, t) { return !!e && this.setFloatArray3(e, new Float32Array(t)) }, t.prototype.setArray4 = function (e, t) { return !!e && this.setFloatArray4(e, new Float32Array(t)) }, t.prototype.setMatrices = function (e, t) { return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRICES), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsFloat32s(t), this._commandBufferEncoder.finishEncodingCommand(), !0) }, t.prototype.setMatrix3x3 = function (e, t) { return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRIX3X3), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsFloat32s(t), this._commandBufferEncoder.finishEncodingCommand(), !0) }, t.prototype.setMatrix2x2 = function (e, t) { return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRIX2X2), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsFloat32s(t), this._commandBufferEncoder.finishEncodingCommand(), !0) }, t.prototype.setFloat = function (e, t) { return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsFloat32(t), this._commandBufferEncoder.finishEncodingCommand(), !0) }, t.prototype.setFloat2 = function (e, t, i) { return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT2), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsFloat32(t), this._commandBufferEncoder.encodeCommandArgAsFloat32(i), this._commandBufferEncoder.finishEncodingCommand(), !0) }, t.prototype.setFloat3 = function (e, t, i, r) { return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT3), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsFloat32(t), this._commandBufferEncoder.encodeCommandArgAsFloat32(i), this._commandBufferEncoder.encodeCommandArgAsFloat32(r), this._commandBufferEncoder.finishEncodingCommand(), !0) }, t.prototype.setFloat4 = function (e, t, i, r, n) { return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT4), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.encodeCommandArgAsFloat32(t), this._commandBufferEncoder.encodeCommandArgAsFloat32(i), this._commandBufferEncoder.encodeCommandArgAsFloat32(r), this._commandBufferEncoder.encodeCommandArgAsFloat32(n), this._commandBufferEncoder.finishEncodingCommand(), !0) }, t.prototype.setColor3 = function (e, t) { return !!e && (this.setFloat3(e, t.r, t.g, t.b), !0) }, t.prototype.setColor4 = function (e, t, i) { return !!e && (this.setFloat4(e, t.r, t.g, t.b, i), !0) }, t.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) }, t.prototype._createTexture = function () { return this._engine.createTexture() }, t.prototype._deleteTexture = function (e) { e && this._engine.deleteTexture(e) }, t.prototype.updateDynamicTexture = function (e, t, i, r, n) { if (void 0 === r && (r = !1), void 0 === r && (r = !1), e && e._hardwareTexture) { var o = t.getCanvasTexture(), a = e._hardwareTexture.underlyingResource; this._engine.copyTexture(a, o), e.isReady = !0 } }, t.prototype.createDynamicTexture = function (e, t, i, r) { return e = Math.max(e, 1), t = Math.max(t, 1), this.createRawTexture(new Uint8Array(e * t * 4), e, t, a.TEXTUREFORMAT_RGBA, !1, !1, r) }, t.prototype.createVideoElement = function (e) { return this._camera ? this._camera.createVideo(e) : null }, t.prototype.updateVideoTexture = function (e, t, i) { if (e && e._hardwareTexture && this._camera) { var r = e._hardwareTexture.underlyingResource; this._camera.updateVideoTexture(r, t, i) } }, t.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 Ht(this, It.Raw); if (d.format = r, d.generateMipMaps = n, d.samplingMode = s, d.invertY = o, d.baseWidth = t, d.baseHeight = i, d.width = d.baseWidth, d.height = d.baseHeight, d._compression = l, d.type = c, d._useSRGBBuffer = this._getUseSRGBBuffer(h, !n), this.updateRawTexture(d, e, r, o, l, c, d._useSRGBBuffer), d._hardwareTexture) { var p = d._hardwareTexture.underlyingResource, f = this._getNativeSamplingMode(s); this._setTextureSampling(p, f) } return this._internalTexturesCache.push(d), d }, t.prototype.createRawTexture2DArray = function (e, t, i, r, n, o, s, l, c, u) { void 0 === c && (c = null), void 0 === u && (u = a.TEXTURETYPE_UNSIGNED_INT); var h = new Ht(this, It.Raw2DArray); if (h.baseWidth = t, h.baseHeight = i, h.baseDepth = r, h.width = t, h.height = i, h.depth = r, h.format = n, h.type = u, h.generateMipMaps = o, h.samplingMode = l, h.is2DArray = !0, h._hardwareTexture) { var d = h._hardwareTexture.underlyingResource; this._engine.loadRawTexture2DArray(d, e, t, i, r, this._getNativeTextureFormat(n, u), o, s); var p = this._getNativeSamplingMode(l); this._setTextureSampling(d, p) } return h.isReady = !0, this._internalTexturesCache.push(h), h }, t.prototype.updateRawTexture = function (e, t, i, r, n, o, s) { if (void 0 === n && (n = null), void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT), void 0 === s && (s = !1), e) { if (t && e._hardwareTexture) { var l = e._hardwareTexture.underlyingResource; this._engine.loadRawTexture(l, t, e.width, e.height, this._getNativeTextureFormat(i, o), e.generateMipMaps, e.invertY) } e.isReady = !0 } }, t.prototype.createTexture = function (e, t, i, r, n, o, s, l, c, u, h, d, p, f, _) { var m = this; 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), void 0 === _ && (_ = !1); var g = "data:" === (e = e || "").substr(0, 5), v = g && -1 !== e.indexOf(";base64,"), y = c || new Ht(this, It.Url), b = e; !this._transformTextureUrl || v || c || l || (e = this._transformTextureUrl(e)); for (var T = e.lastIndexOf("."), E = h || (T > -1 ? e.substring(T).toLowerCase() : ""), x = null, A = 0, R = In._TextureLoaders; A < R.length; A++) { var C = R[A]; if (C.canLoad(E)) { x = C; break } } r && r.addPendingData(y), y.url = e, y.generateMipMaps = !t, y.samplingMode = n, y.invertY = i, y._useSRGBBuffer = this._getUseSRGBBuffer(_, t), this.doNotHandleContextLost || (y._buffer = l); var P = null; if (o && !c && (P = y.onLoadedObservable.add(o)), c || this._internalTexturesCache.push(y), x) throw new Error("Loading textures from IInternalTextureLoader not yet implemented."); var I = function (e) { if (y._hardwareTexture) { var o = y._hardwareTexture.underlyingResource; m._engine.loadTexture(o, e, !t, i, y._useSRGBBuffer, (function () { y.baseWidth = m._engine.getTextureWidth(o), y.baseHeight = m._engine.getTextureHeight(o), y.width = y.baseWidth, y.height = y.baseHeight, y.isReady = !0; var e = m._getNativeSamplingMode(n); m._setTextureSampling(o, e), r && r.removePendingData(y), y.onLoadedObservable.notifyObservers(y), y.onLoadedObservable.clear() }), (function () { throw new Error("Could not load a native texture.") })) } else r && r.removePendingData(y) }; if (g && l) if (l instanceof ArrayBuffer) I(new Uint8Array(l)); else if (ArrayBuffer.isView(l)) I(l); else { if ("string" != typeof l) throw new Error("Unsupported buffer type"); I(new Uint8Array(xi.DecodeBase64(l))) } else v ? I(new Uint8Array(xi.DecodeBase64(e))) : this._loadFile(e, (function (e) { return I(new Uint8Array(e)) }), void 0, void 0, !0, (function (i, a) { var c; c = "Unable to load " + (i && i.responseURL, a), r && r.removePendingData(y), e === b ? (P && y.onLoadedObservable.remove(P), S.UseFallbackTexture && m.createTexture(S.FallbackTexture, t, y.invertY, r, n, null, s, l, y), s && s((c || "Unknown error") + (S.UseFallbackTexture ? " - Fallback texture was used" : ""), void 0)) : ($.Warn("Failed to load ".concat(e, ", falling back to ").concat(b)), m.createTexture(b, t, y.invertY, r, n, o, s, l, y, u, h, d, p)) })); return y }, t.prototype.wrapNativeTexture = function (e, t, i) { void 0 === t && (t = !1), void 0 === i && (i = a.TEXTURE_TRILINEAR_SAMPLINGMODE); var r = new wd(e, this._engine), n = new Ht(this, It.Unknown, !0); return n._hardwareTexture = r, n.isReady = !0, n.useMipMaps = t, this.updateTextureSamplingMode(i, n), n }, t.prototype.wrapWebGLTexture = function () { throw new Error("wrapWebGLTexture is not supported, use wrapNativeTexture instead.") }, t.prototype._createDepthStencilTexture = function (e, t, i) { var r, n, o = t.generateStencil || !1, a = t.samples || 1, s = i, l = new Ht(this, It.DepthStencil), c = null !== (r = e.width) && void 0 !== r ? r : e, u = null !== (n = e.height) && void 0 !== n ? n : e, h = this._engine.createFrameBuffer(l._hardwareTexture.underlyingResource, c, u, o, !0, a); return s._framebufferDepthStencil = h, l }, t.prototype._releaseFramebufferObjects = function (e) { e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEFRAMEBUFFER), this._commandBufferEncoder.encodeCommandArgAsNativeData(e), this._commandBufferEncoder.finishEncodingCommand()) }, t.prototype._createImageBitmapFromSource = function (e, t) { var i = this; return new Promise((function (t, r) { var n = i.createCanvasImage(); n.onload = function () { try { var e = i._engine.createImageBitmap(n); t(e) } catch (e) { r("Error loading image ".concat(n.src, " with exception: ").concat(e)) } }, n.onerror = function (e) { r("Error loading image ".concat(n.src, " with exception: ").concat(e)) }, n.src = e })) }, t.prototype.createImageBitmap = function (e, t) { var i = this; return new Promise((function (t, r) { if (Array.isArray(e)) { var n = e; if (n.length) { var o = i._engine.createImageBitmap(n[0]); if (o) return void t(o) } } r("Unsupported data for createImageBitmap.") })) }, t.prototype.resizeImageBitmap = function (e, t, i) { return this._engine.resizeImageBitmap(e, t, i) }, t.prototype.createCubeTexture = function (e, t, i, r, n, o, s, l, c, u, h, d, p, f) { var _ = this; void 0 === n && (n = null), void 0 === o && (o = null), void 0 === l && (l = null), void 0 === c && (c = !1), void 0 === u && (u = 0), void 0 === h && (h = 0), void 0 === d && (d = null), void 0 === f && (f = !1); var m = d || new Ht(this, It.Cube); m.isCube = !0, m.url = e, m.generateMipMaps = !r, m._lodGenerationScale = u, m._lodGenerationOffset = h, m._useSRGBBuffer = this._getUseSRGBBuffer(f, !!r), this._doNotHandleContextLost || (m._extension = l, m._files = i); var g = e.lastIndexOf("."); if (".env" === (l || (g > -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 = md(e); m.width = t.width, m.height = t.width, xd(m, t); var i = t.specular; if (!i) throw new Error("Nothing else parsed so far"); m._lodGenerationScale = i.lodGenerationScale; var r = bd(e, t); m.format = a.TEXTUREFORMAT_RGBA, m.type = a.TEXTURETYPE_UNSIGNED_INT, m.generateMipMaps = !0, m.getEngine().updateTextureSamplingMode(vo.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 xi.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 wd(this._createTexture(), this._engine) }, t.prototype._createHardwareRenderTargetWrapper = function (e, t, i) { var r = new Ld(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 = It.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 Ht(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 = this._getNativeTextureFormat(d, u); return this._engine.initializeTexture(y, m, g, c, b, !0, p, f), this._setTextureSampling(y, this._getNativeSamplingMode(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, It.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 = this._getNativeSamplingMode(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, this._getAddressMode(t.wrapU), this._getAddressMode(t.wrapV), this._getAddressMode(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._getAddressMode = function (e) { switch (e) { case a.TEXTURE_WRAP_ADDRESSMODE: return _native.Engine.ADDRESS_MODE_WRAP; case a.TEXTURE_CLAMP_ADDRESSMODE: return _native.Engine.ADDRESS_MODE_CLAMP; case a.TEXTURE_MIRROR_ADDRESSMODE: return _native.Engine.ADDRESS_MODE_MIRROR; default: throw new Error("Unexpected wrap mode: " + e + ".") } }, 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._getNativeSamplingMode = function (e) { switch (e) { case a.TEXTURE_NEAREST_NEAREST: return _native.Engine.TEXTURE_NEAREST_NEAREST; case a.TEXTURE_LINEAR_LINEAR: return _native.Engine.TEXTURE_LINEAR_LINEAR; case a.TEXTURE_LINEAR_LINEAR_MIPLINEAR: return _native.Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR; case a.TEXTURE_NEAREST_NEAREST_MIPNEAREST: return _native.Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST; case a.TEXTURE_NEAREST_LINEAR_MIPNEAREST: return _native.Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST; case a.TEXTURE_NEAREST_LINEAR_MIPLINEAR: return _native.Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR; case a.TEXTURE_NEAREST_LINEAR: return _native.Engine.TEXTURE_NEAREST_LINEAR; case a.TEXTURE_NEAREST_NEAREST_MIPLINEAR: return _native.Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR; case a.TEXTURE_LINEAR_NEAREST_MIPNEAREST: return _native.Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST; case a.TEXTURE_LINEAR_NEAREST_MIPLINEAR: return _native.Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR; case a.TEXTURE_LINEAR_LINEAR_MIPNEAREST: return _native.Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST; case a.TEXTURE_LINEAR_NEAREST: return _native.Engine.TEXTURE_LINEAR_NEAREST; default: throw new Error("Unsupported sampling mode: ".concat(e, ".")) } }, t.prototype._getStencilFunc = function (e) { switch (e) { case a.LESS: return _native.Engine.STENCIL_TEST_LESS; case a.LEQUAL: return _native.Engine.STENCIL_TEST_LEQUAL; case a.EQUAL: return _native.Engine.STENCIL_TEST_EQUAL; case a.GEQUAL: return _native.Engine.STENCIL_TEST_GEQUAL; case a.GREATER: return _native.Engine.STENCIL_TEST_GREATER; case a.NOTEQUAL: return _native.Engine.STENCIL_TEST_NOTEQUAL; case a.NEVER: return _native.Engine.STENCIL_TEST_NEVER; case a.ALWAYS: return _native.Engine.STENCIL_TEST_ALWAYS; default: throw new Error("Unsupported stencil func mode: ".concat(e, ".")) } }, t.prototype._getStencilOpFail = function (e) { switch (e) { case a.KEEP: return _native.Engine.STENCIL_OP_FAIL_S_KEEP; case a.ZERO: return _native.Engine.STENCIL_OP_FAIL_S_ZERO; case a.REPLACE: return _native.Engine.STENCIL_OP_FAIL_S_REPLACE; case a.INCR: return _native.Engine.STENCIL_OP_FAIL_S_INCR; case a.DECR: return _native.Engine.STENCIL_OP_FAIL_S_DECR; case a.INVERT: return _native.Engine.STENCIL_OP_FAIL_S_INVERT; case a.INCR_WRAP: return _native.Engine.STENCIL_OP_FAIL_S_INCRSAT; case a.DECR_WRAP: return _native.Engine.STENCIL_OP_FAIL_S_DECRSAT; default: throw new Error("Unsupported stencil OpFail mode: ".concat(e, ".")) } }, t.prototype._getStencilDepthFail = function (e) { switch (e) { case a.KEEP: return _native.Engine.STENCIL_OP_FAIL_Z_KEEP; case a.ZERO: return _native.Engine.STENCIL_OP_FAIL_Z_ZERO; case a.REPLACE: return _native.Engine.STENCIL_OP_FAIL_Z_REPLACE; case a.INCR: return _native.Engine.STENCIL_OP_FAIL_Z_INCR; case a.DECR: return _native.Engine.STENCIL_OP_FAIL_Z_DECR; case a.INVERT: return _native.Engine.STENCIL_OP_FAIL_Z_INVERT; case a.INCR_WRAP: return _native.Engine.STENCIL_OP_FAIL_Z_INCRSAT; case a.DECR_WRAP: return _native.Engine.STENCIL_OP_FAIL_Z_DECRSAT; default: throw new Error("Unsupported stencil depthFail mode: ".concat(e, ".")) } }, t.prototype._getStencilDepthPass = function (e) { switch (e) { case a.KEEP: return _native.Engine.STENCIL_OP_PASS_Z_KEEP; case a.ZERO: return _native.Engine.STENCIL_OP_PASS_Z_ZERO; case a.REPLACE: return _native.Engine.STENCIL_OP_PASS_Z_REPLACE; case a.INCR: return _native.Engine.STENCIL_OP_PASS_Z_INCR; case a.DECR: return _native.Engine.STENCIL_OP_PASS_Z_DECR; case a.INVERT: return _native.Engine.STENCIL_OP_PASS_Z_INVERT; case a.INCR_WRAP: return _native.Engine.STENCIL_OP_PASS_Z_INCRSAT; case a.DECR_WRAP: return _native.Engine.STENCIL_OP_PASS_Z_DECRSAT; default: throw new Error("Unsupported stencil opPass mode: ".concat(e, ".")) } }, t.prototype._getNativeTextureFormat = function (e, t) { if (e == a.TEXTUREFORMAT_RGB && t == a.TEXTURETYPE_UNSIGNED_INT) return _native.Engine.TEXTURE_FORMAT_RGB8; if (e == a.TEXTUREFORMAT_RGBA && t == a.TEXTURETYPE_UNSIGNED_INT) return _native.Engine.TEXTURE_FORMAT_RGBA8; if (e == a.TEXTUREFORMAT_RGBA && t == a.TEXTURETYPE_HALF_FLOAT) return _native.Engine.TEXTURE_FORMAT_RGBA16F; if (e == a.TEXTUREFORMAT_RGBA && t == a.TEXTURETYPE_FLOAT) return _native.Engine.TEXTURE_FORMAT_RGBA32F; throw new ht("Unsupported texture format or type: format ".concat(e, ", type ").concat(t, "."), ut.UnsupportedTextureError) }, t.prototype._getNativeAlphaMode = function (e) { switch (e) { case a.ALPHA_DISABLE: return _native.Engine.ALPHA_DISABLE; case a.ALPHA_ADD: return _native.Engine.ALPHA_ADD; case a.ALPHA_COMBINE: return _native.Engine.ALPHA_COMBINE; case a.ALPHA_SUBTRACT: return _native.Engine.ALPHA_SUBTRACT; case a.ALPHA_MULTIPLY: return _native.Engine.ALPHA_MULTIPLY; case a.ALPHA_MAXIMIZED: return _native.Engine.ALPHA_MAXIMIZED; case a.ALPHA_ONEONE: return _native.Engine.ALPHA_ONEONE; case a.ALPHA_PREMULTIPLIED: return _native.Engine.ALPHA_PREMULTIPLIED; case a.ALPHA_PREMULTIPLIED_PORTERDUFF: return _native.Engine.ALPHA_PREMULTIPLIED_PORTERDUFF; case a.ALPHA_INTERPOLATE: return _native.Engine.ALPHA_INTERPOLATE; case a.ALPHA_SCREENMODE: return _native.Engine.ALPHA_SCREENMODE; default: throw new Error("Unsupported alpha mode: ".concat(e, ".")) } }, t.prototype._getNativeAttribType = function (e) { switch (e) { case Hi.BYTE: return _native.Engine.ATTRIB_TYPE_INT8; case Hi.UNSIGNED_BYTE: return _native.Engine.ATTRIB_TYPE_UINT8; case Hi.SHORT: return _native.Engine.ATTRIB_TYPE_INT16; case Hi.UNSIGNED_SHORT: return _native.Engine.ATTRIB_TYPE_UINT16; case Hi.FLOAT: return _native.Engine.ATTRIB_TYPE_FLOAT; default: throw new Error("Unsupported attribute type: ".concat(e, ".")) } }, 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 }(In); zd._createNativeDataStream = function () { return _native.NativeDataStream.VALIDATION_ENABLED ? new Ip : new Jh }; var Wd, Hd, Xd, 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 = 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 }(Jh); !function (e) { e.LowPower = "low-power", e.HighPerformance = "high-performance" }(Wd || (Wd = {})), 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" }(Hd || (Hd = {})), function (e) { e.Unmapped = "unmapped", e.Pending = "pending", e.Mapped = "mapped" }(Xd || (Xd = {})), 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" }(jd || (jd = {})), function (e) { e[e.Read = 1] = "Read", e[e.Write = 2] = "Write" }(Yd || (Yd = {})), function (e) { e.E1d = "1d", e.E2d = "2d", e.E3d = "3d" }(Kd || (Kd = {})), 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" }(Qd || (Qd = {})), function (e) { e.E1d = "1d", e.E2d = "2d", e.E2dArray = "2d-array", e.Cube = "cube", e.CubeArray = "cube-array", e.E3d = "3d" }(qd || (qd = {})), function (e) { e.All = "all", e.StencilOnly = "stencil-only", e.DepthOnly = "depth-only" }(Zd || (Zd = {})), 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.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.Depth24UnormStencil8 = "depth24unorm-stencil8", e.Depth32FloatStencil8 = "depth32float-stencil8" }(Jd || (Jd = {})), function (e) { e.ClampToEdge = "clamp-to-edge", e.Repeat = "repeat", e.MirrorRepeat = "mirror-repeat" }($d || ($d = {})), function (e) { e.Nearest = "nearest", e.Linear = "linear" }(ep || (ep = {})), function (e) { e.Nearest = "nearest", e.Linear = "linear" }(tp || (tp = {})), 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" }(ip || (ip = {})), function (e) { e[e.Vertex = 1] = "Vertex", e[e.Fragment = 2] = "Fragment", e[e.Compute = 4] = "Compute" }(rp || (rp = {})), function (e) { e.Uniform = "uniform", e.Storage = "storage", e.ReadOnlyStorage = "read-only-storage" }(np || (np = {})), function (e) { e.Filtering = "filtering", e.NonFiltering = "non-filtering", e.Comparison = "comparison" }(op || (op = {})), function (e) { e.Float = "float", e.UnfilterableFloat = "unfilterable-float", e.Depth = "depth", e.Sint = "sint", e.Uint = "uint" }(ap || (ap = {})), function (e) { e.WriteOnly = "write-only" }(sp || (sp = {})), function (e) { e.Error = "error", e.Warning = "warning", e.Info = "info" }(lp || (lp = {})), function (e) { e.Validation = "validation", e.Internal = "internal" }(cp || (cp = {})), function (e) { e.Auto = "auto" }(up || (up = {})), function (e) { e.PointList = "point-list", e.LineList = "line-list", e.LineStrip = "line-strip", e.TriangleList = "triangle-list", e.TriangleStrip = "triangle-strip" }(hp || (hp = {})), function (e) { e.CCW = "ccw", e.CW = "cw" }(dp || (dp = {})), function (e) { e.None = "none", e.Front = "front", e.Back = "back" }(pp || (pp = {})), 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" }(fp || (fp = {})), 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" }(_p || (_p = {})), function (e) { e.Add = "add", e.Subtract = "subtract", e.ReverseSubtract = "reverse-subtract", e.Min = "min", e.Max = "max" }(mp || (mp = {})), 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" }(gp || (gp = {})), function (e) { e.Uint16 = "uint16", e.Uint32 = "uint32" }(vp || (vp = {})), 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" }(yp || (yp = {})), function (e) { e.Vertex = "vertex", e.Instance = "instance" }(bp || (bp = {})), function (e) { e.Beginning = "beginning", e.End = "end" }(Tp || (Tp = {})), function (e) { e.Beginning = "beginning", e.End = "end" }(Ep || (Ep = {})), function (e) { e.Load = "load", e.Clear = "clear" }(Sp || (Sp = {})), function (e) { e.Store = "store", e.Discard = "discard" }(xp || (xp = {})), function (e) { e.Occlusion = "occlusion", e.Timestamp = "timestamp" }(Ap || (Ap = {})), function (e) { e.Opaque = "opaque", e.Premultiplied = "premultiplied" }(Rp || (Rp = {})), function (e) { e.Unknown = "unknown", e.Destroyed = "destroyed" }(Cp || (Cp = {})), function (e) { e.Validation = "validation", e.OutOfMemory = "out-of-memory", e.Internal = "internal" }(Pp || (Pp = {})); var Mp = function () { function e() { this.shaderLanguage = nt.GLSL } 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 < this._webgpuProcessingContext.leftOverUniforms.length; o++)if (this._webgpuProcessingContext.leftOverUniforms[o].name === e) return; this._webgpuProcessingContext.leftOverUniforms.push({ name: e, type: t, length: n }) }, e.prototype._buildLeftOverUBO = function () { if (!this._webgpuProcessingContext.leftOverUniforms.length) return ""; var t = e.LeftOvertUBOName, i = this._webgpuProcessingContext.availableBuffers[t]; return i || (i = { binding: this._webgpuProcessingContext.getNextFreeUBOBinding() }, this._webgpuProcessingContext.availableBuffers[t] = i, this._addBufferBindingDescription(t, i, np.Uniform, !0), this._addBufferBindingDescription(t, i, np.Uniform, !1)), this._generateLeftOverUBOCode(t, i) }, e.prototype._collectBindingNames = function () { for (var e = 0; e < this._webgpuProcessingContext.bindGroupLayoutEntries.length; e++) { var t = this._webgpuProcessingContext.bindGroupLayoutEntries[e]; if (void 0 !== t) for (var i = 0; i < t.length; i++) { var r = this._webgpuProcessingContext.bindGroupLayoutEntries[e][i], n = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[e][r.binding].name, o = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[e][r.binding].nameInArrayOfTexture; r && (r.texture || r.externalTexture || r.storageTexture ? this._webgpuProcessingContext.textureNames.push(o) : r.sampler ? this._webgpuProcessingContext.samplerNames.push(n) : r.buffer && this._webgpuProcessingContext.bufferNames.push(n)) } else this._webgpuProcessingContext.bindGroupLayoutEntries[e] = [] } }, e.prototype._preCreateBindGroupEntries = function () { for (var e = this._webgpuProcessingContext.bindGroupEntries, t = 0; t < this._webgpuProcessingContext.bindGroupLayoutEntries.length; t++) { for (var i = this._webgpuProcessingContext.bindGroupLayoutEntries[t], r = [], n = 0; n < i.length; n++) { var o = this._webgpuProcessingContext.bindGroupLayoutEntries[t][n]; o.sampler || o.texture || o.storageTexture || o.externalTexture ? r.push({ binding: o.binding, resource: void 0 }) : o.buffer && r.push({ binding: o.binding, resource: { buffer: void 0, offset: 0, size: 0 } }) } e[t] = r } }, e.prototype._addTextureBindingDescription = function (e, t, i, r, n, o) { var a, s = (a = t.textures[i]).groupIndex, l = a.bindingIndex; if (this._webgpuProcessingContext.bindGroupLayoutEntries[s] || (this._webgpuProcessingContext.bindGroupLayoutEntries[s] = [], this._webgpuProcessingContext.bindGroupLayoutEntryInfo[s] = []), !this._webgpuProcessingContext.bindGroupLayoutEntryInfo[s][l]) { var c; c = null === r ? this._webgpuProcessingContext.bindGroupLayoutEntries[s].push({ binding: l, visibility: 0, externalTexture: {} }) : n ? this._webgpuProcessingContext.bindGroupLayoutEntries[s].push({ binding: l, visibility: 0, storageTexture: { access: sp.WriteOnly, format: n, viewDimension: r } }) : this._webgpuProcessingContext.bindGroupLayoutEntries[s].push({ binding: l, visibility: 0, texture: { sampleType: t.sampleType, viewDimension: r, multisampled: !1 } }); var u = t.isTextureArray ? e + i : e; this._webgpuProcessingContext.bindGroupLayoutEntryInfo[s][l] = { name: e, index: c - 1, nameInArrayOfTexture: u } } l = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[s][l].index, this._webgpuProcessingContext.bindGroupLayoutEntries[s][l].visibility |= o ? rp.Vertex : rp.Fragment }, e.prototype._addSamplerBindingDescription = function (e, t, i) { var r, n = (r = t.binding).groupIndex, o = r.bindingIndex; if (this._webgpuProcessingContext.bindGroupLayoutEntries[n] || (this._webgpuProcessingContext.bindGroupLayoutEntries[n] = [], this._webgpuProcessingContext.bindGroupLayoutEntryInfo[n] = []), !this._webgpuProcessingContext.bindGroupLayoutEntryInfo[n][o]) { var a = this._webgpuProcessingContext.bindGroupLayoutEntries[n].push({ binding: o, visibility: 0, sampler: { type: t.type } }); this._webgpuProcessingContext.bindGroupLayoutEntryInfo[n][o] = { name: e, index: a - 1 } } o = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[n][o].index, this._webgpuProcessingContext.bindGroupLayoutEntries[n][o].visibility |= i ? rp.Vertex : rp.Fragment }, e.prototype._addBufferBindingDescription = function (e, t, i, r) { var n, o = (n = t.binding).groupIndex, a = n.bindingIndex; if (this._webgpuProcessingContext.bindGroupLayoutEntries[o] || (this._webgpuProcessingContext.bindGroupLayoutEntries[o] = [], this._webgpuProcessingContext.bindGroupLayoutEntryInfo[o] = []), !this._webgpuProcessingContext.bindGroupLayoutEntryInfo[o][a]) { var s = this._webgpuProcessingContext.bindGroupLayoutEntries[o].push({ binding: a, visibility: 0, buffer: { type: i } }); this._webgpuProcessingContext.bindGroupLayoutEntryInfo[o][a] = { name: e, index: s - 1 } } a = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[o][a].index, this._webgpuProcessingContext.bindGroupLayoutEntries[o][a].visibility |= r ? rp.Vertex : rp.Fragment }, e.prototype._injectStartingAndEndingCode = function (e, t, i, r) { var n = e.indexOf(t); if (n < 0) return console.error('No "main" function found in shader code! Processing aborted.'), e; if (i) { for (; n++ < e.length && "{" != e.charAt(n);); if (n < e.length) { var o = e.substring(0, n + 1), a = e.substring(n + 1); e = o + i + a } } if (r) { var s = e.lastIndexOf("}"); e = e.substring(0, s), e += r + "\n}" } return e }, e.AutoSamplerSuffix = "Sampler", e.LeftOvertUBOName = "LeftOver", e.InternalsUBOName = "Internals", e.UniformSizes = { bool: 1, int: 1, float: 1, vec2: 2, ivec2: 2, uvec2: 2, vec3: 3, ivec3: 3, uvec3: 3, vec4: 4, ivec4: 4, uvec4: 4, mat2: 4, mat3: 12, mat4: 16, i32: 1, u32: 1, f32: 1, mat2x2: 4, mat3x3: 12, mat4x4: 16 }, e._SamplerFunctionByWebGLSamplerType = { sampler2D: "sampler2D", sampler2DArray: "sampler2DArray", sampler2DShadow: "sampler2DShadow", sampler2DArrayShadow: "sampler2DArrayShadow", samplerCube: "samplerCube", sampler3D: "sampler3D" }, e._TextureTypeByWebGLSamplerType = { sampler2D: "texture2D", sampler2DArray: "texture2DArray", sampler2DShadow: "texture2D", sampler2DArrayShadow: "texture2DArray", samplerCube: "textureCube", samplerCubeArray: "textureCubeArray", sampler3D: "texture3D" }, e._GpuTextureViewDimensionByWebGPUTextureType = { textureCube: qd.Cube, textureCubeArray: qd.CubeArray, texture2D: qd.E2d, texture2DArray: qd.E2dArray, texture3D: qd.E3d }, e._SamplerTypeByWebGLSamplerType = { sampler2DShadow: "samplerShadow", sampler2DArrayShadow: "samplerShadow" }, e._IsComparisonSamplerByWebGPUSamplerType = { samplerShadow: !0, samplerArrayShadow: !0, sampler: !1 }, e }(), Op = function () { function e(e, t) { this.bindGroupLayouts = {}, this._name = "unnamed", this.shaderProcessingContext = e, this._leftOverUniformsByName = {}, this.engine = t } return Object.defineProperty(e.prototype, "isAsync", { get: function () { return !1 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isReady", { get: function () { return !!this.stages }, enumerable: !1, configurable: !0 }), e.prototype._handlesSpectorRebuildCallback = function () { }, e.prototype._fillEffectInformation = function (e, t, i, r, n, o, a, s) { var l = this.engine; e._fragmentSourceCode = "", e._vertexSourceCode = ""; var c, u = this.shaderProcessingContext.availableTextures; for (c = 0; c < n.length; c++) { var h = n[c], d = u[n[c]]; null == d || null == d ? (n.splice(c, 1), c--) : o[h] = c } for (var p = 0, f = l.getAttributes(this, a); p < f.length; p++) { var _ = f[p]; s.push(_) } this.buildUniformLayout(); var m = [], g = []; for (c = 0; c < a.length; c++) { var v = s[c]; v >= 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 zi(this.engine, void 0, void 0, "leftOver-" + this._name); for (var e = 0, t = this.shaderProcessingContext.leftOverUniforms; e < t.length; e++) { var i = t[e], r = i.type.replace(/^(.*?)(<.*>)?$/, "$1"), n = Mp.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 }(), Dp = { mat2: 2, mat3: 3, mat4: 4, mat2x2: 2, mat3x3: 3, mat4x4: 4 }, Np = 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 = Dp[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 = Dp[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 }(), Fp = 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 = nt.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(Mp.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, 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: ap.Float }; for (var u = 0; u < (l || 1); ++u)c.textures.push(this._webgpuProcessingContext.getNextFreeUBOBinding()) } var h = null !== (n = Mp._SamplerTypeByWebGLSamplerType[a]) && void 0 !== n ? n : "sampler", d = !!Mp._IsComparisonSamplerByWebGPUSamplerType[h], p = d ? op.Comparison : op.Filtering, f = s + Mp.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 ? ap.Depth : "u" === m ? ap.Uint : "i" === m ? ap.Sint : ap.Float; c.sampleType = g; var v = l > 0, y = _.binding.groupIndex, b = _.binding.bindingIndex, T = Mp._SamplerFunctionByWebGLSamplerType[a], E = Mp._TextureTypeByWebGLSamplerType[a], S = Mp._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; u < l; ++u) { var A = c.textures[u].groupIndex, R = c.textures[u].bindingIndex; x.push("layout(set = ".concat(A, ", binding = ").concat(R, ") uniform ").concat(E, " ").concat(s, "Texture").concat(u, ";")), e += "".concat(u > 0 ? "\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 < l; ++u)this._addTextureBindingDescription(s, c, u, S, null, !t) } else this._addUniformToLeftOverUBO(s, a, i), e = "" } return e }, t.prototype.uniformBufferProcessor = function (e, t) { var i = /uniform\s+(\w+)/gm.exec(e); if (null !== i) { var r = i[1], n = this._webgpuProcessingContext.availableBuffers[r]; if (!n) { var o = Np.KnownUBOs[r]; n = { binding: o && -1 !== o.binding.groupIndex ? o.binding : this._webgpuProcessingContext.getNextFreeUBOBinding() }, this._webgpuProcessingContext.availableBuffers[r] = n } this._addBufferBindingDescription(r, n, np.Uniform, !t), e = e.replace("uniform", "layout(set = ".concat(n.binding.groupIndex, ", binding = ").concat(n.binding.bindingIndex, ") uniform")) } return e }, t.prototype.postProcessor = function (e, t, i, r, n) { var o = -1 !== e.search(/#extension.+GL_EXT_draw_buffers.+require/); if (e = (e = e.replace(/#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g, "")).replace(/texture2D\s*\(/g, "texture("), i) { var a = e.indexOf("gl_FragCoord") >= 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; r < n.length; r++) { var o = n[r]; o.length > 0 ? 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; i < this._textureArrayProcessing.length; ++i) { var r = this._textureArrayProcessing[i]; e = this._applyTextureArrayProcessing(e, r), t = this._applyTextureArrayProcessing(t, r) } for (i = 0; i < this._missingVaryings.length; ++i) { var n = this._missingVaryings[i]; n && n.length > 0 && (t = n + "\n" + t) } var o = this._buildLeftOverUBO(); return e = o + e, t = o + t, this._collectBindingNames(), this._preCreateBindGroupEntries(), this._preProcessors = null, { vertexCode: e, fragmentCode: t } }, t }(Mp); Ut.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"; Ut.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"; Ut.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"; Ut.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"; Ut.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"; Ut.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"; Ut.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"; Ut.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"; Ut.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"; Ut.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"; Ut.IncludesShadersStoreWGSL.meshUboDeclaration = "struct Mesh {world : mat4x4,\nvisibility : f32,};var mesh : Mesh;\n#define WORLD_UBO\n"; Ut.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"; Ut.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"; Ut.IncludesShadersStoreWGSL.morphTargetsVertexGlobal = "#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_TEXTURE\nvar vertexID : f32;\n#endif\n#endif\n"; Ut.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"; Ut.IncludesShadersStoreWGSL.sceneUboDeclaration = "struct Scene {viewProjection : mat4x4,\n#ifdef MULTIVIEW\nviewProjectionR : mat4x4,\n#endif \nview : mat4x4,\nprojection : mat4x4,\nvEyePosition : vec4,};var scene : Scene;\n"; var Lp, wp, Bp = { texture_1d: qd.E1d, texture_2d: qd.E2d, texture_2d_array: qd.E2dArray, texture_3d: qd.E3d, texture_cube: qd.Cube, texture_cube_array: qd.CubeArray, texture_multisampled_2d: qd.E2d, texture_depth_2d: qd.E2d, texture_depth_2d_array: qd.E2dArray, texture_depth_cube: qd.Cube, texture_depth_cube_array: qd.CubeArray, texture_depth_multisampled_2d: qd.E2d, texture_storage_1d: qd.E1d, texture_storage_2d: qd.E2d, texture_storage_2d_array: qd.E2dArray, texture_storage_3d: qd.E3d, texture_external: null }, Up = function (e) { function t() { var t = null !== e && e.apply(this, arguments) || this; return t.shaderLanguage = nt.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._attributesWGSL = [], this._varyingsWGSL = [], this._varyingNamesWGSL = [], this._stridedUniformArrays = [] }, t.prototype.preProcessShaderCode = function (e) { return "struct ".concat(Mp.InternalsUBOName, " {\n yFactor_: f32,\n textureOutputHeight_: f32,\n};\nvar ").concat("internals", " : ").concat(Mp.InternalsUBOName, ";\n") + Md(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, this._attributesWGSL.push("@location(".concat(o, ") ").concat(n, " : ").concat(r, ",")), 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: ap.Float }, h = h || 1; for (var p = 0; p < h; ++p)d.textures.push(this._webgpuProcessingContext.getNextFreeUBOBinding()) } this._webgpuProcessingContext.availableTextures[n] = d; var f = s.indexOf("depth") > 0, _ = Bp[s], m = f ? ap.Depth : "u32" === c ? ap.Uint : "i32" === c ? ap.Sint : ap.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 < h; ++p) { var g = d.textures[p], v = g.groupIndex, y = g.bindingIndex; 0 === p && (e = "@group(".concat(v, ") @binding(").concat(y, ") ").concat(e)), this._addTextureBindingDescription(n, d, p, _, u, !t) } } return e }, t.prototype.postProcessor = function (e) { return e }, t.prototype.finalizeShaders = function (e, t) { var i = t.indexOf("fragmentInputs.position") >= 0 ? "\n if (internals.yFactor_ == 1.) {\n fragmentInputs.position.y = internals.textureOutputHeight_ - fragmentInputs.position.y;\n }\n " : ""; e = this._processSamplers(e, !0), t = this._processSamplers(t, !1), e = this._processCustomBuffers(e, !0), t = this._processCustomBuffers(t, !1); var r = this._buildLeftOverUBO(); t = r + t, e = (e = r + e).replace(/#define /g, "//#define "), e = this._processStridedUniformArrays(e); var n = "struct VertexInputs {\n @builtin(vertex_index) vertexIndex : u32,\n @builtin(instance_index) instanceIndex : u32,\n"; this._attributesWGSL.length > 0 && (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, e = this._injectStartingAndEndingCode(e, "fn main", "\n vertexInputs = input;\n", " 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 a = "struct FragmentInputs {\n @builtin(position) position : vec4,\n @builtin(front_facing) frontFacing : bool,\n"; this._varyingsWGSL.length > 0 && (a += this._varyingsWGSL.join("\n")), a += "\n};\nvar fragmentInputs : FragmentInputs;\n"; for (var s = "struct FragmentOutputs {\n @location(0) color : vec4,\n", l = !1, c = 0; !(l || (c = t.indexOf("fragmentOutputs.fragDepth", c)) < 0);) { var u = c; for (l = !0; c > 1 && "\n" !== t.charAt(c);) { if ("/" === t.charAt(c) && "/" === t.charAt(c - 1)) { l = !1; break } c-- } c = u + 25 } l && (s += " @builtin(frag_depth) fragDepth: f32,\n"), t = a + (s += "};\nvar fragmentOutputs : FragmentOutputs;\n") + t; var h = " fragmentInputs = input;\n " + i; return t = this._injectStartingAndEndingCode(t, "fn main", h, " return fragmentOutputs;"), this._collectBindingNames(), this._preCreateBindGroupEntries(), { 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 < o.length; n++) { var a = o[n], s = a.type.replace(/^(.*?)(<.*>)?$/, "$1"), l = Mp.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(Mp.AutoSamplerSuffix) === n.length - Mp.AutoSamplerSuffix.length ? n.substring(0, n.indexOf(Mp.AutoSamplerSuffix)) : null, s = "sampler_comparison" === o ? op.Comparison : op.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 ? Np.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 ? np.Storage : "storage" === n ? np.ReadOnlyStorage : np.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 < i.length; t++) { var r = i[t]; e = e.replace(new RegExp("".concat(r, "\\s*\\[(.*)\\]"), "g"), "".concat(r, "[$1].el")) } return e }, t }(Mp), Vp = function () { function e(e) { void 0 === e && (e = null), this.format = Jd.RGBA8Unorm, this.textureUsages = 0, this.textureAdditionalUsages = 0, this._webgpuTexture = e, this._webgpuMSAATexture = null, this.view = null, this.viewForWriting = null } return Object.defineProperty(e.prototype, "underlyingResource", { get: function () { return this._webgpuTexture }, enumerable: !1, configurable: !0 }), e.prototype.getMSAATexture = function (e) { var t, i; return void 0 === e && (e = 0), null !== (i = null === (t = this._webgpuMSAATexture) || void 0 === t ? void 0 : t[e]) && void 0 !== i ? i : null }, e.prototype.setMSAATexture = function (e, t) { void 0 === t && (t = -1), this._webgpuMSAATexture || (this._webgpuMSAATexture = []), -1 === t && (t = this._webgpuMSAATexture.length), this._webgpuMSAATexture[t] = e }, e.prototype.releaseMSAATexture = function () { if (this._webgpuMSAATexture) { for (var e = 0, t = this._webgpuMSAATexture; e < t.length; e++) { var i = t[e]; null == i || i.destroy() } this._webgpuMSAATexture = null } }, e.prototype.set = function (e) { this._webgpuTexture = e }, e.prototype.setUsage = function (e, t, i, r, n) { this.createView({ format: this.format, dimension: i ? qd.Cube : qd.E2d, mipLevelCount: t ? h.ILog2(Math.max(r, n)) + 1 : 1, baseArrayLayer: 0, baseMipLevel: 0, arrayLayerCount: i ? 6 : 1, aspect: Zd.All }) }, e.prototype.createView = function (e, t) { if (void 0 === t && (t = !1), this.view = this._webgpuTexture.createView(e), t && e) { var i = e.mipLevelCount; e.mipLevelCount = 1, this.viewForWriting = this._webgpuTexture.createView(e), e.mipLevelCount = i } }, e.prototype.reset = function () { this._webgpuTexture = null, this._webgpuMSAATexture = null, this.view = null, this.viewForWriting = null }, e.prototype.release = function () { var e, t; null === (e = this._webgpuTexture) || void 0 === e || e.destroy(), this.releaseMSAATexture(), null === (t = this._copyInvertYTempTexture) || void 0 === t || t.destroy(), this.reset() }, e }(), kp = "\n #extension GL_EXT_samplerless_texture_functions : enable\n\n const vec2 pos[4] = vec2[4](vec2(-1.0f, 1.0f), vec2(1.0f, 1.0f), vec2(-1.0f, -1.0f), vec2(1.0f, -1.0f));\n const vec2 tex[4] = vec2[4](vec2(0.0f, 0.0f), vec2(1.0f, 0.0f), vec2(0.0f, 1.0f), vec2(1.0f, 1.0f));\n\n layout(set = 0, binding = 0) uniform texture2D img;\n\n #ifdef INVERTY\n layout(location = 0) out flat ivec2 vTextureSize;\n #endif\n\n void main() {\n #ifdef INVERTY\n vTextureSize = textureSize(img, 0);\n #endif\n gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n }\n ", Gp = kp; !function (e) { e[e.MipMap = 0] = "MipMap", e[e.InvertYPremultiplyAlpha = 1] = "InvertYPremultiplyAlpha", e[e.Clear = 2] = "Clear", e[e.InvertYPremultiplyAlphaWithOfst = 3] = "InvertYPremultiplyAlphaWithOfst" }(Lp || (Lp = {})), function (e) { e[e.DontInvertY = 0] = "DontInvertY", e[e.InvertY = 1] = "InvertY" }(wp || (wp = {})); var zp, Wp = [{ vertex: "\n const vec2 pos[4] = vec2[4](vec2(-1.0f, 1.0f), vec2(1.0f, 1.0f), vec2(-1.0f, -1.0f), vec2(1.0f, -1.0f));\n const vec2 tex[4] = vec2[4](vec2(0.0f, 0.0f), vec2(1.0f, 0.0f), vec2(0.0f, 1.0f), vec2(1.0f, 1.0f));\n\n layout(location = 0) out vec2 vTex;\n\n void main() {\n vTex = tex[gl_VertexIndex];\n gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n }\n ", fragment: "\n layout(set = 0, binding = 0) uniform sampler imgSampler;\n layout(set = 0, binding = 1) uniform texture2D img;\n\n layout(location = 0) in vec2 vTex;\n layout(location = 0) out vec4 outColor;\n\n void main() {\n outColor = texture(sampler2D(img, imgSampler), vTex);\n }\n " }, { vertex: kp, fragment: "\n #extension GL_EXT_samplerless_texture_functions : enable\n\n layout(set = 0, binding = 0) uniform texture2D img;\n\n #ifdef INVERTY\n layout(location = 0) in flat ivec2 vTextureSize;\n #endif\n layout(location = 0) out vec4 outColor;\n\n void main() {\n #ifdef INVERTY\n vec4 color = texelFetch(img, ivec2(gl_FragCoord.x, vTextureSize.y - gl_FragCoord.y), 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 " }, { vertex: "\n const vec2 pos[4] = vec2[4](vec2(-1.0f, 1.0f), vec2(1.0f, 1.0f), vec2(-1.0f, -1.0f), vec2(1.0f, -1.0f));\n\n void main() {\n gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n }\n ", fragment: "\n layout(set = 0, binding = 0) uniform Uniforms {\n uniform vec4 color;\n };\n\n layout(location = 0) out vec4 outColor;\n\n void main() {\n outColor = color;\n }\n " }, { vertex: Gp, fragment: "\n #extension GL_EXT_samplerless_texture_functions : enable\n\n layout(set = 0, binding = 0) uniform texture2D img;\n layout(set = 0, binding = 1) uniform Params {\n float ofstX;\n float ofstY;\n float width;\n float height;\n };\n\n #ifdef INVERTY\n layout(location = 0) in flat ivec2 vTextureSize;\n #endif\n layout(location = 0) out vec4 outColor;\n\n void main() {\n if (gl_FragCoord.x < ofstX || gl_FragCoord.x >= 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 " }], Hp = { "": 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, rgb10a2unorm: 22, rg32uint: 23, rg32sint: 24, rg32float: 25, rgba16uint: 26, rgba16sint: 27, rgba16float: 28, rgba32uint: 29, rgba32sint: 30, rgba32float: 31, stencil8: 32, depth16unorm: 33, depth24plus: 34, "depth24plus-stencil8": 35, depth32float: 36, "depth32float-stencil8": 37 }, Xp = 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(Hd.RG11B10UFloatRenderable)) { var o = Object.keys(Hp); Hp[Jd.RG11B10UFloat] = Hp[o[o.length - 1]] + 1 } this._mipmapSampler = e.createSampler({ minFilter: ep.Linear }), this._videoSampler = e.createSampler({ minFilter: ep.Linear }), this._ubCopyWithOfst = this._bufferManager.createBuffer(16, jd.Uniform | jd.CopyDst).underlyingResource, this._getPipeline(Jd.RGBA8Unorm), this._getVideoPipeline(Jd.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 = Lp.MipMap); var r = t === Lp.MipMap ? 1 : t === Lp.InvertYPremultiplyAlpha ? ((i.invertY ? 1 : 0) << 1) + ((i.premultiplyAlpha ? 1 : 0) << 2) : t === Lp.Clear ? 8 : t === Lp.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 !== Lp.InvertYPremultiplyAlpha && t !== Lp.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 + Wp[t].vertex, "vertex"), l = this._glslang.compileGLSL(o + Wp[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: up.Auto, vertex: { module: a[0], entryPoint: "main" }, fragment: { module: a[1], entryPoint: "main", targets: [{ format: e }] }, primitive: { topology: hp.TriangleStrip, stripIndexFormat: vp.Uint16 } }); n = this._pipelines[e][r] = [h, h.getBindGroupLayout(0)] } return n }, e.prototype._getVideoPipeline = function (e, t) { void 0 === t && (t = wp.DontInvertY); var i = t === wp.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: up.Auto, vertex: { module: n[0], entryPoint: "main" }, fragment: { module: n[1], entryPoint: "main", targets: [{ format: e }] }, primitive: { topology: hp.TriangleStrip, stripIndexFormat: vp.Uint16 } }); r = this._videoPipelines[e][i] = [s, s.getBindGroupLayout(0)] } return r }, e._GetTextureTypeFromFormat = function (e) { switch (e) { case Jd.R8Unorm: case Jd.R8Snorm: case Jd.R8Uint: case Jd.R8Sint: case Jd.RG8Unorm: case Jd.RG8Snorm: case Jd.RG8Uint: case Jd.RG8Sint: case Jd.RGBA8Unorm: case Jd.RGBA8UnormSRGB: case Jd.RGBA8Snorm: case Jd.RGBA8Uint: case Jd.RGBA8Sint: case Jd.BGRA8Unorm: case Jd.BGRA8UnormSRGB: case Jd.RGB10A2Unorm: case Jd.RGB9E5UFloat: case Jd.RG11B10UFloat: case Jd.Depth24UnormStencil8: case Jd.Depth32FloatStencil8: case Jd.BC7RGBAUnorm: case Jd.BC7RGBAUnormSRGB: case Jd.BC6HRGBUFloat: case Jd.BC6HRGBFloat: case Jd.BC5RGUnorm: case Jd.BC5RGSnorm: case Jd.BC3RGBAUnorm: case Jd.BC3RGBAUnormSRGB: case Jd.BC2RGBAUnorm: case Jd.BC2RGBAUnormSRGB: case Jd.BC4RUnorm: case Jd.BC4RSnorm: case Jd.BC1RGBAUnorm: case Jd.BC1RGBAUnormSRGB: case Jd.ETC2RGB8Unorm: case Jd.ETC2RGB8UnormSRGB: case Jd.ETC2RGB8A1Unorm: case Jd.ETC2RGB8A1UnormSRGB: case Jd.ETC2RGBA8Unorm: case Jd.ETC2RGBA8UnormSRGB: case Jd.EACR11Unorm: case Jd.EACR11Snorm: case Jd.EACRG11Unorm: case Jd.EACRG11Snorm: case Jd.ASTC4x4Unorm: case Jd.ASTC4x4UnormSRGB: case Jd.ASTC5x4Unorm: case Jd.ASTC5x4UnormSRGB: case Jd.ASTC5x5Unorm: case Jd.ASTC5x5UnormSRGB: case Jd.ASTC6x5Unorm: case Jd.ASTC6x5UnormSRGB: case Jd.ASTC6x6Unorm: case Jd.ASTC6x6UnormSRGB: case Jd.ASTC8x5Unorm: case Jd.ASTC8x5UnormSRGB: case Jd.ASTC8x6Unorm: case Jd.ASTC8x6UnormSRGB: case Jd.ASTC8x8Unorm: case Jd.ASTC8x8UnormSRGB: case Jd.ASTC10x5Unorm: case Jd.ASTC10x5UnormSRGB: case Jd.ASTC10x6Unorm: case Jd.ASTC10x6UnormSRGB: case Jd.ASTC10x8Unorm: case Jd.ASTC10x8UnormSRGB: case Jd.ASTC10x10Unorm: case Jd.ASTC10x10UnormSRGB: case Jd.ASTC12x10Unorm: case Jd.ASTC12x10UnormSRGB: case Jd.ASTC12x12Unorm: case Jd.ASTC12x12UnormSRGB: return a.TEXTURETYPE_UNSIGNED_BYTE; case Jd.R16Uint: case Jd.R16Sint: case Jd.RG16Uint: case Jd.RG16Sint: case Jd.RGBA16Uint: case Jd.RGBA16Sint: case Jd.Depth16Unorm: return a.TEXTURETYPE_UNSIGNED_SHORT; case Jd.R16Float: case Jd.RG16Float: case Jd.RGBA16Float: return a.TEXTURETYPE_HALF_FLOAT; case Jd.R32Uint: case Jd.R32Sint: case Jd.RG32Uint: case Jd.RG32Sint: case Jd.RGBA32Uint: case Jd.RGBA32Sint: return a.TEXTURETYPE_UNSIGNED_INTEGER; case Jd.R32Float: case Jd.RG32Float: case Jd.RGBA32Float: case Jd.Depth32Float: return a.TEXTURETYPE_FLOAT; case Jd.Stencil8: throw "No fixed size for Stencil8 format!"; case Jd.Depth24Plus: throw "No fixed size for Depth24Plus format!"; case Jd.Depth24PlusStencil8: throw "No fixed size for Depth24PlusStencil8 format!" }return a.TEXTURETYPE_UNSIGNED_BYTE }, e._GetBlockInformationFromFormat = function (e) { switch (e) { case Jd.R8Unorm: case Jd.R8Snorm: case Jd.R8Uint: case Jd.R8Sint: return { width: 1, height: 1, length: 1 }; case Jd.R16Uint: case Jd.R16Sint: case Jd.R16Float: case Jd.RG8Unorm: case Jd.RG8Snorm: case Jd.RG8Uint: case Jd.RG8Sint: return { width: 1, height: 1, length: 2 }; case Jd.R32Uint: case Jd.R32Sint: case Jd.R32Float: case Jd.RG16Uint: case Jd.RG16Sint: case Jd.RG16Float: case Jd.RGBA8Unorm: case Jd.RGBA8UnormSRGB: case Jd.RGBA8Snorm: case Jd.RGBA8Uint: case Jd.RGBA8Sint: case Jd.BGRA8Unorm: case Jd.BGRA8UnormSRGB: case Jd.RGB9E5UFloat: case Jd.RGB10A2Unorm: case Jd.RG11B10UFloat: return { width: 1, height: 1, length: 4 }; case Jd.RG32Uint: case Jd.RG32Sint: case Jd.RG32Float: case Jd.RGBA16Uint: case Jd.RGBA16Sint: case Jd.RGBA16Float: return { width: 1, height: 1, length: 8 }; case Jd.RGBA32Uint: case Jd.RGBA32Sint: case Jd.RGBA32Float: return { width: 1, height: 1, length: 16 }; case Jd.Stencil8: throw "No fixed size for Stencil8 format!"; case Jd.Depth16Unorm: return { width: 1, height: 1, length: 2 }; case Jd.Depth24Plus: throw "No fixed size for Depth24Plus format!"; case Jd.Depth24PlusStencil8: throw "No fixed size for Depth24PlusStencil8 format!"; case Jd.Depth32Float: case Jd.Depth24UnormStencil8: return { width: 1, height: 1, length: 4 }; case Jd.Depth32FloatStencil8: return { width: 1, height: 1, length: 5 }; case Jd.BC7RGBAUnorm: case Jd.BC7RGBAUnormSRGB: case Jd.BC6HRGBUFloat: case Jd.BC6HRGBFloat: case Jd.BC5RGUnorm: case Jd.BC5RGSnorm: case Jd.BC3RGBAUnorm: case Jd.BC3RGBAUnormSRGB: case Jd.BC2RGBAUnorm: case Jd.BC2RGBAUnormSRGB: return { width: 4, height: 4, length: 16 }; case Jd.BC4RUnorm: case Jd.BC4RSnorm: case Jd.BC1RGBAUnorm: case Jd.BC1RGBAUnormSRGB: case Jd.ETC2RGB8Unorm: case Jd.ETC2RGB8UnormSRGB: case Jd.ETC2RGB8A1Unorm: case Jd.ETC2RGB8A1UnormSRGB: case Jd.EACR11Unorm: case Jd.EACR11Snorm: return { width: 4, height: 4, length: 8 }; case Jd.ETC2RGBA8Unorm: case Jd.ETC2RGBA8UnormSRGB: case Jd.EACRG11Unorm: case Jd.EACRG11Snorm: case Jd.ASTC4x4Unorm: case Jd.ASTC4x4UnormSRGB: return { width: 4, height: 4, length: 16 }; case Jd.ASTC5x4Unorm: case Jd.ASTC5x4UnormSRGB: return { width: 5, height: 4, length: 16 }; case Jd.ASTC5x5Unorm: case Jd.ASTC5x5UnormSRGB: return { width: 5, height: 5, length: 16 }; case Jd.ASTC6x5Unorm: case Jd.ASTC6x5UnormSRGB: return { width: 6, height: 5, length: 16 }; case Jd.ASTC6x6Unorm: case Jd.ASTC6x6UnormSRGB: return { width: 6, height: 6, length: 16 }; case Jd.ASTC8x5Unorm: case Jd.ASTC8x5UnormSRGB: return { width: 8, height: 5, length: 16 }; case Jd.ASTC8x6Unorm: case Jd.ASTC8x6UnormSRGB: return { width: 8, height: 6, length: 16 }; case Jd.ASTC8x8Unorm: case Jd.ASTC8x8UnormSRGB: return { width: 8, height: 8, length: 16 }; case Jd.ASTC10x5Unorm: case Jd.ASTC10x5UnormSRGB: return { width: 10, height: 5, length: 16 }; case Jd.ASTC10x6Unorm: case Jd.ASTC10x6UnormSRGB: return { width: 10, height: 6, length: 16 }; case Jd.ASTC10x8Unorm: case Jd.ASTC10x8UnormSRGB: return { width: 10, height: 8, length: 16 }; case Jd.ASTC10x10Unorm: case Jd.ASTC10x10UnormSRGB: return { width: 10, height: 10, length: 16 }; case Jd.ASTC12x10Unorm: case Jd.ASTC12x10UnormSRGB: return { width: 12, height: 10, length: 16 }; case Jd.ASTC12x12Unorm: case Jd.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 Jd.BC7RGBAUnormSRGB: case Jd.BC7RGBAUnorm: case Jd.BC6HRGBFloat: case Jd.BC6HRGBUFloat: case Jd.BC5RGSnorm: case Jd.BC5RGUnorm: case Jd.BC4RSnorm: case Jd.BC4RUnorm: case Jd.BC3RGBAUnormSRGB: case Jd.BC3RGBAUnorm: case Jd.BC2RGBAUnormSRGB: case Jd.BC2RGBAUnorm: case Jd.BC1RGBAUnormSRGB: case Jd.BC1RGBAUnorm: case Jd.ETC2RGB8Unorm: case Jd.ETC2RGB8UnormSRGB: case Jd.ETC2RGB8A1Unorm: case Jd.ETC2RGB8A1UnormSRGB: case Jd.ETC2RGBA8Unorm: case Jd.ETC2RGBA8UnormSRGB: case Jd.EACR11Unorm: case Jd.EACR11Snorm: case Jd.EACRG11Unorm: case Jd.EACRG11Snorm: case Jd.ASTC4x4Unorm: case Jd.ASTC4x4UnormSRGB: case Jd.ASTC5x4Unorm: case Jd.ASTC5x4UnormSRGB: case Jd.ASTC5x5Unorm: case Jd.ASTC5x5UnormSRGB: case Jd.ASTC6x5Unorm: case Jd.ASTC6x5UnormSRGB: case Jd.ASTC6x6Unorm: case Jd.ASTC6x6UnormSRGB: case Jd.ASTC8x5Unorm: case Jd.ASTC8x5UnormSRGB: case Jd.ASTC8x6Unorm: case Jd.ASTC8x6UnormSRGB: case Jd.ASTC8x8Unorm: case Jd.ASTC8x8UnormSRGB: case Jd.ASTC10x5Unorm: case Jd.ASTC10x5UnormSRGB: case Jd.ASTC10x6Unorm: case Jd.ASTC10x6UnormSRGB: case Jd.ASTC10x8Unorm: case Jd.ASTC10x8UnormSRGB: case Jd.ASTC10x10Unorm: case Jd.ASTC10x10UnormSRGB: case Jd.ASTC12x10Unorm: case Jd.ASTC12x10UnormSRGB: case Jd.ASTC12x12Unorm: case Jd.ASTC12x12UnormSRGB: return !0 }return !1 }, e.GetWebGPUTextureFormat = function (e, t, i) { switch (void 0 === i && (i = !1), t) { case a.TEXTUREFORMAT_DEPTH16: return Jd.Depth16Unorm; case a.TEXTUREFORMAT_DEPTH24: return Jd.Depth24Plus; case a.TEXTUREFORMAT_DEPTH24_STENCIL8: return Jd.Depth24PlusStencil8; case a.TEXTUREFORMAT_DEPTH32_FLOAT: return Jd.Depth32Float; case a.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8: return Jd.Depth24UnormStencil8; case a.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8: return Jd.Depth32FloatStencil8; case a.TEXTUREFORMAT_STENCIL8: return Jd.Stencil8; case a.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM: return i ? Jd.BC7RGBAUnormSRGB : Jd.BC7RGBAUnorm; case a.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: return Jd.BC6HRGBUFloat; case a.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: return Jd.BC6HRGBFloat; case a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5: return i ? Jd.BC3RGBAUnormSRGB : Jd.BC3RGBAUnorm; case a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3: return i ? Jd.BC2RGBAUnormSRGB : Jd.BC2RGBAUnorm; case a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1: case a.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1: return i ? Jd.BC1RGBAUnormSRGB : Jd.BC1RGBAUnorm; case a.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4: return i ? Jd.ASTC4x4UnormSRGB : Jd.ASTC4x4Unorm; case a.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL: case a.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2: return i ? Jd.ETC2RGB8UnormSRGB : Jd.ETC2RGB8Unorm; case a.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC: return i ? Jd.ETC2RGBA8UnormSRGB : Jd.ETC2RGBA8Unorm }switch (e) { case a.TEXTURETYPE_BYTE: switch (t) { case a.TEXTUREFORMAT_RED: return Jd.R8Snorm; case a.TEXTUREFORMAT_RG: return Jd.RG8Snorm; case a.TEXTUREFORMAT_RGB: throw "RGB format not supported in WebGPU"; case a.TEXTUREFORMAT_RED_INTEGER: return Jd.R8Sint; case a.TEXTUREFORMAT_RG_INTEGER: return Jd.RG8Sint; case a.TEXTUREFORMAT_RGB_INTEGER: throw "RGB_INTEGER format not supported in WebGPU"; case a.TEXTUREFORMAT_RGBA_INTEGER: return Jd.RGBA8Sint; default: return Jd.RGBA8Snorm }case a.TEXTURETYPE_UNSIGNED_BYTE: switch (t) { case a.TEXTUREFORMAT_RED: return Jd.R8Unorm; case a.TEXTUREFORMAT_RG: return Jd.RG8Unorm; case a.TEXTUREFORMAT_RGB: throw "TEXTUREFORMAT_RGB format not supported in WebGPU"; case a.TEXTUREFORMAT_RGBA: return i ? Jd.RGBA8UnormSRGB : Jd.RGBA8Unorm; case a.TEXTUREFORMAT_BGRA: return i ? Jd.BGRA8UnormSRGB : Jd.BGRA8Unorm; case a.TEXTUREFORMAT_RED_INTEGER: return Jd.R8Uint; case a.TEXTUREFORMAT_RG_INTEGER: return Jd.RG8Uint; case a.TEXTUREFORMAT_RGB_INTEGER: throw "RGB_INTEGER format not supported in WebGPU"; case a.TEXTUREFORMAT_RGBA_INTEGER: return Jd.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 Jd.RGBA8Unorm }case a.TEXTURETYPE_SHORT: switch (t) { case a.TEXTUREFORMAT_RED_INTEGER: return Jd.R16Sint; case a.TEXTUREFORMAT_RG_INTEGER: return Jd.RG16Sint; case a.TEXTUREFORMAT_RGB_INTEGER: throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU"; case a.TEXTUREFORMAT_RGBA_INTEGER: default: return Jd.RGBA16Sint }case a.TEXTURETYPE_UNSIGNED_SHORT: switch (t) { case a.TEXTUREFORMAT_RED_INTEGER: return Jd.R16Uint; case a.TEXTUREFORMAT_RG_INTEGER: return Jd.RG16Uint; case a.TEXTUREFORMAT_RGB_INTEGER: throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU"; case a.TEXTUREFORMAT_RGBA_INTEGER: default: return Jd.RGBA16Uint }case a.TEXTURETYPE_INT: switch (t) { case a.TEXTUREFORMAT_RED_INTEGER: return Jd.R32Sint; case a.TEXTUREFORMAT_RG_INTEGER: return Jd.RG32Sint; case a.TEXTUREFORMAT_RGB_INTEGER: throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU"; case a.TEXTUREFORMAT_RGBA_INTEGER: default: return Jd.RGBA32Sint }case a.TEXTURETYPE_UNSIGNED_INTEGER: switch (t) { case a.TEXTUREFORMAT_RED_INTEGER: return Jd.R32Uint; case a.TEXTUREFORMAT_RG_INTEGER: return Jd.RG32Uint; case a.TEXTUREFORMAT_RGB_INTEGER: throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU"; case a.TEXTUREFORMAT_RGBA_INTEGER: default: return Jd.RGBA32Uint }case a.TEXTURETYPE_FLOAT: switch (t) { case a.TEXTUREFORMAT_RED: return Jd.R32Float; case a.TEXTUREFORMAT_RG: return Jd.RG32Float; case a.TEXTUREFORMAT_RGB: throw "TEXTUREFORMAT_RGB format not supported in WebGPU"; case a.TEXTUREFORMAT_RGBA: default: return Jd.RGBA32Float }case a.TEXTURETYPE_HALF_FLOAT: switch (t) { case a.TEXTUREFORMAT_RED: return Jd.R16Float; case a.TEXTUREFORMAT_RG: return Jd.RG16Float; case a.TEXTUREFORMAT_RGB: throw "TEXTUREFORMAT_RGB format not supported in WebGPU"; case a.TEXTUREFORMAT_RGBA: default: return Jd.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 Jd.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 Jd.RG11B10UFloat }case a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: switch (t) { case a.TEXTUREFORMAT_RGBA: return Jd.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 Jd.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 Jd.RGB10A2Unorm; case a.TEXTUREFORMAT_RGBA_INTEGER: throw "TEXTUREFORMAT_RGBA_INTEGER format not supported in WebGPU when type is TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV"; default: return Jd.RGB10A2Unorm } }return i ? Jd.RGBA8UnormSRGB : Jd.RGBA8Unorm }, e.GetNumChannelsFromWebGPUTextureFormat = function (e) { switch (e) { case Jd.R8Unorm: case Jd.R8Snorm: case Jd.R8Uint: case Jd.R8Sint: case Jd.BC4RUnorm: case Jd.BC4RSnorm: case Jd.R16Uint: case Jd.R16Sint: case Jd.Depth16Unorm: case Jd.R16Float: case Jd.R32Uint: case Jd.R32Sint: case Jd.R32Float: case Jd.Depth32Float: case Jd.Stencil8: case Jd.Depth24Plus: case Jd.EACR11Unorm: case Jd.EACR11Snorm: return 1; case Jd.RG8Unorm: case Jd.RG8Snorm: case Jd.RG8Uint: case Jd.RG8Sint: case Jd.Depth24UnormStencil8: case Jd.Depth32FloatStencil8: case Jd.BC5RGUnorm: case Jd.BC5RGSnorm: case Jd.RG16Uint: case Jd.RG16Sint: case Jd.RG16Float: case Jd.RG32Uint: case Jd.RG32Sint: case Jd.RG32Float: case Jd.Depth24PlusStencil8: case Jd.EACRG11Unorm: case Jd.EACRG11Snorm: return 2; case Jd.RGB9E5UFloat: case Jd.RG11B10UFloat: case Jd.BC6HRGBUFloat: case Jd.BC6HRGBFloat: case Jd.ETC2RGB8Unorm: case Jd.ETC2RGB8UnormSRGB: return 3; case Jd.RGBA8Unorm: case Jd.RGBA8UnormSRGB: case Jd.RGBA8Snorm: case Jd.RGBA8Uint: case Jd.RGBA8Sint: case Jd.BGRA8Unorm: case Jd.BGRA8UnormSRGB: case Jd.RGB10A2Unorm: case Jd.BC7RGBAUnorm: case Jd.BC7RGBAUnormSRGB: case Jd.BC3RGBAUnorm: case Jd.BC3RGBAUnormSRGB: case Jd.BC2RGBAUnorm: case Jd.BC2RGBAUnormSRGB: case Jd.BC1RGBAUnorm: case Jd.BC1RGBAUnormSRGB: case Jd.RGBA16Uint: case Jd.RGBA16Sint: case Jd.RGBA16Float: case Jd.RGBA32Uint: case Jd.RGBA32Sint: case Jd.RGBA32Float: case Jd.ETC2RGB8A1Unorm: case Jd.ETC2RGB8A1UnormSRGB: case Jd.ETC2RGBA8Unorm: case Jd.ETC2RGBA8UnormSRGB: case Jd.ASTC4x4Unorm: case Jd.ASTC4x4UnormSRGB: case Jd.ASTC5x4Unorm: case Jd.ASTC5x4UnormSRGB: case Jd.ASTC5x5Unorm: case Jd.ASTC5x5UnormSRGB: case Jd.ASTC6x5Unorm: case Jd.ASTC6x5UnormSRGB: case Jd.ASTC6x6Unorm: case Jd.ASTC6x6UnormSRGB: case Jd.ASTC8x5Unorm: case Jd.ASTC8x5UnormSRGB: case Jd.ASTC8x6Unorm: case Jd.ASTC8x6UnormSRGB: case Jd.ASTC8x8Unorm: case Jd.ASTC8x8UnormSRGB: case Jd.ASTC10x5Unorm: case Jd.ASTC10x5UnormSRGB: case Jd.ASTC10x6Unorm: case Jd.ASTC10x6UnormSRGB: case Jd.ASTC10x8Unorm: case Jd.ASTC10x8UnormSRGB: case Jd.ASTC10x10Unorm: case Jd.ASTC10x10UnormSRGB: case Jd.ASTC12x10Unorm: case Jd.ASTC12x10UnormSRGB: case Jd.ASTC12x12Unorm: case Jd.ASTC12x12UnormSRGB: return 4 }throw "Unknown format ".concat(e, "!") }, e.HasStencilAspect = function (e) { switch (e) { case Jd.Stencil8: case Jd.Depth24UnormStencil8: case Jd.Depth32FloatStencil8: case Jd.Depth24PlusStencil8: return !0 }return !1 }, e.HasDepthAndStencilAspects = function (e) { switch (e) { case Jd.Depth24UnormStencil8: case Jd.Depth32FloatStencil8: case Jd.Depth24PlusStencil8: return !0 }return !1 }, e.GetDepthFormatOnly = function (e) { switch (e) { case Jd.Depth16Unorm: return Jd.Depth16Unorm; case Jd.Depth24Plus: case Jd.Depth24PlusStencil8: case Jd.Depth24UnormStencil8: return Jd.Depth24Plus; case Jd.Depth32Float: case Jd.Depth32FloatStencil8: return Jd.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 ? wp.InvertY : wp.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: qd.E2d, mipLevelCount: 1, baseArrayLayer: 0, baseMipLevel: 0, arrayLayerCount: 1, aspect: Zd.All }), loadOp: Sp.Load, storeOp: xp.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 ? Lp.InvertYPremultiplyAlphaWithOfst : Lp.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, Qd.CopySrc | Qd.RenderAttachment | Qd.TextureBinding, void 0, "TempTextureForCopyWithInvertY"), M = null !== (y = null == P ? void 0 : P._copyInvertYRenderPassDescr) && void 0 !== y ? y : { colorAttachments: [{ view: I.createView({ format: n, dimension: qd.E2d, baseMipLevel: 0, mipLevelCount: 1, arrayLayerCount: 1, baseArrayLayer: 0 }), loadOp: Sp.Load, storeOp: xp.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: qd.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, Lp.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 = Jd.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 }, _ = Hp[s] ? Qd.RenderAttachment : 0, m = e.IsCompressedFormat(s), g = i ? e.ComputeNumMipmapLevels(t.width, t.height) : 1, v = u >= 0 ? u : Qd.CopySrc | Qd.CopyDst | Qd.TextureBinding; h |= i && !m ? Qd.CopySrc | _ : 0, m || a || (h |= _ | Qd.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 ? Kd.E3d : Kd.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 = Jd.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 = Hp[a] ? Qd.RenderAttachment : 0, _ = e.IsCompressedFormat(a), m = i ? e.ComputeNumMipmapLevels(d, p) : 1, g = c >= 0 ? c : Qd.CopySrc | Qd.CopyDst | Qd.TextureBinding; u |= i && !_ ? Qd.CopySrc | f : 0, _ || (u |= f | Qd.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: Kd.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; b < r; ++b) { var T = null !== (c = null === (l = null == y ? void 0 : y._mipmapGenRenderPassDescr[n]) || void 0 === l ? void 0 : l[b - 1]) && void 0 !== c ? c : { colorAttachments: [{ view: f.createView({ format: i, dimension: qd.E2d, baseMipLevel: b, mipLevelCount: 1, arrayLayerCount: 1, baseArrayLayer: n }), loadOp: Sp.Load, storeOp: xp.Store }] }; y && (y._mipmapGenRenderPassDescr[n] = y._mipmapGenRenderPassDescr[n] || [], y._mipmapGenRenderPassDescr[n][b - 1] = T); var E = o.beginRenderPass(T), S = null !== (h = null === (u = null == y ? void 0 : y._mipmapGenBindGroup[n]) || void 0 === u ? void 0 : u[b - 1]) && void 0 !== h ? h : this._device.createBindGroup({ layout: v, entries: [{ binding: 0, resource: this._mipmapSampler }, { binding: 1, resource: f.createView({ format: i, dimension: qd.E2d, baseMipLevel: b - 1, mipLevelCount: 1, arrayLayerCount: 1, baseArrayLayer: n }) }] }); y && (y._mipmapGenBindGroup[n] = y._mipmapGenBindGroup[n] || [], y._mipmapGenBindGroup[n][b - 1] = S), E.setPipeline(g), E.setBindGroup(0, S), E.draw(4, 1, 0, 0), E.end() } null === (p = (d = o).popDebugGroup) || void 0 === p || p.call(d), _ && (this._device.queue.submit([o.finish()]), o = null) } }, e.prototype.createGPUTextureForInternalTexture = function (t, i, r, n, o) { t._hardwareTexture || (t._hardwareTexture = new Vp), void 0 === i && (i = t.width), void 0 === r && (r = t.height), void 0 === n && (n = t.depth); var s = t._hardwareTexture, l = 0 != ((null != o ? o : 0) & a.TEXTURE_CREATIONFLAG_STORAGE); s.format = e.GetWebGPUTextureFormat(t.type, t.format, t._useSRGBBuffer), s.textureUsages = t._source === It.RenderTarget || t.source === It.MultiRenderTarget ? Qd.TextureBinding | Qd.CopySrc | Qd.RenderAttachment : t._source === It.DepthStencil ? Qd.TextureBinding | Qd.RenderAttachment : -1, s.textureAdditionalUsages = l ? Qd.StorageBinding : 0; var c, u = t.generateMipMaps, h = n || 1; if (c = null !== t._maxLodLevel ? t._maxLodLevel : u ? e.ComputeNumMipmapLevels(i, r) : 1, t.isCube) { var d = this.createCubeTexture({ width: i, height: r }, t.generateMipMaps, t.generateMipMaps, t.invertY, !1, s.format, 1, this._commandEncoderForCreation, s.textureUsages, s.textureAdditionalUsages, t.label); s.set(d), s.createView({ format: e.GetDepthFormatOnly(s.format), dimension: qd.Cube, mipLevelCount: c, baseArrayLayer: 0, baseMipLevel: 0, arrayLayerCount: 6, aspect: e.HasDepthAndStencilAspects(s.format) ? Zd.DepthOnly : Zd.All }, l) } else d = this.createTexture({ width: i, height: r, layers: h }, t.generateMipMaps, t.generateMipMaps, t.invertY, !1, t.is3D, s.format, 1, this._commandEncoderForCreation, s.textureUsages, s.textureAdditionalUsages, t.label), s.set(d), s.createView({ format: e.GetDepthFormatOnly(s.format), dimension: t.is2DArray ? qd.E2dArray : t.is3D ? Kd.E3d : qd.E2d, mipLevelCount: c, baseArrayLayer: 0, baseMipLevel: 0, arrayLayerCount: t.is3D ? 1 : h, aspect: e.HasDepthAndStencilAspects(s.format) ? Zd.DepthOnly : Zd.All }, l); return t.width = t.baseWidth = i, t.height = t.baseHeight = r, t.depth = t.baseDepth = n, this.createMSAATexture(t, t.samples), s }, e.prototype.createMSAATexture = function (e, t, i, r) { void 0 === i && (i = !0), void 0 === r && (r = -1); var n = e._hardwareTexture; if (i && (null == n || n.releaseMSAATexture()), n && !((null != t ? t : 1) <= 1)) { var o = e.width, a = e.height, s = this.createTexture({ width: o, height: a, layers: 1 }, !1, !1, !1, !1, !1, n.format, t, this._commandEncoderForCreation, Qd.RenderAttachment, 0, e.label ? "MSAA" + e.label : void 0); n.setMSAATexture(s, r) } }, e.prototype.updateCubeTextures = function (e, t, i, r, n, o, a, s, l) { void 0 === o && (o = !1), void 0 === a && (a = !1), void 0 === s && (s = 0), void 0 === l && (l = 0); for (var c = [0, 3, 1, 4, 2, 5], u = 0; u < c.length; ++u) { var h = e[c[u]]; this.updateTexture(h, t, i, r, 1, n, u, 0, o, a, s, l) } }, e.prototype.updateTexture = function (t, i, r, n, o, a, s, l, c, u, h, d, p) { void 0 === s && (s = 0), void 0 === l && (l = 0), void 0 === c && (c = !1), void 0 === u && (u = !1), void 0 === h && (h = 0), void 0 === d && (d = 0); var f = e._IsInternalTexture(i) ? i._hardwareTexture.underlyingResource : i, _ = e._GetBlockInformationFromFormat(a), m = e._IsInternalTexture(i) ? i._hardwareTexture : i, g = { texture: f, origin: { x: h, y: d, z: Math.max(s, 0) }, mipLevel: l, premultipliedAlpha: u }, v = { width: Math.ceil(r / _.width) * _.width, height: Math.ceil(n / _.height) * _.height, depthOrArrayLayers: o || 1 }; if (void 0 !== t.byteLength) { var y = Math.ceil(r / _.width) * _.length; if (256 * Math.ceil(y / 256) === y) { var b = this._device.createCommandEncoder({}), T = this._bufferManager.createRawBuffer(t.byteLength, jd.MapWrite | jd.CopySrc, !0), E = T.getMappedRange(); new Uint8Array(E).set(t), T.unmap(), b.copyBufferToTexture({ buffer: T, offset: 0, bytesPerRow: y, rowsPerImage: n }, g, v), this._device.queue.submit([b.finish()]), this._bufferManager.releaseBuffer(T) } else this._device.queue.writeTexture(g, t, { offset: 0, bytesPerRow: y, rowsPerImage: n }, v); if (c || u) { if (!e._IsInternalTexture(i)) throw "updateTexture: Can't process the texture data because a GPUTexture was provided instead of an InternalTexture!"; var S = 0 === h && 0 === d && r === i.width && n === i.height; this.invertYPreMultiplyAlpha(m, i.width, i.height, a, c, u, s, l, o || 1, h, d, S ? 0 : r, S ? 0 : n, void 0, p) } } else if (c) if (g.premultipliedAlpha = !1, e._IsInternalTexture(i) && 0 === h && 0 === d && r === i.width && n === i.height) this._device.queue.copyExternalImageToTexture({ source: t }, g, v), this.invertYPreMultiplyAlpha(m, r, n, a, c, u, s, l, o || 1, 0, 0, 0, 0, void 0, p); else { b = this._device.createCommandEncoder({}); var x = this.createTexture({ width: r, height: n, layers: 1 }, !1, !1, !1, !1, !1, a, 1, b, Qd.CopySrc | Qd.TextureBinding, void 0, "TempTextureForUpdateTexture"); this._deferredReleaseTextures.push([x, null]), v.depthOrArrayLayers = 1, this._device.queue.copyExternalImageToTexture({ source: t }, { texture: x }, v), v.depthOrArrayLayers = o || 1, this.invertYPreMultiplyAlpha(x, r, n, a, c, u, s, l, o || 1, 0, 0, 0, 0, b, p), b.copyTextureToTexture({ texture: x }, g, v), this._device.queue.submit([b.finish()]) } else this._device.queue.copyExternalImageToTexture({ source: t }, g, v) }, e.prototype.readPixels = function (t, i, r, n, o, a, s, l, c, u) { void 0 === s && (s = 0), void 0 === l && (l = 0), void 0 === c && (c = null), void 0 === u && (u = !1); var h = e._GetBlockInformationFromFormat(a), d = Math.ceil(n / h.width) * h.length, p = 256 * Math.ceil(d / 256), f = p * o, _ = this._bufferManager.createRawBuffer(f, jd.MapRead | jd.CopyDst), m = this._device.createCommandEncoder({}); return m.copyTextureToBuffer({ texture: t, mipLevel: l, origin: { x: i, y: r, z: Math.max(s, 0) } }, { buffer: _, offset: 0, bytesPerRow: p }, { width: n, height: o, depthOrArrayLayers: 1 }), this._device.queue.submit([m.finish()]), this._bufferManager.readDataFromBuffer(_, f, n, o, d, p, e._GetTextureTypeFromFormat(a), 0, c, !0, u) }, e.prototype.releaseTexture = function (t) { if (e._IsInternalTexture(t)) { var i = t._hardwareTexture, r = t._irradianceTexture; this._deferredReleaseTextures.push([i, r]) } else this._deferredReleaseTextures.push([t, null]) }, e.prototype.destroyDeferredTextures = function () { for (var t = 0; t < this._deferredReleaseTextures.length; ++t) { var i = this._deferredReleaseTextures[t], r = i[0], n = i[1]; r && (e._IsHardwareTexture(r) ? r.release() : r.destroy()), null == n || n.dispose() } this._deferredReleaseTextures.length = 0 }, e }(), jp = function (e) { function t(t, i) { void 0 === i && (i = 0); var r = e.call(this) || this; return r.capacity = i, r._buffer = t, r } return W(t, e), Object.defineProperty(t.prototype, "underlyingResource", { get: function () { return this._buffer }, enumerable: !1, configurable: !0 }), t }(Kt), Yp = function () { function e(e) { this._deferredReleaseBuffers = [], this._device = e } return e._IsGPUBuffer = function (e) { return void 0 === e.underlyingResource }, e.prototype.createRawBuffer = function (e, t, i) { void 0 === i && (i = !1); var r = { mappedAtCreation: i, size: void 0 !== e.byteLength ? e.byteLength + 3 & -4 : e + 3 & -4, usage: t }; return this._device.createBuffer(r) }, e.prototype.createBuffer = function (e, t) { var i = void 0 !== e.byteLength, r = this.createRawBuffer(e, t), n = new jp(r); return n.references = 1, n.capacity = i ? e.byteLength : e, i && this.setSubData(n, 0, e), n }, e.prototype.setRawData = function (e, t, i, r, n) { this._device.queue.writeBuffer(e, t, i.buffer, r, n) }, e.prototype.setSubData = function (e, t, i, r, n) { void 0 === r && (r = 0), void 0 === n && (n = 0); var o = e.underlyingResource; n = n || i.byteLength, n = Math.min(n, e.capacity - t); var a = i.byteOffset + r, s = a + n, l = n + 3 & -4; if (l !== n) { var c = new Uint8Array(i.buffer.slice(a, s)); (i = new Uint8Array(l)).set(c), r = 0, a = 0, s = l, n = l } for (var u = 15728640, h = 0; s - (a + h) > u;)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] = ld(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(Yd.Read, l, t).then((function () { var a = e.getMappedRange(l, t), f = c; if (h) f = null === f ? Pn(s, t, !0, a) : Pn(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; v < r; ++v) { g = v * o; for (var y = 0; y < n; ++y)_[m++] = _[g++] } f = 0 === p || h ? new Uint8Array(_.buffer, 0, m) : new Float32Array(_.buffer, 0, m / 4) } e.unmap(), u && d.releaseBuffer(e), i(f) }), (function (e) { return a(e) })) })) }, e.prototype.releaseBuffer = function (t) { return e._IsGPUBuffer(t) ? (this._deferredReleaseBuffers.push(t), !0) : (t.references--, 0 === t.references && (this._deferredReleaseBuffers.push(t.underlyingResource), !0)) }, e.prototype.destroyDeferredBuffers = function () { for (var e = 0; e < this._deferredReleaseBuffers.length; ++e)this._deferredReleaseBuffers[e].destroy(); this._deferredReleaseBuffers.length = 0 }, e }(), Kp = function () { function e() { this.colorAttachmentGPUTextures = [], this.reset() } return e.prototype.reset = function (e) { void 0 === e && (e = !1), this.renderPass = null, e && (this.renderPassDescriptor = null, this.colorAttachmentViewDescriptor = null, this.depthAttachmentViewDescriptor = null, this.colorAttachmentGPUTextures = [], this.depthTextureFormat = void 0) }, e }(), Qp = [0, 0, 3, 7, 0, 2, 6, 2, 4, 1, 5, 3, 1], qp = [0, 64, 32, 96, 16, 80, 48, 112, 8], Zp = [0, 128, 128, 0, 0, 0, 0, 128, 0, 0, 0, 0, 128], Jp = function () { function e(e) { this._samplers = {}, this._device = e, this.disabled = !1 } return e.GetSamplerHashCode = function (e) { var t, i, r, n = e._cachedAnisotropicFilteringLevel && e._cachedAnisotropicFilteringLevel > 1 ? 4 : 1; return Qp[e.samplingMode] + qp[(e._comparisonFunction || 514) - 512 + 1] + Zp[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 = ep.Linear, r = ep.Linear, n = ep.Nearest, l || (o = s = 0); break; case a.TEXTURE_LINEAR_LINEAR_MIPLINEAR: case a.TEXTURE_TRILINEAR_SAMPLINGMODE: i = ep.Linear, r = ep.Linear, l ? n = ep.Linear : (n = ep.Nearest, o = s = 0); break; case a.TEXTURE_NEAREST_NEAREST_MIPLINEAR: i = ep.Nearest, r = ep.Nearest, l ? n = ep.Linear : (n = ep.Nearest, o = s = 0); break; case a.TEXTURE_NEAREST_NEAREST_MIPNEAREST: i = ep.Nearest, r = ep.Nearest, n = ep.Nearest, l || (o = s = 0); break; case a.TEXTURE_NEAREST_LINEAR_MIPNEAREST: i = ep.Nearest, r = ep.Linear, n = ep.Nearest, l || (o = s = 0); break; case a.TEXTURE_NEAREST_LINEAR_MIPLINEAR: i = ep.Nearest, r = ep.Linear, l ? n = ep.Linear : (n = ep.Nearest, o = s = 0); break; case a.TEXTURE_NEAREST_LINEAR: i = ep.Nearest, r = ep.Linear, n = ep.Nearest, o = s = 0; break; case a.TEXTURE_NEAREST_NEAREST: case a.TEXTURE_NEAREST_SAMPLINGMODE: i = ep.Nearest, r = ep.Nearest, n = ep.Nearest, o = s = 0; break; case a.TEXTURE_LINEAR_NEAREST_MIPNEAREST: i = ep.Linear, r = ep.Nearest, n = ep.Nearest, l || (o = s = 0); break; case a.TEXTURE_LINEAR_NEAREST_MIPLINEAR: i = ep.Linear, r = ep.Nearest, l ? n = ep.Linear : (n = ep.Nearest, o = s = 0); break; case a.TEXTURE_LINEAR_LINEAR: case a.TEXTURE_BILINEAR_SAMPLINGMODE: i = ep.Linear, r = ep.Linear, n = ep.Nearest, o = s = 0; break; case a.TEXTURE_LINEAR_NEAREST: i = ep.Linear, r = ep.Nearest, n = ep.Nearest, o = s = 0; break; default: i = ep.Nearest, r = ep.Nearest, n = ep.Nearest, o = s = 0 }return t > 1 && (0 !== o || 0 !== s) ? { magFilter: ep.Linear, minFilter: ep.Linear, mipmapFilter: ep.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 $d.Repeat; case a.TEXTURE_CLAMP_ADDRESSMODE: return $d.ClampToEdge; case a.TEXTURE_MIRROR_ADDRESSMODE: return $d.MirrorRepeat }return $d.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 ip.Always; case a.EQUAL: return ip.Equal; case a.GREATER: return ip.Greater; case a.GEQUAL: return ip.GreaterEqual; case a.LESS: return ip.Less; case a.LEQUAL: return ip.LessEqual; case a.NEVER: return ip.Never; case a.NOTEQUAL: return ip.NotEqual; default: return ip.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" }(zp || (zp = {})); var $p = { 0: 1, 1: 2, 768: 3, 769: 4, 770: 5, 771: 6, 772: 7, 773: 8, 774: 9, 775: 10, 776: 11, 32769: 12, 32770: 13, 32771: 12, 32772: 13 }, ef = { 0: 0, 7680: 1, 7681: 2, 7682: 3, 7683: 4, 5386: 5, 34055: 6, 34056: 7 }, tf = 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.prototype.reset = function () { this._isDirty = !0, this.vertexBuffers.length = 0, this.setAlphaToCoverage(!1), this.resetDepthCullingState(), this.setClampDepth(!1), this.setDepthBias(0), this._webgpuColorFormat = [Jd.BGRA8Unorm], this.setColorFormat(Jd.BGRA8Unorm), this.setMRT([]), this.setAlphaBlendEnabled(!1), this.setAlphaBlendFactors([null, null, null, null], [null, null]), this.setWriteMask(15), this.setDepthStencilFormat(Jd.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[zp.DepthBias] = e, this._isDirty = !0, this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, zp.DepthBias)) }, e.prototype.setDepthBiasSlopeScale = function (e) { this._depthBiasSlopeScale !== e && (this._depthBiasSlopeScale = e, this._states[zp.DepthBiasSlopeScale] = e, this._isDirty = !0, this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, zp.DepthBiasSlopeScale)) }, e.prototype.setColorFormat = function (e) { this._webgpuColorFormat[0] = e, this._colorFormat = Hp[null != e ? e : ""] }, e.prototype.setMRTAttachments = function (e) { this.mrtAttachments = e; for (var t = 0, i = 0; i < e.length; ++i)0 !== e[i] && (t += 1 << i); this._mrtEnabledMask !== t && (this._mrtEnabledMask = t, this._isDirty = !0, this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, zp.MRTAttachments1)) }, e.prototype.setMRT = function (e, t) { var i, r; if ((t = null != t ? t : e.length) > 10) 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 < t; ++l) { var c = e[l], u = null == c ? void 0 : c._hardwareTexture; this._mrtFormats[s] = null !== (i = null == u ? void 0 : u.format) && void 0 !== i ? i : this._webgpuColorFormat[0], n[o] += Hp[null !== (r = this._mrtFormats[s]) && void 0 !== r ? r : ""] << a, s++, (a += 6) >= 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[zp.MRTAttachments1] = n[0], this._states[zp.MRTAttachments2] = n[1], this._isDirty = !0, this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, zp.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 : Hp[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 : ef[e] }, e.prototype.setStencilPassOp = function (e) { this._stencilFrontPassOp = null === e ? 2 : ef[e] }, e.prototype.setStencilFailOp = function (e) { this._stencilFrontFailOp = null === e ? 1 : ef[e] }, e.prototype.setStencilReadMask = function (e) { this._stencilReadMask !== e && (this._stencilReadMask = e, this._states[zp.StencilReadMask] = e, this._isDirty = !0, this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, zp.StencilReadMask)) }, e.prototype.setStencilWriteMask = function (e) { this._stencilWriteMask !== e && (this._stencilWriteMask = e, this._states[zp.StencilWriteMask] = e, this._isDirty = !0, this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, zp.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 : ef[i], this._stencilFrontPassOp = null === r ? 2 : ef[r], this._stencilFrontFailOp = null === n ? 1 : ef[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 hp.TriangleList; case a.MATERIAL_PointFillMode: return hp.PointList; case a.MATERIAL_WireFrameFillMode: return hp.LineList; case a.MATERIAL_PointListDrawMode: return hp.PointList; case a.MATERIAL_LineListDrawMode: return hp.LineList; case a.MATERIAL_LineLoopDrawMode: throw "LineLoop is an unsupported fillmode in WebGPU"; case a.MATERIAL_LineStripDrawMode: return hp.LineStrip; case a.MATERIAL_TriangleStripDrawMode: return hp.TriangleStrip; case a.MATERIAL_TriangleFanDrawMode: throw "TriangleFan is an unsupported fillmode in WebGPU"; default: return hp.TriangleList } }, e._GetAphaBlendOperation = function (e) { switch (e) { case a.GL_ALPHA_EQUATION_ADD: return mp.Add; case a.GL_ALPHA_EQUATION_SUBTRACT: return mp.Subtract; case a.GL_ALPHA_EQUATION_REVERSE_SUBTRACT: return mp.ReverseSubtract; case a.GL_ALPHA_EQUATION_MIN: return mp.Min; case a.GL_ALPHA_EQUATION_MAX: return mp.Max; default: return mp.Add } }, e._GetAphaBlendFactor = function (e) { switch (e) { case 0: return _p.Zero; case 1: return _p.One; case a.GL_ALPHA_FUNCTION_SRC: return _p.Src; case a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR: return _p.OneMinusSrc; case a.GL_ALPHA_FUNCTION_SRC_ALPHA: return _p.SrcAlpha; case a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA: return _p.OneMinusSrcAlpha; case a.GL_ALPHA_FUNCTION_DST_ALPHA: return _p.DstAlpha; case a.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA: return _p.OneMinusDstAlpha; case a.GL_ALPHA_FUNCTION_DST_COLOR: return _p.Dst; case a.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR: return _p.OneMinusDst; case a.GL_ALPHA_FUNCTION_SRC_ALPHA_SATURATED: return _p.SrcAlphaSaturated; case a.GL_ALPHA_FUNCTION_CONSTANT_COLOR: return _p.Constant; case a.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR: return _p.OneMinusConstant; case a.GL_ALPHA_FUNCTION_CONSTANT_ALPHA: return _p.Constant; case a.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA: return _p.OneMinusConstant; default: return _p.One } }, e._GetCompareFunction = function (e) { switch (e) { case 0: return ip.Never; case 1: return ip.Less; case 2: return ip.Equal; case 3: return ip.LessEqual; case 4: return ip.Greater; case 5: return ip.NotEqual; case 6: return ip.GreaterEqual; case 7: return ip.Always }return ip.Never }, e._GetStencilOpFunction = function (e) { switch (e) { case 0: return gp.Zero; case 1: return gp.Keep; case 2: return gp.Replace; case 3: return gp.IncrementClamp; case 4: return gp.DecrementClamp; case 5: return gp.Invert; case 6: return gp.IncrementWrap; case 7: return gp.DecrementWrap }return gp.Keep }, e._GetVertexInputDescriptorFormat = function (e) { var t = e.type, i = e.normalized, r = e.getSize(); switch (t) { case Hi.BYTE: switch (r) { case 1: case 2: return i ? yp.Snorm8x2 : yp.Sint8x2; case 3: case 4: return i ? yp.Snorm8x4 : yp.Sint8x4 }break; case Hi.UNSIGNED_BYTE: switch (r) { case 1: case 2: return i ? yp.Unorm8x2 : yp.Uint8x2; case 3: case 4: return i ? yp.Unorm8x4 : yp.Uint8x4 }break; case Hi.SHORT: switch (r) { case 1: case 2: return i ? yp.Snorm16x2 : yp.Sint16x2; case 3: case 4: return i ? yp.Snorm16x4 : yp.Sint16x4 }break; case Hi.UNSIGNED_SHORT: switch (r) { case 1: case 2: return i ? yp.Unorm16x2 : yp.Uint16x2; case 3: case 4: return i ? yp.Unorm16x4 : yp.Uint16x4 }break; case Hi.INT: switch (r) { case 1: return yp.Sint32; case 2: return yp.Sint32x2; case 3: return yp.Sint32x3; case 4: return yp.Sint32x4 }break; case Hi.UNSIGNED_INT: switch (r) { case 1: return yp.Uint32; case 2: return yp.Uint32x2; case 3: return yp.Uint32x3; case 4: return yp.Uint32x4 }break; case Hi.FLOAT: switch (r) { case 1: return yp.Float32; case 2: return yp.Float32x2; case 3: return yp.Float32x3; case 4: return yp.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[zp.ShaderStage] = e, this._isDirty = !0, this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, zp.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[zp.RasterizationState] = this._rasterizationState, this._isDirty = !0, this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, zp.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 : $p[this._alphaBlendFuncParams[0]]) << 0) + ((null === this._alphaBlendFuncParams[1] ? 2 : $p[this._alphaBlendFuncParams[1]]) << 4) + ((null === this._alphaBlendFuncParams[2] ? 2 : $p[this._alphaBlendFuncParams[2]]) << 8) + ((null === this._alphaBlendFuncParams[3] ? 2 : $p[this._alphaBlendFuncParams[3]]) << 12) + ((null === this._alphaBlendEqParams[0] ? 1 : this._alphaBlendEqParams[0] - 32773) << 16) + ((null === this._alphaBlendEqParams[1] ? 1 : this._alphaBlendEqParams[1] - 32773) << 19)), e !== this._colorStates && (this._colorStates = e, this._states[zp.ColorStates] = this._colorStates, this._isDirty = !0, this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, zp.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[zp.DepthStencilState] = this._depthStencilState, this._isDirty = !0, this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, zp.DepthStencilState)) }, e.prototype._setVertexState = function (e) { for (var t, i, r, n = this._statesLength, o = zp.VertexState, a = e._pipelineContext, s = a.shaderProcessingContext.attributeNamesFromEffect, l = a.shaderProcessingContext.attributeLocationsFromEffect, c = 0, u = 0; u < s.length; u++) { var h = l[u], d = null !== (t = this._overrideVertexBuffers && this._overrideVertexBuffers[s[u]]) && void 0 !== t ? t : this._vertexBuffers[s[u]]; d || (d = this._emptyVertexBuffer); var p = null === (i = d.getBuffer()) || void 0 === i ? void 0 : i.underlyingResource; if (void 0 === d._validOffsetRange) { var f = d.byteOffset, _ = d.getSize(!0), m = d.byteStride; d._validOffsetRange = f <= this._kMaxVertexBufferStride - _ && (0 === m || f + _ <= m) } r && r === p && d._validOffsetRange || (this.vertexBuffers[c++] = d, r = d._validOffsetRange ? p : null); var g = d.hashCode + (h << 7); this._isDirty = this._isDirty || this._states[o] !== g, this._states[o++] = g } this.vertexBuffers.length = c, this._statesLength = o, this._isDirty = this._isDirty || o !== n, this._isDirty && (this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, zp.VertexState)) }, e.prototype._setTextureState = function (e) { this._textureState !== e && (this._textureState = e, this._states[zp.TextureStage] = this._textureState, this._isDirty = !0, this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, zp.TextureStage)) }, e.prototype._createPipelineLayout = function (e) { if (this._useTextureStage) return this._createPipelineLayoutWithTextureStage(e); for (var t = [], i = e.shaderProcessingContext.bindGroupLayoutEntries, r = 0; r < i.length; r++) { var n = i[r]; t[r] = this._device.createBindGroupLayout({ entries: n }) } return e.bindGroupLayouts[0] = t, this._device.createPipelineLayout({ bindGroupLayouts: t }) }, e.prototype._createPipelineLayoutWithTextureStage = function (e) { for (var t, i = e.shaderProcessingContext, r = i.bindGroupLayoutEntries, n = 1, o = 0; o < r.length; o++)for (var a = r[o], s = 0; s < a.length; s++) { var l = r[o][s]; if (l.texture) { var c = i.bindGroupLayoutEntryInfo[o][l.binding].name, u = i.availableTextures[c], h = u.autoBindSampler ? i.availableSamplers[c + Mp.AutoSamplerSuffix] : null, d = u.sampleType, p = null !== (t = null == h ? void 0 : h.type) && void 0 !== t ? t : op.Filtering; if (this._textureState & n && d !== ap.Depth && (u.autoBindSampler && (p = op.NonFiltering), d = ap.UnfilterableFloat), l.texture.sampleType = d, h) { var f = i.bindGroupLayoutEntryInfo[h.binding.groupIndex][h.binding.bindingIndex].index; r[h.binding.groupIndex][f].sampler.type = p } n <<= 1 } } var _ = []; for (o = 0; o < r.length; ++o)_[o] = this._device.createBindGroupLayout({ entries: r[o] }); return e.bindGroupLayouts[this._textureState] = _, this._device.createPipelineLayout({ bindGroupLayouts: _ }) }, e.prototype._getVertexInputDescriptor = function (t) { for (var i, r, n, o, a = [], s = t._pipelineContext, l = s.shaderProcessingContext.attributeNamesFromEffect, c = s.shaderProcessingContext.attributeLocationsFromEffect, u = 0; u < l.length; u++) { var h = c[u], d = null !== (i = this._overrideVertexBuffers && this._overrideVertexBuffers[l[u]]) && void 0 !== i ? i : this._vertexBuffers[l[u]]; d || (d = this._emptyVertexBuffer); var p = null === (r = d.getBuffer()) || void 0 === r ? void 0 : r.underlyingResource, f = d.byteOffset, _ = !d._validOffsetRange; if (!n || !o || n !== p || _) { var m = { arrayStride: d.byteStride, stepMode: d.getIsInstanced() ? bp.Instance : bp.Vertex, attributes: [] }; a.push(m), o = m.attributes, _ && (f = 0, p = null) } o.push({ shaderLocation: h, offset: f, format: e._GetVertexInputDescriptorFormat(d) }), n = p } return a }, e.prototype._createRenderPipeline = function (t, i, r) { var n, o, a, s = t._pipelineContext, l = this._getVertexInputDescriptor(t), c = this._createPipelineLayout(s), u = [], h = this._getAphaBlendState(), d = this._getColorBlendState(); if (this._mrtAttachments1 > 0) for (var p = 0; p < this._mrtFormats.length; ++p) { var f = this._mrtFormats[p]; if (f) { var _ = { format: f, writeMask: 0 != (this._mrtEnabledMask & 1 << p) ? this._writeMask : 0 }; h && d && (_.blend = { alpha: h, color: d }), u.push(_) } else u.push(null) } else this._webgpuColorFormat[0] ? (_ = { format: this._webgpuColorFormat[0], writeMask: this._writeMask }, h && d && (_.blend = { alpha: h, color: d }), u.push(_)) : u.push(null); var m = { compare: e._GetCompareFunction(this._stencilEnabled ? this._stencilFrontCompare : 7), depthFailOp: e._GetStencilOpFunction(this._stencilEnabled ? this._stencilFrontDepthFailOp : 1), failOp: e._GetStencilOpFunction(this._stencilEnabled ? this._stencilFrontFailOp : 1), passOp: e._GetStencilOpFunction(this._stencilEnabled ? this._stencilFrontPassOp : 1) }, g = void 0; i !== hp.LineStrip && i !== hp.TriangleStrip || (g = !this._indexBuffer || this._indexBuffer.is32Bits ? vp.Uint32 : vp.Uint16); var v = !!this._webgpuDepthStencilFormat && Xp.HasStencilAspect(this._webgpuDepthStencilFormat); return this._device.createRenderPipeline({ label: "RenderPipeline_".concat(null !== (o = null === (n = u[0]) || void 0 === n ? void 0 : n.format) && void 0 !== o ? o : "nooutput", "_").concat(null !== (a = this._webgpuDepthStencilFormat) && void 0 !== a ? a : "nodepth", "_samples").concat(r, "_textureState").concat(this._textureState), layout: c, vertex: { module: s.stages.vertexStage.module, entryPoint: s.stages.vertexStage.entryPoint, buffers: l }, primitive: { topology: i, stripIndexFormat: g, frontFace: 1 === this._frontFace ? dp.CCW : dp.CW, cullMode: this._cullEnabled ? 2 === this._cullFace ? pp.Front : pp.Back : pp.None }, fragment: s.stages.fragmentStage ? { module: s.stages.fragmentStage.module, entryPoint: s.stages.fragmentStage.entryPoint, targets: u } : void 0, multisample: { count: r }, depthStencil: void 0 === this._webgpuDepthStencilFormat ? void 0 : { depthWriteEnabled: this._depthWriteEnabled, depthCompare: this._depthTestEnabled ? e._GetCompareFunction(this._depthCompare) : ip.Always, format: this._webgpuDepthStencilFormat, stencilFront: this._stencilEnabled && v ? m : void 0, stencilBack: this._stencilEnabled && v ? m : void 0, stencilReadMask: this._stencilEnabled && v ? this._stencilReadMask : void 0, stencilWriteMask: this._stencilEnabled && v ? this._stencilWriteMask : void 0, depthBias: this._depthBias, depthBiasClamp: this._depthBiasClamp, depthBiasSlopeScale: this._depthBiasSlopeScale } }) }, e.NumCacheHitWithoutHash = 0, e.NumCacheHitWithHash = 0, e.NumCacheMiss = 0, e.NumPipelineCreationLastFrame = 0, e._NumPipelineCreationCurrentFrame = 0, e }(), rf = function () { function e() { this.values = {} } return e.prototype.count = function () { var e = 0, t = this.pipeline ? 1 : 0; for (var i in this.values) { var r = this.values[i].count(); e += r[0], t += r[1], e++ } return [e, t] }, e }(), nf = function (e) { function t(i, r, n) { var o = e.call(this, i, r, n) || this; return o._nodeStack = [], o._nodeStack[0] = t._Cache, o } return W(t, e), t.GetNodeCounts = function () { var e = t._Cache.count(); return { nodeCount: e[0], pipelineCount: e[1] } }, t._GetPipelines = function (e, i, r, n) { if (e.pipeline) { var o = r.slice(); o.length = n, i.push(o) } for (var a in e.values) { var s = e.values[a]; r[n] = parseInt(a), t._GetPipelines(s, i, r, n + 1) } }, t.GetPipelines = function () { var e = []; return t._GetPipelines(t._Cache, e, [], 0), e }, t.prototype._getRenderPipeline = function (e) { for (var t = this._nodeStack[this._stateDirtyLowestIndex], i = this._stateDirtyLowestIndex; i < this._statesLength; ++i) { var r = t.values[this._states[i]]; r || (r = new rf, t.values[this._states[i]] = r), t = r, this._nodeStack[i + 1] = t } e.token = t, e.pipeline = t.pipeline }, t.prototype._setRenderPipeline = function (e) { e.token.pipeline = e.pipeline }, t._Cache = new rf, t }(tf), of = function (e) { function t(t) { var i = e.call(this, !1) || this; return i._cache = t, i.reset(), i } return W(t, e), Object.defineProperty(t.prototype, "func", { get: function () { return this._func }, set: function (e) { this._func !== e && (this._func = e, this._cache.setStencilCompare(e)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "funcMask", { get: function () { return this._funcMask }, set: function (e) { this._funcMask !== e && (this._funcMask = e, this._cache.setStencilReadMask(e)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "opStencilFail", { get: function () { return this._opStencilFail }, set: function (e) { this._opStencilFail !== e && (this._opStencilFail = e, this._cache.setStencilFailOp(e)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "opDepthFail", { get: function () { return this._opDepthFail }, set: function (e) { this._opDepthFail !== e && (this._opDepthFail = e, this._cache.setStencilDepthFailOp(e)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "opStencilDepthPass", { get: function () { return this._opStencilDepthPass }, set: function (e) { this._opStencilDepthPass !== e && (this._opStencilDepthPass = e, this._cache.setStencilPassOp(e)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "mask", { get: function () { return this._mask }, set: function (e) { this._mask !== e && (this._mask = e, this._cache.setStencilWriteMask(e)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "enabled", { get: function () { return this._enabled }, set: function (e) { this._enabled !== e && (this._enabled = e, this._cache.setStencilEnabled(e)) }, enumerable: !1, configurable: !0 }), t.prototype.reset = function () { e.prototype.reset.call(this), this._cache.resetStencilState() }, t.prototype.apply = function () { var e, t = null === (e = this.stencilMaterial) || void 0 === e ? void 0 : e.enabled; this.enabled = t ? this.stencilMaterial.enabled : this.stencilGlobal.enabled, this.enabled && (this.func = t ? this.stencilMaterial.func : this.stencilGlobal.func, this.funcRef = t ? this.stencilMaterial.funcRef : this.stencilGlobal.funcRef, this.funcMask = t ? this.stencilMaterial.funcMask : this.stencilGlobal.funcMask, this.opStencilFail = t ? this.stencilMaterial.opStencilFail : this.stencilGlobal.opStencilFail, this.opDepthFail = t ? this.stencilMaterial.opDepthFail : this.stencilGlobal.opDepthFail, this.opStencilDepthPass = t ? this.stencilMaterial.opStencilDepthPass : this.stencilGlobal.opStencilDepthPass, this.mask = t ? this.stencilMaterial.mask : this.stencilGlobal.mask) }, t }($t), af = function (e) { function t(t) { var i = e.call(this, !1) || this; return i._cache = t, i.reset(), i } return W(t, e), Object.defineProperty(t.prototype, "zOffset", { get: function () { return this._zOffset }, set: function (e) { this._zOffset !== e && (this._zOffset = e, this._isZOffsetDirty = !0, this._cache.setDepthBiasSlopeScale(e)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "zOffsetUnits", { get: function () { return this._zOffsetUnits }, set: function (e) { this._zOffsetUnits !== e && (this._zOffsetUnits = e, this._isZOffsetDirty = !0, this._cache.setDepthBias(e)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cullFace", { get: function () { return this._cullFace }, set: function (e) { this._cullFace !== e && (this._cullFace = e, this._isCullFaceDirty = !0, this._cache.setCullFace(null != e ? e : 1)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cull", { get: function () { return this._cull }, set: function (e) { this._cull !== e && (this._cull = e, this._isCullDirty = !0, this._cache.setCullEnabled(!!e)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "depthFunc", { get: function () { return this._depthFunc }, set: function (e) { this._depthFunc !== e && (this._depthFunc = e, this._isDepthFuncDirty = !0, this._cache.setDepthCompare(e)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "depthMask", { get: function () { return this._depthMask }, set: function (e) { this._depthMask !== e && (this._depthMask = e, this._isDepthMaskDirty = !0, this._cache.setDepthWriteEnabled(e)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "depthTest", { get: function () { return this._depthTest }, set: function (e) { this._depthTest !== e && (this._depthTest = e, this._isDepthTestDirty = !0, this._cache.setDepthTestEnabled(e)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "frontFace", { get: function () { return this._frontFace }, set: function (e) { this._frontFace !== e && (this._frontFace = e, this._isFrontFaceDirty = !0, this._cache.setFrontFace(null != e ? e : 2)) }, enumerable: !1, configurable: !0 }), t.prototype.reset = function () { e.prototype.reset.call(this), this._cache.resetDepthCullingState() }, t.prototype.apply = function () { }, t }(kt), sf = function () { function e(e) { this.useMipMaps = !1, this.type = a.TEXTURETYPE_UNDEFINED, this._video = e, this.uniqueId = Ht._Counter++ } return e.IsExternalTexture = function (e) { return void 0 !== e.underlyingResource }, e.prototype.getClassName = function () { return "ExternalTexture" }, Object.defineProperty(e.prototype, "underlyingResource", { get: function () { return this._video }, enumerable: !1, configurable: !0 }), e.prototype.isReady = function () { return this._video.readyState >= this._video.HAVE_CURRENT_DATA }, e.prototype.dispose = function () { }, e }(), lf = 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 ? Jp.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 = sf.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 }(), cf = 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, jd.CopyDst | jd.Indirect | jd.Storage), 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 }(), uf = function () { this.values = {} }, hf = 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 < v.length; g++) { var y = v[g], b = null !== (o = null === (n = i.buffers[y]) || void 0 === n ? void 0 : n.uniqueId) && void 0 !== o ? o : 0; (C = _.values[b]) || (C = new uf, _.values[b] = C), _ = C } for (var T = 0, E = t.shaderProcessingContext.samplerNames; T < E.length; T++) { var S = E[T], x = null !== (s = null === (a = r.samplers[S]) || void 0 === a ? void 0 : a.hashCode) && void 0 !== s ? s : 0; (C = _.values[x]) || (C = new uf, _.values[x] = C), _ = C } for (var A = 0, R = t.shaderProcessingContext.textureNames; A < R.length; A++) { var C, P = R[A], I = null !== (u = null === (c = null === (l = r.textures[P]) || void 0 === l ? void 0 : l.texture) || void 0 === c ? void 0 : c.uniqueId) && void 0 !== u ? u : 0; (C = _.values[I]) || (C = new uf, _.values[I] = C), _ = C } f = _.bindGroups } if (i.resetIsDirty(r.updateId), r.isDirty = !1, f) return i.bindGroups = f, e._NumBindGroupsLookupCurrentFrame++, f; f = [], i.bindGroups = f, m || (_.bindGroups = f), e.NumBindGroupsCreatedTotal++, e._NumBindGroupsCreatedCurrentFrame++; for (var M = t.bindGroupLayouts[r.textureState], O = 0; O < t.shaderProcessingContext.bindGroupLayoutEntries.length; O++) { for (var D = t.shaderProcessingContext.bindGroupLayoutEntries[O], N = t.shaderProcessingContext.bindGroupEntries[O], F = 0; F < D.length; F++) { var L = t.shaderProcessingContext.bindGroupLayoutEntries[O][F], w = t.shaderProcessingContext.bindGroupLayoutEntryInfo[O][L.binding], B = null !== (h = w.nameInArrayOfTexture) && void 0 !== h ? h : w.name; if (L.sampler) if (k = r.samplers[B]) { var U = k.sampler; if (!U) { this._engine.dbgSanityChecks && $.Error("Trying to bind a null sampler! 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 } 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 uf, e._NumBindGroupsCreatedCurrentFrame = 0, e._NumBindGroupsLookupCurrentFrame = 0, e._NumBindGroupsNoLookupCurrentFrame = 0, e }(); Ut.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"; Ut.ShadersStore.clearQuadPixelShader = "uniform vec4 color;void main() {gl_FragColor=color;}\n"; var df = function () { function e(e, t, i) { this._bindGroups = {}, this._bundleCache = {}, this._keyTemp = [], this._device = e, this._engine = t, this._cacheRenderPipeline = new nf(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; p < this._cacheRenderPipeline.colorFormats.length; ++p)this._keyTemp[d++] = Hp[null !== (o = this._cacheRenderPipeline.colorFormats[p]) && void 0 !== o ? o : ""]; var f = Hp[null !== (s = this._depthTextureFormat) && void 0 !== s ? s : 0]; if (this._keyTemp[d] = (t ? t.r + 256 * t.g + 256 * t.b * 256 + 256 * t.a * 256 * 256 : 0) + (i ? Math.pow(2, 32) : 0) + (r ? Math.pow(2, 33) : 0) + (this._engine.useReverseDepthBuffer ? Math.pow(2, 34) : 0) + (h ? Math.pow(2, 35) : 0) + (n > 1 ? 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 && Xp.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: [] })), Np._SimplifiedKnownBindings || b.push(this._device.createBindGroup({ layout: T[1], entries: [] })), b.push(this._device.createBindGroup({ layout: T[Np._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 < b.length; ++p)l.setBindGroup(p, b[p]); return l.draw(4, 1, 0, 0), e || (u = l.finish(), this._bundleCache[c] = u), u }, e }(), pf = function () { function e(e, t, i, r) { this.x = Math.floor(e), this.y = Math.floor(t), this.w = Math.floor(i), this.h = Math.floor(r) } return e.prototype.run = function (e) { e.setViewport(this.x, this.y, this.w, this.h, 0, 1) }, e.prototype.clone = function () { return new e(this.x, this.y, this.w, this.h) }, e }(), ff = function () { function e(e, t, i, r) { this.x = e, this.y = t, this.w = i, this.h = r } return e.prototype.run = function (e) { e.setScissorRect(this.x, this.y, this.w, this.h) }, e.prototype.clone = function () { return new e(this.x, this.y, this.w, this.h) }, e }(), _f = function () { function e(e) { this.ref = e } return e.prototype.run = function (e) { e.setStencilReference(this.ref) }, e.prototype.clone = function () { return new e(this.ref) }, e }(), mf = function () { function e(e) { this.color = e } return e.prototype.run = function (e) { e.setBlendConstant(this.color) }, e.prototype.clone = function () { return new e(this.color) }, e }(), gf = function () { function e(e) { this.query = e } return e.prototype.run = function (e) { e.beginOcclusionQuery(this.query) }, e.prototype.clone = function () { return new e(this.query) }, e }(), vf = function () { function e() { } return e.prototype.run = function (e) { e.endOcclusionQuery() }, e.prototype.clone = function () { return new e }, e }(), yf = function () { function e() { this.bundles = [] } return e.prototype.run = function (e) { e.executeBundles(this.bundles) }, e.prototype.clone = function () { var t = new e; return t.bundles = this.bundles, t }, e }(), bf = function () { function e(e) { this.numDrawCalls = 0, this._device = e, this._list = new Array(10), this._listLength = 0 } return e.prototype.addBundle = function (e) { if (!this._currentItemIsBundle) { var t = new yf; this._list[this._listLength++] = t, this._currentBundleList = t.bundles, this._currentItemIsBundle = !0 } e && this._currentBundleList.push(e) }, e.prototype._finishBundle = function () { this._currentItemIsBundle && this._bundleEncoder && (this._currentBundleList.push(this._bundleEncoder.finish()), this._bundleEncoder = void 0, this._currentItemIsBundle = !1) }, e.prototype.addItem = function (e) { this._finishBundle(), this._list[this._listLength++] = e, this._currentItemIsBundle = !1 }, e.prototype.getBundleEncoder = function (e, t, i) { return this._currentItemIsBundle || (this.addBundle(), this._bundleEncoder = this._device.createRenderBundleEncoder({ colorFormats: e, depthStencilFormat: t, sampleCount: i })), this._bundleEncoder }, e.prototype.close = function () { this._finishBundle() }, e.prototype.run = function (e) { this.close(); for (var t = 0; t < this._listLength; ++t)this._list[t].run(e) }, e.prototype.reset = function () { this._listLength = 0, this._currentItemIsBundle = !1, this.numDrawCalls = 0 }, e.prototype.clone = function () { this.close(); var t = new e(this._device); t._list = new Array(this._listLength), t._listLength = this._listLength, t.numDrawCalls = this.numDrawCalls; for (var i = 0; i < this._listLength; ++i)t._list[i] = this._list[i].clone(); return t }, e }(), Tf = function () { function e(e, t, i, r, n) { void 0 === n && (n = !0), this._dstBuffers = [], this._device = i, this._bufferManager = r, this._count = e, this._canUseMultipleBuffers = n, this._querySet = i.createQuerySet({ type: t, count: e }), this._queryBuffer = r.createRawBuffer(8 * e, jd.QueryResolve | jd.CopySrc), n || this._dstBuffers.push(this._bufferManager.createRawBuffer(8 * this._count, jd.MapRead | jd.CopyDst)) } return Object.defineProperty(e.prototype, "querySet", { get: function () { return this._querySet }, enumerable: !1, configurable: !0 }), e.prototype._getBuffer = function (e, t) { if (!this._canUseMultipleBuffers && 0 === this._dstBuffers.length) return null; var i, r = this._device.createCommandEncoder(); return 0 === this._dstBuffers.length ? i = this._bufferManager.createRawBuffer(8 * this._count, jd.MapRead | jd.CopyDst) : (i = this._dstBuffers[this._dstBuffers.length - 1], this._dstBuffers.length--), r.resolveQuerySet(this._querySet, e, t, this._queryBuffer, 0), r.copyBufferToBuffer(this._queryBuffer, 0, i, 0, 8 * t), this._device.queue.submit([r.finish()]), i }, e.prototype.readValues = function (e, t) { return void 0 === e && (e = 0), void 0 === t && (t = 1), j(this, void 0, void 0, (function () { var i, r; return Y(this, (function (n) { switch (n.label) { case 0: return null === (i = this._getBuffer(e, t)) ? [2, null] : [4, i.mapAsync(Yd.Read)]; case 1: return n.sent(), r = new BigUint64Array(i.getMappedRange()).slice(), i.unmap(), this._dstBuffers[this._dstBuffers.length] = i, [2, r] } })) })) }, e.prototype.readValue = function (e) { return void 0 === e && (e = 0), j(this, void 0, void 0, (function () { var t, i, r; return Y(this, (function (n) { switch (n.label) { case 0: return null === (t = this._getBuffer(e, 1)) ? [2, null] : [4, t.mapAsync(Yd.Read)]; case 1: return n.sent(), i = new BigUint64Array(t.getMappedRange()), r = Number(i[0]), t.unmap(), this._dstBuffers[this._dstBuffers.length] = t, [2, r] } })) })) }, e.prototype.readTwoValuesAndSubtract = function (e) { return void 0 === e && (e = 0), j(this, void 0, void 0, (function () { var t, i, r; return Y(this, (function (n) { switch (n.label) { case 0: return null === (t = this._getBuffer(e, 2)) ? [2, null] : [4, t.mapAsync(Yd.Read)]; case 1: return n.sent(), i = new BigUint64Array(t.getMappedRange()), r = Number(i[1] - i[0]), t.unmap(), this._dstBuffers[this._dstBuffers.length] = t, [2, r] } })) })) }, e.prototype.dispose = function () { this._querySet.destroy(), this._bufferManager.releaseBuffer(this._queryBuffer); for (var e = 0; e < this._dstBuffers.length; ++e)this._bufferManager.releaseBuffer(this._dstBuffers[e]) }, e }(), Ef = function () { function e(e, t) { this._enabled = !1, this._gpuFrameTimeCounter = new mr, this._measureDurationState = 0, this._device = e, this._bufferManager = t } return Object.defineProperty(e.prototype, "gpuFrameTimeCounter", { get: function () { return this._gpuFrameTimeCounter }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "enable", { get: function () { return this._enabled }, set: function (e) { this._enabled !== e && (this._enabled = e, this._measureDurationState = 0, e ? this._measureDuration = new Sf(this._device, this._bufferManager) : this._measureDuration.dispose()) }, enumerable: !1, configurable: !0 }), e.prototype.startFrame = function (e) { this._enabled && 0 === this._measureDurationState && (this._measureDuration.start(e), this._measureDurationState = 1) }, e.prototype.endFrame = function (e) { var t = this; 1 === this._measureDurationState && (this._measureDurationState = 2, this._measureDuration.stop(e).then((function (e) { null !== e && e >= 0 && (t._gpuFrameTimeCounter.fetchNewFrame(), t._gpuFrameTimeCounter.addCount(e, !0)), t._measureDurationState = 0 }))) }, e }(), Sf = function () { function e(e, t) { this._querySet = new Tf(2, Ap.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 }(), xf = function () { function e(e, t, i, r, n) { void 0 === r && (r = 50), void 0 === n && (n = 100), this._availableIndices = [], 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 }), Object.defineProperty(e.prototype, "canBeginQuery", { get: function () { switch (this._engine._getCurrentRenderPassIndex()) { case 0: return void 0 !== this._engine._mainRenderPassWrapper.renderPassDescriptor.occlusionQuerySet; case 1: return void 0 !== this._engine._rttRenderPassWrapper.renderPassDescriptor.occlusionQuerySet }return !1 }, enumerable: !1, configurable: !0 }), 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 - 1] = e }, e.prototype.isQueryResultAvailable = function (e) { return this._retrieveQueryBuffer(), !!this._lastBuffer && e < this._lastBuffer.length }, e.prototype.getQueryResult = function (e) { var t, i; return Number(null !== (i = null === (t = this._lastBuffer) || void 0 === t ? void 0 : t[e]) && void 0 !== i ? i : -1) }, e.prototype._retrieveQueryBuffer = function () { var e = this; this._lastBuffer && this._frameLastBuffer === this._engine.frameId || this._frameLastBuffer !== this._engine.frameId && (this._frameLastBuffer = this._engine.frameId, this._querySet.readValues(0, this._currentTotalIndices).then((function (t) { e._lastBuffer = t }))) }, e.prototype._allocateNewIndices = function (e) { e = null != e ? e : this._countIncrement, this._delayQuerySetDispose(); for (var t = 0; t < e; ++t)this._availableIndices.push(this._currentTotalIndices + t); this._currentTotalIndices += e, this._querySet = new Tf(this._currentTotalIndices, Ap.Occlusion, this._device, this._bufferManager, !1) }, e.prototype._delayQuerySetDispose = function () { var e = this._querySet; e && setTimeout((function () { return e.dispose }), 1e3) }, e.prototype.dispose = function () { var e; null === (e = this._querySet) || void 0 === e || e.dispose(), this._availableIndices.length = 0 }, e }(), Af = function () { function e() { } return e.prototype.initTwgsl = function (t) { return j(this, void 0, void 0, (function () { var i; return Y(this, (function (r) { switch (r.label) { case 0: return e._twgsl ? [2] : (t = t || {}, (t = H(H({}, e._TWgslDefaultOptions), t)).twgsl ? (e._twgsl = t.twgsl, [2, Promise.resolve()]) : t.jsPath && t.wasmPath ? et() ? [4, xi.LoadScriptAsync(t.jsPath)] : [3, 2] : [3, 3]); case 1: return r.sent(), [3, 3]; case 2: importScripts(t.jsPath), r.label = 3; case 3: return self.twgsl ? (i = e, [4, self.twgsl(t.wasmPath)]) : [3, 5]; case 4: return i._twgsl = r.sent(), [2, Promise.resolve()]; case 5: return [2, Promise.reject("twgsl is not available.")] } })) })) }, e.prototype.convertSpirV2WGSL = function (t, i) { void 0 === i && (i = !1); var r = e._twgsl.convertSpirV2WGSL(t); return e.ShowWGSLShaderCode && (console.log(r), console.log("***********************************************")), e.DisableUniformityAnalysis || i ? "diagnostic(off, derivative_uniformity);\n" + r : r }, e._TWgslDefaultOptions = { jsPath: "https://preview.babylonjs.com/twgsl/twgsl.js", wasmPath: "https://preview.babylonjs.com/twgsl/twgsl.wasm" }, e.ShowWGSLShaderCode = !1, e.DisableUniformityAnalysis = !1, e._twgsl = null, e }(), Rf = function () { function e(e, t, i, r) { this._record = !1, this._play = !1, this._mainPassBundleList = [], this._enabled = !1, this._engine = e, this._mode = t, this._bundleList = i, this._bundleListRenderTarget = r } return Object.defineProperty(e.prototype, "enabled", { get: function () { return this._enabled }, set: function (e) { this._mainPassBundleList.length = 0, this._record = this._enabled = e, this._play = !1, e && (this._modeSaved = this._mode, this._mode = a.SNAPSHOTRENDERING_STANDARD) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "play", { get: function () { return this._play }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "record", { get: function () { return this._record }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "mode", { get: function () { return this._mode }, set: function (e) { this._record ? this._modeSaved = e : this._mode = e }, enumerable: !1, configurable: !0 }), e.prototype.endMainRenderPass = function () { this._record && this._mainPassBundleList.push(this._bundleList.clone()) }, e.prototype.endRenderTargetPass = function (e, t) { var i, r, n, o; if (this._play) null === (r = null === (i = t._bundleLists) || void 0 === i ? void 0 : i[t._currentLayer]) || void 0 === r || r.run(e), this._mode === a.SNAPSHOTRENDERING_FAST && this._engine._reportDrawCall(null === (o = null === (n = t._bundleLists) || void 0 === n ? void 0 : n[t._currentLayer]) || void 0 === o ? void 0 : o.numDrawCalls); else { if (!this._record) return !1; t._bundleLists || (t._bundleLists = []), t._bundleLists[t._currentLayer] = this._bundleListRenderTarget.clone(), t._bundleLists[t._currentLayer].run(e), this._bundleListRenderTarget.reset() } return !0 }, e.prototype.endFrame = function (e) { if (this._record && (this._mainPassBundleList.push(this._bundleList.clone()), this._record = !1, this._play = !0, this._mode = this._modeSaved), null !== e && this._play) for (var t = 0; t < this._mainPassBundleList.length; ++t)this._mainPassBundleList[t].run(e), this._mode === a.SNAPSHOTRENDERING_FAST && this._engine._reportDrawCall(this._mainPassBundleList[t].numDrawCalls) }, e.prototype.reset = function () { this.enabled = !1, this.enabled = !0 }, e }(); Ut.ShadersStoreWGSL.postprocessVertexShader = "attribute position: vec2;uniform scale: vec2;varying vUV: vec2;const madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\n@vertex\nfn main(input : VertexInputs)->FragmentInputs {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvertexOutputs.vUV=(vertexInputs.position*madd+madd)*uniforms.scale;vertexOutputs.position=vec4(vertexInputs.position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}\n"; var Cf = { label: "TextureView_SwapChain_ResolveTarget", dimension: Kd.E2d, format: void 0, mipLevelCount: 1, arrayLayerCount: 1 }, Pf = { label: "TextureView_SwapChain", dimension: Kd.E2d, format: void 0, mipLevelCount: 1, arrayLayerCount: 1 }, If = "/* disable_uniformity_analysis */", Mf = new U, Of = 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 Kp, o._rttRenderPassWrapper = new Kp, 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(In.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 Fp, o._shaderProcessorWGSL = new Up, 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 Af : 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 < c.length; l++) { var u = c[l]; -1 !== n._adapterSupportedExtensions.indexOf(u) && s.push(u) } o.requiredFeatures = s } if (n._options.setMaximumLimits && !o.requiredLimits) for (var h in o.requiredLimits = {}, n._adapterSupportedLimits) o.requiredLimits[h] = n._adapterSupportedLimits[h]; return n._adapter.requestDevice(o) } throw "Could not retrieve a WebGPU adapter (adapter is null)." })).then((function (e) { var t, i; n._device = e, n._deviceEnabledExtensions = [], null === (t = n._device.features) || void 0 === t || t.forEach((function (e) { return n._deviceEnabledExtensions.push(e) })), n._deviceLimits = e.limits; var r = -1; n._device.addEventListener("uncapturederror", (function (e) { ++r < n.numMaxUncapturedErrors ? $.Warn("WebGPU uncaptured error (".concat(r + 1, "): ").concat(e.error, " - ").concat(e.error.message)) : r++ === n.numMaxUncapturedErrors && $.Warn("WebGPU uncaptured error: too many warnings (".concat(n.numMaxUncapturedErrors, "), no more warnings will be reported to the console for this engine.")) })), n._doNotHandleContextLost || null === (i = n._device.lost) || void 0 === i || i.then((function (e) { n._isDisposed || (n._contextWasLost = !0, $.Warn("WebGPU context lost. " + e), n.onContextLostObservable.notifyObservers(n), n._restoreEngineAfterContextLost(n.initAsync.bind(n))) })) }), (function (e) { $.Error("Could not retrieve a WebGPU device."), $.Error(e) })).then((function () { n._bufferManager = new Yp(n._device), n._textureHelper = new Xp(n._device, n._glslang, n._tintWASM, n._bufferManager, n._deviceEnabledExtensions), n._cacheSampler = new Jp(n._device), n._cacheBindGroups = new hf(n._device, n._cacheSampler, n), n._timestampQuery = new Ef(n._device, n._bufferManager), n._occlusionQuery = n._device.createQuerySet ? new xf(n, n._device, n._bufferManager) : void 0, n._bundleList = new bf(n._device), n._bundleListRenderTarget = new bf(n._device), n._snapshotRendering = new Rf(n, n._snapshotRenderingMode, n._bundleList, n._bundleListRenderTarget), n._ubInvertY = n._bufferManager.createBuffer(new Float32Array([-1, 0]), jd.Uniform | jd.CopyDst), n._ubDontInvertY = n._bufferManager.createBuffer(new Float32Array([1, 0]), jd.Uniform | jd.CopyDst), n.dbgVerboseLogsForFirstFrames && void 0 === n._count && (n._count = 0, console.log("%c frame #" + n._count + " - begin", "background: #ffff00")), n._uploadEncoder = n._device.createCommandEncoder(n._uploadEncoderDescriptor), n._renderEncoder = n._device.createCommandEncoder(n._renderEncoderDescriptor), n._renderTargetEncoder = n._device.createCommandEncoder(n._renderTargetEncoderDescriptor), n._emptyVertexBuffer = new Hi(n, [0], "", !1, !1, 1, !1, 0, 1), n._initializeLimits(), n._cacheRenderPipeline = new nf(n._device, n._emptyVertexBuffer, !n._caps.textureFloatLinearFiltering), n._depthCullingState = new af(n._cacheRenderPipeline), n._stencilStateComposer = new of(n._cacheRenderPipeline), n._stencilStateComposer.stencilGlobal = n._stencilState, n._depthCullingState.depthTest = !0, n._depthCullingState.depthFunc = a.LEQUAL, n._depthCullingState.depthMask = !0, n._textureHelper.setCommandEncoder(n._uploadEncoder), n._clearQuad = new df(n._device, n, n._emptyVertexBuffer), n._defaultDrawContext = n.createDrawContext(), n._currentDrawContext = n._defaultDrawContext, n._defaultMaterialContext = n.createMaterialContext(), n._currentMaterialContext = n._defaultMaterialContext, n._initializeContextAndSwapChain(), n._initializeMainAttachments(), n.resize() })).catch((function (e) { $.Error("Can not create WebGPU Device and/or context."), $.Error(e), console.trace && console.trace() })) }, t.prototype._initGlslang = function (e) { return e = e || {}, (e = H(H({}, t._GLSLslangDefaultOptions), e)).glslang ? Promise.resolve(e.glslang) : self.glslang ? self.glslang(e.wasmPath) : e.jsPath && e.wasmPath ? et() ? xi.LoadScriptAsync(e.jsPath).then((function () { return self.glslang(e.wasmPath) })) : (importScripts(e.jsPath), self.glslang(e.wasmPath)) : Promise.reject("gslang is not available.") }, t.prototype._initializeLimits = function () { this._caps = { maxTexturesImageUnits: this._deviceLimits.maxSampledTexturesPerShaderStage, maxVertexTextureImageUnits: this._deviceLimits.maxSampledTexturesPerShaderStage, maxCombinedTexturesImageUnits: 2 * this._deviceLimits.maxSampledTexturesPerShaderStage, maxTextureSize: this._deviceLimits.maxTextureDimension2D, maxCubemapTextureSize: this._deviceLimits.maxTextureDimension2D, maxRenderTextureSize: this._deviceLimits.maxTextureDimension2D, maxVertexAttribs: this._deviceLimits.maxVertexAttributes, maxVaryingVectors: this._deviceLimits.maxInterStageShaderVariables, maxFragmentUniformVectors: Math.floor(this._deviceLimits.maxUniformBufferBindingSize / 4), maxVertexUniformVectors: Math.floor(this._deviceLimits.maxUniformBufferBindingSize / 4), standardDerivatives: !0, astc: this._deviceEnabledExtensions.indexOf(Hd.TextureCompressionASTC) >= 0 || void 0, s3tc: this._deviceEnabledExtensions.indexOf(Hd.TextureCompressionBC) >= 0 || void 0, pvrtc: null, etc1: null, etc2: this._deviceEnabledExtensions.indexOf(Hd.TextureCompressionETC2) >= 0 || void 0, bptc: this._deviceEnabledExtensions.indexOf(Hd.TextureCompressionBC) >= 0 || void 0, maxAnisotropy: 16, uintIndices: !0, fragmentDepthSupported: !0, highPrecisionShaderSupported: !0, colorBufferFloat: !0, textureFloat: !0, textureFloatLinearFiltering: this._deviceEnabledExtensions.indexOf(Hd.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(Hd.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, _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 Vp], 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: Kd.E2d, format: this._options.swapChainFormat, usage: Qd.RenderAttachment }; this._mainTexture && this._textureHelper.releaseTexture(this._mainTexture), this._mainTexture = this._device.createTexture(i), e = [{ view: this._mainTexture.createView({ label: "TextureView_MainColor_antialiasing", dimension: Kd.E2d, format: this._options.swapChainFormat, mipLevelCount: 1, arrayLayerCount: 1 }), clearValue: new U(0, 0, 0, 1), loadOp: Sp.Clear, storeOp: xp.Store }] } else e = [{ view: void 0, clearValue: new U(0, 0, 0, 1), loadOp: Sp.Clear, storeOp: xp.Store }]; this._mainRenderPassWrapper.depthTextureFormat = this.isStencilEnable ? Jd.Depth24PlusStencil8 : Jd.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: Kd.E2d, format: this._mainRenderPassWrapper.depthTextureFormat, usage: Qd.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: Kd.E2d, format: this._depthTexture.format, mipLevelCount: 1, arrayLayerCount: 1 }), depthClearValue: this._clearDepthValue, depthLoadOp: Sp.Clear, depthStoreOp: xp.Store, stencilClearValue: this._clearStencilValue, stencilLoadOp: this.isStencilEnable ? Sp.Clear : void 0, stencilStoreOp: this.isStencilEnable ? xp.Store : void 0 }; this._mainRenderPassWrapper.renderPassDescriptor = { colorAttachments: e, depthStencilAttachment: n } } }, t.prototype._configureContext = function () { this._context.configure({ device: this._device, format: this._options.swapChainFormat, usage: Qd.RenderAttachment | Qd.CopySrc, alphaMode: this.premultipliedAlpha ? Rp.Premultiplied : Rp.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 < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - setSize called -", t, i)), this._initializeMainAttachments(), this.snapshotRendering && this.snapshotRenderingReset(), !0) }, t.prototype._getShaderProcessor = function (e) { return e === nt.WGSL ? this._shaderProcessorWGSL : this._shaderProcessor }, t.prototype._getShaderProcessingContext = function (e) { return new Np(e) }, t.prototype.applyStates = function () { this._stencilStateComposer.apply(), this._cacheRenderPipeline.setAlphaBlendEnabled(this._alphaState.alphaBlend) }, t.prototype.wipeCaches = function (e) { this.preventCacheWipeBetweenFrames && !e || (this._forceEnableEffect = !0, this._currentIndexBuffer = null, this._currentOverrideVertexBuffers = null, this._cacheRenderPipeline.setBuffers(null, null, null), e && (this._stencilStateComposer.reset(), this._depthCullingState.reset(), this._depthCullingState.depthFunc = a.LEQUAL, this._alphaState.reset(), this._alphaMode = a.ALPHA_ADD, this._alphaEquation = a.ALPHA_DISABLE, this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters, this._alphaState._blendEquationParameters), this._cacheRenderPipeline.setAlphaBlendEnabled(!1), this.setColorWrite(!0)), this._cachedVertexBuffers = null, this._cachedIndexBuffer = null, this._cachedEffectForVertexBuffers = null) }, t.prototype.setColorWrite = function (e) { this._colorWriteLocal = e, this._cacheRenderPipeline.setWriteMask(e ? 15 : 0) }, t.prototype.getColorWrite = function () { return this._colorWriteLocal }, t.prototype._resetCurrentViewport = function (e) { this._viewportsCurrent[e].x = 0, this._viewportsCurrent[e].y = 0, this._viewportsCurrent[e].w = 0, this._viewportsCurrent[e].h = 0 }, t.prototype._mustUpdateViewport = function (e) { var t = e === this._mainRenderPassWrapper.renderPass ? 0 : 1, i = this._viewportCached.x, r = this._viewportCached.y, n = this._viewportCached.z, o = this._viewportCached.w, a = this._viewportsCurrent[t].x !== i || this._viewportsCurrent[t].y !== r || this._viewportsCurrent[t].w !== n || this._viewportsCurrent[t].h !== o; return a && (this._viewportsCurrent[t].x = this._viewportCached.x, this._viewportsCurrent[t].y = this._viewportCached.y, this._viewportsCurrent[t].w = this._viewportCached.z, this._viewportsCurrent[t].h = this._viewportCached.w), a }, t.prototype._applyViewport = function (e) { var t = Math.floor(this._viewportCached.y), i = Math.floor(this._viewportCached.w); this._currentRenderTarget || (t = this.getRenderHeight(!0) - t - i), e.setViewport(Math.floor(this._viewportCached.x), t, Math.floor(this._viewportCached.z), i, 0, 1), this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0), (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - viewport applied - (", this._viewportCached.x, this._viewportCached.y, this._viewportCached.z, this._viewportCached.w, ") current pass is main pass=" + (e === this._mainRenderPassWrapper.renderPass))) }, t.prototype._viewport = function (e, t, i, r) { this._viewportCached.x = e, this._viewportCached.y = t, this._viewportCached.z = i, this._viewportCached.w = r }, t.prototype._resetCurrentScissor = function (e) { this._scissorsCurrent[e].x = 0, this._scissorsCurrent[e].y = 0, this._scissorsCurrent[e].w = 0, this._scissorsCurrent[e].h = 0 }, t.prototype._mustUpdateScissor = function (e) { var t = e === this._mainRenderPassWrapper.renderPass ? 0 : 1, i = this._scissorCached.x, r = this._scissorCached.y, n = this._scissorCached.z, o = this._scissorCached.w, a = this._scissorsCurrent[t].x !== i || this._scissorsCurrent[t].y !== r || this._scissorsCurrent[t].w !== n || this._scissorsCurrent[t].h !== o; return a && (this._scissorsCurrent[t].x = this._scissorCached.x, this._scissorsCurrent[t].y = this._scissorCached.y, this._scissorsCurrent[t].w = this._scissorCached.z, this._scissorsCurrent[t].h = this._scissorCached.w), a }, t.prototype._applyScissor = function (e) { e.setScissorRect(this._scissorCached.x, this._currentRenderTarget ? this._scissorCached.y : this.getRenderHeight() - this._scissorCached.w - this._scissorCached.y, this._scissorCached.z, this._scissorCached.w), this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0), (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - scissor applied - (", this._scissorCached.x, this._scissorCached.y, this._scissorCached.z, this._scissorCached.w, ") current pass is main pass=" + (e === this._mainRenderPassWrapper.renderPass))) }, t.prototype._scissorIsActive = function () { return 0 !== this._scissorCached.x || 0 !== this._scissorCached.y || 0 !== this._scissorCached.z || 0 !== this._scissorCached.w }, t.prototype.enableScissor = function (e, t, i, r) { this._scissorCached.x = e, this._scissorCached.y = t, this._scissorCached.z = i, this._scissorCached.w = r }, t.prototype.disableScissor = function () { this._scissorCached.x = 0, this._scissorCached.y = 0, this._scissorCached.z = 0, this._scissorCached.w = 0, this._resetCurrentScissor(0), this._resetCurrentScissor(1) }, t.prototype._resetCurrentStencilRef = function (e) { this._stencilRefsCurrent[e] = -1 }, t.prototype._mustUpdateStencilRef = function (e) { var t = e === this._mainRenderPassWrapper.renderPass ? 0 : 1, i = this._stencilStateComposer.funcRef !== this._stencilRefsCurrent[t]; return i && (this._stencilRefsCurrent[t] = this._stencilStateComposer.funcRef), i }, t.prototype._applyStencilRef = function (e) { var t; e.setStencilReference(null !== (t = this._stencilStateComposer.funcRef) && void 0 !== t ? t : 0) }, t.prototype._resetCurrentColorBlend = function (e) { this._blendColorsCurrent[e][0] = this._blendColorsCurrent[e][1] = this._blendColorsCurrent[e][2] = this._blendColorsCurrent[e][3] = null }, t.prototype._mustUpdateBlendColor = function (e) { var t = e === this._mainRenderPassWrapper.renderPass ? 0 : 1, i = this._alphaState._blendConstants, r = i[0] !== this._blendColorsCurrent[t][0] || i[1] !== this._blendColorsCurrent[t][1] || i[2] !== this._blendColorsCurrent[t][2] || i[3] !== this._blendColorsCurrent[t][3]; return r && (this._blendColorsCurrent[t][0] = i[0], this._blendColorsCurrent[t][1] = i[1], this._blendColorsCurrent[t][2] = i[2], this._blendColorsCurrent[t][3] = i[3]), r }, t.prototype._applyBlendColor = function (e) { e.setBlendConstant(this._alphaState._blendConstants) }, t.prototype.clear = function (e, t, i, r) { void 0 === r && (r = !1), e && void 0 === e.a && (e.a = 1); var n = this._scissorIsActive(); this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0), (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - clear called - backBuffer=", t, " depth=", i, " stencil=", r, " scissor is active=", n)), this._currentRenderTarget ? n ? (this._rttRenderPassWrapper.renderPass || this._startRenderTargetRenderPass(this._currentRenderTarget, !1, t ? e : null, i, r), this.compatibilityMode ? this._applyScissor(this._currentRenderPass) : this._bundleListRenderTarget.addItem(new ff(this._scissorCached.x, this._scissorCached.y, this._scissorCached.z, this._scissorCached.w)), this._clearFullQuad(t ? e : null, i, r)) : (this._currentRenderPass && this._endRenderTargetRenderPass(), this._startRenderTargetRenderPass(this._currentRenderTarget, !0, t ? e : null, i, r)) : (this._mainRenderPassWrapper.renderPass && n || this._startMainRenderPass(!n, t ? e : null, i, r), n && (this.compatibilityMode ? this._applyScissor(this._currentRenderPass) : this._bundleList.addItem(new ff(this._scissorCached.x, this._scissorCached.y, this._scissorCached.z, this._scissorCached.w)), this._clearFullQuad(t ? e : null, i, r))) }, t.prototype._clearFullQuad = function (e, t, i) { var r, n, o, a = this.compatibilityMode ? this._getCurrentRenderPass() : null, s = 0 === this._getCurrentRenderPassIndex() ? this._bundleList : this._bundleListRenderTarget; this._clearQuad.setColorFormat(this._colorFormat), this._clearQuad.setDepthStencilFormat(this._depthTextureFormat), this._clearQuad.setMRTAttachments(null !== (r = this._cacheRenderPipeline.mrtAttachments) && void 0 !== r ? r : [], null !== (n = this._cacheRenderPipeline.mrtTextureArray) && void 0 !== n ? n : [], this._cacheRenderPipeline.mrtTextureCount), this.compatibilityMode ? a.setStencilReference(this._clearStencilValue) : s.addItem(new _f(this._clearStencilValue)); var l = this._clearQuad.clear(a, e, t, i, this.currentSampleCount); this.compatibilityMode ? this._applyStencilRef(a) : (s.addBundle(l), s.addItem(new _f(null !== (o = this._stencilStateComposer.funcRef) && void 0 !== o ? o : 0)), this._reportDrawCall()) }, t.prototype.createVertexBuffer = function (e) { var t; return t = e instanceof Array ? new Float32Array(e) : e instanceof ArrayBuffer ? new Uint8Array(e) : e, this._bufferManager.createBuffer(t, jd.Vertex | jd.CopyDst) }, t.prototype.createDynamicVertexBuffer = function (e) { return this.createVertexBuffer(e) }, t.prototype.createIndexBuffer = function (e) { var t, i = !0; e instanceof Uint32Array || e instanceof Int32Array ? t = e : e instanceof Uint16Array ? (t = e, i = !1) : e.length > 65535 ? t = new Uint32Array(e) : (t = new Uint16Array(e), i = !1); var r = this._bufferManager.createBuffer(t, jd.Index | jd.CopyDst); return r.is32Bits = i, r }, t.prototype._createBuffer = function (e, t) { var i; i = e instanceof Array ? new Float32Array(e) : e instanceof ArrayBuffer ? new Uint8Array(e) : e; var r = 0; return t & a.BUFFER_CREATIONFLAG_READ && (r |= jd.CopySrc), t & a.BUFFER_CREATIONFLAG_WRITE && (r |= jd.CopyDst), t & a.BUFFER_CREATIONFLAG_UNIFORM && (r |= jd.Uniform), t & a.BUFFER_CREATIONFLAG_VERTEX && (r |= jd.Vertex), t & a.BUFFER_CREATIONFLAG_INDEX && (r |= jd.Index), t & a.BUFFER_CREATIONFLAG_STORAGE && (r |= jd.Storage), this._bufferManager.createBuffer(i, r) }, t.prototype.bindBuffersDirectly = function () { throw "Not implemented on WebGPU" }, t.prototype.updateAndBindInstancesBuffer = function () { throw "Not implemented on WebGPU" }, t.prototype.bindBuffers = function (e, t, i, r) { this._currentIndexBuffer = t, this._currentOverrideVertexBuffers = null != r ? r : null, this._cacheRenderPipeline.setBuffers(e, t, this._currentOverrideVertexBuffers) }, t.prototype._releaseBuffer = function (e) { return this._bufferManager.releaseBuffer(e) }, t.prototype.createEffect = function (e, t, i, r, n, o, a, s, l, c) { var u; void 0 === c && (c = nt.GLSL); var h = e.vertexElement || e.vertex || e.vertexToken || e.vertexSource || e, d = e.fragmentElement || e.fragment || e.fragmentToken || e.fragmentSource || e, p = this._getGlobalDefines(), f = null !== (u = null != n ? n : t.defines) && void 0 !== u ? u : ""; p && (f += "\n" + p); var _ = h + "+" + d + "@" + f; if (this._compiledEffects[_]) { var m = this._compiledEffects[_]; return a && m.isReady() && a(m), m } var g = new Vt(e, t, i, r, this, n, o, a, s, l, _, c); return this._compiledEffects[_] = g, g }, t.prototype._compileRawShaderToSpirV = function (e, t) { return this._glslang.compileGLSL(e, t) }, t.prototype._compileShaderToSpirV = function (e, t, i, r) { return this._compileRawShaderToSpirV(r + (i ? i + "\n" : "") + e, t) }, t.prototype._getWGSLShader = function (e, t, i) { return (i = i ? "//" + i.split("\n").join("\n//") + "\n" : "") + e }, t.prototype._createPipelineStageDescriptor = function (e, t, i, r, n) { return this._tintWASM && i === nt.GLSL && (e = this._tintWASM.convertSpirV2WGSL(e, r), t = this._tintWASM.convertSpirV2WGSL(t, n)), { vertexStage: { module: this._device.createShaderModule({ code: e }), entryPoint: "main" }, fragmentStage: { module: this._device.createShaderModule({ code: t }), entryPoint: "main" } } }, t.prototype._compileRawPipelineStageDescriptor = function (e, t, i) { var r = e.indexOf(If) >= 0, n = t.indexOf(If) >= 0, o = i === nt.GLSL ? this._compileRawShaderToSpirV(e, "vertex") : e, a = i === nt.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(If) >= 0, o = t.indexOf(If) >= 0, a = "#version 450\n", s = r === nt.GLSL ? this._compileShaderToSpirV(e, "vertex", i, a) : this._getWGSLShader(e, "vertex", i), l = r === nt.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 Nd(e); return t.debug = !1, t.processCode(), t.code }, t.prototype.createPipelineContext = function (e) { return new Op(e, this) }, t.prototype.createMaterialContext = function () { return new lf }, t.prototype.createDrawContext = function () { return new cf(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; n < t.length; n++) { var o = t[n], a = r.shaderProcessingContext.availableAttributes[o]; void 0 !== a && (i[n] = a) } return i }, t.prototype.enableEffect = function (e) { if (e) { var t = !0; if (Jt.IsWrapper(e)) { if (!e.effect || e.effect === this._currentEffect && e.materialContext === this._currentMaterialContext && e.drawContext === this._currentDrawContext && !this._forceEnableEffect) { if (!e.effect && this.dbgShowEmptyEnableEffectCalls) throw console.error("drawWrapper=", e), "Invalid call to enableEffect: the effect property is empty!"; return } if (t = e.effect !== this._currentEffect, this._currentEffect = e.effect, this._currentMaterialContext = e.materialContext, this._currentDrawContext = e.drawContext, this._counters.numEnableDrawWrapper++, !this._currentMaterialContext) throw console.error("drawWrapper=", e), "Invalid call to enableEffect: the materialContext property is empty!" } else t = e !== this._currentEffect, this._currentEffect = e, this._currentMaterialContext = this._defaultMaterialContext, this._currentDrawContext = this._defaultDrawContext, this._counters.numEnableEffects++, this.dbgLogIfNotDrawWrapper && $.Warn("enableEffect has been called with an Effect and not a Wrapper! effect.uniqueId=".concat(e.uniqueId, ", effect.name=").concat(e.name, ", effect.name.vertex=").concat(e.name.vertex, ", effect.name.fragment=").concat(e.name.fragment), 10); this._stencilStateComposer.stencilMaterial = void 0, this._forceEnableEffect = !t && !this._forceEnableEffect && this._forceEnableEffect, t && (this._currentEffect.onBind && this._currentEffect.onBind(this._currentEffect), this._currentEffect._onBindObservable && this._currentEffect._onBindObservable.notifyObservers(this._currentEffect)) } }, t.prototype._releaseEffect = function (e) { this._compiledEffects[e._key] && (delete this._compiledEffects[e._key], this._deletePipelineContext(e.getPipelineContext())) }, t.prototype.releaseEffects = function () { for (var e in this._compiledEffects) { var t = this._compiledEffects[e].getPipelineContext(); this._deletePipelineContext(t) } this._compiledEffects = {} }, t.prototype._deletePipelineContext = function (e) { e && e.dispose() }, Object.defineProperty(t.prototype, "needPOTTextures", { get: function () { return !1 }, enumerable: !1, configurable: !0 }), t.prototype._createHardwareTexture = function () { return new Vp }, t.prototype._releaseTexture = function (e) { var t = this._internalTexturesCache.indexOf(e); -1 !== t && this._internalTexturesCache.splice(t, 1), this._textureHelper.releaseTexture(e) }, t.prototype._getRGBABufferInternalSizedFormat = function () { return a.TEXTUREFORMAT_RGBA }, t.prototype.updateTextureComparisonFunction = function (e, t) { e._comparisonFunction = t }, t.prototype._createInternalTexture = function (e, t, i, r) { var n, o, s; void 0 === i && (i = !0), void 0 === r && (r = It.Unknown); var l = {}; void 0 !== t && "object" == typeof t ? (l.generateMipMaps = t.generateMipMaps, l.type = void 0 === t.type ? a.TEXTURETYPE_UNSIGNED_INT : t.type, l.samplingMode = void 0 === t.samplingMode ? a.TEXTURE_TRILINEAR_SAMPLINGMODE : t.samplingMode, l.format = void 0 === t.format ? a.TEXTUREFORMAT_RGBA : t.format, l.samples = null !== (n = t.samples) && void 0 !== n ? n : 1, l.creationFlags = null !== (o = t.creationFlags) && void 0 !== o ? o : 0, l.useSRGBBuffer = null !== (s = t.useSRGBBuffer) && void 0 !== s && s, l.label = t.label) : (l.generateMipMaps = t, l.type = a.TEXTURETYPE_UNSIGNED_INT, l.samplingMode = a.TEXTURE_TRILINEAR_SAMPLINGMODE, l.format = a.TEXTUREFORMAT_RGBA, l.samples = 1, l.creationFlags = 0, l.useSRGBBuffer = !1), (l.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (l.type !== a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (l.samplingMode = a.TEXTURE_NEAREST_SAMPLINGMODE), l.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloat || (l.type = a.TEXTURETYPE_UNSIGNED_INT, $.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE")); var c = new Ht(this, r), u = e.width || e, h = e.height || e, d = e.layers || 0; return c.baseWidth = u, c.baseHeight = h, c.width = u, c.height = h, c.depth = d, c.isReady = !0, c.samples = l.samples, c.generateMipMaps = !!l.generateMipMaps, c.samplingMode = l.samplingMode, c.type = l.type, c.format = l.format, c.is2DArray = d > 0, 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, a, s) { var l, c = r; if (e.baseWidth = c.width, e.baseHeight = c.height, e.width = c.width, e.height = c.height, e.format = null != u ? u : -1, s(e.width, e.height, c, t, e, (function () { })), null === (l = e._hardwareTexture) || void 0 === l ? void 0 : l.underlyingResource) o || a || m._generateMipmaps(e, m._uploadEncoder); else { var h = m._textureHelper.createGPUTextureForInternalTexture(e, c.width, c.height, void 0, f); Xp.IsImageBitmap(c) && (m._textureHelper.updateTexture(c, e, c.width, c.height, e.depth, h.format, 0, 0, n, !1, 0, 0), o || a || m._generateMipmaps(e, m._uploadEncoder)) } i && i.removePendingData(e), e.isReady = !0, e.onLoadedObservable.notifyObservers(e), e.onLoadedObservable.clear() }), (function () { return !1 }), l, c, u, h, d, p, _) }, t.prototype.wrapWebGPUTexture = function (e) { var t = new Vp(e), i = new Ht(this, It.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 === It.RenderTarget || e.source === It.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 + Mp.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; n < i.length; n++)this._setTexture(-1, i[n], !0, !1, r + n.toString(), r) }, t.prototype._setTexture = function (e, t, i, r, n, o) { if (void 0 === i && (i = !1), void 0 === r && (r = !1), void 0 === n && (n = ""), o = null != o ? o : n, this._currentEffect) { if (!t) return this._currentMaterialContext.setTexture(n, null), !1; if (t.video) t.update(); else if (t.delayLoadState === a.DELAYLOADSTATE_NOTLOADED) return t.delayLoad(), !1; var s = null; if ((s = r ? t.depthStencilTexture : t.isReady() ? t.getInternalTexture() : t.isCube ? this.emptyCubeTexture : t.is3D ? this.emptyTexture3D : t.is2DArray ? this.emptyTexture2DArray : this.emptyTexture) && !s.isMultiview) { if (s.isCube && s._cachedCoordinatesMode !== t.coordinatesMode) { s._cachedCoordinatesMode = t.coordinatesMode; var l = t.coordinatesMode !== a.TEXTURE_CUBIC_MODE && t.coordinatesMode !== a.TEXTURE_SKYBOX_MODE ? a.TEXTURE_WRAP_ADDRESSMODE : a.TEXTURE_CLAMP_ADDRESSMODE; t.wrapU = l, t.wrapV = l } s._cachedWrapU = t.wrapU, s._cachedWrapV = t.wrapV, s.is3D && (s._cachedWrapR = t.wrapR), this._setAnisotropicLevel(0, s, t.anisotropicFilteringLevel) } this._setInternalTexture(n, s, o) } else this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0), (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - _setTexture called with a null _currentEffect! texture=", t)); return !0 }, t.prototype._setAnisotropicLevel = function (e, t, i) { t._cachedAnisotropicFilteringLevel !== i && (t._cachedAnisotropicFilteringLevel = Math.min(i, this._caps.maxAnisotropy)) }, t.prototype._bindTexture = function (e, t, i) { void 0 !== e && this._setInternalTexture(i, t) }, t.prototype.generateMipmaps = function (e) { this._generateMipmaps(e, this._renderTargetEncoder) }, t.prototype._generateMipmaps = function (e, t) { var i = e._hardwareTexture; if (i) { t = null != t ? t : this._currentRenderTarget && !this._currentRenderPass ? this._renderTargetEncoder : this._currentRenderPass ? this._uploadEncoder : this._renderEncoder; var r = e._hardwareTexture.format, n = Xp.ComputeNumMipmapLevels(e.width, e.height); this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0), (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - generate mipmaps called - width=", e.width, "height=", e.height, "isCube=", e.isCube)), e.isCube ? this._textureHelper.generateCubeMipmaps(i, r, n, t) : this._textureHelper.generateMipmaps(i, r, n, 0, t) } }, t.prototype.updateTextureData = function (e, t, i, r, n, o, a, s, l) { var c; void 0 === a && (a = 0), void 0 === s && (s = 0), void 0 === l && (l = !1); var u = e._hardwareTexture; (null === (c = e._hardwareTexture) || void 0 === c ? void 0 : c.underlyingResource) || (u = this._textureHelper.createGPUTextureForInternalTexture(e)); var h = new Uint8Array(t.buffer, t.byteOffset, t.byteLength); this._textureHelper.updateTexture(h, e, n, o, e.depth, u.format, a, s, e.invertY, !1, i, r), l && this._generateMipmaps(e, this._renderTargetEncoder) }, t.prototype._uploadCompressedDataToTextureDirectly = function (e, t, i, r, n, o, a) { var s; void 0 === o && (o = 0), void 0 === a && (a = 0); var l = e._hardwareTexture; (null === (s = e._hardwareTexture) || void 0 === s ? void 0 : s.underlyingResource) || (e.format = t, l = this._textureHelper.createGPUTextureForInternalTexture(e, i, r)); var c = new Uint8Array(n.buffer, n.byteOffset, n.byteLength); this._textureHelper.updateTexture(c, e, i, r, e.depth, l.format, o, a, !1, !1, 0, 0) }, t.prototype._uploadDataToTextureDirectly = function (e, t, i, r, n, o) { var a; void 0 === i && (i = 0), void 0 === r && (r = 0), void 0 === o && (o = !1); var s = Math.round(Math.log(e.width) * Math.LOG2E), l = Math.round(Math.log(e.height) * Math.LOG2E), c = o ? e.width : Math.pow(2, Math.max(s - r, 0)), u = o ? e.height : Math.pow(2, Math.max(l - r, 0)), h = e._hardwareTexture; (null === (a = e._hardwareTexture) || void 0 === a ? void 0 : a.underlyingResource) || (h = this._textureHelper.createGPUTextureForInternalTexture(e, c, u)); var d = new Uint8Array(t.buffer, t.byteOffset, t.byteLength); this._textureHelper.updateTexture(d, e, c, u, e.depth, h.format, i, r, e.invertY, !1, 0, 0) }, t.prototype._uploadArrayBufferViewToTexture = function (e, t, i, r) { void 0 === i && (i = 0), void 0 === r && (r = 0), this._uploadDataToTextureDirectly(e, t, i, r) }, t.prototype._uploadImageToTexture = function (e, t, i, r) { var n; void 0 === i && (i = 0), void 0 === r && (r = 0); var o = e._hardwareTexture; if ((null === (n = e._hardwareTexture) || void 0 === n ? void 0 : n.underlyingResource) || (o = this._textureHelper.createGPUTextureForInternalTexture(e)), t instanceof HTMLImageElement) throw "WebGPU engine: HTMLImageElement not supported in _uploadImageToTexture!"; var a = t, s = Math.ceil(e.width / (1 << r)), l = Math.ceil(e.height / (1 << r)); this._textureHelper.updateTexture(a, e, s, l, e.depth, o.format, i, r, e.invertY, !1, 0, 0) }, t.prototype.readPixels = function (e, t, i, r, n, o) { void 0 === n && (n = !0), void 0 === o && (o = !0); var a = (this._rttRenderPassWrapper.renderPass ? this._rttRenderPassWrapper : this._mainRenderPassWrapper).colorAttachmentGPUTextures[0]; if (!a) return Promise.resolve(new Uint8Array(0)); var s = a.underlyingResource, l = a.format; return s ? (o && this.flushFramebuffer(), this._textureHelper.readPixels(s, e, t, i, r, l)) : Promise.resolve(new Uint8Array(0)) }, t.prototype.beginFrame = function () { e.prototype.beginFrame.call(this) }, t.prototype.endFrame = function () { if (this._snapshotRendering.endFrame(this._mainRenderPassWrapper.renderPass), this._endMainRenderPass(), this._timestampQuery.endFrame(this._renderEncoder), this.flushFramebuffer(!1), this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0), (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - counters")), this._textureHelper.destroyDeferredTextures(), this._bufferManager.destroyDeferredBuffers(), this._features._collectUbosUpdatedInFrame) { if (this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0), !this._count || this._count < this.dbgVerboseLogsNumFrames)) { var t = []; for (var i in zi._UpdatedUbosInFrame) t.push(i + ":" + zi._UpdatedUbosInFrame[i]); console.log("frame #" + this._count + " - updated ubos -", t.join(", ")) } zi._UpdatedUbosInFrame = {} } this.countersLastFrame.numEnableEffects = this._counters.numEnableEffects, this.countersLastFrame.numEnableDrawWrapper = this._counters.numEnableDrawWrapper, this.countersLastFrame.numBundleCreationNonCompatMode = this._counters.numBundleCreationNonCompatMode, this.countersLastFrame.numBundleReuseNonCompatMode = this._counters.numBundleReuseNonCompatMode, this._counters.numEnableEffects = 0, this._counters.numEnableDrawWrapper = 0, this._counters.numBundleCreationNonCompatMode = 0, this._counters.numBundleReuseNonCompatMode = 0, this._cacheRenderPipeline.endFrame(), this._cacheBindGroups.endFrame(), this._pendingDebugCommands.length = 0, e.prototype.endFrame.call(this), this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0), this._count < this.dbgVerboseLogsNumFrames && console.log("%c frame #" + this._count + " - end", "background: #ffff00"), this._count < this.dbgVerboseLogsNumFrames && (this._count++, this._count !== this.dbgVerboseLogsNumFrames && console.log("%c frame #" + this._count + " - begin", "background: #ffff00"))) }, t.prototype.flushFramebuffer = function (e) { void 0 === e && (e = !0); var t = !this._currentRenderPass, i = 0; this._currentRenderPass && this._currentRenderTarget && (i |= 1, this._endRenderTargetRenderPass()), this._mainRenderPassWrapper.renderPass && (i |= 2, this._endMainRenderPass()), this._commandBuffers[0] = this._uploadEncoder.finish(), this._commandBuffers[1] = this._renderTargetEncoder.finish(), this._commandBuffers[2] = this._renderEncoder.finish(), this._device.queue.submit(this._commandBuffers), this._uploadEncoder = this._device.createCommandEncoder(this._uploadEncoderDescriptor), this._renderEncoder = this._device.createCommandEncoder(this._renderEncoderDescriptor), this._renderTargetEncoder = this._device.createCommandEncoder(this._renderTargetEncoderDescriptor), this._timestampQuery.startFrame(this._uploadEncoder), this._textureHelper.setCommandEncoder(this._uploadEncoder), this._bundleList.reset(), this._bundleListRenderTarget.reset(), e && (2 & i && this._startMainRenderPass(!1), 1 & i && this._startRenderTargetRenderPass(this._currentRenderTarget, !1, null, !1, !1), t && this._currentRenderTarget && (this._currentRenderPass = null)) }, t.prototype._currentFrameBufferIsDefaultFrameBuffer = function () { return null === this._currentRenderTarget }, t.prototype._startRenderTargetRenderPass = function (e, t, i, r, n) { var o, s, l, c, u, h, d, p = e, f = p._depthStencilTexture, _ = null == f ? void 0 : f._hardwareTexture, m = null == _ ? void 0 : _.underlyingResource, g = null == _ ? void 0 : _.getMSAATexture(), v = null == m ? void 0 : m.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor), y = null == g ? void 0 : g.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor), b = !!_ && Xp.HasStencilAspect(_.format), T = []; this.useReverseDepthBuffer && this.setDepthFunctionToGreaterOrEqual(); var E = Mf; i && (E.r = 255 * i.r, E.g = 255 * i.g, E.b = 255 * i.b, E.a = 255 * i.a); var S = t && i, x = t && r, A = t && n; if (p._attachments && p.isMulti) { this._mrtAttachments && 0 !== this._mrtAttachments.length || (this._mrtAttachments = p._defaultAttachments); for (var R = 0; R < this._mrtAttachments.length; ++R) { var C = this._mrtAttachments[R], P = p.textures[R], I = null == P ? void 0 : P._hardwareTexture, M = null == I ? void 0 : I.underlyingResource; if (I && M) { var O = I.getMSAATexture(R), D = null !== (s = null === (o = p.layerIndices) || void 0 === o ? void 0 : o[R]) && void 0 !== s ? s : 0, N = null !== (c = null === (l = p.faceIndices) || void 0 === l ? void 0 : l[R]) && void 0 !== c ? c : 0, F = H(H({}, this._rttRenderPassWrapper.colorAttachmentViewDescriptor), { format: I.format, baseArrayLayer: P.isCube ? 6 * D + N : D }), L = H(H({}, this._rttRenderPassWrapper.colorAttachmentViewDescriptor), { format: I.format, baseArrayLayer: 0 }), w = P.type === a.TEXTURETYPE_UNSIGNED_INTEGER || P.type === a.TEXTURETYPE_UNSIGNED_SHORT, B = M.createView(F), U = null == O ? void 0 : O.createView(L); T.push({ view: U || B, resolveTarget: O ? B : void 0, clearValue: 0 !== C && S ? w ? E : i : void 0, loadOp: 0 !== C && S ? Sp.Clear : Sp.Load, storeOp: xp.Store }) } } this._cacheRenderPipeline.setMRT(p.textures, this._mrtAttachments.length), this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments) } else if (G = p.texture) { var V = G._hardwareTexture, k = V.underlyingResource; O = V.getMSAATexture(), B = k.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor), U = null == O ? void 0 : O.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor), w = G.type === a.TEXTURETYPE_UNSIGNED_INTEGER || G.type === a.TEXTURETYPE_UNSIGNED_SHORT, T.push({ view: U || B, resolveTarget: O ? B : void 0, clearValue: S ? w ? E : i : void 0, loadOp: S ? Sp.Clear : Sp.Load, storeOp: xp.Store }) } else T.push(null); if (null === (u = this._debugPushGroup) || void 0 === u || u.call(this, "render target pass", 1), this._rttRenderPassWrapper.renderPassDescriptor = { colorAttachments: T, depthStencilAttachment: f && m ? { view: y || v, depthClearValue: x ? this.useReverseDepthBuffer ? this._clearReverseDepthValue : this._clearDepthValue : void 0, depthLoadOp: x ? Sp.Clear : Sp.Load, depthStoreOp: xp.Store, stencilClearValue: p._depthStencilTextureWithStencil && A ? this._clearStencilValue : void 0, stencilLoadOp: b ? p._depthStencilTextureWithStencil && A ? Sp.Clear : Sp.Load : void 0, stencilStoreOp: b ? xp.Store : void 0 } : void 0, occlusionQuerySet: (null === (h = this._occlusionQuery) || void 0 === h ? void 0 : h.hasQueries) ? this._occlusionQuery.querySet : void 0 }, this._rttRenderPassWrapper.renderPass = this._renderTargetEncoder.beginRenderPass(this._rttRenderPassWrapper.renderPassDescriptor), this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0), !this._count || this._count < this.dbgVerboseLogsNumFrames)) { var G = p.texture; console.log("frame #" + this._count + " - render target begin pass - internalTexture.uniqueId=", G.uniqueId, "width=", G.width, "height=", G.height, this._rttRenderPassWrapper.renderPassDescriptor) } this._currentRenderPass = this._rttRenderPassWrapper.renderPass, null === (d = this._debugFlushPendingCommands) || void 0 === d || d.call(this), this._resetCurrentViewport(1), this._resetCurrentScissor(1), this._resetCurrentStencilRef(1), this._resetCurrentColorBlend(1), _ && Xp.HasStencilAspect(_.format) || (this._stencilStateComposer.enabled = !1) }, t.prototype._endRenderTargetRenderPass = function () { var e, t, i, r; if (this._currentRenderPass) { var n = null === (e = this._currentRenderTarget.texture) || void 0 === e ? void 0 : e._hardwareTexture; !n || this._snapshotRendering.endRenderTargetPass(this._currentRenderPass, n) || this.compatibilityMode || (this._bundleListRenderTarget.run(this._currentRenderPass), this._bundleListRenderTarget.reset()), this._currentRenderPass.end(), this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0), (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - render target end pass - internalTexture.uniqueId=", null === (i = null === (t = this._currentRenderTarget) || void 0 === t ? void 0 : t.texture) || void 0 === i ? void 0 : i.uniqueId)), null === (r = this._debugPopGroup) || void 0 === r || r.call(this, 1), this._resetCurrentViewport(1), this._viewport(0, 0, 0, 0), this._resetCurrentScissor(1), this._resetCurrentStencilRef(1), this._resetCurrentColorBlend(1), this._currentRenderPass = null, this._rttRenderPassWrapper.reset() } }, t.prototype._getCurrentRenderPass = function () { return this._currentRenderTarget && !this._currentRenderPass ? this._startRenderTargetRenderPass(this._currentRenderTarget, !1, null, !1, !1) : this._currentRenderPass || this._startMainRenderPass(!1), this._currentRenderPass }, t.prototype._getCurrentRenderPassIndex = function () { return null === this._currentRenderPass ? -1 : this._currentRenderPass === this._mainRenderPassWrapper.renderPass ? 0 : 1 }, t.prototype._startMainRenderPass = function (e, t, i, r) { var n, o, a; this._mainRenderPassWrapper.renderPass && this.flushFramebuffer(!1), this.useReverseDepthBuffer && this.setDepthFunctionToGreaterOrEqual(); var s = e && t, l = e && i, c = e && r; this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].clearValue = s ? t : void 0, this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].loadOp = s ? Sp.Clear : Sp.Load, this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.depthClearValue = l ? this.useReverseDepthBuffer ? this._clearReverseDepthValue : this._clearDepthValue : void 0, this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.depthLoadOp = l ? Sp.Clear : Sp.Load, this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.stencilClearValue = c ? this._clearStencilValue : void 0, this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.stencilLoadOp = this.isStencilEnable ? c ? Sp.Clear : Sp.Load : void 0, this._mainRenderPassWrapper.renderPassDescriptor.occlusionQuerySet = (null === (n = this._occlusionQuery) || void 0 === n ? void 0 : n.hasQueries) ? this._occlusionQuery.querySet : void 0; var u = this._context.getCurrentTexture(); this._mainRenderPassWrapper.colorAttachmentGPUTextures[0].set(u), this._options.antialias ? (Cf.format = u.format, this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].resolveTarget = u.createView(Cf)) : (Pf.format = u.format, this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].view = u.createView(Pf)), this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0), (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - main begin pass - texture width=" + this._mainTextureExtends.width, " height=" + this._mainTextureExtends.height, this._mainRenderPassWrapper.renderPassDescriptor)), null === (o = this._debugPushGroup) || void 0 === o || o.call(this, "main pass", 0), this._currentRenderPass = this._renderEncoder.beginRenderPass(this._mainRenderPassWrapper.renderPassDescriptor), this._mainRenderPassWrapper.renderPass = this._currentRenderPass, null === (a = this._debugFlushPendingCommands) || void 0 === a || a.call(this), this._resetCurrentViewport(0), this._resetCurrentScissor(0), this._resetCurrentStencilRef(0), this._resetCurrentColorBlend(0), this._isStencilEnable || (this._stencilStateComposer.enabled = !1) }, t.prototype._endMainRenderPass = function () { var e; null !== this._mainRenderPassWrapper.renderPass && (this._snapshotRendering.endMainRenderPass(), this.compatibilityMode || this._snapshotRendering.play || (this._bundleList.run(this._mainRenderPassWrapper.renderPass), this._bundleList.reset()), this._mainRenderPassWrapper.renderPass.end(), this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0), (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - main end pass")), null === (e = this._debugPopGroup) || void 0 === e || e.call(this, 0), this._resetCurrentViewport(0), this._resetCurrentScissor(0), this._resetCurrentStencilRef(0), this._resetCurrentColorBlend(0), this._mainRenderPassWrapper.renderPass === this._currentRenderPass && (this._currentRenderPass = null), this._mainRenderPassWrapper.reset(!1)) }, t.prototype.bindFramebuffer = function (e, t, i, r, n, o, s) { var l, c; void 0 === t && (t = 0), void 0 === o && (o = 0), void 0 === s && (s = 0); var u = null === (l = e.texture) || void 0 === l ? void 0 : l._hardwareTexture; this._currentRenderTarget && this.unBindFramebuffer(this._currentRenderTarget), this._currentRenderTarget = e, u && (u._currentLayer = e.isCube ? 6 * s + t : s), this._rttRenderPassWrapper.colorAttachmentGPUTextures[0] = u, this._rttRenderPassWrapper.depthTextureFormat = this._currentRenderTarget._depthStencilTexture ? Xp.GetWebGPUTextureFormat(-1, this._currentRenderTarget._depthStencilTexture.format) : void 0, this._setDepthTextureFormat(this._rttRenderPassWrapper), this._setColorFormat(this._rttRenderPassWrapper), this._rttRenderPassWrapper.colorAttachmentViewDescriptor = { format: this._colorFormat, dimension: qd.E2d, mipLevelCount: 1, baseArrayLayer: e.isCube ? 6 * s + t : s, baseMipLevel: o, arrayLayerCount: 1, aspect: Zd.All }, this._rttRenderPassWrapper.depthAttachmentViewDescriptor = { format: this._depthTextureFormat, dimension: qd.E2d, mipLevelCount: 1, baseArrayLayer: e.isCube ? 6 * s + t : s, baseMipLevel: 0, arrayLayerCount: 1, aspect: Zd.All }, this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0), (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - bindFramebuffer called - internalTexture.uniqueId=", null === (c = e.texture) || void 0 === c ? void 0 : c.uniqueId, "face=", t, "lodLevel=", o, "layer=", s, this._rttRenderPassWrapper.colorAttachmentViewDescriptor, this._rttRenderPassWrapper.depthAttachmentViewDescriptor)), this._currentRenderPass = null, this.snapshotRendering && this.snapshotRenderingMode === a.SNAPSHOTRENDERING_FAST && this._getCurrentRenderPass(), 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() }, t.prototype.unBindFramebuffer = function (e, t, i) { var r, n; void 0 === t && (t = !1); var o = this._currentRenderTarget; this._currentRenderTarget = null, i && i(), this._currentRenderTarget = o, this._currentRenderPass && this._currentRenderPass !== this._mainRenderPassWrapper.renderPass && this._endRenderTargetRenderPass(), !(null === (r = e.texture) || void 0 === r ? void 0 : r.generateMipMaps) || t || e.isCube || this._generateMipmaps(e.texture), this._currentRenderTarget = null, this._onAfterUnbindFrameBufferObservable.notifyObservers(this), this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0), (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - unBindFramebuffer called - internalTexture.uniqueId=", null === (n = e.texture) || void 0 === n ? void 0 : n.uniqueId)), this._mrtAttachments = [], this._cacheRenderPipeline.setMRT([]), this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments), this._currentRenderPass = this._mainRenderPassWrapper.renderPass, this._setDepthTextureFormat(this._mainRenderPassWrapper), this._setColorFormat(this._mainRenderPassWrapper) }, t.prototype.restoreDefaultFramebuffer = function () { this._currentRenderTarget ? this.unBindFramebuffer(this._currentRenderTarget) : (this._currentRenderPass = this._mainRenderPassWrapper.renderPass, this._setDepthTextureFormat(this._mainRenderPassWrapper), this._setColorFormat(this._mainRenderPassWrapper)), this._currentRenderPass && this._cachedViewport && this.setViewport(this._cachedViewport), this.wipeCaches() }, t.prototype._setColorFormat = function (e) { var t, i, r = null !== (i = null === (t = e.colorAttachmentGPUTextures[0]) || void 0 === t ? void 0 : t.format) && void 0 !== i ? i : null; this._cacheRenderPipeline.setColorFormat(r), this._colorFormat !== r && (this._colorFormat = r) }, t.prototype._setDepthTextureFormat = function (e) { this._cacheRenderPipeline.setDepthStencilFormat(e.depthTextureFormat), this._depthTextureFormat !== e.depthTextureFormat && (this._depthTextureFormat = e.depthTextureFormat) }, t.prototype.setDitheringState = function () { }, t.prototype.setRasterizerState = function () { }, t.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 ? 1 : 2; (this._depthCullingState.cullFace !== c || i) && (this._depthCullingState.cullFace = c), this.setZOffset(t), this.setZOffsetUnits(a); var u = r ? this._currentRenderTarget ? 1 : 2 : this._currentRenderTarget ? 2 : 1; (this._depthCullingState.frontFace !== u || i) && (this._depthCullingState.frontFace = u), this._stencilStateComposer.stencilMaterial = o }, t.prototype._applyRenderPassChanges = function (e, t) { var i, r = this._mustUpdateViewport(e), n = this._mustUpdateScissor(e), o = !!this._stencilStateComposer.enabled && this._mustUpdateStencilRef(e), a = !!this._alphaState.alphaBlend && this._mustUpdateBlendColor(e); t ? (r && t.addItem(new pf(this._viewportCached.x, this._viewportCached.y, this._viewportCached.z, this._viewportCached.w)), n && t.addItem(new ff(this._scissorCached.x, this._scissorCached.y, this._scissorCached.z, this._scissorCached.w)), o && t.addItem(new _f(null !== (i = this._stencilStateComposer.funcRef) && void 0 !== i ? i : 0)), a && t.addItem(new mf(this._alphaState._blendConstants.slice()))) : (r && this._applyViewport(e), n && this._applyScissor(e), o && this._applyStencilRef(e), a && this._applyBlendColor(e)) }, t.prototype._draw = function (e, t, i, r, n) { var o, s = this._getCurrentRenderPass(), l = 0 === this._getCurrentRenderPassIndex() ? this._bundleList : this._bundleListRenderTarget; this.applyStates(); var c = this._currentEffect._pipelineContext; if (this.bindUniformBufferBase(this._currentRenderTarget ? this._ubInvertY : this._ubDontInvertY, 0, Mp.InternalsUBOName), c.uniformBuffer && (c.uniformBuffer.update(), this.bindUniformBufferBase(c.uniformBuffer.getBuffer(), 0, Mp.LeftOvertUBOName)), this._snapshotRendering.play) this._reportDrawCall(); else { !this.compatibilityMode && (this._currentDrawContext.isDirty(this._currentMaterialContext.updateId) || this._currentMaterialContext.isDirty || this._currentMaterialContext.forceBindGroupCreation) && (this._currentDrawContext.fastBundle = void 0); var u = s; if (!this.compatibilityMode && this._currentDrawContext.fastBundle || this._snapshotRendering.record) { if (this._applyRenderPassChanges(s, l), !this._snapshotRendering.record) return this._counters.numBundleReuseNonCompatMode++, this._currentDrawContext.indirectDrawBuffer && this._currentDrawContext.setIndirectData(r, n || 1, i), l.addBundle(this._currentDrawContext.fastBundle), void this._reportDrawCall(); u = l.getBundleEncoder(this._cacheRenderPipeline.colorFormats, this._depthTextureFormat, this.currentSampleCount), l.numDrawCalls++ } var h = 0; if (!this._caps.textureFloatLinearFiltering && this._currentMaterialContext.hasFloatTextures) for (var d = 1, p = 0; p < c.shaderProcessingContext.textureNames.length; ++p) { var f = c.shaderProcessingContext.textureNames[p], _ = null === (o = this._currentMaterialContext.textures[f]) || void 0 === o ? void 0 : o.texture; (null == _ ? void 0 : _.type) === a.TEXTURETYPE_FLOAT && (h |= d), d <<= 1 } this._currentMaterialContext.textureState = h; var m = this._cacheRenderPipeline.getRenderPipeline(t, this._currentEffect, this.currentSampleCount, h), g = this._cacheBindGroups.getBindGroups(c, this._currentDrawContext, this._currentMaterialContext); this._snapshotRendering.record || (this._applyRenderPassChanges(s, this.compatibilityMode ? null : l), this.compatibilityMode || (this._counters.numBundleCreationNonCompatMode++, u = this._device.createRenderBundleEncoder({ colorFormats: this._cacheRenderPipeline.colorFormats, depthStencilFormat: this._depthTextureFormat, sampleCount: this.currentSampleCount }))), u.setPipeline(m), this._currentIndexBuffer && u.setIndexBuffer(this._currentIndexBuffer.underlyingResource, this._currentIndexBuffer.is32Bits ? vp.Uint32 : vp.Uint16, 0); for (var v = this._cacheRenderPipeline.vertexBuffers, y = 0; y < v.length; y++) { var b = v[y], T = b.getBuffer(); T && u.setVertexBuffer(y, T.underlyingResource, b._validOffsetRange ? 0 : b.byteOffset) } for (p = 0; p < g.length; p++)u.setBindGroup(p, g[p]); var E = !this.compatibilityMode && !this._snapshotRendering.record; E && this._currentDrawContext.indirectDrawBuffer ? (this._currentDrawContext.setIndirectData(r, n || 1, i), 0 === e ? u.drawIndexedIndirect(this._currentDrawContext.indirectDrawBuffer, 0) : u.drawIndirect(this._currentDrawContext.indirectDrawBuffer, 0)) : 0 === e ? u.drawIndexed(r, n || 1, i, 0, 0) : u.draw(r, n || 1, i, 0), E && (this._currentDrawContext.fastBundle = u.finish(), l.addBundle(this._currentDrawContext.fastBundle)), this._reportDrawCall() } }, t.prototype.drawElementsType = function (e, t, i, r) { void 0 === r && (r = 1), this._draw(0, e, t, i, r) }, t.prototype.drawArraysType = function (e, t, i, r) { void 0 === r && (r = 1), this._currentIndexBuffer = null, this._draw(1, e, t, i, r) }, t.prototype.dispose = function () { var t, i; this._isDisposed = !0, null === (t = this._mainTexture) || void 0 === t || t.destroy(), null === (i = this._depthTexture) || void 0 === i || i.destroy(), this._device.destroy(), e.prototype.dispose.call(this) }, t.prototype.getRenderWidth = function (e) { var t, i; return void 0 === e && (e = !1), !e && this._currentRenderTarget ? this._currentRenderTarget.width : null !== (i = null === (t = this._renderingCanvas) || void 0 === t ? void 0 : t.width) && void 0 !== i ? i : 0 }, t.prototype.getRenderHeight = function (e) { var t, i; return void 0 === e && (e = !1), !e && this._currentRenderTarget ? this._currentRenderTarget.height : null !== (i = null === (t = this._renderingCanvas) || void 0 === t ? void 0 : t.height) && void 0 !== i ? i : 0 }, t.prototype.getError = function () { return 0 }, t.prototype.bindSamplers = function () { }, t.prototype._bindTextureDirectly = function () { return !1 }, t.prototype.areAllEffectsReady = function () { return !0 }, t.prototype._executeWhenRenderingStateIsCompiled = function (e, t) { t() }, t.prototype._isRenderingStateCompiled = function () { return !0 }, t.prototype._getUnpackAlignement = function () { return 1 }, t.prototype._unpackFlipY = function () { }, t.prototype._bindUnboundFramebuffer = function () { throw "_bindUnboundFramebuffer is not implementedin WebGPU! You probably want to use restoreDefaultFramebuffer or unBindFramebuffer instead" }, t.prototype._getSamplingParameters = function () { throw "_getSamplingParameters is not available in WebGPU" }, t.prototype.getUniforms = function () { return [] }, t.prototype.setIntArray = function () { return !1 }, t.prototype.setIntArray2 = function () { return !1 }, t.prototype.setIntArray3 = function () { return !1 }, t.prototype.setIntArray4 = function () { return !1 }, t.prototype.setArray = function () { return !1 }, t.prototype.setArray2 = function () { return !1 }, t.prototype.setArray3 = function () { return !1 }, t.prototype.setArray4 = function () { return !1 }, t.prototype.setMatrices = function () { return !1 }, t.prototype.setMatrix3x3 = function () { return !1 }, t.prototype.setMatrix2x2 = function () { return !1 }, t.prototype.setFloat = function () { return !1 }, t.prototype.setFloat2 = function () { return !1 }, t.prototype.setFloat3 = function () { return !1 }, t.prototype.setFloat4 = function () { return !1 }, t._GLSLslangDefaultOptions = { jsPath: "https://preview.babylonjs.com/glslang/glslang.js", wasmPath: "https://preview.babylonjs.com/glslang/glslang.wasm" }, t.UseTWGSL = !0, t }(In); Of.prototype.setAlphaMode = function (e, t) { if (void 0 === t && (t = !1), this._alphaMode === e && (e === a.ALPHA_DISABLE && !this._alphaState.alphaBlend || e !== a.ALPHA_DISABLE && this._alphaState.alphaBlend)) { if (!t) { var i = e === a.ALPHA_DISABLE; this.depthCullingState.depthMask !== i && (this.setDepthWrite(i), this._cacheRenderPipeline.setDepthWriteEnabled(i)) } } else { switch (e) { case a.ALPHA_DISABLE: this._alphaState.alphaBlend = !1; break; case a.ALPHA_PREMULTIPLIED: this._alphaState.setAlphaBlendFunctionParameters(1, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA, 1, 1), this._alphaState.alphaBlend = !0; break; case a.ALPHA_PREMULTIPLIED_PORTERDUFF: this._alphaState.setAlphaBlendFunctionParameters(1, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA, 1, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA), this._alphaState.alphaBlend = !0; break; case a.ALPHA_COMBINE: this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_SRC_ALPHA, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA, 1, 1), this._alphaState.alphaBlend = !0; break; case a.ALPHA_ONEONE: this._alphaState.setAlphaBlendFunctionParameters(1, 1, 0, 1), this._alphaState.alphaBlend = !0; break; case a.ALPHA_ADD: this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_SRC_ALPHA, 1, 0, 1), this._alphaState.alphaBlend = !0; break; case a.ALPHA_SUBTRACT: this._alphaState.setAlphaBlendFunctionParameters(0, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR, 1, 1), this._alphaState.alphaBlend = !0; break; case a.ALPHA_MULTIPLY: this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_DST_COLOR, 0, 1, 1), this._alphaState.alphaBlend = !0; break; case a.ALPHA_MAXIMIZED: this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_SRC_ALPHA, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR, 1, 1), this._alphaState.alphaBlend = !0; break; case a.ALPHA_INTERPOLATE: this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_CONSTANT_COLOR, a.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR, a.GL_ALPHA_FUNCTION_CONSTANT_ALPHA, a.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA), this._alphaState.alphaBlend = !0; break; case a.ALPHA_SCREENMODE: this._alphaState.setAlphaBlendFunctionParameters(1, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR, 1, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA), this._alphaState.alphaBlend = !0; break; case a.ALPHA_ONEONE_ONEONE: this._alphaState.setAlphaBlendFunctionParameters(1, 1, 1, 1), this._alphaState.alphaBlend = !0; break; case a.ALPHA_ALPHATOCOLOR: this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_DST_ALPHA, 1, 0, 0), this._alphaState.alphaBlend = !0; break; case a.ALPHA_REVERSEONEMINUS: this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR, a.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA), this._alphaState.alphaBlend = !0; break; case a.ALPHA_SRC_DSTONEMINUSSRCALPHA: this._alphaState.setAlphaBlendFunctionParameters(1, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA, 1, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA), this._alphaState.alphaBlend = !0; break; case a.ALPHA_ONEONE_ONEZERO: this._alphaState.setAlphaBlendFunctionParameters(1, 1, 1, 0), this._alphaState.alphaBlend = !0; break; case a.ALPHA_EXCLUSION: this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR, 0, 1), this._alphaState.alphaBlend = !0; break; case a.ALPHA_LAYER_ACCUMULATE: this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_SRC_ALPHA, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA, 1, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA), this._alphaState.alphaBlend = !0 }t || (this.setDepthWrite(e === In.ALPHA_DISABLE), this._cacheRenderPipeline.setDepthWriteEnabled(e === In.ALPHA_DISABLE)), this._alphaMode = e, this._cacheRenderPipeline.setAlphaBlendEnabled(this._alphaState.alphaBlend), this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters, this._alphaState._blendEquationParameters) } }, Of.prototype.setAlphaEquation = function (e) { In.prototype.setAlphaEquation.call(this, e), this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters, this._alphaState._blendEquationParameters) }; var Df = function () { function e(t, i) { this._device = t, this._cacheSampler = i, this.uniqueId = e._Counter++, this._bindGroupEntries = [], this.clear() } return e.prototype.getBindGroups = function (e, t, i) { if (!i) throw new Error("WebGPUComputeContext.getBindGroups: bindingsMapping is required until browsers support reflection for wgsl shaders!"); if (0 === this._bindGroups.length) { var r = this._bindGroupEntries.length > 0; 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 ((v = this._bindGroupEntries[s]) || (v = this._bindGroupEntries[s] = []), c) { case eu.Sampler: var d = u; void 0 !== h && r ? v[h].resource = this._cacheSampler.getSampler(d) : (o.indexInGroupEntries = v.length, v.push({ binding: l, resource: this._cacheSampler.getSampler(d) })); break; case eu.Texture: case eu.TextureWithoutSampler: var p = (f = u)._texture._hardwareTexture; void 0 !== h && r ? (c === eu.Texture && (v[h++].resource = this._cacheSampler.getSampler(f._texture)), v[h].resource = p.view) : (o.indexInGroupEntries = v.length, c === eu.Texture && v.push({ binding: l - 1, resource: this._cacheSampler.getSampler(f._texture) }), v.push({ binding: l, resource: p.view })); break; case eu.StorageTexture: var f; 0 == ((p = (f = u)._texture._hardwareTexture).textureAdditionalUsages & Qd.StorageBinding) && $.Error("computeDispatch: The texture (name=".concat(f.name, ", uniqueId=").concat(f.uniqueId, ") is not a storage texture!"), 50), void 0 !== h && r ? v[h].resource = p.viewForWriting : (o.indexInGroupEntries = v.length, v.push({ binding: l, resource: p.viewForWriting })); break; case eu.UniformBuffer: case eu.StorageBuffer: var _ = (eu.UniformBuffer, u).getBuffer(), m = _.underlyingResource; void 0 !== h && r ? (v[h].resource.buffer = m, v[h].resource.size = _.capacity) : (o.indexInGroupEntries = v.length, v.push({ binding: l, resource: { buffer: m, offset: 0, size: _.capacity } })) } } for (var g = 0; g < this._bindGroupEntries.length; ++g) { var v; (v = this._bindGroupEntries[g]) ? this._bindGroups[g] = this._device.createBindGroup({ layout: t.getBindGroupLayout(g), entries: v }) : this._bindGroups[g] = void 0 } this._bindGroups.length = this._bindGroupEntries.length } return this._bindGroups }, e.prototype.clear = function () { this._bindGroups = [] }, e._Counter = 0, e }(), Nf = function () { function e(e) { this._name = "unnamed", this.engine = e } return Object.defineProperty(e.prototype, "isAsync", { get: function () { return !1 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isReady", { get: function () { return !!this.stage }, enumerable: !1, configurable: !0 }), e.prototype._getComputeShaderCode = function () { var e; return null === (e = this.sources) || void 0 === e ? void 0 : e.compute }, e.prototype.dispose = function () { }, e }(); Of.prototype.createComputeContext = function () { return new Df(this._device, this._cacheSampler) }, Of.prototype.createComputeEffect = function (e, t) { var i = (e.computeElement || e.compute || e.computeToken || e.computeSource || e) + "@" + t.defines; if (this._compiledComputeEffects[i]) { var r = this._compiledComputeEffects[i]; return t.onCompiled && r.isReady() && t.onCompiled(r), r } var n = new tu(e, t, this, i); return this._compiledComputeEffects[i] = n, n }, Of.prototype.createComputePipelineContext = function () { return new Nf(this) }, Of.prototype.areAllComputeEffectsReady = function () { for (var e in this._compiledComputeEffects) if (!this._compiledComputeEffects[e].isReady()) return !1; return !0 }, Of.prototype.computeDispatch = function (e, t, i, r, n, o, a) { var s = this; if (this._currentRenderTarget) this._onAfterUnbindFrameBufferObservable.addOnce((function () { s.computeDispatch(e, t, i, r, n, o, a) })); else { var l = e._pipelineContext, c = t; l.computePipeline || (l.computePipeline = this._device.createComputePipeline({ layout: up.Auto, compute: l.stage })); var u = this._renderTargetEncoder.beginComputePass(); u.setPipeline(l.computePipeline); for (var h = c.getBindGroups(i, l.computePipeline, a), d = 0; d < h.length; ++d) { var p = h[d]; p && u.setBindGroup(d, p) } u.dispatchWorkgroups(r, n, o), u.end() } }, Of.prototype.releaseComputeEffects = function () { for (var e in this._compiledComputeEffects) { var t = this._compiledComputeEffects[e].getPipelineContext(); this._deleteComputePipelineContext(t) } this._compiledComputeEffects = {} }, Of.prototype._prepareComputePipelineContext = function (e, t, i, r, n) { var o = e; this.dbgShowShaderCode && (console.log(r), console.log(t)), o.sources = { compute: t, rawCompute: i }, o.stage = this._createComputePipelineStageDescriptor(t, r, n) }, Of.prototype._releaseComputeEffect = function (e) { this._compiledComputeEffects[e._key] && (delete this._compiledComputeEffects[e._key], this._deleteComputePipelineContext(e.getPipelineContext())) }, Of.prototype._rebuildComputeEffects = function () { for (var e in this._compiledComputeEffects) { var t = this._compiledComputeEffects[e]; t._pipelineContext = null, t._wasPreviouslyReady = !1, t._prepareEffect() } }, Of.prototype._deleteComputePipelineContext = function (e) { e && e.dispose() }, Of.prototype._createComputePipelineStageDescriptor = function (e, t, i) { return t = t ? "//" + t.split("\n").join("\n//") + "\n" : "", { module: this._device.createShaderModule({ code: t + e }), entryPoint: i } }, Of.prototype._createDepthStencilCubeTexture = function (e, t) { var i = new Ht(this, It.DepthStencil); i.isCube = !0; var r = H({ bilinearFiltering: !1, comparisonFunction: 0, generateStencil: !1, samples: 1 }, t); return i.format = r.generateStencil ? a.TEXTUREFORMAT_DEPTH24_STENCIL8 : a.TEXTUREFORMAT_DEPTH32_FLOAT, this._setupDepthStencilTexture(i, e, r.generateStencil, r.bilinearFiltering, r.comparisonFunction, r.samples), this._textureHelper.createGPUTextureForInternalTexture(i), this._internalTexturesCache.push(i), i }, Of.prototype.createCubeTexture = function (e, t, i, r, n, o, a, s, l, c, u, h, d) { var p = this; return 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 = !1), this.createCubeTextureBase(e, t, i, !!r, n, o, a, s, l, c, u, h, null, (function (e, t) { var i = t, o = i[0].width, s = o; p._setCubeMapTextureParams(e, !r), e.format = null != a ? a : -1; var l = p._textureHelper.createGPUTextureForInternalTexture(e, o, s); p._textureHelper.updateCubeTextures(i, l.underlyingResource, o, s, l.format, !1, !1, 0, 0), r || p._generateMipmaps(e, p._uploadEncoder), e.isReady = !0, e.onLoadedObservable.notifyObservers(e), e.onLoadedObservable.clear(), n && n() }), !!d) }, Of.prototype._setCubeMapTextureParams = function (e, t, i) { e.samplingMode = t ? a.TEXTURE_TRILINEAR_SAMPLINGMODE : a.TEXTURE_BILINEAR_SAMPLINGMODE, e._cachedWrapU = a.TEXTURE_CLAMP_ADDRESSMODE, e._cachedWrapV = a.TEXTURE_CLAMP_ADDRESSMODE, i && (e._maxLodLevel = i) }, Of.prototype._debugPushGroup = function (e, t) { this._options.enableGPUDebugMarkers && (0 === t || 1 === t ? (0 === t ? this._renderEncoder : this._renderTargetEncoder).pushDebugGroup(e) : this._currentRenderPass ? this._currentRenderPass.pushDebugGroup(e) : this._pendingDebugCommands.push(["push", e])) }, Of.prototype._debugPopGroup = function (e) { this._options.enableGPUDebugMarkers && (0 === e || 1 === e ? (0 === e ? this._renderEncoder : this._renderTargetEncoder).popDebugGroup() : this._currentRenderPass ? this._currentRenderPass.popDebugGroup() : this._pendingDebugCommands.push(["pop", null])) }, Of.prototype._debugInsertMarker = function (e, t) { this._options.enableGPUDebugMarkers && (0 === t || 1 === t ? (0 === t ? this._renderEncoder : this._renderTargetEncoder).insertDebugMarker(e) : this._currentRenderPass ? this._currentRenderPass.insertDebugMarker(e) : this._pendingDebugCommands.push(["insert", e])) }, Of.prototype._debugFlushPendingCommands = function () { for (var e = 0; e < this._pendingDebugCommands.length; ++e) { var t = this._pendingDebugCommands[e], i = t[0], r = t[1]; switch (i) { case "push": this._debugPushGroup(r); break; case "pop": this._debugPopGroup(); break; case "insert": this._debugInsertMarker(r) } } this._pendingDebugCommands.length = 0 }, Of.prototype.updateDynamicIndexBuffer = function (e, t, i) { void 0 === i && (i = 0); var r, n = e; r = e.is32Bits ? t instanceof Uint32Array ? t : new Uint32Array(t) : t instanceof Uint16Array ? t : new Uint16Array(t), this._bufferManager.setSubData(n, i, r) }, Of.prototype.updateDynamicVertexBuffer = 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) }, Of.prototype.updateDynamicTexture = function (e, t, i, r, n, o, a) { var s; if (void 0 === r && (r = !1), e) { var l = t.width, c = t.height, u = e._hardwareTexture; (null === (s = e._hardwareTexture) || void 0 === s ? void 0 : s.underlyingResource) || (u = this._textureHelper.createGPUTextureForInternalTexture(e, l, c)), this._textureHelper.updateTexture(t, e, l, c, e.depth, u.format, 0, 0, i, r, 0, 0, a), e.generateMipMaps && this._generateMipmaps(e, this._uploadEncoder), e.isReady = !0 } }; var Ff = function (e) { function t(t) { return e.call(this, t) || this } return W(t, e), t }(sf); function Lf(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 < t; s++)for (var l = 0; l < i; l++) { var c = 3 * (l * t + s), u = 4 * (l * t + s); n[u + 0] = e[c + 0], n[u + 1] = e[c + 1], n[u + 2] = e[c + 2], n[u + 3] = o } return n } Vt.prototype.setExternalTexture = function (e, t) { this._engine.setExternalTexture(e, t) }, Of.prototype.createExternalTexture = function (e) { return new Ff(e) }, Of.prototype.setExternalTexture = function (e, t) { t ? this._setInternalTexture(e, t) : this._currentMaterialContext.setTexture(e, null) }, Of.prototype.unBindMultiColorAttachmentFramebuffer = function (e, t, i) { void 0 === t && (t = !1), i && i(); var r = e._attachments.length; this._currentRenderPass && this._currentRenderPass !== this._mainRenderPassWrapper.renderPass && this._endRenderTargetRenderPass(); for (var n = 0; n < r; n++) { var o = e.textures[n]; !o.generateMipMaps || t || o.isCube || this._generateMipmaps(o) } this._currentRenderTarget = null, this._mrtAttachments = [], this._cacheRenderPipeline.setMRT([]), this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments), this._currentRenderPass = this._mainRenderPassWrapper.renderPass, this._setDepthTextureFormat(this._mainRenderPassWrapper), this._setColorFormat(this._mainRenderPassWrapper) }, Of.prototype.createMultipleRenderTarget = function (e, t, i) { var r, n, o = !1, s = !0, l = !1, c = !1, u = a.TEXTUREFORMAT_DEPTH16, h = 1, d = a.TEXTURETYPE_UNSIGNED_INT, p = a.TEXTURE_TRILINEAR_SAMPLINGMODE, f = a.TEXTUREFORMAT_RGBA, _ = a.TEXTURE_2D, m = new Array, g = new Array, v = new Array, y = new Array, b = new Array, T = new Array, E = new Array, S = new Array, x = this._createHardwareRenderTargetWrapper(!0, !1, e); void 0 !== t && (o = void 0 !== t.generateMipMaps && t.generateMipMaps, s = void 0 === t.generateDepthBuffer || t.generateDepthBuffer, l = void 0 !== t.generateStencilBuffer && t.generateStencilBuffer, c = void 0 !== t.generateDepthTexture && t.generateDepthTexture, h = t.textureCount || 1, u = null !== (r = t.depthTextureFormat) && void 0 !== r ? r : a.TEXTUREFORMAT_DEPTH16, t.types && (m = t.types), t.samplingModes && (g = t.samplingModes), t.useSRGBBuffers && (v = t.useSRGBBuffers), t.formats && (y = t.formats), t.targetTypes && (b = t.targetTypes), t.faceIndex && (T = t.faceIndex), t.layerIndex && (E = t.layerIndex), t.layerCounts && (S = t.layerCounts)); var A = e.width || e, R = e.height || e, C = null; (s || l || c) && (c || (u = s && l ? a.TEXTUREFORMAT_DEPTH24_STENCIL8 : s ? a.TEXTUREFORMAT_DEPTH32_FLOAT : a.TEXTUREFORMAT_STENCIL8), C = x.createDepthStencilTexture(0, !1, l, 1, u)); var P = [], I = [], M = []; x._generateDepthBuffer = s, x._generateStencilBuffer = l, x._attachments = I, x._defaultAttachments = M; for (var O = 0; O < h; O++) { var D = g[O] || p, N = m[O] || d, F = y[O] || f, L = !!v[O] && this._caps.supportSRGBBuffers, w = b[O] || _, B = null !== (n = S[O]) && void 0 !== n ? n : 1; if ((N !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (N !== a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (D = a.TEXTURE_NEAREST_SAMPLINGMODE), N !== a.TEXTURETYPE_FLOAT || this._caps.textureFloat || (N = a.TEXTURETYPE_UNSIGNED_INT, $.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")), I.push(O + 1), M.push(i ? O + 1 : 0 === O ? 1 : 0), -1 !== w) { var U = new Ht(this, It.MultiRenderTarget); switch (P[O] = U, w) { case a.TEXTURE_CUBE_MAP: U.isCube = !0; break; case a.TEXTURE_3D: U.is3D = !0, U.baseDepth = U.depth = B; break; case a.TEXTURE_2D_ARRAY: U.is2DArray = !0, U.baseDepth = U.depth = B }U.baseWidth = A, U.baseHeight = R, U.width = A, U.height = R, U.isReady = !0, U.samples = 1, U.generateMipMaps = o, U.samplingMode = D, U.type = N, U._cachedWrapU = a.TEXTURE_CLAMP_ADDRESSMODE, U._cachedWrapV = a.TEXTURE_CLAMP_ADDRESSMODE, U._useSRGBBuffer = L, U.format = F, this._internalTexturesCache.push(U), this._textureHelper.createGPUTextureForInternalTexture(U) } } return C && (C.incrementReferences(), P[h] = C, this._internalTexturesCache.push(C)), x.setTextures(P), x.setLayerAndFaceIndices(E, T), x }, Of.prototype.updateMultipleRenderTargetTextureSampleCount = function (e, t) { if (!e || !e.textures || e.textures[0].samples === t) return t; var i = e.textures.length; if (0 === i) return 1; t = Math.min(t, this.getCaps().maxMSAASamples); for (var r = 0; r < i; ++r) { var n = (a = e.textures[r])._hardwareTexture; null == n || n.releaseMSAATexture() } var o = e._depthStencilTexture === e.textures[i - 1]; for (r = 0; r < i; ++r) { var a = e.textures[r]; this._textureHelper.createMSAATexture(a, t, !1, r === i - 1 && o ? 0 : r), a.samples = t } return e._depthStencilTexture && !o && (this._textureHelper.createMSAATexture(e._depthStencilTexture, t), e._depthStencilTexture.samples = t), t }, Of.prototype.bindAttachments = function (e) { 0 !== e.length && this._currentRenderTarget && (this._mrtAttachments = e, this._currentRenderPass && this._cacheRenderPipeline.setMRTAttachments(e)) }, Of.prototype.buildTextureLayout = function (e) { for (var t = [], i = 0; i < e.length; i++)e[i] ? t.push(i + 1) : t.push(0); return t }, Of.prototype.restoreSingleAttachment = function () { }, Of.prototype.restoreSingleAttachmentForRenderTarget = function () { }, Of.prototype.getGPUFrameTimeCounter = function () { return this._timestampQuery.gpuFrameTimeCounter }, Of.prototype.captureGPUFrameTime = function (e) { this._timestampQuery.enable = e && !!this._caps.timerQuery }, Of.prototype.createQuery = function () { return this._occlusionQuery.createQuery() }, Of.prototype.deleteQuery = function (e) { return this._occlusionQuery.deleteQuery(e), this }, Of.prototype.isQueryResultAvailable = function (e) { return this._occlusionQuery.isQueryResultAvailable(e) }, Of.prototype.getQueryResult = function (e) { return this._occlusionQuery.getQueryResult(e) }, Of.prototype.beginOcclusionQuery = function (e, t) { var i; return this.compatibilityMode ? !!this._occlusionQuery.canBeginQuery && (null === (i = this._currentRenderPass) || void 0 === i || i.beginOcclusionQuery(t), !0) : ((0 === this._getCurrentRenderPassIndex() ? this._bundleList : this._bundleListRenderTarget).addItem(new gf(t)), !0) }, Of.prototype.endOcclusionQuery = function () { var e; return this.compatibilityMode ? null === (e = this._currentRenderPass) || void 0 === e || e.endOcclusionQuery() : (0 === this._getCurrentRenderPassIndex() ? this._bundleList : this._bundleListRenderTarget).addItem(new vf), this }, Of.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 Ht(this, It.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), this._textureHelper.createGPUTextureForInternalTexture(d, t, i, void 0, u), this.updateRawTexture(d, e, r, o, l, c, h), this._internalTexturesCache.push(d), d }, Of.prototype.updateRawTexture = function (e, t, i, r, n, o, s) { if (void 0 === n && (n = null), void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT), void 0 === s && (s = !1), e) { if (this._doNotHandleContextLost || (e._bufferView = t, e.invertY = r, e._compression = n, e._useSRGBBuffer = s), t) { var l = e._hardwareTexture; i === a.TEXTUREFORMAT_RGB && (t = Lf(t, e.width, e.height, o)); var c = new Uint8Array(t.buffer, t.byteOffset, t.byteLength); this._textureHelper.updateTexture(c, e, e.width, e.height, e.depth, l.format, 0, 0, r, !1, 0, 0), e.generateMipMaps && this._generateMipmaps(e, this._uploadEncoder) } e.isReady = !0 } }, Of.prototype.createRawCubeTexture = function (e, t, i, r, n, o, s, l) { void 0 === l && (l = null); var c = new Ht(this, It.CubeRaw); return r !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering ? r !== a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering ? r !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatRender ? r !== a.TEXTURETYPE_HALF_FLOAT || this._caps.colorBufferFloat || (n = !1, $.Warn("Render to half float textures is not supported. Mipmap generation forced to false.")) : (n = !1, $.Warn("Render to float textures is not supported. Mipmap generation forced to false.")) : (n = !1, s = a.TEXTURE_NEAREST_SAMPLINGMODE, $.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")) : (n = !1, s = a.TEXTURE_NEAREST_SAMPLINGMODE, $.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")), c.isCube = !0, c.format = i === a.TEXTUREFORMAT_RGB ? a.TEXTUREFORMAT_RGBA : i, c.type = r, c.generateMipMaps = n, c.width = t, c.height = t, c.samplingMode = s, this._doNotHandleContextLost || (c._bufferViewArray = e), c.invertY = o, c._compression = l, c._cachedWrapU = a.TEXTURE_CLAMP_ADDRESSMODE, c._cachedWrapV = a.TEXTURE_CLAMP_ADDRESSMODE, this._textureHelper.createGPUTextureForInternalTexture(c), e && this.updateRawCubeTexture(c, e, i, r, o, l), c.isReady = !0, c }, Of.prototype.updateRawCubeTexture = function (e, t, i, r, n, o) { void 0 === o && (o = null), e._bufferViewArray = t, e.invertY = n, e._compression = o; for (var s = e._hardwareTexture, l = i === a.TEXTUREFORMAT_RGB, c = [], u = 0; u < t.length; ++u) { var h = t[u]; l && (h = Lf(t[u], e.width, e.height, r)), c.push(new Uint8Array(h.buffer, h.byteOffset, h.byteLength)) } this._textureHelper.updateCubeTextures(c, s.underlyingResource, e.width, e.height, s.format, n, !1, 0, 0), e.generateMipMaps && this._generateMipmaps(e, this._uploadEncoder), e.isReady = !0 }, Of.prototype.createRawCubeTextureFromUrl = function (e, t, i, r, n, o, s, l, c, u, h, d) { var p = this; void 0 === c && (c = null), void 0 === u && (u = null), void 0 === h && (h = a.TEXTURE_TRILINEAR_SAMPLINGMODE), void 0 === d && (d = !1); var f = this.createRawCubeTexture(null, i, r, n, !o, d, h, null); return null == t || t.addPendingData(f), f.url = e, this._internalTexturesCache.push(f), this._loadFile(e, (function (e) { !function (e) { var i = f.width, o = s(e); if (o) { var u = [0, 2, 4, 1, 3, 5]; if (l) for (var h = r === a.TEXTUREFORMAT_RGB, _ = l(o), m = f._hardwareTexture, g = [0, 1, 2, 3, 4, 5], v = 0; v < _.length; v++) { for (var y = i >> v, b = [], T = 0; T < 6; T++) { var E = _[v][g[T]]; h && (E = Lf(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 }, Of.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 = It.Raw3D, p = new Ht(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 }, Of.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 = Lf(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 }, Of.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 = It.Raw2DArray, p = new Ht(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 }, Of.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 = Lf(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 }, Of.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) }, Of.prototype._readTexturePixelsSync = function () { throw "_readTexturePixelsSync is unsupported in WebGPU!" }; var wf = function (e) { function t() { return null !== e && e.apply(this, arguments) || this } return W(t, e), t }(Ca); Of.prototype._createHardwareRenderTargetWrapper = function (e, t, i) { var r = new wf(e, t, i, this); return this._renderTargetWrapperCache.push(r), r }, Of.prototype.createRenderTargetTexture = function (e, t) { var i, r, n = this._createHardwareRenderTargetWrapper(!1, !1, e), o = {}; void 0 !== t && "object" == typeof t ? (o.generateMipMaps = t.generateMipMaps, o.generateDepthBuffer = void 0 === t.generateDepthBuffer || t.generateDepthBuffer, o.generateStencilBuffer = o.generateDepthBuffer && t.generateStencilBuffer, o.samplingMode = void 0 === t.samplingMode ? a.TEXTURE_TRILINEAR_SAMPLINGMODE : t.samplingMode, o.creationFlags = null !== (i = t.creationFlags) && void 0 !== i ? i : 0, o.noColorAttachment = !!t.noColorAttachment, o.samples = t.samples, o.label = t.label) : (o.generateMipMaps = t, o.generateDepthBuffer = !0, o.generateStencilBuffer = !1, o.samplingMode = a.TEXTURE_TRILINEAR_SAMPLINGMODE, o.creationFlags = 0, o.noColorAttachment = !1); var s = o.noColorAttachment ? null : this._createInternalTexture(e, t, !0, It.RenderTarget); return n._samples = null !== (r = o.samples) && void 0 !== r ? r : 1, n._generateDepthBuffer = o.generateDepthBuffer, n._generateStencilBuffer = !!o.generateStencilBuffer, n.setTextures(s), (n._generateDepthBuffer || n._generateStencilBuffer) && n.createDepthStencilTexture(0, this._caps.textureFloatLinearFiltering && (void 0 === o.samplingMode || o.samplingMode === a.TEXTURE_BILINEAR_SAMPLINGMODE || o.samplingMode === a.TEXTURE_LINEAR_LINEAR || o.samplingMode === a.TEXTURE_TRILINEAR_SAMPLINGMODE || o.samplingMode === a.TEXTURE_LINEAR_LINEAR_MIPLINEAR || o.samplingMode === a.TEXTURE_NEAREST_LINEAR_MIPNEAREST || o.samplingMode === a.TEXTURE_NEAREST_LINEAR_MIPLINEAR || o.samplingMode === a.TEXTURE_NEAREST_LINEAR || o.samplingMode === a.TEXTURE_LINEAR_LINEAR_MIPNEAREST), n._generateStencilBuffer, n.samples, o.generateStencilBuffer ? a.TEXTUREFORMAT_DEPTH24_STENCIL8 : a.TEXTUREFORMAT_DEPTH32_FLOAT, o.label ? o.label + "-DepthStencil" : void 0), s && (void 0 !== t && "object" == typeof t && t.createMipMaps && !o.generateMipMaps && (s.generateMipMaps = !0), this._textureHelper.createGPUTextureForInternalTexture(s, void 0, void 0, void 0, o.creationFlags), void 0 !== t && "object" == typeof t && t.createMipMaps && !o.generateMipMaps && (s.generateMipMaps = !1)), n }, Of.prototype._createDepthStencilTexture = function (e, t) { var i = new Ht(this, It.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 }, Of.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 }, Of.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 }, Of.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, samples: 1 }, t); r.generateStencilBuffer = r.generateDepthBuffer && r.generateStencilBuffer, i._generateDepthBuffer = r.generateDepthBuffer, i._generateStencilBuffer = r.generateStencilBuffer; var n = new Ht(this, It.RenderTarget); return n.width = e, n.height = e, n.depth = 0, n.isReady = !0, n.isCube = !0, n.samples = r.samples, n.generateMipMaps = r.generateMipMaps, n.samplingMode = r.samplingMode, n.type = r.type, n.format = r.format, this._internalTexturesCache.push(n), i.setTextures(n), (i._generateDepthBuffer || i._generateStencilBuffer) && i.createDepthStencilTexture(0, void 0 === r.samplingMode || r.samplingMode === a.TEXTURE_BILINEAR_SAMPLINGMODE || r.samplingMode === a.TEXTURE_LINEAR_LINEAR || r.samplingMode === a.TEXTURE_TRILINEAR_SAMPLINGMODE || r.samplingMode === a.TEXTURE_LINEAR_LINEAR_MIPLINEAR || r.samplingMode === a.TEXTURE_NEAREST_LINEAR_MIPNEAREST || r.samplingMode === a.TEXTURE_NEAREST_LINEAR_MIPLINEAR || r.samplingMode === a.TEXTURE_NEAREST_LINEAR || r.samplingMode === a.TEXTURE_LINEAR_LINEAR_MIPNEAREST, i._generateStencilBuffer, i.samples), t && t.createMipMaps && !r.generateMipMaps && (n.generateMipMaps = !0), this._textureHelper.createGPUTextureForInternalTexture(n), t && t.createMipMaps && !r.generateMipMaps && (n.generateMipMaps = !1), i }, Vt.prototype.setTextureSampler = function (e, t) { this._engine.setTextureSampler(e, t) }, Of.prototype.setTextureSampler = function (e, t) { var i; null === (i = this._currentMaterialContext) || void 0 === i || i.setSampler(e, t) }, Vt.prototype.setStorageBuffer = function (e, t) { this._engine.setStorageBuffer(e, t) }, Of.prototype.createStorageBuffer = function (e, t) { return this._createBuffer(e, t | a.BUFFER_CREATIONFLAG_STORAGE) }, Of.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) }, Of.prototype.readFromStorageBuffer = function (e, t, i, r) { var n = this; i = i || e.capacity; var o = this._bufferManager.createRawBuffer(i, jd.MapRead | jd.CopyDst); return this._renderTargetEncoder.copyBufferToBuffer(e.underlyingResource, null != t ? t : 0, o, 0, i), new Promise((function (e, t) { n.onEndFrameObservable.addOnce((function () { o.mapAsync(Yd.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) })) })) })) }, Of.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) }, Of.prototype.createUniformBuffer = function (e) { var t; return t = e instanceof Array ? new Float32Array(e) : e, this._bufferManager.createBuffer(t, jd.Uniform | jd.CopyDst) }, Of.prototype.createDynamicUniformBuffer = function (e) { return this.createUniformBuffer(e) }, Of.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) }, Of.prototype.bindUniformBufferBase = function (e, t, i) { this._currentDrawContext.setBuffer(i, e) }, Of.prototype.bindUniformBlock = function () { }, Of.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 Bf = function () { function e() { } return e.CreateAsync = function (e, t) { return Of.IsSupportedAsync.then((function (i) { return i ? Of.CreateAsync(e, t) : In.IsSupported ? new Promise((function (i) { i(new In(e, void 0, t)) })) : new Promise((function (e) { e(new zh(t)) })) })) }, e }(), Uf = function () { function e() { } return e.COPY = 1, e.CUT = 2, e.PASTE = 3, e }(), Vf = function () { function e(e, t) { this.type = e, this.event = t } return e.GetTypeFromCharacter = function (e) { switch (e) { case 67: return Uf.COPY; case 86: return Uf.PASTE; case 88: return Uf.CUT; default: return -1 } }, e }(), kf = function (e) { function t(t) { var i = e.call(this, t) || this; return i.controllerType = cl.DAYDREAM, i } return W(t, e), t.prototype.initControllerMesh = function (e, i) { var r = this; ea.ImportMesh("", t.MODEL_BASE_URL, t.MODEL_FILENAME, e, (function (e) { r._defaultModel = e[1], r.attachToMesh(r._defaultModel), i && i(r._defaultModel) })) }, t.prototype._handleButtonChange = function (e, t) { if (0 === e) { var i = this.onTriggerStateChangedObservable; i && i.notifyObservers(t) } else $.Warn("Unrecognized Daydream button index: ".concat(e)) }, t.MODEL_BASE_URL = "https://controllers.babylonjs.com/generic/", t.MODEL_FILENAME = "generic.babylon", t.GAMEPAD_ID_PREFIX = "Daydream", t }(ec); fl._ControllerFactories.push({ canCreate: function (e) { return 0 === e.id.indexOf(kf.GAMEPAD_ID_PREFIX) }, create: function (e) { return new kf(e) } }); var Gf = function (e) { function t(t) { var i = e.call(this, t) || this; return i._buttonIndexToObservableNameMap = ["onPadStateChangedObservable", "onTriggerStateChangedObservable"], i.controllerType = cl.GEAR_VR, i._calculatedPosition = new R("left" == i.hand ? -.15 : .15, -.5, .25), i._disableTrackPosition(i._calculatedPosition), i } return W(t, e), t.prototype.initControllerMesh = function (e, i) { var r = this; ea.ImportMesh("", t.MODEL_BASE_URL, t.MODEL_FILENAME, e, (function (t) { var n = new Jn("", e); t[1].parent = n, t[1].position.z = -.15, r._defaultModel = n, r.attachToMesh(r._defaultModel), i && i(r._defaultModel) })) }, t.prototype._handleButtonChange = function (e, t) { if (e < this._buttonIndexToObservableNameMap.length) { var i = this[this._buttonIndexToObservableNameMap[e]]; i && i.notifyObservers(t) } }, t.MODEL_BASE_URL = "https://controllers.babylonjs.com/generic/", t.MODEL_FILENAME = "generic.babylon", t.GAMEPAD_ID_PREFIX = "Gear VR", t }(ec); fl._ControllerFactories.push({ canCreate: function (e) { return 0 === e.id.indexOf(Gf.GAMEPAD_ID_PREFIX) || -1 !== e.id.indexOf("Oculus Go") || -1 !== e.id.indexOf("Vive Focus") }, create: function (e) { return new Gf(e) } }); var zf = function (e) { function t(t) { return e.call(this, t) || this } return W(t, e), t.prototype.initControllerMesh = function (e, i) { var r = this; ea.ImportMesh("", t.MODEL_BASE_URL, t.MODEL_FILENAME, e, (function (e) { r._defaultModel = e[1], r.attachToMesh(r._defaultModel), i && i(r._defaultModel) })) }, t.prototype._handleButtonChange = function (e, t) { console.log("Button id: " + e + "state: "), console.dir(t) }, t.MODEL_BASE_URL = "https://controllers.babylonjs.com/generic/", t.MODEL_FILENAME = "generic.babylon", t }(ec); fl._DefaultControllerFactory = function (e) { return new zf(e) }; var Wf = function (e) { function t(t) { var i = e.call(this, t) || this; return i.onSecondaryTriggerStateChangedObservable = new u, i.onThumbRestChangedObservable = new u, i.controllerType = cl.OCULUS, i } return W(t, e), t.prototype.initControllerMesh = function (e, i) { var r, n = this; r = "left" === this.hand ? t.MODEL_LEFT_FILENAME : t.MODEL_RIGHT_FILENAME, ea.ImportMesh("", t._IsQuest ? t.QUEST_MODEL_BASE_URL : t.MODEL_BASE_URL, r, e, (function (e) { n._defaultModel = t._IsQuest ? e[0] : e[1], n.attachToMesh(n._defaultModel), i && i(n._defaultModel) })) }, Object.defineProperty(t.prototype, "onAButtonStateChangedObservable", { get: function () { if ("right" === this.hand) return this.onMainButtonStateChangedObservable; throw new Error("No A button on left hand") }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onBButtonStateChangedObservable", { get: function () { if ("right" === this.hand) return this.onSecondaryButtonStateChangedObservable; throw new Error("No B button on left hand") }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onXButtonStateChangedObservable", { get: function () { if ("left" === this.hand) return this.onMainButtonStateChangedObservable; throw new Error("No X button on right hand") }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onYButtonStateChangedObservable", { get: function () { if ("left" === this.hand) return this.onSecondaryButtonStateChangedObservable; throw new Error("No Y button on right hand") }, enumerable: !1, configurable: !0 }), t.prototype._handleButtonChange = function (e, i) { var r = i, n = "right" === this.hand ? -1 : 1; switch (e) { case 0: return void this.onPadStateChangedObservable.notifyObservers(r); case 1: return !t._IsQuest && this._defaultModel && (this._defaultModel.getChildren()[3].rotation.x = .2 * -r.value, this._defaultModel.getChildren()[3].position.y = .005 * -r.value, this._defaultModel.getChildren()[3].position.z = .005 * -r.value), void this.onTriggerStateChangedObservable.notifyObservers(r); case 2: return !t._IsQuest && this._defaultModel && (this._defaultModel.getChildren()[4].position.x = n * r.value * .0035), void this.onSecondaryTriggerStateChangedObservable.notifyObservers(r); case 3: return !t._IsQuest && this._defaultModel && (r.pressed ? this._defaultModel.getChildren()[1].position.y = -.001 : this._defaultModel.getChildren()[1].position.y = 0), void this.onMainButtonStateChangedObservable.notifyObservers(r); case 4: return !t._IsQuest && this._defaultModel && (r.pressed ? this._defaultModel.getChildren()[2].position.y = -.001 : this._defaultModel.getChildren()[2].position.y = 0), void this.onSecondaryButtonStateChangedObservable.notifyObservers(r); case 5: return void this.onThumbRestChangedObservable.notifyObservers(r) } }, t.MODEL_BASE_URL = "https://controllers.babylonjs.com/oculus/", t.MODEL_LEFT_FILENAME = "left.babylon", t.MODEL_RIGHT_FILENAME = "right.babylon", t.QUEST_MODEL_BASE_URL = "https://controllers.babylonjs.com/oculusQuest/", t._IsQuest = !1, t }(ec); fl._ControllerFactories.push({ canCreate: function (e) { return S.LastCreatedEngine && S.LastCreatedEngine._vrDisplay && "Oculus Quest" === S.LastCreatedEngine._vrDisplay.displayName && (Wf._IsQuest = !0), -1 !== e.id.indexOf("Oculus Touch") }, create: function (e) { return new Wf(e) } }); var Hf = function (e) { function t(t) { var i = e.call(this, t) || this; return i.controllerType = cl.VIVE, i._invertLeftStickY = !0, i } return W(t, e), t.prototype.initControllerMesh = function (e, i) { var r = this; ea.ImportMesh("", t.MODEL_BASE_URL, t.MODEL_FILENAME, e, (function (e) { r._defaultModel = e[1], r.attachToMesh(r._defaultModel), i && i(r._defaultModel) })) }, Object.defineProperty(t.prototype, "onLeftButtonStateChangedObservable", { get: function () { return this.onMainButtonStateChangedObservable }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onRightButtonStateChangedObservable", { get: function () { return this.onMainButtonStateChangedObservable }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onMenuButtonStateChangedObservable", { get: function () { return this.onSecondaryButtonStateChangedObservable }, enumerable: !1, configurable: !0 }), t.prototype._handleButtonChange = function (e, t) { var i = t; switch (e) { case 0: return void this.onPadStateChangedObservable.notifyObservers(i); case 1: return this._defaultModel && (this._defaultModel.getChildren()[6].rotation.x = .15 * -i.value), void this.onTriggerStateChangedObservable.notifyObservers(i); case 2: return void this.onMainButtonStateChangedObservable.notifyObservers(i); case 3: return this._defaultModel && (i.pressed ? this._defaultModel.getChildren()[2].position.y = -.001 : this._defaultModel.getChildren()[2].position.y = 0), void this.onSecondaryButtonStateChangedObservable.notifyObservers(i) } }, t.MODEL_BASE_URL = "https://controllers.babylonjs.com/vive/", t.MODEL_FILENAME = "wand.babylon", t }(ec); fl._ControllerFactories.push({ canCreate: function (e) { return -1 !== e.id.toLowerCase().indexOf("openvr") }, create: function (e) { return new Hf(e) } }); var Xf = function () { this.buttonMeshes = {}, this.axisMeshes = {} }, jf = function (e) { function t(t) { var i = e.call(this, t) || this; return i._mapping = { buttons: ["thumbstick", "trigger", "grip", "menu", "trackpad"], buttonMeshNames: { trigger: "SELECT", menu: "MENU", grip: "GRASP", thumbstick: "THUMBSTICK_PRESS", trackpad: "TOUCHPAD_PRESS" }, buttonObservableNames: { trigger: "onTriggerStateChangedObservable", menu: "onSecondaryButtonStateChangedObservable", grip: "onMainButtonStateChangedObservable", thumbstick: "onPadStateChangedObservable", trackpad: "onTrackpadChangedObservable" }, axisMeshNames: ["THUMBSTICK_X", "THUMBSTICK_Y", "TOUCHPAD_TOUCH_X", "TOUCHPAD_TOUCH_Y"], pointingPoseMeshName: _l.POINTING_POSE }, i.onTrackpadChangedObservable = new u, i.onTrackpadValuesChangedObservable = new u, i.trackpad = { x: 0, y: 0 }, i.controllerType = cl.WINDOWS, i._loadedMeshInfo = null, i } return W(t, e), Object.defineProperty(t.prototype, "onTriggerButtonStateChangedObservable", { get: function () { return this.onTriggerStateChangedObservable }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onMenuButtonStateChangedObservable", { get: function () { return this.onSecondaryButtonStateChangedObservable }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onGripButtonStateChangedObservable", { get: function () { return this.onMainButtonStateChangedObservable }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onThumbstickButtonStateChangedObservable", { get: function () { return this.onPadStateChangedObservable }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onTouchpadButtonStateChangedObservable", { get: function () { return this.onTrackpadChangedObservable }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onTouchpadValuesChangedObservable", { get: function () { return this.onTrackpadValuesChangedObservable }, enumerable: !1, configurable: !0 }), t.prototype._updateTrackpad = function () { !this.browserGamepad.axes || this.browserGamepad.axes[2] == this.trackpad.x && this.browserGamepad.axes[3] == this.trackpad.y || (this.trackpad.x = this.browserGamepad.axes[this._mapping.axisMeshNames.indexOf("TOUCHPAD_TOUCH_X")], this.trackpad.y = this.browserGamepad.axes[this._mapping.axisMeshNames.indexOf("TOUCHPAD_TOUCH_Y")], this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad)) }, t.prototype.update = function () { if (e.prototype.update.call(this), this.browserGamepad.axes && (this._updateTrackpad(), this._loadedMeshInfo)) for (var t = 0; t < this._mapping.axisMeshNames.length; t++)this._lerpAxisTransform(t, this.browserGamepad.axes[t]) }, t.prototype._handleButtonChange = function (e, t) { var i = this._mapping.buttons[e]; if (i) { this._updateTrackpad(); var r = this[this._mapping.buttonObservableNames[i]]; r && r.notifyObservers(t), this._lerpButtonTransform(i, t.value) } }, t.prototype._lerpButtonTransform = function (e, t) { if (this._loadedMeshInfo) { var i = this._loadedMeshInfo.buttonMeshes[e]; i && i.unpressed.rotationQuaternion && i.pressed.rotationQuaternion && i.value.rotationQuaternion && (P.SlerpToRef(i.unpressed.rotationQuaternion, i.pressed.rotationQuaternion, t, i.value.rotationQuaternion), R.LerpToRef(i.unpressed.position, i.pressed.position, t, i.value.position)) } }, t.prototype._lerpAxisTransform = function (e, t) { if (this._loadedMeshInfo) { var i = this._loadedMeshInfo.axisMeshes[e]; if (i && i.min.rotationQuaternion && i.max.rotationQuaternion && i.value.rotationQuaternion) { var r = .5 * t + .5; P.SlerpToRef(i.min.rotationQuaternion, i.max.rotationQuaternion, r, i.value.rotationQuaternion), R.LerpToRef(i.min.position, i.max.position, r, i.value.position) } } }, t.prototype.initControllerMesh = function (e, i, r) { var n, o, a = this; if (void 0 === r && (r = !1), ea.IsPluginForExtensionAvailable(".glb")) { var s = "default"; if (this.id && !r) { var l = this.id.match(t.GAMEPAD_ID_PATTERN); s = l && l[0] || s } o = "left" === this.hand ? t.MODEL_LEFT_FILENAME : t.MODEL_RIGHT_FILENAME, n = t.MODEL_BASE_URL + s + "/" } else $.Warn("You need to reference GLTF loader to load Windows Motion Controllers model. Falling back to generic models"), n = zf.MODEL_BASE_URL, o = zf.MODEL_FILENAME; ea.ImportMesh("", n, o, e, (function (t) { a._loadedMeshInfo = a._processModel(e, t), a._loadedMeshInfo && (a._defaultModel = a._loadedMeshInfo.rootNode, a.attachToMesh(a._defaultModel), i && i(a._defaultModel)) }), null, (function (e, t) { $.Log(t), $.Warn("Failed to retrieve controller model from the remote server: " + n + o), r || a.initControllerMesh(e, i, !0) })) }, t.prototype._processModel = function (e, t) { for (var i = null, r = new Jn(this.id + " " + this.hand, e), n = null, o = 0; o < t.length; o++) { var a = t[o]; if (!a.parent) { a.isPickable = !1, n = a; break } } return n ? (n.setParent(r), i = this._createMeshInfo(r)) : $.Warn("Could not find root node in model file."), i }, t.prototype._createMeshInfo = function (e) { var t, i = new Xf; for (i.rootNode = e, i.buttonMeshes = {}, i.axisMeshes = {}, t = 0; t < this._mapping.buttons.length; t++) { var r = this._mapping.buttonMeshNames[this._mapping.buttons[t]]; if (r) { var n = c(e, r); if (n) { var o = { index: t, value: u(n, "VALUE"), pressed: u(n, "PRESSED"), unpressed: u(n, "UNPRESSED") }; o.value && o.pressed && o.unpressed ? i.buttonMeshes[this._mapping.buttons[t]] = o : $.Warn("Missing button submesh under mesh with name: " + r + "(VALUE: " + !!o.value + ", PRESSED: " + !!o.pressed + ", UNPRESSED:" + !!o.unpressed + ")") } else $.Warn("Missing button mesh with name: " + r) } else $.Log("Skipping unknown button at index: " + t + " with mapped name: " + this._mapping.buttons[t]) } for (t = 0; t < this._mapping.axisMeshNames.length; t++) { var a = this._mapping.axisMeshNames[t]; if (a) { var s = c(e, a); if (s) { var l = { index: t, value: u(s, "VALUE"), min: u(s, "MIN"), max: u(s, "MAX") }; l.value && l.min && l.max ? i.axisMeshes[t] = l : $.Warn("Missing axis submesh under mesh with name: " + a + "(VALUE: " + !!l.value + ", MIN: " + !!l.min + ", MAX:" + !!l.max + ")") } else $.Warn("Missing axis mesh with name: " + a) } else $.Log("Skipping unknown axis at index: " + t) } return i.pointingPoseNode = c(e, this._mapping.pointingPoseMeshName), i.pointingPoseNode ? this._pointingPoseNode = i.pointingPoseNode : $.Warn("Missing pointing pose mesh with name: " + this._mapping.pointingPoseMeshName), i; function c(e, t) { return e.getChildren((function (e) { return e.name === t }), !1)[0] } function u(e, t) { return e.getChildren((function (e) { return e.name == t }), !0)[0] } }, t.prototype.getForwardRay = function (t) { if (void 0 === t && (t = 100), !this._loadedMeshInfo || !this._loadedMeshInfo.pointingPoseNode) return e.prototype.getForwardRay.call(this, t); var i = this._loadedMeshInfo.pointingPoseNode.getWorldMatrix(), r = i.getTranslation(), n = new R(0, 0, -1), o = R.TransformNormal(n, i), a = R.Normalize(o); return new Mo(r, a, t) }, t.prototype.dispose = function () { e.prototype.dispose.call(this), this.onTrackpadChangedObservable.clear(), this.onTrackpadValuesChangedObservable.clear() }, t.MODEL_BASE_URL = "https://controllers.babylonjs.com/microsoft/", t.MODEL_LEFT_FILENAME = "left.glb", t.MODEL_RIGHT_FILENAME = "right.glb", t.GAMEPAD_ID_PREFIX = "Spatial Controller (Spatial Interaction Source) ", t.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/, t }(ec), Yf = function (e) { function t(t) { var i = e.call(this, t) || this; return i._mapping = { buttons: ["trigger", "grip", "trackpad", "thumbstick", "menu"], buttonMeshNames: { trigger: "SELECT", menu: "MENU", grip: "GRASP", thumbstick: "THUMBSTICK_PRESS", trackpad: "TOUCHPAD_PRESS" }, buttonObservableNames: { trigger: "onTriggerStateChangedObservable", menu: "onSecondaryButtonStateChangedObservable", grip: "onMainButtonStateChangedObservable", thumbstick: "onThumbstickStateChangedObservable", trackpad: "onTrackpadChangedObservable" }, axisMeshNames: ["TOUCHPAD_TOUCH_X", "TOUCHPAD_TOUCH_Y", "THUMBSTICK_X", "THUMBSTICK_Y"], pointingPoseMeshName: _l.POINTING_POSE }, i.thumbstickValues = { x: 0, y: 0 }, i.onThumbstickStateChangedObservable = new u, i.onThumbstickValuesChangedObservable = new u, i.onTrackpadChangedObservable = i.onPadStateChangedObservable, i.onTrackpadValuesChangedObservable = i.onPadValuesChangedObservable, i } return W(t, e), Object.defineProperty(t.prototype, "onThumbstickButtonStateChangedObservable", { get: function () { return this.onThumbstickStateChangedObservable }, enumerable: !1, configurable: !0 }), t.prototype._updateTrackpad = function () { !this.browserGamepad.axes || this.browserGamepad.axes[2] == this.thumbstickValues.x && this.browserGamepad.axes[3] == this.thumbstickValues.y || (this.trackpad.x = this.browserGamepad.axes[2], this.trackpad.y = this.browserGamepad.axes[3], this.onThumbstickValuesChangedObservable.notifyObservers(this.trackpad)) }, t.prototype.dispose = function () { e.prototype.dispose.call(this), this.onThumbstickStateChangedObservable.clear(), this.onThumbstickValuesChangedObservable.clear() }, t }(jf); fl._ControllerFactories.push({ canCreate: function (e) { return 0 === e.id.indexOf(jf.GAMEPAD_ID_PREFIX) }, create: function (e) { return new jf(e) } }); var Kf = function (e) { function t(t, i, r, n, o) { void 0 === i && (i = B.Gray()), void 0 === r && (r = lu.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 mc("", r.utilityLayerScene), f._coloredMaterial.diffuseColor = i, f._coloredMaterial.specularColor = i.subtract(new B(.1, .1, .1)), f._hoverMaterial = new mc("", r.utilityLayerScene), f._hoverMaterial.diffuseColor = B.Yellow(), f._disableMaterial = new mc("", r.utilityLayerScene), f._disableMaterial.diffuseColor = B.Gray(), f._disableMaterial.alpha = .4, f._gizmoMesh = new Jn("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, uu.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 wo({ 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) { f._handlePivot(); 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, uu.PreserveScaling ? a : void 0); var s = 1e5; Math.abs(O.Vector3[1].x) < s && Math.abs(O.Vector3[1].y) < s && Math.abs(O.Vector3[1].z) < s && f.attachedNode.getWorldMatrix().copyFrom(O.Matrix[1]), n && (A.snapDistance = f.snapDistance * o, f.onSnapObservable.notifyObservers(A)), f._matrixChanged() } })), f.dragBehavior.onDragStartObservable.add((function () { f._dragging = !0 })), f.dragBehavior.onDragObservable.add((function (e) { return E(e.dragDistance) })), f.dragBehavior.onDragEndObservable.add(S), null === (l = null === (s = null === (a = null == n ? void 0 : n.uniformScaleGizmo) || void 0 === a ? void 0 : a.dragBehavior) || void 0 === s ? void 0 : s.onDragObservable) || void 0 === l || l.add((function (e) { return E(e.delta.y) })), null === (d = null === (h = null === (c = null == n ? void 0 : n.uniformScaleGizmo) || void 0 === c ? void 0 : c.dragBehavior) || void 0 === h ? void 0 : h.onDragEndObservable) || void 0 === d || d.add(S); var C = { gizmoMeshes: [m, g], colliderMeshes: [v.arrowMesh, v.arrowTail], material: f._coloredMaterial, hoverMaterial: f._hoverMaterial, disableMaterial: f._disableMaterial, active: !1, dragBehavior: f.dragBehavior }; null === (p = f._parent) || void 0 === p || p.addToAxisCache(f._gizmoMesh, C), f._pointerObserver = r.utilityLayerScene.onPointerObservable.add((function (e) { var t; if (!f._customMeshSet && (f._isHovered = !(-1 == C.colliderMeshes.indexOf(null === (t = null == e ? void 0 : e.pickInfo) || void 0 === t ? void 0 : t.pickedMesh)), !f._parent)) { var i = f.dragBehavior.enabled ? f._isHovered || f._dragging ? f._hoverMaterial : f._coloredMaterial : f._disableMaterial; f._setGizmoMeshMaterial(C.gizmoMeshes, i) } })), f.dragBehavior.onEnabledObservable.add((function (e) { f._setGizmoMeshMaterial(C.gizmoMeshes, e ? f._coloredMaterial : f._disableMaterial) })); var P = r._getSharedGizmoLight(); return P.includedOnlyMeshes = P.includedOnlyMeshes.concat(f._rootMesh.getChildMeshes()), f } 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) { void 0 === i && (i = !1); var r = gu("yPosMesh", { size: .4 * (1 + (t - 1) / 4) }, this.gizmoLayer.utilityLayerScene), n = Dc("cylinder", { diameterTop: .005 * t, height: .275, diameterBottom: .005 * t, tessellation: 96 }, this.gizmoLayer.utilityLayerScene); return r.scaling.scaleInPlace(.1), r.material = this._coloredMaterial, r.rotation.x = Math.PI / 2, r.position.z += .3, n.material = this._coloredMaterial, n.position.z += .1375, n.rotation.x = Math.PI / 2, i && (r.visibility = 0, n.visibility = 0), e.addChild(r), e.addChild(n), { arrowMesh: r, arrowTail: n } }, 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.attachedNode = this._parent.attachedNode) : (this.attachedMesh = null, this.attachedNode = 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._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach((function (e) { e && e.dispose() })), e.prototype.dispose.call(this) }, t.prototype.setCustomMesh = function (t, i) { var r = this; void 0 === i && (i = !1), e.prototype.setCustomMesh.call(this, t), i && (this._rootMesh.getChildMeshes().forEach((function (e) { e.material = r._coloredMaterial, e.color && (e.color = r._coloredMaterial.diffuseColor) })), this._customMeshSet = !1) }, t }(uu), Qf = function (e) { function t(t, i) { void 0 === t && (t = B.Gray()), void 0 === i && (i = lu.DefaultKeepDepthUtilityLayer); var r = e.call(this, i) || this; r._boundingDimensions = new R(1, 1, 1), r._renderObserver = null, r._pointerObserver = null, r._scaleDragSpeed = .2, r._tmpQuaternion = new P, r._tmpVector = new R(0, 0, 0), r._tmpRotationMatrix = new I, r.ignoreChildren = !1, r.includeChildPredicate = null, r.rotationSphereSize = .1, r.scaleBoxSize = .1, r.fixedDragMeshScreenSize = !1, r.fixedDragMeshBoundsSize = !1, r.fixedDragMeshScreenSizeDistanceFactor = 10, r.onDragStartObservable = new u, r.onScaleBoxDragObservable = new u, r.onScaleBoxDragEndObservable = new u, r.onRotationSphereDragObservable = new u, r.onRotationSphereDragEndObservable = new u, r.scalePivot = null, r._axisFactor = new R(1, 1, 1), r._existingMeshScale = new R, r._dragMesh = null, r._pointerDragBehavior = new wo, r.updateScale = !1, r._anchorMesh = new Ln("anchor", i.utilityLayerScene), r._coloredMaterial = new mc("", i.utilityLayerScene), r._coloredMaterial.disableLighting = !0, r._hoverColoredMaterial = new mc("", i.utilityLayerScene), r._hoverColoredMaterial.disableLighting = !0, r._lineBoundingBox = new Ln("", i.utilityLayerScene), r._lineBoundingBox.rotationQuaternion = new P; var n = []; n.push(Yu("lines", { points: [new R(0, 0, 0), new R(r._boundingDimensions.x, 0, 0)] }, i.utilityLayerScene)), n.push(Yu("lines", { points: [new R(0, 0, 0), new R(0, r._boundingDimensions.y, 0)] }, i.utilityLayerScene)), n.push(Yu("lines", { points: [new R(0, 0, 0), new R(0, 0, r._boundingDimensions.z)] }, i.utilityLayerScene)), n.push(Yu("lines", { points: [new R(r._boundingDimensions.x, 0, 0), new R(r._boundingDimensions.x, r._boundingDimensions.y, 0)] }, i.utilityLayerScene)), n.push(Yu("lines", { points: [new R(r._boundingDimensions.x, 0, 0), new R(r._boundingDimensions.x, 0, r._boundingDimensions.z)] }, i.utilityLayerScene)), n.push(Yu("lines", { points: [new R(0, r._boundingDimensions.y, 0), new R(r._boundingDimensions.x, r._boundingDimensions.y, 0)] }, i.utilityLayerScene)), n.push(Yu("lines", { points: [new R(0, r._boundingDimensions.y, 0), new R(0, r._boundingDimensions.y, r._boundingDimensions.z)] }, i.utilityLayerScene)), n.push(Yu("lines", { points: [new R(0, 0, r._boundingDimensions.z), new R(r._boundingDimensions.x, 0, r._boundingDimensions.z)] }, i.utilityLayerScene)), n.push(Yu("lines", { points: [new R(0, 0, r._boundingDimensions.z), new R(0, r._boundingDimensions.y, r._boundingDimensions.z)] }, i.utilityLayerScene)), n.push(Yu("lines", { points: [new R(r._boundingDimensions.x, r._boundingDimensions.y, r._boundingDimensions.z), new R(0, r._boundingDimensions.y, r._boundingDimensions.z)] }, i.utilityLayerScene)), n.push(Yu("lines", { points: [new R(r._boundingDimensions.x, r._boundingDimensions.y, r._boundingDimensions.z), new R(r._boundingDimensions.x, 0, r._boundingDimensions.z)] }, i.utilityLayerScene)), n.push(Yu("lines", { points: [new R(r._boundingDimensions.x, r._boundingDimensions.y, r._boundingDimensions.z), new R(r._boundingDimensions.x, r._boundingDimensions.y, 0)] }, i.utilityLayerScene)), n.forEach((function (e) { e.color = t, e.position.addInPlace(new R(-r._boundingDimensions.x / 2, -r._boundingDimensions.y / 2, -r._boundingDimensions.z / 2)), e.isPickable = !1, r._lineBoundingBox.addChild(e) })), r._rootMesh.addChild(r._lineBoundingBox), r.setColor(t), r._rotateSpheresParent = new Ln("", i.utilityLayerScene), r._rotateSpheresParent.rotationQuaternion = new P; for (var o = function (e) { var t = bu("", { diameter: 1 }, i.utilityLayerScene); t.rotationQuaternion = new P, t.material = a._coloredMaterial, t.isNearGrabbable = !0; var n = new wo({}); n.moveAttached = !1, n.updateDragPlane = !1, t.addBehavior(n); var o = new R(1, 0, 0), s = 0; n.onDragStartObservable.add((function () { o.copyFrom(t.forward), s = 0 })), n.onDragObservable.add((function (t) { if (r.onRotationSphereDragObservable.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"); Oo._RemoveAndStorePivotPoint(r.attachedMesh); var n = o, a = t.dragPlaneNormal.scale(R.Dot(t.dragPlaneNormal, n)), l = n.subtract(a).normalizeToNew(), c = R.Dot(l, t.delta) < 0 ? Math.abs(t.delta.length()) : -Math.abs(t.delta.length()); c = c / r._boundingDimensions.length() * r._anchorMesh.scaling.length(), r.attachedMesh.rotationQuaternion || (r.attachedMesh.rotationQuaternion = P.RotationYawPitchRoll(r.attachedMesh.rotation.y, r.attachedMesh.rotation.x, r.attachedMesh.rotation.z)), r._anchorMesh.rotationQuaternion || (r._anchorMesh.rotationQuaternion = P.RotationYawPitchRoll(r._anchorMesh.rotation.y, r._anchorMesh.rotation.x, r._anchorMesh.rotation.z)), s += c, Math.abs(s) <= 2 * Math.PI && (e >= 8 ? P.RotationYawPitchRollToRef(0, 0, c, r._tmpQuaternion) : e >= 4 ? P.RotationYawPitchRollToRef(c, 0, 0, r._tmpQuaternion) : P.RotationYawPitchRollToRef(0, c, 0, r._tmpQuaternion), r._anchorMesh.addChild(r.attachedMesh, uu.PreserveScaling), r._anchorMesh.getScene().useRightHandedSystem && r._tmpQuaternion.conjugateInPlace(), r._anchorMesh.rotationQuaternion.multiplyToRef(r._tmpQuaternion, r._anchorMesh.rotationQuaternion), r._anchorMesh.removeChild(r.attachedMesh, uu.PreserveScaling), r.attachedMesh.setParent(i, uu.PreserveScaling)), r.updateBoundingBox(), Oo._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 Ln("", 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 = gu("", { 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 wo({ dragAxis: o }); a.updateDragPlane = !1, a.moveAttached = !1, 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"); Oo._RemoveAndStorePivotPoint(r.attachedMesh); var a = e.dragDistance / r._boundingDimensions.length() * r._anchorMesh.scaling.length(), s = new R(a, a, a); 2 === t && (s.x *= Math.abs(o.x), s.y *= Math.abs(o.y), s.z *= Math.abs(o.z)), s.scaleInPlace(r._scaleDragSpeed), s.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._anchorMesh.addChild(r.attachedMesh, uu.PreserveScaling), r._anchorMesh.scaling.addInPlace(s), (r._anchorMesh.scaling.x < 0 || r._anchorMesh.scaling.y < 0 || r._anchorMesh.scaling.z < 0) && r._anchorMesh.scaling.subtractInPlace(s), r._anchorMesh.removeChild(r.attachedMesh, uu.PreserveScaling), r.attachedMesh.setParent(i, uu.PreserveScaling), Oo._RestorePivotPoint(r.attachedMesh) } r._updateDummy() })), a.onDragStartObservable.add((function () { r.onDragStartObservable.notifyObservers({}), r._selectNode(n) })), 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._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._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), Oo._RemoveAndStorePivotPoint(e); var i = e.parent; this._anchorMesh.addChild(e, uu.PreserveScaling), this._anchorMesh.removeChild(e, uu.PreserveScaling), e.setParent(i, uu.PreserveScaling), Oo._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) { Oo._RemoveAndStorePivotPoint(this.attachedMesh); var e = this.attachedMesh.parent; this.attachedMesh.setParent(null, uu.PreserveScaling), 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, uu.PreserveScaling) } this._updateRotationSpheres(), this._updateScaleBoxes(), this.attachedMesh && (this._existingMeshScale.copyFrom(this.attachedMesh.scaling), Oo._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 = gu("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 = gu("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 }(uu), qf = function (e) { function t(i, r, n, o, a, s, l) { var c; void 0 === r && (r = B.Gray()), void 0 === n && (n = lu.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 mc("", n.utilityLayerScene), d._coloredMaterial.diffuseColor = r, d._coloredMaterial.specularColor = r.subtract(new B(.1, .1, .1)), d._hoverMaterial = new mc("", n.utilityLayerScene), d._hoverMaterial.diffuseColor = B.Yellow(), d._disableMaterial = new mc("", n.utilityLayerScene), d._disableMaterial.diffuseColor = B.Gray(), d._disableMaterial.alpha = .4, d._gizmoMesh = new Jn("", n.utilityLayerScene); var p = (c = d._createGizmoMesh(d._gizmoMesh, l, o)).rotationMesh, f = c.collider; d._rotationDisplayPlane = No("rotationDisplay", { size: .6, updatable: !1 }, d.gizmoLayer.utilityLayerScene), d._rotationDisplayPlane.rotation.z = .5 * Math.PI, d._rotationDisplayPlane.parent = d._gizmoMesh, d._rotationDisplayPlane.setEnabled(!1), Vt.ShadersStore.rotationGizmoVertexShader = t._RotationGizmoVertexShader, Vt.ShadersStore.rotationGizmoFragmentShader = t._RotationGizmoFragmentShader, d._rotationShaderMaterial = new Gu("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, uu.PreserveScaling), d._gizmoMesh.scaling.scaleInPlace(1 / 3), d.dragBehavior = new wo({ 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._handlePivot(), 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); 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), 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 = Lc("ignore", { diameter: .6, thickness: .03 * t, tessellation: i }, this.gizmoLayer.utilityLayerScene); r.visibility = 0; var n = Lc("", { 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, uu.PreserveScaling), e.addChild(r, uu.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 }(uu), Zf = function (e) { function t(t, i, r, n, o, a) { void 0 === t && (t = lu.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.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 qf(new R(1, 0, 0), l, t, i, s, r, n), s.yGizmo = new qf(new R(0, 1, 0), c, t, i, s, r, n), s.zGizmo = new qf(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.onDragEndObservable.add((function () { s.onDragEndObservable.notifyObservers({}) })) })), s.attachedMesh = null, s.attachedNode = null, o ? o.addToAxisCache(s._gizmoAxisCache) : uu.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.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 }(uu), Jf = function (e) { function t(i, r, n, o) { void 0 === r && (r = B.Gray()), void 0 === n && (n = lu.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 mc("", n.utilityLayerScene), s._coloredMaterial.diffuseColor = r, s._coloredMaterial.specularColor = r.subtract(new B(.1, .1, .1)), s._hoverMaterial = new mc("", n.utilityLayerScene), s._hoverMaterial.diffuseColor = B.Yellow(), s._disableMaterial = new mc("", 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 wo({ dragPlaneNormal: i }), s.dragBehavior.moveAttached = !1, s._rootMesh.addBehavior(s.dragBehavior), s.dragBehavior.onDragObservable.add((function (e) { if (s.attachedNode) { if (s._handlePivot(), 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 On("plane", e), r = No("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 }(uu), $f = function (e) { function t(t, i, r) { void 0 === t && (t = lu.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.onDragEndObservable = new u, n._planarGizmoEnabled = !1, n.xGizmo = new hu(new R(1, 0, 0), B.Red().scale(.5), t, n, i), n.yGizmo = new hu(new R(0, 1, 0), B.Green().scale(.5), t, n, i), n.zGizmo = new hu(new R(0, 0, 1), B.Blue().scale(.5), t, n, i), n.xPlaneGizmo = new Jf(new R(1, 0, 0), B.Red().scale(.5), n.gizmoLayer, n), n.yPlaneGizmo = new Jf(new R(0, 1, 0), B.Green().scale(.5), n.gizmoLayer, n), n.zPlaneGizmo = new Jf(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.onDragEndObservable.add((function () { n.onDragEndObservable.notifyObservers({}) })) })), n.attachedMesh = null, r ? r.addToAxisCache(n._gizmoAxisCache) : uu.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.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 }(uu), e_ = function (e) { function t(t, i, r) { void 0 === t && (t = lu.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.onDragEndObservable = new u, n.uniformScaleGizmo = n._createUniformScaleMesh(), n.xGizmo = new Kf(new R(1, 0, 0), B.Red().scale(.5), t, n, i), n.yGizmo = new Kf(new R(0, 1, 0), B.Green().scale(.5), t, n, i), n.zGizmo = new Kf(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.onDragEndObservable.add((function () { n.onDragEndObservable.notifyObservers({}) })) })), n.attachedMesh = null, n.attachedNode = null, r ? r.addToAxisCache(n._gizmoAxisCache) : uu.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 mc("", this.gizmoLayer.utilityLayerScene), this._coloredMaterial.diffuseColor = B.Gray(), this._hoverMaterial = new mc("", this.gizmoLayer.utilityLayerScene), this._hoverMaterial.diffuseColor = B.Yellow(), this._disableMaterial = new mc("", this.gizmoLayer.utilityLayerScene), this._disableMaterial.diffuseColor = B.Gray(), this._disableMaterial.alpha = .4; var e = new Kf(new R(0, 1, 0), B.Gray().scale(.5), this.gizmoLayer, this); e.updateGizmoRotationToMatchAttachedMesh = !1, e.uniformScaling = !0, this._uniformScalingMesh = ph("uniform", { type: 1 }, e.gizmoLayer.utilityLayerScene), this._uniformScalingMesh.scaling.scaleInPlace(.01), this._uniformScalingMesh.visibility = 0, this._octahedron = ph("", { 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) { [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach((function (t) { t.coordinatesMode = 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.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.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 }(uu), t_ = function () { function e(e, t, i, r) { void 0 === t && (t = 1), void 0 === i && (i = lu.DefaultUtilityLayer), void 0 === r && (r = lu.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 = au.Local, this._gizmoAxisCache = new Map, this.boundingBoxDragBehavior = new Vo, 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 = uu.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 == Ji.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 Ln ? 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 $f(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 Zf(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 e_(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 Qf(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 !== lu._DefaultKeepDepthUtilityLayer && (null === (e = this._defaultKeepDepthUtilityLayer) || void 0 === e || e.dispose()), this._defaultUtilityLayer !== lu._DefaultUtilityLayer && (null === (t = this._defaultUtilityLayer) || void 0 === t || t.dispose()), this.boundingBoxDragBehavior.detach(), this.onAttachedToMeshObservable.clear() }, e }(), i_ = 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, Ar.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([Ie()], t.prototype, "position", null), X([Ie()], t.prototype, "direction", null), X([xe()], t.prototype, "shadowMinZ", null), X([xe()], t.prototype, "shadowMaxZ", null), t }(eo); ze.AddNodeConstructor("Light_Type_1", (function (e, t) { return function () { return new r_(e, R.Zero(), t) } })); var r_ = 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 eo.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.MIN_VALUE, this._orthoTop = Number.MIN_VALUE, this._orthoBottom = Number.MAX_VALUE; for (var o = Number.MAX_VALUE, a = Number.MIN_VALUE, s = 0; s < i.length; s++) { var l = i[s]; if (l) for (var c = l.getBoundingInfo().boundingBox, u = 0; u < c.vectorsWorld.length; u++)R.TransformCoordinatesToRef(c.vectorsWorld[u], t, n), n.x < this._orthoLeft && (this._orthoLeft = n.x), n.y < this._orthoBottom && (this._orthoBottom = n.y), n.x > this._orthoRight && (this._orthoRight = n.x), n.y > this._orthoTop && (this._orthoTop = n.y), this.autoCalcShadowZBounds && (n.z < o && (o = n.z), n.z > a && (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([xe()], t.prototype, "shadowFrustumSize", null), X([xe()], t.prototype, "shadowOrthoScale", null), X([xe()], t.prototype, "autoUpdateExtends", void 0), X([xe()], t.prototype, "autoCalcShadowZBounds", void 0), X([xe("orthoLeft")], t.prototype, "_orthoLeft", void 0), X([xe("orthoRight")], t.prototype, "_orthoRight", void 0), X([xe("orthoTop")], t.prototype, "_orthoTop", void 0), X([xe("orthoBottom")], t.prototype, "_orthoBottom", void 0), t }(i_); function n_(e, t, i) { void 0 === t && (t = {}), t.diameter || (t.diameter = 1), t.segments || (t.segments = 16); var r = bu("", { slice: .5, diameter: t.diameter, segments: t.segments }, i), n = Iu("", { radius: t.diameter / 2, tessellation: 3 * t.segments + (4 - t.segments) }, i); n.rotation.x = -Math.PI / 2, n.parent = r; var o = Jn.MergeMeshes([n, r], !0); return o.name = e, o } var o_ = { CreateHemisphere: n_ }; Jn.CreateHemisphere = function (e, t, i, r) { return n_(e, { segments: t, diameter: i }, r) }, ze.AddNodeConstructor("Light_Type_2", (function (e, t) { return function () { return new a_(e, R.Zero(), R.Zero(), 0, 0, t) } })); var a_ = 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 eo.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 vo) { 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([xe()], t.prototype, "angle", null), X([xe()], t.prototype, "innerAngle", null), X([xe()], t.prototype, "shadowAngleScale", null), X([xe()], t.prototype, "exponent", void 0), X([xe()], t.prototype, "projectionTextureLightNear", null), X([xe()], t.prototype, "projectionTextureLightFar", null), X([xe()], t.prototype, "projectionTextureUpDirection", null), X([Ae("projectedLightTexture")], t.prototype, "_projectionTexture", void 0), t }(i_), s_ = function (e) { function t(t) { void 0 === t && (t = lu.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 Ln("", i.gizmoLayer.utilityLayerScene), i._attachedMeshParent = new On("parent", i.gizmoLayer.utilityLayerScene), i.attachedMesh.parent = i._attachedMeshParent, i._material = new mc("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)) }), Ji.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 Zl ? t._CreateHemisphericLightMesh(this.gizmoLayer.utilityLayerScene) : e instanceof r_ ? t._CreateDirectionalLightMesh(this.gizmoLayer.utilityLayerScene) : e instanceof a_ ? 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 Jn("hemisphereLight", e), r = n_(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 Jn("pointLight", e), r = bu(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 Jn("spotLight", e); bu(i.name, { segments: 10, diameter: 1 }, e).parent = i; var r = n_(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 Jn("directionalLight", e), r = new Jn(i.name, e); r.parent = i, bu(i.name, { diameter: 1.2, segments: 10 }, e).parent = r; var n = Dc(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 = Dc(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 Jn("root", t); i.rotation.x = Math.PI / 2; var r = new Jn("linePivot", t); r.parent = i; var n = Dc("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 }(uu), l_ = function (e) { function t(t) { void 0 === t && (t = lu.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 mc("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)) }), Ji.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 Jn("rootCameraGizmo", e), r = new Jn(i.name, e); r.parent = i, gu(i.name, { width: 1, height: .8, depth: .5 }, e).parent = r; var n = Dc(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 = Dc(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 = Dc(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 Jn("rootCameraGizmo", e), i = new Jn(t.name, e); i.parent = t; for (var r = 0; r < 4; r += 2)for (var n = 0; n < 4; n += 2) { var o = Yu("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 = Yu("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 = Yu("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 }(uu); Ut.IncludesShadersStore.kernelBlurVaryingDeclaration = "varying vec2 sampleCoord{X};"; Ut.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);}"; Ut.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"; Ut.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"; Ut.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}"; Ut.IncludesShadersStore.kernelBlurVertex = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};"; Ut.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 c_ = function (e) { function t(t, i, r, n, o, s, l, c, u, h, d, p) { void 0 === s && (s = vo.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; l < r; l++) { var c = l / (r - 1), u = this._gaussianWeight(2 * c - 1); o[l] = l - n, a[l] = u, s += u } for (l = 0; l < a.length; l++)a[l] /= s; var h = [], d = [], p = []; for (l = 0; l <= n; l += 2) { var f = Math.min(l + 1, Math.floor(n)); if (l === f) p.push({ o: o[l], w: a[l] }); else { var _ = f === n, m = a[l] + a[f] * (_ ? .5 : 1), g = o[l] + 1 / (1 + a[l] / a[f]); 0 === g ? (p.push({ o: o[l], w: a[l] }), p.push({ o: o[l + 1], w: a[l + 1] })) : (p.push({ o: g, w: m }), p.push({ o: -g, w: m })) } } for (l = 0; l < p.length; l++)d[l] = p[l].o, h[l] = p[l].w; o = d, a = h; var v = this.getEngine().getCaps().maxVaryingVectors, y = Math.max(v, 0) - 1, b = Math.min(o.length, y), T = ""; for (T += this._staticDefines, -1 != this._staticDefines.indexOf("DOF") && (T += "#define CENTER_WEIGHT ".concat(this._glslFloat(a[b - 1]), "\n"), b--), l = 0; l < b; l++)T += "#define KERNEL_OFFSET".concat(l, " ").concat(this._glslFloat(o[l]), "\n"), T += "#define KERNEL_WEIGHT".concat(l, " ").concat(this._glslFloat(a[l]), "\n"); var E = 0; for (l = y; l < o.length; l++)T += "#define KERNEL_DEP_OFFSET".concat(E, " ").concat(this._glslFloat(o[l]), "\n"), T += "#define KERNEL_DEP_WEIGHT".concat(E, " ").concat(this._glslFloat(a[l]), "\n"), E++; this.packedFloat && (T += "#define PACKEDFLOAT 1"), this._blockCompilation = !1, e.prototype.updateEffect.call(this, T, null, null, { varyingCount: b, depCount: E }, t, i) }, t.prototype._nearestBestKernel = function (e) { for (var t = Math.round(e), i = 0, r = [t, t - 1, t + 1, t - 2, t + 2]; i < r.length; i++) { var n = r[i]; if (n % 2 != 0 && Math.floor(n / 2) % 2 == 0 && n > 0) 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 Ue.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([xe("kernel")], t.prototype, "_kernel", void 0), X([xe("packedFloat")], t.prototype, "_packedFloat", void 0), X([Pe()], t.prototype, "direction", void 0), t }(Ia); b("BABYLON.BlurPostProcess", c_); var u_ = function (e) { function t(t, i, r, n, o, s, l) { void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT), void 0 === s && (s = vo.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 gr(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 c_("horizontal blur", new A(1, 0), this._blurKernelX, this._blurRatio, null, vo.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 c_("vertical blur", new A(0, 1), this._blurKernelY, this._blurRatio, null, vo.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 }(es); vo._CreateMirror = function (e, t, i, r) { return new u_(e, t, i, r) }; var h_ = 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 = vo.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; f < o.length; f++)this._files.push(e + o[f]); this._extensions = o } s ? (this.delayLoadState = a.DELAYLOADSTATE_NOTLOADED, this._delayedOnLoad = i, this._delayedOnError = n) : this._loadTexture(i, n) }, t.prototype.delayLoad = function (e) { this.delayLoadState === a.DELAYLOADSTATE_NOTLOADED && (e && (this._forcedExtension = e), this.delayLoadState = a.DELAYLOADSTATE_LOADED, this._loadTexture(this._delayedOnLoad, this._delayedOnError)) }, t.prototype.getReflectionTextureMatrix = function () { return this._textureMatrix }, t.prototype.setReflectionTextureMatrix = function (e) { var t, i, r = this; if (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(r) }))), this._textureMatrix = e, null === (i = this.getScene()) || void 0 === i ? void 0 : i.useRightHandedSystem)) { var n = O.Vector3[0], o = O.Quaternion[0], s = O.Vector3[1]; this._textureMatrix.decompose(n, o, s), o.z *= -1, o.w *= -1, I.ComposeToRef(n, o, s, this._textureMatrixRefraction) } }, t.prototype.getRefractionTextureMatrix = function () { var e; return (null === (e = this.getScene()) || void 0 === e ? void 0 : e.useRightHandedSystem) ? this._textureMatrixRefraction : this._textureMatrix }, t.prototype._loadTexture = function (e, t) { var i, r = this; void 0 === e && (e = null), void 0 === t && (t = null); var n = this.getScene(), o = this._texture; this._texture = this._getFromCache(this.url, this._noMipmap, void 0, void 0, this._useSRGBBuffer, this.isCube); var s = function () { var t; r.onLoadObservable.notifyObservers(r), o && (o.dispose(), null === (t = r.getScene()) || void 0 === t || t.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)), e && e() }, l = function (e, i) { r._loadingError = !0, r._errorObject = { message: e, exception: i }, t && t(e, i), vo.OnTextureLoadErrorObservable.notifyObservers(r) }; this._texture ? this._texture.isReady ? xi.SetImmediate((function () { return s() })) : this._texture.onLoadedObservable.add((function () { return s() })) : (this._prefiltered ? this._texture = this._getEngine().createPrefilteredCubeTexture(this.url, n, this._lodScale, this._lodOffset, e, l, this._format, this._forcedExtension, this._createPolynomials) : this._texture = this._getEngine().createCubeTexture(this.url, n, this._files, this._noMipmap, e, l, this._format, this._forcedExtension, !1, this._lodScale, this._lodOffset, null, this._loaderOptions, !!this._useSRGBBuffer), null === (i = this._texture) || void 0 === i || i.onLoadedObservable.add((function () { return r.onLoadObservable.notifyObservers(r) }))) }, t.Parse = function (e, i, r) { var n = Ue.Parse((function () { var n, o = !1; return e.prefiltered && (o = e.prefiltered), new t(r + (null !== (n = e.url) && void 0 !== n ? n : e.name), i, e.extensions, !1, e.files || null, null, null, void 0, o, e.forcedExtension) }), e, i); if (e.boundingBoxPosition && (n.boundingBoxPosition = R.FromArray(e.boundingBoxPosition)), e.boundingBoxSize && (n.boundingBoxSize = R.FromArray(e.boundingBoxSize)), e.animations) for (var o = 0; o < e.animations.length; o++) { var a = e.animations[o], s = T("BABYLON.Animation"); s && n.animations.push(s.Parse(a)) } return n }, t.prototype.clone = function () { var e = this, i = 0, r = Ue.Clone((function () { var r = new t(e.url, e.getScene() || e._getEngine(), e._extensions, e._noMipmap, e._files); return i = r.uniqueId, r }), this); return r.uniqueId = i, r }, X([xe()], t.prototype, "url", void 0), X([Ie()], t.prototype, "boundingBoxPosition", void 0), X([Ie()], t.prototype, "boundingBoxSize", null), X([xe("rotationY")], t.prototype, "rotationY", null), X([xe("files")], t.prototype, "_files", void 0), X([xe("forcedExtension")], t.prototype, "_forcedExtension", void 0), X([xe("extensions")], t.prototype, "_extensions", void 0), X([Le("textureMatrix")], t.prototype, "_textureMatrix", void 0), X([Le("textureMatrixRefraction")], t.prototype, "_textureMatrixRefraction", void 0), t }(po); vo._CubeTextureParser = h_.Parse, b("BABYLON.CubeTexture", h_); Ut.IncludesShadersStore.backgroundFragmentDeclaration = "uniform vec4 vEyePosition;uniform vec4 vPrimaryColor;\n#ifdef USEHIGHLIGHTANDSHADOWCOLORS\nuniform vec4 vPrimaryColorShadow;\n#endif\nuniform float shadowLevel;uniform float alpha;\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;uniform mat4 reflectionMatrix;uniform vec3 vReflectionMicrosurfaceInfos;\n#endif\n#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)\nuniform vec3 vBackgroundCenter;\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 vReflectionControl;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n"; Ut.IncludesShadersStore.backgroundUboDeclaration = "layout(std140,column_major) uniform;uniform Material\n{uniform vec4 vPrimaryColor;uniform vec4 vPrimaryColorShadow;uniform vec2 vDiffuseInfos;uniform vec2 vReflectionInfos;uniform mat4 diffuseMatrix;uniform mat4 reflectionMatrix;uniform vec3 vReflectionMicrosurfaceInfos;uniform float fFovMultiplier;uniform float pointSize;uniform float shadowLevel;uniform float alpha;\n#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)\nuniform vec3 vBackgroundCenter;\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 vReflectionControl;\n#endif\n};\n#include\n"; Ut.ShadersStore.backgroundPixelShader = "#ifdef TEXTURELODSUPPORT\n#extension GL_EXT_shader_texture_lod : enable\n#endif\nprecision highp float;\n#include<__decl__backgroundFragment>\n#include\n#define RECIPROCAL_PI2 0.15915494\nvarying vec3 vPositionW;\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif \n#ifdef MAINUV2 \nvarying vec2 vMainUV2; \n#endif \n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV==1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV==2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;uniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;uniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include\n#endif\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n#ifndef SHADOWONLY\n#define SHADOWONLY;\n#endif\n#include\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include\n#include\n#include\n#include\n#include\n#ifdef REFLECTIONFRESNEL\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\nvec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{float weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);return reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));}\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(0.0,1.0,0.0);\n#endif\nfloat shadow=1.;float globalShadow=0.;float shadowLightCount=0.;\n#include[0..maxSimultaneousLights]\n#ifdef SHADOWINUSE\nglobalShadow/=shadowLightCount;\n#else\nglobalShadow=1.0;\n#endif\n#ifndef BACKMAT_SHADOWONLY\nvec4 reflectionColor=vec4(1.,1.,1.,1.);\n#ifdef REFLECTION\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#ifdef REFLECTIONBLUR\nfloat reflectionLOD=vReflectionInfos.y;\n#ifdef TEXTURELODSUPPORT\nreflectionLOD=reflectionLOD*log2(vReflectionMicrosurfaceInfos.x)*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;reflectionColor=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);\n#else\nfloat lodReflectionNormalized=saturate(reflectionLOD);float lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;vec4 reflectionSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);if(lodReflectionNormalizedDoubled<1.0){reflectionColor=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nreflectionSpecularMid,\nlodReflectionNormalizedDoubled\n);} else {reflectionColor=mix(\nreflectionSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);}\n#endif\n#else\nvec4 reflectionSample=sampleReflection(reflectionSampler,reflectionCoords);reflectionColor=reflectionSample;\n#endif\n#ifdef RGBDREFLECTION\nreflectionColor.rgb=fromRGBD(reflectionColor);\n#endif\n#ifdef GAMMAREFLECTION\nreflectionColor.rgb=toLinearSpace(reflectionColor.rgb);\n#endif\n#ifdef REFLECTIONBGR\nreflectionColor.rgb=reflectionColor.bgr;\n#endif\nreflectionColor.rgb*=vReflectionInfos.x;\n#endif\nvec3 diffuseColor=vec3(1.,1.,1.);float finalAlpha=alpha;\n#ifdef DIFFUSE\nvec4 diffuseMap=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef GAMMADIFFUSE\ndiffuseMap.rgb=toLinearSpace(diffuseMap.rgb);\n#endif\ndiffuseMap.rgb*=vDiffuseInfos.y;\n#ifdef DIFFUSEHASALPHA\nfinalAlpha*=diffuseMap.a;\n#endif\ndiffuseColor=diffuseMap.rgb;\n#endif\n#ifdef REFLECTIONFRESNEL\nvec3 colorBase=diffuseColor;\n#else\nvec3 colorBase=reflectionColor.rgb*diffuseColor;\n#endif\ncolorBase=max(colorBase,0.0);\n#ifdef USERGBCOLOR\nvec3 finalColor=colorBase;\n#else\n#ifdef USEHIGHLIGHTANDSHADOWCOLORS\nvec3 mainColor=mix(vPrimaryColorShadow.rgb,vPrimaryColor.rgb,colorBase);\n#else\nvec3 mainColor=vPrimaryColor.rgb;\n#endif\nvec3 finalColor=colorBase*mainColor;\n#endif\n#ifdef REFLECTIONFRESNEL\nvec3 reflectionAmount=vReflectionControl.xxx;vec3 reflectionReflectance0=vReflectionControl.yyy;vec3 reflectionReflectance90=vReflectionControl.zzz;float VdotN=dot(normalize(vEyePosition.xyz),normalW);vec3 planarReflectionFresnel=fresnelSchlickEnvironmentGGX(saturate(VdotN),reflectionReflectance0,reflectionReflectance90,1.0);reflectionAmount*=planarReflectionFresnel;\n#ifdef REFLECTIONFALLOFF\nfloat reflectionDistanceFalloff=1.0-saturate(length(vPositionW.xyz-vBackgroundCenter)*vReflectionControl.w);reflectionDistanceFalloff*=reflectionDistanceFalloff;reflectionAmount*=reflectionDistanceFalloff;\n#endif\nfinalColor=mix(finalColor,reflectionColor.rgb,saturate(reflectionAmount));\n#endif\n#ifdef OPACITYFRESNEL\nfloat viewAngleToFloor=dot(normalW,normalize(vEyePosition.xyz-vBackgroundCenter));const float startAngle=0.1;float fadeFactor=saturate(viewAngleToFloor/startAngle);finalAlpha*=fadeFactor*fadeFactor;\n#endif\n#ifdef SHADOWINUSE\nfinalColor=mix(finalColor*shadowLevel,finalColor,globalShadow);\n#endif\nvec4 color=vec4(finalColor,finalAlpha);\n#else\nvec4 color=vec4(vPrimaryColor.rgb,(1.0-clamp(globalShadow,0.,1.))*alpha);\n#endif\n#include\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n#if !defined(SKIPFINALCOLORCLAMP)\ncolor.rgb=clamp(color.rgb,0.,30.0);\n#endif\n#else\ncolor=applyImageProcessing(color);\n#endif\n#ifdef PREMULTIPLYALPHA\ncolor.rgb*=color.a;\n#endif\n#ifdef NOISE\ncolor.rgb+=dither(vPositionW.xy,0.5);color=max(color,0.0);\n#endif\ngl_FragColor=color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n"; Ut.IncludesShadersStore.backgroundVertexDeclaration = "uniform mat4 view;uniform mat4 viewProjection;uniform float shadowLevel;\n#ifdef DIFFUSE\nuniform mat4 diffuseMatrix;uniform vec2 vDiffuseInfos;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;uniform mat4 reflectionMatrix;uniform vec3 vReflectionMicrosurfaceInfos;uniform float fFovMultiplier;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n"; Ut.ShadersStore.backgroundVertexShader = "precision highp float;\n#include<__decl__backgroundVertex>\n#include\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include\n#include\n#include\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV==0\nvarying vec2 vDiffuseUV;\n#endif\n#include\n#include\n#include<__decl__lightVxFragment>[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=position;\n#endif\n#include\n#include\n#include\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR==0u) {gl_Position=viewProjection*finalWorld*vec4(position,1.0);} else {gl_Position=viewProjectionR*finalWorld*vec4(position,1.0);}\n#else\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#endif\nvec4 worldPos=finalWorld*vec4(position,1.0);vPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normal);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(position,0.0)));\n#ifdef EQUIRECTANGULAR_RELFECTION_FOV\nmat3 screenToWorld=inverseMat3(mat3(finalWorld*viewProjection));vec3 segment=mix(vDirectionW,screenToWorld*vec3(0.0,0.0,1.0),abs(fFovMultiplier-1.0));if (fFovMultiplier<=1.0) {vDirectionW=normalize(segment);} else {vDirectionW=normalize(vDirectionW+(vDirectionW-segment));}\n#endif\n#endif\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV==0\nif (vDiffuseInfos.x==0.)\n{vDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));}\nelse\n{vDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));}\n#endif\n#include\n#include\n#include[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n"; var d_ = function (e) { function t() { var t = e.call(this) || this; return t.DIFFUSE = !1, t.DIFFUSEDIRECTUV = 0, t.GAMMADIFFUSE = !1, t.DIFFUSEHASALPHA = !1, t.OPACITYFRESNEL = !1, t.REFLECTIONBLUR = !1, t.REFLECTIONFRESNEL = !1, t.REFLECTIONFALLOFF = !1, t.TEXTURELODSUPPORT = !1, t.PREMULTIPLYALPHA = !1, t.USERGBCOLOR = !1, t.USEHIGHLIGHTANDSHADOWCOLORS = !1, t.BACKMAT_SHADOWONLY = !1, t.NOISE = !1, t.REFLECTIONBGR = !1, t.IMAGEPROCESSING = !1, t.VIGNETTE = !1, t.VIGNETTEBLENDMODEMULTIPLY = !1, t.VIGNETTEBLENDMODEOPAQUE = !1, t.TONEMAPPING = !1, t.TONEMAPPING_ACES = !1, t.CONTRAST = !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.EXPOSURE = !1, t.MULTIVIEW = !1, t.REFLECTION = !1, t.REFLECTIONMAP_3D = !1, t.REFLECTIONMAP_SPHERICAL = !1, t.REFLECTIONMAP_PLANAR = !1, t.REFLECTIONMAP_CUBIC = !1, t.REFLECTIONMAP_PROJECTION = !1, t.REFLECTIONMAP_SKYBOX = !1, t.REFLECTIONMAP_EXPLICIT = !1, t.REFLECTIONMAP_EQUIRECTANGULAR = !1, t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1, t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1, t.INVERTCUBICMAP = !1, t.REFLECTIONMAP_OPPOSITEZ = !1, t.LODINREFLECTIONALPHA = !1, t.GAMMAREFLECTION = !1, t.RGBDREFLECTION = !1, t.EQUIRECTANGULAR_RELFECTION_FOV = !1, t.MAINUV1 = !1, t.MAINUV2 = !1, t.UV1 = !1, t.UV2 = !1, t.CLIPPLANE = !1, t.CLIPPLANE2 = !1, t.CLIPPLANE3 = !1, t.CLIPPLANE4 = !1, t.CLIPPLANE5 = !1, t.CLIPPLANE6 = !1, t.POINTSIZE = !1, t.FOG = !1, t.NORMAL = !1, t.NUM_BONE_INFLUENCERS = 0, t.BonesPerMesh = 0, t.INSTANCES = !1, t.SHADOWFLOAT = !1, t.LOGARITHMICDEPTH = !1, t.NONUNIFORMSCALING = !1, t.ALPHATEST = !1, t.rebuild(), t } return W(t, e), t }(Mi), p_ = function (e) { function t(t, i) { var r = e.call(this, t, i) || this; return r.primaryColor = B.White(), r._primaryColorShadowLevel = 0, r._primaryColorHighlightLevel = 0, r.reflectionTexture = null, r.reflectionBlur = 0, r.diffuseTexture = null, r._shadowLights = null, r.shadowLights = null, r.shadowLevel = 0, r.sceneCenter = R.Zero(), r.opacityFresnel = !0, r.reflectionFresnel = !1, r.reflectionFalloffDistance = 0, r.reflectionAmount = 1, r.reflectionReflectance0 = .05, r.reflectionReflectance90 = .5, r.useRGBColor = !0, r.enableNoise = !1, r._fovMultiplier = 1, r.useEquirectangularFOV = !1, r._maxSimultaneousLights = 4, r.maxSimultaneousLights = 4, r._shadowOnly = !1, r.shadowOnly = !1, r._imageProcessingObserver = null, r.switchToBGR = !1, r._renderTargets = new Ci(16), r._reflectionControls = C.Zero(), r._white = B.White(), r._primaryShadowColor = B.Black(), r._primaryHighlightColor = B.Black(), r._attachImageProcessingConfiguration(null), r.getRenderTargetTextures = function () { return r._renderTargets.reset(), r._diffuseTexture && r._diffuseTexture.isRenderTarget && r._renderTargets.push(r._diffuseTexture), r._reflectionTexture && r._reflectionTexture.isRenderTarget && r._renderTargets.push(r._reflectionTexture), r._renderTargets }, r } return W(t, e), Object.defineProperty(t.prototype, "_perceptualColor", { get: function () { return this.__perceptualColor }, set: function (e) { this.__perceptualColor = e, this._computePrimaryColorFromPerceptualColor(), this._markAllSubMeshesAsLightsDirty() }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "primaryColorShadowLevel", { get: function () { return this._primaryColorShadowLevel }, set: function (e) { this._primaryColorShadowLevel = e, this._computePrimaryColors(), this._markAllSubMeshesAsLightsDirty() }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "primaryColorHighlightLevel", { get: function () { return this._primaryColorHighlightLevel }, set: function (e) { this._primaryColorHighlightLevel = e, this._computePrimaryColors(), this._markAllSubMeshesAsLightsDirty() }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "reflectionStandardFresnelWeight", { set: function (e) { var i = e; i < .5 ? (i *= 2, this.reflectionReflectance0 = t.StandardReflectance0 * i, this.reflectionReflectance90 = t.StandardReflectance90 * i) : (i = 2 * i - 1, this.reflectionReflectance0 = t.StandardReflectance0 + (1 - t.StandardReflectance0) * i, this.reflectionReflectance90 = t.StandardReflectance90 + (1 - t.StandardReflectance90) * i) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fovMultiplier", { get: function () { return this._fovMultiplier }, set: function (e) { isNaN(e) && (e = 1), this._fovMultiplier = Math.max(0, Math.min(2, e)) }, 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._computePrimaryColorFromPerceptualColor(), t._markAllSubMeshesAsImageProcessingDirty() })))) }, 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 }), Object.defineProperty(t.prototype, "hasRenderTargetTextures", { get: function () { return !(!this._diffuseTexture || !this._diffuseTexture.isRenderTarget) || !(!this._reflectionTexture || !this._reflectionTexture.isRenderTarget) }, enumerable: !1, configurable: !0 }), t.prototype.needAlphaTesting = function () { return !0 }, t.prototype.needAlphaBlending = function () { return this.alpha < 1 || null != this._diffuseTexture && this._diffuseTexture.hasAlpha || this._shadowOnly }, t.prototype.isReadyForSubMesh = function (e, t, i) { if (void 0 === i && (i = !1), t.effect && this.isFrozen && t.effect._wasPreviouslyReady && t.effect._wasPreviouslyUsingInstances === i) return !0; t.materialDefines || (t.materialDefines = new d_); var r = this.getScene(), n = t.materialDefines; if (this._isReadyForSubMesh(t)) return !0; var o = r.getEngine(); if (zn.PrepareDefinesForLights(r, e, n, !1, this._maxSimultaneousLights), n._needNormals = !0, zn.PrepareDefinesForMultiview(r, n), n._areTexturesDirty) { if (n._needUVs = !1, r.texturesEnabled) { if (r.getEngine().getCaps().textureLOD && (n.TEXTURELODSUPPORT = !0), this._diffuseTexture && ic.DiffuseTextureEnabled) { if (!this._diffuseTexture.isReadyOrNotBlocking()) return !1; zn.PrepareDefinesForMergedUV(this._diffuseTexture, n, "DIFFUSE"), n.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha, n.GAMMADIFFUSE = this._diffuseTexture.gammaSpace, n.OPACITYFRESNEL = this._opacityFresnel } else n.DIFFUSE = !1, n.DIFFUSEDIRECTUV = 0, n.DIFFUSEHASALPHA = !1, n.GAMMADIFFUSE = !1, n.OPACITYFRESNEL = !1; var s = this._reflectionTexture; if (s && ic.ReflectionTextureEnabled) { if (!s.isReadyOrNotBlocking()) return !1; switch (n.REFLECTION = !0, n.GAMMAREFLECTION = s.gammaSpace, n.RGBDREFLECTION = s.isRGBD, n.REFLECTIONBLUR = this._reflectionBlur > 0, n.LODINREFLECTIONALPHA = s.lodLevelInAlpha, n.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV, n.REFLECTIONBGR = this.switchToBGR, s.coordinatesMode === vo.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 vo.EXPLICIT_MODE: n.REFLECTIONMAP_EXPLICIT = !0; break; case vo.PLANAR_MODE: n.REFLECTIONMAP_PLANAR = !0; break; case vo.PROJECTION_MODE: n.REFLECTIONMAP_PROJECTION = !0; break; case vo.SKYBOX_MODE: n.REFLECTIONMAP_SKYBOX = !0; break; case vo.SPHERICAL_MODE: n.REFLECTIONMAP_SPHERICAL = !0; break; case vo.EQUIRECTANGULAR_MODE: n.REFLECTIONMAP_EQUIRECTANGULAR = !0; break; case vo.FIXED_EQUIRECTANGULAR_MODE: n.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !0; break; case vo.FIXED_EQUIRECTANGULAR_MIRRORED_MODE: n.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !0; break; case vo.CUBIC_MODE: case vo.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 (zn.PrepareDefinesForMisc(e, r, !1, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(e), n), zn.PrepareDefinesForFrameBoundValues(r, o, this, n, i, null, t.getRenderingMesh().hasThinInstances), zn.PrepareDefinesForAttributes(e, n, !1, !0, !1) && e && (r.getEngine().getCaps().standardDerivatives || e.isVerticesDataPresent(Hi.NormalKind) || (e.createNormals(!0), $.Warn("BackgroundMaterial: Normals have been created for the mesh: " + e.name))), n.isDirty) { n.markAsProcessed(), r.resetCachedMaterial(); var l = new Ra; n.FOG && l.addFallback(0, "FOG"), n.POINTSIZE && l.addFallback(1, "POINTSIZE"), n.MULTIVIEW && l.addFallback(0, "MULTIVIEW"), zn.HandleFallbacksForShadows(n, l, this._maxSimultaneousLights); var c = [Hi.PositionKind]; n.NORMAL && c.push(Hi.NormalKind), n.UV1 && c.push(Hi.UVKind), n.UV2 && c.push(Hi.UV2Kind), zn.PrepareAttributesForBones(c, e, n, l), zn.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"]; wn(u); var h = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"], d = ["Material", "Scene"]; Ni && (Ni.PrepareUniforms(u, n), Ni.PrepareSamplers(h, n)), zn.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.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), zn.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 && ic.DiffuseTextureEnabled && (this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level), zn.BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse")), s && ic.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 && ic.DiffuseTextureEnabled && this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture), s && ic.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)))), Vn(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 && zn.BindLights(r, t, this._activeEffect, n, this._maxSimultaneousLights), this.bindView(o), zn.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 Ue.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 Ue.Parse((function () { return new t(e.name, i) }), e, i, r) }, t.StandardReflectance0 = .05, t.StandardReflectance90 = .5, X([Re()], t.prototype, "_primaryColor", void 0), X([Se("_markAllSubMeshesAsLightsDirty")], t.prototype, "primaryColor", void 0), X([Re()], t.prototype, "__perceptualColor", void 0), X([xe()], t.prototype, "_primaryColorShadowLevel", void 0), X([xe()], t.prototype, "_primaryColorHighlightLevel", void 0), X([Se("_markAllSubMeshesAsLightsDirty")], t.prototype, "primaryColorHighlightLevel", null), X([Ae()], t.prototype, "_reflectionTexture", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionTexture", void 0), X([xe()], t.prototype, "_reflectionBlur", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionBlur", void 0), X([Ae()], t.prototype, "_diffuseTexture", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "diffuseTexture", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "shadowLights", void 0), X([xe()], t.prototype, "_shadowLevel", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "shadowLevel", void 0), X([Ie()], t.prototype, "_sceneCenter", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "sceneCenter", void 0), X([xe()], t.prototype, "_opacityFresnel", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "opacityFresnel", void 0), X([xe()], t.prototype, "_reflectionFresnel", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionFresnel", void 0), X([xe()], t.prototype, "_reflectionFalloffDistance", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionFalloffDistance", void 0), X([xe()], t.prototype, "_reflectionAmount", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionAmount", void 0), X([xe()], t.prototype, "_reflectionReflectance0", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionReflectance0", void 0), X([xe()], t.prototype, "_reflectionReflectance90", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionReflectance90", void 0), X([xe()], t.prototype, "_useRGBColor", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRGBColor", void 0), X([xe()], t.prototype, "_enableNoise", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "enableNoise", void 0), X([xe()], t.prototype, "_maxSimultaneousLights", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "maxSimultaneousLights", void 0), X([xe()], t.prototype, "_shadowOnly", void 0), X([Se("_markAllSubMeshesAsLightsDirty")], t.prototype, "shadowOnly", void 0), X([Ne()], t.prototype, "_imageProcessingConfiguration", void 0), t }(ta); b("BABYLON.BackgroundMaterial", p_); var f_ = 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 po) this._scene.environmentTexture = this._options.environmentTexture; else { var e = h_.CreateFromPrefilteredData(this._options.environmentTexture, this._scene); this._scene.environmentTexture = e } }, e.prototype._setupBackground = function () { this._rootMesh || (this._rootMesh = new Jn("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 nl && 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 = No("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 p_("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 po ? this._groundMaterial.diffuseTexture = this._options.groundTexture : (this._groundTexture = new vo(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 = vo.CLAMP_ADDRESSMODE; if (!this._groundMirror && (this._groundMirror = new u_("BackgroundPlaneMirrorTexture", { ratio: this._options.groundMirrorSizeRatio }, this._scene, !1, this._options.groundMirrorTextureType, vo.BILINEAR_SAMPLINGMODE, !0), this._groundMirror.mirrorPlane = new gr(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; i < this._scene.meshes.length; i++) { var r = this._scene.meshes[i]; r !== this._ground && r !== this._skybox && r !== this._rootMesh && this._groundMirror.renderList.push(r) } var n = this._options.groundColor.toGammaSpace(this._scene.getEngine().useExactSrgbConversions); this._groundMirror.clearColor = new U(n.r, n.g, n.b, 1), this._groundMirror.adaptiveBlurKernel = this._options.groundMirrorBlurKernel }, e.prototype._setupMirrorInGroundMaterial = function () { this._groundMaterial && (this._groundMaterial.reflectionTexture = this._groundMirror, this._groundMaterial.reflectionFresnel = !0, this._groundMaterial.reflectionAmount = this._options.groundMirrorAmount, this._groundMaterial.reflectionStandardFresnelWeight = this._options.groundMirrorFresnelWeight, this._groundMaterial.reflectionFalloffDistance = this._options.groundMirrorFallOffDistance) }, e.prototype._setupSkybox = function (e) { var t = this; this._skybox && !this._skybox.isDisposed() || (this._skybox = gu("BackgroundSkybox", { size: e.skyboxSize, sideOrientation: Jn.BACKSIDE }, this._scene), this._skybox.onDisposeObservable.add((function () { t._skybox = null }))), this._skybox.parent = this._rootMesh }, e.prototype._setupSkyboxMaterial = function () { this._skybox && (this._skyboxMaterial || (this._skyboxMaterial = new p_("BackgroundSkyboxMaterial", this._scene)), this._skyboxMaterial.useRGBColor = !1, this._skyboxMaterial.primaryColor = this._options.skyboxColor, this._skyboxMaterial.enableNoise = !0, this._skybox.material = this._skyboxMaterial) }, e.prototype._setupSkyboxReflectionTexture = function () { this._skyboxMaterial && (this._skyboxTexture || (this._options.skyboxTexture instanceof po ? this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture : (this._skyboxTexture = new h_(this._options.skyboxTexture, this._scene, void 0, void 0, void 0, void 0, this._errorHandler), this._skyboxTexture.coordinatesMode = vo.SKYBOX_MODE, this._skyboxTexture.gammaSpace = !1, this._skyboxMaterial.reflectionTexture = this._skyboxTexture))) }, e.prototype.dispose = function () { this._groundMaterial && this._groundMaterial.dispose(!0, !0), this._skyboxMaterial && this._skyboxMaterial.dispose(!0, !0), this._rootMesh.dispose(!1) }, e._GroundTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundGround.png", e._SkyboxTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundSkybox.dds", e._EnvironmentTextureCDNUrl = "https://assets.babylonjs.com/environments/environmentSpecular.env", e }(), __ = function (e) { function t(i, r, n, o, a) { void 0 === a && (a = null); var s = e.call(this, i, o) || this; s.onError = a, s._halfDome = !1, s._crossEye = !1, s._useDirectMapping = !1, s._textureMode = t.MODE_MONOSCOPIC, s._onBeforeCameraRenderObserver = null, s.onLoadErrorObservable = new u, s.onLoadObservable = new u, o = s.getScene(), i = i || "textureDome", n.resolution = 0 | Math.abs(n.resolution) || 32, n.clickToPlay = Boolean(n.clickToPlay), n.autoPlay = void 0 === n.autoPlay || Boolean(n.autoPlay), n.loop = void 0 === n.loop || Boolean(n.loop), n.size = Math.abs(n.size) || (o.activeCamera ? .48 * o.activeCamera.maxZ : 1e3), void 0 === n.useDirectMapping ? s._useDirectMapping = !0 : s._useDirectMapping = n.useDirectMapping, void 0 === n.faceForward && (n.faceForward = !0), s._setReady(!1), n.mesh ? s._mesh = n.mesh : s._mesh = bu(i + "_mesh", { segments: n.resolution, diameter: n.size, updatable: !1, sideOrientation: Jn.BACKSIDE }, o); var l = s._material = new p_(i + "_material", o); l.useEquirectangularFOV = !0, l.fovMultiplier = 1, l.opacityFresnel = !1; var c = s._initTexture(r, o, n); if (s.texture = c, s._mesh.material = l, s._mesh.parent = s, s._halfDomeMask = bu("", { slice: .5, diameter: .98 * n.size, segments: 2 * n.resolution, sideOrientation: Jn.BACKSIDE }, o), s._halfDomeMask.rotate(Ar.X, -Math.PI / 2), s._halfDomeMask.parent = s._mesh, s._halfDome = !!n.halfDomeMode, s._halfDomeMask.setEnabled(s._halfDome), s._crossEye = !!n.crossEyeMode, s._texture.anisotropicFilteringLevel = 1, s._texture.onLoadObservable.addOnce((function () { s._setReady(!0) })), n.faceForward && o.activeCamera) { var h = o.activeCamera, d = R.Forward(), p = R.TransformNormal(d, h.getViewMatrix()); p.normalize(), s.rotation.y = Math.acos(R.Dot(d, p)) } return s._changeTextureMode(s._textureMode), s } return W(t, e), Object.defineProperty(t.prototype, "texture", { get: function () { return this._texture }, set: function (e) { this._texture !== e && (this._texture = e, this._useDirectMapping ? (this._texture.wrapU = vo.CLAMP_ADDRESSMODE, this._texture.wrapV = vo.CLAMP_ADDRESSMODE, this._material.diffuseTexture = this._texture) : (this._texture.coordinatesMode = vo.FIXED_EQUIRECTANGULAR_MIRRORED_MODE, this._texture.wrapV = vo.CLAMP_ADDRESSMODE, this._material.reflectionTexture = this._texture), this._changeTextureMode(this._textureMode)) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "mesh", { get: function () { return this._mesh }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fovMultiplier", { get: function () { return this._material.fovMultiplier }, set: function (e) { this._material.fovMultiplier = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "textureMode", { get: function () { return this._textureMode }, set: function (e) { this._textureMode !== e && this._changeTextureMode(e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "halfDome", { get: function () { return this._halfDome }, set: function (e) { this._halfDome = e, this._halfDomeMask.setEnabled(e), this._changeTextureMode(this._textureMode) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "crossEye", { get: function () { return this._crossEye }, set: function (e) { this._crossEye = e, this._changeTextureMode(this._textureMode) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "material", { get: function () { return this._material }, enumerable: !1, configurable: !0 }), t.prototype._changeTextureMode = function (e) { var i = this; switch (this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver), this._textureMode = e, this._texture.uScale = 1, this._texture.vScale = 1, this._texture.uOffset = 0, this._texture.vOffset = 0, this._texture.vAng = 0, e) { case t.MODE_MONOSCOPIC: this._halfDome && (this._texture.uScale = 2, this._texture.uOffset = -1); break; case t.MODE_SIDEBYSIDE: this._texture.uScale = this._halfDome ? .99999 : .5; var r = this._halfDome ? 0 : .5, n = this._halfDome ? -.5 : 0; this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add((function (e) { var t = e.isRightCamera; i._crossEye && (t = !t), i._texture.uOffset = t ? r : n })); break; case t.MODE_TOPBOTTOM: this._texture.vScale = this._halfDome ? .99999 : .5, this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add((function (e) { var t = e.isRightCamera; i._crossEye && (t = !t), i._texture.vOffset = t ? .5 : 0 })) } }, t.prototype.dispose = function (t, i) { void 0 === i && (i = !1), this._texture.dispose(), this._mesh.dispose(), this._material.dispose(), this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver), this.onLoadErrorObservable.clear(), this.onLoadObservable.clear(), e.prototype.dispose.call(this, t, i) }, t.MODE_MONOSCOPIC = 0, t.MODE_TOPBOTTOM = 1, t.MODE_SIDEBYSIDE = 2, t }(On), m_ = function (e) { function t() { return null !== e && e.apply(this, arguments) || this } return W(t, e), Object.defineProperty(t.prototype, "photoTexture", { get: function () { return this.texture }, set: function (e) { this.texture = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "imageMode", { 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; return new vo(e, t, !i.generateMipMaps, !this._useDirectMapping, void 0, (function () { r.onLoadObservable.notifyObservers() }), (function (e, t) { r.onLoadErrorObservable.notifyObservers(e || "Unknown error occured"), r.onError && r.onError(e, t) })) }, t.MODE_MONOSCOPIC = __.MODE_MONOSCOPIC, t.MODE_TOPBOTTOM = __.MODE_TOPBOTTOM, t.MODE_SIDEBYSIDE = __.MODE_SIDEBYSIDE, t }(__), g_ = 0, v_ = function (e) { if (!e.environmentBRDFTexture) { var t = e.useDelayedTextureLoading; e.useDelayedTextureLoading = !1; var i = e._blockEntityCollection; e._blockEntityCollection = !1; var r = vo.CreateFromBase64String("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAgAElEQVR42u29yY5tWXIlZnbuiSaTbZFUkZRKrCKhElASQA0EoQABgn6hJvoXzfUP+gP9hWb6Bg00IgRoQJaKqUxmZmTEe8/v0uB2u7Fm2T7HIyIrnz88uPvt3f2a2WrMbOvf/u3PvvzP/sUf/N6//i8vf/lv/3v5H//d//Sb//Uq/5u8yf8hV/m/5Cp/L1f5hVzlG7nKJ7mKyJuIXN/hPwqXI/g++zq6rPI5u8z+WqfLre+zy7PrVv9L8brsMiGvk8XLmM/sdfHXal4e3ad6GXPdyu2ij8u/+uv/5cuf/OSLfdtEfvUr+dnf/d0X//t3H/7bf/hP//N/928h/0Yg/4VA/kogfyGQP5Wr/IFAvhbIlwK5CGQTPP+9z5uPeePJSW+yo2+s/GtN30Rnv1E+f5zxof9R/lSXv/nr//mrr3+i+5dfyX7ZZQP07Tffys//8R/l/9TtX7790T/7r/8G8pdy+/8XAvnnAvkzgfwzgfyxQP5AIL8vkJ8K5KsmMVzu1U7p5PA5AXxOAJ8TwPf7sX/51ZeXfcemqnp9w/W77/S7X/6T/vzf/7383RWCX3/z05/9i3/13/0PX//eX/2FyP8tIv+PiPy9iPy/IvIzEfm5iPxCRH4lIt/c/393//9BRD6KyKf7f488fP74/PH544dJAF9cLl98IZfLBZtuqterXr/7Dt9982v95S9+Lv+gF/3i7Spv/8lf/vnf/vGf/dF/JfKnIvLnIvLvReQ/NEngn0TklyLy6/v/34jIt00iGJOBlxAsdvv54/PH5493SQCXy9t2ueh2ueimKorrFbjq9eNH+fDtb+TXv/ol/vHyhX4Fxfbx7euPf/Lnf/PfiPyeiPyhiPxxkwB+fk8AvxzQgJcIrGTwFsiAEXH4/PH54/PHUgLY7whgu2C7bLqpQgHB2xvePn6SDx8+6G9+84384vKF/IPu8iVU9Y/+7C/+jWxffiHytYj8VER+X0T+oEEBvxqQwCMJeIngo5EI3goIwVMIPn98/vj8ESaAbbtu2ybbvl8u2ybbdtluSECA65u8ffqIDx8+6G++/VZ/efkV/sO261dQXP7wT/7kX8vl8qXIFyLylbySwe/dE0CLAr65B/9vGn0gQwRMMqgmhM/J4fPH548eAezbZd/lsm3YtssNAYiqiogAAkCvb5/k46cP8u2HD/rrb7+R/2/b9Wu9yJe//8d/9Ney6S5yEZFdRL68/38khG/uKOCnAwoYkcCoEXwkEgGDDq7CeQfyOTl8/vhd1QCum26ybZtu2yabbrKpQvXue1yvuF6v+vbpTT5+/CDffviAX1++1V9sO77WXb/66R/+4V/dgkbllQi+aBLBV/dE8LWRALwkYCWCNyMZXElkwLTMeMkga/P4/PH547ccAVwuctkvdxSw6bbdtYDbTfSZBN7e8PHTR/3u4wf55vKd/nL7DX6mu3791U9//5+/gkNFZGuSgZUQvnKowKgLWLTAQgRtEniTuEfwaELw0MJvf3LQzynud+53uG+X6y3gN9kul+2y6XVT1U27JCDAFVc8ksAn/e7jR/nN5YP+avtWfq6Xy9f7Vz/9w1dgRYngiyYhfNkkgzYBWHTg44AEMmqQUYQKOmDaiCIa8TmsfmzB+DnZDQjgcpGLbti2y3bZHjRAdRMVvb/dcYU8kcDbPQlsH/CrbddfbF98+RPZfvLFnAQeieCRDC5DMvju/vmD4JkEvjRQgKULeGggowdHkAHTYxihg89vu88I5UeGAPSOAFTlrgPopiqbKPSmCKreUoAAkCcSePukHz590m8vH+WbD9/JP335k6/+tA86KxFchv8jMvhiogE4JQm8XhfKqOAqx5qRPyeGzx8/cgSwbXcUoLJtim27C4Oi93+4v6VxQwKAvl2v+Hj9pB8+fZJvt4/yzfbF9lPdv/wJnsE2BogmyeCRED40tGFvksIXiSbgiYSRRpDNDZ6BDI6ghM+J4fPHeyKAO+zX7cb9t4tedMMNAQju5V+f1uAtBSiu1zsduMrHy5t8ePsk3376KN98sX/xE5FPAnm7/782o0DiUINXMkCXCB7/P94/e87AWUmARQWVvgMuKej9t1RLBp+Tw+ePgwngsutFFdu26WXbbl+rSvdfbnqAiuA23QcBgCugV1zl7e1NPm5v+LC96XfbJ/1W9y++fgXjA3bDYXV+MuhRwSPwL3JLMFYC+HS/LU8HYrGwIhwyNOF12SvgM4SgztdifP85MXz+KGsA2C6X7aJ6bXSAOwrY5OYIqGy3d5uq4P5GhABXuV6veLvRAf10fZMPb2/y3b7vX7+g+9v98/WOBq7GG7RNAlYy+Dgkhhb+Xxp0sE8IAC4SGAP/TbgVJK/PoJPBnAiwPKxsXfbbnRg+i3s/JAK4Q/4b9NfLtomBAqCickMBjy7BuywAUVyv8na94tMjCVzf9KNcLl/0SeA6oAEYb1i9g+FtSALb/bKL8/+t+wxXFMyswqiHoK4ToIgKqslgpg1qUC0QoYbvJZg/B/q5v4szHmPX7YEAsD0CX25OwEUVm9xag1+agKg+nxQArnKjAtDr9U0+Xd/k4/UqH7bL5YsewrcBBiMJZPRAp6TwQgWfjM9vgRbgUYGL8AvLWH2gqhesCokeUmCSwPsnhs8fP2YNYMO2XeSmAWxy2VQaXeDmDIhApf33rD4PTUCuV+DtCn27XuXT5ir8VmCJ2G5BpBM8/r/dEcJb8/0lEQMtJHA5TAlqNuLRhJChhEpSqFabH3di+G1AGj+W1/dyAR4IYJNNnuLf6+tWC9CHHiAtFhAIFLjK2/Uqn65X+SS67aK+3QeTDoy/IG2ogQ7fb/dAtz5vBgrYGqrwNtCHsVfgIvwK07OTQBURVNCBFpKCOjqCHn5L/67TgTN+fpySAC56nwSUi256kXsSuFGAVyLoUIDo8/Pz7fdoErr/v17lk162HbgHvFpIYDfoAJJfW4sGPjkU4VNAF8ZEcLmLhdc7kljdY1y1Dq9yLiI4IiRqcLujb138KIPn80ejATwRwIbtBvn1cqv+2J78/5EI5N4cJA8qIPcmwRsKAHDF9WYP6mV7VmrgLuTpxYTcMEW0LAmoQxFsuvAI8tv/a/C5fV2ZMMiKg++FCM7RDPRu8ebWY7VG6VJi+Bzk35MI2LsAckMAgwvQ0gC5DQjd3ABg2HQLAPpEAlZ1Bu7VV7MGHDFRAbo3VKsTbAY9sPWC/uvx86gBbDK3D1eEQS8pbAeSgSwmhepnJb6uBv/o/PzHLzxWA/X7TH77De5j6AGQi6o0CUGfCOD2X7cXAlCFQABtEsGLDtxuOyQB2UTQBKZe5GUPXgkUYCUAbZJRhBDeuq8xBf+bgwbehDm+BFQi2IJksOocvA8ysIMfxluVcRsY/eB3JzH8GFDAXQO48X/dcIf9jyDHptIigDsFkEe066tBSETQUYF7ElDdYEBytN4+rk9UcBPfrKaZqFHWcw3i4J8/X4ev2//bSXqAhwTay6OEIPLD2Ipt8OtAGzxkwLw9WVFRjTc/qC6H3+YK/b1oAA0KuOizHfieCLaHHiAb5NYTIC9EMEbZrVEQt1xwhVy1UfBh8PUOquMizwaap3tQXfY5B//tea/NZdfhsvbz+PURQTDSGWB87VX/7WSd4KxjUqrIgE0IUkoKGnhIvwvawpGf6eECXJ7tv4qbA7DJgwpsKthEmmYgfaAAffYF3HLxo0vwNjJ0SwRWMG4db4eh1gPNm18vQ+us/0eGmxDemu/fnM/X4evq/8342ksGHgLY5LyT/zg0wM8lcMjgGFXwqIOVFJBQw99eCvF9oZL9Mfl3QwAvIXDsBRC9R+fz8x0FPBLB0xJEpwUobrfAkARgIAF41h3wQgP6QAmX5E/7eI43IxGwwf/moIkRyWRJQIPgt9CA9b39nzt4bYUWjAlCjWDPgv8IEjgLJfzuaAsrv9VdVG4OwOXW/fdoA35qAdL0BDwvf6AAUVHd8LIEu94A3K+Q+2YxaB84MOH62P//qoo38fCRDERE2zf0JfmDa+MieElAjcDPKz+mRKCOtdgGtXaBjgNJ4H2owSpNeAW/rRH4CaHSpMwnBYYycjgSJwfie9CR6mPu20Uv8kABF206AvXlBMiIBPSlB9wjBW1fwEuSb94296VCqgMaGCt/G1BbExi3IG+r3a3J6P48Gv/J0YmEYoiGY7V/SxwFCwGoE/xa0AJ0CEiV9QPCJb1OJ5F1VTjEY2/MO9AEJvj1BJTQpqLfTlGwjABuzT962e4IoKnyrdh3+/6mzDVJ4PHOxj0JqGKoy20+wBMN6D1gLWi9NQHfVP5MEEPzjGYy8BMAOnTAJgEr8HUIejRo5xrA5xkR5AngmiSHs+zDDAmMgWzTg55GSJEmHE8IvWPAoYTfhWak/Wn/bQ0CGLSAjv83SUEfKp5q24LXuQICpzrjrgWoza8xVE00CQCORdhMJuTUT/rjuls0gO4Iby8BIEgK6gS7BsGuTtDrScH/fR68biUHNVGBnxjeNyHEvQe/ve3LZQqgG3rof6cEclsNflG9J4KtaQ8WHcVBHS1BtHE4QP9OBMS98mpbKTeDW7dJwRsnHpMBTFJpV4I+b0kY/NqInVFSyBLANbnMSgBM8F+Fqfxq/h657/Up+GaBnwV9hRqc9bZ/vA6vu+T9E8KPJWns94UfTeCj2QXwCHS9dNL8Xf3Ho/rfewSeFODGDV69AU0y6NFAE1DP3qK++rdB7/1HRxf86gT376zOr99T/h/ioBiXWQkgQgVeIrCC/WomhDmQK+hASI2ARQZKooHMLdCJwGEBBXC3+uERwg+VOHZ9ioAt9H80AI06wGgJ3nQA3BoCut6AhxYwgcPOFnxuFnrphk+NIKIGrWPQtgz3b0i7Y6D5rs1GKqTop0nQX52vmQC4BkjA+r4a7Kx9WLENGeegkhSETBCrNXIMdi/444Rw1n6E96ry7OPuj8UfLxtQ78NA2iSBbg7gIiIbdDLsb5agPhLC3RkYKv8NDbS2YGsatNRAG2oQwf9ZIOydgy1MAzBkAw8UwEEIDzSAqdPQ6za0PkeJAMH3Z0wXniUSZoHvBXU2mcjQgv56TedIKglCpIoQfgwCIjOytd8WgN0bfxoR8Fn9Gx0Aj5Zgq0lIZbsH/ibSJoFnS+C98g9ooHEELI3gliy25yONIiE6pb0NfBlyNEYyENoodkKwgl6I6s8kARgJ4ZoEfuYWHLEJa0LhSBXm7kImGeSfVdoJ1DO2G7WXsehAptupSOoyrCSF904k+6vt98X/ZcM98Hsd4JYIXhQAIg3/f9AAUYhsLQKAtkHVBnzjCKhOoYl2ym+iBtvzDzQ2DLXJ4PUmbJHAVnBQX4jkxfvHhNDqAdHXGQJgv0aSDGItgOseHIU+K9hXnIJzkoGlEKzNHagTdJ6VWEUH4iCKH4fd2AwDPaYBm4Wgng4gQ9V/CoGiuNmD04AQtNGMGzSAAQ2I2pzfogY9LRh7BrbOh4+D30sAencljFu2CUFrwY8UAWRfWwGvVOVfbx2uIILM0pwDv082dUTw8hYs8L+uIWiHGpWgClnAa1lMPJogovvvbePPs/q3Xr++kgCsfgB5oQF9WYKPJqEn6G+OE3i5AqouF59FQOmahQC8rlPLj38kg1c2f30vw+XaoIX24/pMGIgSBoZqoH3wo0sIIGlA9PWcCPrAtpPB8eBf6x1o6cHra+2+tpIFP4PgBfxZtZUJfo4qxELT948D9ucK8Mt9+ccjIQw6QJcEbrD/1g340ATuDgDkFfx6twSf1f9xvuBECYxq/7ythQQGm+5JDx6Brw4CkMGT3wgscCUoQ4sU2t6DR2ciBjTgtcpenQoZVX9NuL4Owc+dVaDursYVkVALX+shjSBKBuvCYDUZjE5BdNkxdHAUBexyHwB6NP7Iyw7sxUDViwge1t+mz8B/LAvVx/c3PeBBCToB8IUGOgqA3iV4yUg6UAOxaUFHDx6CYS8SorMOue0CCJGAf5YfRhoAI+A1CvwxqNkAY5yAIx2EQmkFfeWOXi+nEdSQQA0ZHMEItiagJArQxDXIrj8nCfQi4HZPAttrIahso9oPQ/2/JwV5JQU8zw+7I4D7/sBn4EO6rjw0FR+i3Z9fHtahzsFvJgM0X+tmVH5vaYiNDGAigewAz+gyNLThnjCURQFR1b9d3lZvnVqmj9mEPDKIUIC4KCCjBXywS4N+otp/Hk3QVthOkwEKlV9PQwXjT7s/zwF4Qf9toAAzFdjuaEB6S7D1//U5FIQu2MevO0rQQH8ZmoXE6B/IkgE60XCjVoq8gt2iCG0S8L5GdxkM1cGsfsCMArSCAnrr7dzAZxCEEpepvB8tqHJ/q+bmJGGts/AcAXFOMMeTwC7Pw0B6CtCtA2vWgonqBQJFSwH0JQK29OB2kvgj2HHXAoyeAIsCQO0kMNECAhFMqCBf8mElAkyBbX1tJQP2RJ/ha0gpAfS9l+/5n00CkrQpq0MZbOdAuxmMvHswog62jZj7BnYQe19b14kxNq2D/ehX/p68HEcF+x3yP7z/V/A/q/5DA3i5A/dzA5pdgbKp3v3/wQF4Bb70WkCTHGRAA6+KL0bFl6FJaFw0ImZwm6igSwbbwPn9RMBWf3sN2JgA/BVh/Rg0kQBgePf6HglAHLFQwqQQOwDjbdVxNZjR4iM6Qa3WxwvNxh0JFb3g/WzFQQS8b/ttKcDWoABtUMAd8j9hf0MB2uDXhzX4CHj03L9DBU3Qjz0C0l4mLSLQPicOOwZoVCB6P6dA7nDbGkVuxcNr8PU2JQO4wX5trEqmccZaHU4q8oCDFOpzAnOwqyMIMktNNNAHouDGxO37DgArQZzlmp/14W1QlqHTMaIIx7SCx0+5yza7AKJ3IXBrNAHVDcMZAU/BT/vgv/ULPOA+XiLggAREDF2g0ci6xNDRglegd7P7TWWH5oJfayliEg7bScQRBVgI4Ookg/F6rvpLWP29swREqA3CaG8/FpKqS8DTAV4TiBqIqtxfzaQRLys5I0XEFIFrPbZRQb+16Fgi2LvJv8EFUPW1gGfQv1T/F/d/HBnccP7rAwnIIyHI4ArgWeGbU4eHy6Tx/EeTZIb5bo/BsMBjmjBE08f/RB0PHYBd9eVRAGY7cHRwiBf8WeCPHY1bgBTa9xKTELzEkQX9CPtl0gJiqsAmCT7I8xbjivh3JGFI+D2nBcSJQJ8agDX+O9iBL7UfG4bzAkcaICrbtYHz1ycSmGmAjJfL3CMgT3tQpmrfB7gxSzC1DnvdhQMieG47u75+kTouKNkM8c/+vq/Q7ZYjO/hhVvRq8F/9gGfhP8aqE9EIdR6LTwJ1h0BItyDqB8iFwuNqASscRnYioxOg9ApvnYA35f8e9Ohbfe8J4rknoFkO0lmA2gmAG0YK0DkB4ieEjiLoMD8wBzom27ANZkzIoU8EMHk/uo1mzeVoEoRWKn8L/62EYAX/lsB7D/LXg74uAMr9oGivJ0CNJCGD6i9DhZdQF+gtOp4S+NODRzsDVbhdgv4BqTMNyIL9SCKwL9/FGPp5oQKxIf8A/UX6r231H7YIqLML0Ae2GtrADOvRQH5b/MPE9dt9BGLNG8jVTAQvIaK5TtvvvWQgDvyXIClUA78S9Nfg7VtIBlO7cbsEYkQDMot+ygQ7QwmOawTHnAM2XUSnJvPIYRYMmYPS+sv3J+cfP3d04JYIXsF/EwMbBKB9Q9AY+BiSwFj9mzrSXmcJhFPVHySTbgHJCPvRQ/z7G/SVUETsg0ZF+i3CRoCjhf7y1A9mOiDD7TwdwEoEXjLwAv+avLE2B7Jnb+OqDpBoAchoQJskxKnss0vu7Q2YhcDv4ySeLOg9GsCKiUIihP7yfW7zbTsBh0TQfN0iAWn9f72Z56/Ax9P7j5OAH/Qvv3/QxKfk0DgDuP+R3USg3bzBC7bO/QT9Eeh9QvDPG7glBQzJwK740lAFFgFk8P88CqDGAa223YckWYhr+c0BPdwetl2ocnsfzePAWcVnnAIp6gDVhDLyfV4nqFEDPxHsbWD3k4BDkN+pARqKMLYBPzYEvxp9xmCHQQdgWH/9EtH2TIFpu3AH/cdGydv1j0TQbRrq+D/mLcX3ZACZ15bF378CG0My6Kq/zoGOQwhASDFwFbxyNGBuSxbCEhQ/uEPe/6gAERWQObCVVfjPpQX+rexxYhYFxIkgpgX7Y/vPs+Pvxf9vwt8kAs7i32t3QCP+3SPaTwIytQXP38u0PESm+YER+o9B3vr8mETAUfDrEkPI80ck0FZ0dXh9U+HRbhey0cAc2H7A4y4egoD6y8JfkBiigLdFP8v2W00E8deT2IeAKujZ/QAVKpAtKI20gLWksHedfgPcb+0+NEHefd9vB9rayi8h7J91gBbaw20MsnWAF5xHkyDUCOoXp+yrOwwxcKj0aL6fFppaaKDv6OpHR5sgx5BAlK/+fYhuP1D196o8e7lFBaKqv5YIMnFQpd0FGVR35RJCnCDaABaXBtgbiSwtICMtalKC+1JQ6bx/PLcDPQL91QFodQNKpwOgF/9eqcBxBBqRcKAAVk+ArQOMx1RYGgB6naDhlK+uQQwJYx4meQbxtNnYQwMjt/d4f3M9ZE4UOld1LAh99fbfzOxiEkKFCkTJIUIMUeVnJ/9sDt8/e1NEJOi9oVHDGYhgnSLss9DX2IAqw1zALUncKcDr0FB5NP+0cBQNrEezDiyiADPkt9qGpwoPdL0AGPx/NOKeyf3b9WJNdfcFv6bKd2cLMJVfJ6Y3B6wB9WFUfWWEwKMfGiQL+3bz9XGQz2EHKhF41GCtZyDi/gUCsNhYoAr3UNJ58YidHKqnMb/6AB5J4N73/4L+t7mAkeeP3P+1LNSB/l0SkMEd8DcEuUlguEw6t2AU/PCE/q++Akw6QFf1u6SBrj1ZnnhG50AfkoGIdf7gJv1KcSfgzWWkQ9U33Z3tHXYASKJ9e/YhU90rvD+q9Ej69/wxYJVs506Eg/r3DkMDzEdDBRGgcZay49XihLA30P+l8N+hf1f57/0AoxbQbwYaan/rBMirE9Dk+sBzTkC8JNDEUlv5McB8PP19Y01Gayep+hC/2zvQ/2HGLAurowsNGlA1cnqGGzeH5weiYLZm7h3QQC4O2tXdhvMMk1ZS5ebpgI8eMrPvPGkwaxayk8Yc6PMOBPEdC1XZ+2UfbfOPtxLMQQAG9BcZFoF0gp/RKjxe7+oAw9T7ZPWhgedodgz0gf5KBtrtIZhQAZpAV1Bi36w6t98qVfH7hqGI318lLCjLCUFlxRHwqYEH9a2qb4XjWvDT7kBwfbZA5P0+PNuRuW1yf4yNQH3zzwv6b70QOJ0G9OT/dhoYRUGT15uQH/71MjQLtQlxfDuiCXrtM+SkA+icQdH6sU/xz7Ze7FlubV4TpoTQ2osdpaEjtqADmEU7OkBEFoLeC3IWFFeswJXKXzkboNL+wzcFHU8hTGKIboO7CLi1/P+5F+gydQhuvRbwEgxvtACmANikhLTbj0gCYk8KdlYgmj+4Ymaod7TwahwadICuX0Cm2fE5iNHPK0x/CDV66Kyg1MnqjNFBnhBoLQCgUULfaVe5nq/6EQWY67bXCszUb+7232fVPz51iGB12owK9peyP1T4raMFF/OEYJP792mgXYfZ04GHMAhBkCSmSj+dKqRPgVFGHbpLEGMiGFeQWfSgrY52VxaeDUPSNJI0P7NoisG729HHl78z6hxfs9rV3m4JjgM/lsui2qmThjCfDFSb+I9vwUqG5wwL55U7C+6ot8B+7N2o6r3q37T9trfpjgmTvv7PSQATLLeRAOZhIJHBQfDQQJPBdUwEbVW3+L08EcEE/9G4ANrCeWcnPKRHDupbNynMx5AA9IRYLmrc/YLSiD5EaEBS/s/TgnU9ILcH19n+CpHwegLejx7Mn/d25fdN+e9U/1vgb7bqf08MOtf8EXxaoh+GY8L6gDfhvs4i6HQ7seYI2sv1GchdMsBIG3xlvxcCRzdgCPTn+6q/TW00VE8Q9FaFv+R2VlOM1vm/hhjhDCdgNflVKME5B47I9xT8z0YgPAJ8myb/LqHy36j/Mwqw9AALxuO1JVjiuQAYLcFzIhiEPe05fk8tRjGw7yWQbsfuLAT2VqOId1osnr0F49VM8INACPHDoBz4B5mqqSnUgyh3ArjXxfQH5BbgUS8gP7aU+w0zHD9GGD0CGHf+P1p/DeivlhU4BbxR9a2kYFR58YaDZCUR2P0DMmgED2eg77puegy6PgDphEB0CwlG/i9d+/Hs34pBEQrBn0W51mqGnJAk3ACCHeiqkQ1XFQA5AlKH7Lk8yJKWY3/nym14h2C3JvxeMwD9ZVMz0BPMi1n1RbKl1cYhIVblF3G0ATsRiCMUvoK9//OgcwYMoe+ZKOLlC6/Xk50br9NFz9fanqA8UIYSpCwlBO4kHc4WLLBfBHVaKwKgLQjmP4Un61Vq+3s7Bsyi0WztmLjJwJwFeE0I2vD/1Q6MVwefxfUf32skCPbCnxQqf+QMPEUDHZ7vGeyj020JgkPXXwsldA7SYR1RE3h94NvNtugswcgxXEkIcBPCGZ1rmrgDC0A4K88nm2fn/eTnpQtWyZfybRoK8Dro4zYDIMGsf7saTBzvX0SMbkAD6o9CYbsfMK38cJKD9l2FJt9/VGs0h5Gib33pxMKWNsigFUh3G2un+/N1WUglI/EEx8fq27vUNnwsiOoKecL7kQS8VnWAGCFUgn6dBtQhv40CmIYggwK0uwDHRGAuBXVdfwzHUjZzATLMAoyJ4FmBhzaWBlrHld9CCWpPHRqofBqMReMGTJ78q9rDes1Tv7/0m0v0AFHXNR6P6g30SHivin7V1BOhh3iWPwvps/yE836L2XiwnUT8x2iHgfqhnwn667QHEE8oLQjEvtEW7GYBZDrDVkwNIO4G5GiBDf9fGoFM6n+vbEtzXwP6u9AduaWnGYSLAlVdl/AU+ikrSeEIKgwdaZ4AACAASURBVKj4/wtgHcHtdO2nWKcBkPfxcvnNQvsj2Me9f02r76T8q0IBn9OLKfz1HX8yVXQYGoAB/2UeBQ5/5kCL6+H/OGGoRnLSwdd3oH8r7KkGTbgIxEwVWvnF8KOpHnyzfF9Jod5Px+IF1h8owyitDw/XEgRb5bPqbt1uvn7qBIQ16vtS/u+DP3cR7CH0WWJgd5mTJKYgNzoGjQrfvu99NDBC+bnyW1x/qhTatv2OaMKgJWPvv5kwnMgxHYGFRtJW8VMl3uP+MgoqSZyWFKr7+KIDw1d6+IiOgZI4+d5iYL3imzbgyO+tph9t2oSBxOM3ugHtPoFZ1LM0hF4kXNEBssvVgPdjdXZWK7uKvyS3q1Xb1WQwtVDqSUggq+Vw3t56JA2cz7PXOwGNW1ecwxPhfe3QEUsDsFaAz8jg0nf+iZMAHNg/XSazDuC18Iq1HBRrOsAQ8NLB+16g614jmuSgs3bROxE55D+WDDQNA4ivdMJ9M1b309UqknaDU8ObV9/PwmMPATvTMAxpABLBzugUtV9bLdhNDQA+7B9tQJ06/7QNDHGSwtgZOCIA47InIoDdROQGtt0U1HI3GaoUnCnC/rzBMQJteN17+VaAzYNA7e+PFqHQUyXPUYB7iQYa5ZFjq1Zqpx8Uqu/XT7+6BWC1Xaj0GlBIwMoHu7UzcI/6/Acb8KIq+hzmGWmAYnADrIpvKP7TZeLaf0LAeQkGgebbq9FToI44p654F47tekKkI0L5PQNZPsDwPBpy/ni+wKMN76Vav4+2cFZFf8+JwAraMt0DFB7beA/u4Zz/a+RXx0M/ct4/jwaNAS8G17eSwmta0Fhx0VRxJkHMivso+onMXr+YwdWKbgioy1jp4x4AzIKg5lEA7wvHEYCRmdx11TAuT6lDLVl4KvXkAET9P4RT8H2u+lg9EPQIpw+/NpJ7RwE8HaDv/Mu4f3OdNkq/EfAiEiOANjEALvcWL9gfFV4NZbgbQc6qPky4Pm35QZxtH1f4j+P/jXuaYPcWwIEH/fmEPBoAO4m4LGxV3txOQqDU+dXgey+UwSzuqP++uImO/u/6ogCb7wTc1n61sL+vZi87rxnrNas+giTg6QLzaUCjIp6JfhwtGI7AjBBB9JjDY4ePYVR6ZPgN4owVv6Q2N5hhVHwNeYrM+w6dN6K1sMHZm/Ce7bHe3dzKr1xw1w4JrSQMZtgnoQHlr18fzunAszD4qurNUg/TDqzx/lfCaO6t4tACMUQ6P6htWjDPC1hCoZ8kpODzJ70MUR9AODcgwyqyPhmE+wfHYB/hvSqt6qeXUShhXH+d9SR8DzrDaZZdpSp/HxqLMQuATgDU/qDPRgOIeT8cvz/h/XC6BtE7ACLOWPE0KIS4UUjmZaJ2grBphiWgT41BUVWZfP3AnEIT6OrfoF122l2rMycBoU5i/OXoUZ4/aglsXwLzHNU++FVF3qikOj5HXm2PBitT1WuvJRAB+6O//W0/PY8vQH5IrAsMs/WuVmAdHBrQgrbOxJShXwRSsu08h8JMBpo0+aDTALwV4tbswgzHrftG/dJKIAQb5h9KCssWIMeto+GYqG12/HWGjx8kzqNJaa0noMWOr2KwW01AMwJoNvhMQda2/RKQP/3ecABM3g9uD6BY68Ntz9+nDOMb5iV+hIE+dP/Zs/wwJhJ9mgBnohBuStABUXjugF3hkXF9ZZJAjefKdHZCc389LoStKvIl7QIEb1d9RyciQgFDI9Cjyccc/23Aam7/PZJBhgDgin5CtQvbCzX8ip9YgIFtOAt+w0owp/hOiCWgEGbVHuYjRigPGR/YOnEoqPDoV5z5YqB3mRq2ox5ICmSSgAP1Ne+XV2NE+/vuFbCTRADxtS70VRBCjgBk2OyDUQiUgfl77b7DwaHm2rAZ7osRSOOUoHgKfNBSLI767+oDYrfwZvqChSpGfj3pFwZFsCJg2jeIQQBUiyI4WgD68ww4qO8khuWkkIuDrxWv2nv+UTBpJYiPd0KemTA8qqFiuUF1jWS3BoG6pADJq751JqBI0wvAVPyMQvjcX1zbELltKK+zBiXRFiRxG+b7q3M9xuLdzR8g0gCGNzSM5gNYfqGO9CBT8OHct6oB3KsSDBisUnwsFuISQaRHxDSv0vptt2oeLHMERfRn/FG/Cx01EpgIQG8LP+/i37PKw53xn6sYCM4/JwSRrCnIeB1ZkLsawDhaPKv/njU3wnZ/dBdGE8+YTHSG8+ofGgIjsC19YnwdM/KAnTSsqj6ig7uGgIPw3nYFzhhIIvriAxFP9CQd4HSlnzgxONIdrE7A8ZDPx9fjib8ifgegNIliRgdx95+E1T7+3nQVNNhEzDgGA3T2rEDLduwtPpuuouPcs8swwXFjdTaMKt+jA5gUAQPcf95KJQxYU0cYxEDvsBSmYuukp7AwnqniC9Afa5z8vboI68ImT0t26CvwBzSggkj447r9IojvCn7U92J/Hw0QSdwZKNNjxPCfSxRqnATkdwpOwh88oc4J8KTSm/wdbZjrc+4iFP8YO0/5JJDCfaijK5xVXevqfg6zGRrQf83chvX4aRfAE//6vv5+6490U4ADdO7QgM/5bcHP/n4OtCQhBEFeDWSvos8DPq8/IwzLzjpa8/U6MMSkBklDm8e0mn3QIY7XG1Om8wzN48y7HwhOK3P0/ZwUQHHv4psbdoVeb9VlAjChBCdtDDpOKTh9ZfcagOYq31RFjN4/gwBYzp8lAwYNwBELhZoxECeZxMlAzWGdCRV0fQWGHo8+8Kx+AAxnCIzowAxy9KvNepWfsfp4RR9kUrD88CPVTuXRybhqqTHcnxEGndsgub1Gdug8yz9fHt3Hpl57x/mfCOC29FOSQ7/noAZR5W3Ob24UMpuPYAYiQrQgk1gnFoUIKr4vKFpV15pHUJO3Y5rfH3UFHU4bGkU+NKJ9f2hJyOMxDBDpjAgwiYqvk5TqNl9EH2Arb6fA3yaA4cBtPWewhkEcIQJBlGzYp6zRmr1v+e3Fv27xpzvyI44NGDkCIi7CGNV9Dw0M8NtHC2vUwHINumCGNG8erxOwtQINsW88Tlwdoc+F85nI559ngEDpt2F/Uu3hiXYrkN/pBFS26hYDAkFgErMK67y9mGBA3L5ore5izf8b3n805MOq/t7XU4WHv1DUF/5gugCSOAIW/59uMwl6CHWAib8bvfxWl9/rBGEMTTwDfG+ezEYG4yk6FvRPuPwE+wvc39IRjENWM+/cm5b0W4Pf4WuKUnw/vD6eDbB1ETs5vl77Dhnm/51g6wPWwQAqxnivgQaeS3gy/u/1H4hpTPrIgHAN0mSgXUX13YP5PMIuQAfBr/f70cdeE+QoCX3i8nFMLcAjInBoAIYqt1LhC1WdtvmSab28AYffaeivCB+ohdYQgfUa/WS4ToMsNLHLc9nnvPZLwn1/EefPVf+U/xvnCVSEQEkEQEnEQJO7S7RvYDxNeNYKrG7DKMhtsQ8cMmhgPKKKj+F7CiHYFR5KIIPxOmg5IVAtu3ACQSPh7CzUQOgAej5CWEkIe3vgxz0ROGO//qYfz/dnLT+ZxDr4QW0eNCJBorCFOVC312Ec2TiY5Bk0cAaQmiA1VH1MOwDHQ0kHdEDDf+2UTWhS4Z8diQMicLx8MLBfverLcP/jQzF0P8EJj5+NGK9RCz755S6F/f1+X/gxeP+Wsedv+vF8/54aSPJYFjIQd624MDz/UDLQnr8HU3ztKHRf8Qeno1vyAQJBaLcMtTV3cvgP56COCqd/QP9xLgBkH4BxO13n4hNUDtACC6G1S3zqooZ6Ba4lp/zcAFb7iERKQwQcF39IFJjdXECGADw0IE4gg674pYAnk4HoHPx54tD5daO5vxrugSkMjgiiqc7TVKAT6AT8R4ckbHEQCYR/IZBxJgA+XZjsR7vaoRpIxWqeqfXuGC2CxwudicwePEB1kNkaZCuwyF0DuKv/4sz9mzP/Qxdg3BDkBTMC8Q+loD6UGBzx0Kz6eAX/KArOQTlPHFoI4vVtf4rNuLrca9edRn4xBP7k8w+9AgZCgBfEUZWfEs8iFNZ3UO7TqmkjCO/rWdgco/yIqHcQWaC2EGTzgz5y/iXQAvyx3riyxxV/JeBriaGB9OrTA5g9/eokM+37GszqfA/UZk9iW5UnCtBqBl3XoNN6Ag/+zy6A5evPAp+TIFDn15gQw9rjrOzFX0s2JBVAxa/nP1a6AsNWYGjPNGPLTQgBsNUFvOA3Ht9o/rGDN0tWOCcxJGp+f7++kkP7PxcGv1+GjkaLt/fawpwwerQxBJNW4b+PJsYEgiAYYdEAGIlDNaAbRkIgK3ut0jKByp+8yz23X6GttmBmjwDvChgiYLP5V/zhH6/110sGcKo5CkggCngxnIPoPja0j2B+1BRkiYJiviaLJqghDI63G2nAgAxMCuDdnoD0wIQm+urMB3VuAwbBrFGgGgnhAFqg9+ujKsLxB3qGCQNEEtPinIQlAj4WgIw7/iXc9V/x/yUWFs2KH504bAh4aYWf4TrTLGTy9YbftyLeVOWNfYNyt/ji29mQnqMAltU3ioTtbX343yv/1u0YPUBz6zB702tQucnX0gWaFh6DgPdmhXaapGotw0SFz1qDiTMdd8h45HfcqCPRUhA3+NmKz1l9teCPaMd4urGaewRitNBDdahR5c3AfQmDCFT9vmtQEwqAYXX4XI2n23Z9B/Yb1FL+LWox6wHGbZSo6FR1LzyG+3hriSZvWT6jfXhl2cmQZJDrAbuYAqAHo1GA/EOgD8eGcU7A8eDvH4fQBuAhBL/Zp/vamPTrRENDGLTV/7E1WEPLDlP/PwzU4YhusIMUgfIPAr6Dhv5R4y2r8ldFwiFoYHnmr8TAHbhRQSZOctH598ZYhqt6wP7q/ouqe77RJxvzFYaji/z4vna4v5cUMDXqDAJ5ytktqtBDckyjvJg04hl16LB0xFfyMfD77PZjErGQRRjYIfSvoAXntks0ok8MsUC4KARWnYPlJBeIgLeFrUgDOHYCag0/XNAbWgRwQuLAsaQwIhC1g7+jCNKuT38JfnYSyTi+QQEwwHeT4/dWHYxJPxfOj5oAnRQqgU3YgGZSOaDyK3n/qkDYBKptzR3oD6B4fyRKjp2AzSl80YR/3P+/1vBjX18Jbu+YsrMRgbqPP8zrDLTAaupphfeZtyPs9BPztpLSBZjowF3woYRwBwOWaqbev15b7X4RWsiqYiY6ZkFEIoUwUA2OrkeEQE8HYNyD/rl3m88jCGgO/nPW3xy8x4Q/HBcM1dYg5q8N+B/SBSYhtD0EY1PRGLDoKIBHF3yLz4H/gSYQJRETgqeB2d4vC8L2NVnQn4PoVJJAcP0inahAfdXVI8CFszjRagCTtRdV7Sr895NBpRKXIT64RMFw/iw5eChhEvmmyUIH+k+Qu3cLzOAN6ILlFvgWnx3YWFDz0f38ze9GlfP6UQ3ojEY0gtqRIEbA5/WgQFhsEuIeL75uTzvqHktAWfj/OD6sQXssROcGiRgFn0QVkld7OznMDT7CJKzhMIqxW9B+LCOQdH4uyxIcE49VTSeLj0wKjzcp2oDXQA8YoDEGBLMW0BJw+eAxXejPV/IXd59/tp5rVyYXDw5BlRetSpQAcvgfOwVM8ObzBq/AQ2wX4lwkQV3vNhYFfn2LFgaoDU1ogqsfqGkJYmrj9Tr22KQwBLzbLuzDeA9yzyJjVRfwegWq0H+FThDPA6ZhZwX2M2Kh4waovCzAWJTzD/qY00c+6PM8coz08VNqglzx54LfHuTJK7z2rwX35ABLg1DzsZ7Qv7l/f2yXDlbf4C/irg0MJ0aCuD0wP74MrxfdFlX7tq+vtRdCpvt599EG9Yz3V+P+Oj/n4zLruZHcJ7oMt/MNp9eD6HEeFb6/TMfbWo85Pb79HJo8t3371/PuIAZqMvjPC34nVV6ZB4hEuA7AzA5cfU0y2n6ux89D/35/n2/vWY5Bf0qwf3tPLISO1Tap9qzFB6eap/beqI94NCCbGwgqOItY3CGl446CaQ8i2Q9g0AvmgJOnBoAA0gu17tsKtKS7D4udgCYERy2QIceCX/P7mBW+g/7D9S6Mn50CS0eAoQPDcBjopIA5+EcxEjLweRjXq0UbLIjcBxsGx2IZvlf0ATjz/6qypAmY7bhrk4ahsIis6ccXKHdueAfUgk+RWPCLh42c6zEeKyJpRTdRAOqBbl/Wq/uT+q+Fx3FoTIuCzc6+hN8j4veGjuAnhSE5gKnco3A3XwYlq2sq+lmP4yEOpqEoG0M+mGDYuYT0pKCFHgLHKt3T7T9p8GcWH+n1UwGa8X6kQt2x4CeqPexegT6o/Z4Cr313PHdgrsS2ZReLfpKIf+IMFnmVmwxQ9AhithYT73+p2s+JIVfrjwiHnpAZrSsr9CMstQXP1+1+510N/q8E/YoekMN9OMFvi5LvkRDsy9rgFCOoPdpgaQIWBZjf5KCSQszZJ1ivTvLokpen6tsJAVND0NFqb6GUGg2Im4Dyx9Pn7/0dm4pADAslJzTv+dKNrAPQ0wyySm7bj1RQgbAXsRa4R+mBJzpaQmHLmy0BLoL+Nh2ZRca8uUc6P37k97n451fvTieAE8BdZ2ItqFEK6oOJIYPsiU4woo140Oh+H/UC++gatHYcOFT+2y3AYvD1rM/fpxdUcsAi70c0OxAEP45X/hymE9XeoC0zfYhbcqfbhs09HpwnKMDR6g0mmYyKth/UcLl9ITGQ8N1S6s+gA1HvQCc2pluPvN2Br8SyZyfyxPP/VhCi1L1HWX2CQCuAE8TIq/sBYdANZmTIwqq0sb0HIzhhugBeUpBZLFyA8y+EErsBUYDZHYN9QAAooQwOws+uQlhdESSSqk5Qsh8LSYI6LDS1AbmOvLlRBqQIeITvM36+TP63VfE5hFClCTr9zEyVFwS3STQBy66DMHB+PJWIrfgGnYBx2dTboPa2X49GaBVlePA7CFx4iaGi4ns0aLVjMGvtPTDtmO4XEE8E5Kb/8qYai+NHl60LgAICcUCoJPVeiYG6Pxw/X9VFNVbFn9FNPzXoIRDTyzcpREYB5Fm1EQQn3KRi9wKApR8Tz48SwxnV3qM0q7ZhpdKvr0zfY+gO4oQf+EGPFYW/Xf5hwWsUgxiBbShGoGIx+D2eH1h2EeR3UQMH4zMaUKr4033nzkSkfQADelFbLOQCalxdxvN8mInhPas9bxtGJw29Fx3Y8429MAS0fL33Oeo7qFZeiToCC3B/VSNYuU0fgDnkhxGgMFdxiYEY7MYel+OHPH30IMeVFK1C79l+QdXVpFqHlMAXEf3EYDyfkkGdNvJ8f3RAXU0jpgM7jMNA5yCrtfzOicKG/M9bgEkEjqqPPDEcDfqVwGZv6zcO9avDfOhf4OmLFd9OLBHHdxp51HvOBlnAoQksYjASA1xnIhPsapTCPjbsGB2YevpPpgM73EYeSYIftgPgte6CWesVBB9QEgfnWYMgoeC8ql69bWoRIqYHvSIv/u26bj/jdqZ9KSGk74JRo6QS9PuTiSHm6Z62kLUGH0UO4rwWrhtRETkR4iKRdI8giJ2D2nUCMjsA0TXiVDb98NAf/rCMlajA9wesWHZrAe1dlwRyVI2jx4KkyUHSx7YDe6YD4tOC6XW01puEdAJwaEJzf1uATHi6ZlSCpBQscsh6C1xRcWEG4bCFeKcAVhVlDu54JQIkTT21hptIT/Afk0kMcS9BKfjBJozcDXCrtgbWXxbMAw3INQIxtQJPAGwXmYaBbYh4SCsuKwLOAQ5awKskCMmRg8P3xwlBfbosQaDqyZqBkyQe1CLQACoTgN4qbyHsPwkTiF2pYaj6MAXBmUosQHnUEYCsBL3MW39SNKMJ5PfoBsT33DVJCEbFnBCMOkHfvj6Xq8uw+dgRIhGgAiUqf5QgKDFyhe8nnYrlqn9sG1GoAfirubygX4H+8IM1CmQrMFAJ5ExzKIp54nPoVU2Auh6eBShDlTV4u5c4HE/fVvjFrsII0Ik6QX+Iq68jB19ziLoKC27FYe0gC+j1RSS+BgB7AvAM3m8HLdy5fV60C8RMVuhD1ieQB32MCCq0QPJuvuw5IHF/geMKwOPdpmsxBwVEfGEOgeincJqNmuSFIPhPq/xM81CWIIi+gCFBqDX3QPYd2OcCRo6GZBoA3AM+00aesAOQ7/2Pe/vBCXoguD4OBD1WfPwClzcui12AuH+gC0gEwW72KfjBCQRBr05D0IQc7N8PzOCMehPWK384MPVDJQim7yDdoiRTItzzFV/ZOX9sYFetP0fsQzb6O7wOoFjxk89YoQXv+BmSN+yYHYO+BsDRAXHhuJXsEFbdIEGZQWUkNVNzGA9NZUVBIQL7jASR0AclE4Pb7JN3BO72mG92+o8UG3nybj+mASh0FsLKn9GPxDrEcS2Au35BzHO1BksriIJdpqWjKR1wlpR4fN977rZqI+XbYjYDgVDpcYQalOYKMiuQbB3G6Pu/HlMbi9a0EMkksXtjvvXTfgMKAEZRN/i/O7yD8Da2S2Bdh3ICWfp8yuMkYl5a4df4vVWt4UF0yyqEnaT6swYyWB8/j111Y1ERS9oB0SLMtBGDEBD1PEHwtdjUEAHnqmoHU4wCDAoAS+lHwtu9eQLUAgmxVvAuMB9cELMV3m8EUtcBYYI9nkNIEEJYrQeUHfnzzRyC39j8CgSkir/E0P2odnAmAqDnDIhqrtV9BDNS2POjv/0pwKr6z1h/PMz3uf9ykFYq9TtoAXSwpz0HljdvBCVAPY6t7osv6gFhMpkX13rcfXQMIpuTsfTibkfOPRAC2meLRipI4mDPwMD5x+v3+Ey+qEfACwoUEkKQSMZxYJDz9R68PyP43yvo2aYf881rNQbZgRU/jp80QnW/hdXqJxMvCFxXQSNHpE8QiF4XI+wFfQcw7VL2Md7RRajsKgh2D+6SLAKPF356+/7yXYBTUgFy/38StUjFHweD+iiHh8/LV/i/TSvGk4L5x7F6AsIKbgb4C0YjgdGRIToGUx7cgS3JKP8pRcgak95BJGQbjaJdBYQ1qHYnYHL8F45QgHx2gLMQ2cDxBD/4SeR0LSDi5XzPQNjM4ySE/HGG6g+ugltLNSARn281BPtNO72eJLjdX4ITSEgpQvJYFEUg24f1qAYQNQdxx6Q/RcB85j9f+03zf2QV33IDPHegNgPABTfqFR8cZK9TA7/ll0EQbUUHW8Gr1d+MSadia+LRHwhunv87yWoJ3h/pRDwJAbDNQQFd2P2mH4kP/wDT/ZeN3CK3+ZjvgVpw4r20AMafb58j4N1UMknuj6iCx883PU9g2VHVH5JX2eEcPghSgRBCKPzK0Q3fknwPN0Hk0CyC0zBkz//7duEetgFjVtypASDI4CsknYJgYDhqsBxxy29+eyxrAZX75EEf8f+CkOcijMDDHx4ASYGGu8WHgPwpHJc0qOG8FgFTuVk0cRZVePFwHEIUEu8xSHoL5qWg4I7/HgOKXe2dcnu2SSdCGIDTA+AcxY1zYL6Q6AAFu+/1GvjKPSeEoJV3NiM4Dz9C6oWkEav+NWjPWXNOIkKgNTi2I8LeBgaZHJxqrC4oNXoB9pzzMws/OW3ghSyQJgjbygOVEDhoj4nHLld8HPD6UUMFVLIgKrTL7cFoBRLQgEdXIseZ2/HhFPKbk4d5tYWwwR0nIFQSD2P5gQhs6meVfB+Bkyz2fOIvX/zxqsSODuAGIOLtPNnmIPCrv6Kqvgz3q4tCwNl9lWYfnsdHj2HTgQw5IBHwULmfSu1jEV3gDFSxTBmqSEVqiYK2IkWcRiAkwV/cyW9YhqHXDw9dkNQAcO6HFNJT7oChfrPUYc3KY17zAd+evAwF2w5SCKLV4EuCEKsKfjBVWHu9Q9Arh4CoBqEMWYBsNX7YgKP/69uC3M7/mOOz232QT+ox4iCyJGEFP4oBHd+GVvXBwX35nqp7qeIbV6L6tdZub3ueJ+gBIKgC6S5gOQFxDoGr+Bv2nzqbknd7ph/EmXzO0o+kZdc/wqvQkAOUffVMzKtYgx5Vob1/+HAfCdzHSiXHenX35/2JTr3KZ9Ruj2lYiMhLIFoNyMq9hFroeYMTE0bSLbhb4l3YlFPa6hMd2jk8dmrDgdQCnC4/+ANFlYTB6ATlx2GDGXP1rvL+SnWHw+cJes5/rRWt4H2pw9GklD4uSMpwasIQiaYR92gIyFX5S8dtRZt/nCAH48VXW3hRE/HKOsGquj8EM85Q9cfeAV4XwNGAlmIFIwPYrfLKuxV476RRetzcdeAsRSZhiHizCKEIOHn3EMOWy5X4uIJnXX6sFiBFLaBm/THOQAkVJK9j6TKwiSDTBWpwHkSPQJX7U959uAkoaTUuug6oQCBz1Zlxm0OJSIoIw04M+7zCGuYiznCfHww9AN6Ir+HXA7lfn2oBSJ2FOOh8SzINfmcAyITq8JX/sOMPx6A9LeYtVfwgCBZhdu25OB9/XmWWNPUEPD5dUuJ68wd1AqD2+w1PI9KxE9BW5t3z/igdYGWiL7L+wPv9jgVY8f0ZcbCKCuLAHN+c5wa69Zpr0J9t2KnpAGzyiAIPiFalJ8/xXrrA6Y+/8NoDnWCPNwFJzf5DpVkHte8hx76P+HU1+HEytEeSEIzAsu5r6wPJGu6oLz8VrKofXLce+ywIHhNa/Dmw8LrptWXZ4NKZm4pr/QQ7Qk8ehMrPtAF7PQCD309QgRgRZMKgAbFREAfBBXNalbHA9cEHMo4IgIUuPjjBWEUFEQpYTkhVO43eRiynJw9Jjj8TOUIlJExK+0wA4gWgQvcFBHAc7P4/u78/Ff4CC5ATB3P3oUwFClYgcALcxzp/B9Ez4DUV8RjBbsCBrMH4dLNwIDaCGhA6o3pXksdBvYBsktrXDgNJKAFy1Z+ZGIy5NXgXoBT8a3ZgVSPIUAMV6DjLxhsV8wX4n4ibbONObHNyCr8Z4FinNFjg8ziiF5zSV8A99u7Zdf5OisvVaAAAG3VJREFU/kIPAJLWX3hUIFD6o7MD4WkHIMXBk4IftSrPNBJVk0OoC7ice8HGS8XBKDoz/YFBLaQi392lGpCMJfhD9xVkx5Xbj73P9V4m1j0v73x9FjDDPlYvATkgFAVWcdNvJBamliOjAwRV0EpeRymAe717kMYRyy/j5FwFBX0fP7Dyx8gq8wn2ZXi8GfGYR+lFcGJSxa3Y84WgzBHetlU4cvKY44Ps4iP9fsgsPGEhQTAcHqwwGCj61SoPexKwasXFqtxq8qhD9SixoBBYcJEDNzmIoi3J7QkoJActVHocTVpPBCDhElAvMDK1PT/Sq3DwB/ygmyB9GNhYDH4so4Foy48kkPtZfZEv1PQTxYpyX0EI3Bu+/5krcN8fgwVdwWu2JNVNWAk+PcOOPMNdGFyAZ5Aj6gicgzNfwuHZg0HrLxBWfjSRl88fVCo/apX/IBrIvf65ZxtEoK9Bec4KZIPLe76osQns46NwW0pUPCPAyMc4A/KXOwZzFLGbAqD5xhhbgBcWfoJBAlarcCSQgdQJ+Movnih4gjZQTw51rz588y/ZgxVUEAQ8soCfX8OR26JwujCLGFAMsOjnwGrlPuQw9D/PPv8BYVR7pG/eeFtQpsLzR2KFI8SwKj9KlX++HeLOPuSBKrKeHBi7L4b+Kx184+ptAp4Trcscv69oARVYzWgaK01H1X0K3zNSmARKtxXYHvwJuT+8gLGGWgpHcWOmBeljFB2Ckg6wiAYOqfxEK3GMCAj6kIiTWdCBCXhkjUKMgJcLk271N9uLSbtvvK0S69OXAvoA5z94VsFubbmZvx4QAnXgBnJxENyQjy38wef81uPhxMpPJIQzr5ckuUTKe0wZyN57iFTWga8GvCwlh5UqvYgmaNV9XSxEVWs40kkosFwA70RgNOu8mLZfR6wDiwRa35y7j08NksqPQhcfkRBK/J8R75Iz+9C8gJpqzwiIeZII3QnYOkJWbVEI5jNuA+o2BwK82ifwnpSgHwaC+GNAdmW2VXfC+vPu6wR6lBj84C9WfvivZyUhZMJlJhjSukDlFJ3g4AvGJfC1iEpQJ/CaEd7G9wds7p71+odruKrHip/C7RdsxeVjzIxhoNkFGOW/+sk/YVAGtltfzZAIfzix8gcHhZCXpcGN2u69qWqD9OlRFAy7x2fQBhHUiETB+DocqvArYt98f+AEAXApsEmEcNLC0t2uPHCqPQIXwHYDfI4/9+8LMpchqr5HK39MJSrBXwnutNqjovjHFdq+fcHLp7YLR4mGgduW5hFpAXUoL4cTTuW5HJSkB5PC0S7A+8c+837DyoM1J9iv/po/o3BunlDqPjOSO/YbLFd+FGy9sxKFeT8b+nLNPrkAyD53FtT27yUS32yqUaEGTMBiASGcZ0FmK8nWxbvjC1q6WQC4VdWdAcBY8eFoAzIrC0b7Wt8wlPcIdE1FhUWeKU1Igv8Q/0dl4k/NnYSxdlDon8diUDeuQB4c8XVzcahRgyyZmNC+LAgeCfSVALde8/t1DCYawNoePGT83wlOpFUdOZKwxn89OsMEf0X8CxJCBN/dwKbFwkSMgx0ACJJDJD4iC1JEYh6XcEqVHpx4+J4I4UiAl26r5x64sttvSlAn3LBuQCz6edU8C+J5epBrC4YP52EFDgHrCw1B0eU9bOaTgh3wmYvQV3Oqqcf53XnVNXUBELX1xtSgFrirlII5d3HFulxBCNEfZx0h7K2f34XwdHpuYQcguN189Ow/nPXclaUcqMH5leCXjKOjbv3F0a7i2ZaRHmBe5zwnhA9S736ZC8AH8LHkg/T5znYgmES1dtuzGo92qwHIquiWX+4KgVLd8utv9Ml1BQNhEJW/FOgweiTguCUoQHkEwYhjfQIgm8eAzPKzHqAG5xGiiPyxeGRRaYetUpDVpHVC1T9bHGyaknb/TQTnuG7rDYwYCUT7/cMjtILzA+Go/FPw581F/mWeTkDuBsBCAK8ki+A29nMzPn4Rzjv6QV7xWW4fzQFUxb9jQQ1qc28kMi4mDl1NBr4usIsz5ltZqNm7AeJXfuTHd7nioLEyPBISU+8/tP1AC4Il/n+YGmjg2NiBRdl6yCw//zG5ph7bqaBuz8B4VMU/TqSsNPbwCeZA1cdxyG9SgKzRZPL+GXFOiH1/SFZ9wX8M3zUgvH8a4rMBjZj/h1W9MrwTiN6MlsCKiI4gycBzgV/xUaQGjGDHwHiYi0VIzeEAasCpNuL76AC7BIEl7i4AIxnAfoMxk35eJbZ68wWEUChs8IPz/EEE9BkUoNA4RCWSLJkY1h0Y/dG9bVCtUVPe7QRhtStXG4nOECDfUxc4Uw/Ik8JkA9o9+a83IrfHH11EdFUWc4phNgVFWkPsIHBnCvCCYBSgqEN9qtoXuwHhByYoJJA7BxIkkRwpDGgAHo+vQ3ZGOwCFJCJKUAx4MBpFZWvReeLgtBBkDDQu2OJxXa7SE/P4ZiUPHABjY1DsFIhPAaygWewiXK72hHjow/k8gCL6gKES8qcDZ7A+EhYlWCPGCX1wXIwzkQEKt8cP6iqkC0FEhFj/ZYtvXCtwuBLcDT5wXN+9H6ZEIkTwV/x/s78fXFX3siWHEKrC3tw7EFZ31Ll7ttknQyEMGgAqCaVe1bGk8r8nFWCQQR0h7CY0dsU/mIeIuA1AGCo02Q0YVXxub36sG1Qgfo0CBBUXxap+ECFEycQVyViBEBFPt14TK9rZHB9EwMG7DPXOv0OVHkdtx7OSCXfb3av4CFZGTwQBwT7/hKPHE4PzpJ4L4+FM9r1n8B+B+9R9I4Fu9brYUZgCunZWNxdQgIs8mASBQ4F8hJpEiaf4GPihk8FdAxin/kybjZjTj+mAQy6ihZ9whDvHAWB6BKrBXQr+5SBfqPaINwiz12UIwoTmbPACZY/fshBBBKNlW8ZCHwH/cVKSOZMm4Mxk4OwE9JeB+EFkn1IzcPQoiSB4vGgNeJSoik1A7m0TCmE/HrggB+/1M12C1Z18ACGoIeH1pH2IhAqFWgBq+kDFEWAvA3X8tpW0cnSD5WAOriOHhnYraF1eLTkS8P/QsHUBdtMPnOrMaANJE9AZiaKWII5Ue/8PTHn/UcCSTgIF2xN4zdmAQYIAKeBFl6FiO0aKfq5jcImHfPwTxcEdRmD3LcFoAva1Hdjm9UgGggI9YOoPkOBYLsT8HlG3nucMDGkOOJ8CkNOELdSO7D5qqAeJYBb2GpABgRi2gxLITgrOQ9C937HgB+0i7MeRx3gfPWCXLtgbLJAu/gCFBPzRX8eADJqCvA3FViC/BlOQC4LZyrBq8BdQAOUKoKjqR7v7EFfVFMojPgEoSlJesNIePyLHwW9NRgq7E6HvUN8A0yj0wyWDHRZ3J2A1jHdMyu3hCGwSDwdRir7h9VP7AKLgPoMCgKziOFLtrUm8aIFHlgxYfz8WBYUU55iAXauo+evJaIK/NTgRJM9sUcZRzcCnMdNKMJc7usnAyrpxHYkTRHK+n1HxS01LheAHqRWwKIDqLvQC0+PupHZgBawfVGsiniTVHwZHRqbUI/D4Cd+ftgyLAR1ehkIiqaKFw7MJEwUIuK5zsu4svoFYCFKgBJZACBuppOId2RDkPZas8H9kULcA9a0KTCQDGtpnzT+RMJiOGseHl4BQ1C29AWUXIIf/OIwwqoNEK3SCuA7FRiBrE9B4/PcrGJ1OQNj83F4Xbol/TgVHfMiIZLAdcaVkgh8sLrd+liNQH/FqsNTfj15m1J0X+ffZuq/gTY7QnvIfJz6UzBJLs83ItQpt3RfZz5iuGfNPajpngUm0R8DoA5jDlzsOTAwZjzsC3Jjxg7H914PjlcskGdghgx9HG4OOQH34uwQyzz61/0qiYNQjXxECuWYbGM/DrjtPH/Mw/K+gBLLSA+cEfPr4MroArzcDuybbr8Zc72i2UnzeHnTgzD4Ug78SzIvCoARVOQxaFFR3TzWnkkHUVFShEuqKxZnKz4p4YYcf8ZhYhuu8wFgSHcuuwCJagI4bgchJQK/qe9c/RT6nGcg6KGREJpb+MI0EY/b0jcsni3AJBeCQNsBOFVYoApcM2Aom4VFgIRdHpeIG8D3YaxBD+qCiQ+rBOSVnci8hzkAG1t/pgHA4uwDzmu8xFKkkkIqCfkIRs204r/hiDgutoAAcowBMZ9+KS0CcXVBOHCvJw2jMQSJyeoeExF2DuTuRcuWAo9sefyUQ6/oBaIjPtiRH1KvQKvygAHb171d+vc4GRMDPoxN/kL5pwlVh1mBQ1quQJAJ5j0TgOAis+h8d3mnC8xTKE34+8sDNjyVXE6nFMN+H39TQDmocHScENvN74LoGScGU4f7g6IG3n3C3qnG6JBS+Z5tHOOzRYQx+u7MZmAl0OSsRLAS/VIKfRAWU92+12aaVPksGDBWQuCMvgNy2M2Mt8EwqbjosZAec5xLEAmXmcFTHiOWARWglpNpjdEtBQRxJJU5VL5/7F1X86XntXgUK4q+KggsUoIIK8oA+kgy4+zLaACqQGTVOX6MBWdehL6BxHn+tlyBMDGAqufd7WOX5WTJwKYDfXJJP2GXDPk7Tj5Ed7BOG7DMFaBRAJgI/+H2Ngeb2SKb0zkoGlQBHkefDr7xMA5HZeJPtKIzyApI9gmnPgf1c3mulfhe0gFekDCdNFnrOwi4Gs6eTACNjB+Uegcgojog4V25P8bctRYY6RL8AJklE9ACFAGZdBEahd4d4CmghFhbzcwaXYH5qTlS6DY+KfNH5Avzjo2JJ0poDkSCMxLn73H/eB+ifvgvyIFCWAji7BWC8hd0qj0FziMdrS70BlVbgamIgcmotGZDNPwm0L9l5iHv7WRoAFx57ScFS2r2iwot8oKu8l+TOCOg2mZ2nFdjTgOFQENzKkJ8OjEnsE8f6AzyXwT6MNF3RDRnuj0Lwo6wTlBMDIyqaz6G+RiLJMg/KUrQV/rh9uH0tWduwoxmky0kSMQ+rnXxZsGadgnxfgk1pCnsIsGYltvfdzTOBIclIsN8MLAGcz5gBwj94AE8DuC9Molip/JGwB57nRyJiyD3pyk6q5ij+3TzRLohcqyqCEQBTepF15+WVmW8SEr5jMUUkx3oMIsrH3ndwAQganKzyMpOJNxMQooGBYwcByw7axIhgPRGEr6GSGJhkAELoQ1YRg+dPeD5IIRDIqq5PA2Jh0Rq0YcS8XBi0ghGRFpCtWTdum5+yLOsQf2EuYY8AfnbQZDgCjHxBSKwTGpt8QCIDVH3/4H5OwEvldhliINwAFLsEyyIfGKV+vm3eEehVqKTdNxtDiPoLHCRiuwTJxCECxMDqDjTvZ63KaPKvRgV2i/F3ohm88V8LN8hgJcXD5pVGIPPNn9EBqSQC0I4AMxBUcQNCkarkFgSn/oCs9GCVep4eUG5BRAOcQOCWlGSc3If0IFqRfURQGRrKewPKEJ9sLnIowKCcw+f48N6UHjqYtgInaCCkBbPSj8VEkCr2g8U43wY1xX/BNkwreQrzg+oaJghOCGTU8RBxuIp6VFOGoEXgEsBLIgV6gBgxoLSI5CgiYNT+GBHsU01GthrceiMUtv9KgAYktgVNeGrBbtiOQVi9x8WjiAW7UNUnm4Vet7WtsFgDCDYEwQ/EVL1PnQf/xCDLTowTh4c4HPRDoQaiwhKIAae4B7xgCBydI/CDPOrevK0FR4p6w3VfoXgQiB3T1N8Y1PCD0X19JqcHGfzB5WkQE4p/kdeXBcEVUXEIFqSij82lMyrWq/7c+LFHA7z5/dwOHHg8s/Y8C2CmhbmALtare+4UWLfb25BmXABKABTniC8gRAP2yvDAiUAsElnrxFzITQa/sAFecAOY7zPV/8jMQHSbWAiUPGkQNABhw85xrSCv+mMSzFR8+7mjw01A8f4F8S/td4jnDHYxpT8/OEyV3gz2+GTfdAeAszswfJNGlQhEIjB0Bls0BKn4Iw7WKu9f1gmSagmvqleEwJwnZwjO7npz1HdCJ1hS/mlBcRXyF3i/M7NxqJFoeH27z7nnJaBmpUZKHsTbGUc1ALEoIGsGYl9ixS50gjAT/VhB8IzvGTrBVfWEz1MzAkRFTtecW731VdjNQPukVdhdn0Y8d/a7WYH6i/TBPBzUFwAlHwtGHOQISrgb1AMUgDETTA3+THAdeRJhg59V/Ektofa9I8wxVICkC7QQSAd2O3cftzPzdMK6aA4iZI4ILfYRbb9RgqICt2AxVnYZ4kkBvHOBxT/zN9ybHx/f5Ql2fkGCX6ANm6F8WCfqAS+Eq5AGcHJd2IFHagTMHAAj+mWBnDXuc81CjhsAi5dL2K8QCYI1aJ/PJtSSxEFXASv7C2I3ZB9/a0j/7nDn/j1pHsz9Jr8fNpxPBUAUUYD4wz5GBlmyAiORjtAIGDFwzSUwqiNZ1d1tPiB7/Q9VeI9KeJU16/knkEeQJEALjY4rkp74fCZiMDSA/PgvT/aT2gYgp5E/P29AKBQAo6TRth5T4VesQFb0i4K7RA2MZpgyFXCEQHCOixuYMPgy2L7+45ezSSKt2oUkURlpXkEMOLSiXPuDQZjk63N5bmzOSxQdLHX7AhwUEA0BAeQPJIQzkAuFlOK/GtyLdiGDKEBdllQ7YouxV2Xdwza9So4Kp5Z0yAgUhTlJgFzSFrznIHYIwKcCu2/L3LsCg6UI1b1/CA+ApIV5/32HqOIjdQusE4azip5Wc1b0q/QGIAlaWEJbXP3r/L+AEipw/+BtkQVY9fIM2i/ZhgVEgJO6DZ1ksVtlYdoQAPhVO0oKmYBmnAYco4DRCRB3TwCziptaE0auER9/VzRqKNOEYINOQg2m1l9GpGNQAhh1v6UmxNQh2M4+LmlUzll0OTjYQOaGlZAEMCrdhmBphaMBwBADrSQQc3//He8KgFETT7p6BHnjj2X9EXsDjrgBS6ihoAmcSQVYmE4JgYWFpp1waAQRoqDzxDhU+HxSnZHz/9JEY6Y5MJA+cwoWrt99+U3Mc/9g/NQTFaigAEtwB1yBzwzucZSX7RZEILhR1d5GDCsBLVUdIQvsldZfEJt5i/MHx2hGJZFkVVyK242iFeh58oBUFqIQbkfp2DV2X0CkAYgv1sU+P+I/HmBu8nErugdRnUWhfp+A/ddlbEH3uQlBsNobUEMHasK1HOYn8BEEvCUaiuigXRIKj+sGOPA4KAWz9/s7WxcgB4+a6/fI2osEwv4yOENAiPf+wQhbc/5f0gGisWuQaRFmGoIqguARWsBQgTTocDLMT5OJUQnhqdCEig+/EShKSEgTVV0MBMnz04BcshPnLk/+OaV0/dwKzB4QUt1NB6uTDfGOP+cNm9mEsBAFiM7AQh9AKVEU75vy68jeOxrUC4mDEuYO0oLqoSdHaEF2eXYYSm0V+oEOwpLmYFOF3Z4CmAeBTIGueiIw2xoKPzDBJVBXQ5g5O8/twwA+QguIjJt3+g0NQEcDfUXgO5gsqlTBLkQLdl86K3CWneitQ8sg/5oWAUJP2C3V3RoEyji5n4b9lB4t9pz2CA+cAFn1Z9I/uzYsU/ELtEBOCHYQQqGcFejV+yeuRJX31zsKV5IGjway9z6PLDxKwNEPsBuOEiqw57jGgOtZ1Y++T50AuMFl7hPIbhskiOwsATtRoc7rS7dXrpcgrMCGJca6ELJo+Y0be0BW5ZKGcFz4y8W9BduwcDnK9iO5fagsKpp9ANnvDPxeP8THNyIVFo1AMas8Qk5v2Ytm0LCCYAXqn+wQsPTBh/5Bcnne14Os3uCQt28vsK1WUESJFviBgAW//3u9PLxusXchcCR2WsNzv/ImvgZzzkUByDUAIrjTvmSHAowpJBQE4SUlxMxnARlQbIqkArVAJ6pBBvELCCKlkyCDAP45BYfEPfcUpfMch3Vn4bheYK4E66BxAxHSVd5INgEPgU/NBCDfNQ8Ho1CoINAPQAW/QT8OCIZlNFCB84XhoDChFByHGjx35v9BLgyhmojqHYb5QYXnuAecvua0hZe6BV9f7v4ibvgvamrmAc1TmaEir0LQ9h97eYAYVoM/nWA60i8Q3Ifezha9BqaaL3zvqd6IAuwwLSCCuCLuJWch4h30giPtyiAphKEBcCu9BV5wwzkMxID8rhMwdwMhcSFgrBT3RUTQboAUg3+p+Qe1IGarOioVnazmefV3lHpwA0AcLWCahUiXwePHWJsP+GH1gnp/we5KfOhJAbsj0H/BIEb04TbrTPsAyb2LLu93KwfCvn5PLAwrOXAa72eEQRo1CNdw5IprsAZ3hApy9zlcITG2vpCihsRSYxNS+J4vdBZ6B52eqRcQ/QXmSjAWSfa/5GA5qEg4iJFtm624AqXLrSA2gx8p1Mdqcghv41S0lSp/xAYs9gakQc4Ie2RTUYwYgt748mV+FU1Xgp14eW3XYZ6cdqGTNHwHICTwEeTPl0jEZwIgP9gDEaogeg5IHWCF+1eoAhvEKPB/EAeTRsM/pSAP5wjWEUMM1/NJRhwJbpJSgK7S7zF3EOsI5jBQBK9DV80Z8Y0COzvmWzJXgDl40KEC6cqvqgi4OB5cpgLFYK/1CvDiItXqC6/S87wfAUfPtxqfGNzlYaOjlf1IsHPPvffHgDAoEeEST4ZLZUd/RSo91/BjXY5ggWgQ4In3fyj4mUqPrInHOCLKO3wUwRsfyXpt1nEIRLrqcWeTuk7bigsbid1zD4iDRQtnIdQsyIXnFCn1I9D7ADgxEhOvR5AJosoUbu1FkJyYCi9OhQERoIx+4AX/YqUXQhtYEwKN4Cy1HntLMmtaAQpqfrT/UCoLSxeswjA5UWPPi0mjajUWxMTdVusNvt/ChMdmILK5IRMFu90BMEzFYHdg2GAgeYVHMMJIBTA7EFTx/5fpgTFXz9w/en0ZjD8kCDoKPNGwlB01BmoWQbh+AxR689mBponGJOr9OwmMu3dtJ/ylW1Tik4ElUPmR9RqII+pVhD9ychABMQ51gOIZg+/G+5mGIzLB1JJC5WhzYjhJ7IWmLDpA8jzsAafUPkB2WnFBF4iSxkq1ty7f25rv/+EQLOxs2oUdTSA9HIR9swdBlCcFe9owPC3XWDDC0ISVzsEVbSCF/sWdA5Fu4HJqankp2SeQCYYrImNalfmhpVxYrGkUS4LeSUjg8dD7+D7w/ybIfy7vlB9/HJ978zr7/45Qgajzj+4EjIK/ULHPRAOlKr/aG0AFcqCyu0GcW45Igh6JMJmhA49/U+cEssHNJhtXDC1MOya3j/sAiAGcrEtqtgjBD6wEzSDc7D8o6C8rIqAZyPk+NQoNLAZ1hR64Yl1FBY648smUYKnSg1Xwk/0DyRyArByMUobyByhCcPnOaPyoegREFS4jNfYAw+IHCjdC1J2WDZBke/OyN85J24WiXwDYPoJyYuCD238ulvuzwt6KgHf0shWKsqCFFGjB/w8HU8eeTED9wAAAAABJRU5ErkJggg==", "EnvironmentBRDFTexture" + g_++, e, !0, !1, vo.BILINEAR_SAMPLINGMODE); e._blockEntityCollection = i; var n = e.getEngine().getLoadedTexturesCache(), o = n.indexOf(r.getInternalTexture()); -1 !== o && n.splice(o, 1), r.isRGBD = !0, r.wrapU = vo.CLAMP_ADDRESSMODE, r.wrapV = vo.CLAMP_ADDRESSMODE, e.environmentBRDFTexture = r, e.useDelayedTextureLoading = t, ud.ExpandRGBDTexture(r); var a = e.getEngine().onContextRestoredObservable.add((function () { r.isRGBD = !0; var e = function () { r.isReady() ? ud.ExpandRGBDTexture(r) : xi.SetImmediate(e) }; e() })); e.onDisposeObservable.add((function () { e.getEngine().onContextRestoredObservable.remove(a) })) } return e.environmentBRDFTexture }, y_ = { GetEnvironmentBRDFTexture: v_ }, b_ = function (e) { function t() { var t = null !== e && e.apply(this, arguments) || this; return t.BRDF_V_HEIGHT_CORRELATED = !1, t.MS_BRDF_ENERGY_CONSERVATION = !1, t.SPHERICAL_HARMONICS = !1, t.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION = !1, t } return W(t, e), t }(Mi), T_ = function (e) { function t(i, r) { void 0 === r && (r = !0); var n = e.call(this, i, "PBRBRDF", 90, new b_, r) || this; return n._useEnergyConservation = t.DEFAULT_USE_ENERGY_CONSERVATION, n.useEnergyConservation = t.DEFAULT_USE_ENERGY_CONSERVATION, n._useSmithVisibilityHeightCorrelated = t.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED, n.useSmithVisibilityHeightCorrelated = t.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED, n._useSphericalHarmonics = t.DEFAULT_USE_SPHERICAL_HARMONICS, n.useSphericalHarmonics = t.DEFAULT_USE_SPHERICAL_HARMONICS, n._useSpecularGlossinessInputEnergyConservation = t.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION, n.useSpecularGlossinessInputEnergyConservation = t.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION, n._internalMarkAllSubMeshesAsMiscDirty = i._dirtyCallbacks[a.MATERIAL_MiscDirtyFlag], n._enable(!0), n } return W(t, e), t.prototype._markAllSubMeshesAsMiscDirty = function () { this._internalMarkAllSubMeshesAsMiscDirty() }, t.prototype.prepareDefines = function (e) { e.BRDF_V_HEIGHT_CORRELATED = this._useSmithVisibilityHeightCorrelated, e.MS_BRDF_ENERGY_CONSERVATION = this._useEnergyConservation && this._useSmithVisibilityHeightCorrelated, e.SPHERICAL_HARMONICS = this._useSphericalHarmonics, e.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION = this._useSpecularGlossinessInputEnergyConservation }, t.prototype.getClassName = function () { return "PBRBRDFConfiguration" }, t.DEFAULT_USE_ENERGY_CONSERVATION = !0, t.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED = !0, t.DEFAULT_USE_SPHERICAL_HARMONICS = !0, t.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION = !0, X([xe(), Se("_markAllSubMeshesAsMiscDirty")], t.prototype, "useEnergyConservation", void 0), X([xe(), Se("_markAllSubMeshesAsMiscDirty")], t.prototype, "useSmithVisibilityHeightCorrelated", void 0), X([xe(), Se("_markAllSubMeshesAsMiscDirty")], t.prototype, "useSphericalHarmonics", void 0), X([xe(), Se("_markAllSubMeshesAsMiscDirty")], t.prototype, "useSpecularGlossinessInputEnergyConservation", void 0), t }(hc); Ut.IncludesShadersStore.pbrFragmentDeclaration = "uniform vec4 vEyePosition;uniform vec3 vReflectionColor;uniform vec4 vAlbedoColor;uniform vec4 vLightingIntensity;uniform vec4 vReflectivityColor;uniform vec4 vMetallicReflectanceFactors;uniform vec3 vEmissiveColor;uniform float visibility;uniform vec3 vAmbientColor;\n#ifdef ALBEDO\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;uniform vec2 vTangentSpaceParams;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(SS_REFRACTION) || defined(PREPASS)\nuniform mat4 view;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#ifdef REALTIME_FILTERING\nuniform vec2 vReflectionFilteringInfo;\n#endif\nuniform mat4 reflectionMatrix;uniform vec3 vReflectionMicrosurfaceInfos;\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;uniform vec3 vReflectionSize; \n#endif\n#endif\n#if defined(SS_REFRACTION) && defined(SS_USE_LOCAL_REFRACTIONMAP_CUBIC)\nuniform vec3 vRefractionPosition;uniform vec3 vRefractionSize; \n#endif\n#ifdef CLEARCOAT\nuniform vec2 vClearCoatParams;uniform vec4 vClearCoatRefractionParams;\n#if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)\nuniform vec4 vClearCoatInfos;\n#endif\n#ifdef CLEARCOAT_TEXTURE\nuniform mat4 clearCoatMatrix;\n#endif\n#ifdef CLEARCOAT_TEXTURE_ROUGHNESS\nuniform mat4 clearCoatRoughnessMatrix;\n#endif\n#ifdef CLEARCOAT_BUMP\nuniform vec2 vClearCoatBumpInfos;uniform vec2 vClearCoatTangentSpaceParams;uniform mat4 clearCoatBumpMatrix;\n#endif\n#ifdef CLEARCOAT_TINT\nuniform vec4 vClearCoatTintParams;uniform float clearCoatColorAtDistance;\n#ifdef CLEARCOAT_TINT_TEXTURE\nuniform vec2 vClearCoatTintInfos;uniform mat4 clearCoatTintMatrix;\n#endif\n#endif\n#endif\n#ifdef IRIDESCENCE\nuniform vec4 vIridescenceParams;\n#if defined(IRIDESCENCE_TEXTURE) || defined(IRIDESCENCE_THICKNESS_TEXTURE)\nuniform vec4 vIridescenceInfos;\n#endif\n#ifdef IRIDESCENCE_TEXTURE\nuniform mat4 iridescenceMatrix;\n#endif\n#ifdef IRIDESCENCE_THICKNESS_TEXTURE\nuniform mat4 iridescenceThicknessMatrix;\n#endif\n#endif\n#ifdef ANISOTROPIC\nuniform vec3 vAnisotropy;\n#ifdef ANISOTROPIC_TEXTURE\nuniform vec2 vAnisotropyInfos;uniform mat4 anisotropyMatrix;\n#endif\n#endif\n#ifdef SHEEN\nuniform vec4 vSheenColor;\n#ifdef SHEEN_ROUGHNESS\nuniform float vSheenRoughness;\n#endif\n#if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)\nuniform vec4 vSheenInfos;\n#endif\n#ifdef SHEEN_TEXTURE\nuniform mat4 sheenMatrix;\n#endif\n#ifdef SHEEN_TEXTURE_ROUGHNESS\nuniform mat4 sheenRoughnessMatrix;\n#endif\n#endif\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\nuniform vec4 vRefractionMicrosurfaceInfos;uniform vec4 vRefractionInfos;uniform mat4 refractionMatrix;\n#ifdef REALTIME_FILTERING\nuniform vec2 vRefractionFilteringInfo;\n#endif\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nuniform vec2 vThicknessInfos;uniform mat4 thicknessMatrix;\n#endif\n#ifdef SS_REFRACTIONINTENSITY_TEXTURE\nuniform vec2 vRefractionIntensityInfos;uniform mat4 refractionIntensityMatrix;\n#endif\n#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE\nuniform vec2 vTranslucencyIntensityInfos;uniform mat4 translucencyIntensityMatrix;\n#endif\nuniform vec2 vThicknessParam;uniform vec3 vDiffusionDistance;uniform vec4 vTintColor;uniform vec3 vSubSurfaceIntensity;\n#endif\n#ifdef PREPASS\n#ifdef SS_SCATTERING\nuniform float scatteringDiffusionProfile;\n#endif\n#endif\n#if DEBUGMODE>0\nuniform vec2 vDebugMode;\n#endif\n#ifdef DETAIL\nuniform vec4 vDetailInfos;\n#endif\n#include\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#ifdef SPHERICAL_HARMONICS\nuniform vec3 vSphericalL00;uniform vec3 vSphericalL1_1;uniform vec3 vSphericalL10;uniform vec3 vSphericalL11;uniform vec3 vSphericalL2_2;uniform vec3 vSphericalL2_1;uniform vec3 vSphericalL20;uniform vec3 vSphericalL21;uniform vec3 vSphericalL22;\n#else\nuniform vec3 vSphericalX;uniform vec3 vSphericalY;uniform vec3 vSphericalZ;uniform vec3 vSphericalXX_ZZ;uniform vec3 vSphericalYY_ZZ;uniform vec3 vSphericalZZ;uniform vec3 vSphericalXY;uniform vec3 vSphericalYZ;uniform vec3 vSphericalZX;\n#endif\n#endif\n#define ADDITIONAL_FRAGMENT_DECLARATION\n"; Ut.IncludesShadersStore.pbrUboDeclaration = "layout(std140,column_major) uniform;uniform Material {vec2 vAlbedoInfos;vec4 vAmbientInfos;vec2 vOpacityInfos;vec2 vEmissiveInfos;vec2 vLightmapInfos;vec3 vReflectivityInfos;vec2 vMicroSurfaceSamplerInfos;vec2 vReflectionInfos;vec2 vReflectionFilteringInfo;vec3 vReflectionPosition;vec3 vReflectionSize;vec3 vBumpInfos;mat4 albedoMatrix;mat4 ambientMatrix;mat4 opacityMatrix;mat4 emissiveMatrix;mat4 lightmapMatrix;mat4 reflectivityMatrix;mat4 microSurfaceSamplerMatrix;mat4 bumpMatrix;vec2 vTangentSpaceParams;mat4 reflectionMatrix;vec3 vReflectionColor;vec4 vAlbedoColor;vec4 vLightingIntensity;vec3 vReflectionMicrosurfaceInfos;float pointSize;vec4 vReflectivityColor;vec3 vEmissiveColor;vec3 vAmbientColor;vec2 vDebugMode;vec4 vMetallicReflectanceFactors;vec2 vMetallicReflectanceInfos;mat4 metallicReflectanceMatrix;vec2 vReflectanceInfos;mat4 reflectanceMatrix;vec3 vSphericalL00;vec3 vSphericalL1_1;vec3 vSphericalL10;vec3 vSphericalL11;vec3 vSphericalL2_2;vec3 vSphericalL2_1;vec3 vSphericalL20;vec3 vSphericalL21;vec3 vSphericalL22;vec3 vSphericalX;vec3 vSphericalY;vec3 vSphericalZ;vec3 vSphericalXX_ZZ;vec3 vSphericalYY_ZZ;vec3 vSphericalZZ;vec3 vSphericalXY;vec3 vSphericalYZ;vec3 vSphericalZX;\n#define ADDITIONAL_UBO_DECLARATION\n};\n#include\n#include\n"; Ut.IncludesShadersStore.pbrFragmentExtraDeclaration = "varying vec3 vPositionW;\n#if DEBUGMODE>0\nvarying vec4 vClipSpacePosition;\n#endif\n#include[1..7]\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#endif\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nvarying vec4 vColor;\n#endif\n"; Ut.IncludesShadersStore.samplerFragmentAlternateDeclaration = "#ifdef _DEFINENAME_\n#if _DEFINENAME_DIRECTUV==1\n#define v_VARYINGNAME_UV vMainUV1\n#elif _DEFINENAME_DIRECTUV==2\n#define v_VARYINGNAME_UV vMainUV2\n#elif _DEFINENAME_DIRECTUV==3\n#define v_VARYINGNAME_UV vMainUV3\n#elif _DEFINENAME_DIRECTUV==4\n#define v_VARYINGNAME_UV vMainUV4\n#elif _DEFINENAME_DIRECTUV==5\n#define v_VARYINGNAME_UV vMainUV5\n#elif _DEFINENAME_DIRECTUV==6\n#define v_VARYINGNAME_UV vMainUV6\n#else\nvarying vec2 v_VARYINGNAME_UV;\n#endif\n#endif\n"; Ut.IncludesShadersStore.pbrFragmentSamplersDeclaration = "#include(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_SAMPLERNAME_,albedo)\n#include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)\n#include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)\n#include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)\n#include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)\n#include(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_SAMPLERNAME_,reflectivity)\n#include(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_SAMPLERNAME_,microSurface)\n#include(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_SAMPLERNAME_,metallicReflectance)\n#include(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_SAMPLERNAME_,reflectance)\n#include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)\n#ifdef CLEARCOAT\n#include(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_SAMPLERNAME_,clearCoat)\n#include(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness)\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL)\nuniform sampler2D clearCoatRoughnessSampler;\n#endif\n#include(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_SAMPLERNAME_,clearCoatBump)\n#include(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_SAMPLERNAME_,clearCoatTint)\n#endif\n#ifdef IRIDESCENCE\n#include(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence,_SAMPLERNAME_,iridescence)\n#include(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness,_SAMPLERNAME_,iridescenceThickness)\n#endif\n#ifdef SHEEN\n#include(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_SAMPLERNAME_,sheen)\n#include(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness)\n#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL)\nuniform sampler2D sheenRoughnessSampler;\n#endif\n#endif\n#ifdef ANISOTROPIC\n#include(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_SAMPLERNAME_,anisotropy)\n#endif\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;uniform samplerCube reflectionSamplerHigh;\n#endif\n#ifdef USEIRRADIANCEMAP\nuniform samplerCube irradianceSampler;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform sampler2D reflectionSamplerLow;uniform sampler2D reflectionSamplerHigh;\n#endif\n#ifdef USEIRRADIANCEMAP\nuniform sampler2D irradianceSampler;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#endif\n#ifdef ENVIRONMENTBRDF\nuniform sampler2D environmentBrdfSampler;\n#endif\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\n#ifdef SS_REFRACTIONMAP_3D\n#define sampleRefraction(s,c) textureCube(s,c)\nuniform samplerCube refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;uniform samplerCube refractionSamplerHigh;\n#endif\n#else\n#define sampleRefraction(s,c) texture2D(s,c)\nuniform sampler2D refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform sampler2D refractionSamplerLow;uniform sampler2D refractionSamplerHigh;\n#endif\n#endif\n#endif\n#include(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_SAMPLERNAME_,thickness)\n#include(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_SAMPLERNAME_,refractionIntensity)\n#include(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_SAMPLERNAME_,translucencyIntensity)\n#endif\n"; Ut.IncludesShadersStore.subSurfaceScatteringFunctions = "bool testLightingForSSS(float diffusionProfile)\n{return diffusionProfile<1.;}"; Ut.IncludesShadersStore.importanceSampling = "vec3 hemisphereCosSample(vec2 u) {float phi=2.*PI*u.x;float cosTheta2=1.-u.y;float cosTheta=sqrt(cosTheta2);float sinTheta=sqrt(1.-cosTheta2);return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);}\nvec3 hemisphereImportanceSampleDggx(vec2 u,float a) {float phi=2.*PI*u.x;float cosTheta2=(1.-u.y)/(1.+(a+1.)*((a-1.)*u.y));float cosTheta=sqrt(cosTheta2);float sinTheta=sqrt(1.-cosTheta2);return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);}\nvec3 hemisphereImportanceSampleDCharlie(vec2 u,float a) { \nfloat phi=2.*PI*u.x;float sinTheta=pow(u.y,a/(2.*a+1.));float cosTheta=sqrt(1.-sinTheta*sinTheta);return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);}"; Ut.IncludesShadersStore.pbrHelperFunctions = "#define RECIPROCAL_PI2 0.15915494\n#define RECIPROCAL_PI 0.31830988618\n#define MINIMUMVARIANCE 0.0005\nfloat convertRoughnessToAverageSlope(float roughness)\n{return square(roughness)+MINIMUMVARIANCE;}\nfloat fresnelGrazingReflectance(float reflectance0) {float reflectance90=saturate(reflectance0*25.0);return reflectance90;}\nvec2 getAARoughnessFactors(vec3 normalVector) {\n#ifdef SPECULARAA\nvec3 nDfdx=dFdx(normalVector.xyz);vec3 nDfdy=dFdy(normalVector.xyz);float slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));float geometricRoughnessFactor=pow(saturate(slopeSquare),0.333);float geometricAlphaGFactor=sqrt(slopeSquare);geometricAlphaGFactor*=0.75;return vec2(geometricRoughnessFactor,geometricAlphaGFactor);\n#else\nreturn vec2(0.);\n#endif\n}\n#ifdef ANISOTROPIC\n#ifdef ANISOTROPIC_LEGACY\nvec2 getAnisotropicRoughness(float alphaG,float anisotropy) {float alphaT=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);float alphaB=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);return vec2(alphaT,alphaB);}\nvec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy,float roughness) {vec3 anisotropicFrameDirection=anisotropy>=0.0 ? B : T;vec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),V);vec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection);vec3 anisotropicNormal=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));return anisotropicNormal;}\n#else\nvec2 getAnisotropicRoughness(float alphaG,float anisotropy) {float alphaT=max(mix(alphaG,1.0,anisotropy*anisotropy),MINIMUMVARIANCE);float alphaB=max(alphaG,MINIMUMVARIANCE);return vec2(alphaT,alphaB);}\nvec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy,float roughness) {vec3 bentNormal=cross(B,V);bentNormal=normalize(cross(bentNormal,B));float a=square(square(1.0-anisotropy*(1.0-roughness)));bentNormal=normalize(mix(bentNormal,N,a));return bentNormal;}\n#endif\n#endif\n#if defined(CLEARCOAT) || defined(SS_REFRACTION)\nvec3 cocaLambert(vec3 alpha,float distance) {return exp(-alpha*distance);}\nvec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) {return cocaLambert(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));}\nvec3 computeColorAtDistanceInMedia(vec3 color,float distance) {return -log(color)/distance;}\nvec3 computeClearCoatAbsorption(float NdotVRefract,float NdotLRefract,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {vec3 clearCoatAbsorption=mix(vec3(1.0),\ncocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),\nclearCoatIntensity);return clearCoatAbsorption;}\n#endif\n#ifdef MICROSURFACEAUTOMATIC\nfloat computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)\n{const float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;float reflectivityLuminance=getLuminance(reflectivityColor);float reflectivityLuma=sqrt(reflectivityLuminance);microSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;return microSurface;}\n#endif\n"; Ut.IncludesShadersStore.harmonicsFunctions = "#ifdef USESPHERICALFROMREFLECTIONMAP\n#ifdef SPHERICAL_HARMONICS\nvec3 computeEnvironmentIrradiance(vec3 normal) {return vSphericalL00\n+ vSphericalL1_1*(normal.y)\n+ vSphericalL10*(normal.z)\n+ vSphericalL11*(normal.x)\n+ vSphericalL2_2*(normal.y*normal.x)\n+ vSphericalL2_1*(normal.y*normal.z)\n+ vSphericalL20*((3.0*normal.z*normal.z)-1.0)\n+ vSphericalL21*(normal.z*normal.x)\n+ vSphericalL22*(normal.x*normal.x-(normal.y*normal.y));}\n#else\nvec3 computeEnvironmentIrradiance(vec3 normal) {float Nx=normal.x;float Ny=normal.y;float Nz=normal.z;vec3 C1=vSphericalZZ.rgb;vec3 Cx=vSphericalX.rgb;vec3 Cy=vSphericalY.rgb;vec3 Cz=vSphericalZ.rgb;vec3 Cxx_zz=vSphericalXX_ZZ.rgb;vec3 Cyy_zz=vSphericalYY_ZZ.rgb;vec3 Cxy=vSphericalXY.rgb;vec3 Cyz=vSphericalYZ.rgb;vec3 Czx=vSphericalZX.rgb;vec3 a1=Cyy_zz*Ny+Cy;vec3 a2=Cyz*Nz+a1;vec3 b1=Czx*Nz+Cx;vec3 b2=Cxy*Ny+b1;vec3 b3=Cxx_zz*Nx+b2;vec3 t1=Cz *Nz+C1;vec3 t2=a2 *Ny+t1;vec3 t3=b3 *Nx+t2;return t3;}\n#endif\n#endif\n"; Ut.IncludesShadersStore.pbrDirectLightingSetupFunctions = "struct preLightingInfo\n{vec3 lightOffset;float lightDistanceSquared;float lightDistance;float attenuation;vec3 L;vec3 H;float NdotV;float NdotLUnclamped;float NdotL;float VdotH;float roughness;\n#ifdef IRIDESCENCE\nfloat iridescenceIntensity;\n#endif\n};preLightingInfo computePointAndSpotPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {preLightingInfo result;result.lightOffset=lightData.xyz-vPositionW;result.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);result.lightDistance=sqrt(result.lightDistanceSquared);result.L=normalize(result.lightOffset);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));result.NdotLUnclamped=dot(N,result.L);result.NdotL=saturateEps(result.NdotLUnclamped);return result;}\npreLightingInfo computeDirectionalPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {preLightingInfo result;result.lightDistance=length(-lightData.xyz);result.L=normalize(-lightData.xyz);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));result.NdotLUnclamped=dot(N,result.L);result.NdotL=saturateEps(result.NdotLUnclamped);return result;}\npreLightingInfo computeHemisphericPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {preLightingInfo result;result.NdotL=dot(N,lightData.xyz)*0.5+0.5;result.NdotL=saturateEps(result.NdotL);result.NdotLUnclamped=result.NdotL;\n#ifdef SPECULARTERM\nresult.L=normalize(lightData.xyz);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));\n#endif\nreturn result;}"; Ut.IncludesShadersStore.pbrDirectLightingFalloffFunctions = "float computeDistanceLightFalloff_Standard(vec3 lightOffset,float range)\n{return max(0.,1.0-length(lightOffset)/range);}\nfloat computeDistanceLightFalloff_Physical(float lightDistanceSquared)\n{return 1.0/maxEps(lightDistanceSquared);}\nfloat computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)\n{float lightDistanceFalloff=1.0/maxEps(lightDistanceSquared);float factor=lightDistanceSquared*inverseSquaredRange;float attenuation=saturate(1.0-factor*factor);attenuation*=attenuation;lightDistanceFalloff*=attenuation;return lightDistanceFalloff;}\nfloat computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDistanceLightFalloff_Physical(lightDistanceSquared);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);\n#else\nreturn computeDistanceLightFalloff_Standard(lightOffset,range);\n#endif\n}\nfloat computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)\n{float falloff=0.0;float cosAngle=maxEps(dot(-lightDirection,directionToLightCenterW));if (cosAngle>=cosHalfAngle)\n{falloff=max(0.,pow(cosAngle,exponent));}\nreturn falloff;}\nfloat computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle)\n{const float kMinusLog2ConeAngleIntensityRatio=6.64385618977; \nfloat concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);vec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);float falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));return falloff;}\nfloat computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset)\n{float cd=dot(-lightDirection,directionToLightCenterW);float falloff=saturate(cd*lightAngleScale+lightAngleOffset);falloff*=falloff;return falloff;}\nfloat computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);\n#else\nreturn computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);\n#endif\n}"; Ut.IncludesShadersStore.pbrBRDFFunctions = "#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n#ifdef MS_BRDF_ENERGY_CONSERVATION\nvec3 getEnergyConservationFactor(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {return 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);}\n#endif\n#ifdef ENVIRONMENTBRDF\nvec3 getBRDFLookup(float NdotV,float perceptualRoughness) {vec2 UV=vec2(NdotV,perceptualRoughness);vec4 brdfLookup=texture2D(environmentBrdfSampler,UV);\n#ifdef ENVIRONMENTBRDF_RGBD\nbrdfLookup.rgb=fromRGBD(brdfLookup.rgba);\n#endif\nreturn brdfLookup.rgb;}\nvec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 specularEnvironmentR90,const vec3 environmentBrdf) {\n#ifdef BRDF_V_HEIGHT_CORRELATED\nvec3 reflectance=(specularEnvironmentR90-specularEnvironmentR0)*environmentBrdf.x+specularEnvironmentR0*environmentBrdf.y;\n#else\nvec3 reflectance=specularEnvironmentR0*environmentBrdf.x+specularEnvironmentR90*environmentBrdf.y;\n#endif\nreturn reflectance;}\nvec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {\n#ifdef BRDF_V_HEIGHT_CORRELATED\nvec3 reflectance=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0);\n#else\nvec3 reflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;\n#endif\nreturn reflectance;}\n#endif\n/* NOT USED\n#if defined(SHEEN) && defined(SHEEN_SOFTER)\nfloat getBRDFLookupCharlieSheen(float NdotV,float perceptualRoughness)\n{float c=1.0-NdotV;float c3=c*c*c;return 0.65584461*c3+1.0/(4.16526551+exp(-7.97291361*perceptualRoughness+6.33516894));}\n#endif\n*/\n#if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL)\nvec3 getReflectanceFromAnalyticalBRDFLookup_Jones(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{float weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);return reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));}\n#endif\n#if defined(SHEEN) && defined(ENVIRONMENTBRDF)\n/**\n* The sheen BRDF not containing F can be easily stored in the blue channel of the BRDF texture.\n* The blue channel contains DCharlie*VAshikhmin*NdotL as a lokkup table\n*/\nvec3 getSheenReflectanceFromBRDFLookup(const vec3 reflectance0,const vec3 environmentBrdf) {vec3 sheenEnvironmentReflectance=reflectance0*environmentBrdf.b;return sheenEnvironmentReflectance;}\n#endif\nvec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)\n{return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);}\nfloat fresnelSchlickGGX(float VdotH,float reflectance0,float reflectance90)\n{return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);}\n#ifdef CLEARCOAT\nvec3 getR0RemappedForClearCoat(vec3 f0) {\n#ifdef CLEARCOAT_DEFAULTIOR\n#ifdef MOBILE\nreturn saturate(f0*(f0*0.526868+0.529324)-0.0482256);\n#else\nreturn saturate(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998);\n#endif\n#else\nvec3 s=sqrt(f0);vec3 t=(vClearCoatRefractionParams.z+vClearCoatRefractionParams.w*s)/(vClearCoatRefractionParams.w+vClearCoatRefractionParams.z*s);return square(t);\n#endif\n}\n#endif\n#ifdef IRIDESCENCE\nconst mat3 XYZ_TO_REC709=mat3(\n3.2404542,-0.9692660, 0.0556434,\n-1.5371385, 1.8760108,-0.2040259,\n-0.4985314, 0.0415560, 1.0572252\n);vec3 getIORTfromAirToSurfaceR0(vec3 f0) {vec3 sqrtF0=sqrt(f0);return (1.+sqrtF0)/(1.-sqrtF0);}\nvec3 getR0fromIORs(vec3 iorT,float iorI) {return square((iorT-vec3(iorI))/(iorT+vec3(iorI)));}\nfloat getR0fromIORs(float iorT,float iorI) {return square((iorT-iorI)/(iorT+iorI));}\nvec3 evalSensitivity(float opd,vec3 shift) {float phase=2.0*PI*opd*1.0e-9;const vec3 val=vec3(5.4856e-13,4.4201e-13,5.2481e-13);const vec3 pos=vec3(1.6810e+06,1.7953e+06,2.2084e+06);const vec3 var=vec3(4.3278e+09,9.3046e+09,6.6121e+09);vec3 xyz=val*sqrt(2.0*PI*var)*cos(pos*phase+shift)*exp(-square(phase)*var);xyz.x+=9.7470e-14*sqrt(2.0*PI*4.5282e+09)*cos(2.2399e+06*phase+shift[0])*exp(-4.5282e+09*square(phase));xyz/=1.0685e-7;vec3 srgb=XYZ_TO_REC709*xyz;return srgb;}\nvec3 evalIridescence(float outsideIOR,float eta2,float cosTheta1,float thinFilmThickness,vec3 baseF0) {vec3 I=vec3(1.0);float iridescenceIOR=mix(outsideIOR,eta2,smoothstep(0.0,0.03,thinFilmThickness));float sinTheta2Sq=square(outsideIOR/iridescenceIOR)*(1.0-square(cosTheta1));float cosTheta2Sq=1.0-sinTheta2Sq;if (cosTheta2Sq<0.0) {return I;}\nfloat cosTheta2=sqrt(cosTheta2Sq);float R0=getR0fromIORs(iridescenceIOR,outsideIOR);float R12=fresnelSchlickGGX(cosTheta1,R0,1.);float R21=R12;float T121=1.0-R12;float phi12=0.0;if (iridescenceIOR 0 && 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([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isEnabled", void 0), X([xe()], t.prototype, "intensity", void 0), X([xe()], t.prototype, "roughness", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "indexOfRefraction", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "texture", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRoughnessFromMainTexture", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "textureRoughness", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "remapF0OnInterfaceChange", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "bumpTexture", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isTintEnabled", void 0), X([Re()], t.prototype, "tintColor", void 0), X([xe()], t.prototype, "tintColorAtDistance", void 0), X([xe()], t.prototype, "tintThickness", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "tintTexture", void 0), t }(hc), x_ = 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 }(Mi), A_ = function (e) { function t(i, r) { void 0 === r && (r = !0); var n = e.call(this, i, "PBRIridescence", 110, new x_, 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 && ic.IridescenceTextureEnabled && !this._texture.isReadyOrNotBlocking()) return !1; if (this._thicknessTexture && ic.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 && ic.IridescenceTextureEnabled ? zn.PrepareDefinesForMergedUV(this._texture, e, "IRIDESCENCE_TEXTURE") : e.IRIDESCENCE_TEXTURE = !1, !e.IRIDESCENCE_USE_THICKNESS_FROM_MAINTEXTURE && this._thicknessTexture && ic.IridescenceTextureEnabled ? zn.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 && ic.IridescenceTextureEnabled ? (e.updateFloat4("vIridescenceInfos", this._texture.coordinatesIndex, this._texture.level, -1, -1), zn.BindTextureMatrix(this._texture, e, "iridescence")) : (this._texture || this._thicknessTexture) && ic.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 && zn.BindTextureMatrix(this._texture, e, "iridescence"), !this._thicknessTexture || f || d.IRIDESCENCE_USE_THICKNESS_FROM_MAINTEXTURE || zn.BindTextureMatrix(this._thicknessTexture, e, "iridescenceThickness")), e.updateFloat4("vIridescenceParams", this.intensity, this.indexOfRefraction, this.minimumThickness, this.maximumThickness)), t.texturesEnabled && (this._texture && ic.IridescenceTextureEnabled && e.setTexture("iridescenceSampler", this._texture), this._thicknessTexture && !f && !d.IRIDESCENCE_USE_THICKNESS_FROM_MAINTEXTURE && ic.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([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isEnabled", void 0), X([xe()], t.prototype, "intensity", void 0), X([xe()], t.prototype, "minimumThickness", void 0), X([xe()], t.prototype, "maximumThickness", void 0), X([xe()], t.prototype, "indexOfRefraction", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "texture", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "thicknessTexture", void 0), t }(hc), R_ = 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 }(Mi), C_ = function (e) { function t(t, i) { void 0 === i && (i = !0); var r = e.call(this, t, "PBRAnisotropic", 110, new R_, 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 && ic.AnisotropicTextureEnabled && !this._texture.isReadyOrNotBlocking()) }, t.prototype.prepareDefinesBeforeAttributes = function (e, t, i) { this._isEnabled ? (e.ANISOTROPIC = this._isEnabled, this._isEnabled && !i.isVerticesDataPresent(Hi.TangentKind) && (e._needUVs = !0, e.MAINUV1 = !0), e._areTexturesDirty && t.texturesEnabled && (this._texture && ic.AnisotropicTextureEnabled ? zn.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 && ic.AnisotropicTextureEnabled && (e.updateFloat2("vAnisotropyInfos", this._texture.coordinatesIndex, this._texture.level), zn.BindTextureMatrix(this._texture, e, "anisotropy")), e.updateFloat3("vAnisotropy", this.direction.x, this.direction.y, this.intensity)), t.texturesEnabled && this._texture && ic.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([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isEnabled", void 0), X([xe()], t.prototype, "intensity", void 0), X([Pe()], t.prototype, "direction", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "texture", void 0), X([xe(), Se("_markAllSubMeshesAsMiscDirty")], t.prototype, "legacy", void 0), t }(hc), P_ = 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 }(Mi), I_ = function (e) { function t(t, i) { void 0 === i && (i = !0); var r = e.call(this, t, "Sheen", 120, new P_, 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 && ic.SheenTextureEnabled && !this._texture.isReadyOrNotBlocking()) return !1; if (this._textureRoughness && ic.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 && ic.SheenTextureEnabled ? (zn.PrepareDefinesForMergedUV(this._texture, e, "SHEEN_TEXTURE"), e.SHEEN_GAMMATEXTURE = this._texture.gammaSpace) : e.SHEEN_TEXTURE = !1, this._textureRoughness && ic.SheenTextureEnabled ? zn.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 && ic.SheenTextureEnabled ? (e.updateFloat4("vSheenInfos", this._texture.coordinatesIndex, this._texture.level, -1, -1), zn.BindTextureMatrix(this._texture, e, "sheen")) : (this._texture || this._textureRoughness) && ic.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 && zn.BindTextureMatrix(this._texture, e, "sheen"), !this._textureRoughness || f || d.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE || zn.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 && ic.SheenTextureEnabled && e.setTexture("sheenSampler", this._texture), this._textureRoughness && !f && !d.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE && ic.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([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isEnabled", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "linkSheenWithAlbedo", void 0), X([xe()], t.prototype, "intensity", void 0), X([Re()], t.prototype, "color", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "texture", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRoughnessFromMainTexture", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "roughness", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "textureRoughness", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "albedoScaling", void 0), t }(hc), M_ = 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 }(Mi), O_ = function (e) { function t(t, i) { void 0 === i && (i = !0); var r = e.call(this, t, "PBRSubSurface", 130, new M_, 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 && ic.ThicknessTextureEnabled && !this._thicknessTexture.isReadyOrNotBlocking()) return !1; var i = this._getRefractionTexture(t); if (i && ic.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 && ic.ThicknessTextureEnabled && zn.PrepareDefinesForMergedUV(this._thicknessTexture, e, "SS_THICKNESSANDMASK_TEXTURE"), this._refractionIntensityTexture && ic.RefractionIntensityTextureEnabled && !n && zn.PrepareDefinesForMergedUV(this._refractionIntensityTexture, e, "SS_REFRACTIONINTENSITY_TEXTURE"), this._translucencyIntensityTexture && ic.TranslucencyIntensityTextureEnabled && !n && zn.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 && ic.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 && ic.ThicknessTextureEnabled && (e.updateFloat2("vThicknessInfos", this._thicknessTexture.coordinatesIndex, this._thicknessTexture.level), zn.BindTextureMatrix(this._thicknessTexture, e, "thickness")), this._refractionIntensityTexture && ic.RefractionIntensityTextureEnabled && n.SS_REFRACTIONINTENSITY_TEXTURE && (e.updateFloat2("vRefractionIntensityInfos", this._refractionIntensityTexture.coordinatesIndex, this._refractionIntensityTexture.level), zn.BindTextureMatrix(this._refractionIntensityTexture, e, "refractionIntensity")), this._translucencyIntensityTexture && ic.TranslucencyIntensityTextureEnabled && n.SS_TRANSLUCENCYINTENSITY_TEXTURE && (e.updateFloat2("vTranslucencyIntensityInfos", this._translucencyIntensityTexture.coordinatesIndex, this._translucencyIntensityTexture.level), zn.BindTextureMatrix(this._translucencyIntensityTexture, e, "translucencyIntensity")), l && ic.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 && ic.ThicknessTextureEnabled && e.setTexture("thicknessSampler", this._thicknessTexture), this._refractionIntensityTexture && ic.RefractionIntensityTextureEnabled && n.SS_REFRACTIONINTENSITY_TEXTURE && e.setTexture("refractionIntensitySampler", this._refractionIntensityTexture), this._translucencyIntensityTexture && ic.TranslucencyIntensityTextureEnabled && n.SS_TRANSLUCENCYINTENSITY_TEXTURE && e.setTexture("translucencyIntensitySampler", this._translucencyIntensityTexture), l && ic.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) { ic.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 !!(ic.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([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isRefractionEnabled", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isTranslucencyEnabled", void 0), X([xe(), Se("_markScenePrePassDirty")], t.prototype, "isScatteringEnabled", void 0), X([xe()], t.prototype, "_scatteringDiffusionProfileIndex", void 0), X([xe()], t.prototype, "refractionIntensity", void 0), X([xe()], t.prototype, "translucencyIntensity", void 0), X([xe()], t.prototype, "useAlbedoToTintRefraction", void 0), X([xe()], t.prototype, "useAlbedoToTintTranslucency", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "thicknessTexture", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "refractionTexture", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "indexOfRefraction", void 0), X([xe()], t.prototype, "_volumeIndexOfRefraction", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "volumeIndexOfRefraction", null), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertRefractionY", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "linkRefractionWithTransparency", void 0), X([xe()], t.prototype, "minimumThickness", void 0), X([xe()], t.prototype, "maximumThickness", void 0), X([xe()], t.prototype, "useThicknessAsDepth", void 0), X([Re()], t.prototype, "tintColor", void 0), X([xe()], t.prototype, "tintColorAtDistance", void 0), X([Re()], t.prototype, "diffusionDistance", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useMaskFromThicknessTexture", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "refractionIntensityTexture", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "translucencyIntensityTexture", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useGltfStyleTextures", void 0), t }(hc), D_ = { effect: null, subMesh: null }, N_ = 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.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_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 }(Mi), F_ = 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 Ci(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 T_(n), n.clearCoat = new S_(n), n.iridescence = new A_(n), n.anisotropy = new C_(n), n.sheen = new I_(n), n.subSurface = new O_(n), n.detailMap = new pc(n), n._attachImageProcessingConfiguration(null), n.getRenderTargetTextures = function () { return n._renderTargets.reset(), ic.ReflectionTextureEnabled && n._reflectionTexture && n._reflectionTexture.isRenderTarget && n._renderTargets.push(n._reflectionTexture), n._eventInfo.renderTargets = n._renderTargets, n._callbackPluginEventFillRenderTargetTextures(n._eventInfo), n._renderTargets }, n._environmentBRDFTexture = v_(n.getScene()), n.prePassConfiguration = new tc, 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 !!(ic.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(Gn.GetDefineNames, this._eventInfo), t.materialDefines = new N_(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 && ic.DiffuseTextureEnabled && !this._albedoTexture.isReadyOrNotBlocking()) return !1; if (this._ambientTexture && ic.AmbientTextureEnabled && !this._ambientTexture.isReadyOrNotBlocking()) return !1; if (this._opacityTexture && ic.OpacityTextureEnabled && !this._opacityTexture.isReadyOrNotBlocking()) return !1; var s = this._getReflectionTexture(); if (s && ic.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 && ic.LightmapTextureEnabled && !this._lightmapTexture.isReadyOrNotBlocking()) return !1; if (this._emissiveTexture && ic.EmissiveTextureEnabled && !this._emissiveTexture.isReadyOrNotBlocking()) return !1; if (ic.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 && ic.BumpTextureEnabled && !this._disableBumpMap && !this._bumpTexture.isReady()) return !1; if (this._environmentBRDFTexture && ic.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(Hi.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 && (D_.effect = u, D_.subMesh = t, this._onEffectCreatedObservable.notifyObservers(D_)), 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 Ra, 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.PARALLAXOCCLUSION && c.addFallback(u++, "PARALLAXOCCLUSION"), t.ENVIRONMENTBRDF && c.addFallback(u++, "ENVIRONMENTBRDF"), t.TANGENT && c.addFallback(u++, "TANGENT"), t.BUMP && c.addFallback(u++, "BUMP"), u = zn.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 = [Hi.PositionKind]; t.NORMAL && h.push(Hi.NormalKind), t.TANGENT && h.push(Hi.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(Hi.ColorKind), t.INSTANCESCOLOR && h.push(Hi.ColorInstanceKind), zn.PrepareAttributesForBones(h, e, t, c), zn.PrepareAttributesForInstances(h, t), zn.PrepareAttributesForMorphTargets(h, e, t), zn.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(Gn.PrepareEffect, this._eventInfo), tc.AddUniforms(f), tc.AddSamplers(_), wn(f), Ni && (Ni.PrepareUniforms(f, t), Ni.PrepareSamplers(_, t)), zn.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(); zn.PrepareDefinesForLights(l, e, i, !0, this._maxSimultaneousLights, this._disableLighting), i._needNormals = !0, zn.PrepareDefinesForMultiview(l, i); var u = this.needAlphaBlendingForMesh(e) && this.getScene().useOrderIndependentTransparency; if (zn.PrepareDefinesForPrePass(l, i, this.canRenderToMRT && !u), zn.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 && ic.DiffuseTextureEnabled ? (zn.PrepareDefinesForMergedUV(this._albedoTexture, i, "ALBEDO"), i.GAMMAALBEDO = this._albedoTexture.gammaSpace) : i.ALBEDO = !1, this._ambientTexture && ic.AmbientTextureEnabled ? (zn.PrepareDefinesForMergedUV(this._ambientTexture, i, "AMBIENT"), i.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale) : i.AMBIENT = !1, this._opacityTexture && ic.OpacityTextureEnabled ? (zn.PrepareDefinesForMergedUV(this._opacityTexture, i, "OPACITY"), i.OPACITYRGB = this._opacityTexture.getAlphaFromRGB) : i.OPACITY = !1; var d = this._getReflectionTexture(); if (d && ic.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 === vo.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 vo.EXPLICIT_MODE: i.REFLECTIONMAP_EXPLICIT = !0; break; case vo.PLANAR_MODE: i.REFLECTIONMAP_PLANAR = !0; break; case vo.PROJECTION_MODE: i.REFLECTIONMAP_PROJECTION = !0; break; case vo.SKYBOX_MODE: i.REFLECTIONMAP_SKYBOX = !0; break; case vo.SPHERICAL_MODE: i.REFLECTIONMAP_SPHERICAL = !0; break; case vo.EQUIRECTANGULAR_MODE: i.REFLECTIONMAP_EQUIRECTANGULAR = !0; break; case vo.FIXED_EQUIRECTANGULAR_MODE: i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !0; break; case vo.FIXED_EQUIRECTANGULAR_MIRRORED_MODE: i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !0; break; case vo.CUBIC_MODE: case vo.INVCUBIC_MODE: default: i.REFLECTIONMAP_CUBIC = !0, i.USE_LOCAL_REFLECTIONMAP_CUBIC = !!d.boundingBoxSize }d.coordinatesMode !== vo.SKYBOX_MODE && (d.irradianceTexture ? (i.USEIRRADIANCEMAP = !0, i.USESPHERICALFROMREFLECTIONMAP = !1) : d.isCube && (i.USESPHERICALFROMREFLECTIONMAP = !0, i.USEIRRADIANCEMAP = !1, this._forceIrradianceInFragment || this.realTimeFiltering || 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 && ic.LightmapTextureEnabled ? (zn.PrepareDefinesForMergedUV(this._lightmapTexture, i, "LIGHTMAP"), i.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap, i.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace, i.RGBDLIGHTMAP = this._lightmapTexture.isRGBD) : i.LIGHTMAP = !1, this._emissiveTexture && ic.EmissiveTextureEnabled ? (zn.PrepareDefinesForMergedUV(this._emissiveTexture, i, "EMISSIVE"), i.GAMMAEMISSIVE = this._emissiveTexture.gammaSpace) : i.EMISSIVE = !1, ic.SpecularTextureEnabled) { if (this._metallicTexture ? (zn.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 ? (zn.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 ? (zn.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) ? (zn.PrepareDefinesForMergedUV(this._reflectanceTexture, i, "REFLECTANCE"), i.REFLECTANCE_GAMMA = this._reflectanceTexture.gammaSpace) : i.REFLECTANCE = !1 } else i.METALLIC_REFLECTANCE = !1, i.REFLECTANCE = !1; this._microSurfaceTexture ? zn.PrepareDefinesForMergedUV(this._microSurfaceTexture, i, "MICROSURFACEMAP") : i.MICROSURFACEMAP = !1 } else i.REFLECTIVITY = !1, i.MICROSURFACEMAP = !1; c.getCaps().standardDerivatives && this._bumpTexture && ic.BumpTextureEnabled && !this._disableBumpMap ? (zn.PrepareDefinesForMergedUV(this._bumpTexture, i, "BUMP"), this._useParallax && this._albedoTexture && ic.DiffuseTextureEnabled ? (i.PARALLAX = !0, i.PARALLAXOCCLUSION = !!this._useParallaxOcclusion) : i.PARALLAX = !1, i.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap) : (i.BUMP = !1, i.PARALLAX = !1, i.PARALLAXOCCLUSION = !1, i.OBJECTSPACE_NORMALMAP = !1), this._environmentBRDFTexture && ic.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 && (zn.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(Hi.NormalKind), i.DEBUGMODE = this._debugMode), zn.PrepareDefinesForFrameBoundValues(l, c, this, i, !!r, n, o), this._eventInfo.defines = i, this._eventInfo.mesh = e, this._callbackPluginEventPrepareDefinesBeforeAttributes(this._eventInfo), zn.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(Gn.GetDefineNames, this._eventInfo); var o = new N_(this._eventInfo.defineNames), a = this._prepareEffect(e, o, void 0, void 0, n.useInstances, n.clipPlane, e.hasThinInstances); this._onEffectCreatedObservable && (D_.effect = a, D_.subMesh = null, this._onEffectCreatedObservable.notifyObservers(D_)), 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); zn.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 && ic.DiffuseTextureEnabled && (f.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level), zn.BindTextureMatrix(this._albedoTexture, f, "albedo")), this._ambientTexture && ic.AmbientTextureEnabled && (f.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights), zn.BindTextureMatrix(this._ambientTexture, f, "ambient")), this._opacityTexture && ic.OpacityTextureEnabled && (f.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level), zn.BindTextureMatrix(this._opacityTexture, f, "opacity")), p && ic.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 && ic.EmissiveTextureEnabled && (f.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level), zn.BindTextureMatrix(this._emissiveTexture, f, "emissive")), this._lightmapTexture && ic.LightmapTextureEnabled && (f.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level), zn.BindTextureMatrix(this._lightmapTexture, f, "lightmap")), ic.SpecularTextureEnabled && (this._metallicTexture ? (f.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength), zn.BindTextureMatrix(this._metallicTexture, f, "reflectivity")) : this._reflectivityTexture && (f.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1), zn.BindTextureMatrix(this._reflectivityTexture, f, "reflectivity")), this._metallicReflectanceTexture && (f.updateFloat2("vMetallicReflectanceInfos", this._metallicReflectanceTexture.coordinatesIndex, this._metallicReflectanceTexture.level), zn.BindTextureMatrix(this._metallicReflectanceTexture, f, "metallicReflectance")), this._reflectanceTexture && l.REFLECTANCE && (f.updateFloat2("vReflectanceInfos", this._reflectanceTexture.coordinatesIndex, this._reflectanceTexture.level), zn.BindTextureMatrix(this._reflectanceTexture, f, "reflectance")), this._microSurfaceTexture && (f.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level), zn.BindTextureMatrix(this._microSurfaceTexture, f, "microSurfaceSampler"))), this._bumpTexture && u.getCaps().standardDerivatives && ic.BumpTextureEnabled && !this._disableBumpMap && (f.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias), zn.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", ic.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 && ic.DiffuseTextureEnabled && f.setTexture("albedoSampler", this._albedoTexture), this._ambientTexture && ic.AmbientTextureEnabled && f.setTexture("ambientSampler", this._ambientTexture), this._opacityTexture && ic.OpacityTextureEnabled && f.setTexture("opacitySampler", this._opacityTexture), p && ic.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 && ic.EmissiveTextureEnabled && f.setTexture("emissiveSampler", this._emissiveTexture), this._lightmapTexture && ic.LightmapTextureEnabled && f.setTexture("lightmapSampler", this._lightmapTexture), ic.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 && ic.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), Vn(this._activeEffect, this, s), this.bindEyePosition(c) } else s.getEngine()._features.needToAlwaysBindUniformBuffers && (this._needToBindSceneUbo = !0); !d && this.isFrozen || (s.lightsEnabled && !this._disableLighting && zn.BindLights(s, t, this._activeEffect, l, this._maxSimultaneousLights), (s.fogEnabled && t.applyFog && s.fogMode !== Sr.FOGMODE_NONE || p || t.receiveShadows || l.PREPASS) && this.bindView(c), zn.BindFogParameters(s, t, this._activeEffect, !0), l.NUM_MORPH_INFLUENCERS && zn.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), zn.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 = Hn.MATERIAL_OPAQUE, t.PBRMATERIAL_ALPHATEST = Hn.MATERIAL_ALPHATEST, t.PBRMATERIAL_ALPHABLEND = Hn.MATERIAL_ALPHABLEND, t.PBRMATERIAL_ALPHATESTANDBLEND = Hn.MATERIAL_ALPHATESTANDBLEND, t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 0, t.LIGHTFALLOFF_PHYSICAL = 0, t.LIGHTFALLOFF_GLTF = 1, t.LIGHTFALLOFF_STANDARD = 2, X([Ne()], t.prototype, "_imageProcessingConfiguration", void 0), X([Se("_markAllSubMeshesAsMiscDirty")], t.prototype, "debugMode", void 0), X([xe()], t.prototype, "useLogarithmicDepth", null), t }(ta), L_ = 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 = v_(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 === F_.LIGHTFALLOFF_PHYSICAL }, set: function (e) { e !== this.usePhysicalLightFalloff && (this._markAllSubMeshesAsTexturesDirty(), this._lightFalloff = e ? F_.LIGHTFALLOFF_PHYSICAL : F_.LIGHTFALLOFF_STANDARD) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "useGLTFLightFalloff", { get: function () { return this._lightFalloff === F_.LIGHTFALLOFF_GLTF }, set: function (e) { e !== this.useGLTFLightFalloff && (this._markAllSubMeshesAsTexturesDirty(), this._lightFalloff = e ? F_.LIGHTFALLOFF_GLTF : F_.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 = Ue.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 = Ue.Parse((function () { return new t(e.name, i) }), e, i, r); return e.stencil && n.stencil.parse(e.stencil, i, r), Hn._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 = F_.PBRMATERIAL_OPAQUE, t.PBRMATERIAL_ALPHATEST = F_.PBRMATERIAL_ALPHATEST, t.PBRMATERIAL_ALPHABLEND = F_.PBRMATERIAL_ALPHABLEND, t.PBRMATERIAL_ALPHATESTANDBLEND = F_.PBRMATERIAL_ALPHATESTANDBLEND, t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = F_.DEFAULT_AO_ON_ANALYTICAL_LIGHTS, X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "directIntensity", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveIntensity", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "environmentIntensity", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "specularIntensity", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "disableBumpMap", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "albedoTexture", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientTexture", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientTextureStrength", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientTextureImpactOnAnalyticalLights", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "opacityTexture", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionTexture", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveTexture", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectivityTexture", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallicTexture", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallic", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "roughness", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallicF0Factor", void 0), X([Re(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallicReflectanceColor", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useOnlyMetallicFromMetallicReflectanceTexture", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallicReflectanceTexture", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectanceTexture", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "microSurfaceTexture", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "bumpTexture", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty", null)], t.prototype, "lightmapTexture", void 0), X([Re("ambient"), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientColor", void 0), X([Re("albedo"), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "albedoColor", void 0), X([Re("reflectivity"), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectivityColor", void 0), X([Re("reflection"), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionColor", void 0), X([Re("emissive"), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveColor", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "microSurface", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useLightmapAsShadowmap", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "useAlphaFromAlbedoTexture", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "forceAlphaTest", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "alphaCutOff", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useSpecularOverAlpha", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useMicroSurfaceFromReflectivityMapAlpha", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRoughnessFromMetallicTextureAlpha", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRoughnessFromMetallicTextureGreen", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useMetallnessFromMetallicTextureBlue", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useAmbientOcclusionFromMetallicTextureRed", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useAmbientInGrayScale", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useAutoMicroSurfaceFromReflectivityMap", void 0), X([xe()], t.prototype, "usePhysicalLightFalloff", null), X([xe()], t.prototype, "useGLTFLightFalloff", null), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRadianceOverAlpha", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useObjectSpaceNormalMap", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useParallax", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useParallaxOcclusion", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "parallaxScaleBias", void 0), X([xe(), Se("_markAllSubMeshesAsLightsDirty")], t.prototype, "disableLighting", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "forceIrradianceInFragment", void 0), X([xe(), Se("_markAllSubMeshesAsLightsDirty")], t.prototype, "maxSimultaneousLights", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapX", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapY", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "twoSidedLighting", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useAlphaFresnel", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useLinearAlphaFresnel", void 0), X([Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "environmentBRDFTexture", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "forceNormalForward", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "enableSpecularAntiAliasing", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useHorizonOcclusion", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRadianceOcclusion", void 0), X([xe(), Se("_markAllSubMeshesAsMiscDirty")], t.prototype, "unlit", void 0), X([xe(), Se("_markAllSubMeshesAsMiscDirty")], t.prototype, "applyDecalMapAfterDetailMap", void 0), t }(F_); b("BABYLON.PBRMaterial", L_); var w_ = 131072, B_ = 131072; function U_(e) { return e.charCodeAt(0) + (e.charCodeAt(1) << 8) + (e.charCodeAt(2) << 16) + (e.charCodeAt(3) << 24) } var V_ = U_("DXT1"), k_ = U_("DXT3"), G_ = U_("DXT5"), z_ = U_("DX10"), W_ = 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] & w_ && (r = Math.max(1, t[7])); var n = t[21], o = n === z_ ? 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 z_: 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] & B_) === B_, isCube: 512 == (512 & t[28]), isCompressed: n === V_ || n === k_ || n === G_, 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 < i; u++)for (var h = 0; h < t; h++) { var d = 4 * (h + u * t); s[c] = ld(l[d]), s[c + 1] = ld(l[d + 1]), s[c + 2] = ld(l[d + 2]), e.StoreLODInAlphaChannel ? s[c + 3] = a : s[c + 3] = ld(l[d + 3]), c += 4 } return s }, e._GetHalfFloatRGBAArrayBuffer = function (t, i, r, n, o, a) { if (e.StoreLODInAlphaChannel) { for (var s = new Uint16Array(n), l = new Uint16Array(o, r), c = 0, u = 0; u < i; u++)for (var h = 0; h < t; h++) { var d = 4 * (h + u * t); s[c] = l[d], s[c + 1] = l[d + 1], s[c + 2] = l[d + 2], s[c + 3] = sd(a), c += 4 } return s } return new Uint16Array(o, r, n) }, e._GetFloatRGBAArrayBuffer = function (t, i, r, n, o, a) { if (e.StoreLODInAlphaChannel) { for (var s = new Float32Array(n), l = new Float32Array(o, r), c = 0, u = 0; u < i; u++)for (var h = 0; h < t; h++) { var d = 4 * (h + u * t); s[c] = l[d], s[c + 1] = l[d + 1], s[c + 2] = l[d + 2], s[c + 3] = a, c += 4 } return s } return new Float32Array(o, r, n) }, e._GetFloatAsHalfFloatRGBAArrayBuffer = function (t, i, r, n, o, a) { for (var s = new Uint16Array(n), l = new Float32Array(o, r), c = 0, u = 0; u < i; u++)for (var h = 0; h < t; h++)s[c] = sd(l[c]), s[c + 1] = sd(l[c + 1]), s[c + 2] = sd(l[c + 2]), e.StoreLODInAlphaChannel ? s[c + 3] = sd(a) : s[c + 3] = sd(l[c + 3]), c += 4; return s }, e._GetFloatAsUIntRGBAArrayBuffer = function (t, i, r, n, o, a) { for (var s = new Uint8Array(n), l = new Float32Array(o, r), c = 0, u = 0; u < i; u++)for (var d = 0; d < t; d++) { var p = 4 * (d + u * t); s[c] = 255 * h.Clamp(l[p]), s[c + 1] = 255 * h.Clamp(l[p + 1]), s[c + 2] = 255 * h.Clamp(l[p + 2]), e.StoreLODInAlphaChannel ? s[c + 3] = a : s[c + 3] = 255 * h.Clamp(l[p + 3]), c += 4 } return s }, e._GetHalfFloatAsUIntRGBAArrayBuffer = function (t, i, r, n, o, a) { for (var s = new Uint8Array(n), l = new Uint16Array(o, r), c = 0, u = 0; u < i; u++)for (var d = 0; d < t; d++) { var p = 4 * (d + u * t); s[c] = 255 * h.Clamp(ld(l[p])), s[c + 1] = 255 * h.Clamp(ld(l[p + 1])), s[c + 2] = 255 * h.Clamp(ld(l[p + 2])), e.StoreLODInAlphaChannel ? s[c + 3] = a : s[c + 3] = 255 * h.Clamp(ld(l[p + 3])), c += 4 } return s }, e._GetRGBAArrayBuffer = function (e, t, i, r, n, o, a, s, l) { for (var c = new Uint8Array(r), u = new Uint8Array(n, i), h = 0, d = 0; d < t; d++)for (var p = 0; p < e; p++) { var f = 4 * (p + d * e); c[h] = u[f + o], c[h + 1] = u[f + a], c[h + 2] = u[f + s], c[h + 3] = u[f + l], h += 4 } return c }, e._ExtractLongWordOrder = function (t) { return 0 === t || 255 === t || -16777216 === t ? 0 : 1 + e._ExtractLongWordOrder(t >> 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 < t; h++)for (var d = 0; d < e; d++) { var p = 3 * (d + h * e); l[u] = c[p + o], l[u + 1] = c[p + a], l[u + 2] = c[p + s], u += 3 } return l }, e._GetLuminanceArrayBuffer = function (e, t, i, r, n) { for (var o = new Uint8Array(r), a = new Uint8Array(n, i), s = 0, l = 0; l < t; l++)for (var c = 0; c < e; c++) { var u = c + l * e; o[s] = a[u], s++ } return o }, e.UploadDDSLevels = function (t, i, r, n, o, s, l, c, u) { void 0 === l && (l = -1), void 0 === u && (u = !0); var h = null; n.sphericalPolynomial && (h = new Array); var d = !!t.getCaps().s3tc; i.generateMipMaps = o; var p, f, _, m, g, v, y, b = new Int32Array(r.buffer, r.byteOffset, 31), T = 0, E = 0, S = 1; if (542327876 === b[0]) if (n.isFourCC || n.isRGB || n.isLuminance) if (!n.isCompressed || d) { var x = b[22]; m = b[1] + 4; var A, R = !1; if (n.isFourCC) switch (p = b[21]) { case V_: S = 8, E = a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1; break; case k_: S = 16, E = a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3; break; case G_: S = 16, E = a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5; break; case 113: R = !0, x = 64; break; case 116: R = !0, x = 128; break; case z_: m += 20; var C = !1; switch (n.dxgiFormat) { case 10: R = !0, x = 64, C = !0; break; case 2: R = !0, x = 128, C = !0; break; case 88: n.isRGB = !0, n.isFourCC = !1, x = 32, C = !0 }if (C) break; default: return void console.error("Unsupported FourCC code:", (A = p, String.fromCharCode(255 & A, A >> 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] & w_ && !1 !== o && (v = Math.max(1, b[7])); for (var D = c || 0, N = t.getCaps(), F = D; F < s; F++) { for (f = b[4], _ = b[3], y = 0; y < v; ++y) { if (-1 === l || l === y) { var L = -1 === l ? y : 0; if (!n.isCompressed && n.isFourCC) { i.format = a.TEXTUREFORMAT_RGBA, T = f * _ * 4; var w = null; if (t._badOS || t._badDesktopOS || !N.textureHalfFloat && !N.textureFloat) 128 === x ? (w = e._GetFloatAsUIntRGBAArrayBuffer(f, _, r.byteOffset + m, T, r.buffer, L), h && 0 == L && h.push(e._GetFloatRGBAArrayBuffer(f, _, r.byteOffset + m, T, r.buffer, L))) : 64 === x && (w = e._GetHalfFloatAsUIntRGBAArrayBuffer(f, _, r.byteOffset + m, T, r.buffer, L), h && 0 == L && h.push(e._GetHalfFloatAsFloatRGBAArrayBuffer(f, _, r.byteOffset + m, T, r.buffer, L))), i.type = a.TEXTURETYPE_UNSIGNED_INT; else { var B = N.textureFloat && (u && N.textureFloatLinearFiltering || !u), U = N.textureHalfFloat && (u && N.textureHalfFloatLinearFiltering || !u), V = (128 === x || 64 === x && !U) && B ? a.TEXTURETYPE_FLOAT : (64 === x || 128 === x && !B) && U ? a.TEXTURETYPE_HALF_FLOAT : a.TEXTURETYPE_UNSIGNED_BYTE, k = void 0, G = null; if (128 === x) switch (V) { case a.TEXTURETYPE_FLOAT: k = e._GetFloatRGBAArrayBuffer, G = null; break; case a.TEXTURETYPE_HALF_FLOAT: k = e._GetFloatAsHalfFloatRGBAArrayBuffer, G = e._GetFloatRGBAArrayBuffer; break; case a.TEXTURETYPE_UNSIGNED_BYTE: k = e._GetFloatAsUIntRGBAArrayBuffer, G = e._GetFloatRGBAArrayBuffer } else switch (V) { case a.TEXTURETYPE_FLOAT: k = e._GetHalfFloatAsFloatRGBAArrayBuffer, G = null; break; case a.TEXTURETYPE_HALF_FLOAT: k = e._GetHalfFloatRGBAArrayBuffer, G = e._GetHalfFloatAsFloatRGBAArrayBuffer; break; case a.TEXTURETYPE_UNSIGNED_BYTE: k = e._GetHalfFloatAsUIntRGBAArrayBuffer, G = e._GetHalfFloatAsFloatRGBAArrayBuffer }i.type = V, w = k(f, _, r.byteOffset + m, T, r.buffer, L), h && 0 == L && h.push(G ? G(f, _, r.byteOffset + m, T, r.buffer, L) : w) } w && t._uploadDataToTextureDirectly(i, w, F, L) } else if (n.isRGB) i.type = a.TEXTURETYPE_UNSIGNED_INT, 24 === x ? (i.format = a.TEXTUREFORMAT_RGB, T = f * _ * 3, g = e._GetRGBArrayBuffer(f, _, r.byteOffset + m, T, r.buffer, P, I, M), t._uploadDataToTextureDirectly(i, g, F, L)) : (i.format = a.TEXTUREFORMAT_RGBA, T = f * _ * 4, g = e._GetRGBAArrayBuffer(f, _, r.byteOffset + m, T, r.buffer, P, I, M, O), t._uploadDataToTextureDirectly(i, g, F, L)); else if (n.isLuminance) { var z = t._getUnpackAlignement(), W = f; T = Math.floor((f + z - 1) / z) * z * (_ - 1) + W, g = e._GetLuminanceArrayBuffer(f, _, r.byteOffset + m, T, r.buffer), i.format = a.TEXTUREFORMAT_LUMINANCE, i.type = a.TEXTURETYPE_UNSIGNED_INT, t._uploadDataToTextureDirectly(i, g, F, L) } else T = Math.max(4, f) / 4 * Math.max(4, _) / 4 * S, g = new Uint8Array(r.buffer, r.byteOffset + m, T), i.type = a.TEXTURETYPE_UNSIGNED_INT, t._uploadCompressedDataToTextureDirectly(i, E, f, _, g, F, L) } m += x ? f * _ * (x / 8) : T, f *= .5, _ *= .5, f = Math.max(1, f), _ = Math.max(1, _) } if (void 0 !== c) break } h && h.length > 0 ? n.sphericalPolynomial = dd.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 }(); ti.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 nd, o._source = It.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 Ht(u, It.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), W_.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 po(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 H_ = 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; l < e.length; l++) { var c = e[l]; n = W_.GetDDSInfo(c), t.width = n.width, t.height = n.height, a = (n.isRGB || n.isLuminance || n.mipmapCount > 1) && t.generateMipMaps, o._unpackFlipY(n.isCompressed), W_.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 = W_.GetDDSInfo(c), t.width = n.width, t.height = n.height, i && (n.sphericalPolynomial = new nd), a = (n.isRGB || n.isLuminance || n.mipmapCount > 1) && t.generateMipMaps, o._unpackFlipY(n.isCompressed), W_.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 = W_.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 () { W_.UploadDDSLevels(t.getEngine(), t, e, r, n, 1) })) }, e }(); In._TextureLoaders.push(new H_); var X_ = 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 = md(e); if (o) { t.width = o.width, t.height = o.width; try { xd(t, o), Td(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 }(); In._TextureLoaders.push(new X_); var j_, Y_, K_, Q_ = 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 < a; s++) { var l = new Int32Array(this.data.buffer, this.data.byteOffset + r, 1)[0]; r += 4; for (var c = 0; c < this.numberOfFaces; c++) { var u = new Uint8Array(this.data.buffer, this.data.byteOffset + r, l); t.getEngine()._uploadCompressedDataToTextureDirectly(t, t.format, n, o, u, c, s), r += l, r += 3 - (l + 3) % 4 } n = Math.max(1, .5 * n), o = Math.max(1, .5 * o) } }, e.IsValid = function (e) { if (e.byteLength >= 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 }(), q_ = 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; e < t.length; e++)t[e].workerPromise.then((function (e) { e.terminate() })); this._workerInfos.length = 0, this._pendingActions.length = 0 }, e.prototype.push = function (e) { this._executeOnIdleWorker(e) || this._pendingActions.push(e) }, e.prototype._executeOnIdleWorker = function (e) { for (var t = 0, i = this._workerInfos; t < i.length; t++) { var r = i[t]; if (r.idle) return this._execute(r, e), !0 } return !1 }, e.prototype._execute = function (e, t) { var i = this; e.idle = !1, e.workerPromise.then((function (r) { t(r, (function () { var t = i._pendingActions.shift(); t ? i._execute(e, t) : e.idle = !0 })) })) }, e }(), Z_ = function (e) { function t(i, r, n) { void 0 === n && (n = t.DefaultOptions); var o = e.call(this, []) || this; return o._maxWorkers = i, o._createWorkerAsync = r, o._options = n, o } return W(t, e), t.prototype.push = function (e) { if (!this._executeOnIdleWorker(e)) if (this._workerInfos.length < this._maxWorkers) { var t = { workerPromise: this._createWorkerAsync(), idle: !1 }; this._workerInfos.push(t), this._execute(t, e) } else this._pendingActions.push(e) }, t.prototype._execute = function (t, i) { var r = this; t.timeoutId && (clearTimeout(t.timeoutId), delete t.timeoutId), e.prototype._execute.call(this, t, (function (e, n) { i(e, (function () { n(), t.idle && (t.timeoutId = setTimeout((function () { t.workerPromise.then((function (e) { e.terminate() })); var e = r._workerInfos.indexOf(t); -1 !== e && r._workerInfos.splice(e, 1) }), r._options.idleTimeElapsedBeforeRelease)) })) })) }, t.DefaultOptions = { idleTimeElapsedBeforeRelease: 1e3 }, t }(q_); function J_(e) { return e ? xi.GetAbsoluteUrl(e) : null } function $_(e) { null !== e.wasmUASTCToASTC && (KTX2DECODER.LiteTranscoder_UASTC_ASTC.WasmModuleURL = e.wasmUASTCToASTC), null !== e.wasmUASTCToBC7 && (KTX2DECODER.LiteTranscoder_UASTC_BC7.WasmModuleURL = e.wasmUASTCToBC7), null !== e.wasmUASTCToRGBA_UNORM && (KTX2DECODER.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL = e.wasmUASTCToRGBA_UNORM), null !== e.wasmUASTCToRGBA_SRGB && (KTX2DECODER.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL = e.wasmUASTCToRGBA_SRGB), null !== e.wasmUASTCToR8_UNORM && (KTX2DECODER.LiteTranscoder_UASTC_R8_UNORM.WasmModuleURL = e.wasmUASTCToR8_UNORM), null !== e.wasmUASTCToRG8_UNORM && (KTX2DECODER.LiteTranscoder_UASTC_RG8_UNORM.WasmModuleURL = e.wasmUASTCToRG8_UNORM), null !== e.jsMSCTranscoder && (KTX2DECODER.MSCTranscoder.JSModuleURL = e.jsMSCTranscoder), null !== e.wasmMSCTranscoder && (KTX2DECODER.MSCTranscoder.WasmModuleURL = e.wasmMSCTranscoder), null !== e.wasmZSTDDecoder && (KTX2DECODER.ZSTDDecoder.WasmModuleURL = e.wasmZSTDDecoder) } !function (e) { e[e.ETC1S = 0] = "ETC1S", e[e.UASTC4x4 = 1] = "UASTC4x4" }(j_ || (j_ = {})), function (e) { e[e.ASTC_4X4_RGBA = 0] = "ASTC_4X4_RGBA", e[e.BC7_RGBA = 1] = "BC7_RGBA", e[e.BC3_RGBA = 2] = "BC3_RGBA", e[e.BC1_RGB = 3] = "BC1_RGB", e[e.PVRTC1_4_RGBA = 4] = "PVRTC1_4_RGBA", e[e.PVRTC1_4_RGB = 5] = "PVRTC1_4_RGB", e[e.ETC2_RGBA = 6] = "ETC2_RGBA", e[e.ETC1_RGB = 7] = "ETC1_RGB", e[e.RGBA32 = 8] = "RGBA32", e[e.R8 = 9] = "R8", e[e.RG8 = 10] = "RG8" }(Y_ || (Y_ = {})), function (e) { e[e.COMPRESSED_RGBA_BPTC_UNORM_EXT = 36492] = "COMPRESSED_RGBA_BPTC_UNORM_EXT", e[e.COMPRESSED_RGBA_ASTC_4X4_KHR = 37808] = "COMPRESSED_RGBA_ASTC_4X4_KHR", e[e.COMPRESSED_RGB_S3TC_DXT1_EXT = 33776] = "COMPRESSED_RGB_S3TC_DXT1_EXT", e[e.COMPRESSED_RGBA_S3TC_DXT5_EXT = 33779] = "COMPRESSED_RGBA_S3TC_DXT5_EXT", e[e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 35842] = "COMPRESSED_RGBA_PVRTC_4BPPV1_IMG", e[e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 35840] = "COMPRESSED_RGB_PVRTC_4BPPV1_IMG", e[e.COMPRESSED_RGBA8_ETC2_EAC = 37496] = "COMPRESSED_RGBA8_ETC2_EAC", e[e.COMPRESSED_RGB8_ETC2 = 37492] = "COMPRESSED_RGB8_ETC2", e[e.COMPRESSED_RGB_ETC1_WEBGL = 36196] = "COMPRESSED_RGB_ETC1_WEBGL", e[e.RGBA8Format = 32856] = "RGBA8Format", e[e.R8Format = 33321] = "R8Format", e[e.RG8Format = 33323] = "RG8Format" }(K_ || (K_ = {})); var em = function () { function e() { this._isDirty = !0, this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC = !0, this._ktx2DecoderOptions = {} } return Object.defineProperty(e.prototype, "isDirty", { get: function () { return this._isDirty }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "useRGBAIfASTCBC7NotAvailableWhenUASTC", { get: function () { return this._useRGBAIfASTCBC7NotAvailableWhenUASTC }, set: function (e) { this._useRGBAIfASTCBC7NotAvailableWhenUASTC !== e && (this._useRGBAIfASTCBC7NotAvailableWhenUASTC = e, this._isDirty = !0) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "useRGBAIfOnlyBC1BC3AvailableWhenUASTC", { get: function () { return this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC }, set: function (e) { this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC !== e && (this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC = e, this._isDirty = !0) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "forceRGBA", { get: function () { return this._forceRGBA }, set: function (e) { this._forceRGBA !== e && (this._forceRGBA = e, this._isDirty = !0) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "forceR8", { get: function () { return this._forceR8 }, set: function (e) { this._forceR8 !== e && (this._forceR8 = e, this._isDirty = !0) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "forceRG8", { get: function () { return this._forceRG8 }, set: function (e) { this._forceRG8 !== e && (this._forceRG8 = e, this._isDirty = !0) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "bypassTranscoders", { get: function () { return this._bypassTranscoders }, set: function (e) { this._bypassTranscoders !== e && (this._bypassTranscoders = e, this._isDirty = !0) }, enumerable: !1, configurable: !0 }), e.prototype._getKTX2DecoderOptions = function () { if (!this._isDirty) return this._ktx2DecoderOptions; this._isDirty = !1; var e = { useRGBAIfASTCBC7NotAvailableWhenUASTC: this._useRGBAIfASTCBC7NotAvailableWhenUASTC, forceRGBA: this._forceRGBA, forceR8: this._forceR8, forceRG8: this._forceRG8, bypassTranscoders: this._bypassTranscoders }; return this.useRGBAIfOnlyBC1BC3AvailableWhenUASTC && (e.transcodeFormatDecisionTree = { UASTC: { transcodeFormat: [Y_.BC1_RGB, Y_.BC3_RGBA], yes: { transcodeFormat: Y_.RGBA32, engineFormat: K_.RGBA8Format, roundToMultiple4: !1 } } }), this._ktx2DecoderOptions = e, e }, e }(), tm = function () { function e(t, i) { void 0 === i && (i = e.DefaultNumWorkers), this._engine = t, e._Initialize(i) } return e.GetDefaultNumWorkers = function () { return "object" == typeof navigator && navigator.hardwareConcurrency ? Math.min(Math.floor(.5 * navigator.hardwareConcurrency), 4) : 1 }, e._Initialize = function (t) { if (!e._WorkerPoolPromise && !e._DecoderModulePromise) { var i = { jsDecoderModule: xi.GetAbsoluteUrl(this.URLConfig.jsDecoderModule), wasmUASTCToASTC: J_(this.URLConfig.wasmUASTCToASTC), wasmUASTCToBC7: J_(this.URLConfig.wasmUASTCToBC7), wasmUASTCToRGBA_UNORM: J_(this.URLConfig.wasmUASTCToRGBA_UNORM), wasmUASTCToRGBA_SRGB: J_(this.URLConfig.wasmUASTCToRGBA_SRGB), wasmUASTCToR8_UNORM: J_(this.URLConfig.wasmUASTCToR8_UNORM), wasmUASTCToRG8_UNORM: J_(this.URLConfig.wasmUASTCToRG8_UNORM), jsMSCTranscoder: J_(this.URLConfig.jsMSCTranscoder), wasmMSCTranscoder: J_(this.URLConfig.wasmMSCTranscoder), wasmZSTDDecoder: J_(this.URLConfig.wasmZSTDDecoder) }; t && "function" == typeof Worker && "undefined" != typeof URL ? e._WorkerPoolPromise = new Promise((function (e) { var r = "".concat($_, "(").concat(im, ")()"), n = URL.createObjectURL(new Blob([r], { type: "application/javascript" })); e(new Z_(t, (function () { return new Promise((function (e, t) { var r = new Worker(n), o = function (e) { r.removeEventListener("error", o), r.removeEventListener("message", a), t(e) }, a = function (t) { "init" === t.data.action && (r.removeEventListener("error", o), r.removeEventListener("message", a), e(r)) }; r.addEventListener("error", o), r.addEventListener("message", a), r.postMessage({ action: "init", urls: i }) })) }))) })) : "undefined" == typeof KTX2DECODER ? e._DecoderModulePromise = xi.LoadScriptAsync(i.jsDecoderModule).then((function () { return KTX2DECODER.MSCTranscoder.UseFromWorkerThread = !1, KTX2DECODER.WASMMemoryManager.LoadBinariesFromCurrentThread = !0, $_(i), new KTX2DECODER.KTX2Decoder })) : (KTX2DECODER.MSCTranscoder.UseFromWorkerThread = !1, KTX2DECODER.WASMMemoryManager.LoadBinariesFromCurrentThread = !0, e._DecoderModulePromise = Promise.resolve(new KTX2DECODER.KTX2Decoder)) } }, e.prototype.uploadAsync = function (t, i, r) { var n = this, o = this._engine.getCaps(), a = { astc: !!o.astc, bptc: !!o.bptc, s3tc: !!o.s3tc, pvrtc: !!o.pvrtc, etc2: !!o.etc2, etc1: !!o.etc1 }; if (e._WorkerPoolPromise) return e._WorkerPoolPromise.then((function (o) { return new Promise((function (s, l) { o.push((function (o, c) { var u = function (e) { o.removeEventListener("error", u), o.removeEventListener("message", h), l(e), c() }, h = function (e) { if ("decoded" === e.data.action) { if (o.removeEventListener("error", u), o.removeEventListener("message", h), e.data.success) try { n._createTexture(e.data.decodedData, i, r), s() } catch (e) { l({ message: e }) } else l({ message: e.data.msg }); c() } }; o.addEventListener("error", u), o.addEventListener("message", h), o.postMessage({ action: "setDefaultDecoderOptions", options: e.DefaultDecoderOptions._getKTX2DecoderOptions() }); var d = new Uint8Array(t.byteLength); d.set(new Uint8Array(t.buffer, t.byteOffset, t.byteLength)), o.postMessage({ action: "decode", data: d, caps: a, options: r }, [d.buffer]) })) })) })); if (e._DecoderModulePromise) return e._DecoderModulePromise.then((function (r) { return e.DefaultDecoderOptions.isDirty && (KTX2DECODER.KTX2Decoder.DefaultDecoderOptions = e.DefaultDecoderOptions._getKTX2DecoderOptions()), new Promise((function (e, a) { r.decode(t, o).then((function (t) { n._createTexture(t, i), e() })).catch((function (e) { a({ message: e }) })) })) })); throw new Error("KTX2 decoder module is not available") }, e.prototype._createTexture = function (e, t, i) { this._engine._bindTextureDirectly(3553, t), i && (i.transcodedFormat = e.transcodedFormat, i.isInGammaSpace = e.isInGammaSpace, i.hasAlpha = e.hasAlpha, i.transcoderName = e.transcoderName); var r = !0; switch (e.transcodedFormat) { case 32856: t.type = a.TEXTURETYPE_UNSIGNED_BYTE, t.format = a.TEXTUREFORMAT_RGBA; break; case 33321: t.type = a.TEXTURETYPE_UNSIGNED_BYTE, t.format = a.TEXTUREFORMAT_R; break; case 33323: t.type = a.TEXTURETYPE_UNSIGNED_BYTE, t.format = a.TEXTUREFORMAT_RG; break; default: t.format = e.transcodedFormat, r = !1 }if (t._gammaSpace = e.isInGammaSpace, t.generateMipMaps = e.mipmaps.length > 1, e.errors) throw new Error("KTX2 container - could not transcode the data. " + e.errors); for (var n = 0; n < e.mipmaps.length; ++n) { var o = e.mipmaps[n]; if (!o || !o.data) throw new Error("KTX2 container - could not transcode one of the image"); r ? (t.width = o.width, t.height = o.height, this._engine._uploadDataToTextureDirectly(t, o.data, 0, n, void 0, !0)) : this._engine._uploadCompressedDataToTextureDirectly(t, e.transcodedFormat, o.width, o.height, o.data, 0, n) } t._extension = ".ktx2", t.width = e.mipmaps[0].width, t.height = e.mipmaps[0].height, t.isReady = !0, this._engine._bindTextureDirectly(3553, null) }, e.IsValid = function (e) { if (e.byteLength >= 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://preview.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 em, e }(); function im() { var e; onmessage = function (t) { if (t.data) switch (t.data.action) { case "init": var i = t.data.urls; importScripts(i.jsDecoderModule), $_(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; i < e.mipmaps.length; ++i) { var r = e.mipmaps[i]; r && r.data && t.push(r.data.buffer) } postMessage({ action: "decoded", success: !0, decodedData: e }, t) })).catch((function (e) { postMessage({ action: "decoded", success: !1, msg: e }) })) } } } var rm = function () { function e() { this.supportCascades = !1 } return e.prototype.canLoad = function (e, t) { return e.endsWith(".ktx") || e.endsWith(".ktx2") || "image/ktx" === t || "image/ktx2" === t }, e.prototype.loadCubeData = function (e, t, i, r) { if (!Array.isArray(e)) { t._invertVScale = !t.invertY; var n = t.getEngine(), o = new Q_(e, 6), a = o.numberOfMipmapLevels > 1 && t.generateMipMaps; n._unpackFlipY(!0), o.uploadLevels(t, t.generateMipMaps), t.width = o.pixelWidth, t.height = o.pixelHeight, n._setCubeMapTextureParams(t, a, o.numberOfMipmapLevels - 1), t.isReady = !0, t.onLoadedObservable.notifyObservers(t), t.onLoadedObservable.clear(), r && r() } }, e.prototype.loadData = function (e, t, i, r) { if (Q_.IsValid(e)) { t._invertVScale = !t.invertY; var n = new Q_(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 tm.IsValid(e) ? new tm(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 }(); In._TextureLoaders.unshift(new rm); var nm = 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 = yc.NOT_TRACKING, 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 = ln.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._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 sn(0, 0, .5, 1), this.rigCameras[0].outputRenderTarget = null, this.rigCameras[1].viewport = new sn(.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 ? yc.TRACKING_LOST : yc.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(yc.NOT_TRACKING) }, t.prototype._updateNumberOfRigCameras = function (e) { for (void 0 === e && (e = 1); this.rigCameras.length < e;) { var t = new tl("XR-RigCamera: " + this.rigCameras.length, R.Zero(), this.getScene()); t.minZ = .1, t.rotationQuaternion = new P, t.updateUpVectorFromRotation = !0, t.isRigCamera = !0, t.rigParent = this, t.freezeProjectionMatrix(), this.rigCameras.push(t) } for (; this.rigCameras.length > e;) { 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 }(il), om = 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 = vc.NOT_IN_XR, this.sessionManager = new Mc(e), this.camera = new nm("webxr", e, this.sessionManager), this.featuresManager = new Wo(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(vc.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(vc.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(zo.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 !== vc.EXITING_XR && u._setState(vc.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(vc.NOT_IN_XR) })), this.sessionManager.onXRFrameObservable.addOnce((function () { u._setState(vc.IN_XR) })), [2, this.sessionManager]; case 6: throw c = h.sent(), console.log(c), console.log(c.message), this._setState(vc.NOT_IN_XR), c; case 7: return [2] } })) })) }, e.prototype.exitXRAsync = function () { return this.state !== vc.IN_XR ? Promise.resolve() : (this._setState(vc.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 === vc.IN_XR ? (t._spectatorCamera = new El("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 === vc.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 }(), am = 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 }(), sm = 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 am(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) } ea.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 Jn(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 }(), lm = function (e) { function t(i, r, n) { var o = e.call(this, i, cm[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 Jn(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 }(sm), cm = { 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" } }, um = 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 = ea.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 === am.TOUCHPAD_TYPE && i.touchPointNodeName ? i.touchPointNodeName : n.valueNodeName; if (t._buttonMeshMapping[e].states[r] = { valueMesh: t._getChildByName(t.rootMesh, o) }, i.type === am.TOUCHPAD_TYPE && !t._touchDots[r]) { var a = bu(r + "dot", { diameter: .0015, segments: 8 }, t.scene); a.material = new mc(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 Jn(this.profileId + "-" + this.handedness, this.scene), this.rootMesh.isPickable = !1; for (var i = 0; i < e.length; i++) { var r = e[i]; r.isPickable = !1, r.parent || (t = r) } t && t.setParent(this.rootMesh), this.scene.useRightHandedSystem || this.rootMesh.rotate(Ar.Y, Math.PI, Er.WORLD) }, t.prototype._updateModel = function (e) { var t = this; this.disableAnimation || this.getComponentIds().forEach((function (e) { var i = t.getComponent(e); if (i.hasChanges) { var r = t._buttonMeshMapping[e], n = t.layout.components[e]; Object.keys(n.visualResponses).forEach((function (e) { var o = n.visualResponses[e], a = i.value; if ("xAxis" === o.componentProperty ? a = i.axes.x : "yAxis" === o.componentProperty && (a = i.axes.y), "transform" === o.valueNodeProperty) t._lerpTransform(r.states[e], a, "button" !== o.componentProperty); else { var s = r.states[e].valueMesh; s && (s.isVisible = i.touched || i.pressed), t._touchDots[e] && (t._touchDots[e].isVisible = i.touched || i.pressed) } })) } })) }, t }(sm), hm = [], dm = function () { function e() { } return e.ClearProfilesCache = function () { this._ProfilesList = null, this._ProfileLoadingPromises = {} }, e.DefaultFallbacks = function () { this.RegisterFallbacksForProfileId("google-daydream", ["generic-touchpad"]), this.RegisterFallbacksForProfileId("htc-vive-focus", ["generic-trigger-touchpad"]), this.RegisterFallbacksForProfileId("htc-vive", ["generic-trigger-squeeze-touchpad"]), this.RegisterFallbacksForProfileId("magicleap-one", ["generic-trigger-squeeze-touchpad"]), this.RegisterFallbacksForProfileId("windows-mixed-reality", ["generic-trigger-squeeze-touchpad-thumbstick"]), this.RegisterFallbacksForProfileId("microsoft-mixed-reality", ["windows-mixed-reality", "generic-trigger-squeeze-touchpad-thumbstick"]), this.RegisterFallbacksForProfileId("oculus-go", ["generic-trigger-touchpad"]), this.RegisterFallbacksForProfileId("oculus-touch-v2", ["oculus-touch", "generic-trigger-squeeze-thumbstick"]), this.RegisterFallbacksForProfileId("oculus-touch", ["generic-trigger-squeeze-thumbstick"]), this.RegisterFallbacksForProfileId("samsung-gearvr", ["windows-mixed-reality", "generic-trigger-squeeze-touchpad-thumbstick"]), this.RegisterFallbacksForProfileId("samsung-odyssey", ["generic-touchpad"]), this.RegisterFallbacksForProfileId("valve-index", ["generic-trigger-squeeze-touchpad-thumbstick"]), this.RegisterFallbacksForProfileId("generic-hand-select", ["generic-trigger"]) }, e.FindFallbackWithProfileId = function (e) { var t = this._Fallbacks[e] || []; return t.unshift(e), t }, e.GetMotionControllerWithXRInput = function (e, t, i) { var r = this, n = []; i && n.push(i), n.push.apply(n, e.profiles || []), n.length && !n[0] && n.pop(), e.gamepad && e.gamepad.id && e.gamepad.id === (e.gamepad.id.match(/oculus touch/gi) ? e.gamepad.id : void 0) && n.push("oculus-touch-v2"); var o = n.indexOf("windows-mixed-reality"); if (-1 !== o && n.splice(o, 0, "microsoft-mixed-reality"), n.length || n.push("generic-trigger"), this.UseOnlineRepository) { var a = this.PrioritizeOnlineRepository ? this._LoadProfileFromRepository : this._LoadProfilesFromAvailableControllers, s = this.PrioritizeOnlineRepository ? this._LoadProfilesFromAvailableControllers : this._LoadProfileFromRepository; return a.call(this, n, e, t).catch((function () { return s.call(r, n, e, t) })) } return this._LoadProfilesFromAvailableControllers(n, e, t) }, e.RegisterController = function (e, t) { this._AvailableControllers[e] = t }, e.RegisterFallbacksForProfileId = function (e, t) { var i; this._Fallbacks[e] ? (i = this._Fallbacks[e]).push.apply(i, t) : this._Fallbacks[e] = t }, e.UpdateProfilesList = function () { return this._ProfilesList = xi.LoadFileAsync(this.BaseRepositoryUrl + "/profiles/profilesList.json", !1).then((function (e) { return JSON.parse(e.toString()) })), this._ProfilesList }, e.ClearControllerCache = function () { hm.forEach((function (e) { e.meshes.forEach((function (e) { e.dispose(!1, !0) })) })), hm.length = 0 }, e._LoadProfileFromRepository = function (e, t, i) { var r = this; return Promise.resolve().then((function () { return r._ProfilesList ? r._ProfilesList : r.UpdateProfilesList() })).then((function (t) { for (var i = 0; i < e.length; ++i)if (e[i] && t[e[i]]) return e[i]; throw new Error("neither controller ".concat(e[0], " nor all fallbacks were found in the repository,")) })).then((function (e) { return r._ProfileLoadingPromises[e] || (r._ProfileLoadingPromises[e] = xi.LoadFileAsync("".concat(r.BaseRepositoryUrl, "/profiles/").concat(e, "/profile.json"), !1).then((function (e) { return JSON.parse(e) }))), r._ProfileLoadingPromises[e] })).then((function (e) { return new um(i, t, e, r.BaseRepositoryUrl, r.DisableControllerCache ? void 0 : hm) })) }, e._LoadProfilesFromAvailableControllers = function (e, t, i) { for (var r = 0; r < e.length; ++r)if (e[r]) for (var n = this.FindFallbackWithProfileId(e[r]), o = 0; o < n.length; ++o) { var a = this._AvailableControllers[n[o]]; if (a) return Promise.resolve(a(t, i)) } throw new Error("no controller requested was found in the available controllers list") }, e._AvailableControllers = {}, e._Fallbacks = {}, e._ProfileLoadingPromises = {}, e.BaseRepositoryUrl = "https://immersive-web.github.io/webxr-input-profiles/packages/viewer/dist", e.PrioritizeOnlineRepository = !0, e.UseOnlineRepository = !0, e.DisableControllerCache = !0, e }(); dm.RegisterController(lm.ProfileId, (function (e, t) { return new lm(t, e.gamepad, e.handedness) })), dm.DefaultFallbacks(); var pm, fm, _m = 0, mm = function () { function e(e, t, i) { void 0 === i && (i = {}); var r = this; this._scene = e, this.inputSource = t, this._options = i, this._tmpVector = new R, this._disposed = !1, this.onDisposeObservable = new u, this.onMeshLoadedObservable = new u, this.onMotionControllerInitObservable = new u, this._uniqueId = "controller-".concat(_m++, "-").concat(t.targetRayMode, "-").concat(t.handedness), this.pointer = new Ln("".concat(this._uniqueId, "-pointer"), e), this.pointer.rotationQuaternion = new P, this.inputSource.gripSpace && (this.grip = new Ln("".concat(this._uniqueId, "-grip"), this._scene), this.grip.rotationQuaternion = new P), this._tmpVector.set(0, 0, this._scene.useRightHandedSystem ? -1 : 1), this.inputSource.gamepad && "tracked-pointer" === this.inputSource.targetRayMode && dm.GetMotionControllerWithXRInput(t, e, this._options.forceControllerProfile).then((function (e) { r.motionController = e, r.onMotionControllerInitObservable.notifyObservers(e), r._options.doNotLoadControllerMesh || r.motionController._doNotLoadControllerMesh || r.motionController.loadModel().then((function (e) { var t; e && r.motionController && r.motionController.rootMesh && (r._options.renderingGroupId && (r.motionController.rootMesh.renderingGroupId = r._options.renderingGroupId, r.motionController.rootMesh.getChildMeshes(!1).forEach((function (e) { return e.renderingGroupId = r._options.renderingGroupId }))), r.onMeshLoadedObservable.notifyObservers(r.motionController.rootMesh), r.motionController.rootMesh.parent = r.grip || r.pointer, r.motionController.disableAnimation = !!r._options.disableMotionControllerAnimation), r._disposed && (null === (t = r.motionController) || void 0 === t || t.dispose()) })) }), (function () { xi.Warn("Could not find a matching motion controller for the registered input source") })) } return Object.defineProperty(e.prototype, "uniqueId", { get: function () { return this._uniqueId }, enumerable: !1, configurable: !0 }), e.prototype.dispose = function () { this.grip && this.grip.dispose(!0), this.motionController && this.motionController.dispose(), this.pointer.dispose(!0), this.onMotionControllerInitObservable.clear(), this.onMeshLoadedObservable.clear(), this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear(), this._disposed = !0 }, e.prototype.getWorldPointerRayToRef = function (e, t) { void 0 === t && (t = !1); var i = t && this.grip ? this.grip : this.pointer; R.TransformNormalToRef(this._tmpVector, i.getWorldMatrix(), e.direction), e.direction.normalize(), e.origin.copyFrom(i.absolutePosition), e.length = 1e3 }, e.prototype.updateFromXRFrame = function (e, t, i) { var r = e.getPose(this.inputSource.targetRaySpace, t); if (this._lastXRPose = r, r) { var n = r.transform.position; this.pointer.position.set(n.x, n.y, n.z); var o = r.transform.orientation; this.pointer.rotationQuaternion.set(o.x, o.y, o.z, o.w), this._scene.useRightHandedSystem || (this.pointer.position.z *= -1, this.pointer.rotationQuaternion.z *= -1, this.pointer.rotationQuaternion.w *= -1), this.pointer.parent = i.parent } if (this.inputSource.gripSpace && this.grip) { var a = e.getPose(this.inputSource.gripSpace, t); if (a) { n = a.transform.position; var s = a.transform.orientation; this.grip.position.set(n.x, n.y, n.z), this.grip.rotationQuaternion.set(s.x, s.y, s.z, s.w), this._scene.useRightHandedSystem || (this.grip.position.z *= -1, this.grip.rotationQuaternion.z *= -1, this.grip.rotationQuaternion.w *= -1) } this.grip.parent = i.parent } this.motionController && this.motionController.updateFromXRFrame(e) }, e }(), gm = function () { function e(e, t, i) { void 0 === i && (i = {}); var r = this; if (this.xrSessionManager = e, this.xrCamera = t, this._options = i, this.controllers = [], this.onControllerAddedObservable = new u, this.onControllerRemovedObservable = new u, this._onInputSourcesChange = function (e) { r._addAndRemoveControllers(e.added, e.removed) }, this._sessionEndedObserver = this.xrSessionManager.onXRSessionEnded.add((function () { r._addAndRemoveControllers([], r.controllers.map((function (e) { return e.inputSource }))) })), this._sessionInitObserver = this.xrSessionManager.onXRSessionInit.add((function (e) { e.addEventListener("inputsourceschange", r._onInputSourcesChange) })), this._frameObserver = this.xrSessionManager.onXRFrameObservable.add((function (e) { r.controllers.forEach((function (t) { t.updateFromXRFrame(e, r.xrSessionManager.referenceSpace, r.xrCamera) })) })), this._options.customControllersRepositoryURL && (dm.BaseRepositoryUrl = this._options.customControllersRepositoryURL), dm.UseOnlineRepository = !this._options.disableOnlineControllerRepository, dm.UseOnlineRepository) try { dm.UpdateProfilesList().catch((function () { dm.UseOnlineRepository = !1 })) } catch (e) { dm.UseOnlineRepository = !1 } } return e.prototype._addAndRemoveControllers = function (e, t) { for (var i = this, r = this.controllers.map((function (e) { return e.inputSource })), n = 0, o = e; n < o.length; n++) { var a = o[n]; if (-1 === r.indexOf(a)) { var s = new mm(this.xrSessionManager.scene, a, H(H({}, this._options.controllerOptions || {}), { forceControllerProfile: this._options.forceInputProfile, doNotLoadControllerMesh: this._options.doNotLoadControllerMeshes, disableMotionControllerAnimation: this._options.disableControllerAnimation })); this.controllers.push(s), this.onControllerAddedObservable.notifyObservers(s) } } var l = [], c = []; this.controllers.forEach((function (e) { -1 === t.indexOf(e.inputSource) ? l.push(e) : c.push(e) })), this.controllers = l, c.forEach((function (e) { i.onControllerRemovedObservable.notifyObservers(e), e.dispose() })) }, e.prototype.dispose = function () { this.controllers.forEach((function (e) { e.dispose() })), this.xrSessionManager.onXRFrameObservable.remove(this._frameObserver), this.xrSessionManager.onXRSessionInit.remove(this._sessionInitObserver), this.xrSessionManager.onXRSessionEnded.remove(this._sessionEndedObserver), this.onControllerAddedObservable.clear(), this.onControllerRemovedObservable.clear(), dm.ClearControllerCache() }, e }(), vm = function (e) { function t(i, r) { var n = e.call(this, i) || this; return n._options = r, n._attachController = function (e) { var i; if (!n._controllers[e.uniqueId]) { var r = (i = n._generateNewMeshPair(e.pointer)).laserPointer, o = i.selectionMesh; switch (n._controllers[e.uniqueId] = { xrController: e, laserPointer: r, selectionMesh: o, meshUnderPointer: null, pick: null, tmpRay: new Mo(new R, new R), disabledByNearInteraction: !1, id: t._IdCounter++ }, n._attachedController ? !n._options.enablePointerSelectionOnAllControllers && n._options.preferredHandedness && e.inputSource.handedness === n._options.preferredHandedness && (n._attachedController = e.uniqueId) : n._options.enablePointerSelectionOnAllControllers || (n._attachedController = e.uniqueId), e.inputSource.targetRayMode) { case "tracked-pointer": return n._attachTrackedPointerRayMode(e); case "gaze": return n._attachGazeMode(e); case "screen": return n._attachScreenRayMode(e) } } }, n._controllers = {}, n._tmpVectorForPickCompare = new R, n.disablePointerLighting = !0, n.disableSelectionMeshLighting = !0, n.displayLaserPointer = !0, n.displaySelectionMesh = !0, n.laserPointerPickedColor = new B(.9, .9, .9), n.laserPointerDefaultColor = new B(.7, .7, .7), n.selectionMeshDefaultColor = new B(.8, .8, .8), n.selectionMeshPickedColor = new B(.3, .3, 1), n._identityMatrix = I.Identity(), n._screenCoordinatesRef = R.Zero(), n._viewportRef = new sn(0, 0, 0, 0), n._scene = n._xrSessionManager.scene, n } return W(t, e), t.prototype.attach = function () { var i, r = this; if (!e.prototype.attach.call(this)) return !1; if (this._options.xrInput.controllers.forEach(this._attachController), this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable, this._attachController), this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable, (function (e) { r._detachController(e.uniqueId) })), this._scene.constantlyUpdateMeshUnderPointer = !0, this._options.gazeCamera) { var n = this._options.gazeCamera, o = (i = this._generateNewMeshPair(n)).laserPointer, a = i.selectionMesh; this._controllers.camera = { webXRCamera: n, laserPointer: o, selectionMesh: a, meshUnderPointer: null, pick: null, tmpRay: new Mo(new R, new R), disabledByNearInteraction: !1, id: t._IdCounter++ }, this._attachGazeMode() } return !0 }, t.prototype.detach = function () { var t = this; return !!e.prototype.detach.call(this) && (Object.keys(this._controllers).forEach((function (e) { t._detachController(e) })), !0) }, t.prototype.getMeshUnderPointer = function (e) { return this._controllers[e] ? this._controllers[e].meshUnderPointer : null }, t.prototype.getXRControllerByPointerId = function (e) { for (var t = Object.keys(this._controllers), i = 0; i < t.length; ++i)if (this._controllers[t[i]].id === e) return this._controllers[t[i]].xrController || null; return null }, t.prototype._getPointerSelectionDisabledByPointerId = function (e) { for (var t = Object.keys(this._controllers), i = 0; i < t.length; ++i)if (this._controllers[t[i]].id === e) return this._controllers[t[i]].disabledByNearInteraction; return !0 }, t.prototype._setPointerSelectionDisabledByPointerId = function (e, t) { for (var i = Object.keys(this._controllers), r = 0; r < i.length; ++r)if (this._controllers[i[r]].id === e) return void (this._controllers[i[r]].disabledByNearInteraction = t) }, t.prototype._onXRFrame = function (e) { var t = this; Object.keys(this._controllers).forEach((function (e) { var i, r = t._controllers[e]; if (!t._options.enablePointerSelectionOnAllControllers && e !== t._attachedController || r.disabledByNearInteraction) return r.selectionMesh.isVisible = !1, r.laserPointer.isVisible = !1, void (r.pick = null); if (r.laserPointer.isVisible = t.displayLaserPointer, r.xrController) i = r.xrController.pointer.position, r.xrController.getWorldPointerRayToRef(r.tmpRay); else { if (!r.webXRCamera) return; i = r.webXRCamera.position, r.webXRCamera.getForwardRayToRef(r.tmpRay) } if (t._options.maxPointerDistance && (r.tmpRay.length = t._options.maxPointerDistance), !t._options.disableScenePointerVectorUpdate && i) { var n = t._xrSessionManager.scene, o = t._options.xrInput.xrCamera; o && (o.viewport.toGlobalToRef(n.getEngine().getRenderWidth(), n.getEngine().getRenderHeight(), t._viewportRef), R.ProjectToRef(i, t._identityMatrix, n.getTransformMatrix(), t._viewportRef, t._screenCoordinatesRef), "number" != typeof t._screenCoordinatesRef.x || "number" != typeof t._screenCoordinatesRef.y || isNaN(t._screenCoordinatesRef.x) || isNaN(t._screenCoordinatesRef.y) || (n.pointerX = t._screenCoordinatesRef.x, n.pointerY = t._screenCoordinatesRef.y, r.screenCoordinates = { x: t._screenCoordinatesRef.x, y: t._screenCoordinatesRef.y })) } var a = null; t._utilityLayerScene && (a = t._utilityLayerScene.pickWithRay(r.tmpRay, t._utilityLayerScene.pointerMovePredicate || t.raySelectionPredicate)); var s = t._scene.pickWithRay(r.tmpRay, t._scene.pointerMovePredicate || t.raySelectionPredicate); a && a.hit ? s && s.hit ? a.distance < s.distance ? r.pick = a : r.pick = s : r.pick = a : r.pick = s, r.pick && r.xrController && (r.pick.aimTransform = r.xrController.pointer, r.pick.gripTransform = r.xrController.grip || null); var l = r.pick; if (l && l.pickedPoint && l.hit) { t._updatePointerDistance(r.laserPointer, l.distance), r.selectionMesh.position.copyFrom(l.pickedPoint), r.selectionMesh.scaling.x = Math.sqrt(l.distance), r.selectionMesh.scaling.y = Math.sqrt(l.distance), r.selectionMesh.scaling.z = Math.sqrt(l.distance); var c = t._convertNormalToDirectionOfRay(l.getNormal(!0), r.tmpRay); if (r.selectionMesh.position.copyFrom(l.pickedPoint), c) { var u = R.Cross(Ar.Y, c), h = R.Cross(c, u); R.RotationFromAxisToRef(h, c, u, r.selectionMesh.rotation), r.selectionMesh.position.addInPlace(c.scale(.001)) } r.selectionMesh.isVisible = t.displaySelectionMesh, r.meshUnderPointer = l.pickedMesh } else r.selectionMesh.isVisible = !1, t._updatePointerDistance(r.laserPointer, 1), r.meshUnderPointer = null })) }, Object.defineProperty(t.prototype, "_utilityLayerScene", { get: function () { return this._options.customUtilityLayerScene || lu.DefaultUtilityLayer.utilityLayerScene }, enumerable: !1, configurable: !0 }), t.prototype._attachGazeMode = function (e) { var t = this, i = this._controllers[e && e.uniqueId || "camera"], r = this._options.timeToSelect || 3e3, n = this._options.useUtilityLayer ? this._utilityLayerScene : this._scene, o = new Xi, a = Lc("selection", { diameter: .0525, thickness: .015, tessellation: 20 }, n); a.isVisible = !1, a.isPickable = !1, a.parent = i.selectionMesh; var s = 0, l = !1, c = { pointerId: i.id, pointerType: "xr" }; i.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add((function () { if (i.pick) { if (t._augmentPointerInit(c, i.id, i.screenCoordinates), i.laserPointer.material.alpha = 0, a.isVisible = !1, i.pick.hit) if (t._pickingMoved(o, i.pick)) l && (t._options.disablePointerUpOnTouchOut || t._scene.simulatePointerUp(i.pick, c)), l = !1, s = 0; else if (s > r / 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)) < Math.PI / 2 && e.scaleInPlace(-1), e }, t.prototype._detachController = function (e) { var t = this, i = this._controllers[e]; if (i) { if (i.selectionComponent && i.onButtonChangedObserver && i.selectionComponent.onButtonStateChangedObservable.remove(i.onButtonChangedObserver), i.onFrameObserver && this._xrSessionManager.onXRFrameObservable.remove(i.onFrameObserver), i.eventListeners && Object.keys(i.eventListeners).forEach((function (e) { var r = i.eventListeners && i.eventListeners[e]; r && t._xrSessionManager.session.removeEventListener(e, r) })), !i.finalPointerUpTriggered && i.pointerDownTriggered) { var r = { pointerId: i.id, pointerType: "xr" }; this._xrSessionManager.runInXRFrame((function () { t._augmentPointerInit(r, i.id, i.screenCoordinates), t._scene.simulatePointerUp(i.pick || new Xi, r), i.finalPointerUpTriggered = !0 })) } this._xrSessionManager.scene.onBeforeRenderObservable.addOnce((function () { try { if (i.selectionMesh.dispose(), i.laserPointer.dispose(), delete t._controllers[e], t._attachedController === e) { var r = Object.keys(t._controllers); r.length ? t._attachedController = r[0] : t._attachedController = "" } } catch (e) { xi.Warn("controller already detached.") } })) } }, t.prototype._generateNewMeshPair = function (e) { var t = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || lu.DefaultUtilityLayer.utilityLayerScene : this._scene, i = this._options.customLasterPointerMeshGenerator ? this._options.customLasterPointerMeshGenerator() : Dc("laserPointer", { height: 1, diameterTop: 2e-4, diameterBottom: .004, tessellation: 20, subdivisions: 1 }, t); i.parent = e; var r = new mc("laserPointerMat", t); r.emissiveColor = this.laserPointerDefaultColor, r.alpha = .7, i.material = r, i.rotation.x = Math.PI / 2, this._updatePointerDistance(i, 1), i.isPickable = !1, i.isVisible = !1; var n = this._options.customSelectionMeshGenerator ? this._options.customSelectionMeshGenerator() : Lc("gazeTracker", { diameter: .0105, thickness: .0075, tessellation: 20 }, t); n.bakeCurrentTransformIntoVertices(), n.isPickable = !1, n.isVisible = !1; var o = new mc("targetMat", t); return o.specularColor = B.Black(), o.emissiveColor = this.selectionMeshDefaultColor, o.backFaceCulling = !1, n.material = o, void 0 !== this._options.renderingGroupId && (i.renderingGroupId = this._options.renderingGroupId, n.renderingGroupId = this._options.renderingGroupId), { laserPointer: i, selectionMesh: n } }, t.prototype._pickingMoved = function (e, t) { var i; if (!e.hit || !t.hit) return !0; if (!(e.pickedMesh && e.pickedPoint && t.pickedMesh && t.pickedPoint)) return !0; if (e.pickedMesh !== t.pickedMesh) return !0; null === (i = e.pickedPoint) || void 0 === i || i.subtractToRef(t.pickedPoint, this._tmpVectorForPickCompare), this._tmpVectorForPickCompare.set(Math.abs(this._tmpVectorForPickCompare.x), Math.abs(this._tmpVectorForPickCompare.y), Math.abs(this._tmpVectorForPickCompare.z)); var r = .01 * (this._options.gazeModePointerMovedFactor || 1) * t.distance; return this._tmpVectorForPickCompare.length() > 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 = zo.POINTER_SELECTION, t.Version = 1, t }(Ho); Wo.AddWebXRFeature(vm.Name, (function (e, t) { return function () { return new vm(e, t) } }), vm.Version, !0), bn.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; c < this.indexStart + this.indexCount - (3 - r); c += r) { var u = i[c], h = i[c + 1], d = i[c + 2]; if (n && 4294967295 === d) c += 2; else { var p = t[u], f = t[h], _ = t[d]; if (p && f && _) { var m = R.ProjectOnTriangleToRef(e, p, f, _, s); m < l && (a.copyFrom(s), l = m) } } } return o.copyFrom(a), l }, bn.prototype._projectOnUnIndexedTrianglesToRef = function (e, t, i, r) { for (var n = O.Vector3[0], o = O.Vector3[1], a = 1 / 0, s = this.verticesStart; s < this.verticesStart + this.verticesCount; s += 3) { var l = t[s], c = t[s + 1], u = t[s + 2], h = R.ProjectOnTriangleToRef(e, l, c, u, o); h < a && (n.copyFrom(o), a = h) } return r.copyFrom(n), a }, bn.prototype.projectToRef = function (e, t, i, r) { var n = this.getMaterial(); if (!n) return -1; var o = 3, s = !1; switch (n.fillMode) { case a.MATERIAL_PointListDrawMode: case a.MATERIAL_LineLoopDrawMode: case a.MATERIAL_LineStripDrawMode: case a.MATERIAL_TriangleFanDrawMode: return -1; case a.MATERIAL_TriangleStripDrawMode: o = 1, s = !0 }return n.fillMode === a.MATERIAL_LineListDrawMode ? -1 : !i.length && this._mesh._unIndexed ? this._projectOnUnIndexedTrianglesToRef(e, t, i, r) : this._projectOnTrianglesToRef(e, t, i, o, s, r) }, function (e) { e[e.DEHYDRATED = 0] = "DEHYDRATED", e[e.HOVER = 1] = "HOVER", e[e.TOUCH = 2] = "TOUCH" }(pm || (pm = {})), function (e) { e[e.DISABLED = 0] = "DISABLED", e[e.CENTERED_ON_CONTROLLER = 1] = "CENTERED_ON_CONTROLLER", e[e.CENTERED_IN_FRONT = 2] = "CENTERED_IN_FRONT" }(fm || (fm = {})); var ym = function (e) { function t(i, r) { var n = e.call(this, i) || this; return n._options = r, n._tmpRay = new Mo(new R, new R), n._attachController = function (e) { var i; if (!n._controllers[e.uniqueId]) { var r = (i = n._generateNewTouchPointMesh()).touchCollisionMesh, o = i.touchCollisionMeshFunction, a = i.hydrateCollisionMeshFunction, s = n._generateVisualCue(); switch (n._controllers[e.uniqueId] = { xrController: e, meshUnderPointer: null, nearInteractionTargetMesh: null, pick: null, stalePick: null, touchCollisionMesh: r, touchCollisionMeshFunction: o, hydrateCollisionMeshFunction: a, currentAnimationState: pm.DEHYDRATED, grabRay: new Mo(new R, new R), hoverInteraction: !1, nearInteraction: !1, grabInteraction: !1, id: t._IdCounter++, pickedPointVisualCue: s }, n._attachedController ? !n._options.enableNearInteractionOnAllControllers && n._options.preferredHandedness && e.inputSource.handedness === n._options.preferredHandedness && (n._attachedController = e.uniqueId) : n._options.enableNearInteractionOnAllControllers || (n._attachedController = e.uniqueId), e.inputSource.targetRayMode) { case "tracked-pointer": return n._attachNearInteractionMode(e); case "gaze": case "screen": return null } } }, n._controllers = {}, n._farInteractionFeature = null, n.selectionMeshDefaultColor = new B(.8, .8, .8), n.selectionMeshPickedColor = new B(.3, .3, 1), n._hoverRadius = .1, n._pickRadius = .02, n._controllerPickRadius = .03, n._nearGrabLengthScale = 5, n._scene = n._xrSessionManager.scene, void 0 === n._options.nearInteractionControllerMode && (n._options.nearInteractionControllerMode = fm.CENTERED_IN_FRONT), n._options.farInteractionFeature && (n._farInteractionFeature = n._options.farInteractionFeature), n } return W(t, e), t.prototype.attach = function () { var t = this; return !!e.prototype.attach.call(this) && (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) })), this._scene.constantlyUpdateMeshUnderPointer = !0, !0) }, t.prototype.detach = function () { var t = this; return !!e.prototype.detach.call(this) && (Object.keys(this._controllers).forEach((function (e) { t._detachController(e) })), !0) }, t.prototype.getMeshUnderPointer = function (e) { return this._controllers[e] ? this._controllers[e].meshUnderPointer : null }, t.prototype.getXRControllerByPointerId = function (e) { for (var t = Object.keys(this._controllers), i = 0; i < t.length; ++i)if (this._controllers[t[i]].id === e) return this._controllers[t[i]].xrController || null; return null }, t.prototype.setFarInteractionFeature = function (e) { this._farInteractionFeature = e }, t.prototype._nearPickPredicate = function (e) { return e.isEnabled() && e.isVisible && e.isPickable && e.isNearPickable }, t.prototype._nearGrabPredicate = function (e) { return e.isEnabled() && e.isVisible && e.isPickable && e.isNearGrabbable }, t.prototype._nearInteractionPredicate = function (e) { return e.isEnabled() && e.isVisible && e.isPickable && (e.isNearPickable || e.isNearGrabbable) }, t.prototype._controllerAvailablePredicate = function (e, t) { for (var i = e; i;) { if (i.reservedDataStore && i.reservedDataStore.nearInteraction && i.reservedDataStore.nearInteraction.excludedControllerId === t) return !1; i = i.parent } return !0 }, t.prototype._handleTransitionAnimation = function (e, t) { var i; if (e.currentAnimationState !== t && this._options.nearInteractionControllerMode === fm.CENTERED_IN_FRONT && !(null === (i = e.xrController) || void 0 === i ? void 0 : i.inputSource.hand)) { if (t > e.currentAnimationState) switch (e.currentAnimationState) { case pm.DEHYDRATED: if (e.hydrateCollisionMeshFunction(!0), t === pm.HOVER) break; case pm.HOVER: if (e.touchCollisionMeshFunction(!0), t === pm.TOUCH) break } else switch (e.currentAnimationState) { case pm.TOUCH: if (e.touchCollisionMeshFunction(!1), t === pm.HOVER) break; case pm.HOVER: if (e.hydrateCollisionMeshFunction(!1), t === pm.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 !== fm.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 !== fm.DISABLED) { var c = n.xrController.pointer; n.xrController.grip && t._options.nearInteractionControllerMode === fm.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.distance < e.distance ? t : e : t : e }, h = function (e) { var t = new Xi, i = !1, r = e && e.pickedPoint && e.hit; return (null == e ? void 0 : e.pickedPoint) && (i = 0 === e.pickedPoint.x && 0 === e.pickedPoint.y && 0 === e.pickedPoint.z), r && !i && (t = e), t }; if (!n.grabInteraction) { var d = null, p = null; t._options.useUtilityLayer && t._utilityLayerScene && (p = t._pickWithSphere(n, t._hoverRadius, t._utilityLayerScene, (function (e) { return t._nearInteractionPredicate(e) }))); var f = u(t._pickWithSphere(n, t._hoverRadius, t._scene, (function (e) { return t._nearInteractionPredicate(e) })), p); if (f && f.hit && (d = h(f)).hit && (n.hoverInteraction = !0), n.hoverInteraction) { var _ = null, m = o ? t._pickRadius : t._controllerPickRadius; t._options.useUtilityLayer && t._utilityLayerScene && (_ = t._pickWithSphere(n, m, t._utilityLayerScene, (function (e) { return t._nearPickPredicate(e) }))); var g = h(u(t._pickWithSphere(n, m, t._scene, (function (e) { return t._nearPickPredicate(e) })), _)); g.hit && (d = g, n.nearInteraction = !0) } n.stalePick = n.pick, n.pick = d, n.pick && n.pick.pickedPoint && n.pick.hit ? (n.meshUnderPointer = n.pick.pickedMesh, n.pickedPointVisualCue.position.copyFrom(n.pick.pickedPoint), n.pickedPointVisualCue.isVisible = !0, t._farInteractionFeature && t._farInteractionFeature.attached && t._farInteractionFeature._setPointerSelectionDisabledByPointerId(n.id, !0)) : (n.meshUnderPointer = null, n.pickedPointVisualCue.isVisible = !1, t._farInteractionFeature && t._farInteractionFeature.attached && t._farInteractionFeature._setPointerSelectionDisabledByPointerId(n.id, !1)) } var v = pm.DEHYDRATED; n.grabInteraction || n.nearInteraction ? v = pm.TOUCH : n.hoverInteraction && (v = pm.HOVER), t._handleTransitionAnimation(n, v) } } else n.pick = null })) }, Object.defineProperty(t.prototype, "_utilityLayerScene", { get: function () { return this._options.customUtilityLayerScene || lu.DefaultUtilityLayer.utilityLayerScene }, enumerable: !1, configurable: !0 }), t.prototype._generateVisualCue = function () { var e = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || lu.DefaultUtilityLayer.utilityLayerScene : this._scene, t = bu("nearInteraction", { diameter: .0105 }, e); t.bakeCurrentTransformIntoVertices(), t.isPickable = !1, t.isVisible = !1, t.rotationQuaternion = P.Identity(); var i = new mc("targetMat", e); return i.specularColor = B.Black(), i.emissiveColor = this.selectionMeshDefaultColor, i.backFaceCulling = !1, t.material = i, t }, t.prototype._isControllerReadyForNearInteraction = function (e) { return !this._farInteractionFeature || this._farInteractionFeature._getPointerSelectionDisabledByPointerId(e) }, t.prototype._attachNearInteractionMode = function (e) { var t = this, i = this._controllers[e.uniqueId], r = { pointerId: i.id, pointerType: "xr-near" }; i.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add((function () { (t._options.enableNearInteractionOnAllControllers || e.uniqueId === t._attachedController) && i.xrController && (i.xrController.inputSource.hand || t._options.nearInteractionControllerMode && i.xrController.inputSource.gamepad) && (i.pick && (i.pick.ray = i.grabRay), i.pick && t._isControllerReadyForNearInteraction(i.id) && t._scene.simulatePointerMove(i.pick, r), i.nearInteraction && i.pick && i.pick.hit ? i.nearInteractionTargetMesh || (t._scene.simulatePointerDown(i.pick, r), i.nearInteractionTargetMesh = i.meshUnderPointer) : i.nearInteractionTargetMesh && i.stalePick && (t._scene.simulatePointerUp(i.stalePick, r), i.nearInteractionTargetMesh = null)) })); var n = function (n) { t._options.enableNearInteractionOnAllControllers || e.uniqueId === t._attachedController && t._isControllerReadyForNearInteraction(i.id) ? (i.pick && (i.pick.ray = i.grabRay), n && i.pick && i.meshUnderPointer && t._nearGrabPredicate(i.meshUnderPointer) ? (i.grabInteraction = !0, i.pickedPointVisualCue.isVisible = !1, t._scene.simulatePointerDown(i.pick, r)) : !n && i.pick && i.grabInteraction && (t._scene.simulatePointerUp(i.pick, r), i.grabInteraction = !1, i.pickedPointVisualCue.isVisible = !0)) : !n || t._options.enableNearInteractionOnAllControllers || t._options.disableSwitchOnClick || (t._attachedController = e.uniqueId) }; if (e.inputSource.gamepad) { var o = function (e) { i.squeezeComponent = e.getComponent("grasp"), i.squeezeComponent ? i.onSqueezeButtonChangedObserver = i.squeezeComponent.onButtonStateChangedObservable.add((function (e) { if (e.changes.pressed) { var t = e.changes.pressed.current; n(t) } })) : (i.selectionComponent = e.getMainComponent(), i.onButtonChangedObserver = i.selectionComponent.onButtonStateChangedObservable.add((function (e) { if (e.changes.pressed) { var t = e.changes.pressed.current; n(t) } }))) }; e.motionController ? o(e.motionController) : e.onMotionControllerInitObservable.add(o) } else { var a = function (e) { i.xrController && e.inputSource === i.xrController.inputSource && i.pick && t._isControllerReadyForNearInteraction(i.id) && i.meshUnderPointer && t._nearGrabPredicate(i.meshUnderPointer) && (i.grabInteraction = !0, i.pickedPointVisualCue.isVisible = !1, t._scene.simulatePointerDown(i.pick, r)) }, s = function (e) { i.xrController && e.inputSource === i.xrController.inputSource && i.pick && t._isControllerReadyForNearInteraction(i.id) && (t._scene.simulatePointerUp(i.pick, r), i.grabInteraction = !1, i.pickedPointVisualCue.isVisible = !0) }; i.eventListeners = { selectend: s, selectstart: a }, this._xrSessionManager.session.addEventListener("selectstart", a), this._xrSessionManager.session.addEventListener("selectend", s) } }, t.prototype._detachController = function (e) { var t = this, i = this._controllers[e]; if (i && (i.squeezeComponent && i.onSqueezeButtonChangedObserver && i.squeezeComponent.onButtonStateChangedObservable.remove(i.onSqueezeButtonChangedObserver), i.selectionComponent && i.onButtonChangedObserver && i.selectionComponent.onButtonStateChangedObservable.remove(i.onButtonChangedObserver), i.onFrameObserver && this._xrSessionManager.onXRFrameObservable.remove(i.onFrameObserver), i.eventListeners && Object.keys(i.eventListeners).forEach((function (e) { var r = i.eventListeners && i.eventListeners[e]; r && t._xrSessionManager.session.removeEventListener(e, r) })), i.touchCollisionMesh.dispose(), i.pickedPointVisualCue.dispose(), this._xrSessionManager.runInXRFrame((function () { var e = { pointerId: i.id, pointerType: "xr-near" }; t._scene.simulatePointerUp(new Xi, e) })), delete this._controllers[e], this._attachedController === e)) { var r = Object.keys(this._controllers); r.length ? this._attachedController = r[0] : this._attachedController = "" } }, t.prototype._generateNewTouchPointMesh = function () { var e = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || lu.DefaultUtilityLayer.utilityLayerScene : this._scene, t = bu("PickSphere", { diameter: 1 }, e); t.isVisible = !1, this._options.motionControllerOrbMaterial ? t.material = this._options.motionControllerOrbMaterial : ss.ParseFromSnippetAsync("8RUNKL#3", e).then((function (e) { t.material = e })); var i = new Hr; i.setEasingMode(wr.EASINGMODE_EASEINOUT); var r = new R(this._controllerPickRadius, this._controllerPickRadius, this._controllerPickRadius), n = this._controllerPickRadius * (4 / 3), o = new R(n, n, n), a = this._controllerPickRadius * (7 / 6), s = new R(a, a, a), l = .8 * this._controllerPickRadius, c = new R(l, l, l), u = 1.5 * this._controllerPickRadius, h = [{ frame: 0, value: r }, { frame: 10, value: new R(u, u, u) }, { frame: 18, value: o }], d = [{ frame: 0, value: o }, { frame: 10, value: c }, { frame: 18, value: r }], p = [{ frame: 0, value: R.ZeroReadOnly }, { frame: 12, value: s }, { frame: 15, value: r }], f = [{ frame: 0, value: r }, { frame: 10, value: R.ZeroReadOnly }, { frame: 15, value: R.ZeroReadOnly }], _ = new je("touch", "scaling", 60, je.ANIMATIONTYPE_VECTOR3, je.ANIMATIONLOOPMODE_CONSTANT), m = new je("release", "scaling", 60, je.ANIMATIONTYPE_VECTOR3, je.ANIMATIONLOOPMODE_CONSTANT), g = new je("hydrate", "scaling", 60, je.ANIMATIONTYPE_VECTOR3, je.ANIMATIONLOOPMODE_CONSTANT), v = new je("dehydrate", "scaling", 60, je.ANIMATIONTYPE_VECTOR3, je.ANIMATIONLOOPMODE_CONSTANT); return _.setEasingFunction(i), m.setEasingFunction(i), g.setEasingFunction(i), v.setEasingFunction(i), _.setKeys(h), m.setKeys(d), g.setKeys(p), v.setKeys(f), { touchCollisionMesh: t, touchCollisionMeshFunction: function (i) { var r = i ? _ : m; e.beginDirectAnimation(t, [r], 0, 18, !1, 1) }, hydrateCollisionMeshFunction: function (i) { var r = i ? g : v; i && (t.isVisible = !0), e.beginDirectAnimation(t, [r], 0, 15, !1, 1, (function () { i || (t.isVisible = !1) })) } } }, t.prototype._pickWithSphere = function (e, i, r, n) { var o = new Xi; if (o.distance = 1 / 0, e.touchCollisionMesh && e.xrController) for (var a = e.touchCollisionMesh.position, s = hn.CreateFromCenterAndRadius(a, i), l = 0; l < r.meshes.length; l++) { var c = r.meshes[l]; if (n(c) && this._controllerAvailablePredicate(c, e.xrController.uniqueId)) { var u = t.PickMeshWithSphere(c, s); u && u.hit && u.distance < o.distance && (o.hit = u.hit, o.pickedMesh = c, o.pickedPoint = u.pickedPoint, o.aimTransform = e.xrController.pointer, o.gripTransform = e.xrController.grip || null, o.originMesh = e.touchCollisionMesh, o.distance = u.distance) } } return o }, t.PickMeshWithSphere = function (e, t, i) { void 0 === i && (i = !1); var r = e.subMeshes, n = new Xi, o = e.getBoundingInfo(); if (!e._generatePointsArray()) return n; if (!e.subMeshes || !o) return n; if (!i && !hn.Intersects(o.boundingSphere, t)) return n; var a, s, l, c = O.Vector3[0], u = O.Vector3[1], h = 1 / 0, d = O.Vector3[2], p = O.Matrix[0]; p.copyFrom(e.getWorldMatrix()), p.invert(), R.TransformCoordinatesToRef(t.center, p, d); for (var f = 0; f < r.length; f++)r[f].projectToRef(d, e._positions, e.getIndices(), u), R.TransformCoordinatesToRef(u, e.getWorldMatrix(), u), a = R.Distance(u, t.center), l = R.Distance(u, e.getAbsolutePosition()), -1 !== (s = R.Distance(t.center, e.getAbsolutePosition())) && -1 !== l && l > s && (a = 0, u.copyFrom(t.center)), -1 !== a && a < h && (h = a, c.copyFrom(u)); return h < t.radius && (n.hit = !0, n.distance = h, n.pickedMesh = e, n.pickedPoint = c.clone()), n }, t._IdCounter = 200, t.Name = zo.NEAR_INTERACTION, t.Version = 1, t }(Ho); Wo.AddWebXRFeature(ym.Name, (function (e, t) { return function () { return new ym(e, t) } }), ym.Version, !0); var bm, Tm = function () { function e(e, t, i) { this.element = e, this.sessionMode = t, this.referenceSpaceType = i } return e.prototype.update = function (e) { }, e }(), Em = function () { }, Sm = function () { function e(e, t) { var i = this; if (this._scene = e, this.options = t, this._activeButton = null, this._buttons = [], this.activeButtonChangedObservable = new u, this._onSessionGranted = function (e) { i._helper && i._enterXRWithButtonIndex(0) }, this.overlay = document.createElement("div"), this.overlay.classList.add("xr-button-overlay"), !t.ignoreSessionGrantedEvent && navigator.xr && navigator.xr.addEventListener("sessiongranted", this._onSessionGranted), "undefined" != typeof window && window.location && "http:" === window.location.protocol && "localhost" !== window.location.hostname) throw xi.Warn("WebXR can only be served over HTTPS"), new Error("WebXR can only be served over HTTPS"); if (t.customButtons) this._buttons = t.customButtons; else { this.overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;"; var r = t.sessionMode || "immersive-vr", n = t.referenceSpaceType || "local-floor", o = ".babylonVRicon { color: #868686; border-color: #868686; border-style: solid; margin-left: 10px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-image: url(" + ("undefined" == typeof SVGSVGElement ? "https://cdn.babylonjs.com/Assets/vrButton.png" : "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") + "); 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) }"; o += '.babylonVRicon.vrdisplaypresenting { background-image: none;} .vrdisplaypresenting::after { content: "EXIT"} .xr-error::after { content: "ERROR"}'; var a = document.createElement("style"); a.appendChild(document.createTextNode(o)), document.getElementsByTagName("head")[0].appendChild(a); var s = document.createElement("button"); s.className = "babylonVRicon", s.title = "".concat(r, " - ").concat(n), this._buttons.push(new Tm(s, r, n)), this._buttons[this._buttons.length - 1].update = function (e) { this.element.style.display = null === e || e === this ? "" : "none", s.className = "babylonVRicon" + (e === this ? " vrdisplaypresenting" : "") }, this._updateButtons(null) } var l = e.getEngine().getInputElement(); l && l.parentNode && (l.parentNode.appendChild(this.overlay), e.onDisposeObservable.addOnce((function () { i.dispose() }))) } return e.prototype.setHelperAsync = function (e, t) { return j(this, void 0, void 0, (function () { var i, r = this; return Y(this, (function (n) { switch (n.label) { case 0: return this._helper = e, this._renderTarget = t, i = this._buttons.map((function (t) { return e.sessionManager.isSessionSupportedAsync(t.sessionMode) })), e.onStateChangedObservable.add((function (e) { e == vc.NOT_IN_XR && r._updateButtons(null) })), [4, Promise.all(i)]; case 1: return n.sent().forEach((function (e, t) { e ? (r.overlay.appendChild(r._buttons[t].element), r._buttons[t].element.onclick = r._enterXRWithButtonIndex.bind(r, t)) : xi.Warn('Session mode "'.concat(r._buttons[t].sessionMode, '" not supported in browser')) })), [2] } })) })) }, e.CreateAsync = function (t, i, r) { return j(this, void 0, void 0, (function () { var n; return Y(this, (function (o) { switch (o.label) { case 0: return [4, (n = new e(t, r)).setHelperAsync(i, r.renderTarget || void 0)]; case 1: return o.sent(), [2, n] } })) })) }, e.prototype._enterXRWithButtonIndex = function (e) { return void 0 === e && (e = 0), j(this, void 0, void 0, (function () { var t, i, r; return Y(this, (function (n) { switch (n.label) { case 0: return this._helper.state != vc.IN_XR ? [3, 2] : [4, this._helper.exitXRAsync()]; case 1: return n.sent(), this._updateButtons(null), [3, 6]; case 2: if (this._helper.state != vc.NOT_IN_XR) return [3, 6]; n.label = 3; case 3: return n.trys.push([3, 5, , 6]), [4, this._helper.enterXRAsync(this._buttons[e].sessionMode, this._buttons[e].referenceSpaceType, this._renderTarget, { optionalFeatures: this.options.optionalFeatures, requiredFeatures: this.options.requiredFeatures })]; case 4: return n.sent(), this._updateButtons(this._buttons[e]), [3, 6]; case 5: return t = n.sent(), this._updateButtons(null), i = this._buttons[e].element, r = i.title, i.title = "Error entering XR session : " + r, i.classList.add("xr-error"), this.options.onError && this.options.onError(t), [3, 6]; case 6: return [2] } })) })) }, e.prototype.dispose = function () { var e = this._scene.getEngine().getInputElement(); e && e.parentNode && e.parentNode.contains(this.overlay) && e.parentNode.removeChild(this.overlay), this.activeButtonChangedObservable.clear(), navigator.xr.removeEventListener("sessiongranted", this._onSessionGranted) }, e.prototype._updateButtons = function (e) { var t = this; this._activeButton = e, this._buttons.forEach((function (e) { e.update(t._activeButton) })), this.activeButtonChangedObservable.notifyObservers(this._activeButton) }, e }(); function xm(e) { var t, i = 0, r = Date.now(); e.observableParameters = null !== (t = e.observableParameters) && void 0 !== t ? t : {}; var n = e.contextObservable.add((function (t) { var o = Date.now(), a = { startTime: r, currentTime: o, deltaTime: i = o - r, completeRate: i / e.timeout, payload: t }; e.onTick && e.onTick(a), e.breakCondition && e.breakCondition() && (e.contextObservable.remove(n), e.onAborted && e.onAborted(a)), i >= 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" }(bm || (bm = {})); var Am = 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(bm.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 === bm.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(bm.STARTED) }, e.prototype.stop = function () { this._state === bm.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(bm.ENDED), t ? this.onTimerAbortedObservable.notifyObservers(e) : this.onTimerEndedObservable.notifyObservers(e) }, e }(), Rm = 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 Mo(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(am.THUMBSTICK_TYPE) || e.motionController.getComponentOfType(am.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, xm({ 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 === Ji.POINTERDOWN ? (t.teleportationState.forward = !0, r._currentTeleportationControllerId = t.xrController.uniqueId, t.teleportationState.baseRotation = r._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y, t.teleportationState.currentRotation = 0, xm({ 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 === Ji.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 < this._snapToPositions.length; ++i)if (this._snapToPositions[i].equals(e)) { t = i; break } return -1 !== t && (this._snapToPositions.splice(t, 1), !0) }, t.prototype.setSelectionFeature = function (e) { this._selectionFeature = e }, t.prototype._onXRFrame = function (e) { var t = this, i = this._xrSessionManager.currentFrame, r = this._xrSessionManager.scene; if (this.attach && i) { var n = this._options.teleportationTargetMesh; if (this._currentTeleportationControllerId) { if (!n) return; n.rotationQuaternion = n.rotationQuaternion || new P; var o = this._controllers[this._currentTeleportationControllerId]; if (o && o.teleportationState.forward) { P.RotationYawPitchRollToRef(o.teleportationState.currentRotation + o.teleportationState.baseRotation, 0, 0, n.rotationQuaternion); var a = !1; if (o.xrController.getWorldPointerRayToRef(this._tmpRay), this.straightRayEnabled) { if ((s = r.pickWithRay(this._tmpRay, (function (e) { if (t._options.pickBlockerMeshes && -1 !== t._options.pickBlockerMeshes.indexOf(e)) return !0; var i = t._floorMeshes.indexOf(e); return -1 !== i && t._floorMeshes[i].absolutePosition.y < t._options.xrInput.xrCamera.globalPosition.y }))) && s.pickedMesh && this._options.pickBlockerMeshes && -1 !== this._options.pickBlockerMeshes.indexOf(s.pickedMesh)) return o.teleportationState.blocked = !0, this._setTargetMeshVisibility(!1), void this._showParabolicPath(s); s && s.pickedPoint && (o.teleportationState.blocked = !1, a = !0, this._setTargetMeshPosition(s), this._setTargetMeshVisibility(!0), this._showParabolicPath(s)) } if (this.parabolicRayEnabled && !a) { var s, l = o.xrController.pointer.rotationQuaternion.toEulerAngles().x, c = Math.PI / 2 - Math.abs(l) + 1, u = this.parabolicCheckRadius * c; if (this._tmpRay.origin.addToRef(this._tmpRay.direction.scale(2 * u), this._tmpVector), this._tmpVector.y = this._tmpRay.origin.y, this._tmpRay.origin.addInPlace(this._tmpRay.direction.scale(u)), this._tmpVector.subtractToRef(this._tmpRay.origin, this._tmpRay.direction), this._tmpRay.direction.normalize(), (s = r.pickWithRay(this._tmpRay, (function (e) { return !(!t._options.pickBlockerMeshes || -1 === t._options.pickBlockerMeshes.indexOf(e)) || -1 !== t._floorMeshes.indexOf(e) }))) && s.pickedMesh && this._options.pickBlockerMeshes && -1 !== this._options.pickBlockerMeshes.indexOf(s.pickedMesh)) return o.teleportationState.blocked = !0, this._setTargetMeshVisibility(!1), void this._showParabolicPath(s); s && s.pickedPoint && (o.teleportationState.blocked = !1, a = !0, this._setTargetMeshPosition(s), this._setTargetMeshVisibility(!0), this._showParabolicPath(s)) } this._setTargetMeshVisibility(a) } else this._setTargetMeshVisibility(!1) } else this._disposeBezierCurve(), this._setTargetMeshVisibility(!1) } }, t.prototype._createDefaultTargetMesh = function () { this._options.defaultTargetMeshOptions = this._options.defaultTargetMeshOptions || {}; var e = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || lu.DefaultUtilityLayer.utilityLayerScene : this._xrSessionManager.scene, t = Gc("teleportationTarget", { width: 2, height: 2, subdivisions: 2 }, e); if (t.isPickable = !1, this._options.defaultTargetMeshOptions.teleportationCircleMaterial) t.material = this._options.defaultTargetMeshOptions.teleportationCircleMaterial; else { var i = new gc("teleportationPlaneDynamicTexture", 512, e, !0); i.hasAlpha = !0; var r = i.getContext(); r.beginPath(), r.arc(256, 256, 200, 0, 2 * Math.PI, !1), r.fillStyle = this._options.defaultTargetMeshOptions.teleportationFillColor || "#444444", r.fill(), r.lineWidth = 10, r.strokeStyle = this._options.defaultTargetMeshOptions.teleportationBorderColor || "#FFFFFF", r.stroke(), r.closePath(), i.update(); var n = new mc("teleportationPlaneMaterial", e); n.diffuseTexture = i, t.material = n } var o = Lc("torusTeleportation", { diameter: .75, thickness: .1, tessellation: 20 }, e); if (o.isPickable = !1, o.parent = t, !this._options.defaultTargetMeshOptions.disableAnimation) { var a = new je("animationInnerCircle", "position.y", 30, je.ANIMATIONTYPE_FLOAT, je.ANIMATIONLOOPMODE_CYCLE), s = []; s.push({ frame: 0, value: 0 }), s.push({ frame: 30, value: .4 }), s.push({ frame: 60, value: 0 }), a.setKeys(s); var l = new Yr; l.setEasingMode(wr.EASINGMODE_EASEINOUT), a.setEasingFunction(l), o.animations = [], o.animations.push(a), e.beginAnimation(o, 0, 60, !0) } var c = Dc("rotationCone", { diameterTop: 0, tessellation: 4 }, e); if (c.isPickable = !1, c.scaling.set(.5, .12, .2), c.rotate(Ar.X, Math.PI / 2), c.position.z = .6, c.parent = o, this._options.defaultTargetMeshOptions.torusArrowMaterial) o.material = this._options.defaultTargetMeshOptions.torusArrowMaterial, c.material = this._options.defaultTargetMeshOptions.torusArrowMaterial; else { var u = new mc("torusConsMat", e); u.disableLighting = !!this._options.defaultTargetMeshOptions.disableLighting, u.disableLighting ? u.emissiveColor = new B(.3, .3, 1) : u.diffuseColor = new B(.3, .3, 1), u.alpha = .9, o.material = u, c.material = u, this._teleportationRingMaterial = u } void 0 !== this._options.renderingGroupId && (t.renderingGroupId = this._options.renderingGroupId, o.renderingGroupId = this._options.renderingGroupId, c.renderingGroupId = this._options.renderingGroupId), this._options.teleportationTargetMesh = t, this._setTargetMeshVisibility(!1) }, t.prototype._detachController = function (e) { var t = this._controllers[e]; t && (t.teleportationComponent && (t.onAxisChangedObserver && t.teleportationComponent.onAxisValueChangedObservable.remove(t.onAxisChangedObserver), t.onButtonChangedObserver && t.teleportationComponent.onButtonStateChangedObservable.remove(t.onButtonChangedObserver)), delete this._controllers[e]) }, t.prototype._findClosestSnapPointWithRadius = function (e, t) { void 0 === t && (t = this._options.snapToPositionRadius || .8); var i = null, r = Number.MAX_VALUE; if (this._snapToPositions.length) { var n = t * t; this._snapToPositions.forEach((function (t) { var o = R.DistanceSquared(t, e); o <= n && o < r && (r = o, i = t) })) } return i }, t.prototype._setTargetMeshPosition = function (e) { var t = e.pickedPoint; if (this._options.teleportationTargetMesh && t) { var i = this._findClosestSnapPointWithRadius(t); this._snappedToPoint = !!i, this.snapPointsOnly && !this._snappedToPoint && this._teleportationRingMaterial ? this._teleportationRingMaterial.diffuseColor.set(1, .3, .3) : this.snapPointsOnly && this._snappedToPoint && this._teleportationRingMaterial && this._teleportationRingMaterial.diffuseColor.set(.3, .3, 1), this._options.teleportationTargetMesh.position.copyFrom(i || t), this._options.teleportationTargetMesh.position.y += .01, this.onTargetMeshPositionUpdatedObservable.notifyObservers(e) } }, t.prototype._setTargetMeshVisibility = function (e, t) { this._options.teleportationTargetMesh && (this._options.teleportationTargetMesh.isVisible !== e || t) && (this._options.teleportationTargetMesh.isVisible = e, this._options.teleportationTargetMesh.getChildren(void 0, !1).forEach((function (t) { t.isVisible = e })), e ? this._selectionFeature && this._selectionFeature.detach() : (this._quadraticBezierCurve && (this._quadraticBezierCurve.dispose(), this._quadraticBezierCurve = null), this._selectionFeature && this._selectionFeature.attach())) }, t.prototype._disposeBezierCurve = function () { this._quadraticBezierCurve && (this._quadraticBezierCurve.dispose(), this._quadraticBezierCurve = null) }, t.prototype._showParabolicPath = function (e) { if (e.pickedPoint && this._currentTeleportationControllerId) { var t = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || lu.DefaultUtilityLayer.utilityLayerScene : this._xrSessionManager.scene, i = this._controllers[this._currentTeleportationControllerId], r = Lr.CreateQuadraticBezier(i.xrController.pointer.absolutePosition, e.ray.origin, e.pickedPoint, 25), n = i.teleportationState.blocked ? this._blockedRayColor : void 0, o = new Array(26).fill(n || this._cachedColor4White); this._options.generateRayPathMesh ? this._quadraticBezierCurve = this._options.generateRayPathMesh(r.getPoints(), e) : this._quadraticBezierCurve = Yu("teleportation path line", { points: r.getPoints(), instance: this._quadraticBezierCurve, updatable: !0, colors: o }, t), this._quadraticBezierCurve.isPickable = !1, void 0 !== this._options.renderingGroupId && (this._quadraticBezierCurve.renderingGroupId = this._options.renderingGroupId) } }, t.prototype._teleportForward = function (e) { var t = this._controllers[e]; if (t && t.teleportationState.forward && this.teleportationEnabled && (t.teleportationState.forward = !1, this._currentTeleportationControllerId = "", !this.snapPointsOnly || this._snappedToPoint)) if (this.skipNextTeleportation) this.skipNextTeleportation = !1; else if (this._options.teleportationTargetMesh && this._options.teleportationTargetMesh.isVisible) { var i = this._options.xrInput.xrCamera.realWorldHeight; this._options.xrInput.xrCamera.onBeforeCameraTeleport.notifyObservers(this._options.xrInput.xrCamera.position), this._options.xrInput.xrCamera.position.copyFrom(this._options.teleportationTargetMesh.position), this._options.xrInput.xrCamera.position.y += i, P.FromEulerAngles(0, t.teleportationState.currentRotation - (this._xrSessionManager.scene.useRightHandedSystem ? Math.PI : 0), 0).multiplyToRef(this._options.xrInput.xrCamera.rotationQuaternion, this._options.xrInput.xrCamera.rotationQuaternion), this._options.xrInput.xrCamera.onAfterCameraTeleport.notifyObservers(this._options.xrInput.xrCamera.position) } }, t.Name = zo.TELEPORTATION, t.Version = 1, t }(Ho); Wo.AddWebXRFeature(Rm.Name, (function (e, t) { return function () { return new Rm(e, t) } }), Rm.Version, !0); var Cm = function () { }, Pm = function () { function e() { } return e.CreateAsync = function (t, i) { void 0 === i && (i = {}); var r = new e; if (t.onDisposeObservable.addOnce((function () { r.dispose() })), !i.disableDefaultUI) { var n = H({ renderTarget: r.renderTarget }, i.uiOptions || {}); i.optionalFeatures && ("boolean" == typeof i.optionalFeatures ? n.optionalFeatures = ["hit-test", "anchors", "plane-detection", "hand-tracking"] : n.optionalFeatures = i.optionalFeatures), r.enterExitUI = new Sm(t, n) } return om.CreateAsync(t).then((function (e) { if (r.baseExperience = e, i.ignoreNativeCameraTransformation && (r.baseExperience.camera.compensateOnFirstFrame = !1), r.input = new gm(e.sessionManager, e.camera, H({ controllerOptions: { renderingGroupId: i.renderingGroupId } }, i.inputOptions || {})), !i.disablePointerSelection) { var t = H(H({}, i.pointerSelectionOptions), { xrInput: r.input, renderingGroupId: i.renderingGroupId }); r.pointerSelection = r.baseExperience.featuresManager.enableFeature(vm.Name, i.useStablePlugins ? "stable" : "latest", t), i.disableTeleportation || (r.teleportation = r.baseExperience.featuresManager.enableFeature(Rm.Name, i.useStablePlugins ? "stable" : "latest", H({ floorMeshes: i.floorMeshes, xrInput: r.input, renderingGroupId: i.renderingGroupId }, i.teleportationOptions)), r.teleportation.setSelectionFeature(r.pointerSelection)) } return i.disableNearInteraction || (r.nearInteraction = r.baseExperience.featuresManager.enableFeature(ym.Name, i.useStablePlugins ? "stable" : "latest", H({ xrInput: r.input, farInteractionFeature: r.pointerSelection, renderingGroupId: i.renderingGroupId, useUtilityLayer: !0, enableNearInteractionOnAllControllers: !0 }, i.nearInteractionOptions))), r.renderTarget = r.baseExperience.sessionManager.getWebXRRenderTarget(i.outputCanvasOptions), i.disableDefaultUI ? void 0 : r.enterExitUI.setHelperAsync(r.baseExperience, r.renderTarget) })).then((function () { return r })).catch((function (e) { return $.Error("Error initializing XR"), $.Error(e), r })) }, e.prototype.dispose = function () { this.baseExperience && this.baseExperience.dispose(), this.input && this.input.dispose(), this.enterExitUI && this.enterExitUI.dispose(), this.renderTarget && this.renderTarget.dispose() }, e }(), Im = !0; function Mm(e) { for (; e.firstChild;)e.removeChild(e.firstChild); e.srcObject = null, e.src = "", e.removeAttribute("src") } Sr.prototype.createDefaultLight = function (e) { if (void 0 === e && (e = !1), e && this.lights) for (var t = 0; t < this.lights.length; t++)this.lights[t].dispose(); 0 === this.lights.length && new Zl("default light", R.Up(), this) }, Sr.prototype.createDefaultCamera = function (e, t, i) { if (void 0 === e && (e = !1), void 0 === t && (t = !1), void 0 === i && (i = !1), t && this.activeCamera && (this.activeCamera.dispose(), this.activeCamera = null), !this.activeCamera) { var r = this.getWorldExtends((function (e) { return e.isVisible && e.isEnabled() })), n = r.max.subtract(r.min), o = r.min.add(n.scale(.5)), a = void 0, s = 1.5 * n.length(); if (isFinite(s) || (s = 1, o.copyFromFloats(0, 0, 0)), e) { var l = new nl("default camera", -Math.PI / 2, Math.PI / 2, s, o, this); l.lowerRadiusLimit = .01 * s, l.wheelPrecision = 100 / s, a = l } else { var c = new il("default camera", new R(o.x, o.y, -s), this); c.setTarget(o), a = c } a.minZ = .01 * s, a.maxZ = 1e3 * s, a.speed = .2 * s, this.activeCamera = a, i && a.attachControl() } }, Sr.prototype.createDefaultCameraOrLight = function (e, t, i) { void 0 === e && (e = !1), void 0 === t && (t = !1), void 0 === i && (i = !1), this.createDefaultLight(t), this.createDefaultCamera(e, t, i) }, Sr.prototype.createDefaultSkybox = function (e, t, i, r, n) { if (void 0 === t && (t = !1), void 0 === i && (i = 1e3), void 0 === r && (r = 0), void 0 === n && (n = !0), !e) return $.Warn("Can not create default skybox without environment texture."), null; n && e && (this.environmentTexture = e); var o = gu("hdrSkyBox", { size: i }, this); if (t) { var a = new L_("skyBox", this); a.backFaceCulling = !1, a.reflectionTexture = e.clone(), a.reflectionTexture && (a.reflectionTexture.coordinatesMode = vo.SKYBOX_MODE), a.microSurface = 1 - r, a.disableLighting = !0, a.twoSidedLighting = !0, o.material = a } else { var s = new mc("skyBox", this); s.backFaceCulling = !1, s.reflectionTexture = e.clone(), s.reflectionTexture && (s.reflectionTexture.coordinatesMode = vo.SKYBOX_MODE), s.disableLighting = !0, o.material = s } return o.isPickable = !1, o.infiniteDistance = !0, o.ignoreCameraMaxZ = !0, o }, Sr.prototype.createDefaultEnvironment = function (e) { return f_ ? new f_(e, this) : null }, Sr.prototype.createDefaultVRExperience = function (e) { return void 0 === e && (e = {}), new qc(this, e) }, Sr.prototype.createDefaultXRExperienceAsync = function (e) { return void 0 === e && (e = {}), Pm.CreateAsync(this, e).then((function (e) { return e })) }; var Om = function (e) { function t(t, i, r, n, o, s, l, c, u) { void 0 === n && (n = !1), void 0 === o && (o = !1), void 0 === s && (s = vo.TRILINEAR_SAMPLINGMODE), void 0 === l && (l = {}), void 0 === u && (u = a.TEXTUREFORMAT_RGBA); var h, d, p = this; (p = e.call(this, null, r, !n, o) || this)._onUserActionRequestedObservable = null, p._stillImageCaptured = !1, p._displayingPosterTexture = !1, p._frameId = -1, p._currentSrc = null, p._errorFound = !1, p._resizeInternalTexture = function () { var e; null != p._texture && p._texture.dispose(), !p._getEngine().needPOTTextures || xi.IsExponentOfTwo(p.video.videoWidth) && xi.IsExponentOfTwo(p.video.videoHeight) ? (p.wrapU = vo.WRAP_ADDRESSMODE, p.wrapV = vo.WRAP_ADDRESSMODE) : (p.wrapU = vo.CLAMP_ADDRESSMODE, p.wrapV = vo.CLAMP_ADDRESSMODE, p._generateMipMaps = !1), p._texture = p._getEngine().createDynamicTexture(p.video.videoWidth, p.video.videoHeight, p._generateMipMaps, p.samplingMode), p._texture.format = null !== (e = p._format) && void 0 !== e ? e : a.TEXTUREFORMAT_RGBA, p._frameId = -1, p._updateInternalTexture() }, p._createInternalTexture = function () { if (null != p._texture) { if (!p._displayingPosterTexture) return; p._displayingPosterTexture = !1 } if (p.video.addEventListener("resize", p._resizeInternalTexture), p._resizeInternalTexture(), p.video.autoplay || p._settings.poster || p._settings.independentVideoSource) p._updateInternalTexture(), p.onLoadObservable.hasObservers() && p.onLoadObservable.notifyObservers(p); else { var e = p.video.onplaying, t = p.video.muted; p.video.muted = !0, p.video.onplaying = function () { p.video.muted = t, p.video.onplaying = e, p._updateInternalTexture(), p._errorFound || p.video.pause(), p.onLoadObservable.hasObservers() && p.onLoadObservable.notifyObservers(p) }, p._handlePlay() } }, p._reset = function () { null != p._texture && (p._displayingPosterTexture || (p._texture.dispose(), p._texture = null)) }, p._updateInternalTexture = function () { if (null != p._texture && !(p.video.readyState < p.video.HAVE_CURRENT_DATA || p._displayingPosterTexture)) { var e = p.getScene().getFrameId(); p._frameId !== e && (p._frameId = e, p._getEngine().updateVideoTexture(p._texture, p._externalTexture ? p._externalTexture : p.video, p._invertY)) } }, p._settings = H({ autoPlay: !0, loop: !0, autoUpdateTexture: !0 }, l), p._onError = c, p._generateMipMaps = n, p._initialSamplingMode = s, p.autoUpdateTexture = p._settings.autoUpdateTexture, p._currentSrc = i, p.name = t || p._getName(i), p.video = p._getVideo(i), p._externalTexture = null !== (d = null === (h = p._engine) || void 0 === h ? void 0 : h.createExternalTexture(p.video)) && void 0 !== d ? d : null, p._settings.independentVideoSource || (p._settings.poster && (p.video.poster = p._settings.poster), void 0 !== p._settings.autoPlay && (p.video.autoplay = p._settings.autoPlay), void 0 !== p._settings.loop && (p.video.loop = p._settings.loop), void 0 !== p._settings.muted && (p.video.muted = p._settings.muted), p.video.setAttribute("playsinline", ""), p.video.addEventListener("paused", p._updateInternalTexture), p.video.addEventListener("seeked", p._updateInternalTexture), p.video.addEventListener("emptied", p._reset), p._settings.autoPlay && p._handlePlay()), p._createInternalTextureOnEvent = p._settings.poster && !p._settings.autoPlay ? "play" : "canplay", p.video.addEventListener(p._createInternalTextureOnEvent, p._createInternalTexture), p._format = u; var f = p.video.readyState >= 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 xi.SetCorsBehavior(e.currentSrc, e), e; var t = document.createElement("video"); return "string" == typeof e ? (xi.SetCorsBehavior(e, t), t.src = e) : (xi.SetCorsBehavior(e[0], t), e.forEach((function (e) { var i = document.createElement("source"); i.src = e, t.appendChild(i) }))), this.onDisposeObservable.addOnce((function () { Mm(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())) }, 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 () { Mm(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) })) }, t }(vo), Dm = 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 Om((this.name || "videoDome") + "_texture", e, t, i.generateMipMaps, this._useDirectMapping, vo.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() }), Ji.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 = __.MODE_MONOSCOPIC, t.MODE_TOPBOTTOM = __.MODE_TOPBOTTOM, t.MODE_SIDEBYSIDE = __.MODE_SIDEBYSIDE, t }(__), Nm = function () { function e(e) { this.engine = e, this._captureGPUFrameTime = !1, this._captureShaderCompilationTime = !1, this._shaderCompilationTime = new mr, 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 }(), Fm = function () { function e(e) { var t = this; this.scene = e, this._captureActiveMeshesEvaluationTime = !1, this._activeMeshesEvaluationTime = new mr, this._captureRenderTargetsRenderTime = !1, this._renderTargetsRenderTime = new mr, this._captureFrameTime = !1, this._frameTime = new mr, this._captureRenderTime = !1, this._renderTime = new mr, this._captureInterFrameTime = !1, this._interFrameTime = new mr, this._captureParticlesRenderTime = !1, this._particlesRenderTime = new mr, this._captureSpritesRenderTime = !1, this._spritesRenderTime = new mr, this._capturePhysicsTime = !1, this._physicsTime = new mr, this._captureAnimationsTime = !1, this._animationsTime = new mr, this._captureCameraRenderTime = !1, this._cameraRenderTime = new mr, 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 && (xi.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 && (xi.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 () { xi.StartPerformanceCounter("Active meshes evaluation"), t._activeMeshesEvaluationTime.beginMonitoring() })), this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add((function () { xi.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 () { xi.StartPerformanceCounter("Render targets rendering"), t._renderTargetsRenderTime.beginMonitoring() })), this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add((function () { xi.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 () { xi.StartPerformanceCounter("Particles"), t._particlesRenderTime.beginMonitoring() })), this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add((function () { xi.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 () { xi.StartPerformanceCounter("Sprites"), t._spritesRenderTime.beginMonitoring() })), this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add((function () { xi.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 () { xi.StartPerformanceCounter("Physics"), t._physicsTime.beginMonitoring() })), this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add((function () { xi.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(), xi.StartPerformanceCounter("Main render") })), this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add((function () { t._renderTime.endMonitoring(!1), xi.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(), xi.StartPerformanceCounter("Rendering camera ".concat(e.name)) })), this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add((function (e) { t._cameraRenderTime.endMonitoring(!1), xi.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 }(); Ut.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 4 && (c.push(Hi.MatricesIndicesExtraKind), c.push(Hi.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"), zn.PrepareAttributesForMorphTargetsInfluencers(c, o, y)), t && (l.push("#define INSTANCES"), zn.PushAttributesForInstances(c), e.getRenderingMesh().hasThinInstances && l.push("#define THIN_INSTANCES")), Bn(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"]; wn(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 < this._postProcesses.length; e++)if (!this._postProcesses[e].isReady()) return; var t = this._scene.getEngine(), i = this._numInternalDraws(), r = !0; for (e = 0; e < i; ++e)(o = this._mergeDrawWrapper[e]) || (o = this._mergeDrawWrapper[e] = new Jt(this._engine)).setEffect(this._createMergeEffect()), r = r && o.effect.isReady(); if (r) { this.onBeforeComposeObservable.notifyObservers(this); var n = t.getAlphaMode(); for (e = 0; e < i; ++e) { var o = this._mergeDrawWrapper[e]; t.enableEffect(o), t.setState(!1), t.bindBuffers(this._vertexBuffers, this._indexBuffer, o.effect), t.setAlphaMode(this._effectLayerOptions.alphaBlendingMode), this._internalRender(o.effect, e) } t.setAlphaMode(n), this.onAfterComposeObservable.notifyObservers(this); var a = this._mainTexture.getSize(); this._setMainTextureSize(), a.width === this._mainTextureDesiredSize.width && a.height === this._mainTextureDesiredSize.height || 0 === this._mainTextureDesiredSize.width || 0 === this._mainTextureDesiredSize.height || (this.onSizeChangedObservable.notifyObservers(this), this._disposeTextureAndPostProcesses(), this._createMainTexture(), this._createTextureAndPostProcesses()) } }, e.prototype.hasMesh = function (e) { return -1 === this.renderingGroupId || e.renderingGroupId === this.renderingGroupId }, e.prototype.shouldRender = function () { return this.isEnabled && this._shouldRender }, e.prototype._shouldRenderMesh = function (e) { return !0 }, e.prototype._canRenderMesh = function (e, t) { return !t.needAlphaBlendingForMesh(e) }, e.prototype._shouldRenderEmissiveTextureForMesh = function () { return !0 }, e.prototype._renderSubMesh = function (e, t) { var i, r; if (void 0 === t && (t = !1), this.shouldRender()) { var n = e.getMaterial(), o = e.getMesh(), a = e.getReplacementMesh(), s = e.getRenderingMesh(), l = e.getEffectiveMesh(), c = this._scene, u = c.getEngine(); if (l._internalAbstractMeshDataInfo._isActiveIntermediate = !1, n && this._canRenderMesh(s, n)) { var h = null !== (i = s.overrideMaterialSideOrientation) && void 0 !== i ? i : n.sideOrientation; l._getWorldMatrixDeterminant() < 0 && (h = h === Hn.ClockWiseSideOrientation ? Hn.CounterClockWiseSideOrientation : Hn.ClockWiseSideOrientation); var d = h === Hn.ClockWiseSideOrientation; u.setState(n.backFaceCulling, n.zOffset, void 0, d, n.cullBackFaces, void 0, n.zOffsetUnits); var p = s._getInstancesRenderList(e._id, !!a); if (!p.mustReturn && this._shouldRenderMesh(s)) { var f = p.hardwareInstancedRendering[e._id] || s.hasThinInstances; if (this._setEmissiveTextureAndColor(s, e, n), this.onBeforeRenderMeshToEffect.notifyObservers(o), this._useMeshMaterial(s)) s.render(e, t, a || void 0); else if (this._isReady(e, f, this._emissiveTextureAndColor.texture)) { var _ = null === (r = l._internalAbstractMeshDataInfo._materialForRenderPass) || void 0 === r ? void 0 : r[u.currentRenderPassId], m = e._getDrawWrapper(); if (!m && _ && (m = _._getDrawWrapper()), !m) return; var g = m.effect; if (u.enableEffect(m), f || s._bind(e, g, n.fillMode), _ ? _.bindForSubMesh(l.getWorldMatrix(), l, e) : (g.setMatrix("viewProjection", c.getTransformMatrix()), g.setMatrix("world", l.getWorldMatrix()), g.setFloat4("glowColor", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a)), !_) { var v = n.needAlphaTesting(), y = n.getAlphaTestTexture(), b = y && y.hasAlpha && (n.useAlphaFromDiffuseTexture || n._useAlphaFromAlbedoTexture); y && (v || b) && (g.setTexture("diffuseSampler", y), (T = y.getTextureMatrix()) && g.setMatrix("diffuseMatrix", T)); var T, E = n.opacityTexture; if (E && (g.setTexture("opacitySampler", E), g.setFloat("opacityIntensity", E.level), (T = E.getTextureMatrix()) && g.setMatrix("opacityMatrix", T)), this._emissiveTextureAndColor.texture && (g.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture), g.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix())), s.useBones && s.computeBonesUsingShaders && s.skeleton) { var S = s.skeleton; if (S.isUsingTextureForMatrices) { var x = S.getTransformMatrixTexture(s); if (!x) return; g.setTexture("boneSampler", x), g.setFloat("boneTextureWidth", 4 * (S.bones.length + 1)) } else g.setMatrices("mBones", S.getTransformMatrices(s)) } zn.BindMorphTargetParameters(s, g), s.morphTargetManager && s.morphTargetManager.isUsingTextureForTargets && s.morphTargetManager._bind(g), t && u.setAlphaMode(n.alphaMode), g.setFloat("glowIntensity", this.getEffectIntensity(s)), Vn(g, n, c) } s._processRendering(l, e, g, n.fillMode, p, f, (function (e, t) { return g.setMatrix("world", t) })) } else this._mainTexture.resetRefreshCounter(); this.onAfterRenderMeshToEffect.notifyObservers(o) } } } }, e.prototype._useMeshMaterial = function (e) { return !1 }, e.prototype._rebuild = function () { var e = this._vertexBuffers[Hi.PositionKind]; e && e._rebuild(), this._generateIndexBuffer() }, e.prototype._disposeTextureAndPostProcesses = function () { this._mainTexture.dispose(); for (var e = 0; e < this._postProcesses.length; e++)this._postProcesses[e] && this._postProcesses[e].dispose(); for (this._postProcesses = [], e = 0; e < this._textures.length; e++)this._textures[e] && this._textures[e].dispose(); this._textures = [] }, e.prototype.dispose = function () { var e = this._vertexBuffers[Hi.PositionKind]; e && (e.dispose(), this._vertexBuffers[Hi.PositionKind] = null), this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer), this._indexBuffer = null); for (var t = 0, i = this._mergeDrawWrapper; t < i.length; t++)i[t].dispose(); this._mergeDrawWrapper = [], this._disposeTextureAndPostProcesses(); var r = this._scene.effectLayers.indexOf(this, 0); r > -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 xi.Instantiate(e.customType).Parse(e, t, i) }, e._SceneComponentInitialization = function (e) { throw ge("EffectLayerSceneComponent") }, X([xe()], e.prototype, "name", void 0), X([De()], e.prototype, "neutralColor", void 0), X([xe()], e.prototype, "isEnabled", void 0), X([we()], e.prototype, "camera", null), X([xe()], e.prototype, "renderingGroupId", null), X([xe()], e.prototype, "disableBoundingBoxesFromEffectLayer", void 0), e }(); o.AddParser(qi.NAME_EFFECTLAYER, (function (e, t, i, r) { if (e.effectLayers) { i.effectLayers || (i.effectLayers = new Array); for (var n = 0; n < e.effectLayers.length; n++) { var o = Lm.Parse(e.effectLayers[n], t, r); i.effectLayers.push(o) } } })), o.prototype.removeEffectLayer = function (e) { var t = this.effectLayers.indexOf(e); return -1 !== t && this.effectLayers.splice(t, 1), t }, o.prototype.addEffectLayer = function (e) { this.effectLayers.push(e) }; var wm = function () { function e(e) { this.name = qi.NAME_EFFECTLAYER, this._renderEffects = !1, this._needStencil = !1, this._previousStencilState = !1, this.scene = e || S.LastCreatedScene, this.scene && (this._engine = this.scene.getEngine(), this.scene.effectLayers = new Array) } return e.prototype.register = function () { this.scene._isReadyForMeshStage.registerStep(qi.STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh), this.scene._cameraDrawRenderTargetStage.registerStep(qi.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture), this.scene._beforeCameraDrawStage.registerStep(qi.STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil), this.scene._afterRenderingGroupDrawStage.registerStep(qi.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup), this.scene._afterCameraDrawStage.registerStep(qi.STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack), this.scene._afterCameraDrawStage.registerStep(qi.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW, this, this._drawCamera) }, e.prototype.rebuild = function () { for (var e = 0, t = this.scene.effectLayers; e < t.length; e++)t[e]._rebuild() }, e.prototype.serialize = function (e) { e.effectLayers = []; for (var t = 0, i = this.scene.effectLayers; t < i.length; t++) { var r = i[t]; r.serialize && e.effectLayers.push(r.serialize()) } }, e.prototype.addFromContainer = function (e) { var t = this; e.effectLayers && e.effectLayers.forEach((function (e) { t.scene.addEffectLayer(e) })) }, e.prototype.removeFromContainer = function (e, t) { var i = this; e.effectLayers && e.effectLayers.forEach((function (e) { i.scene.removeEffectLayer(e), t && e.dispose() })) }, e.prototype.dispose = function () { for (var e = this.scene.effectLayers; e.length;)e[0].dispose() }, e.prototype._isReadyForMesh = function (e, t) { for (var i = this._engine.currentRenderPassId, r = 0, n = this.scene.effectLayers; r < n.length; r++) { var o = n[r]; if (o.hasMesh(e)) { var a = o._mainTexture; this._engine.currentRenderPassId = a.renderPassId; for (var s = 0, l = e.subMeshes; s < l.length; s++) { var c = l[s]; if (!o.isReady(c, t)) return this._engine.currentRenderPassId = i, !1 } } } return this._engine.currentRenderPassId = i, !0 }, e.prototype._renderMainTexture = function (e) { this._renderEffects = !1, this._needStencil = !1; var t = !1, i = this.scene.effectLayers; if (i && i.length > 0) { this._previousStencilState = this._engine.getStencilBuffer(); for (var r = 0, n = i; r < n.length; r++) { var o = n[r]; if (o.shouldRender() && (!o.camera || o.camera.cameraRigMode === ln.RIG_MODE_NONE && e === o.camera || o.camera.cameraRigMode !== ln.RIG_MODE_NONE && o.camera._rigCameras.indexOf(e) > -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 < t.length; i++) { var r = t[i]; r.renderingGroupId === e && r.shouldRender() && r.render() } this._engine.setDepthBuffer(!0) } }, e.prototype._drawCamera = function () { this._renderEffects && this._draw(-1) }, e.prototype._drawRenderingGroup = function (e) { !this.scene._isInIntermediateRendering() && this._renderEffects && this._draw(e) }, e }(); Lm._SceneComponentInitialization = function (e) { var t = e._getComponent(qi.NAME_EFFECTLAYER); t || (t = new wm(e), e._addComponent(t)) }; Ut.ShadersStore.glowMapMergePixelShader = "varying vec2 vUV;uniform sampler2D textureSampler;\n#ifdef EMISSIVE\nuniform sampler2D textureSampler2;\n#endif\nuniform float offset;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec4 baseColor=texture2D(textureSampler,vUV);\n#ifdef EMISSIVE\nbaseColor+=texture2D(textureSampler2,vUV);baseColor*=offset;\n#else\nbaseColor.a=abs(offset-baseColor.a);\n#ifdef STROKE\nfloat alpha=smoothstep(.0,.1,baseColor.a);baseColor.a=alpha;baseColor.rgb=baseColor.rgb*alpha;\n#endif\n#endif\n#if LDR\nbaseColor=clamp(baseColor,0.,1.0);\n#endif\ngl_FragColor=baseColor;\n#define CUSTOM_FRAGMENT_MAIN_END\n}"; Ut.ShadersStore.glowMapMergeVertexShader = "attribute vec2 position;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=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}", o.prototype.getGlowLayerByName = function (e) { for (var t, i = 0; i < (null === (t = this.effectLayers) || void 0 === t ? void 0 : t.length); i++)if (this.effectLayers[i].name === e && this.effectLayers[i].getEffectName() === Bm.EffectName) return this.effectLayers[i]; return null }; var Bm = function (e) { function t(i, r, n) { var o = e.call(this, i, r) || this; return o._intensity = 1, o._includedOnlyMeshes = [], o._excludedMeshes = [], o._meshesUsingTheirOwnMaterials = [], o.neutralColor = new U(0, 0, 0, 1), o._options = H({ mainTextureRatio: t.DefaultTextureRatio, blurKernelSize: 32, mainTextureFixedSize: void 0, camera: null, mainTextureSamples: 1, renderingGroupId: -1, ldrMerge: !1, alphaBlendingMode: a.ALPHA_ADD, mainTextureType: a.TEXTURETYPE_UNSIGNED_INT, generateStencilBuffer: !1 }, n), o._init({ alphaBlendingMode: o._options.alphaBlendingMode, camera: o._options.camera, mainTextureFixedSize: o._options.mainTextureFixedSize, mainTextureRatio: o._options.mainTextureRatio, renderingGroupId: o._options.renderingGroupId, mainTextureType: o._options.mainTextureType, generateStencilBuffer: o._options.generateStencilBuffer }), o } return W(t, e), Object.defineProperty(t.prototype, "blurKernelSize", { get: function () { return this._options.blurKernelSize }, set: function (e) { if (e !== this._options.blurKernelSize) { this._options.blurKernelSize = e; var t = this._getEffectiveBlurKernelSize(); this._horizontalBlurPostprocess1.kernel = t, this._verticalBlurPostprocess1.kernel = t, this._horizontalBlurPostprocess2.kernel = t, this._verticalBlurPostprocess2.kernel = t } }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "intensity", { get: function () { return this._intensity }, set: function (e) { this._intensity = e }, enumerable: !1, configurable: !0 }), t.prototype.getEffectName = function () { return t.EffectName }, t.prototype._createMergeEffect = function () { var e = "#define EMISSIVE \n"; return this._options.ldrMerge && (e += "#define LDR \n"), this._engine.createEffect("glowMapMerge", [Hi.PositionKind], ["offset"], ["textureSampler", "textureSampler2"], e) }, t.prototype._createTextureAndPostProcesses = function () { var e = this, t = this._mainTextureDesiredSize.width, i = this._mainTextureDesiredSize.height; t = this._engine.needPOTTextures ? In.GetExponentOfTwo(t, this._maxSize) : t, i = this._engine.needPOTTextures ? In.GetExponentOfTwo(i, this._maxSize) : i; var r; r = this._engine.getCaps().textureHalfFloatRender ? a.TEXTURETYPE_HALF_FLOAT : a.TEXTURETYPE_UNSIGNED_INT, this._blurTexture1 = new es("GlowLayerBlurRTT", { width: t, height: i }, this._scene, !1, !0, r), this._blurTexture1.wrapU = vo.CLAMP_ADDRESSMODE, this._blurTexture1.wrapV = vo.CLAMP_ADDRESSMODE, this._blurTexture1.updateSamplingMode(vo.BILINEAR_SAMPLINGMODE), this._blurTexture1.renderParticles = !1, this._blurTexture1.ignoreCameraViewport = !0; var n = Math.floor(t / 2), o = Math.floor(i / 2); this._blurTexture2 = new es("GlowLayerBlurRTT2", { width: n, height: o }, this._scene, !1, !0, r), this._blurTexture2.wrapU = vo.CLAMP_ADDRESSMODE, this._blurTexture2.wrapV = vo.CLAMP_ADDRESSMODE, this._blurTexture2.updateSamplingMode(vo.BILINEAR_SAMPLINGMODE), this._blurTexture2.renderParticles = !1, this._blurTexture2.ignoreCameraViewport = !0, this._textures = [this._blurTexture1, this._blurTexture2]; var s = this._getEffectiveBlurKernelSize(); this._horizontalBlurPostprocess1 = new c_("GlowLayerHBP1", new A(1, 0), s, { width: t, height: i }, null, vo.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, r), this._horizontalBlurPostprocess1.width = t, this._horizontalBlurPostprocess1.height = i, this._horizontalBlurPostprocess1.externalTextureSamplerBinding = !0, this._horizontalBlurPostprocess1.onApplyObservable.add((function (t) { t.setTexture("textureSampler", e._mainTexture) })), this._verticalBlurPostprocess1 = new c_("GlowLayerVBP1", new A(0, 1), s, { width: t, height: i }, null, vo.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, r), this._horizontalBlurPostprocess2 = new c_("GlowLayerHBP2", new A(1, 0), s, { width: n, height: o }, null, vo.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, r), this._horizontalBlurPostprocess2.width = n, this._horizontalBlurPostprocess2.height = o, this._horizontalBlurPostprocess2.externalTextureSamplerBinding = !0, this._horizontalBlurPostprocess2.onApplyObservable.add((function (t) { t.setTexture("textureSampler", e._blurTexture1) })), this._verticalBlurPostprocess2 = new c_("GlowLayerVBP2", new A(0, 1), s, { width: n, height: o }, null, vo.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, r), this._postProcesses = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1, this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2], this._postProcesses1 = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1], this._postProcesses2 = [this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2], this._mainTexture.samples = this._options.mainTextureSamples, this._mainTexture.onAfterUnbindObservable.add((function () { var t = e._blurTexture1.renderTarget; if (t) { e._scene.postProcessManager.directRender(e._postProcesses1, t, !0); var i = e._blurTexture2.renderTarget; i && e._scene.postProcessManager.directRender(e._postProcesses2, i, !0), e._engine.unBindFramebuffer(null != i ? i : t, !0) } })), this._postProcesses.map((function (e) { e.autoClear = !1 })) }, t.prototype._getEffectiveBlurKernelSize = function () { return this._options.blurKernelSize / 2 }, t.prototype.isReady = function (t, i) { var r = t.getMaterial(), n = t.getRenderingMesh(); if (!r || !n) return !1; var o = r.emissiveTexture; return e.prototype._isReady.call(this, t, i, o) }, t.prototype.needStencil = function () { return !1 }, t.prototype._canRenderMesh = function (e, t) { return !0 }, t.prototype._internalRender = function (e) { e.setTexture("textureSampler", this._blurTexture1), e.setTexture("textureSampler2", this._blurTexture2), e.setFloat("offset", this._intensity); var t = this._engine, i = t.getStencilBuffer(); t.setStencilBuffer(!1), t.drawElementsType(Hn.TriangleFillMode, 0, 6), t.setStencilBuffer(i) }, t.prototype._setEmissiveTextureAndColor = function (e, t, i) { var r, n = 1; this.customEmissiveTextureSelector ? this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(e, t, i) : i ? (this._emissiveTextureAndColor.texture = i.emissiveTexture, this._emissiveTextureAndColor.texture && (n = this._emissiveTextureAndColor.texture.level)) : this._emissiveTextureAndColor.texture = null, this.customEmissiveColorSelector ? this.customEmissiveColorSelector(e, t, i, this._emissiveTextureAndColor.color) : i.emissiveColor ? (n *= null !== (r = i.emissiveIntensity) && void 0 !== r ? r : 1, this._emissiveTextureAndColor.color.set(i.emissiveColor.r * n, i.emissiveColor.g * n, i.emissiveColor.b * n, i.alpha)) : this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a) }, t.prototype._shouldRenderMesh = function (e) { return this.hasMesh(e) }, t.prototype._addCustomEffectDefines = function (e) { e.push("#define GLOW") }, t.prototype.addExcludedMesh = function (e) { -1 === this._excludedMeshes.indexOf(e.uniqueId) && this._excludedMeshes.push(e.uniqueId) }, t.prototype.removeExcludedMesh = function (e) { var t = this._excludedMeshes.indexOf(e.uniqueId); -1 !== t && this._excludedMeshes.splice(t, 1) }, t.prototype.addIncludedOnlyMesh = function (e) { -1 === this._includedOnlyMeshes.indexOf(e.uniqueId) && this._includedOnlyMeshes.push(e.uniqueId) }, t.prototype.removeIncludedOnlyMesh = function (e) { var t = this._includedOnlyMeshes.indexOf(e.uniqueId); -1 !== t && this._includedOnlyMeshes.splice(t, 1) }, t.prototype.hasMesh = function (t) { return !!e.prototype.hasMesh.call(this, t) && (this._includedOnlyMeshes.length ? -1 !== this._includedOnlyMeshes.indexOf(t.uniqueId) : !this._excludedMeshes.length || -1 === this._excludedMeshes.indexOf(t.uniqueId)) }, t.prototype._useMeshMaterial = function (e) { return 0 != this._meshesUsingTheirOwnMaterials.length && this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId) > -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 = Ue.Serialize(this); if (t.customType = "BABYLON.GlowLayer", t.includedMeshes = [], this._includedOnlyMeshes.length) for (e = 0; e < this._includedOnlyMeshes.length; e++)(i = this._scene.getMeshByUniqueId(this._includedOnlyMeshes[e])) && t.includedMeshes.push(i.id); if (t.excludedMeshes = [], this._excludedMeshes.length) for (e = 0; e < this._excludedMeshes.length; e++) { var i; (i = this._scene.getMeshByUniqueId(this._excludedMeshes[e])) && t.excludedMeshes.push(i.id) } return t }, t.Parse = function (e, i, r) { var n, o = Ue.Parse((function () { return new t(e.name, i, e.options) }), e, i, r); for (n = 0; n < e.excludedMeshes.length; n++)(a = i.getMeshById(e.excludedMeshes[n])) && o.addExcludedMesh(a); for (n = 0; n < e.includedMeshes.length; n++) { var a; (a = i.getMeshById(e.includedMeshes[n])) && o.addIncludedOnlyMesh(a) } return o }, t.EffectName = "GlowLayer", t.DefaultBlurKernelSize = 32, t.DefaultTextureRatio = .5, X([xe()], t.prototype, "blurKernelSize", null), X([xe()], t.prototype, "intensity", null), X([xe("options")], t.prototype, "_options", void 0), t }(Lm); b("BABYLON.GlowLayer", Bm); Ut.ShadersStore.glowBlurPostProcessPixelShader = "varying vec2 vUV;uniform sampler2D textureSampler;uniform vec2 screenSize;uniform vec2 direction;uniform float blurWidth;float getLuminance(vec3 color)\n{return dot(color,vec3(0.2126,0.7152,0.0722));}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{float weights[7];weights[0]=0.05;weights[1]=0.1;weights[2]=0.2;weights[3]=0.3;weights[4]=0.2;weights[5]=0.1;weights[6]=0.05;vec2 texelSize=vec2(1.0/screenSize.x,1.0/screenSize.y);vec2 texelStep=texelSize*direction*blurWidth;vec2 start=vUV-3.0*texelStep;vec4 baseColor=vec4(0.,0.,0.,0.);vec2 texelOffset=vec2(0.,0.);for (int i=0; i<7; i++)\n{vec4 texel=texture2D(textureSampler,start+texelOffset);baseColor.a+=texel.a*weights[i];float luminance=getLuminance(baseColor.rgb);float luminanceTexel=getLuminance(texel.rgb);float choice=step(luminanceTexel,luminance);baseColor.rgb=choice*baseColor.rgb+(1.0-choice)*texel.rgb;texelOffset+=texelStep;}\ngl_FragColor=baseColor;}", o.prototype.getHighlightLayerByName = function (e) { for (var t, i = 0; i < (null === (t = this.effectLayers) || void 0 === t ? void 0 : t.length); i++)if (this.effectLayers[i].name === e && this.effectLayers[i].getEffectName() === Vm.EffectName) return this.effectLayers[i]; return null }; var Um = function (e) { function t(t, i, r, n, o, a, s, l) { void 0 === a && (a = vo.BILINEAR_SAMPLINGMODE); var c = e.call(this, t, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, n, o, a, s, l) || this; return c.direction = i, c.kernel = r, c.onApplyObservable.add((function (e) { e.setFloat2("screenSize", c.width, c.height), e.setVector2("direction", c.direction), e.setFloat("blurWidth", c.kernel) })), c } return W(t, e), t }(Ia), Vm = function (e) { function t(i, r, n) { var o = e.call(this, i, r) || this; return o.name = i, o.innerGlow = !0, o.outerGlow = !0, o.onBeforeBlurObservable = new u, o.onAfterBlurObservable = new u, o._instanceGlowingMeshStencilReference = t.GlowingMeshStencilReference++, o._meshes = {}, o._excludedMeshes = {}, o.neutralColor = t.NeutralColor, o._engine.isStencilEnable || $.Warn("Rendering the Highlight Layer requires the stencil to be active on the canvas. var engine = new Engine(canvas, antialias, { stencil: true }"), o._options = H({ mainTextureRatio: .5, blurTextureSizeRatio: .5, blurHorizontalSize: 1, blurVerticalSize: 1, alphaBlendingMode: a.ALPHA_COMBINE, camera: null, renderingGroupId: -1, mainTextureType: a.TEXTURETYPE_UNSIGNED_INT }, n), o._init({ alphaBlendingMode: o._options.alphaBlendingMode, camera: o._options.camera, mainTextureFixedSize: o._options.mainTextureFixedSize, mainTextureRatio: o._options.mainTextureRatio, renderingGroupId: o._options.renderingGroupId, mainTextureType: o._options.mainTextureType }), o._shouldRender = !1, o } return W(t, e), Object.defineProperty(t.prototype, "blurHorizontalSize", { get: function () { return this._horizontalBlurPostprocess.kernel }, set: function (e) { this._horizontalBlurPostprocess.kernel = e, this._options.blurHorizontalSize = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "blurVerticalSize", { get: function () { return this._verticalBlurPostprocess.kernel }, set: function (e) { this._verticalBlurPostprocess.kernel = e, this._options.blurVerticalSize = e }, enumerable: !1, configurable: !0 }), t.prototype.getEffectName = function () { return t.EffectName }, t.prototype._numInternalDraws = function () { return 2 }, t.prototype._createMergeEffect = function () { return this._engine.createEffect("glowMapMerge", [Hi.PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? "#define STROKE \n" : void 0) }, t.prototype._createTextureAndPostProcesses = function () { var e = this, t = this._mainTextureDesiredSize.width * this._options.blurTextureSizeRatio, i = this._mainTextureDesiredSize.height * this._options.blurTextureSizeRatio; t = this._engine.needPOTTextures ? In.GetExponentOfTwo(t, this._maxSize) : t, i = this._engine.needPOTTextures ? In.GetExponentOfTwo(i, this._maxSize) : i; var r; r = this._engine.getCaps().textureHalfFloatRender ? a.TEXTURETYPE_HALF_FLOAT : a.TEXTURETYPE_UNSIGNED_INT, this._blurTexture = new es("HighlightLayerBlurRTT", { width: t, height: i }, this._scene, !1, !0, r), this._blurTexture.wrapU = vo.CLAMP_ADDRESSMODE, this._blurTexture.wrapV = vo.CLAMP_ADDRESSMODE, this._blurTexture.anisotropicFilteringLevel = 16, this._blurTexture.updateSamplingMode(vo.TRILINEAR_SAMPLINGMODE), this._blurTexture.renderParticles = !1, this._blurTexture.ignoreCameraViewport = !0, this._textures = [this._blurTexture], this._options.alphaBlendingMode === a.ALPHA_COMBINE ? (this._downSamplePostprocess = new xl("HighlightLayerPPP", this._options.blurTextureSizeRatio, null, vo.BILINEAR_SAMPLINGMODE, this._scene.getEngine()), this._downSamplePostprocess.externalTextureSamplerBinding = !0, this._downSamplePostprocess.onApplyObservable.add((function (t) { t.setTexture("textureSampler", e._mainTexture) })), this._horizontalBlurPostprocess = new Um("HighlightLayerHBP", new A(1, 0), this._options.blurHorizontalSize, 1, null, vo.BILINEAR_SAMPLINGMODE, this._scene.getEngine()), this._horizontalBlurPostprocess.onApplyObservable.add((function (e) { e.setFloat2("screenSize", t, i) })), this._verticalBlurPostprocess = new Um("HighlightLayerVBP", new A(0, 1), this._options.blurVerticalSize, 1, null, vo.BILINEAR_SAMPLINGMODE, this._scene.getEngine()), this._verticalBlurPostprocess.onApplyObservable.add((function (e) { e.setFloat2("screenSize", t, i) })), this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess]) : (this._horizontalBlurPostprocess = new c_("HighlightLayerHBP", new A(1, 0), this._options.blurHorizontalSize / 2, { width: t, height: i }, null, vo.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, r), this._horizontalBlurPostprocess.width = t, this._horizontalBlurPostprocess.height = i, this._horizontalBlurPostprocess.externalTextureSamplerBinding = !0, this._horizontalBlurPostprocess.onApplyObservable.add((function (t) { t.setTexture("textureSampler", e._mainTexture) })), this._verticalBlurPostprocess = new c_("HighlightLayerVBP", new A(0, 1), this._options.blurVerticalSize / 2, { width: t, height: i }, null, vo.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, r), this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess]), this._mainTexture.onAfterUnbindObservable.add((function () { e.onBeforeBlurObservable.notifyObservers(e); var t = e._blurTexture.renderTarget; t && (e._scene.postProcessManager.directRender(e._postProcesses, t, !0), e._engine.unBindFramebuffer(t, !0)), e.onAfterBlurObservable.notifyObservers(e) })), this._postProcesses.map((function (e) { e.autoClear = !1 })) }, t.prototype.needStencil = function () { return !0 }, t.prototype.isReady = function (t, i) { var r = t.getMaterial(), n = t.getRenderingMesh(); if (!r || !n || !this._meshes) return !1; var o = null, a = this._meshes[n.uniqueId]; return a && a.glowEmissiveOnly && r && (o = r.emissiveTexture), e.prototype._isReady.call(this, t, i, o) }, t.prototype._internalRender = function (e, t) { e.setTexture("textureSampler", this._blurTexture); var i = this._engine; i.cacheStencilState(), i.setStencilOperationPass(a.REPLACE), i.setStencilOperationFail(a.KEEP), i.setStencilOperationDepthFail(a.KEEP), i.setStencilMask(0), i.setStencilBuffer(!0), i.setStencilFunctionReference(this._instanceGlowingMeshStencilReference), this.outerGlow && 0 === t && (e.setFloat("offset", 0), i.setStencilFunction(a.NOTEQUAL), i.drawElementsType(Hn.TriangleFillMode, 0, 6)), this.innerGlow && 1 === t && (e.setFloat("offset", 1), i.setStencilFunction(a.EQUAL), i.drawElementsType(Hn.TriangleFillMode, 0, 6)), i.restoreStencilState() }, t.prototype.shouldRender = function () { return !!e.prototype.shouldRender.call(this) && !!this._meshes }, t.prototype._shouldRenderMesh = function (t) { return !(this._excludedMeshes && this._excludedMeshes[t.uniqueId] || !e.prototype.hasMesh.call(this, t)) }, t.prototype._canRenderMesh = function (e, t) { return !0 }, t.prototype._addCustomEffectDefines = function (e) { e.push("#define HIGHLIGHT") }, t.prototype._setEmissiveTextureAndColor = function (e, t, i) { var r = this._meshes[e.uniqueId]; r ? this._emissiveTextureAndColor.color.set(r.color.r, r.color.g, r.color.b, 1) : this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a), r && r.glowEmissiveOnly && i ? (this._emissiveTextureAndColor.texture = i.emissiveTexture, this._emissiveTextureAndColor.color.set(1, 1, 1, 1)) : this._emissiveTextureAndColor.texture = null }, t.prototype.addExcludedMesh = function (e) { if (this._excludedMeshes && !this._excludedMeshes[e.uniqueId]) { var t = { mesh: e, beforeBind: null, afterRender: null, stencilState: !1 }; t.beforeBind = e.onBeforeBindObservable.add((function (e) { t.stencilState = e.getEngine().getStencilBuffer(), e.getEngine().setStencilBuffer(!1) })), t.afterRender = e.onAfterRenderObservable.add((function (e) { e.getEngine().setStencilBuffer(t.stencilState) })), this._excludedMeshes[e.uniqueId] = t } }, t.prototype.removeExcludedMesh = function (e) { if (this._excludedMeshes) { var t = this._excludedMeshes[e.uniqueId]; t && (t.beforeBind && e.onBeforeBindObservable.remove(t.beforeBind), t.afterRender && e.onAfterRenderObservable.remove(t.afterRender)), this._excludedMeshes[e.uniqueId] = null } }, t.prototype.hasMesh = function (t) { return !!this._meshes && !!e.prototype.hasMesh.call(this, t) && void 0 !== this._meshes[t.uniqueId] && null !== this._meshes[t.uniqueId] }, t.prototype.addMesh = function (e, t, i) { var r = this; if (void 0 === i && (i = !1), this._meshes) { var n = this._meshes[e.uniqueId]; n ? n.color = t : (this._meshes[e.uniqueId] = { mesh: e, color: t, observerHighlight: e.onBeforeBindObservable.add((function (e) { r.isEnabled && (r._excludedMeshes && r._excludedMeshes[e.uniqueId] ? r._defaultStencilReference(e) : e.getScene().getEngine().setStencilFunctionReference(r._instanceGlowingMeshStencilReference)) })), observerDefault: e.onAfterRenderObservable.add((function (e) { r.isEnabled && r._defaultStencilReference(e) })), glowEmissiveOnly: i }, e.onDisposeObservable.add((function () { r._disposeMesh(e) }))), this._shouldRender = !0 } }, t.prototype.removeMesh = function (e) { if (this._meshes) { var t = this._meshes[e.uniqueId]; for (var i in t && (t.observerHighlight && e.onBeforeBindObservable.remove(t.observerHighlight), t.observerDefault && e.onAfterRenderObservable.remove(t.observerDefault), delete this._meshes[e.uniqueId]), this._shouldRender = !1, this._meshes) if (this._meshes[i]) { this._shouldRender = !0; break } } }, t.prototype.removeAllMeshes = function () { if (this._meshes) for (var e in this._meshes) if (Object.prototype.hasOwnProperty.call(this._meshes, e)) { var t = this._meshes[e]; t && this.removeMesh(t.mesh) } }, t.prototype._defaultStencilReference = function (e) { e.getScene().getEngine().setStencilFunctionReference(t.NormalMeshStencilReference) }, t.prototype._disposeMesh = function (e) { this.removeMesh(e), this.removeExcludedMesh(e) }, t.prototype.dispose = function () { if (this._meshes) { for (var t in this._meshes) (i = this._meshes[t]) && i.mesh && (i.observerHighlight && i.mesh.onBeforeBindObservable.remove(i.observerHighlight), i.observerDefault && i.mesh.onAfterRenderObservable.remove(i.observerDefault)); this._meshes = null } if (this._excludedMeshes) { for (var t in this._excludedMeshes) { var i; (i = this._excludedMeshes[t]) && (i.beforeBind && i.mesh.onBeforeBindObservable.remove(i.beforeBind), i.afterRender && i.mesh.onAfterRenderObservable.remove(i.afterRender)) } this._excludedMeshes = null } e.prototype.dispose.call(this) }, t.prototype.getClassName = function () { return "HighlightLayer" }, t.prototype.serialize = function () { var e = Ue.Serialize(this); if (e.customType = "BABYLON.HighlightLayer", e.meshes = [], this._meshes) for (var t in this._meshes) { var i = this._meshes[t]; i && e.meshes.push({ glowEmissiveOnly: i.glowEmissiveOnly, color: i.color.asArray(), meshId: i.mesh.id }) } if (e.excludedMeshes = [], this._excludedMeshes) for (var r in this._excludedMeshes) { var n = this._excludedMeshes[r]; n && e.excludedMeshes.push(n.mesh.id) } return e }, t.Parse = function (e, i, r) { var n, o = Ue.Parse((function () { return new t(e.name, i, e.options) }), e, i, r); for (n = 0; n < e.excludedMeshes.length; n++)(a = i.getMeshById(e.excludedMeshes[n])) && o.addExcludedMesh(a); for (n = 0; n < e.meshes.length; n++) { var a, s = e.meshes[n]; (a = i.getMeshById(s.meshId)) && o.addMesh(a, B.FromArray(s.color), s.glowEmissiveOnly) } return o }, t.EffectName = "HighlightLayer", t.NeutralColor = new U(0, 0, 0, 0), t.GlowingMeshStencilReference = 2, t.NormalMeshStencilReference = 1, X([xe()], t.prototype, "innerGlow", void 0), X([xe()], t.prototype, "outerGlow", void 0), X([xe()], t.prototype, "blurHorizontalSize", null), X([xe()], t.prototype, "blurVerticalSize", null), X([xe("options")], t.prototype, "_options", void 0), t }(Lm); b("BABYLON.HighlightLayer", Vm); var km = function () { function e(e) { this.name = qi.NAME_LAYER, this.scene = e || S.LastCreatedScene, this.scene && (this._engine = this.scene.getEngine(), this.scene.layers = new Array) } return e.prototype.register = function () { this.scene._beforeCameraDrawStage.registerStep(qi.STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground), this.scene._afterCameraDrawStage.registerStep(qi.STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForegroundWithPostProcessing), this.scene._afterCameraPostProcessStage.registerStep(qi.STEP_AFTERCAMERAPOSTPROCESS_LAYER, this, this._drawCameraForegroundWithoutPostProcessing), this.scene._beforeRenderTargetDrawStage.registerStep(qi.STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground), this.scene._afterRenderTargetDrawStage.registerStep(qi.STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForegroundWithPostProcessing), this.scene._afterRenderTargetPostProcessStage.registerStep(qi.STEP_AFTERRENDERTARGETPOSTPROCESS_LAYER, this, this._drawRenderTargetForegroundWithoutPostProcessing) }, e.prototype.rebuild = function () { for (var e = 0, t = this.scene.layers; e < t.length; e++)t[e]._rebuild() }, e.prototype.dispose = function () { for (var e = this.scene.layers; e.length;)e[0].dispose() }, e.prototype._draw = function (e) { var t = this.scene.layers; if (t.length) { this._engine.setDepthBuffer(!1); for (var i = 0, r = t; i < r.length; i++) { var n = r[i]; e(n) && n.render() } this._engine.setDepthBuffer(!0) } }, e.prototype._drawCameraPredicate = function (e, t, i, r) { return !e.renderOnlyInRenderTargetTextures && e.isBackground === t && e.applyPostProcess === i && 0 != (e.layerMask & r) }, e.prototype._drawCameraBackground = function (e) { var t = this; this._draw((function (i) { return t._drawCameraPredicate(i, !0, !0, e.layerMask) })) }, e.prototype._drawCameraForegroundWithPostProcessing = function (e) { var t = this; this._draw((function (i) { return t._drawCameraPredicate(i, !1, !0, e.layerMask) })) }, e.prototype._drawCameraForegroundWithoutPostProcessing = function (e) { var t = this; this._draw((function (i) { return t._drawCameraPredicate(i, !1, !1, e.layerMask) })) }, e.prototype._drawRenderTargetPredicate = function (e, t, i, r, n) { return e.renderTargetTextures.length > 0 && 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 }(); Ut.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}"; Ut.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 Gm = 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 vo(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(qi.NAME_LAYER); o || (o = new km(this._scene), this._scene._addComponent(o)), this._scene.layers.push(this); var s = this._scene.getEngine(); this._drawWrapper = new Jt(s); var l = []; l.push(1, 1), l.push(-1, 1), l.push(-1, -1), l.push(1, -1); var c = new Hi(s, l, Hi.PositionKind, !1, !1, 2); this._vertexBuffers[Hi.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[Hi.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", [Hi.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(Hn.TriangleFillMode, 0, 6) : (e.setAlphaMode(this.alphaBlendingMode), e.drawElementsType(Hn.TriangleFillMode, 0, 6), e.setAlphaMode(a.ALPHA_DISABLE)), this.onAfterRenderObservable.notifyObservers(this) } } }, e.prototype.dispose = function () { var e = this._vertexBuffers[Hi.PositionKind]; e && (e.dispose(), this._vertexBuffers[Hi.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 }(), zm = 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 vo(r, n.getScene(), !0) : null, this._system = n; var o = n.scene.getEngine(); this._drawWrapper = new Jt(o), this._drawWrapper.effect = o.createEffect("lensFlare", [Hi.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 }(); Ut.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}"; Ut.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 Wm = 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[Hi.PositionKind] = new Hi(n, o, Hi.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._positionX < e.x + e.width && this._positionY > e.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 Mo(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._positionX < this.borderLimit + r.x ? this.borderLimit + r.x - this._positionX : this._positionX > r.x + r.width - this.borderLimit ? this._positionX - r.x - r.width + this.borderLimit : 0) > (t = this._positionY < this.borderLimit + r.y ? this.borderLimit + r.y - this._positionY : this._positionY > r.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; d < this.lensFlares.length; d++) { var p = this.lensFlares[d]; if (p._drawWrapper.effect.isReady() && (!p.texture || p.texture.isReady())) { i.enableEffect(p._drawWrapper), i.bindBuffers(this._vertexBuffers, this._indexBuffer, p._drawWrapper.effect), i.setAlphaMode(p.alphaMode); var f = s - c * p.position, _ = l - u * p.position, m = p.size, g = p.size * i.getAspectRatio(this._scene.activeCamera, !0), v = f / (r.width + 2 * r.x) * 2 - 1, y = 1 - _ / (r.height + 2 * r.y) * 2, b = I.FromValues(m / 2, 0, 0, 0, 0, g / 2, 0, 0, 0, 0, 1, 0, v, y, 0, 1); p._drawWrapper.effect.setMatrix("viewportMatrix", b), p._drawWrapper.effect.setTexture("textureSampler", p.texture), p._drawWrapper.effect.setFloat4("color", p.color.r * o, p.color.g * o, p.color.b * o, 1), i.drawElementsType(Hn.TriangleFillMode, 0, 6) } } return i.setDepthBuffer(!0), i.setAlphaMode(a.ALPHA_DISABLE), !0 }, e.prototype.rebuild = function () { var e; for (var t in this._createIndexBuffer(), this._vertexBuffers) null === (e = this._vertexBuffers[t]) || void 0 === e || e._rebuild() }, e.prototype.dispose = function () { var e = this._vertexBuffers[Hi.PositionKind]; for (e && (e.dispose(), this._vertexBuffers[Hi.PositionKind] = null), this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer), this._indexBuffer = null); this.lensFlares.length;)this.lensFlares[0].dispose(); var t = this._scene.lensFlareSystems.indexOf(this); this._scene.lensFlareSystems.splice(t, 1) }, e.Parse = function (t, i, r) { var n = i.getLastEntryById(t.emitterId), o = t.name || "lensFlareSystem#" + t.emitterId, a = new e(o, n, i); a.id = t.id || o, a.borderLimit = t.borderLimit; for (var s = 0; s < t.flares.length; s++) { var l = t.flares[s]; zm.AddFlare(l.size, l.position, B.FromArray(l.color), l.textureName ? r + l.textureName : "", a) } return a }, e.prototype.serialize = function () { var e = {}; e.id = this.id, e.name = this.name, e.emitterId = this.getEmitter().id, e.borderLimit = this.borderLimit, e.flares = []; for (var t = 0; t < this.lensFlares.length; t++) { var i = this.lensFlares[t]; e.flares.push({ size: i.size, position: i.position, color: i.color.asArray(), textureName: xi.GetFilename(i.texture ? i.texture.name : "") }) } return e }, e._SceneComponentInitialization = function (e) { throw ge("LensFlareSystemSceneComponent") }, e }(); o.AddParser(qi.NAME_LENSFLARESYSTEM, (function (e, t, i, r) { if (void 0 !== e.lensFlareSystems && null !== e.lensFlareSystems) { i.lensFlareSystems || (i.lensFlareSystems = new Array); for (var n = 0, o = e.lensFlareSystems.length; n < o; n++) { var a = e.lensFlareSystems[n], s = Wm.Parse(a, t, r); i.lensFlareSystems.push(s) } } })), o.prototype.getLensFlareSystemByName = function (e) { for (var t = 0; t < this.lensFlareSystems.length; t++)if (this.lensFlareSystems[t].name === e) return this.lensFlareSystems[t]; return null }, o.prototype.getLensFlareSystemById = function (e) { for (var t = 0; t < this.lensFlareSystems.length; t++)if (this.lensFlareSystems[t].id === e) return this.lensFlareSystems[t]; return null }, o.prototype.getLensFlareSystemByID = function (e) { return this.getLensFlareSystemById(e) }, o.prototype.removeLensFlareSystem = function (e) { var t = this.lensFlareSystems.indexOf(e); return -1 !== t && this.lensFlareSystems.splice(t, 1), t }, o.prototype.addLensFlareSystem = function (e) { this.lensFlareSystems.push(e) }; var Hm = function () { function e(e) { this.name = qi.NAME_LENSFLARESYSTEM, this.scene = e, e.lensFlareSystems = new Array } return e.prototype.register = function () { this.scene._afterCameraDrawStage.registerStep(qi.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM, this, this._draw) }, e.prototype.rebuild = function () { for (var e = 0; e < this.scene.lensFlareSystems.length; e++)this.scene.lensFlareSystems[e].rebuild() }, e.prototype.addFromContainer = function (e) { var t = this; e.lensFlareSystems && e.lensFlareSystems.forEach((function (e) { t.scene.addLensFlareSystem(e) })) }, e.prototype.removeFromContainer = function (e, t) { var i = this; e.lensFlareSystems && e.lensFlareSystems.forEach((function (e) { i.scene.removeLensFlareSystem(e), t && e.dispose() })) }, e.prototype.serialize = function (e) { e.lensFlareSystems = []; for (var t = 0, i = this.scene.lensFlareSystems; t < i.length; t++) { var r = i[t]; e.lensFlareSystems.push(r.serialize()) } }, e.prototype.dispose = function () { for (var e = this.scene.lensFlareSystems; e.length;)e[0].dispose() }, e.prototype._draw = function (e) { if (this.scene.lensFlaresEnabled) { var t = this.scene.lensFlareSystems; xi.StartPerformanceCounter("Lens flares", t.length > 0); for (var i = 0, r = t; i < r.length; i++) { var n = r[i]; 0 != (e.layerMask & n.layerMask) && n.render() } xi.EndPerformanceCounter("Lens flares", t.length > 0) } }, e }(); Wm._SceneComponentInitialization = function (e) { var t = e._getComponent(qi.NAME_LENSFLARESYSTEM); t || (t = new Hm(e), e._addComponent(t)) }; Ut.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"; Ut.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"; Ut.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;"; Ut.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}"; Ut.IncludesShadersStore.sceneVertexDeclaration = "uniform mat4 viewProjection;\n#ifdef MULTIVIEW\nuniform mat4 viewProjectionR;\n#endif\nuniform mat4 view;uniform mat4 projection;uniform vec4 vEyePosition;\n"; Ut.IncludesShadersStore.meshVertexDeclaration = "uniform mat4 world;uniform float visibility;\n"; Ut.IncludesShadersStore.shadowMapVertexDeclaration = "#include\n#include\n"; Ut.IncludesShadersStore.shadowMapUboDeclaration = "layout(std140,column_major) uniform;\n#include\n#include\n"; Ut.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"; Ut.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"; Ut.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"; Ut.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}"; Ut.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)));}"; Ut.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow = "#if SM_SOFTTRANSPARENTSHADOW==1\nif ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alpha) discard;\n#endif\n"; var Xm = 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 < r.length; i++) { var n = r[i]; -1 === this._shadowMap.renderList.indexOf(n) && this._shadowMap.renderList.push(n) } return this }, e.prototype.removeShadowCaster = function (e, t) { if (void 0 === t && (t = !0), !this._shadowMap || !this._shadowMap.renderList) return this; var i = this._shadowMap.renderList.indexOf(e); if (-1 !== i && this._shadowMap.renderList.splice(i, 1), t) for (var r = 0, n = e.getChildren(); r < n.length; r++) { var o = n[r]; this.removeShadowCaster(o) } return this }, e.prototype.getLight = function () { return this._light }, e.prototype._getCamera = function () { var e; return null !== (e = this._camera) && void 0 !== e ? e : this._scene.activeCamera }, Object.defineProperty(e.prototype, "mapSize", { get: function () { return this._mapSize }, set: function (e) { this._mapSize = e, this._light._markMeshesAsLightDirty(), this.recreateShadowMap() }, enumerable: !1, configurable: !0 }), e.prototype._initializeGenerator = function () { this._light._markMeshesAsLightDirty(), this._initializeShadowMap() }, e.prototype._createTargetRenderTexture = function () { var e = this._scene.getEngine(); e._features.supportDepthStencilTexture ? (this._shadowMap = new es(this._light.name + "_shadowMap", this._mapSize, this._scene, !1, !0, this._textureType, this._light.needCube(), void 0, !1, !1, void 0, this._useRedTextureType ? a.TEXTUREFORMAT_RED : a.TEXTUREFORMAT_RGBA), this._shadowMap.createDepthStencilTexture(e.useReverseDepthBuffer ? a.GREATER : a.LESS, !0)) : this._shadowMap = new es(this._light.name + "_shadowMap", this._mapSize, this._scene, !1, !0, this._textureType, this._light.needCube()), this._shadowMap.noPrePassRenderer = !0 }, e.prototype._initializeShadowMap = function () { var t = this; if (this._createTargetRenderTexture(), null !== this._shadowMap) { this._shadowMap.wrapU = vo.CLAMP_ADDRESSMODE, this._shadowMap.wrapV = vo.CLAMP_ADDRESSMODE, this._shadowMap.anisotropicFilteringLevel = 1, this._shadowMap.updateSamplingMode(vo.BILINEAR_SAMPLINGMODE), this._shadowMap.renderParticles = !1, this._shadowMap.ignoreCameraViewport = !0, this._storedUniqueId && (this._shadowMap.uniqueId = this._storedUniqueId), this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this), this._shadowMap.customIsReadyFunction = function () { return !0 }; var i = this._scene.getEngine(); this._shadowMap.onBeforeBindObservable.add((function () { var e; t._currentSceneUBO = t._scene.getSceneUniformBuffer(), null === (e = i._debugPushGroup) || void 0 === e || e.call(i, "shadow map generation for pass id ".concat(i.currentRenderPassId), 1) })), this._shadowMap.onBeforeRenderObservable.add((function (r) { t._sceneUBOs && t._scene.setSceneUniformBuffer(t._sceneUBOs[0]), t._currentFaceIndex = r, t._filter === e.FILTER_PCF && i.setColorWrite(!1), t.getTransformMatrix(), t._scene.setTransformMatrix(t._viewMatrix, t._projectionMatrix), t._useUBO && (t._scene.getSceneUniformBuffer().unbindEffect(), t._scene.finalizeSceneUbo()) })), this._shadowMap.onAfterUnbindObservable.add((function () { var r, n; if (t._sceneUBOs && t._scene.setSceneUniformBuffer(t._currentSceneUBO), t._scene.updateTransformMatrix(), t._filter === e.FILTER_PCF && i.setColorWrite(!0), t.useBlurExponentialShadowMap || t.useBlurCloseExponentialShadowMap) { var o = t.getShadowMapForRendering(); o && (t._scene.postProcessManager.directRender(t._blurPostProcesses, o.renderTarget, !0), i.unBindFramebuffer(o.renderTarget, !0), null === (n = i._debugPopGroup) || void 0 === n || n.call(i, 1)) } else null === (r = i._debugPopGroup) || void 0 === r || r.call(i, 1) })); var r = new U(0, 0, 0, 0), n = new U(1, 1, 1, 1); this._shadowMap.onClearObservable.add((function (i) { t._filter === e.FILTER_PCF ? i.clear(n, !1, !0, !1) : t.useExponentialShadowMap || t.useBlurExponentialShadowMap ? i.clear(r, !0, !0, !1) : i.clear(n, !0, !0, !1) })), this._shadowMap.onResizeObservable.add((function (e) { t._storedUniqueId = t._shadowMap.uniqueId, t._mapSize = e.getRenderSize(), t._light._markMeshesAsLightDirty(), t.recreateShadowMap() })); for (var o = Qi.MIN_RENDERINGGROUPS; o < Qi.MAX_RENDERINGGROUPS; o++)this._shadowMap.setRenderingAutoClearDepthStencil(o, !1) } }, e.prototype._initializeBlurRTTAndPostProcesses = function () { var e = this, t = this._scene.getEngine(), i = this._mapSize / this.blurScale; this.useKernelBlur && 1 === this.blurScale || (this._shadowMap2 = new es(this._light.name + "_shadowMap2", i, this._scene, !1, !0, this._textureType, void 0, void 0, !1), this._shadowMap2.wrapU = vo.CLAMP_ADDRESSMODE, this._shadowMap2.wrapV = vo.CLAMP_ADDRESSMODE, this._shadowMap2.updateSamplingMode(vo.BILINEAR_SAMPLINGMODE)), this.useKernelBlur ? (this._kernelBlurXPostprocess = new c_(this._light.name + "KernelBlurX", new A(1, 0), this.blurKernel, 1, null, vo.BILINEAR_SAMPLINGMODE, t, !1, this._textureType), this._kernelBlurXPostprocess.width = i, this._kernelBlurXPostprocess.height = i, this._kernelBlurXPostprocess.externalTextureSamplerBinding = !0, this._kernelBlurXPostprocess.onApplyObservable.add((function (t) { t.setTexture("textureSampler", e._shadowMap) })), this._kernelBlurYPostprocess = new c_(this._light.name + "KernelBlurY", new A(0, 1), this.blurKernel, 1, null, vo.BILINEAR_SAMPLINGMODE, t, !1, this._textureType), this._kernelBlurXPostprocess.autoClear = !1, this._kernelBlurYPostprocess.autoClear = !1, this._textureType === a.TEXTURETYPE_UNSIGNED_INT && (this._kernelBlurXPostprocess.packedFloat = !0, this._kernelBlurYPostprocess.packedFloat = !0), this._blurPostProcesses = [this._kernelBlurXPostprocess, this._kernelBlurYPostprocess]) : (this._boxBlurPostprocess = new Ia(this._light.name + "DepthBoxBlur", "depthBoxBlur", ["screenSize", "boxOffset"], [], 1, null, vo.BILINEAR_SAMPLINGMODE, t, !1, "#define OFFSET " + this._blurBoxOffset, this._textureType), this._boxBlurPostprocess.externalTextureSamplerBinding = !0, this._boxBlurPostprocess.onApplyObservable.add((function (t) { t.setFloat2("screenSize", i, i), t.setTexture("textureSampler", e._shadowMap) })), this._boxBlurPostprocess.autoClear = !1, this._blurPostProcesses = [this._boxBlurPostprocess]) }, e.prototype._renderForShadowMap = function (e, t, i, r) { var n; if (r.length) for (n = 0; n < r.length; n++)this._renderSubMeshForShadowMap(r.data[n]); for (n = 0; n < e.length; n++)this._renderSubMeshForShadowMap(e.data[n]); for (n = 0; n < t.length; n++)this._renderSubMeshForShadowMap(t.data[n]); if (this._transparencyShadow) for (n = 0; n < i.length; n++)this._renderSubMeshForShadowMap(i.data[n], !0); else for (n = 0; n < i.length; n++)i.data[n].getEffectiveMesh()._internalAbstractMeshDataInfo._isActiveIntermediate = !1 }, e.prototype._bindCustomEffectForRenderSubMeshForShadowMap = function (e, t, i) { t.setMatrix("viewProjection", this.getTransformMatrix()) }, e.prototype._renderSubMeshForShadowMap = function (e, t) { var i, r; void 0 === t && (t = !1); var n = e.getRenderingMesh(), o = e.getEffectiveMesh(), s = this._scene, l = s.getEngine(), c = e.getMaterial(); if (o._internalAbstractMeshDataInfo._isActiveIntermediate = !1, c && 0 !== e.verticesCount && e._renderId !== s.getRenderId()) { var u = o._getWorldMatrixDeterminant() < 0, h = null !== (i = n.overrideMaterialSideOrientation) && void 0 !== i ? i : c.sideOrientation; u && (h = h === a.MATERIAL_ClockWiseSideOrientation ? a.MATERIAL_CounterClockWiseSideOrientation : a.MATERIAL_ClockWiseSideOrientation); var d = h === a.MATERIAL_ClockWiseSideOrientation; l.setState(c.backFaceCulling, void 0, void 0, d, c.cullBackFaces); var p = n._getInstancesRenderList(e._id, !!e.getReplacementMesh()); if (!p.mustReturn) { var f = l.getCaps().instancedArrays && (null !== p.visibleInstances[e._id] && void 0 !== p.visibleInstances[e._id] || n.hasThinInstances); if (!this.customAllowRendering || this.customAllowRendering(e)) if (this.isReady(e, f, t)) { e._renderId = s.getRenderId(); var _ = c.shadowDepthWrapper, m = null !== (r = null == _ ? void 0 : _.getEffect(e, this, l.currentRenderPassId)) && void 0 !== r ? r : e._getDrawWrapper(), g = Jt.GetEffect(m); l.enableEffect(m), f || n._bind(e, g, c.fillMode), this.getTransformMatrix(), g.setFloat3("biasAndScaleSM", this.bias, this.normalBias, this.depthScale), this.getLight().getTypeID() === eo.LIGHTTYPEID_DIRECTIONALLIGHT ? g.setVector3("lightDataSM", this._cachedDirection) : g.setVector3("lightDataSM", this._cachedPosition); var v = this._getCamera(); if (v && g.setFloat2("depthValuesSM", this.getLight().getDepthMinZ(v), this.getLight().getDepthMinZ(v) + this.getLight().getDepthMaxZ(v)), t && this.enableSoftTransparentShadow && g.setFloat("softTransparentShadowSM", o.visibility * c.alpha), _) e._setMainDrawWrapperOverride(m), _.standalone ? _.baseMaterial.bindForSubMesh(o.getWorldMatrix(), n, e) : c.bindForSubMesh(o.getWorldMatrix(), n, e), e._setMainDrawWrapperOverride(null); else { if (this._opacityTexture && (g.setTexture("diffuseSampler", this._opacityTexture), g.setMatrix("diffuseMatrix", this._opacityTexture.getTextureMatrix() || this._defaultTextureMatrix)), n.useBones && n.computeBonesUsingShaders && n.skeleton) { var y = n.skeleton; if (y.isUsingTextureForMatrices) { var b = y.getTransformMatrixTexture(n); if (!b) return; g.setTexture("boneSampler", b), g.setFloat("boneTextureWidth", 4 * (y.bones.length + 1)) } else g.setMatrices("mBones", y.getTransformMatrices(n)) } zn.BindMorphTargetParameters(n, g), n.morphTargetManager && n.morphTargetManager.isUsingTextureForTargets && n.morphTargetManager._bind(g), Vn(g, c, s) } this._useUBO || _ || this._bindCustomEffectForRenderSubMeshForShadowMap(e, g, o), zn.BindSceneUniformBuffer(g, this._scene.getSceneUniformBuffer()), this._scene.getSceneUniformBuffer().bindUniformBuffer(); var T = o.getWorldMatrix(); f && (o.getMeshUniformBuffer().bindToEffect(g, "Mesh"), o.transferToEffect(T)), this.forceBackFacesOnly && l.setState(!0, 0, !1, !0, c.cullBackFaces), this.onBeforeShadowMapRenderMeshObservable.notifyObservers(n), this.onBeforeShadowMapRenderObservable.notifyObservers(g), n._processRendering(o, e, g, c.fillMode, p, f, (function (e, t) { o === n || e ? (o.getMeshUniformBuffer().bindToEffect(g, "Mesh"), o.transferToEffect(e ? t : T)) : (n.getMeshUniformBuffer().bindToEffect(g, "Mesh"), n.transferToEffect(t)) })), this.forceBackFacesOnly && l.setState(!0, 0, !1, !1, c.cullBackFaces), this.onAfterShadowMapRenderObservable.notifyObservers(g), this.onAfterShadowMapRenderMeshObservable.notifyObservers(n) } else this._shadowMap && this._shadowMap.resetRefreshCounter() } } }, e.prototype._applyFilterValues = function () { this._shadowMap && (this.filter === e.FILTER_NONE || this.filter === e.FILTER_PCSS ? this._shadowMap.updateSamplingMode(vo.NEAREST_SAMPLINGMODE) : this._shadowMap.updateSamplingMode(vo.BILINEAR_SAMPLINGMODE)) }, e.prototype.forceCompilation = function (e, t) { var i = this, r = H({ useInstances: !1 }, t), n = this.getShadowMap(); if (n) { var o = n.renderList; if (o) { for (var a = new Array, s = 0, l = o; s < l.length; s++) { var c = l[s]; a.push.apply(a, c.subMeshes) } if (0 !== a.length) { var u = 0, h = function () { var t, n; if (i._scene && i._scene.getEngine()) { for (; i.isReady(a[u], r.useInstances, null !== (n = null === (t = a[u].getMaterial()) || void 0 === t ? void 0 : t.needAlphaBlendingForMesh(a[u].getMesh())) && void 0 !== n && n);)if (++u >= 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(Hi.NormalKind) ? "1" : "0")), i.push("#define SM_DIRECTIONINLIGHTDATA " + (this.getLight().getTypeID() === eo.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 = [Hi.PositionKind], d = t.getMesh(); this.normalBias && d.isVerticesDataPresent(Hi.NormalKind) && (h.push(Hi.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(Hi.UVKind) && (h.push(Hi.UVKind), s.push("#define UV1")), d.isVerticesDataPresent(Hi.UV2Kind) && 1 === this._opacityTexture.coordinatesIndex && (h.push(Hi.UV2Kind), s.push("#define UV2")) } var _ = new Ra; if (d.useBones && d.computeBonesUsingShaders && d.skeleton) { h.push(Hi.MatricesIndicesKind), h.push(Hi.MatricesWeightsKind), d.numBoneInfluencers > 4 && (h.push(Hi.MatricesIndicesExtraKind), h.push(Hi.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"), zn.PrepareAttributesForMorphTargetsInfluencers(h, d, v)), Bn(o, this._scene, s), i && (s.push("#define INSTANCES"), zn.PushAttributesForInstances(h), t.getRenderingMesh().hasThinInstances && s.push("#define THIN_INSTANCES")), this.customShaderOptions && this.customShaderOptions.defines) for (var y = 0, b = this.customShaderOptions.defines; y < b.length; y++) { var T = b[y]; -1 === s.indexOf(T) && s.push(T) } var E = s.join("\n"); if (u !== E) { u = E; var S = "shadowMap", x = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightDataSM", "depthValuesSM", "biasAndScaleSM", "morphTargetInfluences", "boneTextureWidth", "softTransparentShadowSM", "morphTargetTextureInfo", "morphTargetTextureIndices"], A = ["diffuseSampler", "boneSampler", "morphTargets"]; if (wn(x), this.customShaderOptions) { if (S = this.customShaderOptions.shaderName, this.customShaderOptions.attributes) for (var R = 0, C = this.customShaderOptions.attributes; R < C.length; R++) { var P = C[R]; -1 === h.indexOf(P) && h.push(P) } if (this.customShaderOptions.uniforms) for (var I = 0, M = this.customShaderOptions.uniforms; I < M.length; I++) { var O = M[I]; -1 === x.indexOf(O) && x.push(O) } if (this.customShaderOptions.samplers) for (var D = 0, N = this.customShaderOptions.samplers; D < N.length; D++) { var F = N[D]; -1 === A.indexOf(F) && A.push(F) } } var L = this._scene.getEngine(); c = L.createEffect(S, { attributes: h, uniformsNames: x, uniformBuffersNames: ["Scene", "Mesh"], samplers: A, defines: E, fallbacks: _, onCompiled: null, onError: null, indexParameters: { maxSimultaneousMorphTargets: v } }, L), l.setEffect(c, u) } if (!c.isReady()) return !1 } return (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) && (this._blurPostProcesses && this._blurPostProcesses.length || this._initializeBlurRTTAndPostProcesses()), !(this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady() || this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady() || this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady()) }, e.prototype.prepareDefines = function (t, i) { var r = this._scene, n = this._light; r.shadowsEnabled && n.shadowEnabled && (t["SHADOW" + i] = !0, this.useContactHardeningShadow ? (t["SHADOWPCSS" + i] = !0, this._filteringQuality === e.QUALITY_LOW ? t["SHADOWLOWQUALITY" + i] = !0 : this._filteringQuality === e.QUALITY_MEDIUM && (t["SHADOWMEDIUMQUALITY" + i] = !0)) : this.usePercentageCloserFiltering ? (t["SHADOWPCF" + i] = !0, this._filteringQuality === e.QUALITY_LOW ? t["SHADOWLOWQUALITY" + i] = !0 : this._filteringQuality === e.QUALITY_MEDIUM && (t["SHADOWMEDIUMQUALITY" + i] = !0)) : this.usePoissonSampling ? t["SHADOWPOISSON" + i] = !0 : this.useExponentialShadowMap || this.useBlurExponentialShadowMap ? t["SHADOWESM" + i] = !0 : (this.useCloseExponentialShadowMap || this.useBlurCloseExponentialShadowMap) && (t["SHADOWCLOSEESM" + i] = !0), n.needCube() && (t["SHADOWCUBE" + i] = !0)) }, e.prototype.bindShadowLight = function (t, i) { var r = this._light; if (this._scene.shadowsEnabled && r.shadowEnabled) { var n = this._getCamera(); if (n) { var o = this.getShadowMap(); o && (r.needCube() || i.setMatrix("lightMatrix" + t, this.getTransformMatrix()), this._filter === e.FILTER_PCF ? (i.setDepthStencilTexture("shadowSampler" + t, this.getShadowMapForRendering()), r._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), o.getSize().width, 1 / o.getSize().width, this.frustumEdgeFalloff, t)) : this._filter === e.FILTER_PCSS ? (i.setDepthStencilTexture("shadowSampler" + t, this.getShadowMapForRendering()), i.setTexture("depthSampler" + t, this.getShadowMapForRendering()), r._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / o.getSize().width, this._contactHardeningLightSizeUVRatio * o.getSize().width, this.frustumEdgeFalloff, t)) : (i.setTexture("shadowSampler" + t, this.getShadowMapForRendering()), r._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / o.getSize().width, this.depthScale, this.frustumEdgeFalloff, t)), r._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(n), this.getLight().getDepthMinZ(n) + this.getLight().getDepthMaxZ(n), t)) } } }, e.prototype.getTransformMatrix = function () { var e = this._scene; if (this._currentRenderId === e.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex) return this._transformMatrix; this._currentRenderId = e.getRenderId(), this._currentFaceIndexCache = this._currentFaceIndex; var t = this._light.position; if (this._light.computeTransformedInformation() && (t = this._light.transformedPosition), R.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection), 1 === Math.abs(R.Dot(this._lightDirection, R.Up())) && (this._lightDirection.z = 1e-13), this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !t.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) { this._cachedPosition.copyFrom(t), this._cachedDirection.copyFrom(this._lightDirection), I.LookAtLHToRef(t, t.add(this._lightDirection), R.Up(), this._viewMatrix); var i = this.getShadowMap(); if (i) { var r = i.renderList; r && this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, r) } this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix) } return this._transformMatrix }, e.prototype.recreateShadowMap = function () { var e = this._shadowMap; if (e) { var t = e.renderList; if (this._disposeRTTandPostProcesses(), this._initializeGenerator(), this.filter = this._filter, this._applyFilterValues(), t) { this._shadowMap.renderList || (this._shadowMap.renderList = []); for (var i = 0, r = t; i < r.length; i++) { var n = r[i]; this._shadowMap.renderList.push(n) } } else this._shadowMap.renderList = null } }, e.prototype._disposeBlurPostProcesses = function () { this._shadowMap2 && (this._shadowMap2.dispose(), this._shadowMap2 = null), this._boxBlurPostprocess && (this._boxBlurPostprocess.dispose(), this._boxBlurPostprocess = null), this._kernelBlurXPostprocess && (this._kernelBlurXPostprocess.dispose(), this._kernelBlurXPostprocess = null), this._kernelBlurYPostprocess && (this._kernelBlurYPostprocess.dispose(), this._kernelBlurYPostprocess = null), this._blurPostProcesses = [] }, e.prototype._disposeRTTandPostProcesses = function () { this._shadowMap && (this._shadowMap.dispose(), this._shadowMap = null), this._disposeBlurPostProcesses() }, e.prototype._disposeSceneUBOs = function () { if (this._sceneUBOs) { for (var e = 0, t = this._sceneUBOs; e < t.length; e++)t[e].dispose(); this._sceneUBOs = [] } }, e.prototype.dispose = function () { var e; if (this._disposeRTTandPostProcesses(), this._disposeSceneUBOs(), this._light) { if (this._light._shadowGenerators) { for (var t = this._light._shadowGenerators.entries(), i = t.next(); !0 !== i.done; i = t.next()) { var r = (e = i.value)[0]; e[1] === this && this._light._shadowGenerators.delete(r) } 0 === this._light._shadowGenerators.size && (this._light._shadowGenerators = null) } this._light._markMeshesAsLightDirty() } this.onBeforeShadowMapRenderMeshObservable.clear(), this.onBeforeShadowMapRenderObservable.clear(), this.onAfterShadowMapRenderMeshObservable.clear(), this.onAfterShadowMapRenderObservable.clear() }, e.prototype.serialize = function () { var e, t = {}, i = this.getShadowMap(); if (!i) return t; if (t.className = this.getClassName(), t.lightId = this._light.id, t.cameraId = null === (e = this._camera) || void 0 === e ? void 0 : e.id, t.id = this.id, t.mapSize = i.getRenderSize(), t.forceBackFacesOnly = this.forceBackFacesOnly, t.darkness = this.getDarkness(), t.transparencyShadow = this._transparencyShadow, t.frustumEdgeFalloff = this.frustumEdgeFalloff, t.bias = this.bias, t.normalBias = this.normalBias, t.usePercentageCloserFiltering = this.usePercentageCloserFiltering, t.useContactHardeningShadow = this.useContactHardeningShadow, t.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio, t.filteringQuality = this.filteringQuality, t.useExponentialShadowMap = this.useExponentialShadowMap, t.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap, t.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap, t.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap, t.usePoissonSampling = this.usePoissonSampling, t.depthScale = this.depthScale, t.blurBoxOffset = this.blurBoxOffset, t.blurKernel = this.blurKernel, t.blurScale = this.blurScale, t.useKernelBlur = this.useKernelBlur, t.renderList = [], i.renderList) for (var r = 0; r < i.renderList.length; r++) { var n = i.renderList[r]; t.renderList.push(n.id) } return t }, e.Parse = function (t, i, r) { for (var n = i.getLightById(t.lightId), o = void 0 !== t.cameraId ? i.getCameraById(t.cameraId) : null, a = r ? r(t.mapSize, n, o) : new e(t.mapSize, n, void 0, o), s = a.getShadowMap(), l = 0; l < t.renderList.length; l++)i.getMeshesById(t.renderList[l]).forEach((function (e) { s && (s.renderList || (s.renderList = []), s.renderList.push(e)) })); return void 0 !== t.id && (a.id = t.id), a.forceBackFacesOnly = !!t.forceBackFacesOnly, void 0 !== t.darkness && a.setDarkness(t.darkness), t.transparencyShadow && a.setTransparencyShadow(!0), void 0 !== t.frustumEdgeFalloff && (a.frustumEdgeFalloff = t.frustumEdgeFalloff), void 0 !== t.bias && (a.bias = t.bias), void 0 !== t.normalBias && (a.normalBias = t.normalBias), t.usePercentageCloserFiltering ? a.usePercentageCloserFiltering = !0 : t.useContactHardeningShadow ? a.useContactHardeningShadow = !0 : t.usePoissonSampling ? a.usePoissonSampling = !0 : t.useExponentialShadowMap ? a.useExponentialShadowMap = !0 : t.useBlurExponentialShadowMap ? a.useBlurExponentialShadowMap = !0 : t.useCloseExponentialShadowMap ? a.useCloseExponentialShadowMap = !0 : t.useBlurCloseExponentialShadowMap ? a.useBlurCloseExponentialShadowMap = !0 : t.useVarianceShadowMap ? a.useExponentialShadowMap = !0 : t.useBlurVarianceShadowMap && (a.useBlurExponentialShadowMap = !0), void 0 !== t.contactHardeningLightSizeUVRatio && (a.contactHardeningLightSizeUVRatio = t.contactHardeningLightSizeUVRatio), void 0 !== t.filteringQuality && (a.filteringQuality = t.filteringQuality), t.depthScale && (a.depthScale = t.depthScale), t.blurScale && (a.blurScale = t.blurScale), t.blurBoxOffset && (a.blurBoxOffset = t.blurBoxOffset), t.useKernelBlur && (a.useKernelBlur = t.useKernelBlur), t.blurKernel && (a.blurKernel = t.blurKernel), a }, e.CLASSNAME = "ShadowGenerator", e.FILTER_NONE = 0, e.FILTER_EXPONENTIALSHADOWMAP = 1, e.FILTER_POISSONSAMPLING = 2, e.FILTER_BLUREXPONENTIALSHADOWMAP = 3, e.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4, e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5, e.FILTER_PCF = 6, e.FILTER_PCSS = 7, e.QUALITY_HIGH = 0, e.QUALITY_MEDIUM = 1, e.QUALITY_LOW = 2, e.DEFAULT_ALPHA_CUTOFF = .5, e._SceneComponentInitialization = function (e) { throw ge("ShadowGeneratorSceneComponent") }, e }(); Ut.ShadersStore.depthPixelShader = "#ifdef ALPHATEST\nvarying vec2 vUV;uniform sampler2D diffuseSampler;\n#endif\n#include\nvarying float vDepthMetric;\n#ifdef PACKED\n#include\n#endif\n#ifdef STORE_CAMERASPACE_Z\nvarying vec4 vViewPos;\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\n#include\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\n#ifdef STORE_CAMERASPACE_Z\n#ifdef PACKED\ngl_FragColor=pack(vViewPos.z);\n#else\ngl_FragColor=vec4(vViewPos.z,0.0,0.0,1.0);\n#endif\n#else\n#ifdef NONLINEARDEPTH\n#ifdef PACKED\ngl_FragColor=pack(gl_FragCoord.z);\n#else\ngl_FragColor=vec4(gl_FragCoord.z,0.0,0.0,0.0);\n#endif\n#else\n#ifdef PACKED\ngl_FragColor=pack(vDepthMetric);\n#else\ngl_FragColor=vec4(vDepthMetric,0.0,0.0,1.0);\n#endif\n#endif\n#endif\n}"; Ut.ShadersStore.depthVertexShader = "attribute vec3 position;\n#include\n#include\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\n#include\nuniform mat4 viewProjection;uniform vec2 depthValues;\n#if defined(ALPHATEST) || defined(NEED_UV)\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#ifdef STORE_CAMERASPACE_Z\nuniform mat4 view;varying vec4 vViewPos;\n#endif\nvarying float vDepthMetric;\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#include\ngl_Position=viewProjection*worldPos;\n#ifdef STORE_CAMERASPACE_Z\nvViewPos=view*worldPos;\n#else\n#ifdef USE_REVERSE_DEPTHBUFFER\nvDepthMetric=((-gl_Position.z+depthValues.x)/(depthValues.y));\n#else\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y));\n#endif\n#endif\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\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}\n"; var jm = function () { function e(t, i, r, n, o, s, l) { void 0 === i && (i = a.TEXTURETYPE_FLOAT), void 0 === r && (r = null), void 0 === n && (n = !1), void 0 === o && (o = vo.TRILINEAR_SAMPLINGMODE), void 0 === s && (s = !1); var c = this; this.enabled = !0, this.forceDepthWriteTransparentMeshes = !1, this.useOnlyInActiveCamera = !1, this.reverseCulling = !1, this._scene = t, this._storeNonLinearDepth = n, this._storeCameraSpaceZ = s, this.isPacked = i === a.TEXTURETYPE_UNSIGNED_BYTE, this.isPacked ? this.clearColor = new U(1, 1, 1, 1) : this.clearColor = new U(s ? 1e8 : 1, 0, 0, 1), e._SceneComponentInitialization(this._scene); var u = t.getEngine(); this._camera = r, o !== vo.NEAREST_SAMPLINGMODE && (i !== a.TEXTURETYPE_FLOAT || u._caps.textureFloatLinearFiltering || (o = vo.NEAREST_SAMPLINGMODE), i !== a.TEXTURETYPE_HALF_FLOAT || u._caps.textureHalfFloatLinearFiltering || (o = vo.NEAREST_SAMPLINGMODE)); var h = this.isPacked || !u._features.supportExtendedTextureFormats ? a.TEXTUREFORMAT_RGBA : a.TEXTUREFORMAT_R; this._depthMap = new es(null != l ? l : "DepthRenderer", { width: u.getRenderWidth(), height: u.getRenderHeight() }, this._scene, !1, !0, i, !1, o, void 0, void 0, void 0, h), this._depthMap.wrapU = vo.CLAMP_ADDRESSMODE, this._depthMap.wrapV = vo.CLAMP_ADDRESSMODE, this._depthMap.refreshRate = 1, this._depthMap.renderParticles = !1, this._depthMap.renderList = null, this._depthMap.noPrePassRenderer = !0, this._depthMap.activeCamera = this._camera, this._depthMap.ignoreCameraViewport = !0, this._depthMap.useCameraPostProcesses = !1, this._depthMap.onClearObservable.add((function (e) { e.clear(c.clearColor, !0, !0, !0) })), this._depthMap.onBeforeBindObservable.add((function () { var e; null === (e = u._debugPushGroup) || void 0 === e || e.call(u, "depth renderer", 1) })), this._depthMap.onAfterUnbindObservable.add((function () { var e; null === (e = u._debugPopGroup) || void 0 === e || e.call(u, 1) })), this._depthMap.customIsReadyFunction = function (e, t, i) { if ((i || 0 === t) && e.subMeshes) for (var r = 0; r < e.subMeshes.length; ++r) { var n = e.subMeshes[r], o = n.getRenderingMesh(), a = o._getInstancesRenderList(n._id, !!n.getReplacementMesh()), s = u.getCaps().instancedArrays && (null !== a.visibleInstances[n._id] && void 0 !== a.visibleInstances[n._id] || o.hasThinInstances); if (!c.isReady(n, s)) return !1 } return !0 }; var d = function (e) { var t, i, r = e.getRenderingMesh(), n = e.getEffectiveMesh(), o = c._scene, s = o.getEngine(), l = e.getMaterial(); if (n._internalAbstractMeshDataInfo._isActiveIntermediate = !1, l && !n.infiniteDistance && !l.disableDepthWrite && 0 !== e.verticesCount && e._renderId !== o.getRenderId()) { var u = n._getWorldMatrixDeterminant() < 0, h = null !== (t = r.overrideMaterialSideOrientation) && void 0 !== t ? t : l.sideOrientation; u && (h = h === a.MATERIAL_ClockWiseSideOrientation ? a.MATERIAL_CounterClockWiseSideOrientation : a.MATERIAL_ClockWiseSideOrientation); var d = h === a.MATERIAL_ClockWiseSideOrientation; s.setState(l.backFaceCulling, 0, !1, d, c.reverseCulling ? !l.cullBackFaces : l.cullBackFaces); var p = r._getInstancesRenderList(e._id, !!e.getReplacementMesh()); if (!p.mustReturn) { var f = s.getCaps().instancedArrays && (null !== p.visibleInstances[e._id] && void 0 !== p.visibleInstances[e._id] || r.hasThinInstances), _ = c._camera || o.activeCamera; if (c.isReady(e, f) && _) { e._renderId = o.getRenderId(); var m = null === (i = n._internalAbstractMeshDataInfo._materialForRenderPass) || void 0 === i ? void 0 : i[s.currentRenderPassId], g = e._getDrawWrapper(); !g && m && (g = m._getDrawWrapper()); var v = _.mode === ln.ORTHOGRAPHIC_CAMERA; if (!g) return; var y = g.effect; s.enableEffect(g), f || r._bind(e, y, l.fillMode), m ? m.bindForSubMesh(n.getWorldMatrix(), n, e) : (y.setMatrix("viewProjection", o.getTransformMatrix()), y.setMatrix("world", n.getWorldMatrix()), c._storeCameraSpaceZ && y.setMatrix("view", o.getViewMatrix())); var b = void 0, T = void 0; if (v ? (b = !s.useReverseDepthBuffer && s.isNDCHalfZRange ? 0 : 1, T = s.useReverseDepthBuffer && s.isNDCHalfZRange ? 0 : 1) : (b = s.useReverseDepthBuffer && s.isNDCHalfZRange ? _.minZ : s.isNDCHalfZRange ? 0 : _.minZ, T = s.useReverseDepthBuffer && s.isNDCHalfZRange ? 0 : _.maxZ), y.setFloat2("depthValues", b, b + T), !m) { if (l.needAlphaTesting()) { var E = l.getAlphaTestTexture(); E && (y.setTexture("diffuseSampler", E), y.setMatrix("diffuseMatrix", E.getTextureMatrix())) } if (r.useBones && r.computeBonesUsingShaders && r.skeleton) { var S = r.skeleton; if (S.isUsingTextureForMatrices) { var x = S.getTransformMatrixTexture(r); if (!x) return; y.setTexture("boneSampler", x), y.setFloat("boneTextureWidth", 4 * (S.bones.length + 1)) } else y.setMatrices("mBones", S.getTransformMatrices(r)) } Vn(y, l, o), zn.BindMorphTargetParameters(r, y), r.morphTargetManager && r.morphTargetManager.isUsingTextureForTargets && r.morphTargetManager._bind(y) } r._processRendering(n, e, y, l.fillMode, p, f, (function (e, t) { return y.setMatrix("world", t) })) } } } }; this._depthMap.customRenderFunction = function (e, t, i, r) { var n; if (r.length) for (n = 0; n < r.length; n++)d(r.data[n]); for (n = 0; n < e.length; n++)d(e.data[n]); for (n = 0; n < t.length; n++)d(t.data[n]); if (c.forceDepthWriteTransparentMeshes) for (n = 0; n < i.length; n++)d(i.data[n]); else for (n = 0; n < i.length; n++)i.data[n].getEffectiveMesh()._internalAbstractMeshDataInfo._isActiveIntermediate = !1 } } return e.prototype.setMaterialForRendering = function (e, t) { this._depthMap.setMaterialForRendering(e, t) }, e.prototype.isReady = function (e, t) { var i, r = this._scene.getEngine(), n = e.getMesh(), o = n.getScene(), a = null === (i = n._internalAbstractMeshDataInfo._materialForRenderPass) || void 0 === i ? void 0 : i[r.currentRenderPassId]; if (a) return a.isReadyForSubMesh(n, e, t); var s = e.getMaterial(); if (!s || s.disableDepthWrite) return !1; var l = [], c = [Hi.PositionKind]; if (s && s.needAlphaTesting() && s.getAlphaTestTexture() && (l.push("#define ALPHATEST"), n.isVerticesDataPresent(Hi.UVKind) && (c.push(Hi.UVKind), l.push("#define UV1")), n.isVerticesDataPresent(Hi.UV2Kind) && (c.push(Hi.UV2Kind), l.push("#define UV2"))), n.useBones && n.computeBonesUsingShaders) { c.push(Hi.MatricesIndicesKind), c.push(Hi.MatricesWeightsKind), n.numBoneInfluencers > 4 && (c.push(Hi.MatricesIndicesExtraKind), c.push(Hi.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"), zn.PrepareAttributesForMorphTargetsInfluencers(c, n, d)), t && (l.push("#define INSTANCES"), zn.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"), Bn(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"]; wn(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; i < r.length; i++)t = r[i], delete this._scene._depthRenderer[t] } }, e._SceneComponentInitialization = function (e) { throw ge("DepthRendererSceneComponent") }, e }(); Ut.ShadersStore.minmaxReduxPixelShader = "varying vec2 vUV;uniform sampler2D textureSampler;\n#if defined(INITIAL)\nuniform sampler2D sourceTexture;uniform vec2 texSize;void main(void)\n{ivec2 coord=ivec2(vUV*(texSize-1.0));float f1=texelFetch(sourceTexture,coord,0).r;float f2=texelFetch(sourceTexture,coord+ivec2(1,0),0).r;float f3=texelFetch(sourceTexture,coord+ivec2(1,1),0).r;float f4=texelFetch(sourceTexture,coord+ivec2(0,1),0).r;float minz=min(min(min(f1,f2),f3),f4);\n#ifdef DEPTH_REDUX\nfloat maxz=max(max(max(sign(1.0-f1)*f1,sign(1.0-f2)*f2),sign(1.0-f3)*f3),sign(1.0-f4)*f4);\n#else\nfloat maxz=max(max(max(f1,f2),f3),f4);\n#endif\nglFragColor=vec4(minz,maxz,0.,0.);}\n#elif defined(MAIN)\nuniform vec2 texSize;void main(void)\n{ivec2 coord=ivec2(vUV*(texSize-1.0));vec2 f1=texelFetch(textureSampler,coord,0).rg;vec2 f2=texelFetch(textureSampler,coord+ivec2(1,0),0).rg;vec2 f3=texelFetch(textureSampler,coord+ivec2(1,1),0).rg;vec2 f4=texelFetch(textureSampler,coord+ivec2(0,1),0).rg;float minz=min(min(min(f1.x,f2.x),f3.x),f4.x);float maxz=max(max(max(f1.y,f2.y),f3.y),f4.y);glFragColor=vec4(minz,maxz,0.,0.);}\n#elif defined(ONEBEFORELAST)\nuniform ivec2 texSize;void main(void)\n{ivec2 coord=ivec2(vUV*vec2(texSize-1));vec2 f1=texelFetch(textureSampler,coord % texSize,0).rg;vec2 f2=texelFetch(textureSampler,(coord+ivec2(1,0)) % texSize,0).rg;vec2 f3=texelFetch(textureSampler,(coord+ivec2(1,1)) % texSize,0).rg;vec2 f4=texelFetch(textureSampler,(coord+ivec2(0,1)) % texSize,0).rg;float minz=min(f1.x,f2.x);float maxz=max(f1.y,f2.y);glFragColor=vec4(minz,maxz,0.,0.);}\n#elif defined(LAST)\nvoid main(void)\n{glFragColor=vec4(0.);if (true) { \ndiscard;}}\n#endif\n"; var Ym = function () { function e(e) { var t = this; this.onAfterReductionPerformed = new u, this._forceFullscreenViewport = !0, this._activated = !1, this._camera = e, this._postProcessManager = new ji(e.getScene()), this._onContextRestoredObserver = e.getEngine().onContextRestoredObservable.add((function () { t._postProcessManager._rebuild() })) } return Object.defineProperty(e.prototype, "sourceTexture", { get: function () { return this._sourceTexture }, enumerable: !1, configurable: !0 }), e.prototype.setSourceTexture = function (e, t, i, r) { var n = this; if (void 0 === i && (i = a.TEXTURETYPE_HALF_FLOAT), void 0 === r && (r = !0), e !== this._sourceTexture) { this.dispose(!1), this._sourceTexture = e, this._reductionSteps = [], this._forceFullscreenViewport = r; var o = this._camera.getScene(), s = new Ia("Initial reduction phase", "minmaxRedux", ["texSize"], ["sourceTexture"], 1, null, a.TEXTURE_NEAREST_NEAREST, o.getEngine(), !1, "#define INITIAL" + (t ? "\n#define DEPTH_REDUX" : ""), i, void 0, void 0, void 0, a.TEXTUREFORMAT_RG); s.autoClear = !1, s.forceFullscreenViewport = r; var l = this._sourceTexture.getRenderWidth(), c = this._sourceTexture.getRenderHeight(); s.onApply = function (e, t) { return function (i) { i.setTexture("sourceTexture", n._sourceTexture), i.setFloat2("texSize", e, t) } }(l, c), this._reductionSteps.push(s); for (var u = 1; l > 1 || c > 1;) { l = Math.max(Math.round(l / 2), 1), c = Math.max(Math.round(c / 2), 1); var h = new Ia("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; t < this._reductionSteps.length; ++t)this._reductionSteps[t].dispose(); this._reductionSteps = null } this._postProcessManager && e && this._postProcessManager.dispose(), this._sourceTexture = null }, e }(), Km = function (e) { function t(t) { return e.call(this, t) || this } return W(t, e), Object.defineProperty(t.prototype, "depthRenderer", { get: function () { return this._depthRenderer }, enumerable: !1, configurable: !0 }), t.prototype.setDepthRenderer = function (t, i, r) { void 0 === t && (t = null), void 0 === i && (i = a.TEXTURETYPE_HALF_FLOAT), void 0 === r && (r = !0); var n = this._camera.getScene(); this._depthRenderer && (delete n._depthRenderer[this._depthRendererId], this._depthRenderer.dispose(), this._depthRenderer = null), null === t && (n._depthRenderer || (n._depthRenderer = {}), (t = this._depthRenderer = new jm(n, i, this._camera, !1, a.TEXTURE_NEAREST_SAMPLINGMODE)).enabled = !1, this._depthRendererId = "minmax" + this._camera.id, n._depthRenderer[this._depthRendererId] = t), e.prototype.setSourceTexture.call(this, t.getDepthMap(), !0, i, r) }, t.prototype.setSourceTexture = function (t, i, r, n) { void 0 === r && (r = a.TEXTURETYPE_HALF_FLOAT), void 0 === n && (n = !0), e.prototype.setSourceTexture.call(this, t, i, r, n) }, t.prototype.activate = function () { this._depthRenderer && (this._depthRenderer.enabled = !0), e.prototype.activate.call(this) }, t.prototype.deactivate = function () { e.prototype.deactivate.call(this), this._depthRenderer && (this._depthRenderer.enabled = !1) }, t.prototype.dispose = function (t) { if (void 0 === t && (t = !0), e.prototype.dispose.call(this, t), this._depthRenderer && t) { var i = this._depthRenderer.getDepthMap().getScene(); i && delete i._depthRenderer[this._depthRendererId], this._depthRenderer.dispose(), this._depthRenderer = null } }, t }(Ym), Qm = R.Up(), qm = R.Zero(), Zm = new R, Jm = new R, $m = new I, eg = function (e) { function t(i, r, n, o, a) { void 0 === a && (a = !0); var s = this; return t.IsSupported ? ((s = e.call(this, i, r, n, o, a) || this).usePercentageCloserFiltering = !0, s) : ($.Error("CascadedShadowMap is not supported by the current engine."), s) } return W(t, e), t.prototype._validateFilter = function (e) { return e === Xm.FILTER_NONE || e === Xm.FILTER_PCF || e === Xm.FILTER_PCSS ? e : (console.error('Unsupported filter "' + e + '"!'), Xm.FILTER_NONE) }, Object.defineProperty(t.prototype, "numCascades", { get: function () { return this._numCascades }, set: function (e) { (e = Math.min(Math.max(e, t.MIN_CASCADES_COUNT), t.MAX_CASCADES_COUNT)) !== this._numCascades && (this._numCascades = e, this.recreateShadowMap(), this._recreateSceneUBOs()) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "freezeShadowCastersBoundingInfo", { get: function () { return this._freezeShadowCastersBoundingInfo }, set: function (e) { this._freezeShadowCastersBoundingInfoObservable && e && (this._scene.onBeforeRenderObservable.remove(this._freezeShadowCastersBoundingInfoObservable), this._freezeShadowCastersBoundingInfoObservable = null), this._freezeShadowCastersBoundingInfoObservable || e || (this._freezeShadowCastersBoundingInfoObservable = this._scene.onBeforeRenderObservable.add(this._computeShadowCastersBoundingInfo.bind(this))), this._freezeShadowCastersBoundingInfo = e, e && this._computeShadowCastersBoundingInfo() }, enumerable: !1, configurable: !0 }), t.prototype._computeShadowCastersBoundingInfo = function () { if (this._scbiMin.copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), this._scbiMax.copyFromFloats(Number.MIN_VALUE, Number.MIN_VALUE, Number.MIN_VALUE), this._shadowMap && this._shadowMap.renderList) { for (var e = this._shadowMap.renderList, t = 0; t < e.length; t++)if (n = e[t]) { var i = n.getBoundingInfo().boundingBox; this._scbiMin.minimizeInPlace(i.minimumWorld), this._scbiMax.maximizeInPlace(i.maximumWorld) } var r = this._scene.meshes; for (t = 0; t < r.length; t++) { var n; (n = r[t]) && n.isVisible && n.isEnabled && n.receiveShadows && (i = n.getBoundingInfo().boundingBox, this._scbiMin.minimizeInPlace(i.minimumWorld), this._scbiMax.maximizeInPlace(i.maximumWorld)) } } this._shadowCastersBoundingInfo.reConstruct(this._scbiMin, this._scbiMax) }, Object.defineProperty(t.prototype, "shadowCastersBoundingInfo", { get: function () { return this._shadowCastersBoundingInfo }, set: function (e) { this._shadowCastersBoundingInfo = e }, enumerable: !1, configurable: !0 }), t.prototype.setMinMaxDistance = function (e, t) { this._minDistance === e && this._maxDistance === t || (e > t && (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 < this._numCascades ? this._cascadeMinExtents[e] : null }, t.prototype.getCascadeMaxExtents = function (e) { return e >= 0 && e < this._numCascades ? this._cascadeMaxExtents[e] : null }, Object.defineProperty(t.prototype, "shadowMaxZ", { get: function () { return this._getCamera() ? this._shadowMaxZ : 0 }, set: function (e) { var t = this._getCamera(); t ? this._shadowMaxZ === e || e < t.minZ || e > 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 < this._numCascades ? this._viewMatrices[e] : null }, t.prototype.getCascadeProjectionMatrix = function (e) { return e >= 0 && e < this._numCascades ? this._projectionMatrices[e] : null }, t.prototype.getCascadeTransformMatrix = function (e) { return e >= 0 && e < this._numCascades ? this._transformMatrices[e] : null }, t.prototype.setDepthRenderer = function (e) { this._depthRenderer = e, this._depthReducer && this._depthReducer.setDepthRenderer(this._depthRenderer) }, Object.defineProperty(t.prototype, "autoCalcDepthBounds", { get: function () { return this._autoCalcDepthBounds }, set: function (e) { var t = this, i = this._getCamera(); if (i) { if (this._autoCalcDepthBounds = e, !e) return this._depthReducer && this._depthReducer.deactivate(), void this.setMinMaxDistance(0, 1); this._depthReducer || (this._depthReducer = new Km(i), this._depthReducer.onAfterReductionPerformed.add((function (e) { var i = e.min, r = e.max; i >= 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 < i && this._shadowMaxZ >= t ? Math.min((this._shadowMaxZ - t) / (i - t), this._maxDistance) : this._maxDistance) * r, s = a - o, l = a / o, c = 0; c < this._cascades.length; ++c) { var u = (c + 1) / this._numCascades, h = o * Math.pow(l, u), d = o + s * u, p = this._lambda * (h - d) + d; this._cascades[c].prevBreakDistance = 0 === c ? n : this._cascades[c - 1].breakDistance, this._cascades[c].breakDistance = (p - t) / r, this._viewSpaceFrustumsZ[c] = p, this._frustumLengths[c] = (this._cascades[c].breakDistance - this._cascades[c].prevBreakDistance) * r } this._breaksAreDirty = !1 } }, t.prototype._computeMatrices = function () { var e = this._scene; if (this._getCamera()) { R.NormalizeToRef(this._light.getShadowDirection(0), this._lightDirection), 1 === Math.abs(R.Dot(this._lightDirection, R.Up())) && (this._lightDirection.z = 1e-13), this._cachedDirection.copyFrom(this._lightDirection); for (var t = e.getEngine().useReverseDepthBuffer, i = 0; i < this._numCascades; ++i) { this._computeFrustumInWorldSpace(i), this._computeCascadeFrustum(i), this._cascadeMaxExtents[i].subtractToRef(this._cascadeMinExtents[i], Zm), this._frustumCenter[i].addToRef(this._lightDirection.scale(this._cascadeMinExtents[i].z), this._shadowCameraPos[i]), I.LookAtLHToRef(this._shadowCameraPos[i], this._frustumCenter[i], Qm, this._viewMatrices[i]); var r = 0, n = Zm.z, o = this._shadowCastersBoundingInfo; o.update(this._viewMatrices[i]), n = Math.min(n, o.boundingBox.maximumWorld.z), r = this._depthClamp && this.filter !== Xm.FILTER_PCSS ? Math.max(r, o.boundingBox.minimumWorld.z) : Math.min(r, o.boundingBox.minimumWorld.z), I.OrthoOffCenterLHToRef(this._cascadeMinExtents[i].x, this._cascadeMaxExtents[i].x, this._cascadeMinExtents[i].y, this._cascadeMaxExtents[i].y, t ? n : r, t ? r : n, this._projectionMatrices[i], e.getEngine().isNDCHalfZRange), this._cascadeMinExtents[i].z = r, this._cascadeMaxExtents[i].z = n, this._viewMatrices[i].multiplyToRef(this._projectionMatrices[i], this._transformMatrices[i]), R.TransformCoordinatesToRef(qm, this._transformMatrices[i], Zm), Zm.scaleInPlace(this._mapSize / 2), Jm.copyFromFloats(Math.round(Zm.x), Math.round(Zm.y), Math.round(Zm.z)), Jm.subtractInPlace(Zm).scaleInPlace(2 / this._mapSize), I.TranslationToRef(Jm.x, Jm.y, 0, $m), this._projectionMatrices[i].multiplyToRef($m, this._projectionMatrices[i]), this._viewMatrices[i].multiplyToRef(this._projectionMatrices[i], this._transformMatrices[i]), this._transformMatrices[i].copyToArray(this._transformMatricesAsArray, 16 * i) } } }, t.prototype._computeFrustumInWorldSpace = function (e) { var i = this._getCamera(); if (i) { var r = this._cascades[e].prevBreakDistance, n = this._cascades[e].breakDistance, o = this._scene.getEngine().isNDCHalfZRange; i.getViewMatrix(); var a = 0 === i.maxZ, s = i.maxZ; a && (i.maxZ = this._shadowMaxZ, i.getProjectionMatrix(!0)); var l = I.Invert(i.getTransformationMatrix()); a && (i.maxZ = s, i.getProjectionMatrix(!0)); for (var c = this._scene.getEngine().useReverseDepthBuffer ? 4 : 0, u = 0; u < t._FrustumCornersNDCSpace.length; ++u)Zm.copyFrom(t._FrustumCornersNDCSpace[(u + c) % t._FrustumCornersNDCSpace.length]), o && -1 === Zm.z && (Zm.z = 0), R.TransformCoordinatesToRef(Zm, l, this._frustumCornersWorldSpace[e][u]); for (u = 0; u < t._FrustumCornersNDCSpace.length / 2; ++u)Zm.copyFrom(this._frustumCornersWorldSpace[e][u + 4]).subtractInPlace(this._frustumCornersWorldSpace[e][u]), Jm.copyFrom(Zm).scaleInPlace(r), Zm.scaleInPlace(n), Zm.addInPlace(this._frustumCornersWorldSpace[e][u]), this._frustumCornersWorldSpace[e][u + 4].copyFrom(Zm), this._frustumCornersWorldSpace[e][u].addInPlace(Jm) } }, t.prototype._computeCascadeFrustum = function (e) { if (this._cascadeMinExtents[e].copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), this._cascadeMaxExtents[e].copyFromFloats(Number.MIN_VALUE, Number.MIN_VALUE, Number.MIN_VALUE), this._frustumCenter[e].copyFromFloats(0, 0, 0), this._getCamera()) { for (var t = 0; t < this._frustumCornersWorldSpace[e].length; ++t)this._frustumCenter[e].addInPlace(this._frustumCornersWorldSpace[e][t]); if (this._frustumCenter[e].scaleInPlace(1 / this._frustumCornersWorldSpace[e].length), this.stabilizeCascades) { var i = 0; for (t = 0; t < this._frustumCornersWorldSpace[e].length; ++t) { var r = this._frustumCornersWorldSpace[e][t].subtractToRef(this._frustumCenter[e], Zm).length(); i = Math.max(i, r) } i = Math.ceil(16 * i) / 16, this._cascadeMaxExtents[e].copyFromFloats(i, i, i), this._cascadeMinExtents[e].copyFromFloats(-i, -i, -i) } else { var n = this._frustumCenter[e]; for (this._frustumCenter[e].addToRef(this._lightDirection, Zm), I.LookAtLHToRef(n, Zm, Qm, $m), t = 0; t < this._frustumCornersWorldSpace[e].length; ++t)R.TransformCoordinatesToRef(this._frustumCornersWorldSpace[e][t], $m, Zm), this._cascadeMinExtents[e].minimizeInPlace(Zm), this._cascadeMaxExtents[e].maximizeInPlace(Zm) } } }, t.prototype._recreateSceneUBOs = function () { if (this._disposeSceneUBOs(), this._sceneUBOs) for (var e = 0; e < this._numCascades; ++e)this._sceneUBOs.push(this._scene.createSceneUniformBuffer('Scene for CSM Shadow Generator (light "'.concat(this._light.name, '" cascade #').concat(e, ")"))) }, Object.defineProperty(t, "IsSupported", { get: function () { var e = S.LastCreatedEngine; return !!e && e._features.supportCSM }, enumerable: !1, configurable: !0 }), t.prototype._initializeGenerator = function () { var i, r, n, o, a, s, l, c, u, h, d, p, f, _, m, g, v, y, b, T; this.penumbraDarkness = null !== (i = this.penumbraDarkness) && void 0 !== i ? i : 1, this._numCascades = null !== (r = this._numCascades) && void 0 !== r ? r : t.DEFAULT_CASCADES_COUNT, this.stabilizeCascades = null !== (n = this.stabilizeCascades) && void 0 !== n && n, this._freezeShadowCastersBoundingInfoObservable = null !== (o = this._freezeShadowCastersBoundingInfoObservable) && void 0 !== o ? o : null, this.freezeShadowCastersBoundingInfo = null !== (a = this.freezeShadowCastersBoundingInfo) && void 0 !== a && a, this._scbiMin = null !== (s = this._scbiMin) && void 0 !== s ? s : new R(0, 0, 0), this._scbiMax = null !== (l = this._scbiMax) && void 0 !== l ? l : new R(0, 0, 0), this._shadowCastersBoundingInfo = null !== (c = this._shadowCastersBoundingInfo) && void 0 !== c ? c : new mn(new R(0, 0, 0), new R(0, 0, 0)), this._breaksAreDirty = null === (u = this._breaksAreDirty) || void 0 === u || u, this._minDistance = null !== (h = this._minDistance) && void 0 !== h ? h : 0, this._maxDistance = null !== (d = this._maxDistance) && void 0 !== d ? d : 1, this._currentLayer = null !== (p = this._currentLayer) && void 0 !== p ? p : 0, this._shadowMaxZ = null !== (m = null !== (f = this._shadowMaxZ) && void 0 !== f ? f : null === (_ = this._getCamera()) || void 0 === _ ? void 0 : _.maxZ) && void 0 !== m ? m : 1e4, this._debug = null !== (g = this._debug) && void 0 !== g && g, this._depthClamp = null === (v = this._depthClamp) || void 0 === v || v, this._cascadeBlendPercentage = null !== (y = this._cascadeBlendPercentage) && void 0 !== y ? y : .1, this._lambda = null !== (b = this._lambda) && void 0 !== b ? b : .5, this._autoCalcDepthBounds = null !== (T = this._autoCalcDepthBounds) && void 0 !== T && T, this._recreateSceneUBOs(), e.prototype._initializeGenerator.call(this) }, t.prototype._createTargetRenderTexture = function () { var e = this._scene.getEngine(), t = { width: this._mapSize, height: this._mapSize, layers: this.numCascades }; this._shadowMap = new es(this._light.name + "_CSMShadowMap", t, this._scene, !1, !0, this._textureType, !1, void 0, !1, !1, void 0, this._useRedTextureType ? a.TEXTUREFORMAT_RED : a.TEXTUREFORMAT_RGBA), this._shadowMap.createDepthStencilTexture(e.useReverseDepthBuffer ? a.GREATER : a.LESS, !0), this._shadowMap.noPrePassRenderer = !0 }, t.prototype._initializeShadowMap = function () { var i = this; if (e.prototype._initializeShadowMap.call(this), null !== this._shadowMap) { this._transformMatricesAsArray = new Float32Array(16 * this._numCascades), this._viewSpaceFrustumsZ = new Array(this._numCascades), this._frustumLengths = new Array(this._numCascades), this._lightSizeUVCorrection = new Array(2 * this._numCascades), this._depthCorrection = new Array(this._numCascades), this._cascades = [], this._viewMatrices = [], this._projectionMatrices = [], this._transformMatrices = [], this._cascadeMinExtents = [], this._cascadeMaxExtents = [], this._frustumCenter = [], this._shadowCameraPos = [], this._frustumCornersWorldSpace = []; for (var r = 0; r < this._numCascades; ++r) { this._cascades[r] = { prevBreakDistance: 0, breakDistance: 0 }, this._viewMatrices[r] = I.Zero(), this._projectionMatrices[r] = I.Zero(), this._transformMatrices[r] = I.Zero(), this._cascadeMinExtents[r] = new R, this._cascadeMaxExtents[r] = new R, this._frustumCenter[r] = new R, this._shadowCameraPos[r] = new R, this._frustumCornersWorldSpace[r] = new Array(t._FrustumCornersNDCSpace.length); for (var n = 0; n < t._FrustumCornersNDCSpace.length; ++n)this._frustumCornersWorldSpace[r][n] = new R } var o = this._scene.getEngine(); this._shadowMap.onBeforeBindObservable.clear(), this._shadowMap.onBeforeRenderObservable.clear(), this._shadowMap.onBeforeRenderObservable.add((function (e) { i._sceneUBOs && i._scene.setSceneUniformBuffer(i._sceneUBOs[e]), i._currentLayer = e, i._filter === Xm.FILTER_PCF && o.setColorWrite(!1), i._scene.setTransformMatrix(i.getCascadeViewMatrix(e), i.getCascadeProjectionMatrix(e)), i._useUBO && (i._scene.getSceneUniformBuffer().unbindEffect(), i._scene.finalizeSceneUbo()) })), this._shadowMap.onBeforeBindObservable.add((function () { var e; i._currentSceneUBO = i._scene.getSceneUniformBuffer(), null === (e = o._debugPushGroup) || void 0 === e || e.call(o, "cascaded shadow map generation for pass id ".concat(o.currentRenderPassId), 1), i._breaksAreDirty && i._splitFrustum(), i._computeMatrices() })), this._splitFrustum() } }, t.prototype._bindCustomEffectForRenderSubMeshForShadowMap = function (e, t) { t.setMatrix("viewProjection", this.getCascadeTransformMatrix(this._currentLayer)) }, t.prototype._isReadyCustomDefines = function (e) { e.push("#define SM_DEPTHCLAMP " + (this._depthClamp && this._filter !== Xm.FILTER_PCSS ? "1" : "0")) }, t.prototype.prepareDefines = function (t, i) { e.prototype.prepareDefines.call(this, t, i); var r = this._scene, n = this._light; if (r.shadowsEnabled && n.shadowEnabled) { t["SHADOWCSM" + i] = !0, t["SHADOWCSMDEBUG" + i] = this.debug, t["SHADOWCSMNUM_CASCADES" + i] = this.numCascades, t["SHADOWCSM_RIGHTHANDED" + i] = r.useRightHandedSystem; var o = this._getCamera(); o && this._shadowMaxZ <= (o.maxZ || this._shadowMaxZ) && (t["SHADOWCSMUSESHADOWMAXZ" + i] = !0), 0 === this.cascadeBlendPercentage && (t["SHADOWCSMNOBLEND" + i] = !0) } }, t.prototype.bindShadowLight = function (e, t) { var i = this._light; if (this._scene.shadowsEnabled && i.shadowEnabled) { var r = this._getCamera(); if (r) { var n = this.getShadowMap(); if (n) { var o = n.getSize().width; if (t.setMatrices("lightMatrix" + e, this._transformMatricesAsArray), t.setArray("viewFrustumZ" + e, this._viewSpaceFrustumsZ), t.setFloat("cascadeBlendFactor" + e, 0 === this.cascadeBlendPercentage ? 1e4 : 1 / this.cascadeBlendPercentage), t.setArray("frustumLengths" + e, this._frustumLengths), this._filter === Xm.FILTER_PCF) t.setDepthStencilTexture("shadowSampler" + e, n), i._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), o, 1 / o, this.frustumEdgeFalloff, e); else if (this._filter === Xm.FILTER_PCSS) { for (var a = 0; a < this._numCascades; ++a)this._lightSizeUVCorrection[2 * a + 0] = 0 === a ? 1 : (this._cascadeMaxExtents[0].x - this._cascadeMinExtents[0].x) / (this._cascadeMaxExtents[a].x - this._cascadeMinExtents[a].x), this._lightSizeUVCorrection[2 * a + 1] = 0 === a ? 1 : (this._cascadeMaxExtents[0].y - this._cascadeMinExtents[0].y) / (this._cascadeMaxExtents[a].y - this._cascadeMinExtents[a].y), this._depthCorrection[a] = 0 === a ? 1 : (this._cascadeMaxExtents[a].z - this._cascadeMinExtents[a].z) / (this._cascadeMaxExtents[0].z - this._cascadeMinExtents[0].z); t.setDepthStencilTexture("shadowSampler" + e, n), t.setTexture("depthSampler" + e, n), t.setArray2("lightSizeUVCorrection" + e, this._lightSizeUVCorrection), t.setArray("depthCorrection" + e, this._depthCorrection), t.setFloat("penumbraDarkness" + e, this.penumbraDarkness), i._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / o, this._contactHardeningLightSizeUVRatio * o, this.frustumEdgeFalloff, e) } else t.setTexture("shadowSampler" + e, n), i._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), o, 1 / o, this.frustumEdgeFalloff, e); i._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(r), this.getLight().getDepthMinZ(r) + this.getLight().getDepthMaxZ(r), e) } } } }, t.prototype.getTransformMatrix = function () { return this.getCascadeTransformMatrix(0) }, t.prototype.dispose = function () { e.prototype.dispose.call(this), this._freezeShadowCastersBoundingInfoObservable && (this._scene.onBeforeRenderObservable.remove(this._freezeShadowCastersBoundingInfoObservable), this._freezeShadowCastersBoundingInfoObservable = null), this._depthReducer && (this._depthReducer.dispose(), this._depthReducer = null) }, t.prototype.serialize = function () { var t = e.prototype.serialize.call(this), i = this.getShadowMap(); if (!i) return t; if (t.numCascades = this._numCascades, t.debug = this._debug, t.stabilizeCascades = this.stabilizeCascades, t.lambda = this._lambda, t.cascadeBlendPercentage = this.cascadeBlendPercentage, t.depthClamp = this._depthClamp, t.autoCalcDepthBounds = this.autoCalcDepthBounds, t.shadowMaxZ = this._shadowMaxZ, t.penumbraDarkness = this.penumbraDarkness, t.freezeShadowCastersBoundingInfo = this._freezeShadowCastersBoundingInfo, t.minDistance = this.minDistance, t.maxDistance = this.maxDistance, t.renderList = [], i.renderList) for (var r = 0; r < i.renderList.length; r++) { var n = i.renderList[r]; t.renderList.push(n.id) } return t }, t.Parse = function (e, i) { var r = Xm.Parse(e, i, (function (e, i, r) { return new t(e, i, void 0, r) })); return void 0 !== e.numCascades && (r.numCascades = e.numCascades), void 0 !== e.debug && (r.debug = e.debug), void 0 !== e.stabilizeCascades && (r.stabilizeCascades = e.stabilizeCascades), void 0 !== e.lambda && (r.lambda = e.lambda), void 0 !== e.cascadeBlendPercentage && (r.cascadeBlendPercentage = e.cascadeBlendPercentage), void 0 !== e.depthClamp && (r.depthClamp = e.depthClamp), void 0 !== e.autoCalcDepthBounds && (r.autoCalcDepthBounds = e.autoCalcDepthBounds), void 0 !== e.shadowMaxZ && (r.shadowMaxZ = e.shadowMaxZ), void 0 !== e.penumbraDarkness && (r.penumbraDarkness = e.penumbraDarkness), void 0 !== e.freezeShadowCastersBoundingInfo && (r.freezeShadowCastersBoundingInfo = e.freezeShadowCastersBoundingInfo), void 0 !== e.minDistance && void 0 !== e.maxDistance && r.setMinMaxDistance(e.minDistance, e.maxDistance), r }, t._FrustumCornersNDCSpace = [new R(-1, 1, -1), new R(1, 1, -1), new R(1, -1, -1), new R(-1, -1, -1), new R(-1, 1, 1), new R(1, 1, 1), new R(1, -1, 1), new R(-1, -1, 1)], t.CLASSNAME = "CascadedShadowGenerator", t.DEFAULT_CASCADES_COUNT = 4, t.MIN_CASCADES_COUNT = 2, t.MAX_CASCADES_COUNT = 4, t._SceneComponentInitialization = function (e) { throw ge("ShadowGeneratorSceneComponent") }, t }(Xm); o.AddParser(qi.NAME_SHADOWGENERATOR, (function (e, t) { if (void 0 !== e.shadowGenerators && null !== e.shadowGenerators) for (var i = 0, r = e.shadowGenerators.length; i < r; i++) { var n = e.shadowGenerators[i]; n.className === eg.CLASSNAME ? eg.Parse(n, t) : Xm.Parse(n, t) } })); var tg = function () { function e(e) { this.name = qi.NAME_SHADOWGENERATOR, this.scene = e } return e.prototype.register = function () { this.scene._gatherRenderTargetsStage.registerStep(qi.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR, this, this._gatherRenderTargets) }, e.prototype.rebuild = function () { }, e.prototype.serialize = function (e) { e.shadowGenerators = []; for (var t = 0, i = this.scene.lights; t < i.length; t++) { var r = i[t].getShadowGenerators(); if (r) for (var n = r.values(), o = n.next(); !0 !== o.done; o = n.next()) { var a = o.value; e.shadowGenerators.push(a.serialize()) } } }, e.prototype.addFromContainer = function (e) { }, e.prototype.removeFromContainer = function (e, t) { }, e.prototype.dispose = function () { }, e.prototype._gatherRenderTargets = function (e) { var t = this.scene; if (this.scene.shadowsEnabled) for (var i = 0; i < t.lights.length; i++) { var r = t.lights[i], n = r.getShadowGenerators(); if (r.isEnabled() && r.shadowEnabled && n) for (var o = n.values(), a = o.next(); !0 !== a.done; a = o.next()) { var s = a.value.getShadowMap(); -1 !== t.textures.indexOf(s) && e.push(s) } } }, e }(); Xm._SceneComponentInitialization = function (e) { var t = e._getComponent(qi.NAME_SHADOWGENERATOR); t || (t = new tg(e), e._addComponent(t)) }, ze.AddNodeConstructor("Light_Type_0", (function (e, t) { return function () { return new ig(e, R.Zero(), t) } })); var ig = function (e) { function t(t, i, r) { var n = e.call(this, t, r) || this; return n._shadowAngle = Math.PI / 2, n.position = i, n } return W(t, e), Object.defineProperty(t.prototype, "shadowAngle", { get: function () { return this._shadowAngle }, set: function (e) { this._shadowAngle = e, this.forceProjectionMatrixCompute() }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "direction", { get: function () { return this._direction }, set: function (e) { var t = this.needCube(); if (this._direction = e, this.needCube() !== t && this._shadowGenerators) for (var i = this._shadowGenerators.values(), r = i.next(); !0 !== r.done; r = i.next())r.value.recreateShadowMap() }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function () { return "PointLight" }, t.prototype.getTypeID = function () { return eo.LIGHTTYPEID_POINTLIGHT }, t.prototype.needCube = function () { return !this.direction }, t.prototype.getShadowDirection = function (t) { if (this.direction) return e.prototype.getShadowDirection.call(this, t); switch (t) { case 0: return new R(1, 0, 0); case 1: return new R(-1, 0, 0); case 2: return new R(0, -1, 0); case 3: return new R(0, 1, 0); case 4: return new R(0, 0, 1); case 5: return new R(0, 0, -1) }return R.Zero() }, t.prototype._setDefaultShadowProjectionMatrix = function (e, t, i) { var r = this.getScene().activeCamera; if (r) { var n = void 0 !== this.shadowMinZ ? this.shadowMinZ : r.minZ, o = void 0 !== this.shadowMaxZ ? this.shadowMaxZ : r.maxZ, a = this.getScene().getEngine().useReverseDepthBuffer; I.PerspectiveFovLHToRef(this.shadowAngle, 1, a ? o : n, a ? n : o, e, !0, this._scene.getEngine().isNDCHalfZRange, void 0, a) } }, t.prototype._buildUniformLayout = function () { this._uniformBuffer.addUniform("vLightData", 4), this._uniformBuffer.addUniform("vLightDiffuse", 4), this._uniformBuffer.addUniform("vLightSpecular", 4), this._uniformBuffer.addUniform("vLightFalloff", 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.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0, t) : this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, 0, t), this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, t), this }, t.prototype.transferToNodeMaterialEffect = function (e, t) { return this.computeTransformedInformation() ? e.setFloat3(t, this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z) : e.setFloat3(t, this.position.x, this.position.y, this.position.z), this }, t.prototype.prepareLightSpecificDefines = function (e, t) { e["POINTLIGHT" + t] = !0 }, X([xe()], t.prototype, "shadowAngle", null), t }(i_), rg = function () { function e(e, t, i) { void 0 === t && (t = ""), void 0 === i && (i = "black"); var r = this; this._renderingCanvas = e, this._loadingText = t, this._loadingDivBackgroundColor = i, this._resizeLoadingUI = function () { var e = r._renderingCanvas.getBoundingClientRect(), t = window.getComputedStyle(r._renderingCanvas).position; r._loadingDiv && (r._loadingDiv.style.position = "fixed" === t ? "fixed" : "absolute", r._loadingDiv.style.left = e.left + "px", r._loadingDiv.style.top = e.top + "px", r._loadingDiv.style.width = e.width + "px", r._loadingDiv.style.height = e.height + "px") } } return e.prototype.displayLoadingUI = function () { if (!this._loadingDiv) { this._loadingDiv = document.createElement("div"), this._loadingDiv.id = "babylonjsLoadingDiv", this._loadingDiv.style.opacity = "0", this._loadingDiv.style.transition = "opacity 1.5s ease", this._loadingDiv.style.pointerEvents = "none", this._loadingDiv.style.display = "grid", this._loadingDiv.style.gridTemplateRows = "100%", this._loadingDiv.style.gridTemplateColumns = "100%", this._loadingDiv.style.justifyItems = "center", this._loadingDiv.style.alignItems = "center", this._loadingTextDiv = document.createElement("div"), this._loadingTextDiv.style.position = "absolute", this._loadingTextDiv.style.left = "0", this._loadingTextDiv.style.top = "50%", this._loadingTextDiv.style.marginTop = "80px", this._loadingTextDiv.style.width = "100%", this._loadingTextDiv.style.height = "20px", this._loadingTextDiv.style.fontFamily = "Arial", this._loadingTextDiv.style.fontSize = "14px", this._loadingTextDiv.style.color = "white", this._loadingTextDiv.style.textAlign = "center", this._loadingTextDiv.style.zIndex = "1", this._loadingTextDiv.innerHTML = "Loading", this._loadingDiv.appendChild(this._loadingTextDiv), this._loadingTextDiv.innerHTML = this._loadingText, this._style = document.createElement("style"), this._style.type = "text/css", this._style.innerHTML = "@-webkit-keyframes spin1 { 0% { -webkit-transform: rotate(0deg);}\n 100% { -webkit-transform: rotate(360deg);}\n } @keyframes spin1 { 0% { transform: rotate(0deg);}\n 100% { transform: rotate(360deg);}\n }", document.getElementsByTagName("head")[0].appendChild(this._style); var t = !!window.SVGSVGElement, i = new Image; e.DefaultLogoUrl ? i.src = e.DefaultLogoUrl : i.src = t ? "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxODAuMTcgMjA4LjA0Ij48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2ZmZjt9LmNscy0ye2ZpbGw6I2UwNjg0Yjt9LmNscy0ze2ZpbGw6I2JiNDY0Yjt9LmNscy00e2ZpbGw6I2UwZGVkODt9LmNscy01e2ZpbGw6I2Q1ZDJjYTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPkJhYnlsb25Mb2dvPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iUGFnZV9FbGVtZW50cyIgZGF0YS1uYW1lPSJQYWdlIEVsZW1lbnRzIj48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik05MC4wOSwwLDAsNTJWMTU2bDkwLjA5LDUyLDkwLjA4LTUyVjUyWiIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtMiIgcG9pbnRzPSIxODAuMTcgNTIuMDEgMTUxLjk3IDM1LjczIDEyNC44NSA1MS4zOSAxNTMuMDUgNjcuNjcgMTgwLjE3IDUyLjAxIi8+PHBvbHlnb24gY2xhc3M9ImNscy0yIiBwb2ludHM9IjI3LjEyIDY3LjY3IDExNy4yMSAxNS42NiA5MC4wOCAwIDAgNTIuMDEgMjcuMTIgNjcuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTIiIHBvaW50cz0iNjEuODkgMTIwLjMgOTAuMDggMTM2LjU4IDExOC4yOCAxMjAuMyA5MC4wOCAxMDQuMDIgNjEuODkgMTIwLjMiLz48cG9seWdvbiBjbGFzcz0iY2xzLTMiIHBvaW50cz0iMTUzLjA1IDY3LjY3IDE1My4wNSAxNDAuMzcgOTAuMDggMTc2LjcyIDI3LjEyIDE0MC4zNyAyNy4xMiA2Ny42NyAwIDUyLjAxIDAgMTU2LjAzIDkwLjA4IDIwOC4wNCAxODAuMTcgMTU2LjAzIDE4MC4xNyA1Mi4wMSAxNTMuMDUgNjcuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTMiIHBvaW50cz0iOTAuMDggNzEuNDYgNjEuODkgODcuNzQgNjEuODkgMTIwLjMgOTAuMDggMTA0LjAyIDExOC4yOCAxMjAuMyAxMTguMjggODcuNzQgOTAuMDggNzEuNDYiLz48cG9seWdvbiBjbGFzcz0iY2xzLTQiIHBvaW50cz0iMTUzLjA1IDY3LjY3IDExOC4yOCA4Ny43NCAxMTguMjggMTIwLjMgOTAuMDggMTM2LjU4IDkwLjA4IDE3Ni43MiAxNTMuMDUgMTQwLjM3IDE1My4wNSA2Ny42NyIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtNSIgcG9pbnRzPSIyNy4xMiA2Ny42NyA2MS44OSA4Ny43NCA2MS44OSAxMjAuMyA5MC4wOCAxMzYuNTggOTAuMDggMTc2LjcyIDI3LjEyIDE0MC4zNyAyNy4xMiA2Ny42NyIvPjwvZz48L2c+PC9zdmc+" : "https://cdn.babylonjs.com/Assets/babylonLogo.png", i.style.width = "150px", i.style.gridColumn = "1", i.style.gridRow = "1", i.style.top = "50%", i.style.left = "50%", i.style.transform = "translate(-50%, -50%)", i.style.position = "absolute"; var r = document.createElement("div"); r.style.width = "300px", r.style.gridColumn = "1", r.style.gridRow = "1", r.style.top = "50%", r.style.left = "50%", r.style.transform = "translate(-50%, -50%)", r.style.position = "absolute"; var n = new Image; if (e.DefaultSpinnerUrl ? n.src = e.DefaultSpinnerUrl : n.src = t ? "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzOTIgMzkyIj48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2UwNjg0Yjt9LmNscy0ye2ZpbGw6bm9uZTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPlNwaW5uZXJJY29uPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iU3Bpbm5lciI+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNNDAuMjEsMTI2LjQzYzMuNy03LjMxLDcuNjctMTQuNDQsMTItMjEuMzJsMy4zNi01LjEsMy41Mi01YzEuMjMtMS42MywyLjQxLTMuMjksMy42NS00LjkxczIuNTMtMy4yMSwzLjgyLTQuNzlBMTg1LjIsMTg1LjIsMCwwLDEsODMuNCw2Ny40M2EyMDgsMjA4LDAsMCwxLDE5LTE1LjY2YzMuMzUtMi40MSw2Ljc0LTQuNzgsMTAuMjUtN3M3LjExLTQuMjgsMTAuNzUtNi4zMmM3LjI5LTQsMTQuNzMtOCwyMi41My0xMS40OSwzLjktMS43Miw3Ljg4LTMuMywxMi00LjY0YTEwNC4yMiwxMDQuMjIsMCwwLDEsMTIuNDQtMy4yMyw2Mi40NCw2Mi40NCwwLDAsMSwxMi43OC0xLjM5QTI1LjkyLDI1LjkyLDAsMCwxLDE5NiwyMS40NGE2LjU1LDYuNTUsMCwwLDEsMi4wNSw5LDYuNjYsNi42NiwwLDAsMS0xLjY0LDEuNzhsLS40MS4yOWEyMi4wNywyMi4wNywwLDAsMS01Ljc4LDMsMzAuNDIsMzAuNDIsMCwwLDEtNS42NywxLjYyLDM3LjgyLDM3LjgyLDAsMCwxLTUuNjkuNzFjLTEsMC0xLjkuMTgtMi44NS4yNmwtMi44NS4yNHEtNS43Mi41MS0xMS40OCwxLjFjLTMuODQuNC03LjcxLjgyLTExLjU4LDEuNGExMTIuMzQsMTEyLjM0LDAsMCwwLTIyLjk0LDUuNjFjLTMuNzIsMS4zNS03LjM0LDMtMTAuOTQsNC42NHMtNy4xNCwzLjUxLTEwLjYsNS41MUExNTEuNiwxNTEuNiwwLDAsMCw2OC41Niw4N0M2Ny4yMyw4OC40OCw2Niw5MCw2NC42NCw5MS41NnMtMi41MSwzLjE1LTMuNzUsNC43M2wtMy41NCw0LjljLTEuMTMsMS42Ni0yLjIzLDMuMzUtMy4zMyw1YTEyNywxMjcsMCwwLDAtMTAuOTMsMjEuNDksMS41OCwxLjU4LDAsMSwxLTMtMS4xNVM0MC4xOSwxMjYuNDcsNDAuMjEsMTI2LjQzWiIvPjxyZWN0IGNsYXNzPSJjbHMtMiIgd2lkdGg9IjM5MiIgaGVpZ2h0PSIzOTIiLz48L2c+PC9nPjwvc3ZnPg==" : "https://cdn.babylonjs.com/Assets/loadingIcon.png", n.style.animation = "spin1 0.75s infinite linear", n.style.webkitAnimation = "spin1 0.75s infinite linear", n.style.transformOrigin = "50% 50%", n.style.webkitTransformOrigin = "50% 50%", !t) { var o = { w: 16, h: 18.5 }, a = { w: 30, h: 30 }; i.style.width = "".concat(o.w, "vh"), i.style.height = "".concat(o.h, "vh"), i.style.left = "calc(50% - ".concat(o.w / 2, "vh)"), i.style.top = "calc(50% - ".concat(o.h / 2, "vh)"), n.style.width = "".concat(a.w, "vh"), n.style.height = "".concat(a.h, "vh"), n.style.left = "calc(50% - ".concat(a.w / 2, "vh)"), n.style.top = "calc(50% - ".concat(a.h / 2, "vh)") } r.appendChild(n), this._loadingDiv.appendChild(i), this._loadingDiv.appendChild(r), this._resizeLoadingUI(), window.addEventListener("resize", this._resizeLoadingUI), this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor, document.body.appendChild(this._loadingDiv), this._loadingDiv.style.opacity = "1" } }, e.prototype.hideLoadingUI = function () { var e = this; this._loadingDiv && (this._loadingDiv.style.opacity = "0", this._loadingDiv.addEventListener("transitionend", (function () { e._loadingTextDiv && (e._loadingTextDiv.remove(), e._loadingTextDiv = null), e._loadingDiv && (e._loadingDiv.remove(), e._loadingDiv = null), e._style && (e._style.remove(), e._style = null), window.removeEventListener("resize", e._resizeLoadingUI) }))) }, Object.defineProperty(e.prototype, "loadingUIText", { get: function () { return this._loadingText }, set: function (e) { this._loadingText = e, this._loadingTextDiv && (this._loadingTextDiv.innerHTML = this._loadingText) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "loadingUIBackgroundColor", { get: function () { return this._loadingDivBackgroundColor }, set: function (e) { this._loadingDivBackgroundColor = e, this._loadingDiv && (this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor) }, enumerable: !1, configurable: !0 }), e.DefaultLogoUrl = "", e.DefaultSpinnerUrl = "", e }(); In.DefaultLoadingScreenFactory = function (e) { return new rg(e) }; var ng = function () { function e() { } return e.ConvertPanoramaToCubemap = function (e, t, i, r, n) { if (void 0 === n && (n = !1), !e) throw "ConvertPanoramaToCubemap: input cannot be null"; if (e.length != t * i * 3) throw "ConvertPanoramaToCubemap: input size is wrong"; return { front: this.CreateCubemapTexture(r, this.FACE_FRONT, e, t, i, n), back: this.CreateCubemapTexture(r, this.FACE_BACK, e, t, i, n), left: this.CreateCubemapTexture(r, this.FACE_LEFT, e, t, i, n), right: this.CreateCubemapTexture(r, this.FACE_RIGHT, e, t, i, n), up: this.CreateCubemapTexture(r, this.FACE_UP, e, t, i, n), down: this.CreateCubemapTexture(r, this.FACE_DOWN, e, t, i, n), size: r, type: a.TEXTURETYPE_FLOAT, format: a.TEXTUREFORMAT_RGB, gammaSpace: !1 } }, e.CreateCubemapTexture = function (e, t, i, r, n, o) { void 0 === o && (o = !1); for (var a = new ArrayBuffer(e * e * 4 * 3), s = new Float32Array(a), l = o ? Math.max(1, Math.round(r / 4 / e)) : 1, c = 1 / l, u = c * c, h = t[1].subtract(t[0]).scale(c / e), d = t[3].subtract(t[2]).scale(c / e), p = 1 / e, f = 0, _ = 0; _ < e; _++)for (var m = 0; m < l; m++) { for (var g = t[0], v = t[2], y = 0; y < e; y++)for (var b = 0; b < l; b++) { var T = v.subtract(g).scale(f).add(g); T.normalize(); var E = this.CalcProjectionSpherical(T, i, r, n); s[_ * e * 3 + 3 * y + 0] += E.r * u, s[_ * e * 3 + 3 * y + 1] += E.g * u, s[_ * e * 3 + 3 * y + 2] += E.b * u, g = g.add(h), v = v.add(d) } f += p * c } return s }, e.CalcProjectionSpherical = function (e, t, i, r) { for (var n = Math.atan2(e.z, e.x), o = Math.acos(e.y); n < -Math.PI;)n += 2 * Math.PI; for (; n > Math.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 }(), og = 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; n < e.length - t && "\n" != (r = String.fromCharCode(e[n])); n++)i += r; return i }, e.RGBE_ReadHeader = function (e) { var t, i, r = this._ReadStringLine(e, 0); if ("#" != r[0] || "?" != r[1]) throw "Bad HDR Format."; var n = !1, o = !1, a = 0; do { a += r.length + 1, "FORMAT=32-bit_rle_rgbe" == (r = this._ReadStringLine(e, a)) ? o = !0 : 0 == r.length && (n = !0) } while (!n); if (!o) throw "HDR Bad header format, unsupported FORMAT"; a += r.length + 1, r = this._ReadStringLine(e, a); var s = /^-Y (.*) \+X (.*)$/g.exec(r); if (!s || s.length < 3) throw "HDR Bad header format, no size"; if (i = parseInt(s[2]), t = parseInt(s[1]), i < 8 || i > 32767) 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 ng.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; u < h;)if (i = e[c++], r = e[c++], i > 128) { 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; g < a; g++)f[u++] = e[c++] } for (d = 0; d < l; d++)i = f[d], r = f[d + l], n = f[d + 2 * l], o = f[d + 3 * l], this._Rgbe2float(m, i, r, n, o, (t.height - s) * l * 3 + 3 * d); s-- } return m }, e._RGBEReadPixelsNOTRLE = function (e, t) { for (var i, r, n, o, a, s = t.height, l = t.width, c = t.dataPosition, u = new ArrayBuffer(t.width * t.height * 4 * 3), h = new Float32Array(u); s > 0;) { for (a = 0; a < t.width; a++)i = e[c++], r = e[c++], n = e[c++], o = e[c++], this._Rgbe2float(h, i, r, n, o, (t.height - s) * l * 3 + 3 * a); s-- } return h }, e }(); Ut.ShadersStore.hdrFilteringVertexShader = "attribute vec2 position;varying vec3 direction;uniform vec3 up;uniform vec3 right;uniform vec3 front;\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nmat3 view=mat3(up,right,front);direction=view*vec3(position,1.0);gl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}"; Ut.ShadersStore.hdrFilteringPixelShader = "#include\n#include\n#include\n#include\nuniform float alphaG;uniform samplerCube inputTexture;uniform vec2 vFilteringInfo;uniform float hdrScale;varying vec3 direction;void main() {vec3 color=radiance(alphaG,inputTexture,direction,vFilteringInfo);gl_FragColor=vec4(color*hdrScale,1.0);}"; var ag = function () { function e(e, t) { void 0 === t && (t = {}), this._lodGenerationOffset = 0, this._lodGenerationScale = .8, this.quality = a.TEXTURE_FILTERING_QUALITY_OFFLINE, this.hdrScale = 1, this._engine = e, this.hdrScale = t.hdrScale || this.hdrScale, this.quality = t.quality || this.quality } return e.prototype._createRenderTarget = function (e) { var t = a.TEXTURETYPE_UNSIGNED_BYTE; this._engine.getCaps().textureHalfFloatRender ? t = a.TEXTURETYPE_HALF_FLOAT : this._engine.getCaps().textureFloatRender && (t = a.TEXTURETYPE_FLOAT); var i = this._engine.createRenderTargetCubeTexture(e, { format: a.TEXTUREFORMAT_RGBA, type: t, createMipMaps: !0, generateMipMaps: !1, generateDepthBuffer: !1, generateStencilBuffer: !1, samplingMode: a.TEXTURE_NEAREST_SAMPLINGMODE }); return this._engine.updateTextureWrappingMode(i.texture, a.TEXTURE_CLAMP_ADDRESSMODE, a.TEXTURE_CLAMP_ADDRESSMODE, a.TEXTURE_CLAMP_ADDRESSMODE), this._engine.updateTextureSamplingMode(a.TEXTURE_TRILINEAR_SAMPLINGMODE, i.texture, !0), i }, e.prototype._prefilterInternal = function (e) { var t = e.getSize().width, i = h.ILog2(t) + 1, r = this._effectWrapper.effect, n = this._createRenderTarget(t); this._effectRenderer.saveStates(), this._effectRenderer.setViewport(); var o = e.getInternalTexture(); o && this._engine.updateTextureSamplingMode(a.TEXTURE_TRILINEAR_SAMPLINGMODE, o, !0), this._effectRenderer.applyEffectWrapper(this._effectWrapper); var s = [[new R(0, 0, -1), new R(0, -1, 0), new R(1, 0, 0)], [new R(0, 0, 1), new R(0, -1, 0), new R(-1, 0, 0)], [new R(1, 0, 0), new R(0, 0, 1), new R(0, 1, 0)], [new R(1, 0, 0), new R(0, 0, -1), new R(0, -1, 0)], [new R(1, 0, 0), new R(0, -1, 0), new R(0, 0, 1)], [new R(-1, 0, 0), new R(0, -1, 0), new R(0, 0, -1)]]; r.setFloat("hdrScale", this.hdrScale), r.setFloat2("vFilteringInfo", e.getSize().width, i), r.setTexture("inputTexture", e); for (var l = 0; l < 6; l++) { r.setVector3("up", s[l][0]), r.setVector3("right", s[l][1]), r.setVector3("front", s[l][2]); for (var c = 0; c < i; c++) { this._engine.bindFramebuffer(n, l, void 0, void 0, !0, c), this._effectRenderer.applyEffectWrapper(this._effectWrapper); var u = Math.pow(2, (c - this._lodGenerationOffset) / this._lodGenerationScale) / t; 0 === c && (u = 0), r.setFloat("alphaG", u), this._effectRenderer.draw() } } this._effectRenderer.restoreStates(), this._engine.restoreDefaultFramebuffer(), this._engine._releaseTexture(e._texture); var d = n.texture.type, p = n.texture.format; return n._swapAndDie(e._texture), e._texture.type = d, e._texture.format = p, e.gammaSpace = !1, e.lodGenerationOffset = this._lodGenerationOffset, e.lodGenerationScale = this._lodGenerationScale, e._prefiltered = !0, e }, e.prototype._createEffect = function (e, t) { var i = []; return e.gammaSpace && i.push("#define GAMMA_INPUT"), i.push("#define NUM_SAMPLES " + this.quality + "u"), new Ka({ engine: this._engine, name: "hdrFiltering", vertexShader: "hdrFiltering", fragmentShader: "hdrFiltering", samplerNames: ["inputTexture"], uniformNames: ["vSampleDirections", "vWeights", "up", "right", "front", "vFilteringInfo", "hdrScale", "alphaG"], useShaderStore: !0, defines: i, onCompiled: t }) }, e.prototype.isReady = function (e) { return e.isReady() && this._effectWrapper.effect.isReady() }, e.prototype.prefilter = function (e, t) { var i = this; return void 0 === t && (t = null), this._engine._features.allowTexturePrefiltering ? new Promise((function (r) { i._effectRenderer = new Ya(i._engine), i._effectWrapper = i._createEffect(e), i._effectWrapper.effect.executeWhenCompiled((function () { i._prefilterInternal(e), i._effectRenderer.dispose(), i._effectWrapper.dispose(), r(), t && t() })) })) : ($.Warn("HDR prefiltering is not available in WebGL 1., you can use real time filtering instead."), Promise.reject("HDR prefiltering is not available in WebGL 1., you can use real time filtering instead.")) }, e }(), sg = function (e) { function t(t, i, r, n, o, s, l, c, h, d) { void 0 === n && (n = !1), void 0 === o && (o = !0), void 0 === s && (s = !1), void 0 === l && (l = !1), void 0 === c && (c = null), void 0 === h && (h = null), void 0 === d && (d = !1); var p, f = this; return (f = e.call(this, i) || this)._generateHarmonics = !0, f._onError = null, f._isBlocking = !0, f._rotationY = 0, f.boundingBoxPosition = R.Zero(), f.onLoadObservable = new u, t ? (f._coordinatesMode = vo.CUBIC_MODE, f.name = t, f.url = t, f.hasAlpha = !1, f.isCube = !0, f._textureMatrix = I.Identity(), f._prefilterOnLoad = l, f._onLoad = function () { f.onLoadObservable.notifyObservers(f), c && c() }, f._onError = h, f.gammaSpace = s, f._noMipmap = n, f._size = r, f._supersample = d, f._generateHarmonics = o, f._texture = f._getFromCache(t, f._noMipmap, void 0, void 0, void 0, f.isCube), f._texture ? f._texture.isReady ? xi.SetImmediate((function () { return f._onLoad() })) : f._texture.onLoadedObservable.add(f._onLoad) : (null === (p = f.getScene()) || void 0 === p ? void 0 : p.useDelayedTextureLoading) ? f.delayLoadState = a.DELAYLOADSTATE_NOTLOADED : f._loadTexture(), f) : f } return W(t, e), Object.defineProperty(t.prototype, "isBlocking", { get: function () { return this._isBlocking }, set: function (e) { this._isBlocking = e }, 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, "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 }), t.prototype.getClassName = function () { return "HDRCubeTexture" }, t.prototype._loadTexture = function () { var e = this, i = this._getEngine(), r = i.getCaps(), n = a.TEXTURETYPE_UNSIGNED_BYTE; if (r.textureFloat && r.textureFloatLinearFiltering ? n = a.TEXTURETYPE_FLOAT : r.textureHalfFloat && r.textureHalfFloatLinearFiltering && (n = a.TEXTURETYPE_HALF_FLOAT), i._features.allowTexturePrefiltering && this._prefilterOnLoad) { var o = this._onLoad, s = new ag(i); this._onLoad = function () { s.prefilter(e, o) } } this._texture = i.createRawCubeTextureFromUrl(this.url, this.getScene(), this._size, a.TEXTUREFORMAT_RGB, n, this._noMipmap, (function (i) { e.lodGenerationOffset = 0, e.lodGenerationScale = .8; var r = og.GetCubeMapTextureData(i, e._size, e._supersample); if (e._generateHarmonics) { var o = dd.ConvertCubeMapToSphericalPolynomial(r); e.sphericalPolynomial = o } for (var s = [], l = null, c = null, u = 0; u < 6; u++) { n === a.TEXTURETYPE_HALF_FLOAT ? c = new Uint16Array(e._size * e._size * 3) : n === a.TEXTURETYPE_UNSIGNED_BYTE && (l = new Uint8Array(e._size * e._size * 3)); var h = r[t._FacesMapping[u]]; if (e.gammaSpace || c || l) for (var p = 0; p < e._size * e._size; p++)if (e.gammaSpace && (h[3 * p + 0] = Math.pow(h[3 * p + 0], d), h[3 * p + 1] = Math.pow(h[3 * p + 1], d), h[3 * p + 2] = Math.pow(h[3 * p + 2], d)), c && (c[3 * p + 0] = sd(h[3 * p + 0]), c[3 * p + 1] = sd(h[3 * p + 1]), c[3 * p + 2] = sd(h[3 * p + 2])), l) { var f = Math.max(255 * h[3 * p + 0], 0), _ = Math.max(255 * h[3 * p + 1], 0), m = Math.max(255 * h[3 * p + 2], 0), g = Math.max(Math.max(f, _), m); if (g > 255) { 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 }(po); b("BABYLON.HDRCubeTexture", sg); var lg = 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 = Ue.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())), Ue.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; n < t.animations.length; n++) { var o = t.animations[n], a = T("BABYLON.Animation"); a && r.animations.push(a.Parse(o)) } t.autoAnimate && i && i.beginAnimation(r, t.autoAnimateFrom, t.autoAnimateTo, t.autoAnimateLoop, t.autoAnimateSpeed || 1) } return r }, e.FromMesh = function (t, i, r) { i || (i = t.name); var n = new e(i, r, t.getScene()); return n.setPositions(t.getVerticesData(Hi.PositionKind)), t.isVerticesDataPresent(Hi.NormalKind) && n.setNormals(t.getVerticesData(Hi.NormalKind)), t.isVerticesDataPresent(Hi.TangentKind) && n.setTangents(t.getVerticesData(Hi.TangentKind)), t.isVerticesDataPresent(Hi.UVKind) && n.setUVs(t.getVerticesData(Hi.UVKind)), n }, X([xe()], e.prototype, "id", void 0), e }(), cg = function (e) { function t(t, i, r, n, o, s, l, c, u, h, d) { void 0 === l && (l = !0), void 0 === c && (c = !1), void 0 === u && (u = vo.TRILINEAR_SAMPLINGMODE), void 0 === h && (h = a.TEXTURETYPE_UNSIGNED_INT); var p = e.call(this, null, s, !l, c) || this; return p.format = o, p._texture = s.getEngine().createRawTexture2DArray(t, i, r, n, o, l, c, u, null, h, d), p._depth = n, p.is2DArray = !0, p } return W(t, e), Object.defineProperty(t.prototype, "depth", { get: function () { return this._depth }, enumerable: !1, configurable: !0 }), t.prototype.update = function (e) { this._texture && this._getEngine().updateRawTexture2DArray(this._texture, e, this._texture.format, this._texture.invertY, null, this._texture.type) }, t.CreateRGBATexture = function (e, i, r, n, o, s, l, c, u) { return 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), new t(e, i, r, n, a.TEXTUREFORMAT_RGBA, o, s, l, c, u) }, t }(vo), ug = function () { function e(e) { if (void 0 === e && (e = null), this._targets = new Array, this._targetInfluenceChangedObservers = new Array, this._targetDataLayoutChangedObservers = new Array, this._activeTargets = new Ci(16), this._supportsNormals = !1, this._supportsTangents = !1, this._supportsUVs = !1, this._vertexCount = 0, this._textureVertexStride = 0, this._textureWidth = 0, this._textureHeight = 1, this._uniqueId = 0, this._tempInfluences = new Array, this._canUseTextureForTargets = !1, this._blockCounter = 0, this._parentContainer = null, this.optimizeInfluencers = !0, this.enableNormalMorphing = !0, this.enableTangentMorphing = !0, this.enableUVMorphing = !0, this._useTextureToStoreTargets = !0, e || (e = S.LastCreatedScene), this._scene = e, this._scene) { this._scene.addMorphTargetManager(this), this._uniqueId = this._scene.getUniqueId(); var t = this._scene.getEngine().getCaps(); this._canUseTextureForTargets = t.canUseGLVertexID && t.textureFloat && t.maxVertexTextureImageUnits > 0 && 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; i < r.length; i++) { var n = r[i]; t.addTarget(n.clone()) } return t.enableNormalMorphing = this.enableNormalMorphing, t.enableTangentMorphing = this.enableTangentMorphing, t.enableUVMorphing = this.enableUVMorphing, t }, e.prototype.serialize = function () { var e = {}; e.id = this.uniqueId, e.targets = []; for (var t = 0, i = this._targets; t < i.length; t++) { var r = i[t]; e.targets.push(r.serialize()) } return e }, e.prototype._syncActiveTargets = function (t) { if (!this.areUpdatesFrozen) { var i = 0; this._activeTargets.reset(), this._supportsNormals = !0, this._supportsTangents = !0, this._supportsUVs = !0, this._vertexCount = 0, this._scene && this._targets.length > this._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 < o.length; n++) { var a = o[n]; if (r++, 0 !== a.influence || !this.optimizeInfluencers) { if (this._activeTargets.length >= 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; c < i; c++)this._influences[c] = this._tempInfluences[c]; t && this.synchronize() } }, e.prototype.synchronize = function () { if (this._scene && !this.areUpdatesFrozen) { if (this.isUsingTextureForTargets && this._vertexCount) { this._textureVertexStride = 1, this._supportsNormals && this._textureVertexStride++, this._supportsTangents && this._textureVertexStride++, this._supportsUVs && this._textureVertexStride++, this._textureWidth = this._vertexCount * this._textureVertexStride, this._textureHeight = 1; var e = this._scene.getEngine().getCaps().maxTextureSize; this._textureWidth > e && (this._textureHeight = Math.ceil(this._textureWidth / e), this._textureWidth = e); var t = !0; if (this._targetStoreTexture) { var i = this._targetStoreTexture.getSize(); i.width === this._textureWidth && i.height === this._textureHeight && this._targetStoreTexture.depth === this._targets.length && (t = !1) } if (t) { this._targetStoreTexture && this._targetStoreTexture.dispose(); for (var r = this._targets.length, n = new Float32Array(r * this._textureWidth * this._textureHeight * 4), o = 0, s = 0; s < r; s++) { var l = this._targets[s], c = l.getPositions(), u = l.getNormals(), h = l.getUVs(), d = l.getTangents(); if (!c) return void (0 === s && $.Error("Invalid morph target. Target must have positions.")); o = s * this._textureWidth * this._textureHeight * 4; for (var p = 0; p < this._vertexCount; p++)n[o] = c[3 * p], n[o + 1] = c[3 * p + 1], n[o + 2] = c[3 * p + 2], o += 4, this._supportsNormals && u && (n[o] = u[3 * p], n[o + 1] = u[3 * p + 1], n[o + 2] = u[3 * p + 2], o += 4), this._supportsUVs && h && (n[o] = h[2 * p], n[o + 1] = h[2 * p + 1], o += 4), this._supportsTangents && d && (n[o] = d[3 * p], n[o + 1] = d[3 * p + 1], n[o + 2] = d[3 * p + 2], o += 4) } this._targetStoreTexture = cg.CreateRGBATexture(n, this._textureWidth, this._textureHeight, r, this._scene, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE, a.TEXTURETYPE_FLOAT) } } for (var f = 0, _ = this._scene.meshes; f < _.length; f++) { var m = _[f]; m.morphTargetManager === this && m._syncGeometryWithMorphTargetManager() } } }, e.prototype.dispose = function () { if (this._targetStoreTexture && this._targetStoreTexture.dispose(), this._targetStoreTexture = null, this._scene) { if (this._scene.removeMorphTargetManager(this), this._parentContainer) { var e = this._parentContainer.morphTargetManagers.indexOf(this); e > -1 && this._parentContainer.morphTargetManagers.splice(e, 1), this._parentContainer = null } for (var t = 0, i = this._targets; t < i.length; t++) { var r = i[t]; this._scene.stopAnimation(r) } } }, e.Parse = function (t, i) { var r = new e(i); r._uniqueId = t.id; for (var n = 0, o = t.targets; n < o.length; n++) { var a = o[n]; r.addTarget(lg.Parse(a, i)) } return r }, e.EnableTextureStorage = !0, e.MaxActiveMorphTargetsInVertexAttributeMode = 8, e }(), hg = function () { function e() { this._hasHit = !1, this._hitDistance = 0, this._hitNormalWorld = R.Zero(), this._hitPointWorld = R.Zero(), this._rayFromWorld = R.Zero(), this._rayToWorld = R.Zero(), this._triangleIndex = -1 } return Object.defineProperty(e.prototype, "hasHit", { get: function () { return this._hasHit }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "hitDistance", { get: function () { return this._hitDistance }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "hitNormalWorld", { get: function () { return this._hitNormalWorld }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "hitPointWorld", { get: function () { return this._hitPointWorld }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "rayFromWorld", { get: function () { return this._rayFromWorld }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "rayToWorld", { get: function () { return this._rayToWorld }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "triangleIndex", { get: function () { return this._triangleIndex }, enumerable: !1, configurable: !0 }), e.prototype.setHitData = function (e, t, i) { this._hasHit = !0, this._hitNormalWorld.set(e.x, e.y, e.z), this._hitPointWorld.set(t.x, t.y, t.z), this._triangleIndex = null != i ? i : -1 }, e.prototype.setHitDistance = function (e) { this._hitDistance = e }, e.prototype.calculateHitDistance = function () { this._hitDistance = R.Distance(this._rayFromWorld, this._hitPointWorld) }, e.prototype.reset = function (e, t) { void 0 === e && (e = R.Zero()), void 0 === t && (t = R.Zero()), this._rayFromWorld.copyFrom(e), this._rayToWorld.copyFrom(t), this._hasHit = !1, this._hitDistance = 0, this._hitNormalWorld.setAll(0), this._hitPointWorld.setAll(0), this._triangleIndex = -1, this.body = void 0, this.bodyIndex = void 0 }, e }(), dg = function () { function e(t, i) { if (void 0 === i && (i = e.DefaultPluginFactory()), this._physicsPlugin = i, this._impostors = [], this._joints = [], this._subTimeStep = 0, this._uniqueIdCounter = 0, !this._physicsPlugin.isSupported()) throw new Error("Physics Engine " + this._physicsPlugin.name + " cannot be found. Please make sure it is included."); 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 ge("CannonJSPlugin") }, 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._impostors.forEach((function (e) { e.dispose() })), this._physicsPlugin.dispose() }, e.prototype.getPhysicsPluginName = function () { return this._physicsPlugin.name }, e.prototype.addImpostor = function (e) { this._impostors.push(e), e.uniqueId = this._uniqueIdCounter++, e.parent || this._physicsPlugin.generatePhysicsBody(e) }, e.prototype.removeImpostor = function (e) { var t = this._impostors.indexOf(e); 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; t < this._impostors.length; ++t)if (this._impostors[t].object === e) return this._impostors[t]; return null }, e.prototype.getImpostorWithPhysicsBody = function (e) { for (var t = 0; t < this._impostors.length; ++t)if (this._impostors[t].physicsBody === e) return this._impostors[t]; return null }, e.prototype.raycast = function (e, t) { return this._physicsPlugin.raycast(e, t) }, e.prototype.raycastToRef = function (e, t, i) { return this._physicsPlugin.raycastToRef(e, t, i) }, e }(), pg = function () { function e(e, t, i) { void 0 === e && (e = !0), void 0 === t && (t = 10), void 0 === i && (i = CANNON), this._useDeltaForWorldStep = e, this.name = "CannonJSPlugin", this._physicsMaterials = new Array, this._fixedTimeStep = 1 / 60, this._physicsBodiesToRemoveAfterStep = new Array, this._firstFrame = !0, this._tmpQuaternion = new P, this._minus90X = new P(-.7071067811865475, 0, 0, .7071067811865475), this._plus90X = new P(.7071067811865475, 0, 0, .7071067811865475), this._tmpPosition = R.Zero(), this._tmpDeltaPosition = R.Zero(), this._tmpUnityRotation = new P, this.BJSCANNON = i, this.isSupported() ? (this._extendNamespace(), this.world = new this.BJSCANNON.World, this.world.broadphase = new this.BJSCANNON.NaiveBroadphase, this.world.solver.iterations = t, this._cannonRaycastResult = new this.BJSCANNON.RaycastResult, this._raycastResult = new hg) : $.Error("CannonJS is not available. Please make sure you included the js file.") } return e.prototype.getPluginVersion = function () { return 1 }, e.prototype.setGravity = function (e) { var t = e; this.world.gravity.set(t.x, t.y, t.z) }, e.prototype.setTimeStep = function (e) { this._fixedTimeStep = e }, e.prototype.getTimeStep = function () { return this._fixedTimeStep }, e.prototype.executeStep = function (e, t) { if (this._firstFrame) { this._firstFrame = !1; for (var i = 0, r = t; i < r.length; i++) { var n = r[i]; n.type != Zo.HeightmapImpostor && n.type !== Zo.PlaneImpostor && n.beforeStep() } } this.world.step(this._useDeltaForWorldStep ? e : this._fixedTimeStep), this._removeMarkedPhysicsBodiesFromWorld() }, e.prototype._removeMarkedPhysicsBodiesFromWorld = function () { var e = this; this._physicsBodiesToRemoveAfterStep.length > 0 && (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 Xo.HingeJoint: case Xo.Hinge2Joint: r = new this.BJSCANNON.HingeConstraint(t, i, o); break; case Xo.DistanceJoint: r = new this.BJSCANNON.DistanceConstraint(t, i, n.maxDistance || 2); break; case Xo.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 Xo.LockJoint: r = new this.BJSCANNON.LockConstraint(t, i, o); break; case Xo.PointToPointJoint: case Xo.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 !== Xo.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 !== Xo.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; r < this._physicsMaterials.length; r++)if ((n = this._physicsMaterials[r]).friction === t && n.restitution === i) return n; var o = new this.BJSCANNON.Material(e); return o.friction = t, o.restitution = i, this._physicsMaterials.push(o), o }, e.prototype._checkWithEpsilon = function (e) { return e < _ ? _ : e }, e.prototype._createShape = function (e) { var t, i = e.object, r = e.getObjectExtents(); switch (e.type) { case Zo.SphereImpostor: var n = r.x, o = r.y, a = r.z; t = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(n), this._checkWithEpsilon(o), this._checkWithEpsilon(a)) / 2); break; case Zo.CylinderImpostor: var s = e.getParam("nativeOptions"); s || (s = {}); var l = void 0 !== s.radiusTop ? s.radiusTop : this._checkWithEpsilon(r.x) / 2, c = void 0 !== s.radiusBottom ? s.radiusBottom : this._checkWithEpsilon(r.x) / 2, u = void 0 !== s.height ? s.height : this._checkWithEpsilon(r.y), h = void 0 !== s.numSegments ? s.numSegments : 16; t = new this.BJSCANNON.Cylinder(l, c, u, h); var d = new this.BJSCANNON.Quaternion; d.setFromAxisAngle(new this.BJSCANNON.Vec3(1, 0, 0), -Math.PI / 2); var p = new this.BJSCANNON.Vec3(0, 0, 0); t.transformAllPoints(p, d); break; case Zo.BoxImpostor: var f = r.scale(.5); t = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(f.x), this._checkWithEpsilon(f.y), this._checkWithEpsilon(f.z))); break; case Zo.PlaneImpostor: $.Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead"), t = new this.BJSCANNON.Plane; break; case Zo.MeshImpostor: var _ = i.getVerticesData ? i.getVerticesData(Hi.PositionKind) : [], m = i.getIndices ? i.getIndices() : []; if (!_) return void $.Warn("Tried to create a MeshImpostor for an object without vertices. This will fail."); var g = i.position.clone(), v = i.rotation && i.rotation.clone(), y = i.rotationQuaternion && i.rotationQuaternion.clone(); i.position.copyFromFloats(0, 0, 0), i.rotation && i.rotation.copyFromFloats(0, 0, 0), i.rotationQuaternion && i.rotationQuaternion.copyFrom(e.getParentsRotation()), i.rotationQuaternion && i.parent && i.rotationQuaternion.conjugateInPlace(); var b = i.computeWorldMatrix(!0), T = new Array, E = void 0; for (E = 0; E < _.length; E += 3)R.TransformCoordinates(R.FromArray(_, E), b).toArray(T, E); $.Warn("MeshImpostor only collides against spheres."), t = new this.BJSCANNON.Trimesh(T, m), i.position.copyFrom(g), v && i.rotation && i.rotation.copyFrom(v), y && i.rotationQuaternion && i.rotationQuaternion.copyFrom(y); break; case Zo.HeightmapImpostor: var S = i.position.clone(), x = i.rotation && i.rotation.clone(), A = i.rotationQuaternion && i.rotationQuaternion.clone(); i.position.copyFromFloats(0, 0, 0), i.rotation && i.rotation.copyFromFloats(0, 0, 0), i.rotationQuaternion && i.rotationQuaternion.copyFrom(e.getParentsRotation()), i.rotationQuaternion && i.parent && i.rotationQuaternion.conjugateInPlace(), i.rotationQuaternion && i.rotationQuaternion.multiplyInPlace(this._minus90X), t = this._createHeightmap(i), i.position.copyFrom(S), x && i.rotation && i.rotation.copyFrom(x), A && i.rotationQuaternion && i.rotationQuaternion.copyFrom(A), i.computeWorldMatrix(!0); break; case Zo.ParticleImpostor: t = new this.BJSCANNON.Particle; break; case Zo.NoImpostor: t = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0, 0, 0)) }return t }, e.prototype._createHeightmap = function (e, t) { var i, r = e.getVerticesData(Hi.PositionKind), n = e.computeWorldMatrix(!0), o = new Array; for (i = 0; i < r.length; i += 3)R.TransformCoordinates(R.FromArray(r, i), n).toArray(o, i); r = o; for (var a = new Array, s = t || ~~(Math.sqrt(r.length / 3) - 1), l = e.getBoundingInfo(), c = Math.min(l.boundingBox.extendSizeWorld.x, l.boundingBox.extendSizeWorld.y), u = l.boundingBox.extendSizeWorld.z, h = 2 * c / s, d = 0; d < r.length; d += 3) { var p = Math.round(r[d + 0] / h + s / 2), f = Math.round(-1 * (r[d + 1] / h - s / 2)), _ = -r[d + 2] + u; a[p] || (a[p] = []), a[p][f] || (a[p][f] = _), a[p][f] = Math.max(_, a[p][f]) } for (p = 0; p <= s; ++p) { if (!a[p]) { for (var m = 1; !a[(p + m) % s];)m++; a[p] = a[(p + m) % s].slice() } for (f = 0; f <= s; ++f)if (!a[p][f]) { m = 1; for (var g = void 0; void 0 === g;)g = a[p][(f + m++) % s]; a[p][f] = g } } var v = new this.BJSCANNON.Heightfield(a, { elementSize: h }); return v.minY = u, v }, e.prototype._updatePhysicsBodyTransformation = function (e) { var t = e.object; if (t.computeWorldMatrix && t.computeWorldMatrix(!0), t.getBoundingInfo()) { var i = e.getObjectCenter(); this._tmpDeltaPosition.copyFrom(t.getAbsolutePivotPoint().subtract(i)), this._tmpDeltaPosition.divideInPlace(e.object.scaling), this._tmpPosition.copyFrom(i); var r = t.rotationQuaternion; if (r) { if (e.type !== Zo.PlaneImpostor && e.type !== Zo.HeightmapImpostor || (r = r.multiply(this._minus90X), e.setDeltaRotation(this._plus90X)), e.type === Zo.HeightmapImpostor) { var n = t, o = n.getBoundingInfo(), a = n.rotationQuaternion; n.rotationQuaternion = this._tmpUnityRotation, n.computeWorldMatrix(!0); var s = i.clone(), l = n.getPivotMatrix(); l = l ? l.clone() : I.Identity(); var c = I.Translation(o.boundingBox.extendSizeWorld.x, 0, -o.boundingBox.extendSizeWorld.z); n.setPreTransformMatrix(c), n.computeWorldMatrix(!0); var u = (o = n.getBoundingInfo()).boundingBox.centerWorld.subtract(i).subtract(n.position).negate(); this._tmpPosition.copyFromFloats(u.x, u.y - o.boundingBox.extendSizeWorld.y, u.z), this._tmpDeltaPosition.copyFrom(o.boundingBox.centerWorld.subtract(s)), this._tmpDeltaPosition.y += o.boundingBox.extendSizeWorld.y, n.rotationQuaternion = a, n.setPreTransformMatrix(l), n.computeWorldMatrix(!0) } else e.type === Zo.MeshImpostor && this._tmpDeltaPosition.copyFromFloats(0, 0, 0); e.setDeltaPosition(this._tmpDeltaPosition), e.physicsBody.position.set(this._tmpPosition.x, this._tmpPosition.y, this._tmpPosition.z), e.physicsBody.quaternion.set(r.x, r.y, r.z, r.w) } } }, e.prototype.setTransformationFromPhysicsBody = function (e) { if (e.object.position.set(e.physicsBody.position.x, e.physicsBody.position.y, e.physicsBody.position.z), e.object.rotationQuaternion) { var t = e.physicsBody.quaternion; e.object.rotationQuaternion.set(t.x, t.y, t.z, t.w) } }, e.prototype.setPhysicsBodyTransformation = function (e, t, i) { e.physicsBody.position.set(t.x, t.y, t.z), e.physicsBody.quaternion.set(i.x, i.y, i.z, i.w) }, e.prototype.isSupported = function () { return void 0 !== this.BJSCANNON }, e.prototype.setLinearVelocity = function (e, t) { e.physicsBody.velocity.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.velocity; 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) { e.physicsBody.mass = t, e.physicsBody.updateMassProperties() }, e.prototype.getBodyMass = function (e) { return e.physicsBody.mass }, e.prototype.getBodyFriction = function (e) { return e.physicsBody.material.friction }, e.prototype.setBodyFriction = function (e, t) { e.physicsBody.material.friction = t }, e.prototype.getBodyRestitution = function (e) { return e.physicsBody.material.restitution }, e.prototype.setBodyRestitution = function (e, t) { e.physicsBody.material.restitution = t }, e.prototype.sleepBody = function (e) { e.physicsBody.sleep() }, e.prototype.wakeUpBody = function (e) { e.physicsBody.wakeUp() }, e.prototype.updateDistanceJoint = function (e, t) { e.physicsJoint.distance = t }, e.prototype.setMotor = function (e, t, i, r) { r || (e.physicsJoint.enableMotor(), e.physicsJoint.setMotorSpeed(t), i && this.setLimit(e, i)) }, e.prototype.setLimit = function (e, t, i) { e.physicsJoint.motorEquation.maxForce = i, e.physicsJoint.motorEquation.minForce = void 0 === t ? -t : t }, 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.quaternion.x, e.rotationQuaternion.y = i.quaternion.y, e.rotationQuaternion.z = i.quaternion.z, e.rotationQuaternion.w = i.quaternion.w) }, e.prototype.getRadius = function (e) { return e.physicsBody.shapes[0].boundingSphereRadius }, e.prototype.getBoxSizeToRef = function (e, t) { var i = e.physicsBody.shapes[0]; t.x = 2 * i.halfExtents.x, t.y = 2 * i.halfExtents.y, t.z = 2 * i.halfExtents.z }, e.prototype.dispose = function () { }, e.prototype._extendNamespace = function () { var e = new this.BJSCANNON.Vec3, t = this.BJSCANNON; this.BJSCANNON.World.prototype.step = function (i, r, n) { if (n = n || 10, 0 === (r = r || 0)) this.internalStep(i), this.time += i; else { var o = Math.floor((this.time + r) / i) - Math.floor(this.time / i); o = Math.min(o, n) || 1; for (var a = performance.now(), s = 0; s !== o && (this.internalStep(i), !(performance.now() - a > 1e3 * 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 }(); dg.DefaultPluginFactory = function () { return new pg }; var fg = 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 hg } 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 Zo.ParticleImpostor: $.Warn("No Particle support in OIMO.js. using SphereImpostor instead"); case Zo.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 Zo.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 Zo.PlaneImpostor: case Zo.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 Xo.BallAndSocketJoint: r = "jointBall"; break; case Xo.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 Xo.DistanceJoint: r = "jointDistance", a.max = n.maxDistance; break; case Xo.PrismaticJoint: r = "jointPrisme"; break; case Xo.SliderJoint: r = "jointSlide"; break; case Xo.WheelJoint: r = "jointWheel"; break; case Xo.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 }(), _g = 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 hg, 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 - i < i ? (this.world.stepSimulation(e, 0), e = 0) : (e -= i, this.world.stepSimulation(i, 0)), t-- }, e.prototype.executeStep = function (e, t) { for (var i = 0, r = t; i < r.length; i++) { var n = r[i]; n.soft || n.beforeStep() } this._stepSimulation(this._useDeltaForWorldStep ? e : this._timeStep, this._maxSteps, this._fixedTimeStep); for (var o = 0, a = t; o < a.length; o++) { var s = a[o]; if (s.soft ? this._afterSoftStep(s) : s.afterStep(), s._onPhysicsCollideCallbacks.length > 0 && this._isImpostorInContact(s)) for (var l = 0, c = s._onPhysicsCollideCallbacks; l < c.length; l++)for (var u = 0, h = c[l].otherImpostors; u < h.length; u++) { var d = h[u]; (s.physicsBody.isActive() || d.physicsBody.isActive()) && this._isImpostorPairInContact(s, d) && (s.onCollide({ body: d.physicsBody, point: this._tmpContactPoint, distance: this._tmpContactDistance, impulse: this._tmpContactImpulse, normal: this._tmpContactNormal }), d.onCollide({ body: s.physicsBody, point: this._tmpContactPoint, distance: this._tmpContactDistance, impulse: this._tmpContactImpulse, normal: this._tmpContactNormal })) } } }, e.prototype._afterSoftStep = function (e) { e.type === Zo.RopeImpostor ? this._ropeStep(e) : this._softbodyOrClothStep(e) }, e.prototype._ropeStep = function (e) { for (var t, i, r, n, o = e.physicsBody.get_m_nodes(), a = o.size(), s = new Array, l = 0; l < a; l++)i = (t = o.at(l).get_m_x()).x(), r = t.y(), n = t.z(), s.push(new R(i, r, n)); var c = e.object, u = e.getParam("shape"); e._isFromLine ? e.object = Yu("lines", { points: s, instance: c }) : e.object = nh("ext", { shape: u, path: s, instance: c }) }, e.prototype._softbodyOrClothStep = function (e) { var t = e.type === Zo.ClothImpostor ? 1 : -1, i = e.object, r = i.getVerticesData(Hi.PositionKind); r || (r = []); var n = i.getVerticesData(Hi.NormalKind); n || (n = []); for (var o, a, s, l, c, u, h, d, p = r.length / 3, f = e.physicsBody.get_m_nodes(), _ = 0; _ < p; _++) { s = (a = (o = f.at(_)).get_m_x()).x(), l = a.y(), c = a.z() * t; var m = o.get_m_n(); u = m.x(), h = m.y(), d = m.z() * t, r[3 * _] = s, r[3 * _ + 1] = l, r[3 * _ + 2] = c, n[3 * _] = u, n[3 * _ + 1] = h, n[3 * _ + 2] = d } var g = new En; g.positions = r, g.normals = n, g.uvs = i.getVerticesData(Hi.UVKind), g.colors = i.getVerticesData(Hi.ColorKind), i && i.getIndices && (g.indices = i.getIndices()), g.applyToMesh(i) }, e.prototype.applyImpulse = function (e, t, i) { if (e.soft) $.Warn("Cannot be applied to a soft body"); else { e.physicsBody.activate(); var r = this._tmpAmmoVectorA, n = this._tmpAmmoVectorB; e.object && e.object.getWorldMatrix && i.subtractInPlace(e.object.getWorldMatrix().getTranslation()), r.setValue(i.x, i.y, i.z), n.setValue(t.x, t.y, t.z), e.physicsBody.applyImpulse(n, r) } }, e.prototype.applyForce = function (e, t, i) { if (e.soft) $.Warn("Cannot be applied to a soft body"); else { e.physicsBody.activate(); var r = this._tmpAmmoVectorA, n = this._tmpAmmoVectorB; if (e.object && e.object.getWorldMatrix) { var o = e.object.getWorldMatrix().getTranslation(); r.setValue(i.x - o.x, i.y - o.y, i.z - o.z) } else r.setValue(i.x, i.y, i.z); n.setValue(t.x, t.y, t.z), e.physicsBody.applyForce(n, r) } }, e.prototype.generatePhysicsBody = function (t) { if (t._pluginData.toDispose = [], t.parent) t.physicsBody && (this.removePhysicsBody(t), t.forceUpdate()); else if (t.isBodyInitRequired()) { var i = this._createShape(t), r = t.getParam("mass"); if (t._pluginData.mass = r, t.soft) i.get_m_cfg().set_collisions(17), i.get_m_cfg().set_kDP(t.getParam("damping")), this.bjsAMMO.castObject(i, this.bjsAMMO.btCollisionObject).getCollisionShape().setMargin(t.getParam("margin")), i.setActivationState(e._DISABLE_DEACTIVATION_FLAG), this.world.addSoftBody(i, 1, -1), t.physicsBody = i, t._pluginData.toDispose.push(i), this.setBodyPressure(t, 0), t.type === Zo.SoftbodyImpostor && this.setBodyPressure(t, t.getParam("pressure")), this.setBodyStiffness(t, t.getParam("stiffness")), this.setBodyVelocityIterations(t, t.getParam("velocityIterations")), this.setBodyPositionIterations(t, t.getParam("positionIterations")); else { var n = new this.bjsAMMO.btVector3(0, 0, 0), o = new this.bjsAMMO.btTransform; t.object.computeWorldMatrix(!0), o.setIdentity(), 0 !== r && i.calculateLocalInertia(r, n), this._tmpAmmoVectorA.setValue(t.object.position.x, t.object.position.y, t.object.position.z), this._tmpAmmoQuaternion.setValue(t.object.rotationQuaternion.x, t.object.rotationQuaternion.y, t.object.rotationQuaternion.z, t.object.rotationQuaternion.w), o.setOrigin(this._tmpAmmoVectorA), o.setRotation(this._tmpAmmoQuaternion); var a = new this.bjsAMMO.btDefaultMotionState(o), s = new this.bjsAMMO.btRigidBodyConstructionInfo(r, a, i, n), l = new this.bjsAMMO.btRigidBody(s); if (0 === r && (l.setCollisionFlags(l.getCollisionFlags() | e._KINEMATIC_FLAG), l.setActivationState(e._DISABLE_DEACTIVATION_FLAG)), t.type != Zo.NoImpostor || i.getChildShape || l.setCollisionFlags(l.getCollisionFlags() | e._DISABLE_COLLISION_FLAG), t.type !== Zo.MeshImpostor && t.type !== Zo.NoImpostor) { var c = t.object.getBoundingInfo(); this._tmpVec3.copyFrom(t.object.getAbsolutePosition()), this._tmpVec3.subtractInPlace(c.boundingBox.centerWorld), this._tmpVec3.x /= t.object.scaling.x, this._tmpVec3.y /= t.object.scaling.y, this._tmpVec3.z /= t.object.scaling.z, t.setDeltaPosition(this._tmpVec3) } var u = t.getParam("group"), h = t.getParam("mask"); u && h ? this.world.addRigidBody(l, u, h) : this.world.addRigidBody(l), t.physicsBody = l, t._pluginData.toDispose = t._pluginData.toDispose.concat([l, s, a, o, n, i]) } this.setBodyRestitution(t, t.getParam("restitution")), this.setBodyFriction(t, t.getParam("friction")) } }, e.prototype.removePhysicsBody = function (e) { var t = this; this.world && (e.soft ? this.world.removeSoftBody(e.physicsBody) : this.world.removeRigidBody(e.physicsBody), e._pluginData && (e._pluginData.toDispose.forEach((function (e) { t.bjsAMMO.destroy(e) })), e._pluginData.toDispose = [])) }, e.prototype.generateJoint = function (e) { var t = e.mainImpostor.physicsBody, i = e.connectedImpostor.physicsBody; if (t && i) { var r, n = e.joint.jointData; switch (n.mainPivot || (n.mainPivot = new R(0, 0, 0)), n.connectedPivot || (n.connectedPivot = new R(0, 0, 0)), e.joint.type) { case Xo.DistanceJoint: var o = n.maxDistance; o && (n.mainPivot = new R(0, -o / 2, 0), n.connectedPivot = new R(0, o / 2, 0)), r = new this.bjsAMMO.btPoint2PointConstraint(t, i, new this.bjsAMMO.btVector3(n.mainPivot.x, n.mainPivot.y, n.mainPivot.z), new this.bjsAMMO.btVector3(n.connectedPivot.x, n.connectedPivot.y, n.connectedPivot.z)); break; case Xo.HingeJoint: n.mainAxis || (n.mainAxis = new R(0, 0, 0)), n.connectedAxis || (n.connectedAxis = new R(0, 0, 0)); var a = new this.bjsAMMO.btVector3(n.mainAxis.x, n.mainAxis.y, n.mainAxis.z), s = new this.bjsAMMO.btVector3(n.connectedAxis.x, n.connectedAxis.y, n.connectedAxis.z); r = new this.bjsAMMO.btHingeConstraint(t, i, new this.bjsAMMO.btVector3(n.mainPivot.x, n.mainPivot.y, n.mainPivot.z), new this.bjsAMMO.btVector3(n.connectedPivot.x, n.connectedPivot.y, n.connectedPivot.z), a, s); break; case Xo.BallAndSocketJoint: r = new this.bjsAMMO.btPoint2PointConstraint(t, i, new this.bjsAMMO.btVector3(n.mainPivot.x, n.mainPivot.y, n.mainPivot.z), new this.bjsAMMO.btVector3(n.connectedPivot.x, n.connectedPivot.y, n.connectedPivot.z)); break; default: $.Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint"), r = new this.bjsAMMO.btPoint2PointConstraint(t, i, new this.bjsAMMO.btVector3(n.mainPivot.x, n.mainPivot.y, n.mainPivot.z), new this.bjsAMMO.btVector3(n.connectedPivot.x, n.connectedPivot.y, n.connectedPivot.z)) }this.world.addConstraint(r, !e.joint.jointData.collision), e.joint.physicsJoint = r } }, e.prototype.removeJoint = function (e) { this.world && this.world.removeConstraint(e.joint.physicsJoint) }, e.prototype._addMeshVerts = 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(Hi.PositionKind); a || (a = []); var s = void 0; if (t && t !== i) { var l; l = t.rotationQuaternion ? t.rotationQuaternion : t.rotation ? P.FromEulerAngles(t.rotation.x, t.rotation.y, t.rotation.z) : P.Identity(), I.Compose(R.One(), l, t.position).invertToRef(this._tmpMatrix), s = i.computeWorldMatrix(!1).multiply(this._tmpMatrix) } else I.ScalingToRef(i.scaling.x, i.scaling.y, i.scaling.z, this._tmpMatrix), s = this._tmpMatrix; for (var c = o.length / 3, u = 0; u < c; u++) { for (var h = [], d = 0; d < 3; d++) { var p = new R(a[3 * o[3 * u + d] + 0], a[3 * o[3 * u + d] + 1], a[3 * o[3 * u + d] + 2]); p = R.TransformCoordinates(p, s); var f = void 0; (f = 0 == d ? this._tmpAmmoVectorA : 1 == d ? this._tmpAmmoVectorB : this._tmpAmmoVectorC).setValue(p.x, p.y, p.z), h.push(f) } e.addTriangle(h[0], h[1], h[2]), n++ } i.getChildMeshes().forEach((function (i) { n += r._addMeshVerts(e, t, i) })) } return n }, e.prototype._softVertexData = function (e) { var t = e.object; if (t && t.getIndices && t.getWorldMatrix && t.getChildMeshes) { var i = t.getIndices(); i || (i = []); var r = t.getVerticesData(Hi.PositionKind); r || (r = []); var n = t.getVerticesData(Hi.NormalKind); n || (n = []), t.computeWorldMatrix(!1); for (var o = [], a = [], s = 0; s < r.length; s += 3) { var l = new R(r[s], r[s + 1], r[s + 2]), c = new R(n[s], n[s + 1], n[s + 2]); l = R.TransformCoordinates(l, t.getWorldMatrix()), c = R.TransformNormal(c, t.getWorldMatrix()), o.push(l.x, l.y, l.z), a.push(c.x, c.y, c.z) } var u = new En; return u.positions = o, u.normals = a, u.uvs = t.getVerticesData(Hi.UVKind), u.colors = t.getVerticesData(Hi.ColorKind), t && t.getIndices && (u.indices = t.getIndices()), u.applyToMesh(t), t.position = R.Zero(), t.rotationQuaternion = null, t.rotation = R.Zero(), t.computeWorldMatrix(!0), u } return En.ExtractFromMesh(t) }, e.prototype._createSoftbody = function (e) { var t = e.object; if (t && t.getIndices) { var i = t.getIndices(); i || (i = []); var r = this._softVertexData(e), n = r.positions, o = r.normals; if (null === n || null === o) return new this.bjsAMMO.btCompoundShape; for (var a = [], s = [], l = 0; l < n.length; l += 3) { var c = new R(n[l], n[l + 1], n[l + 2]), u = new R(o[l], o[l + 1], o[l + 2]); a.push(c.x, c.y, -c.z), s.push(u.x, u.y, -u.z) } var h = (new this.bjsAMMO.btSoftBodyHelpers).CreateFromTriMesh(this.world.getWorldInfo(), a, t.getIndices(), i.length / 3, !0), d = n.length / 3, p = h.get_m_nodes(), f = void 0; for (l = 0; l < d; l++)(f = p.at(l).get_m_n()).setX(s[3 * l]), f.setY(s[3 * l + 1]), f.setZ(s[3 * l + 2]); return h } }, e.prototype._createCloth = function (e) { var t = e.object; if (t && t.getIndices) { var i = t.getIndices(); i || (i = []); var r = this._softVertexData(e), n = r.positions, o = r.normals; if (null === n || null === o) return new this.bjsAMMO.btCompoundShape; var a = n.length, s = Math.sqrt(a / 3); e.segments = s; var l = s - 1; return this._tmpAmmoVectorA.setValue(n[0], n[1], n[2]), this._tmpAmmoVectorB.setValue(n[3 * l], n[3 * l + 1], n[3 * l + 2]), this._tmpAmmoVectorD.setValue(n[a - 3], n[a - 2], n[a - 1]), this._tmpAmmoVectorC.setValue(n[a - 3 - 3 * l], n[a - 2 - 3 * l], n[a - 1 - 3 * l]), (new this.bjsAMMO.btSoftBodyHelpers).CreatePatch(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, this._tmpAmmoVectorC, this._tmpAmmoVectorD, s, s, e.getParam("fixedPoints"), !0) } }, e.prototype._createRope = function (e) { var t, i, r = this._softVertexData(e), n = r.positions, o = r.normals; if (null === n || null === o) return new this.bjsAMMO.btCompoundShape; if (r.applyToMesh(e.object, !0), e._isFromLine = !0, 0 === o.map((function (e) { return e * e })).reduce((function (e, t) { return e + t }))) i = (t = n.length) / 3 - 1, this._tmpAmmoVectorA.setValue(n[0], n[1], n[2]), this._tmpAmmoVectorB.setValue(n[t - 3], n[t - 2], n[t - 1]); else { e._isFromLine = !1; var a = e.getParam("path"); if (null === e.getParam("shape")) return $.Warn("No shape available for extruded mesh"), new this.bjsAMMO.btCompoundShape; i = (t = a.length) - 1, this._tmpAmmoVectorA.setValue(a[0].x, a[0].y, a[0].z), this._tmpAmmoVectorB.setValue(a[t - 1].x, a[t - 1].y, a[t - 1].z) } e.segments = i; var s = e.getParam("fixedPoints"); s = s > 3 ? 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(Hi.PositionKind); a || (a = []), i.computeWorldMatrix(!1); for (var s = o.length / 3, l = 0; l < s; l++) { for (var c = [], u = 0; u < 3; u++) { var h = new R(a[3 * o[3 * l + u] + 0], a[3 * o[3 * l + u] + 1], a[3 * o[3 * l + u] + 2]); I.ScalingToRef(i.scaling.x, i.scaling.y, i.scaling.z, this._tmpMatrix), h = R.TransformCoordinates(h, this._tmpMatrix); var d = void 0; (d = 0 == u ? this._tmpAmmoVectorA : 1 == u ? this._tmpAmmoVectorB : this._tmpAmmoVectorC).setValue(h.x, h.y, h.z), c.push(d) } e.addPoint(c[0], !0), e.addPoint(c[1], !0), e.addPoint(c[2], !0), n++ } i.getChildMeshes().forEach((function (i) { n += r._addHullVerts(e, t, i) })) } return n }, e.prototype._createShape = function (e, t) { var i = this; void 0 === t && (t = !1); var r, n = e.object, o = e.getObjectExtents(); if (!t) { var a = e.object.getChildMeshes ? e.object.getChildMeshes(!0) : []; r = new this.bjsAMMO.btCompoundShape; var s = 0; if (a.forEach((function (e) { var t = e.getPhysicsImpostor(); if (t) { if (t.type == Zo.MeshImpostor) throw "A child MeshImpostor is not supported. Only primitive impostors are supported as children (eg. box or sphere)"; var n = i._createShape(t), o = e.parent.getWorldMatrix().clone(), a = new R; o.decompose(a), i._tmpAmmoTransform.getOrigin().setValue(e.position.x * a.x, e.position.y * a.y, e.position.z * a.z), i._tmpAmmoQuaternion.setValue(e.rotationQuaternion.x, e.rotationQuaternion.y, e.rotationQuaternion.z, e.rotationQuaternion.w), i._tmpAmmoTransform.setRotation(i._tmpAmmoQuaternion), r.addChildShape(i._tmpAmmoTransform, n), t.dispose(), s++ } })), s > 0) { if (e.type != Zo.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 Zo.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 Zo.CapsuleImpostor: var u = o.x / 2; r = new this.bjsAMMO.btCapsuleShape(u, o.y - 2 * u); break; case Zo.CylinderImpostor: this._tmpAmmoVectorA.setValue(o.x / 2, o.y / 2, o.z / 2), r = new this.bjsAMMO.btCylinderShape(this._tmpAmmoVectorA); break; case Zo.PlaneImpostor: case Zo.BoxImpostor: this._tmpAmmoVectorA.setValue(o.x / 2, o.y / 2, o.z / 2), r = new this.bjsAMMO.btBoxShape(this._tmpAmmoVectorA); break; case Zo.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 Zo.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 Zo.NoImpostor: r = new this.bjsAMMO.btSphereShape(o.x / 2); break; case Zo.CustomImpostor: r = this._createCustom(e); break; case Zo.SoftbodyImpostor: r = this._createSoftbody(e); break; case Zo.ClothImpostor: r = this._createCloth(e); break; case Zo.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 === Zo.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 mg = 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 es(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 }, 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; i < r.length; i++)r[i].dispose(); this._sceneUBOs = [] } }, e.prototype.toString = function (e) { var t = "Name: " + this.name; return e && (t += ", position: " + this.position.toString(), this._attachedMesh && (t += ", attached mesh: " + this._attachedMesh.name)), t }, e.prototype.getClassName = function () { return "ReflectionProbe" }, e.prototype.serialize = function () { var e = Ue.Serialize(this, this._renderTargetTexture.serialize()); return e.isReflectionProbe = !0, e.metadata = this.metadata, e }, e.Parse = function (t, i, r) { var n = null; if (i.reflectionProbes) for (var o = 0; o < i.reflectionProbes.length; o++) { var a = i.reflectionProbes[o]; if (a.name === t.name) { n = a; break } } return (n = Ue.Parse((function () { return n || new e(t.name, t.renderTargetSize, i, t._generateMipMaps) }), t, i, r)).cubeTexture._waitingRenderList = t.renderList, t._attachedMesh && n.attachToMesh(i.getMeshById(t._attachedMesh)), t.metadata && (n.metadata = t.metadata), n }, X([Me()], e.prototype, "_attachedMesh", void 0), X([Ie()], e.prototype, "position", void 0), e }(), gg = !0, vg = function () { function e() { } return e.LoaderInjectedPhysicsEngine = void 0, e }(), yg = {}, bg = {}, Tg = function (e, t, i, r) { if (!t.materials) return null; for (var n = 0, o = t.materials.length; n < o; n++) { var a = t.materials[n]; if (e(a)) return { parsedMaterial: a, material: Hn.Parse(a, i, r) } } return null }, Eg = function (e, t) { return e + " of " + (t ? t.file + " from " + t.name + " version: " + t.version + ", exporter version: " + t.exporter_version : "unknown") }, Sg = function (e, t) { var i = t; if (t._waitingData.lods) { if (t._waitingData.lods.ids && t._waitingData.lods.ids.length > 0) { 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; s < r.length; s++) { var l = r[s], c = e.getMeshById(l); null != c && i.addLODLevel(o[s], c) } a > 0 && i.addLODLevel(a, null), !0 === n && i.setEnabled(!0) } else xi.Warn("Invalid level of detail distances for " + t.name) } } t._waitingData.lods = null } }, xg = function (e, t, i) { if ("number" != typeof e) { var r = i.getLastEntryById(e); return r && null != t ? r.instances[parseInt(t)] : r } var n = yg[e]; return n && null != t ? n.instances[parseInt(t)] : n }, Ag = function (e, t) { return "number" != typeof e ? t.getLastMaterialById(e, !0) : bg[e] }, Rg = function (e, t, i, r, n) { void 0 === n && (n = !1); var a = new ro(e), s = "importScene has failed JSON parse"; try { var l = JSON.parse(t); s = ""; var c = ea.loggingLevel === ea.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 sg((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 _ = h_.Parse(l.environmentTexture, e, i); e.environmentTexture = _ } else if (l.environmentTexture.endsWith(".env")) { var m = new h_((l.environmentTexture.match(/https?:\/\//g) ? "" : i) + l.environmentTexture, e, l.environmentTextureForcedExtension); l.environmentTextureRotationY && (m.rotationY = l.environmentTextureRotationY), e.environmentTexture = m } else { var g = h_.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; u < h; u++) { var b = l.lights[u]; (re = eo.Parse(b, e)) && (yg[b.uniqueId] = re, a.lights.push(re), re._parentContainer = a, s += 0 === u ? "\n\tLights:" : "", s += "\n\t\t" + re.toString(c)) } if (void 0 !== l.reflectionProbes && null !== l.reflectionProbes) for (u = 0, h = l.reflectionProbes.length; u < h; u++) { var E = l.reflectionProbes[u], S = mg.Parse(E, e, i); S && (a.reflectionProbes.push(S), S._parentContainer = a, s += 0 === u ? "\n\tReflection Probes:" : "", s += "\n\t\t" + S.toString(c)) } if (void 0 !== l.animations && null !== l.animations) for (u = 0, h = l.animations.length; u < h; u++) { var x = l.animations[u], A = T("BABYLON.Animation"); if (A) { var R = A.Parse(x); e.animations.push(R), a.animations.push(R), s += 0 === u ? "\n\tAnimations:" : "", s += "\n\t\t" + R.toString(c) } } if (void 0 !== l.materials && null !== l.materials) for (u = 0, h = l.materials.length; u < h; u++) { var C = l.materials[u], P = Hn.Parse(C, e, i); P && (bg[C.uniqueId || C.id] = P, a.materials.push(P), P._parentContainer = a, s += 0 === u ? "\n\tMaterials:" : "", s += "\n\t\t" + P.toString(c), P.getActiveTextures().forEach((function (e) { -1 == a.textures.indexOf(e) && (a.textures.push(e), e._parentContainer = a) }))) } if (void 0 !== l.multiMaterials && null !== l.multiMaterials) for (u = 0, h = l.multiMaterials.length; u < h; u++) { var I = l.multiMaterials[u], M = Xn.ParseMultiMaterial(I, e); bg[I.uniqueId || I.id] = M, a.multiMaterials.push(M), M._parentContainer = a, s += 0 === u ? "\n\tMultiMaterials:" : "", s += "\n\t\t" + M.toString(c), M.getActiveTextures().forEach((function (e) { -1 == a.textures.indexOf(e) && (a.textures.push(e), e._parentContainer = a) })) } if (void 0 !== l.morphTargetManagers && null !== l.morphTargetManagers) for (var O = 0, D = l.morphTargetManagers; O < D.length; O++) { var N = D[O], F = ug.Parse(N, e); a.morphTargetManagers.push(F), F._parentContainer = a } if (void 0 !== l.skeletons && null !== l.skeletons) for (u = 0, h = l.skeletons.length; u < h; u++) { var L = l.skeletons[u], w = xs.Parse(L, e); a.skeletons.push(w), w._parentContainer = a, s += 0 === u ? "\n\tSkeletons:" : "", s += "\n\t\t" + w.toString(c) } var B = l.geometries; if (null != B) { var U = new Array, V = B.vertexData; if (null != V) for (u = 0, h = V.length; u < h; u++) { var k = V[u]; U.push(An.Parse(k, e, i)) } U.forEach((function (e) { e && (a.geometries.push(e), e._parentContainer = a) })) } if (void 0 !== l.transformNodes && null !== l.transformNodes) for (u = 0, h = l.transformNodes.length; u < h; u++) { var G = l.transformNodes[u], z = On.Parse(G, e, i); yg[G.uniqueId] = z, a.transformNodes.push(z), z._parentContainer = a } if (void 0 !== l.meshes && null !== l.meshes) for (u = 0, h = l.meshes.length; u < h; u++) { var W = l.meshes[u], H = Jn.Parse(W, e, i); if (yg[W.uniqueId] = H, a.meshes.push(H), H._parentContainer = a, H.hasInstances) for (var X = 0, j = H.instances; X < j.length; X++) { var Y = j[X]; a.meshes.push(Y), Y._parentContainer = a } s += 0 === u ? "\n\tMeshes:" : "", s += "\n\t\t" + H.toString(c) } if (void 0 !== l.cameras && null !== l.cameras) for (u = 0, h = l.cameras.length; u < h; u++) { var K = l.cameras[u], Q = ln.Parse(K, e); yg[K.uniqueId] = Q, a.cameras.push(Q), Q._parentContainer = a, s += 0 === u ? "\n\tCameras:" : "", s += "\n\t\t" + Q.toString(c) } if (void 0 !== l.postProcesses && null !== l.postProcesses) for (u = 0, h = l.postProcesses.length; u < h; u++) { var q = l.postProcesses[u], Z = Ia.Parse(q, e, i); Z && (a.postProcesses.push(Z), Z._parentContainer = a, s += 0 === u ? "\nPostprocesses:" : "", s += "\n\t\t" + Z.toString()) } if (void 0 !== l.animationGroups && null !== l.animationGroups) for (u = 0, h = l.animationGroups.length; u < h; u++) { var J = l.animationGroups[u], ee = Zr.Parse(J, e); a.animationGroups.push(ee), ee._parentContainer = a, s += 0 === u ? "\n\tAnimationGroups:" : "", s += "\n\t\t" + ee.toString(c) } for (u = 0, h = e.cameras.length; u < h; u++)null !== (Q = e.cameras[u])._waitingParentId && (Q.parent = xg(Q._waitingParentId, Q._waitingParentInstanceIndex, e), Q._waitingParentId = null, Q._waitingParentInstanceIndex = null); for (u = 0, h = e.lights.length; u < h; u++)(re = e.lights[u]) && null !== re._waitingParentId && (re.parent = xg(re._waitingParentId, re._waitingParentInstanceIndex, e), re._waitingParentId = null, re._waitingParentInstanceIndex = null); for (u = 0, h = e.transformNodes.length; u < h; u++) { var te = e.transformNodes[u]; null !== te._waitingParentId && (te.parent = xg(te._waitingParentId, te._waitingParentInstanceIndex, e), te._waitingParentId = null, te._waitingParentInstanceIndex = null) } for (u = 0, h = e.meshes.length; u < h; u++)null !== (H = e.meshes[u])._waitingParentId && (H.parent = xg(H._waitingParentId, H._waitingParentInstanceIndex, e), H._waitingParentId = null, H._waitingParentInstanceIndex = null), H._waitingData.lods && Sg(e, H); for (e.multiMaterials.forEach((function (t) { t._waitingSubMaterialsUniqueIds.forEach((function (i) { t.subMaterials.push(Ag(i, e)) })), t._waitingSubMaterialsUniqueIds = [] })), e.meshes.forEach((function (t) { null !== t._waitingMaterialId && (t.material = Ag(t._waitingMaterialId, e), t._waitingMaterialId = null) })), u = 0, h = e.skeletons.length; u < h; u++)(w = e.skeletons[u])._hasWaitingData && (null != w.bones && w.bones.forEach((function (t) { if (t._waitingTransformNodeId) { var i = e.getLastEntryById(t._waitingTransformNodeId); i && t.linkTransformNode(i), t._waitingTransformNodeId = null } })), w._hasWaitingData = null); for (u = 0, h = e.meshes.length; u < h; u++) { var ie = e.meshes[u]; ie._waitingData.freezeWorldMatrix ? (ie.freezeWorldMatrix(), ie._waitingData.freezeWorldMatrix = null) : ie.computeWorldMatrix(!0) } for (u = 0, h = e.lights.length; u < h; u++) { var re; if ((re = e.lights[u])._excludedMeshesIds.length > 0) { for (var ne = 0; ne < re._excludedMeshesIds.length; ne++) { var oe = e.getMeshById(re._excludedMeshesIds[ne]); oe && re.excludedMeshes.push(oe) } re._excludedMeshesIds = [] } if (re._includedOnlyMeshesIds.length > 0) { for (var ae = 0; ae < re._includedOnlyMeshesIds.length; ae++) { var se = e.getMeshById(re._includedOnlyMeshesIds[ae]); se && re.includedOnlyMeshes.push(se) } re._includedOnlyMeshesIds = [] } } for (e.geometries.forEach((function (e) { e._loadedUniqueId = "" })), o.Parse(l, e, a, i), u = 0, h = e.meshes.length; u < h; u++)(H = e.meshes[u])._waitingData.actions && (de.Parse(H._waitingData.actions, H, e), H._waitingData.actions = null); void 0 !== l.actions && null !== l.actions && de.Parse(l.actions, null, e) } catch (e) { var le = Eg("loadAssets", l ? l.producer : "Unknown") + s; if (!r) throw $.Log(le), e; r(le, e) } finally { yg = {}, bg = {}, n || a.removeAllFromScene(), null !== s && ea.loggingLevel !== ea.NO_LOGGING && $.Log(Eg("loadAssets", l ? l.producer : "Unknown") + (ea.loggingLevel !== ea.MINIMAL_LOGGING ? s : "")) } return a }; ea.RegisterPlugin({ name: "babylon.js", extensions: ".babylon", canDirectLoad: function (e) { return -1 !== e.indexOf("babylon") }, importMesh: function (e, t, i, r, n, a, s, l) { var c, u = "importMesh has failed JSON parse"; try { var h = JSON.parse(i); u = ""; var d = ea.loggingLevel === ea.DETAILED_LOGGING; e ? Array.isArray(e) || (e = [e]) : e = null; var p = new Array, f = new Map, _ = []; if (void 0 !== h.transformNodes && null !== h.transformNodes) for (var m = 0, g = h.transformNodes.length; m < g; m++) { var v = h.transformNodes[m], y = On.Parse(v, t, r); _.push(y), f.set(y._waitingParsedUniqueId, y), y._waitingParsedUniqueId = null } if (void 0 !== h.meshes && null !== h.meshes) { var b = [], T = [], E = [], S = [], x = function (i, o) { var a = h.meshes[i]; if (null === e || function (e, t, i) { for (var r in t) if (e.name === t[r]) return i.push(e.id), !0; return void 0 !== e.parentId && -1 !== i.indexOf(e.parentId) && (i.push(e.id), !0) }(a, e, p)) { if (null !== e && delete e[e.indexOf(a.name)], void 0 !== a.geometryId && null !== a.geometryId && void 0 !== h.geometries && null !== h.geometries) { var l = !1;["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach((function (e) { !0 !== l && h.geometries[e] && Array.isArray(h.geometries[e]) && h.geometries[e].forEach((function (i) { i.id === a.geometryId && ("vertexData" === e && An.Parse(i, t, r), l = !0) })) })), !1 === l && $.Warn("Geometry not found for mesh " + a.id) } if (a.materialUniqueId || a.materialId) { var c = a.materialUniqueId ? E : T, _ = -1 !== c.indexOf(a.materialUniqueId || a.materialId); if (!1 === _ && void 0 !== h.multiMaterials && null !== h.multiMaterials) for (var m = function (e, i) { c.push(e); var n = Tg(i, h, t, r); n && n.material && (bg[n.parsedMaterial.uniqueId || n.parsedMaterial.id] = n.material, u += "\n\tMaterial " + n.material.toString(d)) }, g = 0, v = h.multiMaterials.length; g < v; g++) { var y = h.multiMaterials[g]; if (a.materialUniqueId && y.uniqueId === a.materialUniqueId || y.id === a.materialId) { y.materialsUniqueIds ? y.materialsUniqueIds.forEach((function (e) { return m(e, (function (t) { return t.uniqueId === e })) })) : y.materials.forEach((function (e) { return m(e, (function (t) { return t.id === e })) })), c.push(y.uniqueId || y.id); var x = Xn.ParseMultiMaterial(y, t); bg[y.uniqueId || y.id] = x, x && (_ = !0, u += "\n\tMulti-Material " + x.toString(d)); break } } if (!1 === _) { c.push(a.materialUniqueId || a.materialId); var A = Tg((function (e) { return a.materialUniqueId && e.uniqueId === a.materialUniqueId || e.id === a.materialId }), h, t, r); A && A.material ? (bg[A.parsedMaterial.uniqueId || A.parsedMaterial.id] = A.material, u += "\n\tMaterial " + A.material.toString(d)) : $.Warn("Material not found for mesh " + a.id) } } if (null !== a.skeletonId && void 0 !== a.skeletonId && -1 !== h.skeletonId && void 0 !== h.skeletons && null !== h.skeletons && !(b.indexOf(a.skeletonId) > -1)) for (var R = 0, C = h.skeletons.length; R < C; R++) { var P = h.skeletons[R]; if (P.id === a.skeletonId) { var I = xs.Parse(P, t); s.push(I), b.push(P.id), u += "\n\tSkeleton " + I.toString(d) } } if (a.morphTargetManagerId > -1 && void 0 !== h.morphTargetManagers && null !== h.morphTargetManagers && !(S.indexOf(a.morphTargetManagerId) > -1)) for (var M = 0, O = h.morphTargetManagers.length; M < O; M++) { var D = h.morphTargetManagers[M]; if (D.id === a.morphTargetManagerId) { var N = ug.Parse(D, t); S.push(N.uniqueId), u += "\nMorph target " + N.toString() } } var F = Jn.Parse(a, t, r); n.push(F), f.set(F._waitingParsedUniqueId, F), F._waitingParsedUniqueId = null, u += "\n\tMesh " + F.toString(d) } }; for (m = 0, g = h.meshes.length; m < g; m++)x(m); for (t.multiMaterials.forEach((function (e) { e._waitingSubMaterialsUniqueIds.forEach((function (i) { e.subMaterials.push(Ag(i, t)) })), e._waitingSubMaterialsUniqueIds = [] })), t.meshes.forEach((function (e) { null !== e._waitingMaterialId && (e.material = Ag(e._waitingMaterialId, t), e._waitingMaterialId = null) })), m = 0, g = t.transformNodes.length; m < g; m++)if (null !== (D = t.transformNodes[m])._waitingParentId) { var A = f.get(parseInt(D._waitingParentId)) || null; null === A && (A = t.getLastEntryById(D._waitingParentId)); var R = A; D._waitingParentInstanceIndex && (R = A.instances[parseInt(D._waitingParentInstanceIndex)], D._waitingParentInstanceIndex = null), D.parent = R, D._waitingParentId = null } var C = void 0; for (m = 0, g = t.meshes.length; m < g; m++) { if ((C = t.meshes[m])._waitingParentId) { var P = f.get(parseInt(C._waitingParentId)) || null; if (null === P && (P = t.getLastEntryById(C._waitingParentId)), R = P, C._waitingParentInstanceIndex && (R = P.instances[parseInt(C._waitingParentInstanceIndex)], C._waitingParentInstanceIndex = null), C.parent = R, "TransformNode" === (null === (c = C.parent) || void 0 === c ? void 0 : c.getClassName())) { var I = _.indexOf(C.parent); I > -1 && _.splice(I, 1) } C._waitingParentId = null } C._waitingData.lods && Sg(t, C) } for (var M = 0, O = _; M < O.length; M++) { var D; (D = O[M]).dispose() } for (m = 0, g = t.skeletons.length; m < g; m++) { var N = t.skeletons[m]; N._hasWaitingData && (null != N.bones && N.bones.forEach((function (e) { if (e._waitingTransformNodeId) { var i = t.getLastEntryById(e._waitingTransformNodeId); i && e.linkTransformNode(i), e._waitingTransformNodeId = null } })), N._hasWaitingData = null) } for (m = 0, g = t.meshes.length; m < g; m++)(C = t.meshes[m])._waitingData.freezeWorldMatrix ? (C.freezeWorldMatrix(), C._waitingData.freezeWorldMatrix = null) : C.computeWorldMatrix(!0) } if (void 0 !== h.particleSystems && null !== h.particleSystems) { var F = o.GetIndividualParser(qi.NAME_PARTICLESYSTEM); if (F) for (m = 0, g = h.particleSystems.length; m < g; m++) { var L = h.particleSystems[m]; -1 !== p.indexOf(L.emitterId) && a.push(F(L, t, r)) } } return t.geometries.forEach((function (e) { e._loadedUniqueId = "" })), !0 } catch (e) { var w = Eg("importMesh", h ? h.producer : "Unknown") + u; if (!l) throw $.Log(w), e; l(w, e) } finally { null !== u && ea.loggingLevel !== ea.NO_LOGGING && $.Log(Eg("importMesh", h ? h.producer : "Unknown") + (ea.loggingLevel !== ea.MINIMAL_LOGGING ? u : "")), bg = {} } return !1 }, load: function (e, t, i, r) { var n = "importScene has failed JSON parse"; try { var o = JSON.parse(t); if (n = "", void 0 !== o.useDelayedTextureLoading && null !== o.useDelayedTextureLoading && (e.useDelayedTextureLoading = o.useDelayedTextureLoading && !ea.ForceFullSceneLoadingForIncremental), void 0 !== o.autoClear && null !== o.autoClear && (e.autoClear = o.autoClear), void 0 !== o.clearColor && null !== o.clearColor && (e.clearColor = U.FromArray(o.clearColor)), void 0 !== o.ambientColor && null !== o.ambientColor && (e.ambientColor = B.FromArray(o.ambientColor)), void 0 !== o.gravity && null !== o.gravity && (e.gravity = R.FromArray(o.gravity)), void 0 !== o.useRightHandedSystem && (e.useRightHandedSystem = !!o.useRightHandedSystem), o.fogMode && 0 !== o.fogMode) switch (e.fogMode = o.fogMode, e.fogColor = B.FromArray(o.fogColor), e.fogStart = o.fogStart, e.fogEnd = o.fogEnd, e.fogDensity = o.fogDensity, n += "\tFog mode for scene: ", e.fogMode) { case 1: n += "exp\n"; break; case 2: n += "exp2\n"; break; case 3: n += "linear\n" }if (o.physicsEnabled) { var a = void 0; "cannon" === o.physicsEngine || o.physicsEngine === pg.name ? a = new pg(void 0, void 0, vg.LoaderInjectedPhysicsEngine) : "oimo" === o.physicsEngine || o.physicsEngine === fg.name ? a = new fg(void 0, vg.LoaderInjectedPhysicsEngine) : "ammo" !== o.physicsEngine && o.physicsEngine !== _g.name || (a = new _g(void 0, vg.LoaderInjectedPhysicsEngine, void 0)), n = "\tPhysics engine " + (o.physicsEngine ? o.physicsEngine : "oimo") + " enabled\n"; var s = o.physicsGravity ? R.FromArray(o.physicsGravity) : null; e.enablePhysics(s, a) } return void 0 !== o.metadata && null !== o.metadata && (e.metadata = o.metadata), void 0 !== o.collisionsEnabled && null !== o.collisionsEnabled && (e.collisionsEnabled = o.collisionsEnabled), !!Rg(e, t, i, r, !0) && (o.autoAnimate && e.beginAnimation(e, o.autoAnimateFrom, o.autoAnimateTo, o.autoAnimateLoop, o.autoAnimateSpeed || 1), void 0 !== o.activeCameraID && null !== o.activeCameraID && e.setActiveCameraById(o.activeCameraID), !0) } catch (e) { var l = Eg("importScene", o ? o.producer : "Unknown") + n; if (!r) throw $.Log(l), e; r(l, e) } finally { null !== n && ea.loggingLevel !== ea.NO_LOGGING && $.Log(Eg("importScene", o ? o.producer : "Unknown") + (ea.loggingLevel !== ea.MINIMAL_LOGGING ? n : "")) } return !1 }, loadAssetContainer: function (e, t, i, r) { return Rg(e, t, i, r) } }); var Cg = function () { function e(e) { void 0 === e && (e = {}), this._isEnabled = !0, this.bias = void 0 === e.bias ? 0 : e.bias, this.power = void 0 === e.power ? 1 : e.power, this.leftColor = e.leftColor || B.White(), this.rightColor = e.rightColor || B.Black(), !1 === e.isEnabled && (this.isEnabled = !1) } return Object.defineProperty(e.prototype, "isEnabled", { get: function () { return this._isEnabled }, set: function (e) { this._isEnabled !== e && (this._isEnabled = e, In.MarkAllMaterialsAsDirty(a.MATERIAL_FresnelDirtyFlag | a.MATERIAL_MiscDirtyFlag)) }, enumerable: !1, configurable: !0 }), e.prototype.clone = function () { var t = new e; return he.DeepCopy(this, t), t }, e.prototype.equals = function (e) { return e && this.bias === e.bias && this.power === e.power && this.leftColor.equals(e.leftColor) && this.rightColor.equals(e.rightColor) && this.isEnabled === e.isEnabled }, e.prototype.serialize = function () { return { isEnabled: this.isEnabled, leftColor: this.leftColor.asArray(), rightColor: this.rightColor.asArray(), bias: this.bias, power: this.power } }, e.Parse = function (t) { return new e({ isEnabled: t.isEnabled, leftColor: B.FromArray(t.leftColor), rightColor: B.FromArray(t.rightColor), bias: t.bias, power: t.power || 1 }) }, e }(); Ue._FresnelParametersParser = Cg.Parse; var Pg = function (e) { function t(t, i) { var r = e.call(this, t, i, "color", { attributes: ["position"], uniforms: ["world", "viewProjection", "color"] }) || this; return r.disableColorWrite = !0, r.forceDepthWrite = !0, r.setColor4("color", new U(0, 0, 0, 1)), r } return W(t, e), t }(Gu), Ig = function (e) { function t(t, i) { var r = e.call(this, t, i) || this; return r.maxSimultaneousLights = 4, r.disableLighting = !1, r.invertNormalMapX = !1, r.invertNormalMapY = !1, r.emissiveColor = new B(0, 0, 0), r.occlusionStrength = 1, r.useLightmapAsShadowmap = !1, r._useAlphaFromAlbedoTexture = !0, r._useAmbientInGrayScale = !0, r } return W(t, e), Object.defineProperty(t.prototype, "doubleSided", { get: function () { return this._twoSidedLighting }, set: function (e) { this._twoSidedLighting !== e && (this._twoSidedLighting = e, this.backFaceCulling = !e, this._markAllSubMeshesAsTexturesDirty()) }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function () { return "PBRBaseSimpleMaterial" }, X([xe(), Se("_markAllSubMeshesAsLightsDirty")], t.prototype, "maxSimultaneousLights", void 0), X([xe(), Se("_markAllSubMeshesAsLightsDirty")], t.prototype, "disableLighting", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty", "_reflectionTexture")], t.prototype, "environmentTexture", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapX", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapY", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty", "_bumpTexture")], t.prototype, "normalTexture", void 0), X([Re("emissive"), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveColor", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveTexture", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty", "_ambientTextureStrength")], t.prototype, "occlusionStrength", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty", "_ambientTexture")], t.prototype, "occlusionTexture", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty", "_alphaCutOff")], t.prototype, "alphaCutOff", void 0), X([xe()], t.prototype, "doubleSided", null), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty", null)], t.prototype, "lightmapTexture", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useLightmapAsShadowmap", void 0), t }(F_), Mg = function (e) { function t(t, i) { var r = e.call(this, t, i) || this; return r._useRoughnessFromMetallicTextureAlpha = !1, r._useRoughnessFromMetallicTextureGreen = !0, r._useMetallnessFromMetallicTextureBlue = !0, r.metallic = 1, r.roughness = 1, r } return W(t, e), t.prototype.getClassName = function () { return "PBRMetallicRoughnessMaterial" }, t.prototype.clone = function (e) { var i = this, r = Ue.Clone((function () { return new t(e, i.getScene()) }), this); return r.id = e, r.name = e, this.clearCoat.copyTo(r.clearCoat), this.anisotropy.copyTo(r.anisotropy), this.brdf.copyTo(r.brdf), this.sheen.copyTo(r.sheen), this.subSurface.copyTo(r.subSurface), r }, t.prototype.serialize = function () { var e = Ue.Serialize(this); return e.customType = "BABYLON.PBRMetallicRoughnessMaterial", e.clearCoat = this.clearCoat.serialize(), e.anisotropy = this.anisotropy.serialize(), e.brdf = this.brdf.serialize(), e.sheen = this.sheen.serialize(), e.subSurface = this.subSurface.serialize(), e.iridescence = this.iridescence.serialize(), e }, t.Parse = function (e, i, r) { var n = Ue.Parse((function () { return new t(e.name, i) }), e, i, r); return 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 }, X([Re(), Se("_markAllSubMeshesAsTexturesDirty", "_albedoColor")], t.prototype, "baseColor", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")], t.prototype, "baseTexture", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallic", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "roughness", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty", "_metallicTexture")], t.prototype, "metallicRoughnessTexture", void 0), t }(Ig); b("BABYLON.PBRMetallicRoughnessMaterial", Mg); var Og = function (e) { function t(t, i) { var r = e.call(this, t, i) || this; return r._useMicroSurfaceFromReflectivityMapAlpha = !0, r } return W(t, e), Object.defineProperty(t.prototype, "useMicroSurfaceFromReflectivityMapAlpha", { get: function () { return this._useMicroSurfaceFromReflectivityMapAlpha }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function () { return "PBRSpecularGlossinessMaterial" }, t.prototype.clone = function (e) { var i = this, r = Ue.Clone((function () { return new t(e, i.getScene()) }), this); return r.id = e, r.name = e, this.clearCoat.copyTo(r.clearCoat), this.anisotropy.copyTo(r.anisotropy), this.brdf.copyTo(r.brdf), this.sheen.copyTo(r.sheen), this.subSurface.copyTo(r.subSurface), r }, t.prototype.serialize = function () { var e = Ue.Serialize(this); return e.customType = "BABYLON.PBRSpecularGlossinessMaterial", e.clearCoat = this.clearCoat.serialize(), e.anisotropy = this.anisotropy.serialize(), e.brdf = this.brdf.serialize(), e.sheen = this.sheen.serialize(), e.subSurface = this.subSurface.serialize(), e.iridescence = this.iridescence.serialize(), e }, t.Parse = function (e, i, r) { var n = Ue.Parse((function () { return new t(e.name, i) }), e, i, r); return 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 }, X([Re("diffuse"), Se("_markAllSubMeshesAsTexturesDirty", "_albedoColor")], t.prototype, "diffuseColor", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")], t.prototype, "diffuseTexture", void 0), X([Re("specular"), Se("_markAllSubMeshesAsTexturesDirty", "_reflectivityColor")], t.prototype, "specularColor", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty", "_microSurface")], t.prototype, "glossiness", void 0), X([Ae(), Se("_markAllSubMeshesAsTexturesDirty", "_reflectivityTexture")], t.prototype, "specularGlossinessTexture", void 0), t }(Ig); b("BABYLON.PBRSpecularGlossinessMaterial", Og); var Dg = function (e) { function t(t, i, r) { void 0 === r && (r = null); var n = e.call(this, i) || this; if (!t) return n; if (n._textureMatrix = I.Identity(), n.name = t, n.url = t, n._onLoad = r, n._texture = n._getFromCache(t, !0), n._texture) n._triggerOnLoad(); else { var o = n.getScene(); o && o.useDelayedTextureLoading ? n.delayLoadState = a.DELAYLOADSTATE_NOTLOADED : n._loadTexture() } return n } return W(t, e), t.prototype._triggerOnLoad = function () { this._onLoad && this._onLoad() }, t.prototype.getTextureMatrix = function () { return this._textureMatrix }, t.prototype._load3dlTexture = function () { var e, i = this, r = this._getEngine(); e = r._features.support3DTextures ? r.createRawTexture3D(null, 1, 1, 1, a.TEXTUREFORMAT_RGBA, !1, !1, a.TEXTURE_BILINEAR_SAMPLINGMODE, null, a.TEXTURETYPE_UNSIGNED_INT) : r.createRawTexture(null, 1, 1, a.TEXTUREFORMAT_RGBA, !1, !1, a.TEXTURE_BILINEAR_SAMPLINGMODE, null, a.TEXTURETYPE_UNSIGNED_INT), this._texture = e, this._texture.isReady = !1, this.isCube = !1, this.is3D = r._features.support3DTextures, this.wrapU = a.TEXTURE_CLAMP_ADDRESSMODE, this.wrapV = a.TEXTURE_CLAMP_ADDRESSMODE, this.wrapR = a.TEXTURE_CLAMP_ADDRESSMODE, this.anisotropicFilteringLevel = 1; var n = function (n) { if ("string" == typeof n) { for (var o, s = null, l = null, c = n.split("\n"), u = 0, h = 0, d = 0, p = 0, f = 0, _ = 0; _ < c.length; _++)if (o = c[_], t._NoneEmptyLineRegex.test(o) && 0 !== o.indexOf("#")) { var m = o.split(" "); if (0 !== u) { if (0 != u) { var g = Math.max(parseInt(m[0]), 0), v = Math.max(parseInt(m[1]), 0), y = Math.max(parseInt(m[2]), 0); f = Math.max(g, f), f = Math.max(v, f), f = Math.max(y, f); var b = 4 * (h + p * u + d * u * u); l && (l[b + 0] = g, l[b + 1] = v, l[b + 2] = y), ++d % u == 0 && (d = 0, ++p % u == 0 && (h++, p = 0)) } } else u = m.length, s = new Uint8Array(u * u * u * 4), l = new Float32Array(u * u * u * 4) } if (l && s) for (_ = 0; _ < l.length; _++)if (_ > 0 && (_ + 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 }(po); b("BABYLON.ColorGradingTexture", Dg); var Ng = 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 = vo.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 ? xi.SetImmediate((function () { return s() })) : u._texture.onLoadedObservable.add(s)) : i.useDelayedTextureLoading ? u.delayLoadState = a.DELAYLOADSTATE_NOTLOADED : u._loadImage(u._loadTexture.bind(u), u._onError), u } return W(t, e), t.prototype._loadImage = function (e, t) { var i = this, r = document.createElement("canvas"); ui(this.url, (function (t) { i._width = t.width, i._height = t.height, r.width = i._width, r.height = i._height; var n = r.getContext("2d"); n.drawImage(t, 0, 0); var o = n.getImageData(0, 0, t.width, t.height); i._buffer = o.data.buffer, r.remove(), e() }), (function (e, r) { t && t("".concat(i.getClassName(), " could not be loaded"), r) }), null) }, t.prototype._loadTexture = function () { var e = this, i = this.getScene(); i && (this._texture = i.getEngine().createRawCubeTextureFromUrl(this.url, i, this._size, a.TEXTUREFORMAT_RGB, i.getEngine().getCaps().textureFloat ? a.TEXTURETYPE_FLOAT : a.TEXTURETYPE_UNSIGNED_INTEGER, this._noMipmap, (function () { for (var i = e._getFloat32ArrayFromArrayBuffer(e._buffer), r = ng.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 }), null, this._onLoad, this._onError)) }, t.prototype._getFloat32ArrayFromArrayBuffer = function (e) { for (var t = new DataView(e), i = new Float32Array(3 * e.byteLength / 4), r = 0, n = 0; n < e.byteLength; n++)(n + 1) % 4 != 0 && (i[r++] = t.getUint8(n) / 255); return i }, t.prototype.getClassName = function () { return "EquiRectangularCubeTexture" }, t.prototype.clone = function () { var e = this.getScene(); if (!e) return this; var i = new t(this.url, e, this._size, this._noMipmap, this.gammaSpace); return i.level = this.level, i.wrapU = this.wrapU, i.wrapV = this.wrapV, i.coordinatesIndex = this.coordinatesIndex, i.coordinatesMode = this.coordinatesMode, i }, t._FacesMapping = ["right", "left", "up", "down", "front", "back"], t }(po), Fg = function (e) { function t(i, r, n) { var o, a, s = this; return (s = e.call(this, n.scene || n.engine) || this).onLoadObservable = new u, r && (n.engine || n.scene) ? (n = H(H({}, t._DefaultOptions), n), s._generateMipMaps = n.generateMipMaps, s._samplingMode = n.samplingMode, s._textureMatrix = I.Identity(), s._format = n.format, s.name = i, s.element = r, s._isVideo = !!r.getVideoPlaybackQuality, s._externalTexture = s._isVideo && null !== (a = null === (o = s._engine) || void 0 === o ? void 0 : o.createExternalTexture(r)) && void 0 !== a ? a : null, s.anisotropicFilteringLevel = 1, s._createInternalTexture(), s) : s } return W(t, e), t.prototype._createInternalTexture = function () { var e = 0, t = 0; this._isVideo ? (e = this.element.videoWidth, t = this.element.videoHeight) : (e = this.element.width, t = this.element.height); var i = this._getEngine(); i && (this._texture = i.createDynamicTexture(e, t, this._generateMipMaps, this._samplingMode), this._texture.format = this._format), this.update() }, t.prototype.getTextureMatrix = function () { return this._textureMatrix }, t.prototype.update = function (e) { void 0 === e && (e = null); var t = this._getEngine(); if (null != this._texture && null != t) { var i = this.isReady(); if (this._isVideo) { var r = this.element; if (r.readyState < r.HAVE_CURRENT_DATA) return; t.updateVideoTexture(this._texture, this._externalTexture ? this._externalTexture : r, null === e || e) } else { var n = this.element; t.updateDynamicTexture(this._texture, n, null === e || e, !1, this._format) } !i && this.isReady() && this.onLoadObservable.notifyObservers(this) } }, t.prototype.dispose = function () { this.onLoadObservable.clear(), e.prototype.dispose.call(this) }, t._DefaultOptions = { generateMipMaps: !1, samplingMode: a.TEXTURE_BILINEAR_SAMPLINGMODE, format: a.TEXTUREFORMAT_RGBA, engine: null, scene: null }, t }(po), Lg = 1, wg = 2, Bg = 3, Ug = 9, Vg = 10, kg = 11, Gg = 48, zg = 4, Wg = 0, Hg = 1, Xg = 2, jg = 3; function Yg(e) { var t = 0; return { id_length: e[t++], colormap_type: e[t++], image_type: e[t++], colormap_index: e[t++] | e[t++] << 8, colormap_length: e[t++] | e[t++] << 8, colormap_size: e[t++], origin: [e[t++] | e[t++] << 8, e[t++] | e[t++] << 8], width: e[t++] | e[t++] << 8, height: e[t++] | e[t++] << 8, pixel_size: e[t++], flags: e[t++] } } function Kg(e, t) { if (t.length < 19) $.Error("Unable to load TGA file - Not enough data to contain header"); else { var i = 18, r = Yg(t); if (r.id_length + i > t.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 Ug: o = !0; case Lg: a = !0; break; case Vg: o = !0; case wg: break; case kg: o = !0; case Bg: 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 < m && b < m;)if (v = 1 + (127 & (g = t[i++])), 128 & g) { for (y = 0; y < _; ++y)T[y] = t[i++]; for (y = 0; y < v; ++y)n.set(T, b + y * _); b += _ * v } else { for (v *= _, y = 0; y < v; ++y)n[b + y] = t[i++]; b += v } } else n = t.subarray(i, i += a ? r.width * r.height : m); switch ((r.flags & Gg) >> zg) { default: case Xg: c = 0, h = 1, f = r.width, u = 0, d = 1, p = r.height; break; case Wg: c = 0, h = 1, f = r.width, u = r.height - 1, d = -1, p = -1; break; case jg: c = r.width - 1, h = -1, f = -1, u = 0, d = 1, p = r.height; break; case Hg: 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 = Qg[E](r, l, n, u, d, p, c, h, f); e.getEngine()._uploadDataToTextureDirectly(e, S) } } } var Qg = { GetTGAHeader: Yg, UploadContent: Kg, _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 _ } }, qg = 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 = Yg(r); i(n.width, n.height, t.generateMipMaps, !1, (function () { Kg(t, r) })) }, e }(); In._TextureLoaders.push(new qg); var Zg = 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 = og.RGBE_ReadHeader(r), o = og.RGBE_ReadPixels(r, n), s = n.width * n.height, l = new Float32Array(4 * s), c = 0; c < s; c += 1)l[4 * c] = o[3 * c], l[4 * c + 1] = o[3 * c + 1], l[4 * c + 2] = o[3 * c + 2], l[4 * c + 3] = 1; i(n.width, n.height, t.generateMipMaps, !1, (function () { var e = t.getEngine(); t.type = a.TEXTURETYPE_FLOAT, t.format = a.TEXTUREFORMAT_RGBA, t._gammaSpace = !1, e._uploadDataToTextureDirectly(t, l) })) }, e }(); In._TextureLoaders.push(new Zg); var Jg, $g = function () { }; !function (e) { e[e.cTFETC1 = 0] = "cTFETC1", e[e.cTFETC2 = 1] = "cTFETC2", e[e.cTFBC1 = 2] = "cTFBC1", e[e.cTFBC3 = 3] = "cTFBC3", e[e.cTFBC4 = 4] = "cTFBC4", e[e.cTFBC5 = 5] = "cTFBC5", e[e.cTFBC7 = 6] = "cTFBC7", e[e.cTFPVRTC1_4_RGB = 8] = "cTFPVRTC1_4_RGB", e[e.cTFPVRTC1_4_RGBA = 9] = "cTFPVRTC1_4_RGBA", e[e.cTFASTC_4x4 = 10] = "cTFASTC_4x4", e[e.cTFATC_RGB = 11] = "cTFATC_RGB", e[e.cTFATC_RGBA_INTERPOLATED_ALPHA = 12] = "cTFATC_RGBA_INTERPOLATED_ALPHA", e[e.cTFRGBA32 = 13] = "cTFRGBA32", e[e.cTFRGB565 = 14] = "cTFRGB565", e[e.cTFBGR565 = 15] = "cTFBGR565", e[e.cTFRGBA4444 = 16] = "cTFRGBA4444", e[e.cTFFXT1_RGB = 17] = "cTFFXT1_RGB", e[e.cTFPVRTC2_4_RGB = 18] = "cTFPVRTC2_4_RGB", e[e.cTFPVRTC2_4_RGBA = 19] = "cTFPVRTC2_4_RGBA", e[e.cTFETC2_EAC_R11 = 20] = "cTFETC2_EAC_R11", e[e.cTFETC2_EAC_RG11 = 21] = "cTFETC2_EAC_RG11" }(Jg || (Jg = {})); var ev = { JSModuleURL: "https://cdn.babylonjs.com/basisTranscoder/1/basis_transcoder.js", WasmModuleURL: "https://cdn.babylonjs.com/basisTranscoder/1/basis_transcoder.wasm" }, tv = function (e, t) { var i; switch (e) { case Jg.cTFETC1: i = a.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL; break; case Jg.cTFBC1: i = a.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1; break; case Jg.cTFBC4: i = a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5; break; case Jg.cTFASTC_4x4: i = a.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4; break; case Jg.cTFETC2: i = a.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC; break; case Jg.cTFBC7: i = a.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM }if (void 0 === i) throw "The chosen Basis transcoder format is not currently supported"; return i }, iv = null, rv = null, nv = 0, ov = function (e, t) { var i = e instanceof ArrayBuffer ? new Uint8Array(e) : e; return new Promise((function (e, r) { (iv || (iv = new Promise((function (e, t) { rv ? e(rv) : xi.LoadFileAsync(ev.WasmModuleURL).then((function (i) { if ("function" != typeof URL) return t("Basis transcoder requires an environment with a URL constructor"); var r = URL.createObjectURL(new Blob(["(".concat(cv, ")()")], { type: "application/javascript" })); rv = new Worker(r); var n = function (i) { "init" === i.data.action ? (rv.removeEventListener("message", n), e(rv)) : "error" === i.data.action && t(i.data.error || "error initializing worker") }; rv.addEventListener("message", n), rv.postMessage({ action: "init", url: ev.JSModuleURL, wasmBinary: i }) })).catch(t) }))), iv).then((function () { var n = nv++, o = function (t) { "transcode" === t.data.action && t.data.id === n && (rv.removeEventListener("message", o), t.data.success ? e(t.data) : r("Transcode is not supported on this device")) }; rv.addEventListener("message", o); var a = new Uint8Array(i.byteLength); a.set(new Uint8Array(i.buffer, i.byteOffset, i.byteLength)), rv.postMessage({ action: "transcode", id: n, imageData: a, config: t, ignoreSupportedFormats: !1 }, [a.buffer]) }), (function (e) { r(e) })) })) }, av = function (e, t) { var i, r, n = null === (i = t._gl) || void 0 === i ? void 0 : i.TEXTURE_2D; e.isCube && (n = null === (r = t._gl) || void 0 === r ? void 0 : r.TEXTURE_CUBE_MAP), t._bindTextureDirectly(n, e, !0) }, sv = function (e, t) { for (var i = e.getEngine(), r = function (r) { var n = t.fileInfo.images[r].levels[0]; if (e._invertVScale = e.invertY, -1 === t.format || t.format === Jg.cTFRGB565) if (e.type = a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5, e.format = a.TEXTUREFORMAT_RGB, !i._features.basisNeedsPOT || h.Log2(n.width) % 1 == 0 && h.Log2(n.height) % 1 == 0) e._invertVScale = !e.invertY, e.width = n.width + 3 & -4, e.height = n.height + 3 & -4, e.samplingMode = a.TEXTURE_LINEAR_LINEAR, av(e, i), i._uploadDataToTextureDirectly(e, new Uint16Array(n.transcodedPixels.buffer), r, 0, a.TEXTUREFORMAT_RGB, !0); else { var o = new Ht(i, It.Temp); e._invertVScale = e.invertY, o.type = a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5, o.format = a.TEXTUREFORMAT_RGB, o.width = n.width + 3 & -4, o.height = n.height + 3 & -4, av(o, i), i._uploadDataToTextureDirectly(o, new Uint16Array(n.transcodedPixels.buffer), r, 0, a.TEXTUREFORMAT_RGB, !0), i._rescaleTexture(o, e, i.scenes[0], i._getInternalFormat(a.TEXTUREFORMAT_RGB), (function () { i._releaseTexture(o), av(e, i) })) } else { e.width = n.width, e.height = n.height, e.generateMipMaps = t.fileInfo.images[r].levels.length > 1; var s = lv.GetInternalFormatFromBasisFormat(t.format, i); e.format = s, av(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 || (xi.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 = vo.CLAMP_ADDRESSMODE, e._cachedWrapV = vo.CLAMP_ADDRESSMODE) } }, n = 0; n < t.fileInfo.images.length; n++)r(n) }, lv = { JSModuleURL: ev.JSModuleURL, WasmModuleURL: ev.WasmModuleURL, GetInternalFormatFromBasisFormat: tv, TranscodeAsync: ov, LoadTextureFromTranscodeResult: sv }; function cv() { var e = null; function t(e, t, i, r, n) { var o = e.getImageTranscodedSizeInBytes(t, i, r), a = new Uint8Array(o); return e.transcodeImage(a, t, i, r, 1, 0) ? (n && (a = function (e, t, i, r) { for (var n = new Uint16Array(4), o = new Uint16Array(i * r), a = i / 4, s = r / 4, l = 0; l < s; l++)for (var c = 0; c < a; c++) { var u = 0 + 8 * (l * a + c); n[0] = e[u] | e[u + 1] << 8, n[1] = e[u + 2] | e[u + 3] << 8, n[2] = (2 * (31 & n[0]) + 1 * (31 & n[1])) / 3 | (2 * (2016 & n[0]) + 1 * (2016 & n[1])) / 3 & 2016 | (2 * (63488 & n[0]) + 1 * (63488 & n[1])) / 3 & 63488, n[3] = (2 * (31 & n[1]) + 1 * (31 & n[0])) / 3 | (2 * (2016 & n[1]) + 1 * (2016 & n[0])) / 3 & 2016 | (2 * (63488 & n[1]) + 1 * (63488 & n[0])) / 3 & 63488; for (var h = 0; h < 4; h++) { var d = e[u + 4 + h], p = (4 * l + h) * i + 4 * c; o[p++] = n[3 & d], o[p++] = n[d >> 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; n < i; n++) { for (var o = { levels: [] }, a = e.getNumLevels(n), s = 0; s < a; s++) { var l = { width: e.getImageWidth(n, s), height: e.getImageHeight(n, s) }; o.levels.push(l) } r.push(o) } return { hasAlpha: t, images: r } }(o), s = i.data.ignoreSupportedFormats ? null : function (e, t) { var i = null; return e.supportedCompressionFormats && (i = e.supportedCompressionFormats.astc ? 10 : e.supportedCompressionFormats.bc7 ? 6 : e.supportedCompressionFormats.s3tc ? t.hasAlpha ? 3 : 2 : e.supportedCompressionFormats.pvrtc ? t.hasAlpha ? 9 : 8 : e.supportedCompressionFormats.etc2 ? 1 : e.supportedCompressionFormats.etc1 ? 0 : 14), i }(i.data.config, a), l = !1; null === s && (l = !0, s = a.hasAlpha ? 3 : 2); var c = !0; o.startTranscoding() || (c = !1); for (var u = [], h = 0; h < a.images.length && c; h++) { var d = a.images[h]; if (void 0 === r.loadSingleImage || r.loadSingleImage === h) { var p = d.levels.length; !1 === r.loadMipmapLevels && (p = 1); for (var f = 0; f < p; f++) { var _ = d.levels[f], m = t(o, h, f, s, l); if (!m) { c = !1; break } _.transcodedPixels = m, u.push(_.transcodedPixels.buffer) } } } o.close(), o.delete(), l && (s = -1), c ? postMessage({ action: "transcode", success: c, id: i.data.id, fileInfo: a, format: s }, u) : postMessage({ action: "transcode", success: c, id: i.data.id }) } } } Object.defineProperty(lv, "JSModuleURL", { get: function () { return ev.JSModuleURL }, set: function (e) { ev.JSModuleURL = e } }), Object.defineProperty(lv, "WasmModuleURL", { get: function () { return ev.WasmModuleURL }, set: function (e) { ev.WasmModuleURL = e } }); var uv = function () { function e() { this.supportCascades = !1 } return e.prototype.canLoad = function (e) { return e.endsWith(".basis") }, e.prototype.loadCubeData = function (e, t, i, r, n) { if (!Array.isArray(e)) { var o = t.getEngine().getCaps(), a = { supportedCompressionFormats: { etc1: !!o.etc1, s3tc: !!o.s3tc, pvrtc: !!o.pvrtc, etc2: !!o.etc2, astc: !!o.astc, bc7: !!o.bptc } }; ov(e, a).then((function (e) { var i = e.fileInfo.images[0].levels.length > 1 && t.generateMipMaps; sv(t, e), t.getEngine()._setCubeMapTextureParams(t, i), t.isReady = !0, t.onLoadedObservable.notifyObservers(t), t.onLoadedObservable.clear(), r && r() })).catch((function (e) { xi.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 } }; ov(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 () { sv(t, e) })) })).catch((function (e) { xi.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"), xi.Warn("Failed to transcode Basis file: ".concat(e)), i(0, 0, !1, !1, (function () { }), !0) })) }, e }(); In._TextureLoaders.push(new uv); var hv = 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 < this._textures.length; t++)this._textures[t].wrapU = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wrapV", { set: function (e) { if (this._textures) for (var t = 0; t < this._textures.length; t++)this._textures[t].wrapV = e }, enumerable: !1, configurable: !0 }), t.prototype._initTypes = function (e, t, i, r, n, o, s, l, c, u) { for (var h = 0; h < e; h++)u && u.types && void 0 !== u.types[h] ? t.push(u.types[h]) : t.push(u && u.defaultType ? u.defaultType : a.TEXTURETYPE_UNSIGNED_INT), u && u.samplingModes && void 0 !== u.samplingModes[h] ? i.push(u.samplingModes[h]) : i.push(vo.BILINEAR_SAMPLINGMODE), u && u.useSRGBBuffers && void 0 !== u.useSRGBBuffers[h] ? r.push(u.useSRGBBuffers[h]) : r.push(!1), u && u.formats && void 0 !== u.formats[h] ? n.push(u.formats[h]) : n.push(a.TEXTUREFORMAT_RGBA), u && u.targetTypes && void 0 !== u.targetTypes[h] ? o.push(u.targetTypes[h]) : o.push(a.TEXTURE_2D), u && u.faceIndex && void 0 !== u.faceIndex[h] ? s.push(u.faceIndex[h]) : s.push(0), u && u.layerIndex && void 0 !== u.layerIndex[h] ? l.push(u.layerIndex[h]) : l.push(0), u && u.layerCounts && void 0 !== u.layerCounts[h] ? c.push(u.layerCounts[h]) : c.push(1) }, t.prototype._createInternaTextureIndexMapping = function () { var e = {}, t = []; if (!this._renderTarget) return t; for (var i = this._renderTarget.textures, r = 0; r < i.length; r++) { var n = i[r]; if (n) { var o = e[n.uniqueId]; void 0 !== o ? t[r] = o : e[n.uniqueId] = r } } return t }, t.prototype._rebuild = function (e, t) { if (void 0 === e && (e = !1), !(this._count < 1)) { var i = this._createInternaTextureIndexMapping(); this.releaseInternalTextures(), this._createInternalTextures(), e && (this._releaseTextures(), this._createTextures(t)); for (var r = this._renderTarget.textures, n = 0; n < r.length; n++) { var o = this._textures[n]; void 0 !== i[n] && this._renderTarget.setTexture(r[i[n]], n), o._texture = r[n], o._texture && (o._noMipmap = !o._texture.useMipMaps, o._useSRGBBuffer = o._texture._useSRGBBuffer) } 1 !== this.samples && this._renderTarget.setSamples(this.samples, !this._drawOnlyOnFirstAttachmentByDefault, !0) } }, t.prototype._createInternalTextures = function () { this._renderTarget = this._getEngine().createMultipleRenderTarget(this._size, this._multiRenderTargetOptions, !this._drawOnlyOnFirstAttachmentByDefault), this._texture = this._renderTarget.texture }, t.prototype._releaseTextures = function () { if (this._textures) for (var e = 0; e < this._textures.length; e++)this._textures[e]._texture = null, this._textures[e].dispose() }, t.prototype._createTextures = function (e) { var t = this._renderTarget.textures; this._textures = []; for (var i = 0; i < t.length; i++) { var r = new vo(null, this.getScene()); (null == e ? void 0 : e[i]) && (r.name = e[i]), r._texture = t[i], r._texture && (r._noMipmap = !r._texture.useMipMaps, r._useSRGBBuffer = r._texture._useSRGBBuffer), this._textures.push(r) } }, t.prototype.setInternalTexture = function (e, t, i) { var r, n; if (void 0 === i && (i = !0), this.renderTarget && (0 === t && (this._texture = e), this.renderTarget.setTexture(e, t, i), this.textures[t] || (this.textures[t] = new vo(null, this.getScene()), this.textures[t].name = null !== (n = null === (r = this._textureNames) || void 0 === r ? void 0 : r[t]) && void 0 !== n ? n : this.textures[t].name), this.textures[t]._texture = e, this.textures[t]._noMipmap = !e.useMipMaps, this.textures[t]._useSRGBBuffer = e._useSRGBBuffer, this._count = this.renderTarget.textures ? this.renderTarget.textures.length : 0, this._multiRenderTargetOptions.types && (this._multiRenderTargetOptions.types[t] = e.type), this._multiRenderTargetOptions.samplingModes && (this._multiRenderTargetOptions.samplingModes[t] = e.samplingMode), this._multiRenderTargetOptions.useSRGBBuffers && (this._multiRenderTargetOptions.useSRGBBuffers[t] = e._useSRGBBuffer), this._multiRenderTargetOptions.targetTypes && -1 !== this._multiRenderTargetOptions.targetTypes[t])) { var o; o = e.is2DArray ? a.TEXTURE_2D_ARRAY : e.isCube ? a.TEXTURE_CUBE_MAP : e.is3D ? a.TEXTURE_3D : a.TEXTURE_2D, this._multiRenderTargetOptions.targetTypes[t] = o } }, t.prototype.setLayerAndFaceIndex = function (e, t, i) { void 0 === t && (t = -1), void 0 === i && (i = -1), this.textures[e] && this.renderTarget && (this._multiRenderTargetOptions.layerIndex && (this._multiRenderTargetOptions.layerIndex[e] = t), this._multiRenderTargetOptions.faceIndex && (this._multiRenderTargetOptions.faceIndex[e] = i), this.renderTarget.setLayerAndFaceIndex(e, t, i)) }, t.prototype.setLayerAndFaceIndices = function (e, t) { this.renderTarget && (this._multiRenderTargetOptions.layerIndex = e, this._multiRenderTargetOptions.faceIndex = t, this.renderTarget.setLayerAndFaceIndices(e, t)) }, Object.defineProperty(t.prototype, "samples", { get: function () { return this._samples }, set: function (e) { this._renderTarget ? this._samples = this._renderTarget.setSamples(e) : this._samples = e }, enumerable: !1, configurable: !0 }), t.prototype.resize = function (e) { this._processSizeParameter(e, !1), this._rebuild(void 0, this._textureNames) }, t.prototype.updateCount = function (e, t, i) { this._multiRenderTargetOptions.textureCount = e, this._count = e; var r = [], n = [], o = [], a = [], s = [], l = [], c = [], u = []; this._textureNames = i, this._initTypes(e, r, n, o, a, s, l, c, u, t), this._multiRenderTargetOptions.types = r, this._multiRenderTargetOptions.samplingModes = n, this._multiRenderTargetOptions.useSRGBBuffers = o, this._multiRenderTargetOptions.formats = a, this._multiRenderTargetOptions.targetTypes = s, this._multiRenderTargetOptions.faceIndex = l, this._multiRenderTargetOptions.layerIndex = c, this._multiRenderTargetOptions.layerCounts = u, this._rebuild(!0, i) }, t.prototype._unbindFrameBuffer = function (e, t) { var i = this; this._renderTarget && e.unBindMultiColorAttachmentFramebuffer(this._renderTarget, this.isCube, (function () { i.onAfterRenderObservable.notifyObservers(t) })) }, t.prototype.dispose = function (t) { void 0 === t && (t = !1), this._releaseTextures(), t ? this._texture = null : this.releaseInternalTextures(), e.prototype.dispose.call(this) }, t.prototype.releaseInternalTextures = function () { var e, t, i = null === (e = this._renderTarget) || void 0 === e ? void 0 : e.textures; if (i) { for (var r = i.length - 1; r >= 0; r--)this._textures[r]._texture = null; null === (t = this._renderTarget) || void 0 === t || t.dispose(), this._renderTarget = null } }, t }(es), dv = function (e, t, i) { this.id = e, this.scale = t, this.offset = i }, pv = 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 : Hi.UVKind, this.options.uvsOut = null !== (s = this.options.uvsOut) && void 0 !== s ? s : Hi.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; l < s.length; l++) { var c = s[l], u = new gc(this.name + ".TexturePack." + c + "Set", { width: i.x, height: i.y }, this.scene, !0, vo.TRILINEAR_SAMPLINGMODE, In.TEXTUREFORMAT_RGBA), h = u.getContext(); h.fillStyle = "rgba(0,0,0,0)", h.fillRect(0, 0, i.x, i.y), u.update(!1), this.sets[c] = u } var d = this.options.frameSize || 256, p = this._paddingValue, f = d + 2 * p; for (l = 0; l < a; l++)for (var _ = this.meshes[l].material, m = function (a) { var c = new gc("temp", f, g.scene, !0), u = c.getContext(), h = g._getFrameOffset(l), m = function () { n++, c.update(!1); var a = u.getImageData(0, 0, f, f), s = t.sets[v]; if (s.getContext().putImageData(a, i.x * h.x, i.y * h.y), c.dispose(), s.update(!1), n == o) return t._calculateMeshUVFrames(d, p, i, r, t.options.updateInputMeshes || !1), void e() }, v = s[a] || "_blank"; if (_ && null !== _[v]) { var y = _[v], b = new Image; b.src = y instanceof gc ? y.getContext().canvas.toDataURL("image/png") : y.url, xi.SetCorsBehavior(b.src, b), b.onload = function () { u.fillStyle = "rgba(0,0,0,0)", u.fillRect(0, 0, f, f), c.update(!1), u.setTransform(1, 0, 0, -1, 0, 0); var e = [0, 0, 1, 0, 1, 1, 0, 1, -1, 1, -1, 0, -2, 0, -1, 1, -1]; switch (t.options.paddingMode) { case 0: for (var i = 0; i < 9; i++)u.drawImage(b, 0, 0, b.width, b.height, p + d * e[i], p + d * e[i + 1] - f, d, d); break; case 1: for (var r = 0; r < p; r++)u.drawImage(b, 0, 0, b.width, b.height, r + d * e[0], p - f, d, d), u.drawImage(b, 0, 0, b.width, b.height, 2 * p - r, p - f, d, d), u.drawImage(b, 0, 0, b.width, b.height, p, r - f, d, d), u.drawImage(b, 0, 0, b.width, b.height, p, 2 * p - r - f, d, d); u.drawImage(b, 0, 0, b.width, b.height, p + d * e[0], p + d * e[1] - f, d, d); break; case 2: u.fillStyle = (t.options.paddingColor || B.Black()).toHexString(), u.fillRect(0, 0, f, -f), u.clearRect(p, p, d, d), u.drawImage(b, 0, 0, b.width, b.height, p + d * e[0], p + d * e[1] - f, d, d) }u.setTransform(1, 0, 0, 1, 0, 0), m() } } else u.fillStyle = "rgba(0,0,0,0)", g.options.fillBlanks && (u.fillStyle = g.options.customFillColor), u.fillRect(0, 0, f, f), m() }, g = this, v = 0; v < s.length; v++)m(v) }, e.prototype._calculateSize = function () { var e = this.meshes.length || 0, t = this.options.frameSize || 0, i = this._paddingValue || 0; switch (this.options.layout) { case 0: return new A(t * e + 2 * i * e, t + 2 * i); case 1: var r = Math.max(2, Math.ceil(Math.sqrt(e))), n = t * r + 2 * i * r; return new A(n, n); case 2: var o = this.options.colnum || 1, a = Math.max(1, Math.ceil(e / o)); return new A(t * o + 2 * i * o, t * a + 2 * i * a) }return A.Zero() }, e.prototype._calculateMeshUVFrames = function (e, t, i, r, n) { for (var o = this.meshes.length, a = 0; a < o; a++) { var s = this.meshes[a], l = new A(e / i.x, e / i.y), c = r.clone().scale(t), u = this._getFrameOffset(a).add(c), h = new dv(a, l, u); this.frames.push(h), n && (this._updateMeshUV(s, a), this._updateTextureReferences(s)) } }, e.prototype._getFrameOffset = function (e) { var t, i, r, n = this.meshes.length; switch (this.options.layout) { case 0: return new A(e * (t = 1 / n), 0); case 1: var o = Math.max(2, Math.ceil(Math.sqrt(n))); return i = Math.floor(e / o), new A((r = e - i * o) * (t = 1 / o), i * t); case 2: var a = this.options.colnum || 1, s = Math.max(1, Math.ceil(n / a)); return i = e - (r = Math.floor(e / s)) * s, t = new A(1 / a, 1 / s), new A(r * t.x, i * t.y) }return A.Zero() }, e.prototype._updateMeshUV = function (e, t) { var i = this.frames[t], r = e.getVerticesData(this.options.uvsIn || Hi.UVKind), n = [], o = 0; r.length && (o = r.length || 0); for (var a = 0; a < o; a += 2)n.push(r[a] * i.scale.x + i.offset.x, r[a + 1] * i.scale.y + i.offset.y); e.setVerticesData(this.options.uvsOut || Hi.UVKind, n) }, e.prototype._updateTextureReferences = function (e, t) { void 0 === t && (t = !1); for (var i = e.material, r = Object.keys(this.sets), n = function (e) { e.dispose && e.dispose() }, o = 0; o < r.length; o++) { var a = r[o]; if (t) null !== i[a] && n(i[a]), i[a] = this.sets[a]; else { if (!i) return; null !== i[a] && (n(i[a]), i[a] = this.sets[a]) } } }, e.prototype.setMeshToFrame = function (e, t, i) { void 0 === i && (i = !1), this._updateMeshUV(e, t), i && this._updateTextureReferences(e, !0) }, e.prototype.processAsync = function () { var e = this; return new Promise((function (t, i) { try { if (0 === e.meshes.length) return void t(); for (var r = 0, n = function (i) { var n = e.meshes[i], o = n.material; if (!o) return ++r === e.meshes.length ? { value: e._createFrames(t) } : "continue"; o.forceCompilationAsync(n).then((function () { !function (i) { if (r++, e.options.map) { for (var n = 0; n < e.options.map.length; n++)null !== i[e.options.map[n]] && (e.sets[e.options.map[n]] || (e.sets[e.options.map[n]] = !0), e._expecting++); r === e.meshes.length && e._createFrames(t) } }(o) })) }, o = 0; o < e.meshes.length; o++) { var a = n(o); if ("object" == typeof a) return a.value } } catch (e) { return i(e) } })) }, e.prototype.dispose = function () { for (var e = Object.keys(this.sets), t = 0; t < e.length; t++) { var i = e[t]; this.sets[i].dispose() } }, e.prototype.download = function (e, t) { var i = this; void 0 === e && (e = "png"), void 0 === t && (t = 1), setTimeout((function () { var r = { name: i.name, sets: {}, options: {}, frames: [] }, n = Object.keys(i.sets), o = Object.keys(i.options); try { for (var a = 0; a < n.length; a++) { var s = n[a], l = i.sets[s]; r.sets[s] = l.getContext().canvas.toDataURL("image/" + e, t) } for (a = 0; a < o.length; a++) { var c = o[a]; r.options[c] = i.options[c] } for (a = 0; a < i.frames.length; a++) { var u = i.frames[a]; r.frames.push(u.scale.x, u.scale.y, u.offset.x, u.offset.y) } } catch (e) { return void $.Warn("Unable to download: " + e) } var h = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(r, null, 4)), d = document.createElement("a"); d.setAttribute("href", h), d.setAttribute("download", i.name + "_texurePackage.json"), document.body.appendChild(d), d.click(), d.remove() }), 0) }, e.prototype.updateFromJSON = function (e) { try { var t = JSON.parse(e); this.name = t.name; for (var i = Object.keys(t.options), r = 0; r < i.length; r++)this.options[i[r]] = t.options[i[r]]; for (r = 0; r < t.frames.length; r += 4) { var n = new dv(r / 4, new A(t.frames[r], t.frames[r + 1]), new A(t.frames[r + 2], t.frames[r + 3])); this.frames.push(n) } var o = Object.keys(t.sets); for (r = 0; r < o.length; r++) { var a = new vo(t.sets[o[r]], this.scene, !1, !1); this.sets[o[r]] = a } } catch (e) { $.Warn("Unable to update from JSON: " + e) } }, e.LAYOUT_STRIP = 0, e.LAYOUT_POWER2 = 1, e.LAYOUT_COLNUM = 2, e.SUBUV_WRAP = 0, e.SUBUV_EXTEND = 1, e.SUBUV_COLOR = 2, e }(), fv = function (e) { function t(t, i, r, n, o, a, s) { var l = e.call(this, t, r, null, n, o, a) || this; return l._animate = !0, l._time = 0, l._texturePath = i, s ? l.setFragment(l._texturePath) : l._loadJson(i), l.refreshRate = 1, l } return W(t, e), t.prototype._loadJson = function (e) { var t = this, i = function () { try { t.setFragment(t._texturePath) } catch (e) { $.Log("No json or ShaderStore or DOM element found for CustomProceduralTexture") } }, r = e + "/config.json", n = new He; n.open("GET", r), n.addEventListener("load", (function () { if (200 === n.status || n.responseText && n.responseText.length > 0) 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; e < this._config.sampler2Ds.length; e++)this.setTexture(this._config.sampler2Ds[e].sample2Dname, new vo(this._texturePath + "/" + this._config.sampler2Ds[e].textureRelativeUrl, this.getScene())) }, t.prototype.updateShaderUniforms = function () { if (this._config) for (var e = 0; e < this._config.uniforms.length; e++) { var t = this._config.uniforms[e]; switch (t.type) { case "float": this.setFloat(t.name, t.value); break; case "color3": this.setColor3(t.name, new B(t.r, t.g, t.b)); break; case "color4": this.setColor4(t.name, new U(t.r, t.g, t.b, t.a)); break; case "vector2": this.setVector2(t.name, new A(t.x, t.y)); break; case "vector3": this.setVector3(t.name, new R(t.x, t.y, t.z)) } } this.setFloat("time", this._time) }, Object.defineProperty(t.prototype, "animate", { get: function () { return this._animate }, set: function (e) { this._animate = e }, enumerable: !1, configurable: !0 }), t }(rs); Ut.ShadersStore.noisePixelShader = "uniform float brightness;uniform float persistence;uniform float timeScale;varying vec2 vUV;vec2 hash22(vec2 p)\n{p=p*mat2(127.1,311.7,269.5,183.3);p=-1.0+2.0*fract(sin(p)*43758.5453123);return sin(p*6.283+timeScale);}\nfloat interpolationNoise(vec2 p)\n{vec2 pi=floor(p);vec2 pf=p-pi;vec2 w=pf*pf*(3.-2.*pf);float f00=dot(hash22(pi+vec2(.0,.0)),pf-vec2(.0,.0));float f01=dot(hash22(pi+vec2(.0,1.)),pf-vec2(.0,1.));float f10=dot(hash22(pi+vec2(1.0,0.)),pf-vec2(1.0,0.));float f11=dot(hash22(pi+vec2(1.0,1.)),pf-vec2(1.0,1.));float xm1=mix(f00,f10,w.x);float xm2=mix(f01,f11,w.x);float ym=mix(xm1,xm2,w.y); \nreturn ym;}\nfloat perlinNoise2D(float x,float y)\n{float sum=0.0;float frequency=0.0;float amplitude=0.0;for(int i=0; i 0 && (zn.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; y < p; y++)v += "#ifdef MORPHTARGETS\n", (null == f ? void 0 : f.isUsingTextureForTargets) ? (v += "vertexID = float(gl_VertexID) * morphTargetTextureInfo.x;\n", v += "".concat(l.associatedVariableName, " += (readVector3FromRawSampler(").concat(y, ", vertexID) - ").concat(n.associatedVariableName, ") * morphTargetInfluences[").concat(y, "];\n"), v += "vertexID += 1.0;\n") : v += "".concat(l.associatedVariableName, " += (position").concat(y, " - ").concat(n.associatedVariableName, ") * morphTargetInfluences[").concat(y, "];\n"), _ && (v += "#ifdef MORPHTARGETS_NORMAL\n", (null == f ? void 0 : f.isUsingTextureForTargets) ? (v += "".concat(c.associatedVariableName, " += (readVector3FromRawSampler(").concat(y, ", vertexID) - ").concat(o.associatedVariableName, ") * morphTargetInfluences[").concat(y, "];\n"), v += "vertexID += 1.0;\n") : v += "".concat(c.associatedVariableName, " += (normal").concat(y, " - ").concat(o.associatedVariableName, ") * morphTargetInfluences[").concat(y, "];\n"), v += "#endif\n"), g && (v += "#ifdef MORPHTARGETS_UV\n", (null == f ? void 0 : f.isUsingTextureForTargets) ? (v += "".concat(h.associatedVariableName, " += (readVector3FromRawSampler(").concat(y, ", vertexID).xy - ").concat(s.associatedVariableName, ") * morphTargetInfluences[").concat(y, "];\n"), v += "vertexID += 1.0;\n") : v += "".concat(h.associatedVariableName, ".xy += (uv_").concat(y, " - ").concat(s.associatedVariableName, ".xy) * morphTargetInfluences[").concat(y, "];\n"), v += "#endif\n"), m && (v += "#ifdef MORPHTARGETS_TANGENT\n", (null == f ? void 0 : f.isUsingTextureForTargets) ? v += "".concat(u.associatedVariableName, ".xyz += (readVector3FromRawSampler(").concat(y, ", vertexID) - ").concat(a.associatedVariableName, ".xyz) * morphTargetInfluences[").concat(y, "];\n") : v += "".concat(u.associatedVariableName, ".xyz += (tangent").concat(y, " - ").concat(a.associatedVariableName, ".xyz) * morphTargetInfluences[").concat(y, "];\n"), a.type === Jo.Vector4 ? v += "".concat(u.associatedVariableName, ".w = ").concat(a.associatedVariableName, ".w;\n") : v += "".concat(u.associatedVariableName, ".w = 1.;\n"), v += "#endif\n"), v += "#endif\n"; if (d.compilationString = d.compilationString.replace(this._repeatableContentAnchor, v), p > 0) for (y = 0; y < p; y++)d.attributes.push(Hi.PositionKind + y), _ && d.attributes.push(Hi.NormalKind + y), m && d.attributes.push(Hi.TangentKind + y), g && d.attributes.push(Hi.UVKind + "_" + y) }, t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t), t.sharedData.blocksWithDefines.push(this), t.sharedData.bindableBlocks.push(this), t.sharedData.repeatableContentBlocks.push(this); var i = this.position, r = this.normal, n = this.tangent, o = this.uv, a = this.positionOutput, s = this.normalOutput, l = this.tangentOutput, c = this.uvOutput, u = "//".concat(this.name); return t.uniforms.push("morphTargetInfluences"), t.uniforms.push("morphTargetTextureInfo"), t.uniforms.push("morphTargetTextureIndices"), t.samplers.push("morphTargets"), t._emitFunctionFromInclude("morphTargetsVertexGlobalDeclaration", u), t._emitFunctionFromInclude("morphTargetsVertexDeclaration", u, { repeatKey: "maxSimultaneousMorphTargets" }), t.compilationString += "".concat(this._declareOutput(a, t), " = ").concat(i.associatedVariableName, ";\n"), t.compilationString += "#ifdef NORMAL\n", t.compilationString += "".concat(this._declareOutput(s, t), " = ").concat(r.associatedVariableName, ";\n"), t.compilationString += "#else\n", t.compilationString += "".concat(this._declareOutput(s, t), " = vec3(0., 0., 0.);\n"), t.compilationString += "#endif\n", t.compilationString += "#ifdef TANGENT\n", t.compilationString += "".concat(this._declareOutput(l, t), " = ").concat(n.associatedVariableName, ";\n"), t.compilationString += "#else\n", t.compilationString += "".concat(this._declareOutput(l, t), " = vec4(0., 0., 0., 0.);\n"), t.compilationString += "#endif\n", t.compilationString += "#ifdef UV1\n", t.compilationString += "".concat(this._declareOutput(c, t), " = ").concat(o.associatedVariableName, ";\n"), t.compilationString += "#else\n", t.compilationString += "".concat(this._declareOutput(c, t), " = vec2(0., 0.);\n"), t.compilationString += "#endif\n", this._repeatableContentAnchor = t._repeatableContentAnchor, t.compilationString += this._repeatableContentAnchor, this }, t }(sa); b("BABYLON.MorphTargetsBlock", Sv); var xv = function (e) { function t(t) { var i = e.call(this, t, $o.Vertex) || this; return i.registerInput("worldPosition", Jo.Vector4, !1, $o.Vertex), i.registerOutput("direction", Jo.Vector3), i.registerOutput("color", Jo.Color3), i.registerOutput("intensity", Jo.Float), i.registerOutput("shadowBias", Jo.Float), i.registerOutput("shadowNormalBias", Jo.Float), i.registerOutput("shadowDepthScale", Jo.Float), i.registerOutput("shadowDepthRange", Jo.Vector2), i } return W(t, e), t.prototype.getClassName = function () { return "LightInformationBlock" }, Object.defineProperty(t.prototype, "worldPosition", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "direction", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "color", { get: function () { return this._outputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "intensity", { get: function () { return this._outputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "shadowBias", { get: function () { return this._outputs[3] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "shadowNormalBias", { get: function () { return this._outputs[4] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "shadowDepthScale", { get: function () { return this._outputs[5] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "shadowDepthRange", { get: function () { return this._outputs[6] }, enumerable: !1, configurable: !0 }), t.prototype.bind = function (e, t, i) { if (i) { this.light && this.light.isDisposed() && (this.light = null); var r = this.light, n = t.getScene(); if (!r && n.lights.length && (r = this.light = n.lights[0], this._forcePrepareDefines = !0), !r || !r.isEnabled) return e.setFloat3(this._lightDataUniformName, 0, 0, 0), void e.setFloat4(this._lightColorUniformName, 0, 0, 0, 0); r.transferToNodeMaterialEffect(e, this._lightDataUniformName), e.setColor4(this._lightColorUniformName, r.diffuse, r.intensity); var o = r.getShadowGenerator(); if ((this.shadowBias.hasEndpoints || this.shadowNormalBias.hasEndpoints || this.shadowDepthScale.hasEndpoints) && (o ? e.setFloat3(this._lightShadowUniformName, o.bias, o.normalBias, o.depthScale) : e.setFloat3(this._lightShadowUniformName, 0, 0, 0)), this.shadowDepthRange) if (o && n.activeCamera) { var a = r; e.setFloat2(this._lightShadowExtraUniformName, a.getDepthMinZ(n.activeCamera), a.getDepthMinZ(n.activeCamera) + a.getDepthMaxZ(n.activeCamera)) } else e.setFloat2(this._lightShadowExtraUniformName, 0, 0) } }, t.prototype.prepareDefines = function (e, t, i) { if (i._areLightsDirty || this._forcePrepareDefines) { this._forcePrepareDefines = !1; var r = this.light; i.setValue(this._lightTypeDefineName, !!(r && r instanceof ig), !0) } }, t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t), t.sharedData.bindableBlocks.push(this), t.sharedData.blocksWithDefines.push(this); var i = this.direction, r = this.color, n = this.intensity, o = this.shadowBias, a = this.shadowNormalBias, s = this.shadowDepthScale, l = this.shadowDepthRange; return this._lightDataUniformName = t._getFreeVariableName("lightData"), this._lightColorUniformName = t._getFreeVariableName("lightColor"), this._lightShadowUniformName = t._getFreeVariableName("shadowData"), this._lightShadowExtraUniformName = t._getFreeVariableName("shadowExtraData"), this._lightTypeDefineName = t._getFreeDefineName("LIGHTPOINTTYPE"), t._emitUniformFromString(this._lightDataUniformName, "vec3"), t._emitUniformFromString(this._lightColorUniformName, "vec4"), t.compilationString += "#ifdef ".concat(this._lightTypeDefineName, "\n"), t.compilationString += this._declareOutput(i, t) + " = normalize(".concat(this.worldPosition.associatedVariableName, ".xyz - ").concat(this._lightDataUniformName, ");\n"), t.compilationString += "#else\n", t.compilationString += this._declareOutput(i, t) + " = ".concat(this._lightDataUniformName, ";\n"), t.compilationString += "#endif\n", t.compilationString += this._declareOutput(r, t) + " = ".concat(this._lightColorUniformName, ".rgb;\n"), t.compilationString += this._declareOutput(n, t) + " = ".concat(this._lightColorUniformName, ".a;\n"), (o.hasEndpoints || a.hasEndpoints || s.hasEndpoints) && (t._emitUniformFromString(this._lightShadowUniformName, "vec3"), o.hasEndpoints && (t.compilationString += this._declareOutput(o, t) + " = ".concat(this._lightShadowUniformName, ".x;\n")), a.hasEndpoints && (t.compilationString += this._declareOutput(a, t) + " = ".concat(this._lightShadowUniformName, ".y;\n")), s.hasEndpoints && (t.compilationString += this._declareOutput(s, t) + " = ".concat(this._lightShadowUniformName, ".z;\n"))), l.hasEndpoints && (t._emitUniformFromString(this._lightShadowExtraUniformName, "vec2"), t.compilationString += this._declareOutput(l, t) + " = ".concat(this._lightShadowUniformName, ";\n")), this }, t.prototype.serialize = function () { var t = e.prototype.serialize.call(this); return 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)) }, t }(sa); b("BABYLON.LightInformationBlock", xv); var Av = function (e) { function t(t) { var i = e.call(this, t, $o.Fragment) || this; return i.convertInputToLinearSpace = !0, i.registerInput("color", Jo.AutoDetect), i.registerOutput("output", Jo.Color4), i.registerOutput("rgb", Jo.Color3), i._inputs[0].addExcludedConnectionPointFromAllowedTypes(Jo.Color3 | Jo.Color4 | Jo.Vector3 | Jo.Vector4), i } return W(t, e), t.prototype.getClassName = function () { return "ImageProcessingBlock" }, Object.defineProperty(t.prototype, "color", { 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, "rgb", { get: function () { return this._outputs[1] }, enumerable: !1, configurable: !0 }), t.prototype.initialize = function (e) { e._excludeVariableName("exposureLinear"), e._excludeVariableName("contrast"), e._excludeVariableName("vInverseScreenSize"), e._excludeVariableName("vignetteSettings1"), e._excludeVariableName("vignetteSettings2"), e._excludeVariableName("vCameraColorCurveNegative"), e._excludeVariableName("vCameraColorCurveNeutral"), e._excludeVariableName("vCameraColorCurvePositive"), e._excludeVariableName("txColorTransform"), e._excludeVariableName("colorTransformSettings"), e._excludeVariableName("ditherIntensity") }, t.prototype.isReady = function (e, t, i) { return !(i._areImageProcessingDirty && t.imageProcessingConfiguration && !t.imageProcessingConfiguration.isReady()) }, t.prototype.prepareDefines = function (e, t, i) { i._areImageProcessingDirty && t.imageProcessingConfiguration && t.imageProcessingConfiguration.prepareDefines(i) }, t.prototype.bind = function (e, t, i) { i && t.imageProcessingConfiguration && t.imageProcessingConfiguration.bind(e) }, t.prototype._buildBlock = function (t) { var i; e.prototype._buildBlock.call(this, t), t.sharedData.blocksWithDefines.push(this), t.sharedData.blockingBlocks.push(this), t.sharedData.bindableBlocks.push(this), 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"); var r = this.color, n = this._outputs[0], o = "//".concat(this.name); return t._emitFunctionFromInclude("helperFunctions", o), t._emitFunctionFromInclude("imageProcessingDeclaration", o), t._emitFunctionFromInclude("imageProcessingFunctions", o), (null === (i = r.connectedPoint) || void 0 === i ? void 0 : i.isConnected) && (r.connectedPoint.type === Jo.Color4 || r.connectedPoint.type === Jo.Vector4 ? t.compilationString += "".concat(this._declareOutput(n, t), " = ").concat(r.associatedVariableName, ";\n") : t.compilationString += "".concat(this._declareOutput(n, t), " = vec4(").concat(r.associatedVariableName, ", 1.0);\n"), t.compilationString += "#ifdef IMAGEPROCESSINGPOSTPROCESS\n", this.convertInputToLinearSpace && (t.compilationString += "".concat(n.associatedVariableName, ".rgb = toLinearSpace(").concat(r.associatedVariableName, ".rgb);\n")), t.compilationString += "#else\n", t.compilationString += "#ifdef IMAGEPROCESSING\n", this.convertInputToLinearSpace && (t.compilationString += "".concat(n.associatedVariableName, ".rgb = toLinearSpace(").concat(r.associatedVariableName, ".rgb);\n")), t.compilationString += "".concat(n.associatedVariableName, " = applyImageProcessing(").concat(n.associatedVariableName, ");\n"), t.compilationString += "#endif\n", t.compilationString += "#endif\n", this.rgb.hasEndpoints && (t.compilationString += this._declareOutput(this.rgb, t) + " = ".concat(this.output.associatedVariableName, ".xyz;\n"))), this }, t.prototype._dumpPropertiesCode = function () { return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".convertInputToLinearSpace = ").concat(this.convertInputToLinearSpace, ";\n") }, t.prototype.serialize = function () { var t = e.prototype.serialize.call(this); return t.convertInputToLinearSpace = this.convertInputToLinearSpace, t }, t.prototype._deserialize = function (t, i, r) { var n; e.prototype._deserialize.call(this, t, i, r), this.convertInputToLinearSpace = null === (n = t.convertInputToLinearSpace) || void 0 === n || n }, X([ha("Convert input to linear space", ca.Boolean, "ADVANCED")], t.prototype, "convertInputToLinearSpace", void 0), t }(sa); b("BABYLON.ImageProcessingBlock", Av); var Rv = function (e) { function t(i) { var r = e.call(this, i, $o.Fragment, !0) || this; return r.registerInput("normal", Jo.AutoDetect, !1), r.normal.addExcludedConnectionPointFromAllowedTypes(Jo.Color4 | Jo.Vector4 | Jo.Vector3), r.registerInput("tangent", Jo.Vector4, !1), r.registerInput("world", Jo.Matrix, !1), r.registerOutput("TBN", Jo.Object, $o.Fragment, new bv("TBN", r, ra.Output, t, "TBNBlock")), r.registerOutput("row0", Jo.Vector3, $o.Fragment), r.registerOutput("row1", Jo.Vector3, $o.Fragment), r.registerOutput("row2", Jo.Vector3, $o.Fragment), r } return W(t, e), t.prototype.getClassName = function () { return "TBNBlock" }, t.prototype.initialize = function (e) { e._excludeVariableName("tbnNormal"), e._excludeVariableName("tbnTangent"), e._excludeVariableName("tbnBitangent"), e._excludeVariableName("TBN") }, Object.defineProperty(t.prototype, "normal", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tangent", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "world", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "TBN", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "row0", { get: function () { return this._outputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "row1", { get: function () { return this._outputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "row2", { get: function () { return this._outputs[3] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "target", { get: function () { return $o.Fragment }, set: function (e) { }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function (e) { if (!this.world.isConnected) { var t = e.getInputBlockByPredicate((function (e) { return e.isSystemValue && e.systemValue === pa.World })); t || (t = new Ta("world")).setAsSystemValue(pa.World), t.output.connectTo(this.world) } if (!this.normal.isConnected) { var i = e.getInputBlockByPredicate((function (e) { return e.isAttribute && "normal" === e.name })); i || (i = new Ta("normal")).setAsAttribute("normal"), i.output.connectTo(this.normal) } if (!this.tangent.isConnected) { var r = e.getInputBlockByPredicate((function (e) { return e.isAttribute && "tangent" === e.name && e.type === Jo.Vector4 })); r || (r = new Ta("tangent")).setAsAttribute("tangent"), r.output.connectTo(this.tangent) } }, t.prototype.prepareDefines = function (e, t, i) { var r, n, o, a, s = this.normal, l = this.tangent, c = s.isConnected; (null === (r = s.connectInputBlock) || void 0 === r ? void 0 : r.isAttribute) && !e.isVerticesDataPresent(null === (n = s.connectInputBlock) || void 0 === n ? void 0 : n.name) && (c = !1); var u = l.isConnected; (null === (o = l.connectInputBlock) || void 0 === o ? void 0 : o.isAttribute) && !e.isVerticesDataPresent(null === (a = l.connectInputBlock) || void 0 === a ? void 0 : a.name) && (u = !1); var h = c && u; i.setValue("TBNBLOCK", h, !0) }, t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t); var i = this.normal, r = this.tangent, n = this.world, o = this.TBN, a = this.row0, s = this.row1, l = this.row2; return t.target === $o.Fragment && (t.compilationString += "\n // ".concat(this.name, "\n vec3 tbnNormal = normalize(").concat(i.associatedVariableName, ").xyz;\n vec3 tbnTangent = normalize(").concat(r.associatedVariableName, ".xyz);\n vec3 tbnBitangent = cross(tbnNormal, tbnTangent) * ").concat(r.associatedVariableName, ".w;\n mat3 ").concat(o.associatedVariableName, " = mat3(").concat(n.associatedVariableName, ") * mat3(tbnTangent, tbnBitangent, tbnNormal);\n "), a.hasEndpoints && (t.compilationString += this._declareOutput(a, t) + " = vec3(".concat(o.associatedVariableName, "[0][0], ").concat(o.associatedVariableName, "[0][1], ").concat(o.associatedVariableName, "[0][2]);\n")), s.hasEndpoints && (t.compilationString += this._declareOutput(s, t) + " = vec3(".concat(o.associatedVariableName, "[1[0], ").concat(o.associatedVariableName, "[1][1], ").concat(o.associatedVariableName, "[1][2]);\n")), l.hasEndpoints && (t.compilationString += this._declareOutput(l, t) + " = vec3(".concat(o.associatedVariableName, "[2][0], ").concat(o.associatedVariableName, "[2][1], ").concat(o.associatedVariableName, "[2][2]);\n")), t.sharedData.blocksWithDefines.push(this)), this }, t }(sa); b("BABYLON.TBNBlock", Rv); var Cv = function (e) { function t(t) { var i = e.call(this, t, $o.Fragment) || this; return i._tangentSpaceParameterName = "", i._tangentCorrectionFactorName = "", i._worldMatrixName = "", i.invertX = !1, i.invertY = !1, i.useParallaxOcclusion = !1, i.useObjectSpaceNormalMap = !1, i._isUnique = !0, i.registerInput("worldPosition", Jo.Vector4, !1), i.registerInput("worldNormal", Jo.Vector4, !1), i.registerInput("worldTangent", Jo.Vector4, !0), i.registerInput("uv", Jo.Vector2, !1), i.registerInput("normalMapColor", Jo.Color3, !1), i.registerInput("strength", Jo.Float, !1), i.registerInput("viewDirection", Jo.Vector3, !0), i.registerInput("parallaxScale", Jo.Float, !0), i.registerInput("parallaxHeight", Jo.Float, !0), i.registerInput("TBN", Jo.Object, !0, $o.VertexAndFragment, new bv("TBN", i, ra.Input, Rv, "TBNBlock")), i.registerInput("world", Jo.Matrix, !0), i.registerOutput("output", Jo.Vector4), i.registerOutput("uvOffset", Jo.Vector2), i } return W(t, e), t.prototype.getClassName = function () { return "PerturbNormalBlock" }, Object.defineProperty(t.prototype, "worldPosition", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldNormal", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldTangent", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "uv", { get: function () { return this._inputs[3] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "normalMapColor", { get: function () { return this._inputs[4] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "strength", { get: function () { return this._inputs[5] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "viewDirection", { get: function () { return this._inputs[6] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "parallaxScale", { get: function () { return this._inputs[7] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "parallaxHeight", { get: function () { return this._inputs[8] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "TBN", { get: function () { return this._inputs[9] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "world", { get: function () { return this._inputs[10] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "uvOffset", { get: function () { return this._outputs[1] }, enumerable: !1, configurable: !0 }), t.prototype.prepareDefines = function (e, t, i) { var r = this.normalMapColor.connectedPoint._ownerBlock.samplerName, n = this.viewDirection.isConnected && (this.useParallaxOcclusion && r || !this.useParallaxOcclusion && this.parallaxHeight.isConnected); i.setValue("BUMP", !0), i.setValue("PARALLAX", n, !0), i.setValue("PARALLAXOCCLUSION", this.useParallaxOcclusion, !0), i.setValue("OBJECTSPACE_NORMALMAP", this.useObjectSpaceNormalMap, !0) }, t.prototype.bind = function (e, t, i) { t.getScene()._mirroredCameraPosition ? e.setFloat2(this._tangentSpaceParameterName, this.invertX ? 1 : -1, this.invertY ? 1 : -1) : e.setFloat2(this._tangentSpaceParameterName, this.invertX ? -1 : 1, this.invertY ? -1 : 1), i && (e.setFloat(this._tangentCorrectionFactorName, i.getWorldMatrix().determinant() < 0 ? -1 : 1), this.useObjectSpaceNormalMap && !this.world.isConnected && e.setMatrix(this._worldMatrixName, i.getWorldMatrix())) }, t.prototype.autoConfigure = function (e) { if (!this.uv.isConnected) { var t = e.getInputBlockByPredicate((function (e) { return e.isAttribute && "uv" === e.name })); t || (t = new Ta("uv")).setAsAttribute(), t.output.connectTo(this.uv) } if (!this.strength.isConnected) { var i = new Ta("strength"); i.value = 1, i.output.connectTo(this.strength) } }, t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t); var i = "//".concat(this.name), r = this.uv, n = this.worldPosition, o = this.worldNormal, a = this.worldTangent; t.sharedData.blocksWithDefines.push(this), t.sharedData.bindableBlocks.push(this), this._tangentSpaceParameterName = t._getFreeDefineName("tangentSpaceParameter"), t._emitUniformFromString(this._tangentSpaceParameterName, "vec2"), this._tangentCorrectionFactorName = t._getFreeDefineName("tangentCorrectionFactor"), t._emitUniformFromString(this._tangentCorrectionFactorName, "float"), this._worldMatrixName = t._getFreeDefineName("perturbNormalWorldMatrix"), t._emitUniformFromString(this._worldMatrixName, "mat4"); var s = null; this.normalMapColor.connectedPoint && (s = this.normalMapColor.connectedPoint._ownerBlock.samplerName); var l = this.viewDirection.isConnected && (this.useParallaxOcclusion && s || !this.useParallaxOcclusion && this.parallaxHeight.isConnected), c = this.parallaxScale.isConnectedToInputBlock ? this.parallaxScale.connectInputBlock.isConstant ? t._emitFloat(this.parallaxScale.connectInputBlock.value) : this.parallaxScale.associatedVariableName : "0.05", u = this.strength.isConnectedToInputBlock && this.strength.connectInputBlock.isConstant ? "\n#if !defined(NORMALXYSCALE)\n1.0/\n#endif\n".concat(t._emitFloat(this.strength.connectInputBlock.value)) : "\n#if !defined(NORMALXYSCALE)\n1.0/\n#endif\n".concat(this.strength.associatedVariableName); t._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable"); var h = { search: /defined\(TANGENT\)/g, replace: a.isConnected ? "defined(TANGENT)" : "defined(IGNORE)" }, d = this.TBN; d.isConnected ? t.compilationString += "\n #ifdef TBNBLOCK\n mat3 vTBN = ".concat(d.associatedVariableName, ";\n #endif\n ") : a.isConnected && (t.compilationString += "vec3 tbnNormal = normalize(".concat(o.associatedVariableName, ".xyz);\n"), t.compilationString += "vec3 tbnTangent = normalize(".concat(a.associatedVariableName, ".xyz);\n"), t.compilationString += "vec3 tbnBitangent = cross(tbnNormal, tbnTangent) * ".concat(this._tangentCorrectionFactorName, ";\n"), t.compilationString += "mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\n"), t._emitFunctionFromInclude("bumpFragmentMainFunctions", i, { replaceStrings: [h, { search: /varying mat3 vTBN;/g, replace: "" }, { search: /uniform mat4 normalMatrix;/g, replace: "" }] }), t._emitFunctionFromInclude("bumpFragmentFunctions", i, { replaceStrings: [{ search: /#include\(_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([ha("Invert X axis", ca.Boolean, "PROPERTIES", { notifiers: { update: !1 } })], t.prototype, "invertX", void 0), X([ha("Invert Y axis", ca.Boolean, "PROPERTIES", { notifiers: { update: !1 } })], t.prototype, "invertY", void 0), X([ha("Use parallax occlusion", ca.Boolean)], t.prototype, "useParallaxOcclusion", void 0), X([ha("Object Space Mode", ca.Boolean, "PROPERTIES", { notifiers: { update: !1 } })], t.prototype, "useObjectSpaceNormalMap", void 0), t }(sa); b("BABYLON.PerturbNormalBlock", Cv); var Pv = function (e) { function t(t) { var i = e.call(this, t, $o.Fragment, !0) || this; return i.registerInput("value", Jo.Float, !0), i.registerInput("cutoff", Jo.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 }(sa); b("BABYLON.DiscardBlock", Pv); var Iv = function (e) { function t(t) { var i = e.call(this, t, $o.Fragment) || this; return i.registerOutput("output", Jo.Float, $o.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 === $o.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 }(sa); b("BABYLON.FrontFacingBlock", Iv); var Mv = function (e) { function t(t) { var i = e.call(this, t, $o.Fragment) || this; return i.registerInput("input", Jo.AutoDetect, !1), i.registerOutput("dx", Jo.BasedOnInput), i.registerOutput("dy", Jo.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 }(sa); b("BABYLON.DerivativeBlock", Mv); var Ov = function (e) { function t(t) { var i = e.call(this, t, $o.Fragment) || this; return i.registerOutput("xy", Jo.Vector2, $o.Fragment), i.registerOutput("xyz", Jo.Vector3, $o.Fragment), i.registerOutput("xyzw", Jo.Vector4, $o.Fragment), i.registerOutput("x", Jo.Float, $o.Fragment), i.registerOutput("y", Jo.Float, $o.Fragment), i.registerOutput("z", Jo.Float, $o.Fragment), i.registerOutput("w", Jo.Float, $o.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 < r.length; i++) { var n = r[i]; n.hasEndpoints && (t += "".concat(this._declareOutput(n, e), " = gl_FragCoord.").concat(n.name, ";\n")) } return t }, t.prototype._buildBlock = function (t) { if (e.prototype._buildBlock.call(this, t), t.target === $o.Vertex) throw "FragCoordBlock must only be used in a fragment shader"; return t.compilationString += this.writeOutputs(t), this }, t }(sa); b("BABYLON.FragCoordBlock", Ov); var Dv = function (e) { function t(t) { var i = e.call(this, t, $o.Fragment) || this; return i.registerOutput("xy", Jo.Vector2, $o.Fragment), i.registerOutput("x", Jo.Float, $o.Fragment), i.registerOutput("y", Jo.Float, $o.Fragment), i } return W(t, e), t.prototype.getClassName = function () { return "ScreenSizeBlock" }, Object.defineProperty(t.prototype, "xy", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "x", { get: function () { return this._outputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "y", { get: function () { return this._outputs[2] }, enumerable: !1, configurable: !0 }), t.prototype.bind = function (e) { var t = this._scene.getEngine(); e.setFloat2(this._varName, t.getRenderWidth(), t.getRenderHeight()) }, t.prototype.writeOutputs = function (e, t) { for (var i = "", r = 0, n = this._outputs; r < n.length; r++) { var o = n[r]; o.hasEndpoints && (i += "".concat(this._declareOutput(o, e), " = ").concat(t, ".").concat(o.name, ";\n")) } return i }, t.prototype._buildBlock = function (t) { if (e.prototype._buildBlock.call(this, t), this._scene = t.sharedData.scene, t.target === $o.Vertex) throw "ScreenSizeBlock must only be used in a fragment shader"; return t.sharedData.bindableBlocks.push(this), this._varName = t._getFreeVariableName("screenSize"), t._emitUniformFromString(this._varName, "vec2"), t.compilationString += this.writeOutputs(t, this._varName), this }, t }(sa); b("BABYLON.ScreenSizeBlock", Dv); var Nv = function (e) { function t(t) { var i = e.call(this, t, $o.Fragment) || this; return i.registerInput("vector", Jo.AutoDetect), i.registerInput("worldViewProjection", Jo.Matrix), i.registerOutput("output", Jo.Vector2), i.registerOutput("x", Jo.Float), i.registerOutput("y", Jo.Float), i.inputs[0].addExcludedConnectionPointFromAllowedTypes(Jo.Color3 | Jo.Vector3 | Jo.Vector4), i } return W(t, e), t.prototype.getClassName = function () { return "ScreenSpaceBlock" }, Object.defineProperty(t.prototype, "vector", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldViewProjection", { 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 }), Object.defineProperty(t.prototype, "x", { get: function () { return this._outputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "y", { get: function () { return this._outputs[2] }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function (e) { if (!this.worldViewProjection.isConnected) { var t = e.getInputBlockByPredicate((function (e) { return e.systemValue === pa.WorldViewProjection })); t || (t = new Ta("worldViewProjection")).setAsSystemValue(pa.WorldViewProjection), t.output.connectTo(this.worldViewProjection) } }, t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t); var i = this.vector, r = this.worldViewProjection; if (i.connectedPoint) { var n = r.associatedVariableName, o = t._getFreeVariableName("screenSpaceTemp"); switch (i.connectedPoint.type) { case Jo.Vector3: t.compilationString += "vec4 ".concat(o, " = ").concat(n, " * vec4(").concat(i.associatedVariableName, ", 1.0);\n"); break; case Jo.Vector4: t.compilationString += "vec4 ".concat(o, " = ").concat(n, " * ").concat(i.associatedVariableName, ";\n") }return t.compilationString += "".concat(o, ".xy /= ").concat(o, ".w;"), t.compilationString += "".concat(o, ".xy = ").concat(o, ".xy * 0.5 + vec2(0.5, 0.5);"), this.output.hasEndpoints && (t.compilationString += this._declareOutput(this.output, t) + " = ".concat(o, ".xy;\n")), this.x.hasEndpoints && (t.compilationString += this._declareOutput(this.x, t) + " = ".concat(o, ".x;\n")), this.y.hasEndpoints && (t.compilationString += this._declareOutput(this.y, t) + " = ".concat(o, ".y;\n")), this } }, t }(sa); b("BABYLON.ScreenSpaceBlock", Nv); var Fv = function (e) { function t(t) { var i = e.call(this, t, $o.Fragment) || this; return i.registerInput("input", Jo.Vector2), i.registerInput("strength", Jo.Float), i.registerInput("center", Jo.Vector2), i.registerInput("offset", Jo.Vector2), i.registerOutput("output", Jo.Vector2), i.registerOutput("x", Jo.Float), i.registerOutput("y", Jo.Float), i } return W(t, e), t.prototype.getClassName = function () { return "TwirlBlock" }, Object.defineProperty(t.prototype, "input", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "strength", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "center", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "offset", { 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 }), Object.defineProperty(t.prototype, "x", { get: function () { return this._outputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "y", { get: function () { return this._outputs[2] }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function () { if (!this.center.isConnected) { var e = new Ta("center"); e.value = new A(.5, .5), e.output.connectTo(this.center) } if (!this.strength.isConnected) { var t = new Ta("strength"); t.value = 1, t.output.connectTo(this.strength) } if (!this.offset.isConnected) { var i = new Ta("offset"); i.value = new A(0, 0), i.output.connectTo(this.offset) } }, t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t); var i = t._getFreeVariableName("delta"), r = t._getFreeVariableName("angle"), n = t._getFreeVariableName("x"), o = t._getFreeVariableName("y"), a = t._getFreeVariableName("result"); return t.compilationString += "\n vec2 ".concat(i, " = ").concat(this.input.associatedVariableName, " - ").concat(this.center.associatedVariableName, ";\n float ").concat(r, " = ").concat(this.strength.associatedVariableName, " * length(").concat(i, ");\n float ").concat(n, " = cos(").concat(r, ") * ").concat(i, ".x - sin(").concat(r, ") * ").concat(i, ".y;\n float ").concat(o, " = sin(").concat(r, ") * ").concat(i, ".x + cos(").concat(r, ") * ").concat(i, ".y;\n vec2 ").concat(a, " = vec2(").concat(n, " + ").concat(this.center.associatedVariableName, ".x + ").concat(this.offset.associatedVariableName, ".x, ").concat(o, " + ").concat(this.center.associatedVariableName, ".y + ").concat(this.offset.associatedVariableName, ".y);\n "), this.output.hasEndpoints && (t.compilationString += this._declareOutput(this.output, t) + " = ".concat(a, ";\n")), this.x.hasEndpoints && (t.compilationString += this._declareOutput(this.x, t) + " = ".concat(a, ".x;\n")), this.y.hasEndpoints && (t.compilationString += this._declareOutput(this.y, t) + " = ".concat(a, ".y;\n")), this }, t }(sa); b("BABYLON.TwirlBlock", Fv); var Lv = function (e) { function t(t) { var i = e.call(this, t, $o.Fragment) || this; return i.generateInWorldSpace = !1, i.automaticNormalizationNormal = !0, i.automaticNormalizationTangent = !0, i.registerInput("input", Jo.Float), i.registerInput("worldPosition", Jo.Vector3), i.registerInput("worldNormal", Jo.Vector3), i.registerInput("worldTangent", Jo.AutoDetect, !0), i.registerOutput("output", Jo.Vector4), i.registerOutput("xyz", Jo.Vector3), i._inputs[3].addExcludedConnectionPointFromAllowedTypes(Jo.Color3 | Jo.Vector3 | Jo.Vector4), i } return W(t, e), t.prototype.getClassName = function () { return "HeightToNormalBlock" }, Object.defineProperty(t.prototype, "input", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldPosition", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldNormal", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldTangent", { 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 }), Object.defineProperty(t.prototype, "xyz", { 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]; this.generateInWorldSpace || this.worldTangent.isConnected || console.error("You must connect the 'worldTangent' input of the ".concat(this.name, " block!")); var r = this.generateInWorldSpace ? "" : "\n vec3 biTangent = cross(normal, tangent);\n mat3 TBN = mat3(tangent, biTangent, normal);\n ", n = this.generateInWorldSpace ? "" : "\n result = TBN * result;\n result = result * vec3(0.5) + vec3(0.5);\n ", o = "\n vec4 heightToNormal(in float height, in vec3 position, in vec3 tangent, in vec3 normal) {\n ".concat(r, "\n ").concat(this.automaticNormalizationTangent ? "tangent = normalize(tangent);" : "", "\n ").concat(this.automaticNormalizationNormal ? "normal = normalize(normal);" : "", "\n vec3 worlddX = dFdx(position);\n vec3 worlddY = dFdy(position);\n vec3 crossX = cross(normal, worlddX);\n vec3 crossY = cross(normal, worlddY);\n float d = abs(dot(crossY, worlddX));\n vec3 inToNormal = vec3(((((height + dFdx(height)) - height) * crossY) + (((height + dFdy(height)) - height) * crossX)) * sign(d));\n inToNormal.y *= -1.0;\n vec3 result = normalize((d * normal) - inToNormal);\n ").concat(n, "\n return vec4(result, 0.);\n }"); return t._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable"), t._emitFunction("heightToNormal", o, "// heightToNormal"), t.compilationString += this._declareOutput(i, t) + " = heightToNormal(".concat(this.input.associatedVariableName, ", ").concat(this.worldPosition.associatedVariableName, ", ").concat(this.worldTangent.isConnected ? this.worldTangent.associatedVariableName : "vec3(0.)", ".xyz, ").concat(this.worldNormal.associatedVariableName, ");\n"), this.xyz.hasEndpoints && (t.compilationString += this._declareOutput(this.xyz, t) + " = ".concat(this.output.associatedVariableName, ".xyz;\n")), this }, t.prototype._dumpPropertiesCode = function () { var t = e.prototype._dumpPropertiesCode.call(this); return t += "".concat(this._codeVariableName, ".generateInWorldSpace = ").concat(this.generateInWorldSpace, ";\n"), (t += "".concat(this._codeVariableName, ".automaticNormalizationNormal = ").concat(this.automaticNormalizationNormal, ";\n")) + "".concat(this._codeVariableName, ".automaticNormalizationTangent = ").concat(this.automaticNormalizationTangent, ";\n") }, t.prototype.serialize = function () { var t = e.prototype.serialize.call(this); return t.generateInWorldSpace = this.generateInWorldSpace, t.automaticNormalizationNormal = this.automaticNormalizationNormal, t.automaticNormalizationTangent = this.automaticNormalizationTangent, t }, t.prototype._deserialize = function (t, i, r) { e.prototype._deserialize.call(this, t, i, r), this.generateInWorldSpace = t.generateInWorldSpace, this.automaticNormalizationNormal = t.automaticNormalizationNormal, this.automaticNormalizationTangent = t.automaticNormalizationTangent }, X([ha("Generate in world space instead of tangent space", ca.Boolean, "PROPERTIES", { notifiers: { update: !0 } })], t.prototype, "generateInWorldSpace", void 0), X([ha("Force normalization for the worldNormal input", ca.Boolean, "PROPERTIES", { notifiers: { update: !0 } })], t.prototype, "automaticNormalizationNormal", void 0), X([ha("Force normalization for the worldTangent input", ca.Boolean, "PROPERTIES", { notifiers: { update: !0 } })], t.prototype, "automaticNormalizationTangent", void 0), t }(sa); b("BABYLON.HeightToNormalBlock", Lv); var wv = function (e) { function t(t) { var i = e.call(this, t, $o.Fragment, !0) || this; return i.registerInput("depth", Jo.Float, !0), i.registerInput("worldPos", Jo.Vector4, !0), i.registerInput("viewProjection", Jo.Matrix, !0), i } return W(t, e), t.prototype.getClassName = function () { return "FragDepthBlock" }, Object.defineProperty(t.prototype, "depth", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldPos", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "viewProjection", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function (t) { return e.prototype._buildBlock.call(this, t), this.depth.isConnected ? t.compilationString += "gl_FragDepth = ".concat(this.depth.associatedVariableName, ";\n") : this.worldPos.isConnected && this.viewProjection.isConnected ? t.compilationString += "\n vec4 p = ".concat(this.viewProjection.associatedVariableName, " * ").concat(this.worldPos.associatedVariableName, ";\n float v = p.z / p.w;\n #ifndef IS_NDC_HALF_ZRANGE\n v = v * 0.5 + 0.5;\n #endif\n gl_FragDepth = v;\n \n ") : console.warn("FragDepthBlock: either the depth input or both the worldPos and viewProjection inputs must be connected!"), this }, t }(sa); b("BABYLON.FragDepthBlock", wv); var Bv = function (e) { function t(t) { var i = e.call(this, t, $o.Fragment) || this; return i.registerInput("worldPosition", Jo.Vector4, !1), i.registerInput("viewProjection", Jo.Matrix, !1), i.registerInput("worldNormal", Jo.AutoDetect, !0), i.registerOutput("depth", Jo.Vector3), i.worldNormal.addExcludedConnectionPointFromAllowedTypes(Jo.Color3 | Jo.Vector3 | Jo.Vector4), i } return W(t, e), t.prototype.getClassName = function () { return "ShadowMapBlock" }, t.prototype.initialize = function (e) { e._excludeVariableName("vPositionWSM"), e._excludeVariableName("lightDataSM"), e._excludeVariableName("biasAndScaleSM"), e._excludeVariableName("depthValuesSM"), e._excludeVariableName("clipPos"), e._excludeVariableName("worldPos"), e._excludeVariableName("zSM") }, Object.defineProperty(t.prototype, "worldPosition", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "viewProjection", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldNormal", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "depth", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t); var i = "//".concat(this.name); return t._emitUniformFromString("biasAndScaleSM", "vec3"), t._emitUniformFromString("lightDataSM", "vec3"), t._emitUniformFromString("depthValuesSM", "vec2"), t._emitFunctionFromInclude("packingFunctions", i), t.compilationString += "vec4 worldPos = ".concat(this.worldPosition.associatedVariableName, ";\n"), t.compilationString += "vec3 vPositionWSM;\n", t.compilationString += "float vDepthMetricSM = 0.0;\n", t.compilationString += "float zSM;\n", this.worldNormal.isConnected && (t.compilationString += "vec3 vNormalW = ".concat(this.worldNormal.associatedVariableName, ".xyz;\n"), t.compilationString += t._emitCodeFromInclude("shadowMapVertexNormalBias", i)), t.compilationString += "vec4 clipPos = ".concat(this.viewProjection.associatedVariableName, " * worldPos;\n"), t.compilationString += t._emitCodeFromInclude("shadowMapVertexMetric", i, { replaceStrings: [{ search: /gl_Position/g, replace: "clipPos" }] }), t.compilationString += t._emitCodeFromInclude("shadowMapFragment", i, { replaceStrings: [{ search: /return;/g, replace: "" }] }), t.compilationString += "\n #if SM_DEPTHTEXTURE == 1\n #ifdef IS_NDC_HALF_ZRANGE\n gl_FragDepth = (clipPos.z / clipPos.w);\n #else\n gl_FragDepth = (clipPos.z / clipPos.w) * 0.5 + 0.5;\n #endif\n #endif\n ", t.compilationString += "".concat(this._declareOutput(this.depth, t), " = vec3(depthSM, 1., 1.);\n"), this }, t }(sa); b("BABYLON.ShadowMapBlock", Bv); var Uv = function (e) { function t(t) { var i = e.call(this, t, $o.VertexAndFragment, !1) || this; return i.registerInput("worldPosition", Jo.Vector4, !1, $o.Vertex), i.registerInput("view", Jo.Matrix, !1, $o.Vertex), i.registerInput("input", Jo.AutoDetect, !1, $o.Fragment), i.registerInput("fogColor", Jo.AutoDetect, !1, $o.Fragment), i.registerOutput("output", Jo.Color3, $o.Fragment), i.input.addExcludedConnectionPointFromAllowedTypes(Jo.Color3 | Jo.Vector3 | Jo.Color4), i.fogColor.addExcludedConnectionPointFromAllowedTypes(Jo.Color3 | Jo.Vector3 | Jo.Color4), i } return W(t, e), t.prototype.getClassName = function () { return "FogBlock" }, Object.defineProperty(t.prototype, "worldPosition", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "view", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "input", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fogColor", { 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.autoConfigure = function (e) { if (!this.view.isConnected) { var t = e.getInputBlockByPredicate((function (e) { return e.systemValue === pa.View })); t || (t = new Ta("view")).setAsSystemValue(pa.View), t.output.connectTo(this.view) } if (!this.fogColor.isConnected) { var i = e.getInputBlockByPredicate((function (e) { return e.systemValue === pa.FogColor })); i || (i = new Ta("fogColor", void 0, Jo.Color3)).setAsSystemValue(pa.FogColor), i.output.connectTo(this.fogColor) } }, t.prototype.prepareDefines = function (e, t, i) { var r = e.getScene(); i.setValue("FOG", t.fogEnabled && zn.GetFogState(e, r)) }, t.prototype.bind = function (e, t, i) { if (i) { var r = i.getScene(); e.setFloat4(this._fogParameters, r.fogMode, r.fogStart, r.fogEnd, r.fogDensity) } }, t.prototype._buildBlock = function (t) { if (e.prototype._buildBlock.call(this, t), t.target === $o.Fragment) { t.sharedData.blocksWithDefines.push(this), t.sharedData.bindableBlocks.push(this), t._emitFunctionFromInclude("fogFragmentDeclaration", "//".concat(this.name), { removeUniforms: !0, removeVaryings: !0, removeIfDef: !1, replaceStrings: [{ search: /float CalcFogFactor\(\)/, replace: "float CalcFogFactor(vec3 vFogDistance, vec4 vFogInfos)" }] }); var i = t._getFreeVariableName("fog"), r = this.input, n = this.fogColor; this._fogParameters = t._getFreeVariableName("fogParameters"); var o = this._outputs[0]; t._emitUniformFromString(this._fogParameters, "vec4"), t.compilationString += "#ifdef FOG\n", t.compilationString += "float ".concat(i, " = CalcFogFactor(").concat(this._fogDistanceName, ", ").concat(this._fogParameters, ");\n"), t.compilationString += this._declareOutput(o, t) + " = ".concat(i, " * ").concat(r.associatedVariableName, ".rgb + (1.0 - ").concat(i, ") * ").concat(n.associatedVariableName, ".rgb;\n"), t.compilationString += "#else\n".concat(this._declareOutput(o, t), " = ").concat(r.associatedVariableName, ".rgb;\n"), t.compilationString += "#endif\n" } else { var a = this.worldPosition, s = this.view; this._fogDistanceName = t._getFreeVariableName("vFogDistance"), t._emitVaryingFromString(this._fogDistanceName, "vec3"), t.compilationString += "".concat(this._fogDistanceName, " = (").concat(s.associatedVariableName, " * ").concat(a.associatedVariableName, ").xyz;\n") } return this }, t }(sa); b("BABYLON.FogBlock", Uv); var Vv = function (e) { function t(t) { var i = e.call(this, t, $o.VertexAndFragment) || this; return i._lightId = 0, i.generateOnlyFragmentCode = !1, i._isUnique = !0, i.registerInput("worldPosition", Jo.Vector4, !1, $o.Vertex), i.registerInput("worldNormal", Jo.Vector4, !1, $o.Fragment), i.registerInput("cameraPosition", Jo.Vector3, !1, $o.Fragment), i.registerInput("glossiness", Jo.Float, !0, $o.Fragment), i.registerInput("glossPower", Jo.Float, !0, $o.Fragment), i.registerInput("diffuseColor", Jo.Color3, !0, $o.Fragment), i.registerInput("specularColor", Jo.Color3, !0, $o.Fragment), i.registerInput("view", Jo.Matrix, !0), i.registerOutput("diffuseOutput", Jo.Color3, $o.Fragment), i.registerOutput("specularOutput", Jo.Color3, $o.Fragment), i.registerOutput("shadow", Jo.Float, $o.Fragment), i } return W(t, e), t._OnGenerateOnlyFragmentCodeChanged = function (e, t) { var i = e; return i.worldPosition.isConnected ? (i.generateOnlyFragmentCode = !i.generateOnlyFragmentCode, console.error("The worldPosition input must not be connected to be able to switch!"), !1) : (i._setTarget(), !0) }, t.prototype._setTarget = function () { this._setInitialTarget(this.generateOnlyFragmentCode ? $o.Fragment : $o.VertexAndFragment), this.getInputByName("worldPosition").target = this.generateOnlyFragmentCode ? $o.Fragment : $o.Vertex }, t.prototype.getClassName = function () { return "LightBlock" }, Object.defineProperty(t.prototype, "worldPosition", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldNormal", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraPosition", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "glossiness", { get: function () { return this._inputs[3] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "glossPower", { get: function () { return this._inputs[4] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "diffuseColor", { get: function () { return this._inputs[5] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "specularColor", { get: function () { return this._inputs[6] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "view", { get: function () { return this._inputs[7] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "diffuseOutput", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "specularOutput", { get: function () { return this._outputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "shadow", { get: function () { return this._outputs[2] }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function (e) { if (!this.cameraPosition.isConnected) { var t = e.getInputBlockByPredicate((function (e) { return e.systemValue === pa.CameraPosition })); t || (t = new Ta("cameraPosition")).setAsSystemValue(pa.CameraPosition), t.output.connectTo(this.cameraPosition) } }, t.prototype.prepareDefines = function (e, t, i) { if (i._areLightsDirty) { var r = e.getScene(); if (this.light) { var n = { needNormals: !1, needRebuild: !1, lightmapMode: !1, shadowEnabled: !1, specularEnabled: !1 }; zn.PrepareDefinesForLight(r, e, this.light, this._lightId, i, !0, n), n.needRebuild && i.rebuild() } else zn.PrepareDefinesForLights(r, e, i, !0, t.maxSimultaneousLights) } }, t.prototype.updateUniformsAndSamples = function (e, t, i, r) { for (var n = 0; n < t.maxSimultaneousLights && i["LIGHT" + n]; n++) { var o = e.uniforms.indexOf("vLightData" + n) >= 0; zn.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 ? zn.BindLight(this.light, this._lightId, r, e, !0) : zn.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 === $o.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 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() }] }) : t.compilationString += t._emitCodeFromInclude("lightFragment", i, { repeatKey: "maxSimultaneousLights" }); 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) + " = shadow;\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([ha("Generate only fragment code", ca.Boolean, "ADVANCED", { notifiers: { rebuild: !0, update: !0, onValidation: t._OnGenerateOnlyFragmentCodeChanged } })], t.prototype, "generateOnlyFragmentCode", void 0), t }(sa); b("BABYLON.LightBlock", Vv); var kv = function (e) { function t(i) { var r = e.call(this, i, $o.VertexAndFragment) || this; return r.registerOutput("source", Jo.Object, $o.VertexAndFragment, new bv("source", r, ra.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 === $o.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 && !ss.IgnoreTexturesAtLoadTime && void 0 !== t.texture.url && (r = 0 === t.texture.url.indexOf("data:") ? "" : r, this.texture = vo.Parse(t.texture, i, r)) }, t }(sa); b("BABYLON.ImageSourceBlock", kv); var Gv = function (e) { function t(t, i) { void 0 === i && (i = !1); var r = e.call(this, t, i ? $o.Fragment : $o.VertexAndFragment) || this; return r._convertToGammaSpace = !1, r._convertToLinearSpace = !1, r.disableLevelMultiplication = !1, r._fragmentOnly = i, r.registerInput("uv", Jo.AutoDetect, !1, $o.VertexAndFragment), r.registerInput("source", Jo.Object, !0, $o.VertexAndFragment, new bv("source", r, ra.Input, kv, "ImageSourceBlock")), r.registerInput("layer", Jo.Float, !0), r.registerInput("lod", Jo.Float, !0), r.registerOutput("rgba", Jo.Color4, $o.Neutral), r.registerOutput("rgb", Jo.Color3, $o.Neutral), r.registerOutput("r", Jo.Float, $o.Neutral), r.registerOutput("g", Jo.Float, $o.Neutral), r.registerOutput("b", Jo.Float, $o.Neutral), r.registerOutput("a", Jo.Float, $o.Neutral), r.registerOutput("level", Jo.Float, $o.Neutral), r._inputs[0].addExcludedConnectionPointFromAllowedTypes(Jo.Vector2 | Jo.Vector3 | Jo.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 }), Object.defineProperty(t.prototype, "samplerName", { get: function () { return this._imageSource ? this._imageSource.samplerName : 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 $o.Fragment; if (!this.uv.isConnected) return $o.VertexAndFragment; if (this.uv.sourceBlock.isInput) return $o.VertexAndFragment; for (var e = this.uv.connectedPoint; e;) { if (e.target === $o.Fragment) return $o.Fragment; if (e.target === $o.Vertex) return $o.VertexAndFragment; if (e.target === $o.Neutral || e.target === $o.VertexAndFragment) { var t = e.ownerBlock; if (t.target === $o.Fragment) return $o.Fragment; e = null; for (var i = 0, r = t.inputs; i < r.length; i++) { var n = r[i]; if (n.connectedPoint) { e = n.connectedPoint; break } } } } return $o.VertexAndFragment }, set: function (e) { }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function (e) { if (!this.uv.isConnected) if (e.mode === Da.PostProcess) (t = e.getBlockByPredicate((function (e) { return "uv" === e.name }))) && t.connectTo(this); else { var t, i = e.mode === Da.Particle ? "particle_uv" : "uv"; (t = e.getInputBlockByPredicate((function (e) { return e.isAttribute && e.name === i }))) || (t = new Ta("uv")).setAsAttribute(i), t.output.connectTo(this.uv) } }, t.prototype.initializeDefines = function (e, t, i) { i._areTexturesDirty && void 0 !== this._mainUVDefineName && i.setValue(this._mainUVDefineName, !1, !0) }, t.prototype.prepareDefines = function (e, t, i) { if (i._areTexturesDirty) if (this.texture && this.texture.getTextureMatrix) { 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), this._isMixed && (this.texture.getTextureMatrix().isIdentityAs3x2() ? (i.setValue(this._defineName, !1, !0), i.setValue(this._mainUVDefineName, !0, !0)) : (i.setValue(this._defineName, !0), null == i[this._mainUVDefineName] && i.setValue(this._mainUVDefineName, !1, !0))) } else this._isMixed && (i.setValue(this._defineName, !1, !0), i.setValue(this._mainUVDefineName, !0, !0)) }, t.prototype.isReady = function () { return !(this.texture && !this.texture.isReadyOrNotBlocking()) }, t.prototype.bind = function (e) { this.texture && (this._isMixed && (e.setFloat(this._textureInfoName, this.texture.level), e.setMatrix(this._textureTransformName, this.texture.getTextureMatrix())), this._imageSource || e.setTexture(this._samplerName, this.texture)) }, Object.defineProperty(t.prototype, "_isMixed", { get: function () { return this.target !== $o.Fragment }, enumerable: !1, configurable: !0 }), t.prototype._injectVertexCode = function (e) { var t = this.uv; if (this._defineName = e._getFreeDefineName("UVTRANSFORM"), this._mainUVDefineName = "VMAIN" + t.associatedVariableName.toUpperCase(), this._mainUVName = "vMain" + t.associatedVariableName, this._transformedUVName = e._getFreeVariableName("transformedUV"), this._textureTransformName = e._getFreeVariableName("textureTransform"), this._textureInfoName = e._getFreeVariableName("textureInfoName"), this.level.associatedVariableName = this._textureInfoName, e._emitVaryingFromString(this._transformedUVName, "vec2", this._defineName), e._emitVaryingFromString(this._mainUVName, "vec2", this._mainUVDefineName), e._emitUniformFromString(this._textureTransformName, "mat4", this._defineName), e.compilationString += "#ifdef ".concat(this._defineName, "\n"), e.compilationString += "".concat(this._transformedUVName, " = vec2(").concat(this._textureTransformName, " * vec4(").concat(t.associatedVariableName, ".xy, 1.0, 0.0));\n"), e.compilationString += "#elif defined(".concat(this._mainUVDefineName, ")\n"), e.compilationString += "".concat(this._mainUVName, " = ").concat(t.associatedVariableName, ".xy;\n"), e.compilationString += "#endif\n", this._outputs.some((function (e) { return e.isConnectedInVertexShader }))) { this._writeTextureRead(e, !0); for (var i = 0, r = this._outputs; i < r.length; i++) { var n = r[i]; n.hasEndpoints && "level" !== n.name && this._writeOutput(e, n, n.name, !0) } } }, t.prototype._getUVW = function (e) { var t, i, r, n = e; if (null !== (r = null === (i = null === (t = this._texture) || void 0 === t ? void 0 : t._texture) || void 0 === i ? void 0 : i.is2DArray) && void 0 !== r && r) { var o = this.layer.isConnected ? this.layer.associatedVariableName : "0"; n = "vec3(".concat(e, ", ").concat(o, ")") } return n }, Object.defineProperty(t.prototype, "_samplerFunc", { get: function () { return this.lod.isConnected ? "texture2DLodEXT" : "texture2D" }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "_samplerLodSuffix", { get: function () { return this.lod.isConnected ? ", ".concat(this.lod.associatedVariableName) : "" }, enumerable: !1, configurable: !0 }), t.prototype._generateTextureLookup = function (e) { var t = this.samplerName; e.compilationString += "#ifdef ".concat(this._defineName, "\n"), e.compilationString += "vec4 ".concat(this._tempTextureRead, " = ").concat(this._samplerFunc, "(").concat(t, ", ").concat(this._getUVW(this._transformedUVName)).concat(this._samplerLodSuffix, ");\n"), e.compilationString += "#elif defined(".concat(this._mainUVDefineName, ")\n"), e.compilationString += "vec4 ".concat(this._tempTextureRead, " = ").concat(this._samplerFunc, "(").concat(t, ", ").concat(this._getUVW(this._mainUVName ? this._mainUVName : this.uv.associatedVariableName)).concat(this._samplerLodSuffix, ");\n"), e.compilationString += "#endif\n" }, t.prototype._writeTextureRead = function (e, t) { void 0 === t && (t = !1); var i = this.uv; if (t) { if (e.target === $o.Fragment) return; this._generateTextureLookup(e) } else this.uv.ownerBlock.target !== $o.Fragment ? this._generateTextureLookup(e) : e.compilationString += "vec4 ".concat(this._tempTextureRead, " = ").concat(this._samplerFunc, "(").concat(this.samplerName, ", ").concat(this._getUVW(i.associatedVariableName)).concat(this._samplerLodSuffix, ");\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, r) { if (void 0 === r && (r = !1), r) { if (e.target === $o.Fragment) return; return e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\n"), void this._generateConversionCode(e, t, i) } if (this.uv.ownerBlock.target === $o.Fragment) return e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\n"), void this._generateConversionCode(e, t, i); var n = ""; this.disableLevelMultiplication || (n = " * ".concat(this._textureInfoName)), e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i).concat(n, ";\n"), this._generateConversionCode(e, t, i) }, t.prototype._buildBlock = function (t) { var i, r, n, o; if (e.prototype._buildBlock.call(this, t), this.source.isConnected ? this._imageSource = this.source.connectedPoint.ownerBlock : this._imageSource = null, (t.target === $o.Vertex || this._fragmentOnly || t.target === $o.Fragment) && (this._tempTextureRead = t._getFreeVariableName("tempTextureRead"), this._linearDefineName = t._getFreeDefineName("ISLINEAR"), this._gammaDefineName = t._getFreeDefineName("ISGAMMA")), (!this._isMixed && t.target === $o.Fragment || this._isMixed && t.target === $o.Vertex) && (this._imageSource || (this._samplerName = t._getFreeVariableName(this.name + "Sampler"), (null === (r = null === (i = this._texture) || void 0 === i ? void 0 : i._texture) || void 0 === r ? void 0 : r.is2DArray) ? t._emit2DArraySampler(this._samplerName) : t._emit2DSampler(this._samplerName)), t.sharedData.blockingBlocks.push(this), t.sharedData.textureBlocks.push(this), t.sharedData.blocksWithDefines.push(this), t.sharedData.bindableBlocks.push(this)), t.target === $o.Fragment) { if (this._outputs.some((function (e) { return e.isConnectedInFragmentShader }))) { this._isMixed && !this._imageSource && ((null === (o = null === (n = this._texture) || void 0 === n ? void 0 : n._texture) || void 0 === o ? void 0 : o.is2DArray) ? t._emit2DArraySampler(this._samplerName) : t._emit2DSampler(this._samplerName)); var a = "//".concat(this.name); t._emitFunctionFromInclude("helperFunctions", a), this._isMixed && t._emitUniformFromString(this._textureInfoName, "float"), this._writeTextureRead(t); for (var s = 0, l = this._outputs; s < l.length; s++) { var c = l[s]; c.hasEndpoints && "level" !== c.name && this._writeOutput(t, c, c.name) } return this } } else this._injectVertexCode(t) }, t.prototype._dumpPropertiesCode = function () { var t = e.prototype._dumpPropertiesCode.call(this); return t += "".concat(this._codeVariableName, ".convertToGammaSpace = ").concat(this.convertToGammaSpace, ";\n"), t += "".concat(this._codeVariableName, ".convertToLinearSpace = ").concat(this.convertToLinearSpace, ";\n"), t += "".concat(this._codeVariableName, ".disableLevelMultiplication = ").concat(this.disableLevelMultiplication, ";\n"), 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 t.convertToGammaSpace = this.convertToGammaSpace, t.convertToLinearSpace = this.convertToLinearSpace, t.fragmentOnly = this._fragmentOnly, t.disableLevelMultiplication = this.disableLevelMultiplication, this.hasImageSource || !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), this.convertToGammaSpace = t.convertToGammaSpace, this.convertToLinearSpace = !!t.convertToLinearSpace, this._fragmentOnly = !!t.fragmentOnly, this.disableLevelMultiplication = !!t.disableLevelMultiplication, t.texture && !ss.IgnoreTexturesAtLoadTime && void 0 !== t.texture.url && (r = 0 === t.texture.url.indexOf("data:") ? "" : r, this.texture = vo.Parse(t.texture, i, r)) }, t }(sa); b("BABYLON.TextureBlock", Gv); var zv = function (e) { function t(t) { var i = e.call(this, t, $o.VertexAndFragment) || this; return i.generateOnlyFragmentCode = !1, i } 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 }), t._OnGenerateOnlyFragmentCodeChanged = function (e, t) { return e._onGenerateOnlyFragmentCodeChanged() }, t.prototype._onGenerateOnlyFragmentCodeChanged = function () { return this._setTarget(), !0 }, t.prototype._setTarget = function () { this._setInitialTarget(this.generateOnlyFragmentCode ? $o.Fragment : $o.VertexAndFragment) }, t.prototype.getClassName = function () { return "ReflectionTextureBaseBlock" }, t.prototype._getTexture = function () { return this.texture }, t.prototype.autoConfigure = function (e) { if (!this.position.isConnected) { var t = e.getInputBlockByPredicate((function (e) { return e.isAttribute && "position" === e.name })); t || (t = new Ta("position")).setAsAttribute(), t.output.connectTo(this.position) } if (!this.world.isConnected) { var i = e.getInputBlockByPredicate((function (e) { return e.systemValue === pa.World })); i || (i = new Ta("world")).setAsSystemValue(pa.World), i.output.connectTo(this.world) } if (this.view && !this.view.isConnected) { var r = e.getInputBlockByPredicate((function (e) { return e.systemValue === pa.View })); r || (r = new Ta("view")).setAsSystemValue(pa.View), r.output.connectTo(this.view) } }, t.prototype.prepareDefines = function (e, t, i) { if (i._areTexturesDirty) { var r = this._getTexture(); r && r.getTextureMatrix && (i.setValue(this._define3DName, r.isCube, !0), i.setValue(this._defineLocalCubicName, !!r.boundingBoxSize, !0), i.setValue(this._defineExplicitName, r.coordinatesMode === a.TEXTURE_EXPLICIT_MODE, !0), i.setValue(this._defineSkyboxName, r.coordinatesMode === a.TEXTURE_SKYBOX_MODE, !0), i.setValue(this._defineCubicName, r.coordinatesMode === a.TEXTURE_CUBIC_MODE || r.coordinatesMode === a.TEXTURE_INVCUBIC_MODE, !0), i.setValue("INVERTCUBICMAP", r.coordinatesMode === a.TEXTURE_INVCUBIC_MODE, !0), i.setValue(this._defineSphericalName, r.coordinatesMode === a.TEXTURE_SPHERICAL_MODE, !0), i.setValue(this._definePlanarName, r.coordinatesMode === a.TEXTURE_PLANAR_MODE, !0), i.setValue(this._defineProjectionName, r.coordinatesMode === a.TEXTURE_PROJECTION_MODE, !0), i.setValue(this._defineEquirectangularName, r.coordinatesMode === a.TEXTURE_EQUIRECTANGULAR_MODE, !0), i.setValue(this._defineEquirectangularFixedName, r.coordinatesMode === a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE, !0), i.setValue(this._defineMirroredEquirectangularFixedName, r.coordinatesMode === a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE, !0)) } }, t.prototype.isReady = function () { var e = this._getTexture(); return !(e && !e.isReadyOrNotBlocking()) }, t.prototype.bind = function (e, t, i) { var r = this._getTexture(); if (i && r && (e.setMatrix(this._reflectionMatrixName, r.getReflectionTextureMatrix()), r.isCube ? e.setTexture(this._cubeSamplerName, r) : e.setTexture(this._2DSamplerName, r), r.boundingBoxSize)) { var n = r; e.setVector3(this._reflectionPositionName, n.boundingBoxPosition), e.setVector3(this._reflectionSizeName, n.boundingBoxSize) } }, t.prototype.handleVertexSide = function (e) { if (this.generateOnlyFragmentCode && e.target === $o.Vertex) return ""; this._define3DName = e._getFreeDefineName("REFLECTIONMAP_3D"), this._defineCubicName = e._getFreeDefineName("REFLECTIONMAP_CUBIC"), this._defineSphericalName = e._getFreeDefineName("REFLECTIONMAP_SPHERICAL"), this._definePlanarName = e._getFreeDefineName("REFLECTIONMAP_PLANAR"), this._defineProjectionName = e._getFreeDefineName("REFLECTIONMAP_PROJECTION"), this._defineExplicitName = e._getFreeDefineName("REFLECTIONMAP_EXPLICIT"), this._defineEquirectangularName = e._getFreeDefineName("REFLECTIONMAP_EQUIRECTANGULAR"), this._defineLocalCubicName = e._getFreeDefineName("USE_LOCAL_REFLECTIONMAP_CUBIC"), this._defineMirroredEquirectangularFixedName = e._getFreeDefineName("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"), this._defineEquirectangularFixedName = e._getFreeDefineName("REFLECTIONMAP_EQUIRECTANGULAR_FIXED"), this._defineSkyboxName = e._getFreeDefineName("REFLECTIONMAP_SKYBOX"), this._defineOppositeZ = e._getFreeDefineName("REFLECTIONMAP_OPPOSITEZ"), this._reflectionMatrixName = e._getFreeVariableName("reflectionMatrix"), e._emitUniformFromString(this._reflectionMatrixName, "mat4"); var t = ""; this._worldPositionNameInFragmentOnlyMode = e._getFreeVariableName("worldPosition"); var i = this.generateOnlyFragmentCode ? this._worldPositionNameInFragmentOnlyMode : "v_" + this.worldPosition.associatedVariableName; return (this.generateOnlyFragmentCode || e._emitVaryingFromString(i, "vec4")) && (t += "".concat(this.generateOnlyFragmentCode ? "vec4 " : "").concat(i, " = ").concat(this.worldPosition.associatedVariableName, ";\n")), this._positionUVWName = e._getFreeVariableName("positionUVW"), this._directionWName = e._getFreeVariableName("directionW"), (this.generateOnlyFragmentCode || e._emitVaryingFromString(this._positionUVWName, "vec3", this._defineSkyboxName)) && (t += "#ifdef ".concat(this._defineSkyboxName, "\n"), t += "".concat(this.generateOnlyFragmentCode ? "vec3 " : "").concat(this._positionUVWName, " = ").concat(this.position.associatedVariableName, ".xyz;\n"), t += "#endif\n"), (this.generateOnlyFragmentCode || e._emitVaryingFromString(this._directionWName, "vec3", "defined(".concat(this._defineEquirectangularFixedName, ") || defined(").concat(this._defineMirroredEquirectangularFixedName, ")"))) && (t += "#if defined(".concat(this._defineEquirectangularFixedName, ") || defined(").concat(this._defineMirroredEquirectangularFixedName, ")\n"), t += "".concat(this.generateOnlyFragmentCode ? "vec3 " : "").concat(this._directionWName, " = normalize(vec3(").concat(this.world.associatedVariableName, " * vec4(").concat(this.position.associatedVariableName, ".xyz, 0.0)));\n"), t += "#endif\n"), t }, t.prototype.handleFragmentSideInits = function (e) { e.sharedData.blockingBlocks.push(this), e.sharedData.textureBlocks.push(this), this._cubeSamplerName = e._getFreeVariableName(this.name + "CubeSampler"), e.samplers.push(this._cubeSamplerName), this._2DSamplerName = e._getFreeVariableName(this.name + "2DSampler"), e.samplers.push(this._2DSamplerName), e._samplerDeclaration += "#ifdef ".concat(this._define3DName, "\n"), e._samplerDeclaration += "uniform samplerCube ".concat(this._cubeSamplerName, ";\n"), e._samplerDeclaration += "#else\n", e._samplerDeclaration += "uniform sampler2D ".concat(this._2DSamplerName, ";\n"), e._samplerDeclaration += "#endif\n", e.sharedData.blocksWithDefines.push(this), e.sharedData.bindableBlocks.push(this); var t = "//".concat(this.name); e._emitFunction("ReciprocalPI", "#define RECIPROCAL_PI2 0.15915494", ""), e._emitFunctionFromInclude("helperFunctions", t), e._emitFunctionFromInclude("reflectionFunction", t, { replaceStrings: [{ search: /vec3 computeReflectionCoords/g, replace: "void DUMMYFUNC" }] }), this._reflectionColorName = e._getFreeVariableName("reflectionColor"), this._reflectionVectorName = e._getFreeVariableName("reflectionUVW"), this._reflectionCoordsName = e._getFreeVariableName("reflectionCoords"), this._reflectionPositionName = e._getFreeVariableName("vReflectionPosition"), e._emitUniformFromString(this._reflectionPositionName, "vec3"), this._reflectionSizeName = e._getFreeVariableName("vReflectionPosition"), e._emitUniformFromString(this._reflectionSizeName, "vec3") }, t.prototype.handleFragmentSideCodeReflectionCoords = function (e, t, i, r) { void 0 === i && (i = !1), void 0 === r && (r = !1), t || (t = this.generateOnlyFragmentCode ? this._worldPositionNameInFragmentOnlyMode : "v_".concat(this.worldPosition.associatedVariableName)); var n = this._reflectionMatrixName, o = "normalize(".concat(this._directionWName, ")"), a = "".concat(this._positionUVWName), s = "".concat(this.cameraPosition.associatedVariableName), l = "".concat(this.view.associatedVariableName); e += ".xyz"; var c = "\n #ifdef ".concat(this._defineMirroredEquirectangularFixedName, "\n vec3 ").concat(this._reflectionVectorName, " = computeMirroredFixedEquirectangularCoords(").concat(t, ", ").concat(e, ", ").concat(o, ");\n #endif\n\n #ifdef ").concat(this._defineEquirectangularFixedName, "\n vec3 ").concat(this._reflectionVectorName, " = computeFixedEquirectangularCoords(").concat(t, ", ").concat(e, ", ").concat(o, ");\n #endif\n\n #ifdef ").concat(this._defineEquirectangularName, "\n vec3 ").concat(this._reflectionVectorName, " = computeEquirectangularCoords(").concat(t, ", ").concat(e, ", ").concat(s, ".xyz, ").concat(n, ");\n #endif\n\n #ifdef ").concat(this._defineSphericalName, "\n vec3 ").concat(this._reflectionVectorName, " = computeSphericalCoords(").concat(t, ", ").concat(e, ", ").concat(l, ", ").concat(n, ");\n #endif\n\n #ifdef ").concat(this._definePlanarName, "\n vec3 ").concat(this._reflectionVectorName, " = computePlanarCoords(").concat(t, ", ").concat(e, ", ").concat(s, ".xyz, ").concat(n, ");\n #endif\n\n #ifdef ").concat(this._defineCubicName, "\n #ifdef ").concat(this._defineLocalCubicName, "\n vec3 ").concat(this._reflectionVectorName, " = computeCubicLocalCoords(").concat(t, ", ").concat(e, ", ").concat(s, ".xyz, ").concat(n, ", ").concat(this._reflectionSizeName, ", ").concat(this._reflectionPositionName, ");\n #else\n vec3 ").concat(this._reflectionVectorName, " = computeCubicCoords(").concat(t, ", ").concat(e, ", ").concat(s, ".xyz, ").concat(n, ");\n #endif\n #endif\n\n #ifdef ").concat(this._defineProjectionName, "\n vec3 ").concat(this._reflectionVectorName, " = computeProjectionCoords(").concat(t, ", ").concat(l, ", ").concat(n, ");\n #endif\n\n #ifdef ").concat(this._defineSkyboxName, "\n vec3 ").concat(this._reflectionVectorName, " = computeSkyBoxCoords(").concat(a, ", ").concat(n, ");\n #endif\n\n #ifdef ").concat(this._defineExplicitName, "\n vec3 ").concat(this._reflectionVectorName, " = vec3(0, 0, 0);\n #endif\n"); return r || (c += "#ifdef ".concat(this._defineOppositeZ, "\n ").concat(this._reflectionVectorName, ".z *= -1.0;\n #endif\n")), i || (c += "\n #ifdef ".concat(this._define3DName, "\n vec3 ").concat(this._reflectionCoordsName, " = ").concat(this._reflectionVectorName, ";\n #else\n vec2 ").concat(this._reflectionCoordsName, " = ").concat(this._reflectionVectorName, ".xy;\n #ifdef ").concat(this._defineProjectionName, "\n ").concat(this._reflectionCoordsName, " /= ").concat(this._reflectionVectorName, ".z;\n #endif\n ").concat(this._reflectionCoordsName, ".y = 1.0 - ").concat(this._reflectionCoordsName, ".y;\n #endif\n")), c }, t.prototype.handleFragmentSideCodeReflectionColor = function (e, t) { void 0 === t && (t = ".rgb"); var i = "vec" + (0 === t.length ? "4" : t.length - 1), r = "".concat(i, " ").concat(this._reflectionColorName, ";\n #ifdef ").concat(this._define3DName, "\n"); return r += e ? "".concat(this._reflectionColorName, " = textureCubeLodEXT(").concat(this._cubeSamplerName, ", ").concat(this._reflectionVectorName, ", ").concat(e, ")").concat(t, ";\n") : "".concat(this._reflectionColorName, " = textureCube(").concat(this._cubeSamplerName, ", ").concat(this._reflectionVectorName, ")").concat(t, ";\n"), r += "\n #else\n", (r += e ? "".concat(this._reflectionColorName, " = texture2DLodEXT(").concat(this._2DSamplerName, ", ").concat(this._reflectionCoordsName, ", ").concat(e, ")").concat(t, ";\n") : "".concat(this._reflectionColorName, " = texture2D(").concat(this._2DSamplerName, ", ").concat(this._reflectionCoordsName, ")").concat(t, ";\n")) + "#endif\n" }, t.prototype.writeOutputs = function (e, t) { var i = ""; if (e.target === $o.Fragment) for (var r = 0, n = this._outputs; r < n.length; r++) { var o = n[r]; o.hasEndpoints && (i += "".concat(this._declareOutput(o, e), " = ").concat(t, ".").concat(o.name, ";\n")) } return i }, t.prototype._buildBlock = function (t) { return e.prototype._buildBlock.call(this, t), this }, t.prototype._dumpPropertiesCode = function () { var t = e.prototype._dumpPropertiesCode.call(this); if (!this.texture) return t; if (this.texture.isCube) { var i = this.texture.forcedExtension; t += "".concat(this._codeVariableName, '.texture = new BABYLON.CubeTexture("').concat(this.texture.name, '", undefined, undefined, ').concat(this.texture.noMipmap, ", null, undefined, undefined, undefined, ").concat(this.texture._prefiltered, ", ").concat(i ? '"' + i + '"' : "null", ");\n") } else t += "".concat(this._codeVariableName, '.texture = new BABYLON.Texture("').concat(this.texture.name, '", null);\n'); return t + "".concat(this._codeVariableName, ".texture.coordinatesMode = ").concat(this.texture.coordinatesMode, ";\n") }, t.prototype.serialize = function () { var t = e.prototype.serialize.call(this); return this.texture && !this.texture.isRenderTarget && (t.texture = this.texture.serialize()), t.generateOnlyFragmentCode = this.generateOnlyFragmentCode, t }, t.prototype._deserialize = function (t, i, r) { e.prototype._deserialize.call(this, t, i, r), t.texture && !ss.IgnoreTexturesAtLoadTime && (r = 0 === t.texture.url.indexOf("data:") ? "" : r, t.texture.isCube ? this.texture = h_.Parse(t.texture, i, r) : this.texture = vo.Parse(t.texture, i, r)), this.generateOnlyFragmentCode = t.generateOnlyFragmentCode, this._setTarget() }, X([ha("Generate only fragment code", ca.Boolean, "ADVANCED", { notifiers: { rebuild: !0, update: !0, onValidation: t._OnGenerateOnlyFragmentCodeChanged } })], t.prototype, "generateOnlyFragmentCode", void 0), t }(sa); b("BABYLON.ReflectionTextureBaseBlock", zv); var Wv = function (e) { function t(t) { var i = e.call(this, t) || this; return i.registerInput("position", Jo.AutoDetect, !1, $o.Vertex), i.registerInput("worldPosition", Jo.Vector4, !1, $o.Vertex), i.registerInput("worldNormal", Jo.Vector4, !1, $o.Fragment), i.registerInput("world", Jo.Matrix, !1, $o.Vertex), i.registerInput("cameraPosition", Jo.Vector3, !1, $o.Fragment), i.registerInput("view", Jo.Matrix, !1, $o.Fragment), i.registerOutput("rgb", Jo.Color3, $o.Fragment), i.registerOutput("rgba", Jo.Color4, $o.Fragment), i.registerOutput("r", Jo.Float, $o.Fragment), i.registerOutput("g", Jo.Float, $o.Fragment), i.registerOutput("b", Jo.Float, $o.Fragment), i.registerOutput("a", Jo.Float, $o.Fragment), i._inputs[0].addExcludedConnectionPointFromAllowedTypes(Jo.Color3 | Jo.Vector3 | Jo.Vector4), i } return W(t, e), t.prototype._onGenerateOnlyFragmentCodeChanged = function () { return this.position.isConnected ? (this.generateOnlyFragmentCode = !this.generateOnlyFragmentCode, console.error("The position input must not be connected to be able to switch!"), !1) : this.worldPosition.isConnected ? (this.generateOnlyFragmentCode = !this.generateOnlyFragmentCode, console.error("The worldPosition input must not be connected to be able to switch!"), !1) : (this._setTarget(), !0) }, t.prototype._setTarget = function () { e.prototype._setTarget.call(this), this.getInputByName("position").target = this.generateOnlyFragmentCode ? $o.Fragment : $o.Vertex, this.getInputByName("worldPosition").target = this.generateOnlyFragmentCode ? $o.Fragment : $o.Vertex }, t.prototype.getClassName = function () { return "ReflectionTextureBlock" }, Object.defineProperty(t.prototype, "position", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldPosition", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldNormal", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "world", { get: function () { return this._inputs[3] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraPosition", { get: function () { return this._inputs[4] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "view", { get: function () { return this._inputs[5] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgb", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgba", { 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 }), t.prototype.autoConfigure = function (t) { if (e.prototype.autoConfigure.call(this, t), !this.cameraPosition.isConnected) { var i = t.getInputBlockByPredicate((function (e) { return e.systemValue === pa.CameraPosition })); i || (i = new Ta("cameraPosition")).setAsSystemValue(pa.CameraPosition), i.output.connectTo(this.cameraPosition) } }, t.prototype._buildBlock = function (t) { if (e.prototype._buildBlock.call(this, t), !this.texture) return t.compilationString += this.writeOutputs(t, "vec4(0.)"), this; if (t.target !== $o.Fragment) return t.compilationString += this.handleVertexSide(t), this; this.generateOnlyFragmentCode && (t.compilationString += this.handleVertexSide(t)), this.handleFragmentSideInits(t); var i = t._getFreeVariableName("normalWUnit"); return t.compilationString += "vec4 ".concat(i, " = normalize(").concat(this.worldNormal.associatedVariableName, ");\n"), t.compilationString += this.handleFragmentSideCodeReflectionCoords(i), t.compilationString += this.handleFragmentSideCodeReflectionColor(void 0, ""), t.compilationString += this.writeOutputs(t, this._reflectionColorName), this }, t }(zv); b("BABYLON.ReflectionTextureBlock", Wv); var Hv = function (e) { function t(t) { var i = e.call(this, t, $o.VertexAndFragment) || this; return i.useNonLinearDepth = !1, i.storeCameraSpaceZ = !1, i.force32itsFloat = !1, i._isUnique = !0, i.registerInput("uv", Jo.AutoDetect, !1, $o.VertexAndFragment), i.registerOutput("depth", Jo.Float, $o.Neutral), i._inputs[0].addExcludedConnectionPointFromAllowedTypes(Jo.Vector2 | Jo.Vector3 | Jo.Vector4), i._inputs[0]._prioritizeVertex = !1, i } return W(t, e), t.prototype.getClassName = function () { return "SceneDepthBlock" }, Object.defineProperty(t.prototype, "uv", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "depth", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype.initialize = function (e) { e._excludeVariableName("textureSampler") }, Object.defineProperty(t.prototype, "target", { get: function () { return this.uv.isConnected ? this.uv.sourceBlock.isInput ? $o.VertexAndFragment : $o.Fragment : $o.VertexAndFragment }, enumerable: !1, configurable: !0 }), t.prototype._getTexture = function (e) { return e.enableDepthRenderer(void 0, this.useNonLinearDepth, this.force32itsFloat, void 0, this.storeCameraSpaceZ).getDepthMap() }, t.prototype.bind = function (e, t) { var i = this._getTexture(t.getScene()); e.setTexture(this._samplerName, i) }, t.prototype._injectVertexCode = function (e) { var t = this.uv; if (t.connectedPoint.ownerBlock.isInput && (t.connectedPoint.ownerBlock.isAttribute || e._emitUniformFromString(t.associatedVariableName, "vec" + (t.type === Jo.Vector3 ? "3" : t.type === Jo.Vector4 ? "4" : "2"))), this._mainUVName = "vMain" + t.associatedVariableName, e._emitVaryingFromString(this._mainUVName, "vec2"), e.compilationString += "".concat(this._mainUVName, " = ").concat(t.associatedVariableName, ".xy;\n"), this._outputs.some((function (e) { return e.isConnectedInVertexShader }))) { this._writeTextureRead(e, !0); for (var i = 0, r = this._outputs; i < r.length; i++) { var n = r[i]; n.hasEndpoints && this._writeOutput(e, n, "r", !0) } } }, t.prototype._writeTextureRead = function (e, t) { void 0 === t && (t = !1); var i = this.uv; if (t) { if (e.target === $o.Fragment) return; e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(i.associatedVariableName, ".xy);\n") } else this.uv.ownerBlock.target !== $o.Fragment ? e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(this._mainUVName, ");\n") : e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(i.associatedVariableName, ".xy);\n") }, t.prototype._writeOutput = function (e, t, i, r) { if (void 0 === r && (r = !1), r) { if (e.target === $o.Fragment) return; e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\n") } else this.uv.ownerBlock.target, $o.Fragment, e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\n") }, t.prototype._buildBlock = function (t) { if (e.prototype._buildBlock.call(this, t), this._samplerName = t._getFreeVariableName(this.name + "Sampler"), this._tempTextureRead = t._getFreeVariableName("tempTextureRead"), t.sharedData.bindableBlocks.indexOf(this) < 0 && t.sharedData.bindableBlocks.push(this), t.target !== $o.Fragment) return t._emit2DSampler(this._samplerName), void this._injectVertexCode(t); if (this._outputs.some((function (e) { return e.isConnectedInFragmentShader }))) { t._emit2DSampler(this._samplerName), this._writeTextureRead(t); for (var i = 0, r = this._outputs; i < r.length; i++) { var n = r[i]; n.hasEndpoints && this._writeOutput(t, n, "r") } return this } }, t.prototype.serialize = function () { var t = e.prototype.serialize.call(this); return t.useNonLinearDepth = this.useNonLinearDepth, t.storeCameraSpaceZ = this.storeCameraSpaceZ, t.force32itsFloat = this.force32itsFloat, t }, t.prototype._deserialize = function (t, i, r) { e.prototype._deserialize.call(this, t, i, r), this.useNonLinearDepth = t.useNonLinearDepth, this.storeCameraSpaceZ = !!t.storeCameraSpaceZ, this.force32itsFloat = t.force32itsFloat }, X([ha("Use non linear depth", ca.Boolean, "ADVANCED", { notifiers: { activatePreviewCommand: !0, callback: function (e, t) { var i = t, r = !1; return i.useNonLinearDepth && (i.storeCameraSpaceZ = !1, r = !0), e && e.disableDepthRenderer(), r } } })], t.prototype, "useNonLinearDepth", void 0), X([ha("Store Camera space Z", ca.Boolean, "ADVANCED", { notifiers: { activatePreviewCommand: !0, callback: function (e, t) { var i = t, r = !1; return i.storeCameraSpaceZ && (i.useNonLinearDepth = !1, r = !0), e && e.disableDepthRenderer(), r } } })], t.prototype, "storeCameraSpaceZ", void 0), X([ha("Force 32 bits float", ca.Boolean, "ADVANCED", { notifiers: { activatePreviewCommand: !0, callback: function (e) { return null == e ? void 0 : e.disableDepthRenderer() } } })], t.prototype, "force32itsFloat", void 0), t }(sa); b("BABYLON.SceneDepthBlock", Hv); var Xv = function (e) { function t(t) { var i = e.call(this, t, $o.VertexAndFragment, !0) || this; return i.registerInput("worldPosition", Jo.Vector4, !1), i } return W(t, e), t.prototype.getClassName = function () { return "ClipPlanesBlock" }, t.prototype.initialize = function (e) { e._excludeVariableName("vClipPlane"), e._excludeVariableName("fClipDistance"), e._excludeVariableName("vClipPlane2"), e._excludeVariableName("fClipDistance2"), e._excludeVariableName("vClipPlane3"), e._excludeVariableName("fClipDistance3"), e._excludeVariableName("vClipPlane4"), e._excludeVariableName("fClipDistance4"), e._excludeVariableName("vClipPlane5"), e._excludeVariableName("fClipDistance5"), e._excludeVariableName("vClipPlane6"), e._excludeVariableName("fClipDistance6") }, Object.defineProperty(t.prototype, "worldPosition", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "target", { get: function () { return $o.VertexAndFragment }, set: function (e) { }, enumerable: !1, configurable: !0 }), t.prototype.prepareDefines = function (e, t, i) { var r, n, o, a, s, l, c = e.getScene(), u = !!(null !== (r = t.clipPlane) && void 0 !== r ? r : c.clipPlane), h = !!(null !== (n = t.clipPlane2) && void 0 !== n ? n : c.clipPlane2), d = !!(null !== (o = t.clipPlane3) && void 0 !== o ? o : c.clipPlane3), p = !!(null !== (a = t.clipPlane4) && void 0 !== a ? a : c.clipPlane4), f = !!(null !== (s = t.clipPlane5) && void 0 !== s ? s : c.clipPlane5), _ = !!(null !== (l = t.clipPlane6) && void 0 !== l ? l : c.clipPlane6); i.setValue("CLIPPLANE", u, !0), i.setValue("CLIPPLANE2", h, !0), i.setValue("CLIPPLANE3", d, !0), i.setValue("CLIPPLANE4", p, !0), i.setValue("CLIPPLANE5", f, !0), i.setValue("CLIPPLANE6", _, !0) }, t.prototype.bind = function (e, t, i) { i && Vn(e, t, i.getScene()) }, t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t); var i = "//".concat(this.name); if (t.target !== $o.Fragment) { var r = this.worldPosition; return t._emitFunctionFromInclude("clipPlaneVertexDeclaration", i, { replaceStrings: [{ search: /uniform vec4 vClipPlane\d*;/g, replace: "" }] }), t.compilationString += t._emitCodeFromInclude("clipPlaneVertex", i, { replaceStrings: [{ search: /worldPos/g, replace: r.associatedVariableName }] }), t._emitUniformFromString("vClipPlane", "vec4"), t._emitUniformFromString("vClipPlane2", "vec4"), t._emitUniformFromString("vClipPlane3", "vec4"), t._emitUniformFromString("vClipPlane4", "vec4"), t._emitUniformFromString("vClipPlane5", "vec4"), void t._emitUniformFromString("vClipPlane6", "vec4") } return t.sharedData.bindableBlocks.push(this), t.sharedData.blocksWithDefines.push(this), t._emitFunctionFromInclude("clipPlaneFragmentDeclaration", i), t.compilationString += t._emitCodeFromInclude("clipPlaneFragment", i), this }, t }(sa); b("BABYLON.ClipPlanesBlock", Xv); var jv = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i._endpoints = [], i.registerInput("input", Jo.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 "NodeMaterialTeleportInBlock" }, Object.defineProperty(t.prototype, "input", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), t.prototype.isConnectedInFragmentShader = function () { return this.endpoints.some((function (e) { return e.output.isConnectedInFragmentShader })) }, t.prototype._dumpCode = function (t, i) { for (var r = e.prototype._dumpCode.call(this, t, i), n = 0, o = this.endpoints; n < o.length; n++) { var a = o[n]; -1 === i.indexOf(a) && (r += a._dumpCode(t, i)) } return r }, t.prototype.attachToEndpoint = function (e) { e.detach(), this._endpoints.push(e), e._entryPoint = this, e._outputs[0]._typeConnectionSource = this._inputs[0], e._tempEntryPointUniqueId = null }, 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; t < i.length; t++) { var r = i[t]; this.detachFromEndpoint(r) } this._endpoints = [] }, t }(sa); b("BABYLON.NodeMaterialTeleportInBlock", jv); var Yv = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i._entryPoint = null, i._tempEntryPointUniqueId = null, i.registerOutput("output", Jo.BasedOnInput), i } return W(t, e), Object.defineProperty(t.prototype, "entryPoint", { get: function () { return this._entryPoint }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function () { return "NodeMaterialTeleportOutBlock" }, Object.defineProperty(t.prototype, "output", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "target", { get: function () { return this._entryPoint ? this._entryPoint.target : this._target }, set: function (e) { 0 == (this._target & e) && (this._target = e) }, enumerable: !1, configurable: !0 }), t.prototype.detach = function () { this._entryPoint && this._entryPoint.detachFromEndpoint(this) }, t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t), this.entryPoint && (t.compilationString += this._declareOutput(this.output, t) + " = ".concat(this.entryPoint.input.associatedVariableName, ";\n")) }, t.prototype.clone = function (t, i) { void 0 === i && (i = ""); var r = e.prototype.clone.call(this, t, i); return this.entryPoint && this.entryPoint.attachToEndpoint(r), r }, t.prototype._customBuildStep = function (e, t) { this.entryPoint && this.entryPoint.build(e, t) }, t.prototype._dumpCode = function (t, i) { var r = ""; return this.entryPoint && -1 === i.indexOf(this.entryPoint) && (r += this.entryPoint._dumpCode(t, i)), r + e.prototype._dumpCode.call(this, t, i) }, t.prototype._dumpCodeForOutputConnections = function (t) { var i = e.prototype._dumpCodeForOutputConnections.call(this, t); return this.entryPoint && (i += this.entryPoint._dumpCodeForOutputConnections(t)), i }, t.prototype._dumpPropertiesCode = function () { var t = e.prototype._dumpPropertiesCode.call(this); return this.entryPoint && (t += "".concat(this.entryPoint._codeVariableName, ".attachToEndpoint(").concat(this._codeVariableName, ");\n")), t }, t.prototype.serialize = function () { var t, i, r = e.prototype.serialize.call(this); return r.entryPoint = null !== (i = null === (t = this.entryPoint) || void 0 === t ? void 0 : t.uniqueId) && void 0 !== i ? i : "", r }, t.prototype._deserialize = function (t, i, r) { e.prototype._deserialize.call(this, t, i, r), this._tempEntryPointUniqueId = t.entryPoint }, t }(sa); b("BABYLON.NodeMaterialTeleportOutBlock", Yv); var Kv = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("left", Jo.AutoDetect), i.registerInput("right", Jo.AutoDetect), i.registerOutput("output", Jo.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i._inputs[0].acceptedConnectionPointTypes.push(Jo.Float), i._inputs[1].acceptedConnectionPointTypes.push(Jo.Float), i } return W(t, e), t.prototype.getClassName = function () { return "AddBlock" }, 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 }(sa); b("BABYLON.AddBlock", Kv); var Qv = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("input", Jo.AutoDetect), i.registerInput("factor", Jo.Float), i.registerOutput("output", Jo.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i } return W(t, e), t.prototype.getClassName = function () { return "ScaleBlock" }, Object.defineProperty(t.prototype, "input", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "factor", { 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.input.associatedVariableName, " * ").concat(this.factor.associatedVariableName, ";\n"), this }, t }(sa); b("BABYLON.ScaleBlock", Qv); var qv = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.minimum = 0, i.maximum = 1, i.registerInput("value", Jo.AutoDetect), i.registerOutput("output", Jo.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i } return W(t, e), t.prototype.getClassName = function () { return "ClampBlock" }, Object.defineProperty(t.prototype, "value", { 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]; return t.compilationString += this._declareOutput(i, t) + " = clamp(".concat(this.value.associatedVariableName, ", ").concat(this._writeFloat(this.minimum), ", ").concat(this._writeFloat(this.maximum), ");\n"), this }, t.prototype._dumpPropertiesCode = function () { return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".minimum = ").concat(this.minimum, ";\n") + "".concat(this._codeVariableName, ".maximum = ").concat(this.maximum, ";\n") }, t.prototype.serialize = function () { var t = e.prototype.serialize.call(this); return t.minimum = this.minimum, t.maximum = this.maximum, t }, t.prototype._deserialize = function (t, i, r) { e.prototype._deserialize.call(this, t, i, r), this.minimum = t.minimum, this.maximum = t.maximum }, X([ha("Minimum", ca.Float)], t.prototype, "minimum", void 0), X([ha("Maximum", ca.Float)], t.prototype, "maximum", void 0), t }(sa); b("BABYLON.ClampBlock", qv); var Zv = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("left", Jo.AutoDetect), i.registerInput("right", Jo.AutoDetect), i.registerOutput("output", Jo.Vector3), i._linkConnectionTypes(0, 1), i._inputs[0].excludedConnectionPointTypes.push(Jo.Float), i._inputs[0].excludedConnectionPointTypes.push(Jo.Matrix), i._inputs[0].excludedConnectionPointTypes.push(Jo.Vector2), i._inputs[1].excludedConnectionPointTypes.push(Jo.Float), i._inputs[1].excludedConnectionPointTypes.push(Jo.Matrix), i._inputs[1].excludedConnectionPointTypes.push(Jo.Vector2), i } return W(t, e), t.prototype.getClassName = function () { return "CrossBlock" }, 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) + " = cross(".concat(this.left.associatedVariableName, ".xyz, ").concat(this.right.associatedVariableName, ".xyz);\n"), this }, t }(sa); b("BABYLON.CrossBlock", Zv); var Jv = function (e) { function t(t) { return e.call(this, t) || this } return W(t, e), Object.defineProperty(t.prototype, "options", { get: function () { return this._options }, set: function (e) { this._deserializeOptions(e) }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function () { return "CustomBlock" }, t.prototype._buildBlock = function (t) { var i = this; e.prototype._buildBlock.call(this, t); var r = this._code, n = this._options.functionName; this._inputs.forEach((function (e) { var i = new RegExp("\\{TYPE_" + e.name + "\\}", "gm"), o = t._getGLType(e.type); r = r.replace(i, o), n = n.replace(i, o) })), this._outputs.forEach((function (e) { var i = new RegExp("\\{TYPE_" + e.name + "\\}", "gm"), o = t._getGLType(e.type); r = r.replace(i, o), n = n.replace(i, o) })), t._emitFunction(n, r, ""), this._outputs.forEach((function (e) { t.compilationString += i._declareOutput(e, t) + ";\n" })), t.compilationString += n + "("; var o = !1; return this._inputs.forEach((function (e, r) { var n, a, s; r > 0 && (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 = $o[e.target], null === (t = e.inParameters) || void 0 === t || t.forEach((function (e, t) { var i = Jo[e.type]; "sampler2D" === e.type || "samplerCube" === e.type ? (n._inputSamplers = n._inputSamplers || [], n._inputSamplers.push(e.name), n.registerInput(e.name, Jo.Object, !0, $o.VertexAndFragment, new bv(e.name, n, ra.Input, kv, "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, Jo[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 < this._inputs.length; t++)if (this._inputs[t].name === e) return [this._inputs[t], t]; return null }, t }(sa); b("BABYLON.CustomBlock", Jv); var $v = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("left", Jo.AutoDetect), i.registerInput("right", Jo.AutoDetect), i.registerOutput("output", Jo.Float), i._linkConnectionTypes(0, 1), i._inputs[0].excludedConnectionPointTypes.push(Jo.Float), i._inputs[0].excludedConnectionPointTypes.push(Jo.Matrix), i._inputs[1].excludedConnectionPointTypes.push(Jo.Float), i._inputs[1].excludedConnectionPointTypes.push(Jo.Matrix), i } return W(t, e), t.prototype.getClassName = function () { return "DotBlock" }, 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) + " = dot(".concat(this.left.associatedVariableName, ", ").concat(this.right.associatedVariableName, ");\n"), this }, t }(sa); b("BABYLON.DotBlock", $v); var ey = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("input", Jo.AutoDetect), i.registerOutput("output", Jo.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._inputs[0].excludedConnectionPointTypes.push(Jo.Float), i._inputs[0].excludedConnectionPointTypes.push(Jo.Matrix), i } return W(t, e), t.prototype.getClassName = function () { return "NormalizeBlock" }, 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]; return t.compilationString += this._declareOutput(i, t) + " = normalize(".concat(r.associatedVariableName, ");\n"), this }, t }(sa); b("BABYLON.NormalizeBlock", ey); var ty = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.rSwizzle = "r", i.gSwizzle = "g", i.bSwizzle = "b", i.aSwizzle = "a", i.registerInput("rgb ", Jo.Color3, !0), i.registerInput("r", Jo.Float, !0), i.registerInput("g", Jo.Float, !0), i.registerInput("b", Jo.Float, !0), i.registerInput("a", Jo.Float, !0), i.registerOutput("rgba", Jo.Color4), i.registerOutput("rgb", Jo.Color3), i } return W(t, e), t.prototype.getClassName = function () { return "ColorMergerBlock" }, Object.defineProperty(t.prototype, "rgbIn", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "r", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "g", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "b", { get: function () { return this._inputs[3] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "a", { get: function () { return this._inputs[4] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgba", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgbOut", { get: function () { return this._outputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgb", { get: function () { return this.rgbOut }, enumerable: !1, configurable: !0 }), t.prototype._inputRename = function (e) { return "rgb " === e ? "rgbIn" : e }, t.prototype._buildSwizzle = function (e) { return "." + (this.rSwizzle + this.gSwizzle + this.bSwizzle + this.aSwizzle).substr(0, e) }, t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t); var i = this.r, r = this.g, n = this.b, o = this.a, a = this.rgbIn, s = this._outputs[0], l = this._outputs[1]; return a.isConnected ? (s.hasEndpoints && (t.compilationString += this._declareOutput(s, t) + " = vec4(".concat(a.associatedVariableName, ", ").concat(o.isConnected ? this._writeVariable(o) : "0.0", ")").concat(this._buildSwizzle(4), ";\n")), l.hasEndpoints && (t.compilationString += this._declareOutput(l, t) + " = ".concat(a.associatedVariableName).concat(this._buildSwizzle(3), ";\n"))) : (s.hasEndpoints && (t.compilationString += this._declareOutput(s, 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")), l.hasEndpoints && (t.compilationString += this._declareOutput(l, 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"))), this }, t.prototype.serialize = function () { var t = e.prototype.serialize.call(this); return t.rSwizzle = this.rSwizzle, t.gSwizzle = this.gSwizzle, t.bSwizzle = this.bSwizzle, t.aSwizzle = this.aSwizzle, t }, t.prototype._deserialize = function (t, i, r) { var n, o, a, s; e.prototype._deserialize.call(this, t, i, r), this.rSwizzle = null !== (n = t.rSwizzle) && void 0 !== n ? n : "r", this.gSwizzle = null !== (o = t.gSwizzle) && void 0 !== o ? o : "g", this.bSwizzle = null !== (a = t.bSwizzle) && void 0 !== a ? a : "b", this.aSwizzle = null !== (s = t.aSwizzle) && void 0 !== s ? s : "a" }, t.prototype._dumpPropertiesCode = function () { var t = e.prototype._dumpPropertiesCode.call(this); return t += "".concat(this._codeVariableName, '.rSwizzle = "').concat(this.rSwizzle, '";\n'), t += "".concat(this._codeVariableName, '.gSwizzle = "').concat(this.gSwizzle, '";\n'), (t += "".concat(this._codeVariableName, '.bSwizzle = "').concat(this.bSwizzle, '";\n')) + "".concat(this._codeVariableName, '.aSwizzle = "').concat(this.aSwizzle, '";\n') }, t }(sa); b("BABYLON.ColorMergerBlock", ty); var iy = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("xyzw", Jo.Vector4, !0), i.registerInput("xyz ", Jo.Vector3, !0), i.registerInput("xy ", Jo.Vector2, !0), i.registerOutput("xyz", Jo.Vector3), i.registerOutput("xy", Jo.Vector2), i.registerOutput("zw", Jo.Vector2), i.registerOutput("x", Jo.Float), i.registerOutput("y", Jo.Float), i.registerOutput("z", Jo.Float), i.registerOutput("w", Jo.Float), i.inputsAreExclusive = !0, i } return W(t, e), t.prototype.getClassName = function () { return "VectorSplitterBlock" }, Object.defineProperty(t.prototype, "xyzw", { 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, "xyzOut", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyOut", { get: function () { return this._outputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "zw", { 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, "w", { get: function () { return this._outputs[6] }, enumerable: !1, configurable: !0 }), t.prototype._inputRename = function (e) { switch (e) { case "xy ": return "xyIn"; case "xyz ": return "xyzIn"; default: return e } }, t.prototype._outputRename = function (e) { switch (e) { case "xy": return "xyOut"; case "xyz": return "xyzOut"; default: return e } }, t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t); var i = this.xyzw.isConnected ? this.xyzw : this.xyzIn.isConnected ? this.xyzIn : this.xyIn, r = this._outputs[0], n = this._outputs[1], o = this._outputs[2], a = this._outputs[3], s = this._outputs[4], l = this._outputs[5], c = this._outputs[6]; return r.hasEndpoints && (i === this.xyIn ? t.compilationString += this._declareOutput(r, t) + " = vec3(".concat(i.associatedVariableName, ", 0.0);\n") : t.compilationString += this._declareOutput(r, t) + " = ".concat(i.associatedVariableName, ".xyz;\n")), o.hasEndpoints && this.xyzw.isConnected && (t.compilationString += this._declareOutput(o, t) + " = ".concat(this.xyzw.associatedVariableName, ".zw;\n")), n.hasEndpoints && (t.compilationString += this._declareOutput(n, t) + " = ".concat(i.associatedVariableName, ".xy;\n")), a.hasEndpoints && (t.compilationString += this._declareOutput(a, t) + " = ".concat(i.associatedVariableName, ".x;\n")), s.hasEndpoints && (t.compilationString += this._declareOutput(s, t) + " = ".concat(i.associatedVariableName, ".y;\n")), l.hasEndpoints && (t.compilationString += this._declareOutput(l, t) + " = ".concat(i.associatedVariableName, ".z;\n")), c.hasEndpoints && (t.compilationString += this._declareOutput(c, t) + " = ".concat(i.associatedVariableName, ".w;\n")), this }, t }(sa); b("BABYLON.VectorSplitterBlock", iy); var ry = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("left", Jo.AutoDetect), i.registerInput("right", Jo.AutoDetect), i.registerInput("gradient", Jo.AutoDetect), i.registerOutput("output", Jo.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i._linkConnectionTypes(1, 2, !0), i._inputs[2].acceptedConnectionPointTypes.push(Jo.Float), i } return W(t, e), t.prototype.getClassName = function () { return "LerpBlock" }, Object.defineProperty(t.prototype, "left", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "gradient", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t); var i = this._outputs[0]; return t.compilationString += this._declareOutput(i, t) + " = mix(".concat(this.left.associatedVariableName, " , ").concat(this.right.associatedVariableName, ", ").concat(this.gradient.associatedVariableName, ");\n"), this }, t }(sa); b("BABYLON.LerpBlock", ry); var ny = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("left", Jo.AutoDetect), i.registerInput("right", Jo.AutoDetect), i.registerOutput("output", Jo.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i._inputs[0].acceptedConnectionPointTypes.push(Jo.Float), i._inputs[1].acceptedConnectionPointTypes.push(Jo.Float), i } return W(t, e), t.prototype.getClassName = function () { return "DivideBlock" }, 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 }(sa); b("BABYLON.DivideBlock", ny); var oy = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("left", Jo.AutoDetect), i.registerInput("right", Jo.AutoDetect), i.registerOutput("output", Jo.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i._inputs[0].acceptedConnectionPointTypes.push(Jo.Float), i._inputs[1].acceptedConnectionPointTypes.push(Jo.Float), i } return W(t, e), t.prototype.getClassName = function () { return "SubtractBlock" }, 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 }(sa); b("BABYLON.SubtractBlock", oy); var ay = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("value", Jo.Float), i.registerInput("edge", Jo.Float), i.registerOutput("output", Jo.Float), i } return W(t, e), t.prototype.getClassName = function () { return "StepBlock" }, Object.defineProperty(t.prototype, "value", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "edge", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t); var i = this._outputs[0]; return t.compilationString += this._declareOutput(i, t) + " = step(".concat(this.edge.associatedVariableName, ", ").concat(this.value.associatedVariableName, ");\n"), this }, t }(sa); b("BABYLON.StepBlock", ay); var sy = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("input", Jo.AutoDetect), i.registerOutput("output", Jo.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._outputs[0].excludedConnectionPointTypes.push(Jo.Matrix), i } return W(t, e), t.prototype.getClassName = function () { return "OneMinusBlock" }, 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]; return t.compilationString += this._declareOutput(i, t) + " = 1. - ".concat(this.input.associatedVariableName, ";\n"), this }, t }(sa); b("BABYLON.OneMinusBlock", sy), b("BABYLON.OppositeBlock", sy); var ly = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("worldPosition", Jo.Vector4), i.registerInput("cameraPosition", Jo.Vector3), i.registerOutput("output", Jo.Vector3), i } return W(t, e), t.prototype.getClassName = function () { return "ViewDirectionBlock" }, Object.defineProperty(t.prototype, "worldPosition", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraPosition", { 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 (e) { if (!this.cameraPosition.isConnected) { var t = e.getInputBlockByPredicate((function (e) { return e.systemValue === pa.CameraPosition })); t || (t = new Ta("cameraPosition")).setAsSystemValue(pa.CameraPosition), t.output.connectTo(this.cameraPosition) } }, t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t); var i = this._outputs[0]; return t.compilationString += this._declareOutput(i, t) + " = normalize(".concat(this.cameraPosition.associatedVariableName, " - ").concat(this.worldPosition.associatedVariableName, ".xyz);\n"), this }, t }(sa); b("BABYLON.ViewDirectionBlock", ly); var cy = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("worldNormal", Jo.Vector4), i.registerInput("viewDirection", Jo.Vector3), i.registerInput("bias", Jo.Float), i.registerInput("power", Jo.Float), i.registerOutput("fresnel", Jo.Float), i } return W(t, e), t.prototype.getClassName = function () { return "FresnelBlock" }, Object.defineProperty(t.prototype, "worldNormal", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "viewDirection", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "bias", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "power", { get: function () { return this._inputs[3] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fresnel", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function (e) { if (!this.viewDirection.isConnected) { var t = new ly("View direction"); t.output.connectTo(this.viewDirection), t.autoConfigure(e) } if (!this.bias.isConnected) { var i = new Ta("bias"); i.value = 0, i.output.connectTo(this.bias) } if (!this.power.isConnected) { var r = new Ta("power"); r.value = 1, r.output.connectTo(this.power) } }, t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t); var i = "//".concat(this.name); return t._emitFunctionFromInclude("fresnelFunction", i, { removeIfDef: !0 }), t.compilationString += this._declareOutput(this.fresnel, t) + " = computeFresnelTerm(".concat(this.viewDirection.associatedVariableName, ".xyz, ").concat(this.worldNormal.associatedVariableName, ".xyz, ").concat(this.bias.associatedVariableName, ", ").concat(this.power.associatedVariableName, ");\n"), this }, t }(sa); b("BABYLON.FresnelBlock", cy); var uy = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("left", Jo.AutoDetect), i.registerInput("right", Jo.AutoDetect), i.registerOutput("output", Jo.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i } return W(t, e), t.prototype.getClassName = function () { return "MaxBlock" }, 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) + " = max(".concat(this.left.associatedVariableName, ", ").concat(this.right.associatedVariableName, ");\n"), this }, t }(sa); b("BABYLON.MaxBlock", uy); var hy = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("left", Jo.AutoDetect), i.registerInput("right", Jo.AutoDetect), i.registerOutput("output", Jo.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i } return W(t, e), t.prototype.getClassName = function () { return "MinBlock" }, 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) + " = min(".concat(this.left.associatedVariableName, ", ").concat(this.right.associatedVariableName, ");\n"), this }, t }(sa); b("BABYLON.MinBlock", hy); var dy = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("left", Jo.AutoDetect), i.registerInput("right", Jo.AutoDetect), i.registerOutput("output", Jo.Float), i._linkConnectionTypes(0, 1), i._inputs[0].excludedConnectionPointTypes.push(Jo.Float), i._inputs[0].excludedConnectionPointTypes.push(Jo.Matrix), i._inputs[1].excludedConnectionPointTypes.push(Jo.Float), i._inputs[1].excludedConnectionPointTypes.push(Jo.Matrix), i } return W(t, e), t.prototype.getClassName = function () { return "DistanceBlock" }, 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) + " = length(".concat(this.left.associatedVariableName, " - ").concat(this.right.associatedVariableName, ");\n"), this }, t }(sa); b("BABYLON.DistanceBlock", dy); var py = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("value", Jo.AutoDetect), i.registerOutput("output", Jo.Float), i._inputs[0].excludedConnectionPointTypes.push(Jo.Float), i._inputs[0].excludedConnectionPointTypes.push(Jo.Matrix), i } return W(t, e), t.prototype.getClassName = function () { return "LengthBlock" }, Object.defineProperty(t.prototype, "value", { 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]; return t.compilationString += this._declareOutput(i, t) + " = length(".concat(this.value.associatedVariableName, ");\n"), this }, t }(sa); b("BABYLON.LengthBlock", py); var fy = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("value", Jo.AutoDetect), i.registerOutput("output", Jo.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i } return W(t, e), t.prototype.getClassName = function () { return "NegateBlock" }, Object.defineProperty(t.prototype, "value", { 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]; return t.compilationString += this._declareOutput(i, t) + " = -1.0 * ".concat(this.value.associatedVariableName, ";\n"), this }, t }(sa); b("BABYLON.NegateBlock", fy); var _y = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("value", Jo.AutoDetect), i.registerInput("power", Jo.AutoDetect), i.registerOutput("output", Jo.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i } return W(t, e), t.prototype.getClassName = function () { return "PowBlock" }, Object.defineProperty(t.prototype, "value", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "power", { 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) + " = pow(".concat(this.value.associatedVariableName, ", ").concat(this.power.associatedVariableName, ");\n"), this }, t }(sa); b("BABYLON.PowBlock", _y); var my = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("seed", Jo.AutoDetect), i.registerOutput("output", Jo.Float), i._inputs[0].addExcludedConnectionPointFromAllowedTypes(Jo.Vector2 | Jo.Vector3 | Jo.Vector4 | Jo.Color3 | Jo.Color4), i } return W(t, e), t.prototype.getClassName = function () { return "RandomNumberBlock" }, Object.defineProperty(t.prototype, "seed", { 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 = "//".concat(this.name); return t._emitFunctionFromInclude("helperFunctions", r), t.compilationString += this._declareOutput(i, t) + " = getRand(".concat(this.seed.associatedVariableName, ".xy);\n"), this }, t }(sa); b("BABYLON.RandomNumberBlock", my); var gy = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("x", Jo.Float), i.registerInput("y", Jo.Float), i.registerOutput("output", Jo.Float), i } return W(t, e), t.prototype.getClassName = function () { return "ArcTan2Block" }, Object.defineProperty(t.prototype, "x", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "y", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t); var i = this._outputs[0]; return t.compilationString += this._declareOutput(i, t) + " = atan(".concat(this.x.associatedVariableName, ", ").concat(this.y.associatedVariableName, ");\n"), this }, t }(sa); b("BABYLON.ArcTan2Block", gy); var vy = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("value", Jo.AutoDetect), i.registerInput("edge0", Jo.Float), i.registerInput("edge1", Jo.Float), i.registerOutput("output", Jo.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i } return W(t, e), t.prototype.getClassName = function () { return "SmoothStepBlock" }, Object.defineProperty(t.prototype, "value", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "edge0", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "edge1", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t); var i = this._outputs[0]; return t.compilationString += this._declareOutput(i, t) + " = smoothstep(".concat(this.edge0.associatedVariableName, ", ").concat(this.edge1.associatedVariableName, ", ").concat(this.value.associatedVariableName, ");\n"), this }, t }(sa); b("BABYLON.SmoothStepBlock", vy); var yy = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("input", Jo.AutoDetect), i.registerOutput("output", Jo.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i } return W(t, e), t.prototype.getClassName = function () { return "ReciprocalBlock" }, 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]; return this.input.type === Jo.Matrix ? t.compilationString += this._declareOutput(i, t) + " = inverse(".concat(this.input.associatedVariableName, ");\n") : t.compilationString += this._declareOutput(i, t) + " = 1. / ".concat(this.input.associatedVariableName, ";\n"), this }, t }(sa); b("BABYLON.ReciprocalBlock", yy); var by = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("value", Jo.AutoDetect), i.registerInput("reference", Jo.AutoDetect), i.registerInput("distance", Jo.Float), i.registerInput("replacement", Jo.AutoDetect), i.registerOutput("output", Jo.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i._linkConnectionTypes(0, 3), i._inputs[0].excludedConnectionPointTypes.push(Jo.Float), i._inputs[0].excludedConnectionPointTypes.push(Jo.Matrix), i._inputs[1].excludedConnectionPointTypes.push(Jo.Float), i._inputs[1].excludedConnectionPointTypes.push(Jo.Matrix), i._inputs[3].excludedConnectionPointTypes.push(Jo.Float), i._inputs[3].excludedConnectionPointTypes.push(Jo.Matrix), i } return W(t, e), t.prototype.getClassName = function () { return "ReplaceColorBlock" }, Object.defineProperty(t.prototype, "value", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "reference", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "distance", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "replacement", { 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._buildBlock = function (t) { e.prototype._buildBlock.call(this, t); var i = this._outputs[0]; return t.compilationString += this._declareOutput(i, t) + ";\n", t.compilationString += "if (length(".concat(this.value.associatedVariableName, " - ").concat(this.reference.associatedVariableName, ") < ").concat(this.distance.associatedVariableName, ") {\n"), t.compilationString += "".concat(i.associatedVariableName, " = ").concat(this.replacement.associatedVariableName, ";\n"), t.compilationString += "} else {\n", t.compilationString += "".concat(i.associatedVariableName, " = ").concat(this.value.associatedVariableName, ";\n"), t.compilationString += "}\n", this }, t }(sa); b("BABYLON.ReplaceColorBlock", by); var Ty, Ey = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("value", Jo.AutoDetect), i.registerInput("steps", Jo.AutoDetect), i.registerOutput("output", Jo.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i._inputs[0].excludedConnectionPointTypes.push(Jo.Matrix), i._inputs[1].excludedConnectionPointTypes.push(Jo.Matrix), i } return W(t, e), t.prototype.getClassName = function () { return "PosterizeBlock" }, Object.defineProperty(t.prototype, "value", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "steps", { 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) + " = floor(".concat(this.value.associatedVariableName, " / (1.0 / ").concat(this.steps.associatedVariableName, ")) * (1.0 / ").concat(this.steps.associatedVariableName, ");\n"), this }, t }(sa); b("BABYLON.PosterizeBlock", Ey), function (e) { e[e.SawTooth = 0] = "SawTooth", e[e.Square = 1] = "Square", e[e.Triangle = 2] = "Triangle" }(Ty || (Ty = {})); var Sy = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.kind = Ty.SawTooth, i.registerInput("input", Jo.AutoDetect), i.registerOutput("output", Jo.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._inputs[0].excludedConnectionPointTypes.push(Jo.Matrix), i } return W(t, e), t.prototype.getClassName = function () { return "WaveBlock" }, 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]; switch (this.kind) { case Ty.SawTooth: t.compilationString += this._declareOutput(i, t) + " = ".concat(this.input.associatedVariableName, " - floor(0.5 + ").concat(this.input.associatedVariableName, ");\n"); break; case Ty.Square: t.compilationString += this._declareOutput(i, t) + " = 1.0 - 2.0 * round(fract(".concat(this.input.associatedVariableName, "));\n"); break; case Ty.Triangle: t.compilationString += this._declareOutput(i, t) + " = 2.0 * abs(2.0 * (".concat(this.input.associatedVariableName, " - floor(0.5 + ").concat(this.input.associatedVariableName, "))) - 1.0;\n") }return this }, t.prototype.serialize = function () { var t = e.prototype.serialize.call(this); return t.kind = this.kind, t }, t.prototype._deserialize = function (t, i, r) { e.prototype._deserialize.call(this, t, i, r), this.kind = t.kind }, t }(sa); b("BABYLON.WaveBlock", Sy); var xy = function () { function e(e, t) { this.step = e, this.color = t } return Object.defineProperty(e.prototype, "step", { get: function () { return this._step }, set: function (e) { this._step = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "color", { get: function () { return this._color }, set: function (e) { this._color = e }, enumerable: !1, configurable: !0 }), e }(), Ay = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.colorSteps = [new xy(0, B.Black()), new xy(1, B.White())], i.onValueChangedObservable = new u, i.registerInput("gradient", Jo.AutoDetect), i.registerOutput("output", Jo.Color3), i._inputs[0].addExcludedConnectionPointFromAllowedTypes(Jo.Float | Jo.Vector2 | Jo.Vector3 | Jo.Vector4 | Jo.Color3 | Jo.Color4), i } return W(t, e), t.prototype.colorStepsUpdated = function () { this.onValueChangedObservable.notifyObservers(this) }, t.prototype.getClassName = function () { return "GradientBlock" }, Object.defineProperty(t.prototype, "gradient", { 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._writeColorConstant = function (e) { var t = this.colorSteps[e]; return "vec3(".concat(t.color.r, ", ").concat(t.color.g, ", ").concat(t.color.b, ")") }, t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t); var i = this._outputs[0]; if (this.colorSteps.length && this.gradient.connectedPoint) { var r = t._getFreeVariableName("gradientTempColor"), n = t._getFreeVariableName("gradientTempPosition"); t.compilationString += "vec3 ".concat(r, " = ").concat(this._writeColorConstant(0), ";\n"), t.compilationString += "float ".concat(n, ";\n"); var o = this.gradient.associatedVariableName; this.gradient.connectedPoint.type !== Jo.Float && (o += ".x"); for (var a = 1; a < this.colorSteps.length; a++) { var s = this.colorSteps[a], l = this.colorSteps[a - 1]; t.compilationString += "".concat(n, " = clamp((").concat(o, " - ").concat(t._emitFloat(l.step), ") / (").concat(t._emitFloat(s.step), " - ").concat(t._emitFloat(l.step), "), 0.0, 1.0) * step(").concat(t._emitFloat(a), ", ").concat(t._emitFloat(this.colorSteps.length - 1), ");\n"), t.compilationString += "".concat(r, " = mix(").concat(r, ", ").concat(this._writeColorConstant(a), ", ").concat(n, ");\n") } return t.compilationString += this._declareOutput(i, t) + " = ".concat(r, ";\n"), this } t.compilationString += this._declareOutput(i, t) + " = vec3(0., 0., 0.);\n" }, t.prototype.serialize = function () { var t = e.prototype.serialize.call(this); t.colorSteps = []; for (var i = 0, r = this.colorSteps; i < r.length; i++) { var n = r[i]; t.colorSteps.push({ step: n.step, color: { r: n.color.r, g: n.color.g, b: n.color.b } }) } return t }, t.prototype._deserialize = function (t, i, r) { e.prototype._deserialize.call(this, t, i, r), this.colorSteps.length = 0; for (var n = 0, o = t.colorSteps; n < o.length; n++) { var a = o[n]; this.colorSteps.push(new xy(a.step, new B(a.color.r, a.color.g, a.color.b))) } }, t.prototype._dumpPropertiesCode = function () { var t = e.prototype._dumpPropertiesCode.call(this); t += "".concat(this._codeVariableName, ".colorSteps = [];\n"); for (var i = 0, r = this.colorSteps; i < r.length; i++) { var n = r[i]; t += "".concat(this._codeVariableName, ".colorSteps.push(new BABYLON.GradientBlockColorStep(").concat(n.step, ", new BABYLON.Color3(").concat(n.color.r, ", ").concat(n.color.g, ", ").concat(n.color.b, ")));\n") } return t }, t }(sa); b("BABYLON.GradientBlock", Ay); var Ry = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("left", Jo.AutoDetect), i.registerInput("right", Jo.AutoDetect), i.registerInput("gradient", Jo.AutoDetect), i.registerOutput("output", Jo.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i._linkConnectionTypes(1, 2, !0), i._inputs[2].acceptedConnectionPointTypes.push(Jo.Float), i } return W(t, e), t.prototype.getClassName = function () { return "NLerpBlock" }, Object.defineProperty(t.prototype, "left", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "gradient", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t); var i = this._outputs[0]; return t.compilationString += this._declareOutput(i, t) + " = normalize(mix(".concat(this.left.associatedVariableName, " , ").concat(this.right.associatedVariableName, ", ").concat(this.gradient.associatedVariableName, "));\n"), this }, t }(sa); b("BABYLON.NLerpBlock", Ry); var Cy = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.manhattanDistance = !1, i.registerInput("seed", Jo.Vector3), i.registerInput("jitter", Jo.Float), i.registerOutput("output", Jo.Vector2), i.registerOutput("x", Jo.Float), i.registerOutput("y", Jo.Float), i } return W(t, e), t.prototype.getClassName = function () { return "WorleyNoise3DBlock" }, Object.defineProperty(t.prototype, "seed", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "jitter", { 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 }), Object.defineProperty(t.prototype, "x", { get: function () { return this._outputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "y", { get: function () { return this._outputs[2] }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function (t) { if (e.prototype._buildBlock.call(this, t), this.seed.isConnected && (this.output.hasEndpoints || this.x.hasEndpoints || this.y.hasEndpoints)) { t._emitFunction("worley3D", "vec3 permute(vec3 x){\n return mod((34.0 * x + 1.0) * x, 289.0);\n}\n\nvec3 dist(vec3 x, vec3 y, vec3 z, bool manhattanDistance){\n return manhattanDistance ? abs(x) + abs(y) + abs(z) : (x * x + y * y + z * z);\n}\n\nvec2 worley(vec3 P, float jitter, bool manhattanDistance){\n float K = 0.142857142857; // 1/7\n float Ko = 0.428571428571; // 1/2-K/2\n float K2 = 0.020408163265306; // 1/(7*7)\n float Kz = 0.166666666667; // 1/6\n float Kzo = 0.416666666667; // 1/2-1/6*2\n\n vec3 Pi = mod(floor(P), 289.0);\n vec3 Pf = fract(P) - 0.5;\n\n vec3 Pfx = Pf.x + vec3(1.0, 0.0, -1.0);\n vec3 Pfy = Pf.y + vec3(1.0, 0.0, -1.0);\n vec3 Pfz = Pf.z + vec3(1.0, 0.0, -1.0);\n\n vec3 p = permute(Pi.x + vec3(-1.0, 0.0, 1.0));\n vec3 p1 = permute(p + Pi.y - 1.0);\n vec3 p2 = permute(p + Pi.y);\n vec3 p3 = permute(p + Pi.y + 1.0);\n\n vec3 p11 = permute(p1 + Pi.z - 1.0);\n vec3 p12 = permute(p1 + Pi.z);\n vec3 p13 = permute(p1 + Pi.z + 1.0);\n\n vec3 p21 = permute(p2 + Pi.z - 1.0);\n vec3 p22 = permute(p2 + Pi.z);\n vec3 p23 = permute(p2 + Pi.z + 1.0);\n\n vec3 p31 = permute(p3 + Pi.z - 1.0);\n vec3 p32 = permute(p3 + Pi.z);\n vec3 p33 = permute(p3 + Pi.z + 1.0);\n\n vec3 ox11 = fract(p11*K) - Ko;\n vec3 oy11 = mod(floor(p11*K), 7.0)*K - Ko;\n vec3 oz11 = floor(p11*K2)*Kz - Kzo; // p11 < 289 guaranteed\n\n vec3 ox12 = fract(p12*K) - Ko;\n vec3 oy12 = mod(floor(p12*K), 7.0)*K - Ko;\n vec3 oz12 = floor(p12*K2)*Kz - Kzo;\n\n vec3 ox13 = fract(p13*K) - Ko;\n vec3 oy13 = mod(floor(p13*K), 7.0)*K - Ko;\n vec3 oz13 = floor(p13*K2)*Kz - Kzo;\n\n vec3 ox21 = fract(p21*K) - Ko;\n vec3 oy21 = mod(floor(p21*K), 7.0)*K - Ko;\n vec3 oz21 = floor(p21*K2)*Kz - Kzo;\n\n vec3 ox22 = fract(p22*K) - Ko;\n vec3 oy22 = mod(floor(p22*K), 7.0)*K - Ko;\n vec3 oz22 = floor(p22*K2)*Kz - Kzo;\n\n vec3 ox23 = fract(p23*K) - Ko;\n vec3 oy23 = mod(floor(p23*K), 7.0)*K - Ko;\n vec3 oz23 = floor(p23*K2)*Kz - Kzo;\n\n vec3 ox31 = fract(p31*K) - Ko;\n vec3 oy31 = mod(floor(p31*K), 7.0)*K - Ko;\n vec3 oz31 = floor(p31*K2)*Kz - Kzo;\n\n vec3 ox32 = fract(p32*K) - Ko;\n vec3 oy32 = mod(floor(p32*K), 7.0)*K - Ko;\n vec3 oz32 = floor(p32*K2)*Kz - Kzo;\n\n vec3 ox33 = fract(p33*K) - Ko;\n vec3 oy33 = mod(floor(p33*K), 7.0)*K - Ko;\n vec3 oz33 = floor(p33*K2)*Kz - Kzo;\n\n vec3 dx11 = Pfx + jitter*ox11;\n vec3 dy11 = Pfy.x + jitter*oy11;\n vec3 dz11 = Pfz.x + jitter*oz11;\n\n vec3 dx12 = Pfx + jitter*ox12;\n vec3 dy12 = Pfy.x + jitter*oy12;\n vec3 dz12 = Pfz.y + jitter*oz12;\n\n vec3 dx13 = Pfx + jitter*ox13;\n vec3 dy13 = Pfy.x + jitter*oy13;\n vec3 dz13 = Pfz.z + jitter*oz13;\n\n vec3 dx21 = Pfx + jitter*ox21;\n vec3 dy21 = Pfy.y + jitter*oy21;\n vec3 dz21 = Pfz.x + jitter*oz21;\n\n vec3 dx22 = Pfx + jitter*ox22;\n vec3 dy22 = Pfy.y + jitter*oy22;\n vec3 dz22 = Pfz.y + jitter*oz22;\n\n vec3 dx23 = Pfx + jitter*ox23;\n vec3 dy23 = Pfy.y + jitter*oy23;\n vec3 dz23 = Pfz.z + jitter*oz23;\n\n vec3 dx31 = Pfx + jitter*ox31;\n vec3 dy31 = Pfy.z + jitter*oy31;\n vec3 dz31 = Pfz.x + jitter*oz31;\n\n vec3 dx32 = Pfx + jitter*ox32;\n vec3 dy32 = Pfy.z + jitter*oy32;\n vec3 dz32 = Pfz.y + jitter*oz32;\n\n vec3 dx33 = Pfx + jitter*ox33;\n vec3 dy33 = Pfy.z + jitter*oy33;\n vec3 dz33 = Pfz.z + jitter*oz33;\n\n vec3 d11 = dist(dx11, dy11, dz11, manhattanDistance);\n vec3 d12 =dist(dx12, dy12, dz12, manhattanDistance);\n vec3 d13 = dist(dx13, dy13, dz13, manhattanDistance);\n vec3 d21 = dist(dx21, dy21, dz21, manhattanDistance);\n vec3 d22 = dist(dx22, dy22, dz22, manhattanDistance);\n vec3 d23 = dist(dx23, dy23, dz23, manhattanDistance);\n vec3 d31 = dist(dx31, dy31, dz31, manhattanDistance);\n vec3 d32 = dist(dx32, dy32, dz32, manhattanDistance);\n vec3 d33 = dist(dx33, dy33, dz33, manhattanDistance);\n\n vec3 d1a = min(d11, d12);\n d12 = max(d11, d12);\n d11 = min(d1a, d13); // Smallest now not in d12 or d13\n d13 = max(d1a, d13);\n d12 = min(d12, d13); // 2nd smallest now not in d13\n vec3 d2a = min(d21, d22);\n d22 = max(d21, d22);\n d21 = min(d2a, d23); // Smallest now not in d22 or d23\n d23 = max(d2a, d23);\n d22 = min(d22, d23); // 2nd smallest now not in d23\n vec3 d3a = min(d31, d32);\n d32 = max(d31, d32);\n d31 = min(d3a, d33); // Smallest now not in d32 or d33\n d33 = max(d3a, d33);\n d32 = min(d32, d33); // 2nd smallest now not in d33\n vec3 da = min(d11, d21);\n d21 = max(d11, d21);\n d11 = min(da, d31); // Smallest now in d11\n d31 = max(da, d31); // 2nd smallest now not in d31\n d11.xy = (d11.x < d11.y) ? d11.xy : d11.yx;\n d11.xz = (d11.x < d11.z) ? d11.xz : d11.zx; // d11.x now smallest\n d12 = min(d12, d21); // 2nd smallest now not in d21\n d12 = min(d12, d22); // nor in d22\n d12 = min(d12, d31); // nor in d31\n d12 = min(d12, d32); // nor in d32\n d11.yz = min(d11.yz,d12.xy); // nor in d12.yz\n d11.y = min(d11.y,d12.z); // Only two more to go\n d11.y = min(d11.y,d11.z); // Done! (Phew!)\n return sqrt(d11.xy); // F1, F2\n}\n\n", "// Worley3D"); var i = t._getFreeVariableName("worleyTemp"); return t.compilationString += "vec2 ".concat(i, " = worley(").concat(this.seed.associatedVariableName, ", ").concat(this.jitter.associatedVariableName, ", ").concat(this.manhattanDistance, ");\n"), this.output.hasEndpoints && (t.compilationString += this._declareOutput(this.output, t) + " = ".concat(i, ";\n")), this.x.hasEndpoints && (t.compilationString += this._declareOutput(this.x, t) + " = ".concat(i, ".x;\n")), this.y.hasEndpoints && (t.compilationString += this._declareOutput(this.y, t) + " = ".concat(i, ".y;\n")), this } }, t.prototype._dumpPropertiesCode = function () { return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".manhattanDistance = ").concat(this.manhattanDistance, ";\n") }, t.prototype.serialize = function () { var t = e.prototype.serialize.call(this); return t.manhattanDistance = this.manhattanDistance, t }, t.prototype._deserialize = function (t, i, r) { e.prototype._deserialize.call(this, t, i, r), this.manhattanDistance = t.manhattanDistance }, X([ha("Use Manhattan Distance", ca.Boolean, "PROPERTIES", { notifiers: { update: !1 } })], t.prototype, "manhattanDistance", void 0), t }(sa); b("BABYLON.WorleyNoise3DBlock", Cy); var Py = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("seed", Jo.Vector3), i.registerOutput("output", Jo.Float), i } return W(t, e), t.prototype.getClassName = function () { return "SimplexPerlin3DBlock" }, Object.defineProperty(t.prototype, "seed", { 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) { if (e.prototype._buildBlock.call(this, t), this.seed.isConnected && this._outputs[0].hasEndpoints) return t._emitFunction("SimplexPerlin3D", "const float SKEWFACTOR = 1.0/3.0;\nconst float UNSKEWFACTOR = 1.0/6.0;\nconst float SIMPLEX_CORNER_POS = 0.5;\nconst float SIMPLEX_TETRAHADRON_HEIGHT = 0.70710678118654752440084436210485;\nfloat SimplexPerlin3D( vec3 P ){\n P.x = P == vec3(0., 0., 0.) ? 0.00001 : P.x;\n P *= SIMPLEX_TETRAHADRON_HEIGHT;\n vec3 Pi = floor( P + dot( P, vec3( SKEWFACTOR) ) ); vec3 x0 = P - Pi + dot(Pi, vec3( UNSKEWFACTOR ) );\n vec3 g = step(x0.yzx, x0.xyz);\n vec3 l = 1.0 - g;\n vec3 Pi_1 = min( g.xyz, l.zxy );\n vec3 Pi_2 = max( g.xyz, l.zxy );\n vec3 x1 = x0 - Pi_1 + UNSKEWFACTOR;\n vec3 x2 = x0 - Pi_2 + SKEWFACTOR;\n vec3 x3 = x0 - SIMPLEX_CORNER_POS;\n vec4 v1234_x = vec4( x0.x, x1.x, x2.x, x3.x );\n vec4 v1234_y = vec4( x0.y, x1.y, x2.y, x3.y );\n vec4 v1234_z = vec4( x0.z, x1.z, x2.z, x3.z );\n Pi.xyz = Pi.xyz - floor(Pi.xyz * ( 1.0 / 69.0 )) * 69.0;\n vec3 Pi_inc1 = step( Pi, vec3( 69.0 - 1.5 ) ) * ( Pi + 1.0 );\n vec4 Pt = vec4( Pi.xy, Pi_inc1.xy ) + vec2( 50.0, 161.0 ).xyxy;\n Pt *= Pt;\n vec4 V1xy_V2xy = mix( Pt.xyxy, Pt.zwzw, vec4( Pi_1.xy, Pi_2.xy ) );\n Pt = vec4( Pt.x, V1xy_V2xy.xz, Pt.z ) * vec4( Pt.y, V1xy_V2xy.yw, Pt.w );\n const vec3 SOMELARGEFLOATS = vec3( 635.298681, 682.357502, 668.926525 );\n const vec3 ZINC = vec3( 48.500388, 65.294118, 63.934599 );\n vec3 lowz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi.zzz * ZINC.xyz ) );\n vec3 highz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi_inc1.zzz * ZINC.xyz ) );\n Pi_1 = ( Pi_1.z < 0.5 ) ? lowz_mods : highz_mods;\n Pi_2 = ( Pi_2.z < 0.5 ) ? lowz_mods : highz_mods;\n vec4 hash_0 = fract( Pt * vec4( lowz_mods.x, Pi_1.x, Pi_2.x, highz_mods.x ) ) - 0.49999;\n vec4 hash_1 = fract( Pt * vec4( lowz_mods.y, Pi_1.y, Pi_2.y, highz_mods.y ) ) - 0.49999;\n vec4 hash_2 = fract( Pt * vec4( lowz_mods.z, Pi_1.z, Pi_2.z, highz_mods.z ) ) - 0.49999;\n vec4 grad_results = inversesqrt( hash_0 * hash_0 + hash_1 * hash_1 + hash_2 * hash_2 ) * ( hash_0 * v1234_x + hash_1 * v1234_y + hash_2 * v1234_z );\n const float FINAL_NORMALIZATION = 37.837227241611314102871574478976;\n vec4 kernel_weights = v1234_x * v1234_x + v1234_y * v1234_y + v1234_z * v1234_z;\n kernel_weights = max(0.5 - kernel_weights, 0.0);\n kernel_weights = kernel_weights*kernel_weights*kernel_weights;\n return dot( kernel_weights, grad_results ) * FINAL_NORMALIZATION;\n}\n", "// SimplexPerlin3D"), t.compilationString += this._declareOutput(this._outputs[0], t) + " = SimplexPerlin3D(".concat(this.seed.associatedVariableName, ");\n"), this }, t }(sa); b("BABYLON.SimplexPerlin3DBlock", Py); var Iy = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("normalMap0", Jo.AutoDetect), i.registerInput("normalMap1", Jo.AutoDetect), i.registerOutput("output", Jo.Vector3), i._inputs[0].addExcludedConnectionPointFromAllowedTypes(Jo.Color3 | Jo.Color4 | Jo.Vector3 | Jo.Vector4), i._inputs[1].addExcludedConnectionPointFromAllowedTypes(Jo.Color3 | Jo.Color4 | Jo.Vector3 | Jo.Vector4), i } return W(t, e), t.prototype.getClassName = function () { return "NormalBlendBlock" }, Object.defineProperty(t.prototype, "normalMap0", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "normalMap1", { 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], r = this._inputs[0], n = this._inputs[1], o = t._getFreeVariableName("stepR"), a = t._getFreeVariableName("stepG"); return t.compilationString += "float ".concat(o, " = step(0.5, ").concat(r.associatedVariableName, ".r);\n"), t.compilationString += "float ".concat(a, " = step(0.5, ").concat(r.associatedVariableName, ".g);\n"), t.compilationString += this._declareOutput(i, t) + ";\n", t.compilationString += "".concat(i.associatedVariableName, ".r = (1.0 - ").concat(o, ") * ").concat(r.associatedVariableName, ".r * ").concat(n.associatedVariableName, ".r * 2.0 + ").concat(o, " * (1.0 - (1.0 - ").concat(r.associatedVariableName, ".r) * (1.0 - ").concat(n.associatedVariableName, ".r) * 2.0);\n"), t.compilationString += "".concat(i.associatedVariableName, ".g = (1.0 - ").concat(a, ") * ").concat(r.associatedVariableName, ".g * ").concat(n.associatedVariableName, ".g * 2.0 + ").concat(a, " * (1.0 - (1.0 - ").concat(r.associatedVariableName, ".g) * (1.0 - ").concat(n.associatedVariableName, ".g) * 2.0);\n"), t.compilationString += "".concat(i.associatedVariableName, ".b = ").concat(r.associatedVariableName, ".b * ").concat(n.associatedVariableName, ".b;\n"), this }, t }(sa); b("BABYLON.NormalBlendBlock", Iy); var My = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("input", Jo.Vector2), i.registerInput("angle", Jo.Float), i.registerOutput("output", Jo.Vector2), i } return W(t, e), t.prototype.getClassName = function () { return "Rotate2dBlock" }, Object.defineProperty(t.prototype, "input", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "angle", { 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.angle.isConnected) { var e = new Ta("angle"); e.value = 0, e.output.connectTo(this.angle) } }, t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t); var i = this._outputs[0], r = this.angle, n = this.input; return t.compilationString += this._declareOutput(i, t) + " = vec2(cos(".concat(r.associatedVariableName, ") * ").concat(n.associatedVariableName, ".x - sin(").concat(r.associatedVariableName, ") * ").concat(n.associatedVariableName, ".y, sin(").concat(r.associatedVariableName, ") * ").concat(n.associatedVariableName, ".x + cos(").concat(r.associatedVariableName, ") * ").concat(n.associatedVariableName, ".y);\n"), this }, t }(sa); b("BABYLON.Rotate2dBlock", My); var Oy = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("incident", Jo.AutoDetect), i.registerInput("normal", Jo.AutoDetect), i.registerOutput("output", Jo.Vector3), i._inputs[0].addExcludedConnectionPointFromAllowedTypes(Jo.Vector3 | Jo.Vector4 | Jo.Color3 | Jo.Color4), i._inputs[1].addExcludedConnectionPointFromAllowedTypes(Jo.Vector3 | Jo.Vector4 | Jo.Color3 | Jo.Color4), i } return W(t, e), t.prototype.getClassName = function () { return "ReflectBlock" }, Object.defineProperty(t.prototype, "incident", { 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, "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) + " = reflect(".concat(this.incident.associatedVariableName, ".xyz, ").concat(this.normal.associatedVariableName, ".xyz);\n"), this }, t }(sa); b("BABYLON.ReflectBlock", Oy); var Dy = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("incident", Jo.AutoDetect), i.registerInput("normal", Jo.AutoDetect), i.registerInput("ior", Jo.Float), i.registerOutput("output", Jo.Vector3), i._inputs[0].addExcludedConnectionPointFromAllowedTypes(Jo.Vector3 | Jo.Vector4 | Jo.Color3 | Jo.Color4), i._inputs[1].addExcludedConnectionPointFromAllowedTypes(Jo.Vector3 | Jo.Vector4 | Jo.Color3 | Jo.Color4), i } return W(t, e), t.prototype.getClassName = function () { return "RefractBlock" }, Object.defineProperty(t.prototype, "incident", { 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, "ior", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t); var i = this._outputs[0]; return t.compilationString += this._declareOutput(i, t) + " = refract(".concat(this.incident.associatedVariableName, ".xyz, ").concat(this.normal.associatedVariableName, ".xyz, ").concat(this.ior.associatedVariableName, ");\n"), this }, t }(sa); b("BABYLON.RefractBlock", Dy); var Ny = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("color", Jo.Color3), i.registerInput("level", Jo.Float), i.registerOutput("output", Jo.Color3), i } return W(t, e), t.prototype.getClassName = function () { return "DesaturateBlock" }, Object.defineProperty(t.prototype, "color", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "level", { 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], r = this.color.associatedVariableName, n = t._getFreeVariableName("colorMin"), o = t._getFreeVariableName("colorMax"), a = t._getFreeVariableName("colorMerge"); return t.compilationString += "float ".concat(n, " = min(min(").concat(r, ".x, ").concat(r, ".y), ").concat(r, ".z);\n"), t.compilationString += "float ".concat(o, " = max(max(").concat(r, ".x, ").concat(r, ".y), ").concat(r, ".z);\n"), t.compilationString += "float ".concat(a, " = 0.5 * (").concat(n, " + ").concat(o, ");\n"), t.compilationString += this._declareOutput(i, t) + " = mix(".concat(r, ", vec3(").concat(a, ", ").concat(a, ", ").concat(a, "), ").concat(this.level.associatedVariableName, ");\n"), this }, t }(sa); b("BABYLON.DesaturateBlock", Ny); var Fy = function (e) { function t(i) { var r = e.call(this, i, $o.Fragment) || this; return r.albedoScaling = !1, r.linkSheenWithAlbedo = !1, r._isUnique = !0, r.registerInput("intensity", Jo.Float, !0, $o.Fragment), r.registerInput("color", Jo.Color3, !0, $o.Fragment), r.registerInput("roughness", Jo.Float, !0, $o.Fragment), r.registerOutput("sheen", Jo.Object, $o.Fragment, new bv("sheen", r, ra.Output, t, "SheenBlock")), r } return W(t, e), t.prototype.initialize = function (e) { e._excludeVariableName("sheenOut"), e._excludeVariableName("sheenMapData"), e._excludeVariableName("vSheenColor"), e._excludeVariableName("vSheenRoughness") }, t.prototype.getClassName = function () { return "SheenBlock" }, Object.defineProperty(t.prototype, "intensity", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "color", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "roughness", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sheen", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype.prepareDefines = function (t, i, r) { e.prototype.prepareDefines.call(this, t, i, r), r.setValue("SHEEN", !0), r.setValue("SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE", !0, !0), r.setValue("SHEEN_LINKWITHALBEDO", this.linkSheenWithAlbedo, !0), r.setValue("SHEEN_ROUGHNESS", this.roughness.isConnected, !0), r.setValue("SHEEN_ALBEDOSCALING", this.albedoScaling, !0) }, t.prototype.getCode = function (e) { var t = this.color.isConnected ? this.color.associatedVariableName : "vec3(1.)", i = this.intensity.isConnected ? this.intensity.associatedVariableName : "1.", r = this.roughness.isConnected ? this.roughness.associatedVariableName : "0."; return "#ifdef SHEEN\n sheenOutParams sheenOut;\n\n vec4 vSheenColor = vec4(".concat(t, ", ").concat(i, ");\n\n sheenBlock(\n vSheenColor,\n #ifdef SHEEN_ROUGHNESS\n ").concat(r, ",\n #endif\n roughness,\n #ifdef SHEEN_TEXTURE\n ").concat("vec4(0.)", ",\n 1.0,\n #endif\n reflectance,\n #ifdef SHEEN_LINKWITHALBEDO\n baseColor,\n surfaceAlbedo,\n #endif\n #ifdef ENVIRONMENTBRDF\n NdotV,\n environmentBrdf,\n #endif\n #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)\n AARoughnessFactors,\n ").concat(null == e ? void 0 : e._vReflectionMicrosurfaceInfosName, ",\n ").concat(null == e ? void 0 : e._vReflectionInfosName, ",\n ").concat(null == e ? void 0 : e.reflectionColor, ",\n vLightingIntensity,\n #ifdef ").concat(null == e ? void 0 : e._define3DName, "\n ").concat(null == e ? void 0 : e._cubeSamplerName, ",\n #else\n ").concat(null == e ? void 0 : e._2DSamplerName, ",\n #endif\n reflectionOut.reflectionCoords,\n NdotVUnclamped,\n #ifndef LODBASEDMICROSFURACE\n #ifdef ").concat(null == e ? void 0 : e._define3DName, "\n ").concat(null == e ? void 0 : e._cubeSamplerName, ",\n ").concat(null == e ? void 0 : e._cubeSamplerName, ",\n #else\n ").concat(null == e ? void 0 : e._2DSamplerName, ",\n ").concat(null == e ? void 0 : e._2DSamplerName, ",\n #endif\n #endif\n #if !defined(").concat(null == e ? void 0 : e._defineSkyboxName, ") && defined(RADIANCEOCCLUSION)\n seo,\n #endif\n #if !defined(").concat(null == e ? void 0 : e._defineSkyboxName, ") && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(").concat(null == e ? void 0 : e._define3DName, ")\n eho,\n #endif\n #endif\n sheenOut\n );\n\n #ifdef SHEEN_LINKWITHALBEDO\n surfaceAlbedo = sheenOut.surfaceAlbedo;\n #endif\n #endif\n") }, t.prototype._buildBlock = function (e) { return e.target === $o.Fragment && e.sharedData.blocksWithDefines.push(this), this }, t.prototype._dumpPropertiesCode = function () { var t = e.prototype._dumpPropertiesCode.call(this); return (t += "".concat(this._codeVariableName, ".albedoScaling = ").concat(this.albedoScaling, ";\n")) + "".concat(this._codeVariableName, ".linkSheenWithAlbedo = ").concat(this.linkSheenWithAlbedo, ";\n") }, t.prototype.serialize = function () { var t = e.prototype.serialize.call(this); return t.albedoScaling = this.albedoScaling, t.linkSheenWithAlbedo = this.linkSheenWithAlbedo, t }, t.prototype._deserialize = function (t, i, r) { e.prototype._deserialize.call(this, t, i, r), this.albedoScaling = t.albedoScaling, this.linkSheenWithAlbedo = t.linkSheenWithAlbedo }, X([ha("Albedo scaling", ca.Boolean, "PROPERTIES", { notifiers: { update: !0 } })], t.prototype, "albedoScaling", void 0), X([ha("Link sheen with albedo", ca.Boolean, "PROPERTIES", { notifiers: { update: !0 } })], t.prototype, "linkSheenWithAlbedo", void 0), t }(sa); b("BABYLON.SheenBlock", Fy); var Ly = function (e) { function t(i) { var r = e.call(this, i, $o.Fragment) || this; return r._tangentCorrectionFactorName = "", r._isUnique = !0, r.registerInput("intensity", Jo.Float, !0, $o.Fragment), r.registerInput("direction", Jo.Vector2, !0, $o.Fragment), r.registerInput("uv", Jo.Vector2, !0), r.registerInput("worldTangent", Jo.Vector4, !0), r.registerInput("TBN", Jo.Object, !0, $o.VertexAndFragment, new bv("TBN", r, ra.Input, Rv, "TBNBlock")), r.registerInput("roughness", Jo.Float, !0, $o.Fragment), r.registerOutput("anisotropy", Jo.Object, $o.Fragment, new bv("anisotropy", r, ra.Output, t, "AnisotropyBlock")), r } return W(t, e), t.prototype.initialize = function (e) { e._excludeVariableName("anisotropicOut"), e._excludeVariableName("TBN") }, t.prototype.getClassName = function () { return "AnisotropyBlock" }, Object.defineProperty(t.prototype, "intensity", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "direction", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "uv", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldTangent", { get: function () { return this._inputs[3] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "TBN", { get: function () { return this._inputs[4] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "roughness", { get: function () { return this._inputs[5] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "anisotropy", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype._generateTBNSpace = function (e) { var t = "", i = "//".concat(this.name), r = this.uv, n = this.worldPositionConnectionPoint, o = this.worldNormalConnectionPoint, a = this.worldTangent; r.isConnected || console.error("You must connect the 'uv' input of the Anisotropy block!"), e._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable"); var s = { search: /defined\(TANGENT\)/g, replace: a.isConnected ? "defined(TANGENT)" : "defined(IGNORE)" }, l = this.TBN; return l.isConnected ? e.compilationString += "\n #ifdef TBNBLOCK\n mat3 vTBN = ".concat(l.associatedVariableName, ";\n #endif\n ") : a.isConnected && (t += "vec3 tbnNormal = normalize(".concat(o.associatedVariableName, ".xyz);\n"), t += "vec3 tbnTangent = normalize(".concat(a.associatedVariableName, ".xyz);\n"), t += "vec3 tbnBitangent = cross(tbnNormal, tbnTangent) * ".concat(this._tangentCorrectionFactorName, ";\n"), t += "mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\n"), t += "\n #if defined(".concat(a.isConnected ? "TANGENT" : "IGNORE", ") && defined(NORMAL)\n mat3 TBN = vTBN;\n #else\n mat3 TBN = cotangent_frame(").concat(o.associatedVariableName + ".xyz", ", ").concat("v_" + n.associatedVariableName + ".xyz", ", ").concat(r.isConnected ? r.associatedVariableName : "vec2(0.)", ", vec2(1., 1.));\n #endif\n"), e._emitFunctionFromInclude("bumpFragmentMainFunctions", i, { replaceStrings: [s] }), t }, t.prototype.getCode = function (e, t) { void 0 === t && (t = !1); var i = ""; t && (i += this._generateTBNSpace(e)); var r = this.intensity.isConnected ? this.intensity.associatedVariableName : "1.0", n = this.direction.isConnected ? this.direction.associatedVariableName : "vec2(1., 0.)", o = this.roughness.isConnected ? this.roughness.associatedVariableName : "0."; return i + "anisotropicOutParams anisotropicOut;\n anisotropicBlock(\n vec3(".concat(n, ", ").concat(r, "),\n ").concat(o, ",\n #ifdef ANISOTROPIC_TEXTURE\n vec3(0.),\n #endif\n TBN,\n normalW,\n viewDirectionW,\n anisotropicOut\n );\n") }, t.prototype.prepareDefines = function (t, i, r) { e.prototype.prepareDefines.call(this, t, i, r), r.setValue("ANISOTROPIC", !0), r.setValue("ANISOTROPIC_TEXTURE", !1, !0), r.setValue("ANISOTROPIC_LEGACY", !this.roughness.isConnected) }, t.prototype.bind = function (t, i, r) { e.prototype.bind.call(this, t, i, r), r && t.setFloat(this._tangentCorrectionFactorName, r.getWorldMatrix().determinant() < 0 ? -1 : 1) }, t.prototype._buildBlock = function (e) { return e.target === $o.Fragment && (e.sharedData.blocksWithDefines.push(this), e.sharedData.bindableBlocks.push(this), this._tangentCorrectionFactorName = e._getFreeDefineName("tangentCorrectionFactor"), e._emitUniformFromString(this._tangentCorrectionFactorName, "float")), this }, t }(sa); b("BABYLON.AnisotropyBlock", Ly); var wy = function (e) { function t(i) { var r = e.call(this, i) || this; return r.useSphericalHarmonics = !0, r.forceIrradianceInFragment = !1, r._isUnique = !0, r.registerInput("position", Jo.AutoDetect, !1, $o.Vertex), r.registerInput("world", Jo.Matrix, !1, $o.Vertex), r.registerInput("color", Jo.Color3, !0, $o.Fragment), r.registerOutput("reflection", Jo.Object, $o.Fragment, new bv("reflection", r, ra.Output, t, "ReflectionBlock")), r.position.addExcludedConnectionPointFromAllowedTypes(Jo.Color3 | Jo.Vector3 | Jo.Vector4), r } return W(t, e), t.prototype._onGenerateOnlyFragmentCodeChanged = function () { return this.position.isConnected ? (this.generateOnlyFragmentCode = !this.generateOnlyFragmentCode, console.error("The position input must not be connected to be able to switch!"), !1) : (this._setTarget(), !0) }, t.prototype._setTarget = function () { e.prototype._setTarget.call(this), this.getInputByName("position").target = this.generateOnlyFragmentCode ? $o.Fragment : $o.Vertex, this.generateOnlyFragmentCode && (this.forceIrradianceInFragment = !0) }, t.prototype.getClassName = function () { return "ReflectionBlock" }, Object.defineProperty(t.prototype, "position", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldPosition", { get: function () { return this.worldPositionConnectionPoint }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldNormal", { get: function () { return this.worldNormalConnectionPoint }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "world", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraPosition", { get: function () { return this.cameraPositionConnectionPoint }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "view", { get: function () { return this.viewConnectionPoint }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "color", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "reflection", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasTexture", { get: function () { return !!this._getTexture() }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "reflectionColor", { get: function () { return this.color.isConnected ? this.color.associatedVariableName : "vec3(1., 1., 1.)" }, enumerable: !1, configurable: !0 }), t.prototype._getTexture = function () { return this.texture ? this.texture : this._scene.environmentTexture }, t.prototype.prepareDefines = function (t, i, r) { e.prototype.prepareDefines.call(this, t, i, r); var n = this._getTexture(), o = n && n.getTextureMatrix; r.setValue("REFLECTION", o, !0), o && (r.setValue(this._defineLODReflectionAlpha, n.lodLevelInAlpha, !0), r.setValue(this._defineLinearSpecularReflection, n.linearSpecularLOD, !0), r.setValue(this._defineOppositeZ, this._scene.useRightHandedSystem ? !n.invertZ : n.invertZ, !0), r.setValue("SPHERICAL_HARMONICS", this.useSphericalHarmonics, !0), r.setValue("GAMMAREFLECTION", n.gammaSpace, !0), r.setValue("RGBDREFLECTION", n.isRGBD, !0), n && n.coordinatesMode !== vo.SKYBOX_MODE && n.isCube && (r.setValue("USESPHERICALFROMREFLECTIONMAP", !0), r.setValue("USEIRRADIANCEMAP", !1), this.forceIrradianceInFragment || this._scene.getEngine().getCaps().maxVaryingVectors <= 8 ? r.setValue("USESPHERICALINVERTEX", !1) : r.setValue("USESPHERICALINVERTEX", !0))) }, t.prototype.bind = function (t, i, r, n) { e.prototype.bind.call(this, t, i, r); var o = this._getTexture(); if (o && n) { o.isCube ? t.setTexture(this._cubeSamplerName, o) : t.setTexture(this._2DSamplerName, o); var a = o.getSize().width; t.setFloat3(this._vReflectionMicrosurfaceInfosName, a, o.lodGenerationScale, o.lodGenerationOffset), t.setFloat2(this._vReflectionFilteringInfoName, a, h.Log2(a)); var s = n.materialDefines, l = o.sphericalPolynomial; if (s.USESPHERICALFROMREFLECTIONMAP && l) if (s.SPHERICAL_HARMONICS) { var c = l.preScaledHarmonics; t.setVector3("vSphericalL00", c.l00), t.setVector3("vSphericalL1_1", c.l1_1), t.setVector3("vSphericalL10", c.l10), t.setVector3("vSphericalL11", c.l11), t.setVector3("vSphericalL2_2", c.l2_2), t.setVector3("vSphericalL2_1", c.l2_1), t.setVector3("vSphericalL20", c.l20), t.setVector3("vSphericalL21", c.l21), t.setVector3("vSphericalL22", c.l22) } else t.setFloat3("vSphericalX", l.x.x, l.x.y, l.x.z), t.setFloat3("vSphericalY", l.y.x, l.y.y, l.y.z), t.setFloat3("vSphericalZ", l.z.x, l.z.y, l.z.z), t.setFloat3("vSphericalXX_ZZ", l.xx.x - l.zz.x, l.xx.y - l.zz.y, l.xx.z - l.zz.z), t.setFloat3("vSphericalYY_ZZ", l.yy.x - l.zz.x, l.yy.y - l.zz.y, l.yy.z - l.zz.z), t.setFloat3("vSphericalZZ", l.zz.x, l.zz.y, l.zz.z), t.setFloat3("vSphericalXY", l.xy.x, l.xy.y, l.xy.z), t.setFloat3("vSphericalYZ", l.yz.x, l.yz.y, l.yz.z), t.setFloat3("vSphericalZX", l.zx.x, l.zx.y, l.zx.z) } }, t.prototype.handleVertexSide = function (t) { var i = e.prototype.handleVertexSide.call(this, t); t._emitFunctionFromInclude("harmonicsFunctions", "//".concat(this.name), { replaceStrings: [{ search: /uniform vec3 vSphericalL00;[\s\S]*?uniform vec3 vSphericalL22;/g, replace: "" }, { search: /uniform vec3 vSphericalX;[\s\S]*?uniform vec3 vSphericalZX;/g, replace: "" }] }); var r = t._getFreeVariableName("reflectionVector"); return this._vEnvironmentIrradianceName = t._getFreeVariableName("vEnvironmentIrradiance"), t._emitVaryingFromString(this._vEnvironmentIrradianceName, "vec3", "defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)"), t._emitUniformFromString("vSphericalL00", "vec3", "SPHERICAL_HARMONICS"), t._emitUniformFromString("vSphericalL1_1", "vec3", "SPHERICAL_HARMONICS"), t._emitUniformFromString("vSphericalL10", "vec3", "SPHERICAL_HARMONICS"), t._emitUniformFromString("vSphericalL11", "vec3", "SPHERICAL_HARMONICS"), t._emitUniformFromString("vSphericalL2_2", "vec3", "SPHERICAL_HARMONICS"), t._emitUniformFromString("vSphericalL2_1", "vec3", "SPHERICAL_HARMONICS"), t._emitUniformFromString("vSphericalL20", "vec3", "SPHERICAL_HARMONICS"), t._emitUniformFromString("vSphericalL21", "vec3", "SPHERICAL_HARMONICS"), t._emitUniformFromString("vSphericalL22", "vec3", "SPHERICAL_HARMONICS"), t._emitUniformFromString("vSphericalX", "vec3", "SPHERICAL_HARMONICS", !0), t._emitUniformFromString("vSphericalY", "vec3", "SPHERICAL_HARMONICS", !0), t._emitUniformFromString("vSphericalZ", "vec3", "SPHERICAL_HARMONICS", !0), t._emitUniformFromString("vSphericalXX_ZZ", "vec3", "SPHERICAL_HARMONICS", !0), t._emitUniformFromString("vSphericalYY_ZZ", "vec3", "SPHERICAL_HARMONICS", !0), t._emitUniformFromString("vSphericalZZ", "vec3", "SPHERICAL_HARMONICS", !0), t._emitUniformFromString("vSphericalXY", "vec3", "SPHERICAL_HARMONICS", !0), t._emitUniformFromString("vSphericalYZ", "vec3", "SPHERICAL_HARMONICS", !0), t._emitUniformFromString("vSphericalZX", "vec3", "SPHERICAL_HARMONICS", !0), i + "#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\n vec3 ".concat(r, " = vec3(").concat(this._reflectionMatrixName, " * vec4(normalize(").concat(this.worldNormal.associatedVariableName, ").xyz, 0)).xyz;\n #ifdef ").concat(this._defineOppositeZ, "\n ").concat(r, ".z *= -1.0;\n #endif\n ").concat(this._vEnvironmentIrradianceName, " = computeEnvironmentIrradiance(").concat(r, ");\n #endif\n") }, t.prototype.getCode = function (e, t) { var i = ""; this.handleFragmentSideInits(e), e._emitFunctionFromInclude("harmonicsFunctions", "//".concat(this.name), { replaceStrings: [{ search: /uniform vec3 vSphericalL00;[\s\S]*?uniform vec3 vSphericalL22;/g, replace: "" }, { search: /uniform vec3 vSphericalX;[\s\S]*?uniform vec3 vSphericalZX;/g, replace: "" }] }), e._emitFunction("sampleReflection", "\n #ifdef ".concat(this._define3DName, "\n #define sampleReflection(s, c) textureCube(s, c)\n #else\n #define sampleReflection(s, c) texture2D(s, c)\n #endif\n"), "//".concat(this.name)), e._emitFunction("sampleReflectionLod", "\n #ifdef ".concat(this._define3DName, "\n #define sampleReflectionLod(s, c, l) textureCubeLodEXT(s, c, l)\n #else\n #define sampleReflectionLod(s, c, l) texture2DLodEXT(s, c, l)\n #endif\n"), "//".concat(this.name)); var r = "\n vec3 computeReflectionCoordsPBR(vec4 worldPos, vec3 worldNormal) {\n ".concat(this.handleFragmentSideCodeReflectionCoords("worldNormal", "worldPos", !0, !0), "\n return ").concat(this._reflectionVectorName, ";\n }\n"); return e._emitFunction("computeReflectionCoordsPBR", r, "//".concat(this.name)), this._vReflectionMicrosurfaceInfosName = e._getFreeVariableName("vReflectionMicrosurfaceInfos"), e._emitUniformFromString(this._vReflectionMicrosurfaceInfosName, "vec3"), this._vReflectionInfosName = e._getFreeVariableName("vReflectionInfos"), this._vReflectionFilteringInfoName = e._getFreeVariableName("vReflectionFilteringInfo"), e._emitUniformFromString(this._vReflectionFilteringInfoName, "vec2"), i + "#ifdef REFLECTION\n vec2 ".concat(this._vReflectionInfosName, " = vec2(1., 0.);\n\n reflectionOutParams reflectionOut;\n\n reflectionBlock(\n ").concat(this.generateOnlyFragmentCode ? this._worldPositionNameInFragmentOnlyMode : "v_" + this.worldPosition.associatedVariableName, ".xyz,\n ").concat(t, ",\n alphaG,\n ").concat(this._vReflectionMicrosurfaceInfosName, ",\n ").concat(this._vReflectionInfosName, ",\n ").concat(this.reflectionColor, ",\n #ifdef ANISOTROPIC\n anisotropicOut,\n #endif\n #if defined(").concat(this._defineLODReflectionAlpha, ") && !defined(").concat(this._defineSkyboxName, ")\n NdotVUnclamped,\n #endif\n #ifdef ").concat(this._defineLinearSpecularReflection, "\n roughness,\n #endif\n #ifdef ").concat(this._define3DName, "\n ").concat(this._cubeSamplerName, ",\n #else\n ").concat(this._2DSamplerName, ",\n #endif\n #if defined(NORMAL) && defined(USESPHERICALINVERTEX)\n ").concat(this._vEnvironmentIrradianceName, ",\n #endif\n #ifdef USESPHERICALFROMREFLECTIONMAP\n #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\n ").concat(this._reflectionMatrixName, ",\n #endif\n #endif\n #ifdef USEIRRADIANCEMAP\n irradianceSampler, // ** not handled **\n #endif\n #ifndef LODBASEDMICROSFURACE\n #ifdef ").concat(this._define3DName, "\n ").concat(this._cubeSamplerName, ",\n ").concat(this._cubeSamplerName, ",\n #else\n ").concat(this._2DSamplerName, ",\n ").concat(this._2DSamplerName, ",\n #endif\n #endif\n #ifdef REALTIME_FILTERING\n ").concat(this._vReflectionFilteringInfoName, ",\n #endif\n reflectionOut\n );\n #endif\n") }, t.prototype._buildBlock = function (e) { return this._scene = e.sharedData.scene, e.target !== $o.Fragment && (this._defineLODReflectionAlpha = e._getFreeDefineName("LODINREFLECTIONALPHA"), this._defineLinearSpecularReflection = e._getFreeDefineName("LINEARSPECULARREFLECTION")), this }, t.prototype._dumpPropertiesCode = function () { var t = e.prototype._dumpPropertiesCode.call(this); return this.texture && (t += "".concat(this._codeVariableName, ".texture.gammaSpace = ").concat(this.texture.gammaSpace, ";\n")), (t += "".concat(this._codeVariableName, ".useSphericalHarmonics = ").concat(this.useSphericalHarmonics, ";\n")) + "".concat(this._codeVariableName, ".forceIrradianceInFragment = ").concat(this.forceIrradianceInFragment, ";\n") }, t.prototype.serialize = function () { var t, i, r = e.prototype.serialize.call(this); return r.useSphericalHarmonics = this.useSphericalHarmonics, r.forceIrradianceInFragment = this.forceIrradianceInFragment, r.gammaSpace = null === (i = null === (t = this.texture) || void 0 === t ? void 0 : t.gammaSpace) || void 0 === i || i, r }, t.prototype._deserialize = function (t, i, r) { e.prototype._deserialize.call(this, t, i, r), this.useSphericalHarmonics = t.useSphericalHarmonics, this.forceIrradianceInFragment = t.forceIrradianceInFragment, this.texture && (this.texture.gammaSpace = t.gammaSpace) }, X([ha("Spherical Harmonics", ca.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "useSphericalHarmonics", void 0), X([ha("Force irradiance in fragment", ca.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "forceIrradianceInFragment", void 0), t }(zv); b("BABYLON.ReflectionBlock", wy); var By = function (e) { function t(i) { var r = e.call(this, i, $o.Fragment) || this; return r._tangentCorrectionFactorName = "", r.remapF0OnInterfaceChange = !0, r._isUnique = !0, r.registerInput("intensity", Jo.Float, !1, $o.Fragment), r.registerInput("roughness", Jo.Float, !0, $o.Fragment), r.registerInput("indexOfRefraction", Jo.Float, !0, $o.Fragment), r.registerInput("normalMapColor", Jo.Color3, !0, $o.Fragment), r.registerInput("uv", Jo.Vector2, !0, $o.Fragment), r.registerInput("tintColor", Jo.Color3, !0, $o.Fragment), r.registerInput("tintAtDistance", Jo.Float, !0, $o.Fragment), r.registerInput("tintThickness", Jo.Float, !0, $o.Fragment), r.registerInput("worldTangent", Jo.Vector4, !0), r.registerInput("worldNormal", Jo.AutoDetect, !0), r.worldNormal.addExcludedConnectionPointFromAllowedTypes(Jo.Color4 | Jo.Vector4 | Jo.Vector3), r.registerInput("TBN", Jo.Object, !0, $o.VertexAndFragment, new bv("TBN", r, ra.Input, Rv, "TBNBlock")), r.registerOutput("clearcoat", Jo.Object, $o.Fragment, new bv("clearcoat", r, ra.Output, t, "ClearCoatBlock")), r } return W(t, e), t.prototype.initialize = function (e) { e._excludeVariableName("clearcoatOut"), e._excludeVariableName("vClearCoatParams"), e._excludeVariableName("vClearCoatTintParams"), e._excludeVariableName("vClearCoatRefractionParams"), e._excludeVariableName("vClearCoatTangentSpaceParams"), e._excludeVariableName("vGeometricNormaClearCoatW") }, t.prototype.getClassName = function () { return "ClearCoatBlock" }, Object.defineProperty(t.prototype, "intensity", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "roughness", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "indexOfRefraction", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "normalMapColor", { get: function () { return this._inputs[3] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "uv", { get: function () { return this._inputs[4] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tintColor", { get: function () { return this._inputs[5] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tintAtDistance", { get: function () { return this._inputs[6] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tintThickness", { get: function () { return this._inputs[7] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldTangent", { get: function () { return this._inputs[8] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldNormal", { get: function () { return this._inputs[9] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "TBN", { get: function () { return this._inputs[10] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "clearcoat", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function () { if (!this.intensity.isConnected) { var e = new Ta("ClearCoat intensity", $o.Fragment, Jo.Float); e.value = 1, e.output.connectTo(this.intensity) } }, t.prototype.prepareDefines = function (t, i, r) { e.prototype.prepareDefines.call(this, t, i, r), r.setValue("CLEARCOAT", !0), r.setValue("CLEARCOAT_TEXTURE", !1, !0), r.setValue("CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE", !0, !0), r.setValue("CLEARCOAT_TINT", this.tintColor.isConnected || this.tintThickness.isConnected || this.tintAtDistance.isConnected, !0), r.setValue("CLEARCOAT_BUMP", this.normalMapColor.isConnected, !0), r.setValue("CLEARCOAT_DEFAULTIOR", !this.indexOfRefraction.isConnected || this.indexOfRefraction.connectInputBlock.value === S_._DefaultIndexOfRefraction, !0), r.setValue("CLEARCOAT_REMAP_F0", this.remapF0OnInterfaceChange, !0) }, t.prototype.bind = function (t, i, r) { var n, o; e.prototype.bind.call(this, t, i, r); var a = null !== (o = null === (n = this.indexOfRefraction.connectInputBlock) || void 0 === n ? void 0 : n.value) && void 0 !== o ? o : S_._DefaultIndexOfRefraction, s = 1 - a, l = 1 + a, c = Math.pow(-s / l, 2), u = 1 / a; t.setFloat4("vClearCoatRefractionParams", c, u, s, l); var h = this.clearcoat.hasEndpoints ? this.clearcoat.endpoints[0].ownerBlock : null, d = (null == h ? void 0 : h.perturbedNormal.isConnected) ? h.perturbedNormal.connectedPoint.ownerBlock : null; this._scene._mirroredCameraPosition ? t.setFloat2("vClearCoatTangentSpaceParams", (null == d ? void 0 : d.invertX) ? 1 : -1, (null == d ? void 0 : d.invertY) ? 1 : -1) : t.setFloat2("vClearCoatTangentSpaceParams", (null == d ? void 0 : d.invertX) ? -1 : 1, (null == d ? void 0 : d.invertY) ? -1 : 1), r && t.setFloat(this._tangentCorrectionFactorName, r.getWorldMatrix().determinant() < 0 ? -1 : 1) }, t.prototype._generateTBNSpace = function (e, t, i) { var r = "", n = "//".concat(this.name), o = this.worldTangent; e._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable"); var a = { search: /defined\(TANGENT\)/g, replace: o.isConnected ? "defined(TANGENT)" : "defined(IGNORE)" }, s = this.TBN; return s.isConnected ? e.compilationString += "\n #ifdef TBNBLOCK\n mat3 vTBN = ".concat(s.associatedVariableName, ";\n #endif\n ") : o.isConnected && (r += "vec3 tbnNormal = normalize(".concat(i, ".xyz);\n"), r += "vec3 tbnTangent = normalize(".concat(o.associatedVariableName, ".xyz);\n"), r += "vec3 tbnBitangent = cross(tbnNormal, tbnTangent) * ".concat(this._tangentCorrectionFactorName, ";\n"), r += "mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\n"), e._emitFunctionFromInclude("bumpFragmentMainFunctions", n, { replaceStrings: [a] }), r }, t.GetCode = function (e, t, i, r, n, o, a) { var s = "", l = (null == t ? void 0 : t.intensity.isConnected) ? t.intensity.associatedVariableName : "1.", c = (null == t ? void 0 : t.roughness.isConnected) ? t.roughness.associatedVariableName : "0.", u = (null == t ? void 0 : t.normalMapColor.isConnected) ? t.normalMapColor.associatedVariableName : "vec3(0.)", h = (null == t ? void 0 : t.uv.isConnected) ? t.uv.associatedVariableName : "vec2(0.)", d = (null == t ? void 0 : t.tintColor.isConnected) ? t.tintColor.associatedVariableName : "vec3(1.)", p = (null == t ? void 0 : t.tintThickness.isConnected) ? t.tintThickness.associatedVariableName : "1.", f = (null == t ? void 0 : t.tintAtDistance.isConnected) ? t.tintAtDistance.associatedVariableName : "1."; if (t) { e._emitUniformFromString("vClearCoatRefractionParams", "vec4"), e._emitUniformFromString("vClearCoatTangentSpaceParams", "vec2"); var _ = t.worldNormal; s += "vec3 vGeometricNormaClearCoatW = ".concat(_.isConnected ? "normalize(" + _.associatedVariableName + ".xyz)" : "geometricNormalW", ";\n") } else s += "vec3 vGeometricNormaClearCoatW = geometricNormalW;\n"; return n && t && (s += t._generateTBNSpace(e, r, a), o = t.worldTangent.isConnected), s + "clearcoatOutParams clearcoatOut;\n\n #ifdef CLEARCOAT\n vec2 vClearCoatParams = vec2(".concat(l, ", ").concat(c, ");\n vec4 vClearCoatTintParams = vec4(").concat(d, ", ").concat(p, ");\n\n clearcoatBlock(\n ").concat(r, ".xyz,\n vGeometricNormaClearCoatW,\n viewDirectionW,\n vClearCoatParams,\n specularEnvironmentR0,\n #ifdef CLEARCOAT_TEXTURE\n vec2(0.),\n #endif\n #ifdef CLEARCOAT_TINT\n vClearCoatTintParams,\n ").concat(f, ",\n vClearCoatRefractionParams,\n #ifdef CLEARCOAT_TINT_TEXTURE\n ").concat("vec4(0.)", ",\n #endif\n #endif\n #ifdef CLEARCOAT_BUMP\n vec2(0., 1.),\n vec4(").concat(u, ", 0.),\n ").concat(h, ",\n #if defined(").concat(o ? "TANGENT" : "IGNORE", ") && defined(NORMAL)\n vTBN,\n #else\n vClearCoatTangentSpaceParams,\n #endif\n #ifdef OBJECTSPACE_NORMALMAP\n normalMatrix,\n #endif\n #endif\n #if defined(FORCENORMALFORWARD) && defined(NORMAL)\n faceNormal,\n #endif\n #ifdef REFLECTION\n ").concat(null == i ? void 0 : i._vReflectionMicrosurfaceInfosName, ",\n ").concat(null == i ? void 0 : i._vReflectionInfosName, ",\n ").concat(null == i ? void 0 : i.reflectionColor, ",\n vLightingIntensity,\n #ifdef ").concat(null == i ? void 0 : i._define3DName, "\n ").concat(null == i ? void 0 : i._cubeSamplerName, ",\n #else\n ").concat(null == i ? void 0 : i._2DSamplerName, ",\n #endif\n #ifndef LODBASEDMICROSFURACE\n #ifdef ").concat(null == i ? void 0 : i._define3DName, "\n ").concat(null == i ? void 0 : i._cubeSamplerName, ",\n ").concat(null == i ? void 0 : i._cubeSamplerName, ",\n #else\n ").concat(null == i ? void 0 : i._2DSamplerName, ",\n ").concat(null == i ? void 0 : i._2DSamplerName, ",\n #endif\n #endif\n #endif\n #if defined(ENVIRONMENTBRDF) && !defined(").concat(null == i ? void 0 : i._defineSkyboxName, ")\n #ifdef RADIANCEOCCLUSION\n ambientMonochrome,\n #endif\n #endif\n #if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)\n (gl_FrontFacing ? 1. : -1.),\n #endif\n clearcoatOut\n );\n #else\n clearcoatOut.specularEnvironmentR0 = specularEnvironmentR0;\n #endif\n") }, t.prototype._buildBlock = function (e) { return this._scene = e.sharedData.scene, e.target === $o.Fragment && (e.sharedData.bindableBlocks.push(this), e.sharedData.blocksWithDefines.push(this), this._tangentCorrectionFactorName = e._getFreeDefineName("tangentCorrectionFactor"), e._emitUniformFromString(this._tangentCorrectionFactorName, "float")), this }, t.prototype._dumpPropertiesCode = function () { return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".remapF0OnInterfaceChange = ").concat(this.remapF0OnInterfaceChange, ";\n") }, t.prototype.serialize = function () { var t = e.prototype.serialize.call(this); return t.remapF0OnInterfaceChange = this.remapF0OnInterfaceChange, t }, t.prototype._deserialize = function (t, i, r) { var n; e.prototype._deserialize.call(this, t, i, r), this.remapF0OnInterfaceChange = null === (n = t.remapF0OnInterfaceChange) || void 0 === n || n }, X([ha("Remap F0 on interface change", ca.Boolean, "ADVANCED")], t.prototype, "remapF0OnInterfaceChange", void 0), t }(sa); b("BABYLON.ClearCoatBlock", By); var Uy = function (e) { function t(i) { var r = e.call(this, i, $o.Fragment) || this; return r._isUnique = !0, r.registerInput("intensity", Jo.Float, !0, $o.Fragment), r.registerInput("indexOfRefraction", Jo.Float, !0, $o.Fragment), r.registerInput("thickness", Jo.Float, !0, $o.Fragment), r.registerOutput("iridescence", Jo.Object, $o.Fragment, new bv("iridescence", r, ra.Output, t, "IridescenceBlock")), r } return W(t, e), t.prototype.initialize = function (e) { e._excludeVariableName("iridescenceOut"), e._excludeVariableName("vIridescenceParams") }, t.prototype.getClassName = function () { return "IridescenceBlock" }, Object.defineProperty(t.prototype, "intensity", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "indexOfRefraction", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "thickness", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "iridescence", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function () { if (!this.intensity.isConnected) { var e = new Ta("Iridescence intensity", $o.Fragment, Jo.Float); e.value = 1, e.output.connectTo(this.intensity); var t = new Ta("Iridescence ior", $o.Fragment, Jo.Float); t.value = 1.3, t.output.connectTo(this.indexOfRefraction); var i = new Ta("Iridescence thickness", $o.Fragment, Jo.Float); i.value = 400, i.output.connectTo(this.thickness) } }, t.prototype.prepareDefines = function (t, i, r) { e.prototype.prepareDefines.call(this, t, i, r), r.setValue("IRIDESCENCE", !0, !0), r.setValue("IRIDESCENCE_TEXTURE", !1, !0), r.setValue("IRIDESCENCE_THICKNESS_TEXTURE", !1, !0) }, t.GetCode = function (e) { var t = "", i = (null == e ? void 0 : e.intensity.isConnected) ? e.intensity.associatedVariableName : "1.", r = (null == e ? void 0 : e.indexOfRefraction.isConnected) ? e.indexOfRefraction.associatedVariableName : A_._DefaultIndexOfRefraction, n = (null == e ? void 0 : e.thickness.isConnected) ? e.thickness.associatedVariableName : A_._DefaultMaximumThickness; return t + "iridescenceOutParams iridescenceOut;\n\n #ifdef IRIDESCENCE\n iridescenceBlock(\n vec4(".concat(i, ", ").concat(r, ", 1., ").concat(n, "),\n NdotV,\n specularEnvironmentR0,\n #ifdef CLEARCOAT\n NdotVUnclamped,\n #endif\n iridescenceOut\n );\n\n float iridescenceIntensity = iridescenceOut.iridescenceIntensity;\n specularEnvironmentR0 = iridescenceOut.specularEnvironmentR0;\n #endif\n") }, t.prototype._buildBlock = function (e) { return e.target === $o.Fragment && (e.sharedData.bindableBlocks.push(this), e.sharedData.blocksWithDefines.push(this)), this }, t.prototype.serialize = function () { return e.prototype.serialize.call(this) }, t.prototype._deserialize = function (t, i, r) { e.prototype._deserialize.call(this, t, i, r) }, t }(sa); b("BABYLON.IridescenceBlock", Uy); var Vy = function (e) { function t(i) { var r = e.call(this, i, $o.Fragment) || this; return r.linkRefractionWithTransparency = !1, r.invertRefractionY = !1, r.useThicknessAsDepth = !1, r._isUnique = !0, r.registerInput("intensity", Jo.Float, !1, $o.Fragment), r.registerInput("tintAtDistance", Jo.Float, !0, $o.Fragment), r.registerInput("volumeIndexOfRefraction", Jo.Float, !0, $o.Fragment), r.registerOutput("refraction", Jo.Object, $o.Fragment, new bv("refraction", r, ra.Output, t, "RefractionBlock")), r } return W(t, e), t.prototype.initialize = function (e) { e._excludeVariableName("vRefractionPosition"), e._excludeVariableName("vRefractionSize") }, t.prototype.getClassName = function () { return "RefractionBlock" }, Object.defineProperty(t.prototype, "intensity", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tintAtDistance", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "volumeIndexOfRefraction", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "view", { get: function () { return this.viewConnectionPoint }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "refraction", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasTexture", { get: function () { return !!this._getTexture() }, enumerable: !1, configurable: !0 }), t.prototype._getTexture = function () { return this.texture ? this.texture : this._scene.environmentTexture }, t.prototype.autoConfigure = function (e) { if (!this.intensity.isConnected) { var t = new Ta("Refraction intensity", $o.Fragment, Jo.Float); t.value = 1, t.output.connectTo(this.intensity) } if (this.view && !this.view.isConnected) { var i = e.getInputBlockByPredicate((function (e) { return e.systemValue === pa.View })); i || (i = new Ta("view")).setAsSystemValue(pa.View), i.output.connectTo(this.view) } }, t.prototype.prepareDefines = function (t, i, r) { e.prototype.prepareDefines.call(this, t, i, r); var n = this._getTexture(), o = n && n.getTextureMatrix; r.setValue("SS_REFRACTION", o, !0), o && (r.setValue(this._define3DName, n.isCube, !0), r.setValue(this._defineLODRefractionAlpha, n.lodLevelInAlpha, !0), r.setValue(this._defineLinearSpecularRefraction, n.linearSpecularLOD, !0), r.setValue(this._defineOppositeZ, this._scene.useRightHandedSystem && n.isCube ? !n.invertZ : n.invertZ, !0), r.setValue("SS_LINKREFRACTIONTOTRANSPARENCY", this.linkRefractionWithTransparency, !0), r.setValue("SS_GAMMAREFRACTION", n.gammaSpace, !0), r.setValue("SS_RGBDREFRACTION", n.isRGBD, !0), r.setValue("SS_USE_LOCAL_REFRACTIONMAP_CUBIC", !!n.boundingBoxSize, !0), r.setValue("SS_USE_THICKNESS_AS_DEPTH", this.useThicknessAsDepth, !0)) }, t.prototype.isReady = function () { var e = this._getTexture(); return !(e && !e.isReadyOrNotBlocking()) }, t.prototype.bind = function (t, i, r) { var n, o, a, s; e.prototype.bind.call(this, t, i, r); var l = this._getTexture(); if (l) { l.isCube ? t.setTexture(this._cubeSamplerName, l) : t.setTexture(this._2DSamplerName, l), t.setMatrix(this._refractionMatrixName, l.getRefractionTextureMatrix()); var c = 1; l.isCube || l.depth && (c = l.depth); var u = null !== (s = null !== (o = null === (n = this.volumeIndexOfRefraction.connectInputBlock) || void 0 === n ? void 0 : n.value) && void 0 !== o ? o : null === (a = this.indexOfRefractionConnectionPoint.connectInputBlock) || void 0 === a ? void 0 : a.value) && void 0 !== s ? s : 1.5; t.setFloat4(this._vRefractionInfosName, l.level, 1 / u, c, this.invertRefractionY ? -1 : 1), t.setFloat4(this._vRefractionMicrosurfaceInfosName, l.getSize().width, l.lodGenerationScale, l.lodGenerationOffset, 1 / u); var d = l.getSize().width; if (t.setFloat2(this._vRefractionFilteringInfoName, d, h.Log2(d)), l.boundingBoxSize) { var p = l; t.setVector3("vRefractionPosition", p.boundingBoxPosition), t.setVector3("vRefractionSize", p.boundingBoxSize) } } }, t.prototype.getCode = function (e) { return e.sharedData.blockingBlocks.push(this), e.sharedData.textureBlocks.push(this), this._cubeSamplerName = e._getFreeVariableName(this.name + "CubeSampler"), e.samplers.push(this._cubeSamplerName), this._2DSamplerName = e._getFreeVariableName(this.name + "2DSampler"), e.samplers.push(this._2DSamplerName), this._define3DName = e._getFreeDefineName("SS_REFRACTIONMAP_3D"), e._samplerDeclaration += "#ifdef ".concat(this._define3DName, "\n"), e._samplerDeclaration += "uniform samplerCube ".concat(this._cubeSamplerName, ";\n"), e._samplerDeclaration += "#else\n", e._samplerDeclaration += "uniform sampler2D ".concat(this._2DSamplerName, ";\n"), e._samplerDeclaration += "#endif\n", e.sharedData.blocksWithDefines.push(this), e.sharedData.bindableBlocks.push(this), this._defineLODRefractionAlpha = e._getFreeDefineName("SS_LODINREFRACTIONALPHA"), this._defineLinearSpecularRefraction = e._getFreeDefineName("SS_LINEARSPECULARREFRACTION"), this._defineOppositeZ = e._getFreeDefineName("SS_REFRACTIONMAP_OPPOSITEZ"), this._refractionMatrixName = e._getFreeVariableName("refractionMatrix"), e._emitUniformFromString(this._refractionMatrixName, "mat4"), e._emitFunction("sampleRefraction", "\n #ifdef ".concat(this._define3DName, "\n #define sampleRefraction(s, c) textureCube(s, c)\n #else\n #define sampleRefraction(s, c) texture2D(s, c)\n #endif\n"), "//".concat(this.name)), e._emitFunction("sampleRefractionLod", "\n #ifdef ".concat(this._define3DName, "\n #define sampleRefractionLod(s, c, l) textureCubeLodEXT(s, c, l)\n #else\n #define sampleRefractionLod(s, c, l) texture2DLodEXT(s, c, l)\n #endif\n"), "//".concat(this.name)), this._vRefractionMicrosurfaceInfosName = e._getFreeVariableName("vRefractionMicrosurfaceInfos"), e._emitUniformFromString(this._vRefractionMicrosurfaceInfosName, "vec4"), this._vRefractionInfosName = e._getFreeVariableName("vRefractionInfos"), e._emitUniformFromString(this._vRefractionInfosName, "vec4"), this._vRefractionFilteringInfoName = e._getFreeVariableName("vRefractionFilteringInfo"), e._emitUniformFromString(this._vRefractionFilteringInfoName, "vec2"), e._emitUniformFromString("vRefractionPosition", "vec3"), e._emitUniformFromString("vRefractionSize", "vec3"), "" }, t.prototype._buildBlock = function (e) { return this._scene = e.sharedData.scene, this }, t.prototype._dumpPropertiesCode = function () { var t = e.prototype._dumpPropertiesCode.call(this); return this.texture && (t = this.texture.isCube ? "".concat(this._codeVariableName, '.texture = new BABYLON.CubeTexture("').concat(this.texture.name, '");\n') : "".concat(this._codeVariableName, '.texture = new BABYLON.Texture("').concat(this.texture.name, '");\n'), t += "".concat(this._codeVariableName, ".texture.coordinatesMode = ").concat(this.texture.coordinatesMode, ";\n")), t += "".concat(this._codeVariableName, ".linkRefractionWithTransparency = ").concat(this.linkRefractionWithTransparency, ";\n"), (t += "".concat(this._codeVariableName, ".invertRefractionY = ").concat(this.invertRefractionY, ";\n")) + "".concat(this._codeVariableName, ".useThicknessAsDepth = ").concat(this.useThicknessAsDepth, ";\n") }, t.prototype.serialize = function () { var t = e.prototype.serialize.call(this); return this.texture && !this.texture.isRenderTarget && (t.texture = this.texture.serialize()), t.linkRefractionWithTransparency = this.linkRefractionWithTransparency, t.invertRefractionY = this.invertRefractionY, t.useThicknessAsDepth = this.useThicknessAsDepth, t }, t.prototype._deserialize = function (t, i, r) { e.prototype._deserialize.call(this, t, i, r), t.texture && (r = 0 === t.texture.url.indexOf("data:") ? "" : r, t.texture.isCube ? this.texture = h_.Parse(t.texture, i, r) : this.texture = vo.Parse(t.texture, i, r)), this.linkRefractionWithTransparency = t.linkRefractionWithTransparency, this.invertRefractionY = t.invertRefractionY, this.useThicknessAsDepth = !!t.useThicknessAsDepth }, X([ha("Link refraction to transparency", ca.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "linkRefractionWithTransparency", void 0), X([ha("Invert refraction Y", ca.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "invertRefractionY", void 0), X([ha("Use thickness as depth", ca.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "useThicknessAsDepth", void 0), t }(sa); b("BABYLON.RefractionBlock", Vy); var ky = function (e) { function t(i) { var r = e.call(this, i, $o.Fragment) || this; return r._isUnique = !0, r.registerInput("thickness", Jo.Float, !1, $o.Fragment), r.registerInput("tintColor", Jo.Color3, !0, $o.Fragment), r.registerInput("translucencyIntensity", Jo.Float, !0, $o.Fragment), r.registerInput("translucencyDiffusionDist", Jo.Color3, !0, $o.Fragment), r.registerInput("refraction", Jo.Object, !0, $o.Fragment, new bv("refraction", r, ra.Input, Vy, "RefractionBlock")), r.registerOutput("subsurface", Jo.Object, $o.Fragment, new bv("subsurface", r, ra.Output, t, "SubSurfaceBlock")), r } return W(t, e), t.prototype.initialize = function (e) { e._excludeVariableName("subSurfaceOut"), e._excludeVariableName("vThicknessParam"), e._excludeVariableName("vTintColor"), e._excludeVariableName("vSubSurfaceIntensity") }, t.prototype.getClassName = function () { return "SubSurfaceBlock" }, Object.defineProperty(t.prototype, "thickness", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tintColor", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "translucencyIntensity", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "translucencyDiffusionDist", { get: function () { return this._inputs[3] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "refraction", { get: function () { return this._inputs[4] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subsurface", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function () { if (!this.thickness.isConnected) { var e = new Ta("SubSurface thickness", $o.Fragment, Jo.Float); e.value = 0, e.output.connectTo(this.thickness) } }, t.prototype.prepareDefines = function (t, i, r) { e.prototype.prepareDefines.call(this, t, i, r); var n = this.translucencyDiffusionDist.isConnected || this.translucencyIntensity.isConnected; r.setValue("SUBSURFACE", n || this.refraction.isConnected, !0), r.setValue("SS_TRANSLUCENCY", n, !0), r.setValue("SS_THICKNESSANDMASK_TEXTURE", !1, !0), r.setValue("SS_REFRACTIONINTENSITY_TEXTURE", !1, !0), r.setValue("SS_TRANSLUCENCYINTENSITY_TEXTURE", !1, !0), r.setValue("SS_MASK_FROM_THICKNESS_TEXTURE", !1, !0), r.setValue("SS_USE_GLTF_TEXTURES", !1, !0) }, t.GetCode = function (e, t, i, r) { var n, o, a, s, l, c, u, h, d, p, f, _, m, g, v, y, b = "", T = (null == t ? void 0 : t.thickness.isConnected) ? t.thickness.associatedVariableName : "0.", E = (null == t ? void 0 : t.tintColor.isConnected) ? t.tintColor.associatedVariableName : "vec3(1.)", S = (null == t ? void 0 : t.translucencyIntensity.isConnected) ? null == t ? void 0 : t.translucencyIntensity.associatedVariableName : "1.", x = (null == t ? void 0 : t.translucencyDiffusionDist.isConnected) ? null == t ? void 0 : t.translucencyDiffusionDist.associatedVariableName : "vec3(1.)", A = (null == t ? void 0 : t.refraction.isConnected) ? null === (n = null == t ? void 0 : t.refraction.connectedPoint) || void 0 === n ? void 0 : n.ownerBlock : null, R = (null == A ? void 0 : A.tintAtDistance.isConnected) ? A.tintAtDistance.associatedVariableName : "1.", C = (null == A ? void 0 : A.intensity.isConnected) ? A.intensity.associatedVariableName : "1.", P = (null == A ? void 0 : A.view.isConnected) ? A.view.associatedVariableName : ""; return (b += null !== (o = null == A ? void 0 : A.getCode(e)) && void 0 !== o ? o : "") + "subSurfaceOutParams subSurfaceOut;\n\n #ifdef SUBSURFACE\n vec2 vThicknessParam = vec2(0., ".concat(T, ");\n vec4 vTintColor = vec4(").concat(E, ", ").concat(R, ");\n vec3 vSubSurfaceIntensity = vec3(").concat(C, ", ").concat(S, ", 0.);\n\n subSurfaceBlock(\n vSubSurfaceIntensity,\n vThicknessParam,\n vTintColor,\n normalW,\n specularEnvironmentReflectance,\n #ifdef SS_THICKNESSANDMASK_TEXTURE\n vec4(0.),\n #endif\n #ifdef REFLECTION\n #ifdef SS_TRANSLUCENCY\n ").concat(null == i ? void 0 : i._reflectionMatrixName, ",\n #ifdef USESPHERICALFROMREFLECTIONMAP\n #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\n reflectionOut.irradianceVector,\n #endif\n #if defined(REALTIME_FILTERING)\n ").concat(null == i ? void 0 : i._cubeSamplerName, ",\n ").concat(null == i ? void 0 : i._vReflectionFilteringInfoName, ",\n #endif\n #endif\n #ifdef USEIRRADIANCEMAP\n irradianceSampler,\n #endif\n #endif\n #endif\n #if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)\n surfaceAlbedo,\n #endif\n #ifdef SS_REFRACTION\n ").concat(r, ".xyz,\n viewDirectionW,\n ").concat(P, ",\n ").concat(null !== (a = null == A ? void 0 : A._vRefractionInfosName) && void 0 !== a ? a : "", ",\n ").concat(null !== (s = null == A ? void 0 : A._refractionMatrixName) && void 0 !== s ? s : "", ",\n ").concat(null !== (l = null == A ? void 0 : A._vRefractionMicrosurfaceInfosName) && void 0 !== l ? l : "", ",\n vLightingIntensity,\n #ifdef SS_LINKREFRACTIONTOTRANSPARENCY\n alpha,\n #endif\n #ifdef ").concat(null !== (c = null == A ? void 0 : A._defineLODRefractionAlpha) && void 0 !== c ? c : "IGNORE", "\n NdotVUnclamped,\n #endif\n #ifdef ").concat(null !== (u = null == A ? void 0 : A._defineLinearSpecularRefraction) && void 0 !== u ? u : "IGNORE", "\n roughness,\n #endif\n alphaG,\n #ifdef ").concat(null !== (h = null == A ? void 0 : A._define3DName) && void 0 !== h ? h : "IGNORE", "\n ").concat(null !== (d = null == A ? void 0 : A._cubeSamplerName) && void 0 !== d ? d : "", ",\n #else\n ").concat(null !== (p = null == A ? void 0 : A._2DSamplerName) && void 0 !== p ? p : "", ",\n #endif\n #ifndef LODBASEDMICROSFURACE\n #ifdef ").concat(null !== (f = null == A ? void 0 : A._define3DName) && void 0 !== f ? f : "IGNORE", "\n ").concat(null !== (_ = null == A ? void 0 : A._cubeSamplerName) && void 0 !== _ ? _ : "", ",\n ").concat(null !== (m = null == A ? void 0 : A._cubeSamplerName) && void 0 !== m ? m : "", ",\n #else\n ").concat(null !== (g = null == A ? void 0 : A._2DSamplerName) && void 0 !== g ? g : "", ",\n ").concat(null !== (v = null == A ? void 0 : A._2DSamplerName) && void 0 !== v ? v : "", ",\n #endif\n #endif\n #ifdef ANISOTROPIC\n anisotropicOut,\n #endif\n #ifdef REALTIME_FILTERING\n ").concat(null !== (y = null == A ? void 0 : A._vRefractionFilteringInfoName) && void 0 !== y ? y : "", ",\n #endif\n #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC\n vRefractionPosition,\n vRefractionSize,\n #endif\n #endif\n #ifdef SS_TRANSLUCENCY\n ").concat(x, ",\n #endif\n subSurfaceOut\n );\n\n #ifdef SS_REFRACTION\n surfaceAlbedo = subSurfaceOut.surfaceAlbedo;\n #ifdef SS_LINKREFRACTIONTOTRANSPARENCY\n alpha = subSurfaceOut.alpha;\n #endif\n #endif\n #else\n subSurfaceOut.specularEnvironmentReflectance = specularEnvironmentReflectance;\n #endif\n") }, t.prototype._buildBlock = function (e) { return e.target === $o.Fragment && e.sharedData.blocksWithDefines.push(this), this }, t }(sa); b("BABYLON.SubSurfaceBlock", ky); var Gy = { ambientClr: ["finalAmbient", ""], diffuseDir: ["finalDiffuse", ""], specularDir: ["finalSpecularScaled", "!defined(UNLIT) && defined(SPECULARTERM)"], clearcoatDir: ["finalClearCoatScaled", "!defined(UNLIT) && defined(CLEARCOAT)"], sheenDir: ["finalSheenScaled", "!defined(UNLIT) && defined(SHEEN)"], diffuseInd: ["finalIrradiance", "!defined(UNLIT) && defined(REFLECTION)"], specularInd: ["finalRadianceScaled", "!defined(UNLIT) && defined(REFLECTION)"], clearcoatInd: ["clearcoatOut.finalClearCoatRadianceScaled", "!defined(UNLIT) && defined(REFLECTION) && defined(CLEARCOAT)"], sheenInd: ["sheenOut.finalSheenRadianceScaled", "!defined(UNLIT) && defined(REFLECTION) && defined(SHEEN) && defined(ENVIRONMENTBRDF)"], refraction: ["subSurfaceOut.finalRefraction", "!defined(UNLIT) && defined(SS_REFRACTION)"], lighting: ["finalColor.rgb", ""], shadow: ["shadow", ""], alpha: ["alpha", ""] }, zy = function (e) { function t(t) { var i = e.call(this, t, $o.VertexAndFragment) || this; return i._environmentBRDFTexture = null, i._metallicReflectanceColor = B.White(), i._metallicF0Factor = 1, i.directIntensity = 1, i.environmentIntensity = 1, i.specularIntensity = 1, i.lightFalloff = 0, i.useAlphaTest = !1, i.alphaTestCutoff = .5, i.useAlphaBlending = !1, i.useRadianceOverAlpha = !0, i.useSpecularOverAlpha = !0, i.enableSpecularAntiAliasing = !1, i.realTimeFiltering = !1, i.realTimeFilteringQuality = a.TEXTURE_FILTERING_QUALITY_LOW, i.useEnergyConservation = !0, i.useRadianceOcclusion = !0, i.useHorizonOcclusion = !0, i.unlit = !1, i.forceNormalForward = !1, i.generateOnlyFragmentCode = !1, i.debugMode = 0, i.debugLimit = 0, i.debugFactor = 1, i._isUnique = !0, i.registerInput("worldPosition", Jo.Vector4, !1, $o.Vertex), i.registerInput("worldNormal", Jo.Vector4, !1, $o.Fragment), i.registerInput("view", Jo.Matrix, !1), i.registerInput("cameraPosition", Jo.Vector3, !1, $o.Fragment), i.registerInput("perturbedNormal", Jo.Vector4, !0, $o.Fragment), i.registerInput("baseColor", Jo.Color3, !0, $o.Fragment), i.registerInput("metallic", Jo.Float, !1, $o.Fragment), i.registerInput("roughness", Jo.Float, !1, $o.Fragment), i.registerInput("ambientOcc", Jo.Float, !0, $o.Fragment), i.registerInput("opacity", Jo.Float, !0, $o.Fragment), i.registerInput("indexOfRefraction", Jo.Float, !0, $o.Fragment), i.registerInput("ambientColor", Jo.Color3, !0, $o.Fragment), i.registerInput("reflection", Jo.Object, !0, $o.Fragment, new bv("reflection", i, ra.Input, wy, "ReflectionBlock")), i.registerInput("clearcoat", Jo.Object, !0, $o.Fragment, new bv("clearcoat", i, ra.Input, By, "ClearCoatBlock")), i.registerInput("sheen", Jo.Object, !0, $o.Fragment, new bv("sheen", i, ra.Input, Fy, "SheenBlock")), i.registerInput("subsurface", Jo.Object, !0, $o.Fragment, new bv("subsurface", i, ra.Input, ky, "SubSurfaceBlock")), i.registerInput("anisotropy", Jo.Object, !0, $o.Fragment, new bv("anisotropy", i, ra.Input, Ly, "AnisotropyBlock")), i.registerInput("iridescence", Jo.Object, !0, $o.Fragment, new bv("iridescence", i, ra.Input, Uy, "IridescenceBlock")), i.registerOutput("ambientClr", Jo.Color3, $o.Fragment), i.registerOutput("diffuseDir", Jo.Color3, $o.Fragment), i.registerOutput("specularDir", Jo.Color3, $o.Fragment), i.registerOutput("clearcoatDir", Jo.Color3, $o.Fragment), i.registerOutput("sheenDir", Jo.Color3, $o.Fragment), i.registerOutput("diffuseInd", Jo.Color3, $o.Fragment), i.registerOutput("specularInd", Jo.Color3, $o.Fragment), i.registerOutput("clearcoatInd", Jo.Color3, $o.Fragment), i.registerOutput("sheenInd", Jo.Color3, $o.Fragment), i.registerOutput("refraction", Jo.Color3, $o.Fragment), i.registerOutput("lighting", Jo.Color3, $o.Fragment), i.registerOutput("shadow", Jo.Float, $o.Fragment), i.registerOutput("alpha", Jo.Float, $o.Fragment), i } return W(t, e), t._OnGenerateOnlyFragmentCodeChanged = function (e, t) { var i = e; return i.worldPosition.isConnected ? (i.generateOnlyFragmentCode = !i.generateOnlyFragmentCode, console.error("The worldPosition input must not be connected to be able to switch!"), !1) : (i._setTarget(), !0) }, t.prototype._setTarget = function () { this._setInitialTarget(this.generateOnlyFragmentCode ? $o.Fragment : $o.VertexAndFragment), this.getInputByName("worldPosition").target = this.generateOnlyFragmentCode ? $o.Fragment : $o.Vertex }, t.prototype.initialize = function (e) { e._excludeVariableName("vLightingIntensity"), e._excludeVariableName("geometricNormalW"), e._excludeVariableName("normalW"), e._excludeVariableName("faceNormal"), e._excludeVariableName("albedoOpacityOut"), e._excludeVariableName("surfaceAlbedo"), e._excludeVariableName("alpha"), e._excludeVariableName("aoOut"), e._excludeVariableName("baseColor"), e._excludeVariableName("reflectivityOut"), e._excludeVariableName("microSurface"), e._excludeVariableName("roughness"), e._excludeVariableName("NdotVUnclamped"), e._excludeVariableName("NdotV"), e._excludeVariableName("alphaG"), e._excludeVariableName("AARoughnessFactors"), e._excludeVariableName("environmentBrdf"), e._excludeVariableName("ambientMonochrome"), e._excludeVariableName("seo"), e._excludeVariableName("eho"), e._excludeVariableName("environmentRadiance"), e._excludeVariableName("irradianceVector"), e._excludeVariableName("environmentIrradiance"), e._excludeVariableName("diffuseBase"), e._excludeVariableName("specularBase"), e._excludeVariableName("preInfo"), e._excludeVariableName("info"), e._excludeVariableName("shadow"), e._excludeVariableName("finalDiffuse"), e._excludeVariableName("finalAmbient"), e._excludeVariableName("ambientOcclusionForDirectDiffuse"), e._excludeVariableName("finalColor"), e._excludeVariableName("vClipSpacePosition"), e._excludeVariableName("vDebugMode") }, t.prototype.getClassName = function () { return "PBRMetallicRoughnessBlock" }, Object.defineProperty(t.prototype, "worldPosition", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldNormal", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "view", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraPosition", { get: function () { return this._inputs[3] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "perturbedNormal", { get: function () { return this._inputs[4] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "baseColor", { get: function () { return this._inputs[5] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "metallic", { get: function () { return this._inputs[6] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "roughness", { get: function () { return this._inputs[7] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "ambientOcc", { get: function () { return this._inputs[8] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "opacity", { get: function () { return this._inputs[9] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "indexOfRefraction", { get: function () { return this._inputs[10] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "ambientColor", { get: function () { return this._inputs[11] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "reflection", { get: function () { return this._inputs[12] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "clearcoat", { get: function () { return this._inputs[13] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sheen", { get: function () { return this._inputs[14] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subsurface", { get: function () { return this._inputs[15] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "anisotropy", { get: function () { return this._inputs[16] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "iridescence", { get: function () { return this._inputs[17] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "ambientClr", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "diffuseDir", { get: function () { return this._outputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "specularDir", { get: function () { return this._outputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "clearcoatDir", { get: function () { return this._outputs[3] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sheenDir", { get: function () { return this._outputs[4] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "diffuseInd", { get: function () { return this._outputs[5] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "specularInd", { get: function () { return this._outputs[6] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "clearcoatInd", { get: function () { return this._outputs[7] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sheenInd", { get: function () { return this._outputs[8] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "refraction", { get: function () { return this._outputs[9] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "lighting", { get: function () { return this._outputs[10] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "shadow", { get: function () { return this._outputs[11] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "alpha", { get: function () { return this._outputs[12] }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function (e) { if (!this.cameraPosition.isConnected) { var t = e.getInputBlockByPredicate((function (e) { return e.systemValue === pa.CameraPosition })); t || (t = new Ta("cameraPosition")).setAsSystemValue(pa.CameraPosition), t.output.connectTo(this.cameraPosition) } if (!this.view.isConnected) { var i = e.getInputBlockByPredicate((function (e) { return e.systemValue === pa.View })); i || (i = new Ta("view")).setAsSystemValue(pa.View), i.output.connectTo(this.view) } }, t.prototype.prepareDefines = function (e, t, i) { i.setValue("PBR", !0), i.setValue("METALLICWORKFLOW", !0), i.setValue("DEBUGMODE", this.debugMode, !0), i.setValue("NORMALXYSCALE", !0), i.setValue("BUMP", this.perturbedNormal.isConnected, !0), i.setValue("LODBASEDMICROSFURACE", this._scene.getEngine().getCaps().textureLOD), i.setValue("ALBEDO", !1, !0), i.setValue("OPACITY", this.opacity.isConnected, !0), i.setValue("AMBIENT", !0, !0), i.setValue("AMBIENTINGRAYSCALE", !1, !0), i.setValue("REFLECTIVITY", !1, !0), i.setValue("AOSTOREINMETALMAPRED", !1, !0), i.setValue("METALLNESSSTOREINMETALMAPBLUE", !1, !0), i.setValue("ROUGHNESSSTOREINMETALMAPALPHA", !1, !0), i.setValue("ROUGHNESSSTOREINMETALMAPGREEN", !1, !0), this.lightFalloff === F_.LIGHTFALLOFF_STANDARD ? (i.setValue("USEPHYSICALLIGHTFALLOFF", !1), i.setValue("USEGLTFLIGHTFALLOFF", !1)) : this.lightFalloff === F_.LIGHTFALLOFF_GLTF ? (i.setValue("USEPHYSICALLIGHTFALLOFF", !1), i.setValue("USEGLTFLIGHTFALLOFF", !0)) : (i.setValue("USEPHYSICALLIGHTFALLOFF", !0), i.setValue("USEGLTFLIGHTFALLOFF", !1)); var r = this.alphaTestCutoff.toString(); i.setValue("ALPHABLEND", this.useAlphaBlending, !0), i.setValue("ALPHAFROMALBEDO", !1, !0), i.setValue("ALPHATEST", this.useAlphaTest, !0), i.setValue("ALPHATESTVALUE", r.indexOf(".") < 0 ? r + "." : r, !0), i.setValue("OPACITYRGB", !1, !0), i.setValue("RADIANCEOVERALPHA", this.useRadianceOverAlpha, !0), i.setValue("SPECULAROVERALPHA", this.useSpecularOverAlpha, !0), i.setValue("SPECULARAA", this._scene.getEngine().getCaps().standardDerivatives && this.enableSpecularAntiAliasing, !0), i.setValue("REALTIME_FILTERING", this.realTimeFiltering, !0); var n = e.getScene(); if (n.getEngine()._features.needTypeSuffixInShaderConstants ? i.setValue("NUM_SAMPLES", this.realTimeFilteringQuality + "u", !0) : i.setValue("NUM_SAMPLES", "" + this.realTimeFilteringQuality, !0), i.setValue("BRDF_V_HEIGHT_CORRELATED", !0), i.setValue("MS_BRDF_ENERGY_CONSERVATION", this.useEnergyConservation, !0), i.setValue("RADIANCEOCCLUSION", this.useRadianceOcclusion, !0), i.setValue("HORIZONOCCLUSION", this.useHorizonOcclusion, !0), i.setValue("UNLIT", this.unlit, !0), i.setValue("FORCENORMALFORWARD", this.forceNormalForward, !0), this._environmentBRDFTexture && ic.ReflectionTextureEnabled ? (i.setValue("ENVIRONMENTBRDF", !0), i.setValue("ENVIRONMENTBRDF_RGBD", this._environmentBRDFTexture.isRGBD, !0)) : (i.setValue("ENVIRONMENTBRDF", !1), i.setValue("ENVIRONMENTBRDF_RGBD", !1)), i._areImageProcessingDirty && t.imageProcessingConfiguration && t.imageProcessingConfiguration.prepareDefines(i), i._areLightsDirty) if (this.light) { var o = { needNormals: !1, needRebuild: !1, lightmapMode: !1, shadowEnabled: !1, specularEnabled: !1 }; zn.PrepareDefinesForLight(n, e, this.light, this._lightId, i, !0, o), o.needRebuild && i.rebuild() } else zn.PrepareDefinesForLights(n, e, i, !0, t.maxSimultaneousLights), i._needNormals = !0, zn.PrepareDefinesForMultiview(n, i) }, t.prototype.updateUniformsAndSamples = function (e, t, i, r) { for (var n = 0; n < t.maxSimultaneousLights && i["LIGHT" + n]; n++) { var o = e.uniforms.indexOf("vLightData" + n) >= 0; zn.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 ? zn.BindLight(this.light, this._lightId, o, e, !0) : zn.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 = v_(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 !== $o.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, { replaceStrings: [{ search: /vPositionW/g, replace: j + ".xyz" }] }), 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 += Uy.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 += By.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 += ky.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() }] }) : t.compilationString += t._emitCodeFromInclude("lightFragment", H, { repeatKey: "maxSimultaneousLights" }), t.compilationString += t._emitCodeFromInclude("pbrBlockFinalLitComponents", H), t.compilationString += "#endif\n"; var re = this.ambientColor.isConnected ? this.ambientColor.associatedVariableName : "vec3(0., 0., 0.)", ne = F_.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 < ae.length; oe++) { var se = ae[oe]; if (se.hasEndpoints) { var le = Gy[se.name]; if (le) { var ce = le[0], ue = le[1]; ue && (t.compilationString += "#if ".concat(ue, "\n")), t.compilationString += "".concat(this._declareOutput(se, t), " = ").concat(ce, ";\n"), ue && (t.compilationString += "#else\n", t.compilationString += "".concat(this._declareOutput(se, t), " = vec3(0.);\n"), t.compilationString += "#endif\n") } else console.error("There's no remapping for the ".concat(se.name, " end point! No code generated")) } } return this }, t.prototype._dumpPropertiesCode = function () { var t = e.prototype._dumpPropertiesCode.call(this); return t += "".concat(this._codeVariableName, ".lightFalloff = ").concat(this.lightFalloff, ";\n"), t += "".concat(this._codeVariableName, ".useAlphaTest = ").concat(this.useAlphaTest, ";\n"), t += "".concat(this._codeVariableName, ".alphaTestCutoff = ").concat(this.alphaTestCutoff, ";\n"), t += "".concat(this._codeVariableName, ".useAlphaBlending = ").concat(this.useAlphaBlending, ";\n"), t += "".concat(this._codeVariableName, ".useRadianceOverAlpha = ").concat(this.useRadianceOverAlpha, ";\n"), t += "".concat(this._codeVariableName, ".useSpecularOverAlpha = ").concat(this.useSpecularOverAlpha, ";\n"), t += "".concat(this._codeVariableName, ".enableSpecularAntiAliasing = ").concat(this.enableSpecularAntiAliasing, ";\n"), t += "".concat(this._codeVariableName, ".realTimeFiltering = ").concat(this.realTimeFiltering, ";\n"), t += "".concat(this._codeVariableName, ".realTimeFilteringQuality = ").concat(this.realTimeFilteringQuality, ";\n"), t += "".concat(this._codeVariableName, ".useEnergyConservation = ").concat(this.useEnergyConservation, ";\n"), t += "".concat(this._codeVariableName, ".useRadianceOcclusion = ").concat(this.useRadianceOcclusion, ";\n"), t += "".concat(this._codeVariableName, ".useHorizonOcclusion = ").concat(this.useHorizonOcclusion, ";\n"), t += "".concat(this._codeVariableName, ".unlit = ").concat(this.unlit, ";\n"), t += "".concat(this._codeVariableName, ".forceNormalForward = ").concat(this.forceNormalForward, ";\n"), t += "".concat(this._codeVariableName, ".debugMode = ").concat(this.debugMode, ";\n"), (t += "".concat(this._codeVariableName, ".debugLimit = ").concat(this.debugLimit, ";\n")) + "".concat(this._codeVariableName, ".debugFactor = ").concat(this.debugFactor, ";\n") }, t.prototype.serialize = function () { var t = e.prototype.serialize.call(this); return this.light && (t.lightId = this.light.id), t.lightFalloff = this.lightFalloff, t.useAlphaTest = this.useAlphaTest, t.alphaTestCutoff = this.alphaTestCutoff, t.useAlphaBlending = this.useAlphaBlending, t.useRadianceOverAlpha = this.useRadianceOverAlpha, t.useSpecularOverAlpha = this.useSpecularOverAlpha, t.enableSpecularAntiAliasing = this.enableSpecularAntiAliasing, t.realTimeFiltering = this.realTimeFiltering, t.realTimeFilteringQuality = this.realTimeFilteringQuality, t.useEnergyConservation = this.useEnergyConservation, t.useRadianceOcclusion = this.useRadianceOcclusion, t.useHorizonOcclusion = this.useHorizonOcclusion, t.unlit = this.unlit, t.forceNormalForward = this.forceNormalForward, t.debugMode = this.debugMode, t.debugLimit = this.debugLimit, t.debugFactor = this.debugFactor, t.generateOnlyFragmentCode = this.generateOnlyFragmentCode, t }, t.prototype._deserialize = function (t, i, r) { var n, o; e.prototype._deserialize.call(this, t, i, r), t.lightId && (this.light = i.getLightById(t.lightId)), this.lightFalloff = null !== (n = t.lightFalloff) && void 0 !== n ? n : 0, this.useAlphaTest = t.useAlphaTest, this.alphaTestCutoff = t.alphaTestCutoff, this.useAlphaBlending = t.useAlphaBlending, this.useRadianceOverAlpha = t.useRadianceOverAlpha, this.useSpecularOverAlpha = t.useSpecularOverAlpha, this.enableSpecularAntiAliasing = t.enableSpecularAntiAliasing, this.realTimeFiltering = !!t.realTimeFiltering, this.realTimeFilteringQuality = null !== (o = t.realTimeFilteringQuality) && void 0 !== o ? o : a.TEXTURE_FILTERING_QUALITY_LOW, this.useEnergyConservation = t.useEnergyConservation, this.useRadianceOcclusion = t.useRadianceOcclusion, this.useHorizonOcclusion = t.useHorizonOcclusion, this.unlit = t.unlit, this.forceNormalForward = !!t.forceNormalForward, this.debugMode = t.debugMode, this.debugLimit = t.debugLimit, this.debugFactor = t.debugFactor, this.generateOnlyFragmentCode = !!t.generateOnlyFragmentCode, this._setTarget() }, X([ha("Direct lights", ca.Float, "INTENSITY", { min: 0, max: 1, notifiers: { update: !0 } })], t.prototype, "directIntensity", void 0), X([ha("Environment lights", ca.Float, "INTENSITY", { min: 0, max: 1, notifiers: { update: !0 } })], t.prototype, "environmentIntensity", void 0), X([ha("Specular highlights", ca.Float, "INTENSITY", { min: 0, max: 1, notifiers: { update: !0 } })], t.prototype, "specularIntensity", void 0), X([ha("Light falloff", ca.List, "LIGHTING & COLORS", { notifiers: { update: !0 }, options: [{ label: "Physical", value: F_.LIGHTFALLOFF_PHYSICAL }, { label: "GLTF", value: F_.LIGHTFALLOFF_GLTF }, { label: "Standard", value: F_.LIGHTFALLOFF_STANDARD }] })], t.prototype, "lightFalloff", void 0), X([ha("Alpha Testing", ca.Boolean, "OPACITY")], t.prototype, "useAlphaTest", void 0), X([ha("Alpha CutOff", ca.Float, "OPACITY", { min: 0, max: 1, notifiers: { update: !0 } })], t.prototype, "alphaTestCutoff", void 0), X([ha("Alpha blending", ca.Boolean, "OPACITY")], t.prototype, "useAlphaBlending", void 0), X([ha("Radiance over alpha", ca.Boolean, "RENDERING", { notifiers: { update: !0 } })], t.prototype, "useRadianceOverAlpha", void 0), X([ha("Specular over alpha", ca.Boolean, "RENDERING", { notifiers: { update: !0 } })], t.prototype, "useSpecularOverAlpha", void 0), X([ha("Specular anti-aliasing", ca.Boolean, "RENDERING", { notifiers: { update: !0 } })], t.prototype, "enableSpecularAntiAliasing", void 0), X([ha("Realtime filtering", ca.Boolean, "RENDERING", { notifiers: { update: !0 } })], t.prototype, "realTimeFiltering", void 0), X([ha("Realtime filtering quality", ca.List, "RENDERING", { notifiers: { update: !0 }, options: [{ label: "Low", value: a.TEXTURE_FILTERING_QUALITY_LOW }, { label: "Medium", value: a.TEXTURE_FILTERING_QUALITY_MEDIUM }, { label: "High", value: a.TEXTURE_FILTERING_QUALITY_HIGH }] })], t.prototype, "realTimeFilteringQuality", void 0), X([ha("Energy Conservation", ca.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "useEnergyConservation", void 0), X([ha("Radiance occlusion", ca.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "useRadianceOcclusion", void 0), X([ha("Horizon occlusion", ca.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "useHorizonOcclusion", void 0), X([ha("Unlit", ca.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "unlit", void 0), X([ha("Force normal forward", ca.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "forceNormalForward", void 0), X([ha("Generate only fragment code", ca.Boolean, "ADVANCED", { notifiers: { rebuild: !0, update: !0, onValidation: t._OnGenerateOnlyFragmentCodeChanged } })], t.prototype, "generateOnlyFragmentCode", void 0), X([ha("Debug mode", ca.List, "DEBUG", { notifiers: { update: !0 }, options: [{ label: "None", value: 0 }, { label: "Normalized position", value: 1 }, { label: "Normals", value: 2 }, { label: "Tangents", value: 3 }, { label: "Bitangents", value: 4 }, { label: "Bump Normals", value: 5 }, { label: "ClearCoat Normals", value: 8 }, { label: "ClearCoat Tangents", value: 9 }, { label: "ClearCoat Bitangents", value: 10 }, { label: "Anisotropic Normals", value: 11 }, { label: "Anisotropic Tangents", value: 12 }, { label: "Anisotropic Bitangents", value: 13 }, { label: "Env Refraction", value: 40 }, { label: "Env Reflection", value: 41 }, { label: "Env Clear Coat", value: 42 }, { label: "Direct Diffuse", value: 50 }, { label: "Direct Specular", value: 51 }, { label: "Direct Clear Coat", value: 52 }, { label: "Direct Sheen", value: 53 }, { label: "Env Irradiance", value: 54 }, { label: "Surface Albedo", value: 60 }, { label: "Reflectance 0", value: 61 }, { label: "Metallic", value: 62 }, { label: "Metallic F0", value: 71 }, { label: "Roughness", value: 63 }, { label: "AlphaG", value: 64 }, { label: "NdotV", value: 65 }, { label: "ClearCoat Color", value: 66 }, { label: "ClearCoat Roughness", value: 67 }, { label: "ClearCoat NdotV", value: 68 }, { label: "Transmittance", value: 69 }, { label: "Refraction Transmittance", value: 70 }, { label: "SEO", value: 80 }, { label: "EHO", value: 81 }, { label: "Energy Factor", value: 82 }, { label: "Specular Reflectance", value: 83 }, { label: "Clear Coat Reflectance", value: 84 }, { label: "Sheen Reflectance", value: 85 }, { label: "Luminance Over Alpha", value: 86 }, { label: "Alpha", value: 87 }] })], t.prototype, "debugMode", void 0), X([ha("Split position", ca.Float, "DEBUG", { min: -1, max: 1, notifiers: { update: !0 } })], t.prototype, "debugLimit", void 0), X([ha("Output factor", ca.Float, "DEBUG", { min: 0, max: 5, notifiers: { update: !0 } })], t.prototype, "debugFactor", void 0), t }(sa); b("BABYLON.PBRMetallicRoughnessBlock", zy); var Wy = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("left", Jo.AutoDetect), i.registerInput("right", Jo.AutoDetect), i.registerOutput("output", Jo.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), i } return W(t, e), t.prototype.getClassName = function () { return "ModBlock" }, 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) + " = mod(".concat(this.left.associatedVariableName, ", ").concat(this.right.associatedVariableName, ");\n"), this }, t }(sa); b("BABYLON.ModBlock", Wy); var Hy, Xy = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("row0", Jo.Vector4), i.registerInput("row1", Jo.Vector4), i.registerInput("row2", Jo.Vector4), i.registerInput("row3", Jo.Vector4), i.registerOutput("output", Jo.Matrix), i } return W(t, e), t.prototype.getClassName = function () { return "MatrixBuilder" }, Object.defineProperty(t.prototype, "row0", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "row1", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "row2", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "row3", { 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.autoConfigure = function () { if (!this.row0.isConnected) { var e = new Ta("row0"); e.value = new C(1, 0, 0, 0), e.output.connectTo(this.row0) } if (!this.row1.isConnected) { var t = new Ta("row1"); t.value = new C(0, 1, 0, 0), t.output.connectTo(this.row1) } if (!this.row2.isConnected) { var i = new Ta("row2"); i.value = new C(0, 0, 1, 0), i.output.connectTo(this.row2) } if (!this.row3.isConnected) { var r = new Ta("row3"); r.value = new C(0, 0, 0, 1), r.output.connectTo(this.row3) } }, t.prototype._buildBlock = function (t) { e.prototype._buildBlock.call(this, t); var i = this._outputs[0], r = this.row0, n = this.row1, o = this.row2, a = this.row3; return t.compilationString += this._declareOutput(i, t) + " = mat4(".concat(r.associatedVariableName, ", ").concat(n.associatedVariableName, ", ").concat(o.associatedVariableName, ", ").concat(a.associatedVariableName, ");\n"), this }, t }(sa); b("BABYLON.MatrixBuilder", Xy), function (e) { e[e.Equal = 0] = "Equal", e[e.NotEqual = 1] = "NotEqual", e[e.LessThan = 2] = "LessThan", e[e.GreaterThan = 3] = "GreaterThan", e[e.LessOrEqual = 4] = "LessOrEqual", e[e.GreaterOrEqual = 5] = "GreaterOrEqual", e[e.Xor = 6] = "Xor", e[e.Or = 7] = "Or", e[e.And = 8] = "And" }(Hy || (Hy = {})); var jy = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.condition = Hy.LessThan, i.registerInput("a", Jo.Float), i.registerInput("b", Jo.Float), i.registerInput("true", Jo.AutoDetect, !0), i.registerInput("false", Jo.AutoDetect, !0), i.registerOutput("output", Jo.BasedOnInput), i._linkConnectionTypes(2, 3), i._outputs[0]._typeConnectionSource = i._inputs[2], i._outputs[0]._defaultConnectionPointType = Jo.Float, i } return W(t, e), t.prototype.getClassName = function () { return "ConditionalBlock" }, Object.defineProperty(t.prototype, "a", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "b", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "true", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "false", { 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._buildBlock = function (t) { e.prototype._buildBlock.call(this, t); var i = this._outputs[0], r = this.true.isConnected ? this.true.associatedVariableName : "1.0", n = this.false.isConnected ? this.false.associatedVariableName : "0.0"; switch (this.condition) { case Hy.Equal: t.compilationString += this._declareOutput(i, t) + " = ".concat(this.a.associatedVariableName, " == ").concat(this.b.associatedVariableName, " ? ").concat(r, " : ").concat(n, ";\n"); break; case Hy.NotEqual: t.compilationString += this._declareOutput(i, t) + " = ".concat(this.a.associatedVariableName, " != ").concat(this.b.associatedVariableName, " ? ").concat(r, " : ").concat(n, ";\n"); break; case Hy.LessThan: t.compilationString += this._declareOutput(i, t) + " = ".concat(this.a.associatedVariableName, " < ").concat(this.b.associatedVariableName, " ? ").concat(r, " : ").concat(n, ";\n"); break; case Hy.LessOrEqual: t.compilationString += this._declareOutput(i, t) + " = ".concat(this.a.associatedVariableName, " <= ").concat(this.b.associatedVariableName, " ? ").concat(r, " : ").concat(n, ";\n"); break; case Hy.GreaterThan: t.compilationString += this._declareOutput(i, t) + " = ".concat(this.a.associatedVariableName, " > ").concat(this.b.associatedVariableName, " ? ").concat(r, " : ").concat(n, ";\n"); break; case Hy.GreaterOrEqual: t.compilationString += this._declareOutput(i, t) + " = ".concat(this.a.associatedVariableName, " >= ").concat(this.b.associatedVariableName, " ? ").concat(r, " : ").concat(n, ";\n"); break; case Hy.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 Hy.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 Hy.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(Hy[this.condition], ";\n") }, t }(sa); b("BABYLON.ConditionalBlock", jy); var Yy = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.octaves = 6, i.registerInput("seed", Jo.AutoDetect), i.registerInput("chaos", Jo.AutoDetect, !0), i.registerInput("offsetX", Jo.Float, !0), i.registerInput("offsetY", Jo.Float, !0), i.registerInput("offsetZ", Jo.Float, !0), i.registerOutput("output", Jo.Float), i._inputs[0].acceptedConnectionPointTypes.push(Jo.Vector2), i._inputs[0].acceptedConnectionPointTypes.push(Jo.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) === Jo.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) === Jo.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([ha("Octaves", ca.Int)], t.prototype, "octaves", void 0), t }(sa); b("BABYLON.CloudBlock", Yy); var Ky = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("seed", Jo.Vector2), i.registerInput("offset", Jo.Float), i.registerInput("density", Jo.Float), i.registerOutput("output", Jo.Float), i.registerOutput("cells", Jo.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 }(sa); b("BABYLON.VoronoiNoiseBlock", Ky); var Qy = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("input", Jo.AutoDetect), i.registerOutput("output", Jo.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 !== $o.VertexAndFragment) return t.target; if (e.connectedPoint.target !== $o.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 }(sa); b("BABYLON.ElbowBlock", Qy); var qy = function (e) { function t(t, i) { void 0 === i && (i = !1); var r = e.call(this, t, $o.Neutral) || this; return r.projectAsCube = !1, r._convertToGammaSpace = !1, r._convertToLinearSpace = !1, r.disableLevelMultiplication = !1, r.registerInput("position", Jo.AutoDetect, !1), r.registerInput("normal", Jo.AutoDetect, !1), r.registerInput("sharpness", Jo.Float, !0), r.registerInput("source", Jo.Object, !0, $o.VertexAndFragment, new bv("source", r, ra.Input, kv, "ImageSourceBlock")), r.registerInput("sourceY", Jo.Object, !0, $o.VertexAndFragment, new bv("sourceY", r, ra.Input, kv, "ImageSourceBlock")), i || r.registerInput("sourceZ", Jo.Object, !0, $o.VertexAndFragment, new bv("sourceZ", r, ra.Input, kv, "ImageSourceBlock")), r.registerOutput("rgba", Jo.Color4, $o.Neutral), r.registerOutput("rgb", Jo.Color3, $o.Neutral), r.registerOutput("r", Jo.Float, $o.Neutral), r.registerOutput("g", Jo.Float, $o.Neutral), r.registerOutput("b", Jo.Float, $o.Neutral), r.registerOutput("a", Jo.Float, $o.Neutral), r.registerOutput("level", Jo.Float, $o.Neutral), r._inputs[0].addExcludedConnectionPointFromAllowedTypes(Jo.Color3 | Jo.Vector3 | Jo.Vector4), r._inputs[1].addExcludedConnectionPointFromAllowedTypes(Jo.Color3 | Jo.Vector3 | Jo.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 < n.length; r++) { var o = n[r]; o.hasEndpoints && "level" !== o.name && this._writeOutput(t, o, o.name) } return this }, t.prototype._dumpPropertiesCode = function () { var t = e.prototype._dumpPropertiesCode.call(this); return t += "".concat(this._codeVariableName, ".convertToGammaSpace = ").concat(this.convertToGammaSpace, ";\n"), t += "".concat(this._codeVariableName, ".convertToLinearSpace = ").concat(this.convertToLinearSpace, ";\n"), t += "".concat(this._codeVariableName, ".disableLevelMultiplication = ").concat(this.disableLevelMultiplication, ";\n"), t += "".concat(this._codeVariableName, ".projectAsCube = ").concat(this.projectAsCube, ";\n"), 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 t.convertToGammaSpace = this.convertToGammaSpace, t.convertToLinearSpace = this.convertToLinearSpace, t.disableLevelMultiplication = this.disableLevelMultiplication, t.projectAsCube = this.projectAsCube, this.hasImageSource || !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), this.convertToGammaSpace = t.convertToGammaSpace, this.convertToLinearSpace = !!t.convertToLinearSpace, this.disableLevelMultiplication = !!t.disableLevelMultiplication, this.projectAsCube = !!t.projectAsCube, t.texture && !ss.IgnoreTexturesAtLoadTime && void 0 !== t.texture.url && (r = 0 === t.texture.url.indexOf("data:") ? "" : r, this.texture = vo.Parse(t.texture, i, r)) }, X([ha("Project as cube", ca.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "projectAsCube", void 0), t }(sa); b("BABYLON.TriPlanarBlock", qy); var Zy = function (e) { function t(t) { return e.call(this, t, !0) || this } return W(t, e), t.prototype.getClassName = function () { return "BiPlanarBlock" }, t.prototype._generateTextureLookup = function (e) { var t, i = this.samplerName, r = null !== (t = this.samplerYName) && void 0 !== t ? t : this.samplerName, n = this.sharpness.isConnected ? this.sharpness.associatedVariableName : "1.0", o = e._getFreeVariableName("dpdx"), a = e._getFreeVariableName("dpdy"), s = e._getFreeVariableName("n"), l = e._getFreeVariableName("ma"), c = e._getFreeVariableName("mi"), u = e._getFreeVariableName("me"), h = e._getFreeVariableName("x"), d = e._getFreeVariableName("y"), p = e._getFreeVariableName("y"); e.compilationString += "\n // grab coord derivatives for texturing\n vec3 ".concat(o, " = dFdx(").concat(this.position.associatedVariableName, ".xyz);\n vec3 ").concat(a, " = dFdy(").concat(this.position.associatedVariableName, ".xyz);\n vec3 ").concat(s, " = abs(").concat(this.normal.associatedVariableName, ".xyz);\n \n // determine major axis (in x; yz are following axis)\n ivec3 ").concat(l, " = (").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 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 }(qy); b("BABYLON.BiPlanarBlock", Zy); var Jy = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("input", Jo.Matrix), i.registerOutput("output", Jo.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 }(sa); b("BABYLON.MatrixDeterminantBlock", Jy); var $y, eb = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.registerInput("input", Jo.Matrix), i.registerOutput("output", Jo.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 }(sa); b("BABYLON.MatrixTransposeBlock", eb), 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" }($y || ($y = {})); var tb, ib = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.attributeType = $y.None, i.registerInput("input", Jo.AutoDetect), i.registerInput("fallback", Jo.AutoDetect), i.registerOutput("output", Jo.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 Ta && r.isAttribute) switch (r.name) { case "color": i.attributeType = $y.VertexColor; break; case "normal": i.attributeType = $y.Normal; break; case "tangent": i.attributeType = $y.Tangent; break; case "uv": i.attributeType = $y.UV1; break; case "uv2": i.attributeType = $y.UV2; break; case "uv3": i.attributeType = $y.UV3; break; case "uv4": i.attributeType = $y.UV4; break; case "uv5": i.attributeType = $y.UV5; break; case "uv6": i.attributeType = $y.UV6 } else if (r instanceof Sv) switch (null === (t = i.input.connectedPoint) || void 0 === t ? void 0 : t.name) { case "normalOutput": i.attributeType = $y.Normal; break; case "tangentOutput": i.attributeType = $y.Tangent; break; case "uvOutput": i.attributeType = $y.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 $y.VertexColor: i = "VERTEXCOLOR_NME"; break; case $y.Normal: i = "NORMAL"; break; case $y.Tangent: i = "TANGENT"; break; case $y.UV1: i = "UV1"; break; case $y.UV2: i = "UV2"; break; case $y.UV3: i = "UV3"; break; case $y.UV4: i = "UV4"; break; case $y.UV5: i = "UV5"; break; case $y.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 : $y.None }, t.prototype._dumpPropertiesCode = function () { return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".attributeType = ").concat(this.attributeType, ";\n") }, X([ha("Attribute lookup", ca.List, void 0, { notifiers: { update: !0 }, options: [{ label: "(None)", value: $y.None }, { label: "Normal", value: $y.Normal }, { label: "Tangent", value: $y.Tangent }, { label: "Vertex Color", value: $y.VertexColor }, { label: "UV1", value: $y.UV1 }, { label: "UV2", value: $y.UV2 }, { label: "UV3", value: $y.UV3 }, { label: "UV4", value: $y.UV4 }, { label: "UV5", value: $y.UV5 }, { label: "UV6", value: $y.UV6 }] })], t.prototype, "attributeType", void 0), t }(sa); b("BABYLON.MeshAttributeExistsBlock", ib), 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" }(tb || (tb = {})); var rb = function (e) { function t(t) { var i = e.call(this, t, $o.Neutral) || this; return i.type = tb.EaseInOutSine, i.registerInput("input", Jo.AutoDetect), i.registerOutput("output", Jo.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._inputs[0].excludedConnectionPointTypes.push(Jo.Matrix), i._inputs[0].excludedConnectionPointTypes.push(Jo.Object), i._inputs[0].excludedConnectionPointTypes.push(Jo.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 Jo.Float: o = "float"; break; case Jo.Vector2: o = "vec2"; break; case Jo.Vector3: case Jo.Color3: o = "vec3"; break; case Jo.Vector4: case Jo.Color4: o = "vec4" }switch (i = tb[this.type] + "_" + o, this.type) { case tb.EaseInSine: n = "return 1.0 - cos((v * 3.1415) / 2.0)"; break; case tb.EaseOutSine: n = "return sin((v * 3.1415) / 2.0)"; break; case tb.EaseInOutSine: n = "return -(cos(v * 3.1415) - 1.0) / 2.0"; break; case tb.EaseInQuad: n = "return v * v"; break; case tb.EaseOutQuad: n = "return (1.0 - v) * (1.0 - v)"; break; case tb.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 tb.EaseInCubic: n = "return v * v * v"; break; case tb.EaseOutCubic: a = "1.0 - pow(1.0 - VAL, 3.0)", n = this._duplicateVector(a, o); break; case tb.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 tb.EaseInQuart: n = "return v * v * v * v"; break; case tb.EaseOutQuart: a = "1.0 - pow(1.0 - VAL, 4.0)", n = this._duplicateVector(a, o); break; case tb.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 tb.EaseInQuint: n = "return v * v * v * v * v"; break; case tb.EaseOutQuint: a = "1.0 - pow(1.0 - VAL, 5.0)", n = this._duplicateVector(a, o); break; case tb.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 tb.EaseInExpo: a = "VAL == 0.0 ? 0.0 : pow(2.0, 10.0 * VAL - 10.0)", n = this._duplicateVector(a, o); break; case tb.EaseOutExpo: a = "VAL == 1.0 ? 1.0 : 1.0 - pow(2.0, -10.0 * VAL)", n = this._duplicateVector(a, o); break; case tb.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 tb.EaseInCirc: a = "1.0 - sqrt(1.0 - pow(VAL, 2.0))", n = this._duplicateVector(a, o); break; case tb.EaseOutCirc: a = "sqrt(1.0 - pow(VAL - 1.0, 2.0))", n = this._duplicateVector(a, o); break; case tb.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 tb.EaseInBack: n = "return 2.70158 * v * v * v - 1.70158 * v * v"; break; case tb.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 tb.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 tb.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 tb.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 tb.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(tb[this.type], ";\n") }, t }(sa); b("BABYLON.CurveBlock", rb); var nb, ob, ab, sb = function () { function e() { } return e.prototype.optimize = function (e, t) { }, e }(), lb = 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 }(), cb = 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 lb, this._meshes = new Map, this._onEffectCreatedObserver = this._baseMaterial.onEffectCreatedObservable.add((function (e) { var t, i = null === (t = e.subMesh) || void 0 === t ? void 0 : t.getMesh(); i && !r._meshes.has(i) && r._meshes.set(i, i.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._subMeshToDepthWrapper.mm.delete(n)) } }))), r._subMeshToEffect.set(e.subMesh, [e.effect, r._scene.getEngine().currentRenderPassId]), r._subMeshToDepthWrapper.mm.delete(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.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 Jt(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 Jt(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: Ei() }).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(","), ")") : Vt.IncludesShadersStore.shadowMapVertexNormalBias, v = this._options && this._options.remappedVariables ? "#include(".concat(this._options.remappedVariables.join(","), ")") : Vt.IncludesShadersStore.shadowMapVertexMetric, y = this._options && this._options.remappedVariables ? "#include(".concat(this._options.remappedVariables.join(","), ")") : Vt.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow, b = Vt.IncludesShadersStore.shadowMapFragment; _ = (_ = -1 !== (_ = (_ = _.replace(/void\s+?main/g, Vt.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, Vt.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; x < h.drawWrapper.length; ++x)x !== r && (null === (a = h.drawWrapper[x]) || void 0 === a || a.setEffect(h.mainDrawWrapper.effect, h.mainDrawWrapper.defines)); return h.mainDrawWrapper.effect }, e }(), ub = function (e) { function t() { var t = null !== e && e.apply(this, arguments) || this; return t.DECAL = !1, t.DECALDIRECTUV = 0, t.DECAL_SMOOTHALPHA = !1, t.GAMMADECAL = !1, t } return W(t, e), t }(Mi), hb = function (e) { function t(t, i) { void 0 === i && (i = !0); var r = e.call(this, t, "DecalMap", 150, new ub, i) || this; return r._isEnabled = !1, r.isEnabled = !1, r._smoothAlpha = !1, r.smoothAlpha = !1, r.registerForExtraEvents = !0, 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, i, r) { var n = r.getMesh().decalMap; return !(this._isEnabled && (null == n ? void 0 : n.texture) && ic.DecalMapEnabled && t.texturesEnabled) || n.isReady() }, t.prototype.prepareDefines = function (e, t, i) { var r = i.decalMap; this._isEnabled && (null == r ? void 0 : r.texture) && ic.DecalMapEnabled && t.texturesEnabled ? ((!e.DECAL || e.GAMMADECAL !== r.texture.gammaSpace) && e.markAsTexturesDirty(), e.DECAL = !0, e.GAMMADECAL = r.texture.gammaSpace, e.DECAL_SMOOTHALPHA = this._smoothAlpha, zn.PrepareDefinesForMergedUV(r.texture, e, "DECAL")) : (e.DECAL && e.markAsTexturesDirty(), e.DECAL = !1) }, t.prototype.hardBindForSubMesh = function (e, t, i, r) { var n = r.getMesh().decalMap; if (this._isEnabled && (null == n ? void 0 : n.texture) && ic.DecalMapEnabled && t.texturesEnabled) { var o = this._material.isFrozen, a = n.texture; e.useUbo && o && e.isSync || (e.updateFloat4("vDecalInfos", a.coordinatesIndex, 0, 0, 0), zn.BindTextureMatrix(a, e, "decal")), e.setTexture("decalSampler", a) } }, t.prototype.getClassName = function () { return "DecalMapConfiguration" }, t.prototype.getSamplers = function (e) { e.push("decalSampler") }, t.prototype.getUniforms = function () { return { ubo: [{ name: "vDecalInfos", size: 4, type: "vec4" }, { name: "decalMatrix", size: 16, type: "mat4" }] } }, X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isEnabled", void 0), X([xe(), Se("_markAllSubMeshesAsTexturesDirty")], t.prototype, "smoothAlpha", void 0), t }(hc); function db(e) { return e instanceof F_ ? new C_(e) : null } function pb(e) { return e instanceof F_ ? new T_(e) : null } function fb(e) { return e instanceof F_ ? new S_(e) : null } function _b(e) { return e instanceof F_ ? new A_(e) : null } function mb(e) { return e instanceof F_ ? new I_(e) : null } function gb(e) { return e instanceof F_ ? new O_(e) : null } function vb(e) { return e instanceof F_ || e instanceof mc ? new pc(e) : null } b("BABYLON.DecalMapConfiguration", hb), function (e) { e[e.MATERIAL_TYPE_STANDARD = 0] = "MATERIAL_TYPE_STANDARD", e[e.MATERIAL_TYPE_PBR = 1] = "MATERIAL_TYPE_PBR", e[e.MATERIAL_TYPE_SIMPLE = 2] = "MATERIAL_TYPE_SIMPLE" }(nb || (nb = {})), function (e) { e[e.COLOR_MODE_SET = 0] = "COLOR_MODE_SET", e[e.COLOR_MODE_ADD = 1] = "COLOR_MODE_ADD", e[e.COLOR_MODE_MULTIPLY = 2] = "COLOR_MODE_MULTIPLY" }(ob || (ob = {})), function (e) { e[e.COLOR_DISTRIBUTION_TYPE_SEGMENT = 0] = "COLOR_DISTRIBUTION_TYPE_SEGMENT", e[e.COLOR_DISTRIBUTION_TYPE_LINE = 1] = "COLOR_DISTRIBUTION_TYPE_LINE" }(ab || (ab = {})); var yb = function (e) { function t() { var t = null !== e && e.apply(this, arguments) || this; return t.GREASED_LINE_HAS_COLOR = !1, t.GREASED_LINE_SIZE_ATTENUATION = !1, t.GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE = !1, t.GREASED_LNE_RIGHT_HANDED_COORDINATE_SYSTEM = !1, t } return W(t, e), t }(Mi), bb = function (e) { function t(i, r, n) { var o, a, s, l, c, u, h, d, p, f, _, m, g, v, y, b, T = this; n = n || { color: t.DEFAULT_COLOR }; var E = new yb; return E.GREASED_LINE_HAS_COLOR = !!n.color, E.GREASED_LINE_SIZE_ATTENUATION = null !== (o = n.sizeAttenuation) && void 0 !== o && o, E.GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE = n.colorDistributionType === ab.COLOR_DISTRIBUTION_TYPE_LINE, E.GREASED_LNE_RIGHT_HANDED_COORDINATE_SYSTEM = r.useRightHandedSystem, (T = e.call(this, i, t.GREASED_LINE_MATERIAL_NAME, 200, E) || this)._scene = r, T._scene = null !== (a = T._scene) && void 0 !== a ? a : i.getScene(), T._engine = T._scene.getEngine(), T.visibility = null !== (s = n.visibility) && void 0 !== s ? s : 1, T.useDash = null !== (l = n.useDash) && void 0 !== l && l, T.dashRatio = null !== (c = n.dashRatio) && void 0 !== c ? c : .5, T.dashOffset = null !== (u = n.dashOffset) && void 0 !== u ? u : 0, T.width = n.width ? n.width : n.sizeAttenuation ? t.DEFAULT_WIDTH_ATTENUATED : t.DEFAULT_WIDTH, T._sizeAttenuation = null !== (h = n.sizeAttenuation) && void 0 !== h && h, T.colorMode = null !== (d = n.colorMode) && void 0 !== d ? d : ob.COLOR_MODE_SET, T._color = null !== (p = n.color) && void 0 !== p ? p : null, T.useColors = null !== (f = n.useColors) && void 0 !== f && f, T._colorsDistributionType = null !== (_ = n.colorDistributionType) && void 0 !== _ ? _ : ab.COLOR_DISTRIBUTION_TYPE_SEGMENT, T.colorsSampling = null !== (m = n.colorsSampling) && void 0 !== m ? m : Eo.NEAREST_NEAREST, T._colors = null !== (g = n.colors) && void 0 !== g ? g : null, T.dashCount = null !== (v = n.dashCount) && void 0 !== v ? v : 1, T.resolution = null !== (y = n.resolution) && void 0 !== y ? y : new A(T._engine.getRenderWidth(), T._engine.getRenderHeight()), T._colors ? T._createColorsTexture("".concat(i.name, "-colors-texture"), T._colors) : (T._color = null !== (b = T._color) && void 0 !== b ? b : t.DEFAULT_COLOR, t._PrepareEmptyColorsTexture(r)), T._engine.onDisposeObservable.add((function () { var e; null === (e = t._EmptyColorsTexture) || void 0 === e || e.dispose(), t._EmptyColorsTexture = null })), T._enable(!0), T } return W(t, e), t.prototype.getAttributes = function (e) { e.push("grl_offsets"), e.push("grl_previousAndSide"), e.push("grl_nextAndCounters"), e.push("grl_widths"), e.push("grl_colorPointers") }, t.prototype.getSamplers = function (e) { e.push("grl_colors") }, t.prototype.getActiveTextures = function (e) { this._colorsTexture && e.push(this._colorsTexture) }, t.prototype.getUniforms = function () { return { ubo: [{ name: "grl_projection", size: 16, type: "mat4" }, { name: "grl_singleColor", size: 3, type: "vec3" }, { name: "grl_aspect_resolution_lineWidth", size: 4, type: "vec4" }, { name: "grl_dashOptions", size: 4, type: "vec4" }, { name: "grl_colorMode_visibility_colorsWidth_useColors", size: 4, type: "vec4" }], vertex: "\n uniform vec4 grl_aspect_resolution_lineWidth;\n uniform mat4 grl_projection;\n ", fragment: "\n uniform vec4 grl_dashOptions;\n uniform vec4 grl_colorMode_visibility_colorsWidth_useColors;\n uniform vec3 grl_singleColor;\n " } }, Object.defineProperty(t.prototype, "isEnabled", { get: function () { return !0 }, enumerable: !1, configurable: !0 }), t.prototype.bindForSubMesh = function (e) { var i, r = this._scene.activeCamera; if (!r) throw Error("GreasedLinePluginMaterial requires an active camera."); var n = r.getProjectionMatrix(); e.updateMatrix("grl_projection", n); var o = O.Vector4[0]; o.x = this._aspect, o.y = this._resolution.x, o.z = this._resolution.y, o.w = this.width, e.updateVector4("grl_aspect_resolution_lineWidth", o); var a = O.Vector4[0]; a.x = t._BooleanToNumber(this.useDash), a.y = this._dashArray, a.z = this.dashOffset, a.w = this.dashRatio, e.updateVector4("grl_dashOptions", a); var s = O.Vector4[1]; s.x = this.colorMode, s.y = this.visibility, s.z = this._colorsTexture ? this._colorsTexture.getSize().width : 0, s.w = t._BooleanToNumber(this.useColors), e.updateVector4("grl_colorMode_visibility_colorsWidth_useColors", s), this._color && e.updateColor3("grl_singleColor", this._color), e.setTexture("grl_colors", null !== (i = this._colorsTexture) && void 0 !== i ? i : t._EmptyColorsTexture) }, t.prototype.prepareDefines = function (e, t, i) { var r; e.GREASED_LINE_HAS_COLOR = !!this._color, e.GREASED_LINE_SIZE_ATTENUATION = null !== (r = this._sizeAttenuation) && void 0 !== r && r, e.GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE = this._colorsDistributionType === ab.COLOR_DISTRIBUTION_TYPE_LINE, e.GREASED_LNE_RIGHT_HANDED_COORDINATE_SYSTEM = t.useRightHandedSystem }, t.prototype.getClassName = function () { return t.GREASED_LINE_MATERIAL_NAME }, t.prototype.getCustomCode = function (e) { return "vertex" === e ? { CUSTOM_VERTEX_DEFINITIONS: "\n attribute vec4 grl_previousAndSide;\n attribute vec4 grl_nextAndCounters;\n attribute float grl_widths;\n attribute vec3 grl_offsets;\n attribute float grl_colorPointers;\n\n varying float grlCounters;\n varying float grlColorPointer;\n\n vec2 grlFix( vec4 i, float aspect ) {\n vec2 res = i.xy / i.w;\n res.x *= aspect;\n return res;\n }\n ", CUSTOM_VERTEX_UPDATE_POSITION: "\n vec3 grlPositionOffset = grl_offsets;\n positionUpdated += grlPositionOffset;\n ", CUSTOM_VERTEX_MAIN_END: "\n\n float grlAspect = grl_aspect_resolution_lineWidth.x;\n float grlBaseWidth = grl_aspect_resolution_lineWidth.w;\n\n grlColorPointer = grl_colorPointers;\n\n vec3 grlPrevious = grl_previousAndSide.xyz;\n float grlSide = grl_previousAndSide.w;\n\n vec3 grlNext = grl_nextAndCounters.xyz;\n grlCounters = grl_nextAndCounters.w;\n\n\n mat4 grlMatrix = viewProjection * world;\n vec4 grlFinalPosition = grlMatrix * vec4( positionUpdated , 1.0 );\n vec4 grlPrevPos = grlMatrix * vec4( grlPrevious + grlPositionOffset, 1.0 );\n vec4 grlNextPos = grlMatrix * vec4( grlNext + grlPositionOffset, 1.0 );\n\n vec2 grlCurrentP = grlFix( grlFinalPosition, grlAspect );\n vec2 grlPrevP = grlFix( grlPrevPos, grlAspect );\n vec2 grlNextP = grlFix( grlNextPos, grlAspect );\n\n float grlWidth = grlBaseWidth * grl_widths;\n\n vec2 grlDir;\n if( grlNextP == grlCurrentP ) grlDir = normalize( grlCurrentP - grlPrevP );\n else if( grlPrevP == grlCurrentP ) grlDir = normalize( grlNextP - grlCurrentP );\n else {\n vec2 grlDir1 = normalize( grlCurrentP - grlPrevP );\n vec2 grlDir2 = normalize( grlNextP - grlCurrentP );\n grlDir = normalize( grlDir1 + grlDir2 );\n }\n vec4 grlNormal = vec4( -grlDir.y, grlDir.x, 0., 1. );\n #ifdef GREASED_LNE_RIGHT_HANDED_COORDINATE_SYSTEM\n grlNormal.xy *= -.5 * grlWidth;\n #else\n grlNormal.xy *= .5 * grlWidth;\n #endif\n grlNormal *= grl_projection;\n #ifdef GREASED_LINE_SIZE_ATTENUATION\n grlNormal.xy *= grlFinalPosition.w;\n grlNormal.xy /= ( vec4( grl_aspect_resolution_lineWidth.yz, 0., 1. ) * grl_projection ).xy;\n #endif\n grlFinalPosition.xy += grlNormal.xy * grlSide;\n gl_Position = grlFinalPosition;\n\n vPositionW = vec3(grlFinalPosition);\n\n ", "!gl_Position\\=viewProjection\\*worldPos;": "//" } : "fragment" === e ? { CUSTOM_FRAGMENT_DEFINITIONS: "\n varying float grlCounters;\n varying float grlColorPointer;\n uniform sampler2D grl_colors;\n ", CUSTOM_FRAGMENT_MAIN_END: "\n float grlColorMode = grl_colorMode_visibility_colorsWidth_useColors.x;\n float grlVisibility = grl_colorMode_visibility_colorsWidth_useColors.y;\n float grlColorsWidth = grl_colorMode_visibility_colorsWidth_useColors.z;\n float grlUseColors = grl_colorMode_visibility_colorsWidth_useColors.w;\n\n float grlUseDash = grl_dashOptions.x;\n float grlDashArray = grl_dashOptions.y;\n float grlDashOffset = grl_dashOptions.z;\n float grlDashRatio = grl_dashOptions.w;\n\n gl_FragColor.a *= step(grlCounters, grlVisibility);\n if( gl_FragColor.a == 0. ) discard;\n\n if(grlUseDash == 1.){\n gl_FragColor.a *= ceil(mod(grlCounters + grlDashOffset, grlDashArray) - (grlDashArray * grlDashRatio));\n if (gl_FragColor.a == 0.) discard;\n }\n\n #ifdef GREASED_LINE_HAS_COLOR\n if (grlColorMode == ".concat(ob.COLOR_MODE_SET, ".) {\n gl_FragColor.rgb = grl_singleColor;\n } else if (grlColorMode == ").concat(ob.COLOR_MODE_ADD, ".) {\n gl_FragColor.rgb += grl_singleColor;\n } else if (grlColorMode == ").concat(ob.COLOR_MODE_MULTIPLY, ".) {\n gl_FragColor.rgb *= grl_singleColor;\n }\n #else\n if (grlUseColors == 1.) {\n #ifdef GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE\n vec4 grlColor = texture2D(grl_colors, vec2(grlCounters, 0.), 0.);\n #else\n vec4 grlColor = texture2D(grl_colors, vec2(grlColorPointer/grlColorsWidth, 0.), 0.);\n #endif\n if (grlColorMode == ").concat(ob.COLOR_MODE_SET, ".) {\n gl_FragColor = grlColor;\n } else if (grlColorMode == ").concat(ob.COLOR_MODE_ADD, ".) {\n gl_FragColor += grlColor;\n } else if (grlColorMode == ").concat(ob.COLOR_MODE_MULTIPLY, ".) {\n gl_FragColor *= grlColor;\n }\n }\n #endif\n ") } : null }, t._BooleanToNumber = function (e) { return e ? 1 : 0 }, t._Color3toRGBAUint8 = function (e) { for (var t = new Uint8Array(4 * e.length), i = 0, r = 0; i < e.length; i++)t[r++] = 255 * e[i].r, t[r++] = 255 * e[i].g, t[r++] = 255 * e[i].b, t[r++] = 255; return t }, t.prototype._createColorsTexture = function (e, i) { var r = t._Color3toRGBAUint8(i); this._colorsTexture = new Eo(r, i.length, 1, In.TEXTUREFORMAT_RGBA, this._scene, !1, !0, this.colorsSampling), this._colorsTexture.name = e }, t.prototype.dispose = function () { var t; null === (t = this._colorsTexture) || void 0 === t || t.dispose(), e.prototype.dispose.call(this) }, Object.defineProperty(t.prototype, "colors", { get: function () { return this._colors }, set: function (e) { this.setColors(e) }, enumerable: !1, configurable: !0 }), t.prototype.setColors = function (e, i, r) { var n, o, a, s; void 0 === i && (i = !1), void 0 === r && (r = !1); var l = null !== (o = null === (n = this._colors) || void 0 === n ? void 0 : n.length) && void 0 !== o ? o : 0; if (this._colors = e, null !== e && 0 !== e.length) { if (!i || r) if (this._colorsTexture && l === e.length && !r) { var c = t._Color3toRGBAUint8(e); this._colorsTexture.update(c) } else null === (s = this._colorsTexture) || void 0 === s || s.dispose(), this._createColorsTexture("".concat(this._material.name, "-colors-texture"), e) } else null === (a = this._colorsTexture) || void 0 === a || a.dispose() }, t.prototype.updateLazy = function () { this._colors && this.setColors(this._colors, !1, !0) }, Object.defineProperty(t.prototype, "dashCount", { get: function () { return this._dashCount }, set: function (e) { this._dashCount = e, this._dashArray = 1 / e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sizeAttenuation", { get: function () { return this._sizeAttenuation }, set: function (e) { this._sizeAttenuation = e, this.markAllDefinesAsDirty() }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "color", { get: function () { return this.color }, set: function (e) { this.setColor(e) }, enumerable: !1, configurable: !0 }), t.prototype.setColor = function (e, t) { void 0 === t && (t = !1), null === this._color && null !== e || null !== this._color && null === e ? (this._color = e, !t && this.markAllDefinesAsDirty()) : this._color = e }, Object.defineProperty(t.prototype, "colorsDistributionType", { get: function () { return this._colorsDistributionType }, set: function (e) { this._colorsDistributionType = e, this.markAllDefinesAsDirty() }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "resolution", { get: function () { return this._resolution }, set: function (e) { this._aspect = e.x / e.y, this._resolution = e }, enumerable: !1, configurable: !0 }), t.prototype.serialize = function () { var t = e.prototype.serialize.call(this), i = { colorDistributionType: this._colorsDistributionType, colorsSampling: this.colorsSampling, colorMode: this.colorMode, dashCount: this._dashCount, dashOffset: this.dashOffset, dashRatio: this.dashRatio, resolution: this._resolution, sizeAttenuation: this._sizeAttenuation, useColors: this.useColors, useDash: this.useDash, visibility: this.visibility, width: this.width }; return this._colors && (i.colors = this._colors), this._color && (i.color = this._color), t.greasedLineMaterialOptions = i, t }, t.prototype.parse = function (i, r, n) { var o; e.prototype.parse.call(this, i, r, n); var a = i.greasedLineMaterialOptions; null === (o = this._colorsTexture) || void 0 === o || o.dispose(), a.colors ? this._createColorsTexture("".concat(this._material.name, "-colors-texture"), a.colors) : t._PrepareEmptyColorsTexture(r), a.color && this.setColor(a.color, !0), a.colorDistributionType && (this.colorsDistributionType = a.colorDistributionType), a.colorsSampling && (this.colorsSampling = a.colorsSampling), a.colorMode && (this.colorMode = a.colorMode), a.useColors && (this.useColors = a.useColors), a.visibility && (this.visibility = a.visibility), a.useDash && (this.useDash = a.useDash), a.dashCount && (this.dashCount = a.dashCount), a.dashRatio && (this.dashRatio = a.dashRatio), a.dashOffset && (this.dashOffset = a.dashOffset), a.width && (this.width = a.width), a.sizeAttenuation && (this.sizeAttenuation = a.sizeAttenuation), a.resolution && (this.resolution = a.resolution), this.markAllDefinesAsDirty() }, t._PrepareEmptyColorsTexture = function (e) { if (!this._EmptyColorsTexture) { var i = new Uint8Array(4); t._EmptyColorsTexture = new Eo(i, 1, 1, In.TEXTUREFORMAT_RGBA, e, !1, !1, Eo.NEAREST_NEAREST), t._EmptyColorsTexture.name = "grlEmptyColorsTexture" } }, t.GREASED_LINE_MATERIAL_NAME = "GreasedLinePluginMaterial", t.DEFAULT_COLOR = B.White(), t.DEFAULT_WIDTH_ATTENUATED = 1, t.DEFAULT_WIDTH = .1, t }(hc); b("BABYLON.".concat(bb.GREASED_LINE_MATERIAL_NAME), bb); var Tb, Eb = [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 Sb = 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 }(Mi), xb = 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 Sb; 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 (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 = Eb }, t.PrepareMeshForTrianglesAndVerticesMode = function (e, t) { void 0 === t && (t = !1); var i = function () { }; if (0 == e.getTotalIndices()) return i; if (t) { for (var r = e.getVerticesDataKinds(), n = e.getIndices(), o = {}, a = 0, s = r; a < s.length; a++) { var l = s[a]; o[l] = e.getVerticesData(l) } i = function () { e.setIndices(n); for (var t = 0, i = r; t < i.length; t++) { var a = i[t], s = e.getVertexBuffer(a).getStrideSize(); e.setVerticesData(a, o[a], void 0, s) } e.removeVerticesData("dbg_initialPass") } } for (var c = Array.from(e.getIndices()), u = [], h = 0; h < c.length; h += 3)u.push(c[h + 1], c[h + 2], c[h + 0]); e.setIndices(c.concat(u)), e.convertToUnIndexedMesh(), e.isUnIndexed = !1; var d = []; for (h = (c = Array.from(e.getIndices())).length / 2; h < c.length; h += 3)d.push(c[h + 1], c[h + 2], c[h + 0]); e.setIndices(c.concat(d)); var p = e.getTotalVertices(), f = p / 2, _ = new Array(p).fill(1, 0, f).fill(0, f, p); return e.setVerticesData("dbg_initialPass", _, !1, 1), i }, t._PluginCount = 0, t.MaterialColors = Eb, X([Re()], t.prototype, "_materialColor", void 0), X([xe()], t.prototype, "_isEnabled", void 0), X([xe(), Se("_markAllDefinesAsDirty")], t.prototype, "mode", void 0), X([xe(), Se("_markAllDefinesAsDirty")], t.prototype, "multiply", void 0), X([Re()], t.prototype, "shadedDiffuseColor", void 0), X([Re()], t.prototype, "shadedSpecularColor", void 0), X([xe()], t.prototype, "shadedSpecularPower", void 0), X([xe()], t.prototype, "wireframeThickness", void 0), X([Re()], t.prototype, "wireframeTrianglesColor", void 0), X([Re()], t.prototype, "wireframeVerticesColor", void 0), X([Re()], t.prototype, "vertexColor", void 0), X([xe()], t.prototype, "vertexRadius", void 0), X([xe()], t.prototype, "uvScale", void 0), X([Re()], t.prototype, "uvPrimaryColor", void 0), X([Re()], t.prototype, "uvSecondaryColor", void 0), t }(hc); b("BABYLON.MeshDebugPluginMaterial", xb), Object.defineProperty(mc.prototype, "decalMap", { get: function () { if (!this._decalMap) { if (this._uniformBufferLayoutBuilt) return null; this._decalMap = new hb(this) } return this._decalMap }, enumerable: !0, configurable: !0 }), Object.defineProperty(F_.prototype, "decalMap", { get: function () { if (!this._decalMap) { if (this._uniformBufferLayoutBuilt) return null; this._decalMap = new hb(this) } return this._decalMap }, enumerable: !0, configurable: !0 }), Object.defineProperty(Ln.prototype, "decalMap", { get: function () { return this._decalMap }, set: function (e) { this._decalMap = e }, enumerable: !0, configurable: !0 }); var Ab = function () { function e(e, t) { this.radius = e, this.theta = t } return e.prototype.getClassName = function () { return "Polar" }, e.prototype.toString = function () { return JSON.stringify(this) }, e.prototype.asArray = function () { return [this.radius, this.theta] }, e.prototype.addToRef = function (e, t) { return t.radius = this.radius + e.radius, t.theta = this.theta + e.theta, t }, e.prototype.add = function (t) { var i = new e(0, 0); return this.addToRef(t, i), i }, e.prototype.addInPlace = function (e) { return this.addToRef(e, this), this }, e.prototype.addInPlaceFromFloats = function (e, t) { return this.radius += e, this.theta += t, this }, e.prototype.subtractToRef = function (e, t) { return t.radius = this.radius - e.radius, t.theta = this.theta - e.theta, t }, e.prototype.subtract = function (t) { var i = new e(0, 0); return this.subtractToRef(t, i), i }, e.prototype.subtractInPlace = function (e) { return this.subtractToRef(e, this), this }, e.prototype.subtractFromFloatsToRef = function (e, t, i) { return i.radius = this.radius - e, i.theta = this.theta - t, i }, e.prototype.subtractFromFloats = function (t, i) { var r = new e(0, 0); return this.subtractFromFloatsToRef(t, i, r), r }, e.prototype.multiplyToRef = function (e, t) { return t.radius = this.radius * e.radius, t.theta = this.theta * e.theta, t }, e.prototype.multiply = function (t) { var i = new e(0, 0); return this.multiplyToRef(t, i), i }, e.prototype.multiplyInPlace = function (e) { return this.multiplyToRef(e, this), this }, e.prototype.divideToRef = function (e, t) { return t.radius = this.radius / e.radius, t.theta = this.theta / e.theta, t }, e.prototype.divide = function (t) { var i = new e(0, 0); return this.divideToRef(t, i), i }, e.prototype.divideInPlace = function (e) { return this.divideToRef(e, this), this }, e.prototype.clone = function () { return new e(this.radius, this.theta) }, e.prototype.copyFrom = function (e) { return this.radius = e.radius, this.theta = e.theta, this }, e.prototype.copyFromFloats = function (e, t) { return this.radius = e, this.theta = t, this }, e.prototype.scaleToRef = function (e, t) { return t.radius = this.radius * e, t.theta = this.theta * e, t }, e.prototype.scale = function (t) { var i = new e(0, 0); return this.scaleToRef(t, i), i }, e.prototype.scaleInPlace = function (e) { return this.scaleToRef(e, this), this }, e.prototype.set = function (e, t) { return this.radius = e, this.theta = t, this }, e.prototype.setAll = function (e) { return this.set(e, e), this }, e.prototype.toVector2ToRef = function (e) { var t = this.radius * Math.cos(this.theta), i = this.radius * Math.sin(this.theta); return e.set(t, i), e }, e.prototype.toVector2 = function () { var e = new A(0, 0); return this.toVector2ToRef(e) }, e.FromVector2ToRef = function (e, t) { var i = Math.sign(e.y) * Math.acos(e.x / e.length()); return t.radius = e.length(), t.theta = i, t }, e.FromVector2 = function (t) { var i = new e(0, 0); return e.FromVector2ToRef(t, i), i }, e.FromArray = function (t) { return new e(t[0], t[1]) }, e }(), Rb = function () { function e(e, t, i) { this.radius = e, this.theta = t, this.phi = i } return e.prototype.getClassName = function () { return "Spherical" }, e.prototype.toString = function () { return JSON.stringify(this) }, e.prototype.asArray = function () { return [this.radius, this.theta, this.phi] }, e.prototype.addToRef = function (e, t) { return t.radius = this.radius + e.radius, t.theta = this.theta + e.theta, t.phi = this.phi + e.phi, t }, e.prototype.add = function (t) { var i = new e(0, 0, 0); return this.addToRef(t, i), i }, e.prototype.addInPlace = function (e) { return this.addToRef(e, this), this }, e.prototype.addInPlaceFromFloats = function (e, t, i) { return this.radius += e, this.theta += t, this.phi += i, this }, e.prototype.subtractToRef = function (e, t) { return t.radius = this.radius - e.radius, t.theta = this.theta - e.theta, t.phi = this.phi - e.phi, t }, e.prototype.subtract = function (t) { var i = new e(0, 0, 0); return this.subtractToRef(t, i), i }, e.prototype.subtractInPlace = function (e) { return this.subtractToRef(e, this), this }, e.prototype.subtractFromFloatsToRef = function (e, t, i, r) { return r.radius = this.radius - e, r.theta = this.theta - t, r.phi = this.phi - i, r }, e.prototype.subtractFromFloats = function (t, i, r) { var n = new e(0, 0, 0); return this.subtractFromFloatsToRef(t, i, r, n), n }, e.prototype.multiplyToRef = function (e, t) { return t.radius = this.radius * e.radius, t.theta = this.theta * e.theta, t.phi = this.phi * e.phi, t }, e.prototype.multiply = function (t) { var i = new e(0, 0, 0); return this.multiplyToRef(t, i), i }, e.prototype.multiplyInPlace = function (e) { return this.multiplyToRef(e, this), this }, e.prototype.divideToRef = function (e, t) { return t.radius = this.radius / e.radius, t.theta = this.theta / e.theta, t.phi = this.phi / e.phi, t }, e.prototype.divide = function (t) { var i = new e(0, 0, 0); return this.divideToRef(t, i), i }, e.prototype.divideInPlace = function (e) { return this.divideToRef(e, this), this }, e.prototype.clone = function () { return new e(this.radius, this.theta, this.phi) }, e.prototype.copyFrom = function (e) { return this.radius = e.radius, this.theta = e.theta, this.phi = e.phi, this }, e.prototype.copyFromFloats = function (e, t, i) { return this.radius = e, this.theta = t, this.phi = i, this }, e.prototype.scaleToRef = function (e, t) { return t.radius = this.radius * e, t.theta = this.theta * e, t.phi = this.phi * e, t }, e.prototype.scale = function (t) { var i = new e(0, 0, 0); return this.scaleToRef(t, i), i }, e.prototype.scaleInPlace = function (e) { return this.scaleToRef(e, this), this }, e.prototype.set = function (e, t, i) { return this.radius = e, this.theta = t, this.phi = i, this }, e.prototype.setAll = function (e) { return this.set(e, e, e), this }, e.prototype.toVector3ToRef = function (e) { var t = this.radius * Math.sin(this.theta) * Math.cos(this.phi), i = this.radius * Math.cos(this.theta), r = this.radius * Math.sin(this.theta) * Math.sin(this.phi); return e.set(t, i, r), e }, e.prototype.toVector3 = function () { var e = new R(0, 0, 0); return this.toVector3ToRef(e) }, e.FromVector3ToRef = function (e, t) { return t.radius = e.length(), t.theta = Math.acos(e.y / t.radius), t.phi = Math.atan2(e.z, e.x), t }, e.FromVector3 = function (t) { var i = new e(0, 0, 0); return e.FromVector3ToRef(t, i), i }, e.FromArray = function (t) { return new e(t[0], t[1], t[2]) }, e }(); function Cb(e, t, i, r, n, o) { var a = new e.DecoderBuffer; a.Init(t, t.byteLength); var s, l, c = new e.Decoder; try { var u = c.GetEncodedGeometryType(a); switch (u) { case e.TRIANGULAR_MESH: s = new e.Mesh, l = c.DecodeBufferToMesh(a, s); break; case e.POINT_CLOUD: s = new e.PointCloud, l = c.DecodeBufferToPointCloud(a, s); break; default: throw new Error("Invalid geometry type ".concat(u)) }if (!l.ok() || !s.ptr) throw new Error(l.error_msg()); if (u === e.TRIANGULAR_MESH) { var h = 3 * s.num_faces(), d = 4 * h, p = e._malloc(d); try { c.GetTrianglesUInt32Array(s, d, p); var f = new Uint32Array(h); f.set(new Uint32Array(e.HEAPF32.buffer, p, h)), r(f) } finally { e._free(p) } } var _ = function (t, i, r) { void 0 === r && (r = 1); var o = i.num_components(), a = s.num_points(), l = a * o, u = l * Float32Array.BYTES_PER_ELEMENT, h = e._malloc(u); try { c.GetAttributeDataArrayForAllPoints(s, i, e.DT_FLOAT32, u, h); var d = new Float32Array(e.HEAPF32.buffer, h, l); if ("color" === t && 3 === o) { for (var p = new Float32Array(4 * a), f = 0, _ = 0; f < p.length; f += 4, _ += o)p[f + 0] = d[_ + 0], p[f + 1] = d[_ + 1], p[f + 2] = d[_ + 2], p[f + 3] = 1; n(t, p) } else { if ((p = new Float32Array(l)).set(new Float32Array(e.HEAPF32.buffer, h, l)), 1 !== r) for (f = 0; f < p.length; f++)p[f] = p[f] / r; n(t, p) } } finally { e._free(h) } }; if (i) for (var m in i) { var g = i[m]; _(m, c.GetAttributeByUniqueId(s, g), o && o[m] || 1) } else { var v = { position: "POSITION", normal: "NORMAL", color: "COLOR", uv: "TEX_COORD" }; for (var m in v) -1 !== (g = c.GetAttributeId(s, e[v[m]])) && _(m, c.GetAttribute(s, g)) } } finally { s && e.destroy(s), e.destroy(c), e.destroy(a) } } function Pb() { var e; onmessage = function (t) { var i = t.data; switch (i.id) { case "init": var r = i.decoder; r.url && (importScripts(r.url), e = DracoDecoderModule({ wasmBinary: r.wasmBinary })), postMessage("done"); break; case "decodeMesh": if (!e) throw new Error("Draco decoder module is not available"); e.then((function (e) { Cb(e, i.dataView, i.attributes, (function (e) { postMessage({ id: "indices", value: e }, [e.buffer]) }), (function (e, t) { postMessage({ id: e, value: t }, [t.buffer]) })), postMessage("done") })) } } } var Ib = function () { function e(t) { void 0 === t && (t = e.DefaultNumWorkers); var i = e.Configuration.decoder, r = i.wasmUrl && i.wasmBinaryUrl && "object" == typeof WebAssembly ? { url: xi.GetAbsoluteUrl(i.wasmUrl), wasmBinaryPromise: xi.LoadFileAsync(xi.GetAbsoluteUrl(i.wasmBinaryUrl)) } : { url: xi.GetAbsoluteUrl(i.fallbackUrl), wasmBinaryPromise: Promise.resolve(void 0) }; t && "function" == typeof Worker && "function" == typeof URL ? this._workerPoolPromise = r.wasmBinaryPromise.then((function (e) { var i = "".concat(Cb, "(").concat(Pb, ")()"), n = URL.createObjectURL(new Blob([i], { type: "application/javascript" })); return new Z_(t, (function () { return new Promise((function (t, i) { var o = new Worker(n), a = function (e) { o.removeEventListener("error", a), o.removeEventListener("message", s), i(e) }, s = function (e) { "done" === e.data && (o.removeEventListener("error", a), o.removeEventListener("message", s), t(o)) }; o.addEventListener("error", a), o.addEventListener("message", s), o.postMessage({ id: "init", decoder: { url: r.url, wasmBinary: e } }) })) })) })) : this._decoderModulePromise = r.wasmBinaryPromise.then((function (e) { if (!r.url) throw new Error("Draco decoder module is not available"); return xi.LoadScriptAsync(r.url).then((function () { return t = e, new Promise((function (e) { DracoDecoderModule({ wasmBinary: t }).then((function (t) { e({ module: t }) })) })); var t })) })) } return Object.defineProperty(e, "DecoderAvailable", { get: function () { var t = e.Configuration.decoder; return !!(t.wasmUrl && t.wasmBinaryUrl && "object" == typeof WebAssembly || t.fallbackUrl) }, enumerable: !1, configurable: !0 }), e.GetDefaultNumWorkers = function () { return "object" == typeof navigator && navigator.hardwareConcurrency ? Math.min(Math.floor(.5 * navigator.hardwareConcurrency), 4) : 1 }, Object.defineProperty(e, "Default", { get: function () { return e._Default || (e._Default = new e), e._Default }, enumerable: !1, configurable: !0 }), e.prototype.dispose = function () { this._workerPoolPromise && this._workerPoolPromise.then((function (e) { e.dispose() })), delete this._workerPoolPromise, delete this._decoderModulePromise }, e.prototype.whenReadyAsync = function () { return this._workerPoolPromise ? this._workerPoolPromise.then((function () { })) : this._decoderModulePromise ? this._decoderModulePromise.then((function () { })) : Promise.resolve() }, e.prototype.decodeMeshAsync = function (e, t, i) { var r = e instanceof ArrayBuffer ? new Uint8Array(e) : e; if (this._workerPoolPromise) return this._workerPoolPromise.then((function (e) { return new Promise((function (n, o) { e.push((function (e, a) { var s = new En, l = function (t) { e.removeEventListener("error", l), e.removeEventListener("message", c), o(t), a() }, c = function (t) { if ("done" === t.data) e.removeEventListener("error", l), e.removeEventListener("message", c), n(s), a(); else if ("indices" === t.data.id) s.indices = t.data.value; else { var r = i && i[t.data.id] ? i[t.data.id] : 1; if (1 !== r) for (var o = 0; o < t.data.value.length; o++)t.data.value[o] = t.data.value[o] / r; s.set(t.data.value, t.data.id) } }; e.addEventListener("error", l), e.addEventListener("message", c); var u = new Uint8Array(r.byteLength); u.set(new Uint8Array(r.buffer, r.byteOffset, r.byteLength)), e.postMessage({ id: "decodeMesh", dataView: u, attributes: t }, [u.buffer]) })) })) })); if (this._decoderModulePromise) return this._decoderModulePromise.then((function (e) { var n = new En; return Cb(e.module, r, t, (function (e) { n.indices = e }), (function (e, t) { n.set(t, e) }), i), n })); throw new Error("Draco decoder module is not available") }, e.Configuration = { decoder: { wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js", wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm", fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js" } }, e.DefaultNumWorkers = e.GetDefaultNumWorkers(), e._Default = null, e }(), Mb = function () { function e() { var t = e.Configuration.decoder; this._decoderModulePromise = xi.LoadScriptAsync(xi.GetAbsoluteUrl(t.url)).then((function () { return MeshoptDecoder.ready })) } return Object.defineProperty(e, "Default", { get: function () { return e._Default || (e._Default = new e), e._Default }, enumerable: !1, configurable: !0 }), e.prototype.dispose = function () { delete this._decoderModulePromise }, e.prototype.decodeGltfBufferAsync = function (e, t, i, r, n) { return this._decoderModulePromise.then((function () { var o = new Uint8Array(t * i); return MeshoptDecoder.decodeGltfBuffer(o, t, i, e, r, n), o })) }, e.Configuration = { decoder: { url: "https://preview.babylonjs.com/meshopt_decoder.js" } }, e._Default = null, e }(), Ob = 0, Db = function () { function e(e, t, i, r) { this.pos = e, this.normal = t, this.uv = i, this.vertColor = r } return e.prototype.clone = function () { var t, i; return new e(this.pos.clone(), this.normal.clone(), null === (t = this.uv) || void 0 === t ? void 0 : t.clone(), null === (i = this.vertColor) || void 0 === i ? void 0 : i.clone()) }, e.prototype.flip = function () { this.normal = this.normal.scale(-1) }, e.prototype.interpolate = function (t, i) { return new e(R.Lerp(this.pos, t.pos, i), R.Lerp(this.normal, t.normal, i), this.uv && t.uv ? A.Lerp(this.uv, t.uv, i) : void 0, this.vertColor && t.vertColor ? U.Lerp(this.vertColor, t.vertColor, i) : void 0) }, e }(), Nb = function () { function e(e, t) { this.normal = e, this.w = t } return e.FromPoints = function (t, i, r) { var n = r.subtract(t), o = i.subtract(t); if (0 === n.lengthSquared() || 0 === o.lengthSquared()) return null; var a = R.Normalize(R.Cross(n, o)); return new e(a, R.Dot(a, t)) }, e.prototype.clone = function () { return new e(this.normal.clone(), this.w) }, e.prototype.flip = function () { this.normal.scaleInPlace(-1), this.w = -this.w }, e.prototype.splitPolygon = function (t, i, r, n, o) { var a, s, l = 0, c = []; for (a = 0; a < t.vertices.length; a++) { var u = (s = R.Dot(this.normal, t.vertices[a].pos) - this.w) < -e.EPSILON ? 2 : s > e.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 < t.vertices.length; a++) { var p = (a + 1) % t.vertices.length, f = c[a], _ = c[p], m = t.vertices[a], g = t.vertices[p]; if (2 !== f && h.push(m), 1 !== f && d.push(2 !== f ? m.clone() : m), 3 == (f | _)) { s = (this.w - R.Dot(this.normal, m.pos)) / R.Dot(this.normal, g.pos.subtract(m.pos)); var v = m.interpolate(g, s); h.push(v), d.push(v.clone()) } } var y = void 0; h.length >= 3 && (y = new Fb(h, t.shared)).plane && n.push(y), d.length >= 3 && (y = new Fb(d, t.shared)).plane && o.push(y) } }, e.EPSILON = 1e-5, e }(), Fb = function () { function e(e, t) { this.vertices = e, this.shared = t, this.plane = Nb.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 }(), Lb = 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 < this._polygons.length; e++)this._polygons[e].flip(); this._plane && this._plane.flip(), this._front && this._front.invert(), this._back && this._back.invert(); var t = this._front; this._front = this._back, this._back = t }, e.prototype.clipPolygons = function (e) { if (!this._plane) return e.slice(); for (var t = new Array, i = new Array, r = 0; r < e.length; r++)this._plane.splitPolygon(e[r], t, i, t, i); return this._front && (t = this._front.clipPolygons(t)), i = this._back ? this._back.clipPolygons(i) : [], t.concat(i) }, e.prototype.clipTo = function (e) { this._polygons = e.clipPolygons(this._polygons), this._front && this._front.clipTo(e), this._back && this._back.clipTo(e) }, e.prototype.allPolygons = function () { var e = this._polygons.slice(); return this._front && (e = e.concat(this._front.allPolygons())), this._back && (e = e.concat(this._back.allPolygons())), e }, e.prototype.build = function (t) { if (t.length) { this._plane || (this._plane = t[0].plane.clone()); for (var i = new Array, r = new Array, n = 0; n < t.length; n++)this._plane.splitPolygon(t[n], this._polygons, this._polygons, i, r); i.length && (this._front || (this._front = new e), this._front.build(i)), r.length && (this._back || (this._back = new e), this._back.build(r)) } }, e }(), wb = function () { function e() { this._polygons = new Array } return e.FromMesh = function (t, i) { void 0 === i && (i = !1); var r, n, o, s, l, c, u, h, d, p = void 0, f = void 0, _ = new Array, m = null, g = !1; if (!(t instanceof Jn)) throw "BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh"; t.computeWorldMatrix(!0), c = t.getWorldMatrix(), u = t.position.clone(), h = t.rotation.clone(), t.rotationQuaternion && (m = t.rotationQuaternion.clone()), d = t.scaling.clone(), t.material && i && (g = t.material.sideOrientation === a.MATERIAL_ClockWiseSideOrientation); for (var v = t.getIndices(), y = t.getVerticesData(Hi.PositionKind), b = t.getVerticesData(Hi.NormalKind), T = t.getVerticesData(Hi.UVKind), E = t.getVerticesData(Hi.ColorKind), S = t.subMeshes, x = 0, C = S.length; x < C; x++)for (var M = S[x].indexStart, O = S[x].indexCount + S[x].indexStart; M < O; M += 3) { l = []; for (var D = 0; D < 3; D++) { var N = 0 === D ? M + D : g ? M + 3 - D : M + D, F = new R(b[3 * v[N]], b[3 * v[N] + 1], b[3 * v[N] + 2]); T && (p = new A(T[2 * v[N]], T[2 * v[N] + 1])), E && (f = new U(E[4 * v[N]], E[4 * v[N] + 1], E[4 * v[N] + 2], E[4 * v[N] + 3])); var L = new R(y[3 * v[N]], y[3 * v[N] + 1], y[3 * v[N] + 2]); o = R.TransformCoordinates(L, c), n = R.TransformNormal(F, c), r = new Db(o, n, p, f), l.push(r) } (s = new Fb(l, { subMeshId: x, meshId: Ob, materialIndex: S[x].materialIndex })).plane && _.push(s) } var w = e._FromPolygons(_); return w.matrix = i ? I.Identity() : c, w.position = i ? R.Zero() : u, w.rotation = i ? R.Zero() : h, w.scaling = i ? R.One() : d, w.rotationQuaternion = i && m ? P.Identity() : m, Ob++, w }, e._FromPolygons = function (t) { var i = new e; return i._polygons = t, i }, e.prototype.clone = function () { var t = new e; return t._polygons = this._polygons.map((function (e) { return e.clone() })), t.copyTransformAttributes(this), t }, e.prototype.union = function (t) { var i = new Lb(this.clone()._polygons), r = new Lb(t.clone()._polygons); return i.clipTo(r), r.clipTo(i), r.invert(), r.clipTo(i), r.invert(), i.build(r.allPolygons()), e._FromPolygons(i.allPolygons()).copyTransformAttributes(this) }, e.prototype.unionInPlace = function (e) { var t = new Lb(this._polygons), i = new Lb(e._polygons); t.clipTo(i), i.clipTo(t), i.invert(), i.clipTo(t), i.invert(), t.build(i.allPolygons()), this._polygons = t.allPolygons() }, e.prototype.subtract = function (t) { var i = new Lb(this.clone()._polygons), r = new Lb(t.clone()._polygons); return i.invert(), i.clipTo(r), r.clipTo(i), r.invert(), r.clipTo(i), r.invert(), i.build(r.allPolygons()), i.invert(), e._FromPolygons(i.allPolygons()).copyTransformAttributes(this) }, e.prototype.subtractInPlace = function (e) { var t = new Lb(this._polygons), i = new Lb(e._polygons); t.invert(), t.clipTo(i), i.clipTo(t), i.invert(), i.clipTo(t), i.invert(), t.build(i.allPolygons()), t.invert(), this._polygons = t.allPolygons() }, e.prototype.intersect = function (t) { var i = new Lb(this.clone()._polygons), r = new Lb(t.clone()._polygons); return i.invert(), r.clipTo(i), r.invert(), i.clipTo(r), r.clipTo(i), i.build(r.allPolygons()), i.invert(), e._FromPolygons(i.allPolygons()).copyTransformAttributes(this) }, e.prototype.intersectInPlace = function (e) { var t = new Lb(this._polygons), i = new Lb(e._polygons); t.invert(), i.clipTo(t), i.invert(), t.clipTo(i), i.clipTo(t), t.build(i.allPolygons()), t.invert(), this._polygons = t.allPolygons() }, e.prototype.inverse = function () { var e = this.clone(); return e.inverseInPlace(), e }, e.prototype.inverseInPlace = function () { this._polygons.map((function (e) { e.flip() })) }, e.prototype.copyTransformAttributes = function (e) { return this.matrix = e.matrix, this.position = e.position, this.rotation = e.rotation, this.scaling = e.scaling, this.rotationQuaternion = e.rotationQuaternion, this }, e.prototype.buildMeshGeometry = function (e, t, i) { var r = this.matrix.clone(); r.invert(); var n, o, a, s = new Jn(e, t), l = [], c = [], u = [], h = null, d = null, p = R.Zero(), f = R.Zero(), _ = A.Zero(), m = new U(0, 0, 0, 0), g = this._polygons, v = [0, 0, 0], y = {}, b = 0, T = {}; i && g.sort((function (e, t) { return e.shared.meshId === t.shared.meshId ? e.shared.subMeshId - t.shared.subMeshId : e.shared.meshId - t.shared.meshId })); for (var E = 0, S = g.length; E < S; E++) { T[(n = g[E]).shared.meshId] || (T[n.shared.meshId] = {}), T[n.shared.meshId][n.shared.subMeshId] || (T[n.shared.meshId][n.shared.subMeshId] = { indexStart: 1 / 0, indexEnd: -1 / 0, materialIndex: n.shared.materialIndex }), a = T[n.shared.meshId][n.shared.subMeshId]; for (var x = 2, C = n.vertices.length; x < C; x++) { v[0] = 0, v[1] = x - 1, v[2] = x; for (var P = 0; P < 3; P++) { p.copyFrom(n.vertices[v[P]].pos), f.copyFrom(n.vertices[v[P]].normal), n.vertices[v[P]].uv && (h || (h = []), _.copyFrom(n.vertices[v[P]].uv)), n.vertices[v[P]].vertColor && (d || (d = []), m.copyFrom(n.vertices[v[P]].vertColor)); var I = R.TransformCoordinates(p, r), M = R.TransformNormal(f, r); o = y[I.x + "," + I.y + "," + I.z]; var O = !1; h && h[2 * o] !== _.x && h[2 * o + 1] !== _.y && (O = !0); var D = !1; d && d[4 * o] !== m.r && d[4 * o + 1] !== m.g && d[4 * o + 2] !== m.b && d[4 * o + 3] !== m.a && (D = !0), (void 0 === o || u[3 * o] !== M.x || u[3 * o + 1] !== M.y || u[3 * o + 2] !== M.z || O || D) && (l.push(I.x, I.y, I.z), h && h.push(_.x, _.y), u.push(f.x, f.y, f.z), d && d.push(m.r, m.g, m.b, m.a), o = y[I.x + "," + I.y + "," + I.z] = l.length / 3 - 1), c.push(o), a.indexStart = Math.min(b, a.indexStart), a.indexEnd = Math.max(b, a.indexEnd), b++ } } } if (s.setVerticesData(Hi.PositionKind, l), s.setVerticesData(Hi.NormalKind, u), h && s.setVerticesData(Hi.UVKind, h), d && s.setVerticesData(Hi.ColorKind, d), s.setIndices(c, null), i) { var N = 0, F = void 0; for (var L in s.subMeshes = new Array, T) { for (var w in F = -1, T[L]) a = T[L][w], bn.CreateFromIndices(a.materialIndex + N, a.indexStart, a.indexEnd - a.indexStart + 1, s), F = Math.max(a.materialIndex, F); N += ++F } } return s }, e.prototype.toMesh = function (e, t, i, r) { void 0 === t && (t = null); var n = this.buildMeshGeometry(e, i, r); return n.material = t, n.position.copyFrom(this.position), n.rotation.copyFrom(this.rotation), this.rotationQuaternion && (n.rotationQuaternion = this.rotationQuaternion.clone()), n.scaling.copyFrom(this.scaling), n.computeWorldMatrix(!0), n }, e }(); Ut.ShadersStore.meshUVSpaceRendererVertexShader = "precision highp float;attribute vec3 position;attribute vec3 normal;attribute vec2 uv;uniform mat4 projMatrix;varying vec2 vDecalTC;\n#include\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"; Ut.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 Bb = 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 Gu("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 es(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 }(); Jn._TrailMeshParser = function (e, t) { return Vb.Parse(e, t) }; var Ub, Vb = function (e) { function t(t, i, r, n, o, a) { void 0 === n && (n = 1), void 0 === o && (o = 60), void 0 === a && (a = !0); var s = e.call(this, t, r) || this; s._sectionPolygonPointsCount = 4, s._running = !1, s._autoStart = a, s._generator = i, s.diameter = n, s._length = o, s._sectionVectors = [], s._sectionNormalVectors = []; for (var l = 0; l < s._sectionPolygonPointsCount; l++)s._sectionVectors[l] = R.Zero(), s._sectionNormalVectors[l] = R.Zero(); return s._createMesh(), s } return W(t, e), t.prototype.getClassName = function () { return "TrailMesh" }, t.prototype._createMesh = function () { var e = new En, t = [], i = [], r = [], n = R.Zero(); n = this._generator instanceof Ln && this._generator.hasBoundingInfo ? this._generator.getBoundingInfo().boundingBox.centerWorld : this._generator.position; for (var o = 2 * Math.PI / this._sectionPolygonPointsCount, a = 0; a < this._sectionPolygonPointsCount; a++)t.push(n.x + Math.cos(a * o) * this.diameter, n.y + Math.sin(a * o) * this.diameter, n.z); for (a = 1; a <= this._length; a++) { for (var s = 0; s < this._sectionPolygonPointsCount; s++)t.push(n.x + Math.cos(s * o) * this.diameter, n.y + Math.sin(s * o) * this.diameter, n.z); var l = t.length / 3 - 2 * this._sectionPolygonPointsCount; for (s = 0; s < this._sectionPolygonPointsCount - 1; s++)r.push(l + s, l + s + this._sectionPolygonPointsCount, l + s + this._sectionPolygonPointsCount + 1), r.push(l + s, l + s + this._sectionPolygonPointsCount + 1, l + s + 1); r.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount - 1 + this._sectionPolygonPointsCount, l + this._sectionPolygonPointsCount), r.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount, l) } En.ComputeNormals(t, r, i), e.positions = t, e.normals = i, e.indices = r, e.applyToMesh(this, !0), this._autoStart && this.start() }, t.prototype.start = function () { var e = this; this._running || (this._running = !0, this._beforeRenderObserver = this.getScene().onBeforeRenderObservable.add((function () { e.update() }))) }, t.prototype.stop = function () { this._beforeRenderObserver && this._running && (this._running = !1, this.getScene().onBeforeRenderObservable.remove(this._beforeRenderObserver)) }, t.prototype.update = function () { var e = this.getVerticesData(Hi.PositionKind), t = this.getVerticesData(Hi.NormalKind), i = this._generator.getWorldMatrix(); if (e && t) { for (var r = 3 * this._sectionPolygonPointsCount; r < e.length; r++)e[r - 3 * this._sectionPolygonPointsCount] = e[r] - t[r] / this._length * this.diameter; for (r = 3 * this._sectionPolygonPointsCount; r < t.length; r++)t[r - 3 * this._sectionPolygonPointsCount] = t[r]; var n = e.length - 3 * this._sectionPolygonPointsCount, o = 2 * Math.PI / this._sectionPolygonPointsCount; for (r = 0; r < this._sectionPolygonPointsCount; r++)this._sectionVectors[r].copyFromFloats(Math.cos(r * o) * this.diameter, Math.sin(r * o) * this.diameter, 0), this._sectionNormalVectors[r].copyFromFloats(Math.cos(r * o), Math.sin(r * o), 0), R.TransformCoordinatesToRef(this._sectionVectors[r], i, this._sectionVectors[r]), R.TransformNormalToRef(this._sectionNormalVectors[r], i, this._sectionNormalVectors[r]); for (r = 0; r < this._sectionPolygonPointsCount; r++)e[n + 3 * r] = this._sectionVectors[r].x, e[n + 3 * r + 1] = this._sectionVectors[r].y, e[n + 3 * r + 2] = this._sectionVectors[r].z, t[n + 3 * r] = this._sectionNormalVectors[r].x, t[n + 3 * r + 1] = this._sectionNormalVectors[r].y, t[n + 3 * r + 2] = this._sectionNormalVectors[r].z; this.updateVerticesData(Hi.PositionKind, e, !0, !1), this.updateVerticesData(Hi.NormalKind, t, !0, !1) } }, t.prototype.clone = function (e, i) { return void 0 === e && (e = ""), new t(e, void 0 === i ? this._generator : i, this.getScene(), this.diameter, this._length, this._autoStart) }, t.prototype.serialize = function (t) { e.prototype.serialize.call(this, t), t.generatorId = this._generator.id }, t.Parse = function (e, i) { var r, n, o = null !== (r = i.getLastMeshById(e.generatorId)) && void 0 !== r ? r : i.getLastTransformNodeById(e.generatorId); if (!o) throw new Error("TrailMesh: generator not found with ID " + e.generatorId); return new t(e.name, o, i, null !== (n = e.diameter) && void 0 !== n ? n : e._diameter, e._length, e._autoStart) }, t }(Jn), kb = function (e, t, i) { this.quality = e, this.distance = t, this.optimizeMesh = i }, Gb = function () { function e() { this.running = !1, this._simplificationArray = [] } return e.prototype.addTask = function (e) { this._simplificationArray.push(e) }, e.prototype.executeNext = function () { var e = this._simplificationArray.pop(); e ? (this.running = !0, this.runSimplification(e)) : this.running = !1 }, e.prototype.runSimplification = function (e) { var t = this; if (e.parallelProcessing) e.settings.forEach((function (i) { t._getSimplifier(e).simplify(i, (function (r) { void 0 !== i.distance && e.mesh.addLODLevel(i.distance, r), r.isVisible = !0, i.quality === e.settings[e.settings.length - 1].quality && e.successCallback && e.successCallback(), t.executeNext() })) })); else { var i = this._getSimplifier(e); Ri.Run(e.settings.length, (function (t) { var r, n; r = e.settings[t.index], n = function () { t.executeNext() }, i.simplify(r, (function (t) { void 0 !== r.distance && e.mesh.addLODLevel(r.distance, t), t.isVisible = !0, n() })) }), (function () { e.successCallback && e.successCallback(), t.executeNext() })) } }, e.prototype._getSimplifier = function (e) { return e.simplificationType, Ub.QUADRATIC, new jb(e.mesh) }, e }(); !function (e) { e[e.QUADRATIC = 0] = "QUADRATIC" }(Ub || (Ub = {})); var zb = function (e) { this._vertices = e, this.error = new Array(4), this.deleted = !1, this.isDirty = !1, this.deletePending = !1, this.borderFactor = 0 }, Wb = function () { function e(e, t) { this.position = e, this.id = t, this.isBorder = !0, this.q = new Hb, this.triangleCount = 0, this.triangleStart = 0, this.originalOffsets = [] } return e.prototype.updatePosition = function (e) { this.position.copyFrom(e) }, e }(), Hb = function () { function e(e) { this.data = new Array(10); for (var t = 0; t < 10; ++t)e && e[t] ? this.data[t] = e[t] : this.data[t] = 0 } return e.prototype.det = function (e, t, i, r, n, o, a, s, l) { return this.data[e] * this.data[n] * this.data[l] + this.data[i] * this.data[r] * this.data[s] + this.data[t] * this.data[o] * this.data[a] - this.data[i] * this.data[n] * this.data[a] - this.data[e] * this.data[o] * this.data[s] - this.data[t] * this.data[r] * this.data[l] }, e.prototype.addInPlace = function (e) { for (var t = 0; t < 10; ++t)this.data[t] += e.data[t] }, e.prototype.addArrayInPlace = function (e) { for (var t = 0; t < 10; ++t)this.data[t] += e[t] }, e.prototype.add = function (t) { for (var i = new e, r = 0; r < 10; ++r)i.data[r] = this.data[r] + t.data[r]; return i }, e.FromData = function (t, i, r, n) { return new e(e.DataFromNumbers(t, i, r, n)) }, e.DataFromNumbers = function (e, t, i, r) { return [e * e, e * t, e * i, e * r, t * t, t * i, t * r, i * i, i * r, r * r] }, e }(), Xb = function (e, t) { this.vertexId = e, this.triangleId = t }, jb = function () { function e(e) { this._mesh = e, this.syncIterations = 5e3, this.aggressiveness = 7, this.decimationIterations = 100, this.boundingBoxEpsilon = _ } return e.prototype.simplify = function (e, t) { var i = this; this._initDecimatedMesh(), Ri.Run(this._mesh.subMeshes.length, (function (t) { i._initWithMesh(t.index, (function () { i._runDecimation(e, t.index, (function () { t.executeNext() })) }), e.optimizeMesh) }), (function () { setTimeout((function () { t(i._reconstructedMesh) }), 0) })) }, e.prototype._runDecimation = function (e, t, i) { var r = this, n = ~~(this._triangles.length * e.quality), o = 0, a = this._triangles.length; Ri.Run(this.decimationIterations, (function (e) { var t, i; a - o <= n ? e.breakLoop() : (t = e.index, i = function () { e.executeNext() }, setTimeout((function () { t % 5 == 0 && r._updateMesh(0 === t); for (var e = 0; e < r._triangles.length; ++e)r._triangles[e].isDirty = !1; var s = 1e-9 * Math.pow(t + 3, r.aggressiveness); Ri.SyncAsyncForLoop(r._triangles.length, r.syncIterations, (function (e) { var t = ~~((r._triangles.length / 2 + e) % r._triangles.length), i = r._triangles[t]; if (i && !(i.error[3] > s || i.deleted || i.isDirty)) for (var n = function (e) { if (i.error[e] < s) { var t = [], n = [], a = i._vertices[e], l = i._vertices[(e + 1) % 3]; if (a.isBorder || l.isBorder) return "continue"; var c = R.Zero(); r._calculateError(a, l, c); var u = new Array; if (r._isFlipped(a, l, c, t, u)) return "continue"; if (r._isFlipped(l, a, c, n, u)) return "continue"; if (t.indexOf(!0) < 0 || n.indexOf(!0) < 0) return "continue"; var h = new Array; if (u.forEach((function (e) { -1 === h.indexOf(e) && (e.deletePending = !0, h.push(e)) })), h.length % 2 != 0) return "continue"; a.q = l.q.add(a.q), a.updatePosition(c); var d = r._references.length; o = r._updateTriangles(a, a, t, o), o = r._updateTriangles(a, l, n, o); var p = r._references.length - d; if (p <= a.triangleCount) { if (p) for (var f = 0; f < p; f++)r._references[a.triangleStart + f] = r._references[d + f] } else a.triangleStart = d; return a.triangleCount = p, "break" } }, a = 0; a < 3 && "break" !== n(a); ++a); }), i, (function () { return a - o <= n })) }), 0)) }), (function () { setTimeout((function () { r._reconstructMesh(t), i() }), 0) })) }, e.prototype._initWithMesh = function (e, t, i) { var r = this; this._vertices = [], this._triangles = []; var n = this._mesh.getVerticesData(Hi.PositionKind), o = this._mesh.getIndices(), a = this._mesh.subMeshes[e], s = [], l = a.verticesCount; Ri.SyncAsyncForLoop(l, this.syncIterations / 4 >> 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; t < r._vertices.length; ++t)if (r._vertices[t].position.equalsWithEpsilon(e, 1e-4)) return r._vertices[t]; return null }(o) || new Wb(o, r._vertices.length); l.originalOffsets.push(t), l.id === r._vertices.length && r._vertices.push(l), s.push(l.id) } }), (function () { Ri.SyncAsyncForLoop(a.indexCount / 3, r.syncIterations, (function (e) { if (o) { var t = 3 * (a.indexStart / 3 + e), i = o[t + 0], n = o[t + 1], l = o[t + 2], c = r._vertices[s[i - a.verticesStart]], u = r._vertices[s[n - a.verticesStart]], h = r._vertices[s[l - a.verticesStart]], d = new zb([c, u, h]); d.originalOffset = t, r._triangles.push(d) } }), (function () { r._init(t) })) })) }, e.prototype._init = function (e) { var t = this; Ri.SyncAsyncForLoop(this._triangles.length, this.syncIterations, (function (e) { var i = t._triangles[e]; i.normal = R.Cross(i._vertices[1].position.subtract(i._vertices[0].position), i._vertices[2].position.subtract(i._vertices[0].position)).normalize(); for (var r = 0; r < 3; r++)i._vertices[r].q.addArrayInPlace(Hb.DataFromNumbers(i.normal.x, i.normal.y, i.normal.z, -R.Dot(i.normal, i._vertices[0].position))) }), (function () { Ri.SyncAsyncForLoop(t._triangles.length, t.syncIterations, (function (e) { for (var i = t._triangles[e], r = 0; r < 3; ++r)i.error[r] = t._calculateError(i._vertices[r], i._vertices[(r + 1) % 3]); i.error[3] = Math.min(i.error[0], i.error[1], i.error[2]) }), (function () { e() })) })) }, e.prototype._reconstructMesh = function (e) { var t, i, r, n = []; for (t = 0; t < this._vertices.length; ++t)this._vertices[t].triangleCount = 0; for (t = 0; t < this._triangles.length; ++t)if (!this._triangles[t].deleted) { for (i = this._triangles[t], r = 0; r < 3; ++r)i._vertices[r].triangleCount = 1; n.push(i) } var o = this._reconstructedMesh.getVerticesData(Hi.PositionKind) || [], a = this._reconstructedMesh.getVerticesData(Hi.NormalKind) || [], s = this._reconstructedMesh.getVerticesData(Hi.UVKind) || [], l = this._reconstructedMesh.getVerticesData(Hi.ColorKind) || [], c = this._mesh.getVerticesData(Hi.NormalKind), u = this._mesh.getVerticesData(Hi.UVKind), h = this._mesh.getVerticesData(Hi.ColorKind), d = 0, p = function () { var e = f._vertices[t]; e.id = d, e.triangleCount && e.originalOffsets.forEach((function (t) { o.push(e.position.x), o.push(e.position.y), o.push(e.position.z), c && c.length && (a.push(c[3 * t]), a.push(c[3 * t + 1]), a.push(c[3 * t + 2])), u && u.length && (s.push(u[2 * t]), s.push(u[2 * t + 1])), h && h.length && (l.push(h[4 * t]), l.push(h[4 * t + 1]), l.push(h[4 * t + 2]), l.push(h[4 * t + 3])), ++d })) }, f = this; for (t = 0; t < this._vertices.length; ++t)p(); var _ = this._reconstructedMesh.getTotalIndices(), m = this._reconstructedMesh.getTotalVertices(), g = this._reconstructedMesh.subMeshes; this._reconstructedMesh.subMeshes = []; var v = this._reconstructedMesh.getIndices(), y = this._mesh.getIndices(); for (t = 0; t < n.length; ++t)i = n[t], [0, 1, 2].forEach((function (e) { var t = y[i.originalOffset + e], r = i._vertices[e].originalOffsets.indexOf(t); r < 0 && (r = 0), v.push(i._vertices[e].id + r + m) })); this._reconstructedMesh.setIndices(v), this._reconstructedMesh.setVerticesData(Hi.PositionKind, o), a.length > 0 && this._reconstructedMesh.setVerticesData(Hi.NormalKind, a), s.length > 0 && this._reconstructedMesh.setVerticesData(Hi.UVKind, s), l.length > 0 && this._reconstructedMesh.setVerticesData(Hi.ColorKind, l); var b = this._mesh.subMeshes[e]; e > 0 && (this._reconstructedMesh.subMeshes = [], g.forEach((function (e) { bn.AddToMesh(e.materialIndex, e.verticesStart, e.verticesCount, e.indexStart, e.indexCount, e.getMesh()) })), bn.AddToMesh(b.materialIndex, m, d, _, 3 * n.length, this._reconstructedMesh)) }, e.prototype._initDecimatedMesh = function () { this._reconstructedMesh = new Jn(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 < e.triangleCount; ++o) { var a = this._triangles[this._references[e.triangleStart + o].triangleId]; if (!a.deleted) { var s = this._references[e.triangleStart + o].vertexId, l = a._vertices[(s + 1) % 3], c = a._vertices[(s + 2) % 3]; if (l !== t && c !== t) { var u = l.position.subtract(i); u = u.normalize(); var h = c.position.subtract(i); if (h = h.normalize(), Math.abs(R.Dot(u, h)) > .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; o < t.triangleCount; ++o) { var a = this._references[t.triangleStart + o], s = this._triangles[a.triangleId]; s.deleted || (i[o] && s.deletePending ? (s.deleted = !0, n++) : (s._vertices[a.vertexId] = e, s.isDirty = !0, s.error[0] = this._calculateError(s._vertices[0], s._vertices[1]) + s.borderFactor / 2, s.error[1] = this._calculateError(s._vertices[1], s._vertices[2]) + s.borderFactor / 2, s.error[2] = this._calculateError(s._vertices[2], s._vertices[0]) + s.borderFactor / 2, s.error[3] = Math.min(s.error[0], s.error[1], s.error[2]), this._references.push(a))) } return n }, e.prototype._identifyBorder = function () { for (var e = 0; e < this._vertices.length; ++e) { var t = [], i = [], r = this._vertices[e], n = void 0; for (n = 0; n < r.triangleCount; ++n)for (var o = this._triangles[this._references[r.triangleStart + n].triangleId], a = 0; a < 3; a++) { for (var s = 0, l = o._vertices[a]; s < t.length && i[s] !== l.id;)++s; s === t.length ? (t.push(1), i.push(l.id)) : t[s]++ } for (n = 0; n < t.length; ++n)1 === t[n] ? this._vertices[i[n]].isBorder = !0 : this._vertices[i[n]].isBorder = !1 } }, e.prototype._updateMesh = function (e) { var t, i, r, n; if (void 0 === e && (e = !1), !e) { var o = []; for (t = 0; t < this._triangles.length; ++t)this._triangles[t].deleted || o.push(this._triangles[t]); this._triangles = o } for (t = 0; t < this._vertices.length; ++t)this._vertices[t].triangleCount = 0, this._vertices[t].triangleStart = 0; for (t = 0; t < this._triangles.length; ++t)for (i = this._triangles[t], r = 0; r < 3; ++r)(n = i._vertices[r]).triangleCount++; var a = 0; for (t = 0; t < this._vertices.length; ++t)this._vertices[t].triangleStart = a, a += this._vertices[t].triangleCount, this._vertices[t].triangleCount = 0; var s = new Array(3 * this._triangles.length); for (t = 0; t < this._triangles.length; ++t)for (i = this._triangles[t], r = 0; r < 3; ++r)s[(n = i._vertices[r]).triangleStart + n.triangleCount] = new Xb(r, t), n.triangleCount++; this._references = s, e && this._identifyBorder() }, e.prototype._vertexError = function (e, t) { var i = t.x, r = t.y, n = t.z; return e.data[0] * i * i + 2 * e.data[1] * i * r + 2 * e.data[2] * i * n + 2 * e.data[3] * i + e.data[4] * r * r + 2 * e.data[5] * r * n + 2 * e.data[6] * r + e.data[7] * n * n + 2 * e.data[8] * n + e.data[9] }, e.prototype._calculateError = function (e, t, i) { var r = e.q.add(t.q), n = e.isBorder && t.isBorder, o = 0, a = r.det(0, 1, 2, 1, 4, 5, 2, 5, 7); if (0 === a || n) { var s = e.position.add(t.position).divide(new R(2, 2, 2)), l = this._vertexError(r, e.position), c = this._vertexError(r, t.position), u = this._vertexError(r, s); (o = Math.min(l, c, u)) === l ? i && i.copyFrom(e.position) : o === c ? i && i.copyFrom(t.position) : i && i.copyFrom(s) } else i || (i = R.Zero()), i.x = -1 / a * r.det(1, 2, 3, 4, 5, 6, 5, 7, 8), i.y = 1 / a * r.det(0, 2, 3, 1, 5, 6, 2, 7, 8), i.z = -1 / a * r.det(0, 1, 3, 1, 4, 6, 2, 5, 8), o = this._vertexError(r, i); return o }, e }(); Object.defineProperty(Sr.prototype, "simplificationQueue", { get: function () { if (!this._simplificationQueue) { this._simplificationQueue = new Gb; var e = this._getComponent(qi.NAME_SIMPLIFICATIONQUEUE); e || (e = new Yb(this), this._addComponent(e)) } return this._simplificationQueue }, set: function (e) { this._simplificationQueue = e }, enumerable: !0, configurable: !0 }), Jn.prototype.simplify = function (e, t, i, r) { return void 0 === t && (t = !0), void 0 === i && (i = Ub.QUADRATIC), this.getScene().simplificationQueue.addTask({ settings: e, parallelProcessing: t, mesh: this, simplificationType: i, successCallback: r }), this }; var Yb = function () { function e(e) { this.name = qi.NAME_SIMPLIFICATIONQUEUE, this.scene = e } return e.prototype.register = function () { this.scene._beforeCameraUpdateStage.registerStep(qi.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE, this, this._beforeCameraUpdate) }, e.prototype.rebuild = function () { }, e.prototype.dispose = function () { }, e.prototype._beforeCameraUpdate = function () { this.scene._simplificationQueue && !this.scene._simplificationQueue.running && this.scene._simplificationQueue.executeNext() }, e }(), Kb = function () { function e() { } return e.OmitZeroLengthPredicate = function (e, t, i) { return 0 === e.lengthSquared() && 0 === t.lengthSquared() && 0 === i.lengthSquared() }, e.MeshesToLines = function (e, t) { var i = []; return e.forEach((function (e, r) { var n = e.getVerticesData(Hi.PositionKind), o = e.getIndices(); if (n && o) for (var a = 0, s = 0; a < o.length; a++) { var l = 3 * o[s++], c = 3 * o[s++], u = 3 * o[s++], h = new R(n[l], n[l + 1], n[l + 2]), d = new R(n[c], n[c + 1], n[c + 2]), p = new R(n[u], n[u + 1], n[u + 2]); if (t) { var f = t(h, d, p, a, l, e, r, n, o); f && i.push(f) } else i.push([h, d, p, h]) } })), i }, e.ToVector3Array = function (e) { for (var t = [], i = 0; i < e.length; i += 3)t.push(new R(e[i], e[i + 1], e[i + 2])); return t }, e.ToNumberArray = function (e) { return e.flatMap((function (e) { return [e.x, e.y, e.z] })) }, e.GetPointsCountInfo = function (e) { for (var t = new Array(e.length), i = 0, r = e.length; r--;)t[r] = e[r].length / 3, i += t[r]; return { total: i, counts: t } }, e.GetLineLength = function (t) { if (0 === t.length) return 0; var i; i = "number" == typeof t[0] ? e.ToVector3Array(t) : t; for (var r = O.Vector3[0], n = 0, o = 0; o < i.length - 1; o++) { var a = i[o]; n += i[o + 1].subtractToRef(a, r).length() } return n }, e.SegmentizeSegmentByCount = function (e, t, i) { var r = [], n = t.subtract(e), o = O.Vector3[0]; o.setAll(i); var a = O.Vector3[1]; n.divideToRef(o, a); var s = e.clone(); r.push(s); for (var l = 0; l < i; l++)s = s.clone(), r.push(s.addInPlace(a)); return r }, e.SegmentizeLineBySegmentLength = function (t, i) { var r = t[0] instanceof R ? e.GetLineSegments(t) : t, n = []; return r.forEach((function (t) { t.length > i ? 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 = e.GetLineLength(t) / i; return e.SegmentizeLineBySegmentLength(t, r) }, e.GetLineSegments = function (e) { for (var t = [], i = 0; i < e.length - 1; i++) { var r = e[i], n = e[i + 1], o = n.subtract(r).length(); t.push({ point1: r, point2: n, length: o }) } return t }, e.GetMinMaxSegmentLength = function (t) { var i = e.GetLineSegments(t).sort((function (e) { return e.length })); return { min: i[0].length, max: i[i.length - 1].length } }, e.GetPositionOnLineByVisibility = function (e, t, i, r) { void 0 === r && (r = !1); for (var n = t * i, o = 0, a = 0, s = e.length, l = 0; l < s; l++) { if (n <= o + e[l].length) { a = l; break } o += e[l].length } var c = (n - o) / e[a].length; return e[a].point2.subtractToRef(e[a].point1, O.Vector3[0]), O.Vector3[1] = O.Vector3[0].multiplyByFloats(c, c, c), r || O.Vector3[1].addInPlace(e[a].point1), O.Vector3[1].clone() }, e.GetCircleLinePoints = function (e, t, i, r, n) { void 0 === i && (i = 0), void 0 === r && (r = e), void 0 === n && (n = 2 * Math.PI / t); for (var o = [], a = 0; a <= t; a++)o.push(new R(Math.cos(a * n) * e, Math.sin(a * n) * r, i)); return o }, e.GetBezierLinePoints = function (e, t, i, r) { return Lr.CreateQuadraticBezier(e, t, i, r).getPoints().flatMap((function (e) { return [e.x, e.y, e.z] })) }, e.GetArrowCap = function (e, t, i, r, n, o, a) { return void 0 === o && (o = 0), void 0 === a && (a = 0), { points: [e.clone(), e.add(t.multiplyByFloats(i, i, i))], widths: [r, n, o, a] } }, e.GetPointsFromText = function (e, t, i, r, n, o) { void 0 === n && (n = 0), void 0 === o && (o = !0); for (var a = [], s = 0, l = Fh(e, t, i, r); s < l.length; s++) { for (var c = l[s], u = 0, h = c.paths; u < h.length; u++) { for (var d = [], p = 0, f = h[u].getPoints(); p < f.length; p++) { var _ = f[p]; d.push(_.x, _.y, n) } a.push(d) } if (o) for (var m = 0, g = c.holes; m < g.length; m++) { for (var v = [], y = 0, b = g[m].getPoints(); y < b.length; y++)_ = b[y], v.push(_.x, _.y, n); a.push(v) } } return a }, e }(); Ut.ShadersStore.greasedLinePixelShader = "precision highp float;uniform sampler2D grlColors;uniform float grlUseColors;uniform float grlUseDash;uniform float grlDashArray;uniform float grlDashOffset;uniform float grlDashRatio;uniform float grlVisibility;uniform float grlColorsWidth;uniform vec2 grl_colorModeAndColorDistributionType;uniform vec3 grlColor;varying float grlCounters;varying float grlColorPointer;void main() {float grlColorMode=grl_colorModeAndColorDistributionType.x;float grlColorDistributionType=grl_colorModeAndColorDistributionType.y;gl_FragColor=vec4(grlColor,1.);gl_FragColor.a=step(grlCounters,grlVisibility);if (gl_FragColor.a==0.) discard;if( grlUseDash==1. ){gl_FragColor.a=ceil(mod(grlCounters+grlDashOffset,grlDashArray)-(grlDashArray*grlDashRatio));if (gl_FragColor.a==0.) discard;}\nif (grlUseColors==1.) {vec4 textureColor;if (grlColorDistributionType==1.) { \ntextureColor=texture2D(grlColors,vec2(grlCounters,0.),0.);} else {textureColor=texture2D(grlColors,vec2(grlColorPointer/grlColorsWidth,0.),0.);}\nif (grlColorMode==0.) { \ngl_FragColor=textureColor;} else if (grlColorMode==1.) { \ngl_FragColor+=textureColor;} else if (grlColorMode==2.) { \ngl_FragColor*=textureColor;}}}\n"; Ut.ShadersStore.greasedLineVertexShader = "precision highp float;attribute vec4 grl_previousAndSide;attribute vec4 grl_nextAndCounters;attribute float grl_widths;attribute vec3 grl_offsets;attribute float grl_colorPointers;attribute vec3 position;uniform vec2 grlResolution;uniform float grlAspect;uniform float grlWidth;uniform float grlSizeAttenuation;uniform mat4 worldViewProjection;uniform mat4 projection;varying float grlCounters;varying float grlColorPointer;vec2 grlFix( vec4 i,float aspect ) {vec2 res=i.xy/i.w;res.x*=aspect;return res;}\nvoid main() {grlColorPointer=grl_colorPointers;float grlBaseWidth=grlWidth;vec3 grlPrevious=grl_previousAndSide.xyz;float grlSide=grl_previousAndSide.w;vec3 grlNext=grl_nextAndCounters.xyz;grlCounters=grl_nextAndCounters.w;mat4 grlMatrix=worldViewProjection;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_LNE_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"; var Qb = function (e) { function t(i, r, n) { var o, a, s, l, c, u, h, d, p, f, _, m, g, v = this; return (v = e.call(this, i, r, { vertex: "greasedLine", fragment: "greasedLine" }, { attributes: ["position", "normal", "grl_previousAndSide", "grl_nextAndCounters", "grl_widths", "grl_offsets", "grl_colorPointers"], uniforms: ["worldViewProjection", "projection", "grlColorsWidth", "grlUseColors", "grlWidth", "grlColor", "grl_colorModeAndColorDistributionType", "grlResolution", "grlAspect", "grlAizeAttenuation", "grlDashArray", "grlDashOffset", "grlDashRatio", "grlUseDash", "grlVisibility"], samplers: ["grlColors"], defines: r.useRightHandedSystem ? ["GREASED_LNE_RIGHT_HANDED_COORDINATE_SYSTEM"] : [] }) || this)._color = B.White(), v._colorsDistributionType = ab.COLOR_DISTRIBUTION_TYPE_SEGMENT, n = n || { color: t.DEFAULT_COLOR }, v._engine = r.getEngine(), v.visibility = null !== (o = n.visibility) && void 0 !== o ? o : 1, v.useDash = null !== (a = n.useDash) && void 0 !== a && a, v.dashRatio = null !== (s = n.dashRatio) && void 0 !== s ? s : .5, v.dashOffset = null !== (l = n.dashOffset) && void 0 !== l ? l : 0, v.dashCount = null !== (c = n.dashCount) && void 0 !== c ? c : 1, v.width = n.width ? n.width : n.sizeAttenuation ? t.DEFAULT_WIDTH_ATTENUATED : t.DEFAULT_WIDTH, v.sizeAttenuation = null !== (u = n.sizeAttenuation) && void 0 !== u && u, v.color = null !== (h = n.color) && void 0 !== h ? h : B.White(), v.useColors = null !== (d = n.useColors) && void 0 !== d && d, v.colorsDistributionType = null !== (p = n.colorDistributionType) && void 0 !== p ? p : ab.COLOR_DISTRIBUTION_TYPE_SEGMENT, v.colorsSampling = null !== (f = n.colorsSampling) && void 0 !== f ? f : Eo.NEAREST_NEAREST, v.colorMode = null !== (_ = n.colorMode) && void 0 !== _ ? _ : ob.COLOR_MODE_SET, v._colors = null !== (m = n.colors) && void 0 !== m ? m : null, v.resolution = null !== (g = n.resolution) && void 0 !== g ? g : new A(v._engine.getRenderWidth(), v._engine.getRenderHeight()), v._colors && v.setColors(v._colors), v._engine.onDisposeObservable.add((function () { var e; null === (e = t._EmptyColorsTexture) || void 0 === e || e.dispose() })), v } return W(t, e), t._BooleanToNumber = function (e) { return e ? 1 : 0 }, t._Color3toRGBAUint8 = function (e) { for (var t = new Uint8Array(4 * e.length), i = 0, r = 0; i < e.length; i++)t[r++] = 255 * e[i].r, t[r++] = 255 * e[i].g, t[r++] = 255 * e[i].b, t[r++] = 255; return t }, t.prototype._createColorsTexture = function (e, i) { var r = t._Color3toRGBAUint8(i); this._colorsTexture = new Eo(r, i.length, 1, In.TEXTUREFORMAT_RGBA, this.getScene(), !1, !0, this._colorsSampling), this._colorsTexture.name = 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, i, r) { var n, o, a, s; void 0 === i && (i = !1), void 0 === r && (r = !1); var l = null !== (o = null === (n = this._colors) || void 0 === n ? void 0 : n.length) && void 0 !== o ? o : 0; if (this._colors = e, null !== e && 0 !== e.length) { if (!i || r) { if (this._colorsTexture && l === e.length && !r) { var c = t._Color3toRGBAUint8(e); this._colorsTexture.update(c) } else null === (s = this._colorsTexture) || void 0 === s || s.dispose(), this._createColorsTexture("".concat(this.name, "-colors-texture"), e); this._colorsTexture && (this.setFloat("grlColorsWidth", this._colorsTexture.getSize().width), this.setTexture("grlColors", this._colorsTexture)) } } else null === (a = this._colorsTexture) || void 0 === a || a.dispose() }, 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", t._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", t._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", t._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 : t.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 }; return this._colors && (i.colors = this._colors), t.greasedLineMaterialOptions = i, t }, t.prototype.parse = function (e, i, r) { var n, o = e.greasedLineMaterialOptions; null === (n = this._colorsTexture) || void 0 === n || n.dispose(), o.colors ? this._createColorsTexture("".concat(this.name, "-colors-texture"), o.colors) : t._PrepareEmptyColorsTexture(i), 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) }, t._PrepareEmptyColorsTexture = function (e) { if (!this._EmptyColorsTexture) { var i = new Uint8Array(4); t._EmptyColorsTexture = new Eo(i, 1, 1, In.TEXTUREFORMAT_RGBA, e, !1, !1, Eo.NEAREST_NEAREST), t._EmptyColorsTexture.name = "grlEmptyColorsTexture" } }, t.DEFAULT_COLOR = B.White(), t.DEFAULT_WIDTH_ATTENUATED = 1, t.DEFAULT_WIDTH = .1, t }(Gu); Jn._GreasedLineMeshParser = function (e, t) { return tT.Parse(e, t) }; var qb, Zb, Jb, $b, eT, tT = function (e) { function t(i, r, n) { var o, a, s, l, c = this; return (c = e.call(this, i, r, null, null, !1, !1) || this).name = i, c._options = n, c._lazy = !1, c._updatable = !1, c.intersectionThreshold = .1, c._lazy = null !== (o = n.lazy) && void 0 !== o && o, c._updatable = null !== (a = n.updatable) && void 0 !== a && a, c._vertexPositions = [], c._indices = [], c._uvs = [], c._points = [], c._colorPointers = null !== (s = n.colorPointers) && void 0 !== s ? s : [], c._widths = null !== (l = n.widths) && void 0 !== l ? l : new Array(n.points.length).fill(1), c._previousAndSide = [], c._nextAndCounters = [], n.points && c.addPoints(t.ConvertPoints(n.points)), c } return W(t, e), t.prototype.getClassName = function () { return "GreasedLineMesh" }, t.ConvertPoints = function (e) { if (e.length && Array.isArray(e) && "number" == typeof e[0]) return [e]; if (e.length && Array.isArray(e[0]) && "number" == typeof e[0][0]) return e; if (e.length && !Array.isArray(e[0]) && e[0] instanceof R) { for (var t = [], i = 0; i < e.length; i++) { var r = e[i]; t.push(r.x, r.y, r.z) } return [t] } if (e.length > 0 && 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 [] }, t.prototype.updateLazy = function () { var e; this._setPoints(this._points), this._options.colorPointers || this._updateColorPointers(), this._createVertexBuffers(), this.refreshBoundingInfo(), null === (e = this.greasedLineMaterial) || void 0 === e || e.updateLazy() }, t.prototype.dispose = function () { e.prototype.dispose.call(this) }, t.prototype.isLazy = function () { return this._lazy }, Object.defineProperty(t.prototype, "offsets", { get: function () { return this._offsets }, set: function (e) { this._offsets = e, this._offsetsBuffer ? this._offsetsBuffer && this._offsetsBuffer.update(e) : this._createOffsetsBuffer(e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "widths", { get: function () { return this._widths }, set: function (e) { this._widths = e, this._lazy || this._widthsBuffer && this._widthsBuffer.update(e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "colorPointers", { get: function () { return this._colorPointers }, set: function (e) { this._colorPointers = e, this._lazy || this._colorPointersBuffer && this._colorPointersBuffer.update(e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "greasedLineMaterial", { get: function () { var e, t; return this.material && this.material instanceof Qb ? this.material : (null === (t = null === (e = this.material) || void 0 === e ? void 0 : e.pluginManager) || void 0 === t ? void 0 : t.getPlugin(bb.GREASED_LINE_MATERIAL_NAME)) || void 0 }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "points", { get: function () { var e = []; return he.DeepCopy(this._points, e), e }, enumerable: !1, configurable: !0 }), t.prototype.addPoints = function (e) { for (var t = 0, i = e; t < i.length; t++) { var r = i[t]; this._points.push(r) } this._lazy || this.setPoints(this._points) }, t.prototype._updateColorPointers = function () { var e = this, t = 0; this._colorPointers = [], this._points.forEach((function (i) { for (var r = 0; r < i.length; r += 3)e._colorPointers.push(t), e._colorPointers.push(t++) })) }, t.prototype._updateWidths = function () { for (var e = 0, t = 0, i = this._points; t < i.length; t++)e += i[t].length; for (var r = e / 3 * 2 - this._widths.length, n = 0; n < r; n++)this._widths.push(1) }, t.prototype.setPoints = function (e) { this._points = e, this._updateWidths(), this._updateColorPointers(), this._setPoints(e) }, t.prototype._setPoints = function (e) { var t = this; this._points = e, this._options.points = e, this._initGreasedLine(); var i = 0; e.forEach((function (e) { for (var r, n = [], o = [], a = [], s = Kb.GetLineLength(e), l = 0, c = 0; c < e.length; l++, c += 3) { var u = e.slice(0, c + 3), h = Kb.GetLineLength(u) / s; if (o.push(e[c], e[c + 1], e[c + 2]), o.push(e[c], e[c + 1], e[c + 2]), n.push(h), n.push(h), c < e.length - 3) { var d = 2 * l + i; a.push(d, d + 1, d + 2), a.push(d + 2, d + 1, d + 3) } } i += e.length / 3 * 2; var p = [], f = [], _ = [], m = []; t._preprocess(o, p, f, _, m); for (var g = 0, v = o; g < v.length; g++) { var y = v[g]; t._vertexPositions.push(y) } for (var b = 0, T = a; b < T.length; b++) { var E = T[b]; t._indices.push(E) } for (E = 0; E < _.length; E++)t._previousAndSide.push(p[3 * E], p[3 * E + 1], p[3 * E + 2], _[E]), t._nextAndCounters.push(f[3 * E], f[3 * E + 1], f[3 * E + 2], n[E]); for (var S = 0, x = m = null !== (r = t._options.uvs) && void 0 !== r ? r : m; S < x.length; S++) { var A = x[S]; t._uvs.push(A) } })), this._lazy || (this._options.colorPointers || this._updateColorPointers(), this._createVertexBuffers(), this.refreshBoundingInfo()) }, t.prototype._createLineOptions = function () { return { points: this._points, colorPointers: this._colorPointers, lazy: this._lazy, updatable: this._updatable, uvs: this._uvs, widths: this._widths } }, t.prototype.clone = function (e, i) { void 0 === e && (e = "".concat(this.name, "-cloned")); var r = this._createLineOptions(), n = {}; he.DeepCopy(r, n, ["instance"]); var o = new t(e, this._scene, n); return i && (o.parent = i), o.material = this.material, o }, t.prototype.serialize = function (t) { e.prototype.serialize.call(this, t), t.type = this.getClassName(), t.lineOptions = this._createLineOptions() }, t.Parse = function (e, i) { var r = e.lineOptions; return new t(e.name, i, r) }, t.prototype.intersects = function (e, t, i, r, n, o) { void 0 === r && (r = !1), void 0 === o && (o = !1); var a = new Xi, s = this.findAllIntersections(e, t, i, r, n, o, !0); if (1 === (null == s ? void 0 : s.length)) { var l = s[0]; a.hit = !0, a.distance = l.distance, a.ray = e, a.pickedMesh = this, a.pickedPoint = l.point } return a }, t.prototype.findAllIntersections = function (e, i, r, n, o, a, s) { var l, c; if (void 0 === n && (n = !1), void 0 === a && (a = !1), void 0 === s && (s = !1), !n || a || !1 !== e.intersectsSphere(this._boundingSphere, this.intersectionThreshold)) { var u = this.getIndices(), h = this.getVerticesData(Hi.PositionKind), d = this._widths, p = null !== (c = null === (l = this.greasedLineMaterial) || void 0 === l ? void 0 : l.width) && void 0 !== c ? c : 1, f = []; if (u && h && d) { var _, m = 0; for (m = 0, _ = u.length - 1; m < _; m += 3) { var g = u[m], v = u[m + 1]; t._V_START.fromArray(h, 3 * g), t._V_END.fromArray(h, 3 * v), this._offsets && (t._V_OFFSET_START.fromArray(this._offsets, 3 * g), t._V_OFFSET_END.fromArray(this._offsets, 3 * v), t._V_START.addInPlace(t._V_OFFSET_START), t._V_END.addInPlace(t._V_OFFSET_END)); var y = Math.floor(m / 3), b = void 0 !== d[y] ? d[y] : 1, T = this.intersectionThreshold * (p * b) / 2, E = e.intersectionSegment(t._V_START, t._V_END, T); if (-1 !== E && (f.push({ distance: E, point: e.direction.normalize().multiplyByFloats(E, E, E).add(e.origin) }), s)) return f } m = _ } return f } }, t.prototype._initGreasedLine = function () { this._vertexPositions = [], this._previousAndSide = [], this._nextAndCounters = [], this._indices = [], this._uvs = [] }, Object.defineProperty(t.prototype, "_boundingSphere", { get: function () { return this.getBoundingInfo().boundingSphere }, enumerable: !1, configurable: !0 }), t._CompareV3 = function (e, t, i) { var r = 6 * e, n = 6 * t; return i[r] === i[n] && i[r + 1] === i[n + 1] && i[r + 2] === i[n + 2] }, t._CopyV3 = function (e, t) { var i = 6 * e; return [t[i], t[i + 1], t[i + 2]] }, t.prototype._preprocess = function (e, i, r, n, o) { var a = e.length / 6, s = []; s = t._CompareV3(0, a - 1, e) ? t._CopyV3(a - 2, e) : t._CopyV3(0, e), i.push(s[0], s[1], s[2]), i.push(s[0], s[1], s[2]); for (var l = 0; l < a; l++)n.push(1), n.push(-1), this._options.uvs || (o.push(l / (a - 1), 0), o.push(l / (a - 1), 1)), l < a - 1 && (s = t._CopyV3(l, e), i.push(s[0], s[1], s[2]), i.push(s[0], s[1], s[2])), l > 0 && (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 e = new En; e.positions = this._vertexPositions, e.indices = this._indices, e.uvs = this._uvs, e.applyToMesh(this, this._options.updatable); var t = this._scene.getEngine(), i = new Wi(t, this._previousAndSide, !1, 4); this.setVerticesBuffer(i.createVertexBuffer("grl_previousAndSide", 0, 4)); var r = new Wi(t, this._nextAndCounters, !1, 4); this.setVerticesBuffer(r.createVertexBuffer("grl_nextAndCounters", 0, 4)); var n = new Wi(t, this._widths, this._updatable, 1); this.setVerticesBuffer(n.createVertexBuffer("grl_widths", 0, 1)), this._widthsBuffer = n; var o = new Wi(t, this._colorPointers, this._updatable, 1); this.setVerticesBuffer(o.createVertexBuffer("grl_colorPointers", 0, 1)), this._colorPointersBuffer = o }, t.prototype._createOffsetsBuffer = function (e) { var t = this._scene.getEngine(), i = new Wi(t, e, this._updatable, 3); this.setVerticesBuffer(i.createVertexBuffer("grl_offsets", 0, 3)), this._offsetsBuffer = i }, t._V_START = new R, t._V_END = new R, t._V_OFFSET_START = new R, t._V_OFFSET_END = new R, t }(Jn); function iT(e, t, i) { var r; switch (i = null != i ? i : S.LastCreatedScene, t.materialType) { case nb.MATERIAL_TYPE_PBR: r = new L_(e, i), new bb(r, i, t); break; case nb.MATERIAL_TYPE_SIMPLE: r = new Qb(e, i, t); break; default: r = new mc(e, i), new bb(r, i, t) }return r } function rT(e, t, i, r) { var n, o, a, s, l, c, u; r = null != r ? r : S.LastCreatedScene; var h = tT.ConvertPoints(t.points), d = 0; Array.isArray(h[0]) && h.forEach((function (e) { d += e.length / 3 })), t.widthDistribution = null !== (n = t.widthDistribution) && void 0 !== n ? n : Zb.WIDTH_DISTRIBUTION_START, (i = null != i ? i : { color: bb.DEFAULT_COLOR }).createAndAssignMaterial = null === (o = i.createAndAssignMaterial) || void 0 === o || o, i.colorDistribution = null !== (a = null == i ? void 0 : i.colorDistribution) && void 0 !== a ? a : qb.COLOR_DISTRIBUTION_START, i.materialType = null !== (s = i.materialType) && void 0 !== s ? s : nb.MATERIAL_TYPE_STANDARD; var p = nT(d, null !== (l = t.widths) && void 0 !== l ? l : [], t.widthDistribution), f = (null == i ? void 0 : i.colors) ? oT(d, i.colors, i.colorDistribution, null !== (c = i.color) && void 0 !== c ? c : bb.DEFAULT_COLOR) : void 0; if (t.instance) { var _ = (u = t.instance).widths; if (_) { for (var m = _.slice(), g = 0, v = p; g < v.length; g++) { var y = v[g]; m.push(y) } u.widths = m } else u.widths = p; u.addPoints(h) } else { var b = { points: h, updatable: t.updatable, widths: p, lazy: t.lazy }; if (u = new tT(e, r, b), i) { var T = { materialType: i.materialType, dashCount: i.dashCount, dashOffset: i.dashOffset, dashRatio: i.dashRatio, resolution: i.resolution, sizeAttenuation: i.sizeAttenuation, useColors: i.useColors, useDash: i.useDash, visibility: i.visibility, width: i.width, color: i.color, colorMode: i.colorMode, colorsSampling: i.colorsSampling, colorDistributionType: i.colorDistributionType, colors: f }; if (i.createAndAssignMaterial) { var E = iT(e, T, r); u.material = E } } } if (f && t.instance && t.instance.greasedLineMaterial) { var x = t.instance.greasedLineMaterial.colors; if (x) { var A = x.concat(f); t.instance.greasedLineMaterial.setColors(A, u.isLazy()) } } return u } function nT(e, t, i, r, n) { void 0 === r && (r = 1), void 0 === n && (n = 1); var o = e - t.length / 2, a = []; if (o < 0) return t.slice(0, 2 * e); if (o > 0) { if (i === Zb.WIDTH_DISTRIBUTION_START_END) { for (var s = Math.floor(t.length / 2), l = 0, c = 0; l < s - 1; l++)a.push(t[c++]), a.push(t[c++]); var u = t[s / 2], h = t[s / 2 + 1]; for (l = 0; l < o; l++)a.push(h), a.push(u); for (l = s; l < t.length; l += 2)a.push(t[l]), a.push(t[l + 1]) } else if (i === Zb.WIDTH_DISTRIBUTION_START) { for (l = 0; l < t.length; l += 2)a.push(t[l]), a.push(t[l + 1]); for (l = 0; l < o; l++)a.push(r), a.push(n) } else if (i === Zb.WIDTH_DISTRIBUTION_END) { for (l = 0; l < o; l++)a.push(r), a.push(n); for (l = 0; l < t.length; l += 2)a.push(t[l]), a.push(t[l + 1]) } else if (i === Zb.WIDTH_DISTRIBUTION_REPEAT) { l = 0; for (var d = 0; d < e; d++)a.push(t[l++]), a.push(t[l++]), l === t.length && (l = 0) } else if (i === Zb.WIDTH_DISTRIBUTION_EVEN) { c = 0; var p = t.length / (2 * (e - 1)); for (d = 0; d < e; d++)l = Math.floor(c), a.push(t[l]), a.push(t[l + 1]), c += p } } else for (l = 0; l < t.length; l++)a.push(t[l]); return a } function oT(e, t, i, r) { var n = (e = Math.max(t.length, e)) - t.length; if (n < 0) return t.slice(0, e); var o = []; if (n > 0) { if (i === qb.COLOR_DISTRIBUTION_START_END) { for (var a = Math.floor(t.length / 2), s = 0; s < a; s++)o.push(t[s]); for (s = 0; s < n - 1; s++)o.push(r); for (s = a; s < t.length; s++)o.push(t[s]) } else if (i === qb.COLOR_DISTRIBUTION_START) { for (s = 0; s < t.length; s++)o.push(t[s]); for (s = 0; s < n; s++)o.push(r) } else if (i === qb.COLOR_DISTRIBUTION_END) { for (s = 0; s < n - 1; s++)o.push(r); for (s = 0; s < t.length; s++)o.push(t[s]) } else if (i === qb.COLOR_DISTRIBUTION_REPEAT) { s = 0; for (var l = 0; l < e; l++)o.push(t[s]), ++s === t.length && (s = 0) } else if (i === qb.COLOR_DISTRIBUTION_EVEN) { var c = 0, u = t.length / (e - 1); for (l = 0; l < e - 1; l++)s = Math.floor(c), o.push(t[s]), c += u } else if (i === qb.COLOR_DISTRIBUTION_NONE) for (s = 0; s < t.length; s++)o.push(t[s]) } else for (s = 0; s < e; s++)o.push(t[s]); return o } !function (e) { e[e.COLOR_DISTRIBUTION_NONE = 0] = "COLOR_DISTRIBUTION_NONE", e[e.COLOR_DISTRIBUTION_REPEAT = 1] = "COLOR_DISTRIBUTION_REPEAT", e[e.COLOR_DISTRIBUTION_EVEN = 2] = "COLOR_DISTRIBUTION_EVEN", e[e.COLOR_DISTRIBUTION_START = 3] = "COLOR_DISTRIBUTION_START", e[e.COLOR_DISTRIBUTION_END = 4] = "COLOR_DISTRIBUTION_END", e[e.COLOR_DISTRIBUTION_START_END = 5] = "COLOR_DISTRIBUTION_START_END" }(qb || (qb = {})), function (e) { e[e.WIDTH_DISTRIBUTION_NONE = 0] = "WIDTH_DISTRIBUTION_NONE", e[e.WIDTH_DISTRIBUTION_REPEAT = 1] = "WIDTH_DISTRIBUTION_REPEAT", e[e.WIDTH_DISTRIBUTION_EVEN = 2] = "WIDTH_DISTRIBUTION_EVEN", e[e.WIDTH_DISTRIBUTION_START = 3] = "WIDTH_DISTRIBUTION_START", e[e.WIDTH_DISTRIBUTION_END = 4] = "WIDTH_DISTRIBUTION_END", e[e.WIDTH_DISTRIBUTION_START_END = 5] = "WIDTH_DISTRIBUTION_START_END" }(Zb || (Zb = {})), Jn.prototype.thinInstanceAdd = function (e, t) { if (void 0 === t && (t = !0), !this.getScene().getEngine().getCaps().instancedArrays) return $.Error("Thin Instances are not supported on this device as Instanced Array extension not supported"), -1; this._thinInstanceUpdateBufferSize("matrix", Array.isArray(e) ? e.length : 1); var i = this._thinInstanceDataStorage.instancesCount; if (Array.isArray(e)) for (var r = 0; r < e.length; ++r)this.thinInstanceSetMatrixAt(this._thinInstanceDataStorage.instancesCount++, e[r], r === e.length - 1 && t); else this.thinInstanceSetMatrixAt(this._thinInstanceDataStorage.instancesCount++, e, t); return i }, Jn.prototype.thinInstanceAddSelf = function (e) { return void 0 === e && (e = !0), this.thinInstanceAdd(I.IdentityReadOnly, e) }, Jn.prototype.thinInstanceRegisterAttribute = function (e, t) { e === Hi.ColorKind && (e = Hi.ColorInstanceKind), this.removeVerticesData(e), this._thinInstanceInitializeUserStorage(), this._userThinInstanceBuffersStorage.strides[e] = t, this._userThinInstanceBuffersStorage.sizes[e] = t * Math.max(32, this._thinInstanceDataStorage.instancesCount), this._userThinInstanceBuffersStorage.data[e] = new Float32Array(this._userThinInstanceBuffersStorage.sizes[e]), this._userThinInstanceBuffersStorage.vertexBuffers[e] = new Hi(this.getEngine(), this._userThinInstanceBuffersStorage.data[e], e, !0, !1, t, !0), this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[e]) }, Jn.prototype.thinInstanceSetMatrixAt = function (e, t, i) { if (void 0 === i && (i = !0), !this._thinInstanceDataStorage.matrixData || e >= 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 }, Jn.prototype.thinInstanceSetAttributeAt = function (e, t, i, r) { return void 0 === r && (r = !0), e === Hi.ColorKind && (e = Hi.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(Jn.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 }), Jn.prototype._thinInstanceCreateMatrixBuffer = function (e, t, i) { void 0 === i && (i = !1), e === Hi.ColorKind && (e = Hi.ColorInstanceKind); for (var r = new Wi(this.getEngine(), t, !i, 16, !1, !0), n = 0; n < 4; n++)this.setVerticesBuffer(r.createVertexBuffer(e + n, 4 * n, 4)); return r }, Jn.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 === Hi.ColorKind && (e = Hi.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 Hi(this.getEngine(), t, e, !r, !1, i, !0), this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[e]))) }, Jn.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 === Hi.ColorKind && (e = Hi.ColorInstanceKind), (null === (r = this._userThinInstanceBuffersStorage) || void 0 === r ? void 0 : r.vertexBuffers[e]) && this._userThinInstanceBuffersStorage.vertexBuffers[e].updateDirectly(this._userThinInstanceBuffersStorage.data[e], 0)) }, Jn.prototype.thinInstancePartialBufferUpdate = function (e, t, i) { var r; "matrix" === e ? this._thinInstanceDataStorage.matrixBuffer && this._thinInstanceDataStorage.matrixBuffer.updateDirectly(t, i) : (e === Hi.ColorKind && (e = Hi.ColorInstanceKind), (null === (r = this._userThinInstanceBuffersStorage) || void 0 === r ? void 0 : r.vertexBuffers[e]) && this._userThinInstanceBuffersStorage.vertexBuffers[e].updateDirectly(t, i)) }, Jn.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; t < this._thinInstanceDataStorage.instancesCount; ++t)this._thinInstanceDataStorage.worldMatrices[t] = I.FromArray(e, 16 * t) } return this._thinInstanceDataStorage.worldMatrices }, Jn.prototype.thinInstanceRefreshBoundingInfo = function (e, t, i) { if (void 0 === e && (e = !1), void 0 === t && (t = !1), void 0 === i && (i = !1), this._thinInstanceDataStorage.matrixData && this._thinInstanceDataStorage.matrixBuffer) { var r = this._thinInstanceDataStorage.boundingVectors; if (e || !this.rawBoundingInfo) { r.length = 0, this.refreshBoundingInfo(t, i); var n = this.getBoundingInfo(); this.rawBoundingInfo = new mn(n.minimum, n.maximum) } var o = this.getBoundingInfo(), a = this._thinInstanceDataStorage.matrixData; if (0 === r.length) for (var s = 0; s < o.boundingBox.vectors.length; ++s)r.push(o.boundingBox.vectors[s].clone()); O.Vector3[0].setAll(Number.POSITIVE_INFINITY), O.Vector3[1].setAll(Number.NEGATIVE_INFINITY); for (var l = 0; l < this._thinInstanceDataStorage.instancesCount; ++l)for (I.FromArrayToRef(a, 16 * l, O.Matrix[0]), s = 0; s < r.length; ++s)R.TransformCoordinatesToRef(r[s], O.Matrix[0], O.Vector3[2]), O.Vector3[0].minimizeInPlace(O.Vector3[2]), O.Vector3[1].maximizeInPlace(O.Vector3[2]); o.reConstruct(O.Vector3[0], O.Vector3[1]), this._updateBoundingInfo() } }, Jn.prototype._thinInstanceUpdateBufferSize = function (e, t) { var i, r, n; void 0 === t && (t = 1), e === Hi.ColorKind && (e = Hi.ColorInstanceKind); var o = "matrix" === e; if (o || this._userThinInstanceBuffersStorage && this._userThinInstanceBuffersStorage.strides[e]) { for (var a = o ? 16 : this._userThinInstanceBuffersStorage.strides[e], s = o ? this._thinInstanceDataStorage.matrixBufferSize : this._userThinInstanceBuffersStorage.sizes[e], l = o ? this._thinInstanceDataStorage.matrixData : this._userThinInstanceBuffersStorage.data[e], c = (this._thinInstanceDataStorage.instancesCount + t) * a, u = s; u < c;)u *= 2; if (!l || s != u) { if (l) { var h = new Float32Array(u); h.set(l, 0), l = h } else l = new Float32Array(u); o ? (null === (i = this._thinInstanceDataStorage.matrixBuffer) || void 0 === i || i.dispose(), this._thinInstanceDataStorage.matrixBuffer = this._thinInstanceCreateMatrixBuffer("world", l, !1), this._thinInstanceDataStorage.matrixData = l, this._thinInstanceDataStorage.matrixBufferSize = u, this._scene.needsPreviousWorldMatrices && !this._thinInstanceDataStorage.previousMatrixData && (null === (r = this._thinInstanceDataStorage.previousMatrixBuffer) || void 0 === r || r.dispose(), this._thinInstanceDataStorage.previousMatrixBuffer = this._thinInstanceCreateMatrixBuffer("previousWorld", l, !1))) : (null === (n = this._userThinInstanceBuffersStorage.vertexBuffers[e]) || void 0 === n || n.dispose(), this._userThinInstanceBuffersStorage.data[e] = l, this._userThinInstanceBuffersStorage.sizes[e] = u, this._userThinInstanceBuffersStorage.vertexBuffers[e] = new Hi(this.getEngine(), l, e, !0, !1, a, !0), this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[e])) } } }, Jn.prototype._thinInstanceInitializeUserStorage = function () { this._userThinInstanceBuffersStorage || (this._userThinInstanceBuffersStorage = { data: {}, sizes: {}, vertexBuffers: {}, strides: {} }) }, Jn.prototype._disposeThinInstanceSpecificData = function () { var e; (null === (e = this._thinInstanceDataStorage) || void 0 === e ? void 0 : e.matrixBuffer) && (this._thinInstanceDataStorage.matrixBuffer.dispose(), this._thinInstanceDataStorage.matrixBuffer = null) }, function (e) { e[e.Int = 1] = "Int", e[e.Float = 2] = "Float", e[e.Vector2 = 4] = "Vector2", e[e.Vector3 = 8] = "Vector3", e[e.Vector4 = 16] = "Vector4", e[e.Matrix = 32] = "Matrix", e[e.Geometry = 64] = "Geometry", e[e.AutoDetect = 1024] = "AutoDetect", e[e.BasedOnInput = 2048] = "BasedOnInput", e[e.Undefined = 4096] = "Undefined", e[e.All = 4095] = "All" }(Jb || (Jb = {})), function (e) { e[e.Compatible = 0] = "Compatible", e[e.TypeIncompatible = 1] = "TypeIncompatible", e[e.HierarchyIssue = 2] = "HierarchyIssue" }($b || ($b = {})), function (e) { e[e.Input = 0] = "Input", e[e.Output = 1] = "Output" }(eT || (eT = {})); var aT, sT = function () { function e(e, t, i) { this._connectedPoint = null, this._storedValue = null, this._storedFunction = null, this._acceptedConnectionPointType = null, this._endpoints = new Array, this._type = Jb.Geometry, this._linkedConnectionSource = null, this._typeConnectionSource = null, this._defaultConnectionPointType = null, this.acceptedConnectionPointTypes = new Array, this.excludedConnectionPointTypes = new Array, this.onConnectionObservable = new u, this.isExposedOnFrame = !1, this.exposedPortPosition = -1, this.value = null, this.valueMin = null, this.valueMax = null, this._ownerBlock = t, this.name = e, this._direction = i } return Object.defineProperty(e.prototype, "direction", { get: function () { return this._direction }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "type", { get: function () { if (this._type === Jb.AutoDetect) { if (this._ownerBlock.isInput) return this._ownerBlock.type; if (this._connectedPoint) return this._connectedPoint.type; if (this._linkedConnectionSource && this._linkedConnectionSource.isConnected) return this._linkedConnectionSource.type } if (this._type === Jb.BasedOnInput) { if (this._typeConnectionSource) return !this._typeConnectionSource.isConnected && this._defaultConnectionPointType ? this._defaultConnectionPointType : this._typeConnectionSource.type; if (this._defaultConnectionPointType) return this._defaultConnectionPointType } return this._type }, set: function (e) { this._type = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isConnected", { get: function () { return null !== this.connectedPoint || this.hasEndpoints }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "connectedPoint", { get: function () { return this._connectedPoint }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "ownerBlock", { get: function () { return this._ownerBlock }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "sourceBlock", { get: function () { return this._connectedPoint ? this._connectedPoint.ownerBlock : null }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "connectedBlocks", { get: function () { return 0 === this._endpoints.length ? [] : this._endpoints.map((function (e) { return e.ownerBlock })) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "endpoints", { get: function () { return this._endpoints }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "hasEndpoints", { get: function () { return this._endpoints && this._endpoints.length > 0 }, 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) === $b.Compatible }, e.prototype.checkCompatibilityState = function (e) { var t = this._ownerBlock, i = e.ownerBlock; if (this.type !== e.type && e.innerType !== Jb.AutoDetect) return e.acceptedConnectionPointTypes && -1 !== e.acceptedConnectionPointTypes.indexOf(this.type) ? $b.Compatible : $b.TypeIncompatible; if (e.excludedConnectionPointTypes && -1 !== e.excludedConnectionPointTypes.indexOf(this.type)) return $b.TypeIncompatible; var r = i, n = t; return this.direction === eT.Input && (r = t, n = i), r.isAnAncestorOf(n) ? $b.HierarchyIssue : $b.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; t < Jb.All;)e & t || this.excludedConnectionPointTypes.push(t), t <<= 1 }, e.prototype.serialize = function (e) { void 0 === e && (e = !0); var t = {}; return t.name = this.name, t.displayName = this.displayName, void 0 !== this.value && null !== this.value && (this.value.asArray ? (t.valueType = "BABYLON." + this.value.getClassName(), t.value = this.value.asArray()) : (t.valueType = "number", t.value = this.value)), e && this.connectedPoint && (t.inputName = this.name, t.targetBlockId = this.connectedPoint.ownerBlock.uniqueId, t.targetConnectionName = this.connectedPoint.name), t }, e.prototype.dispose = function () { this.onConnectionObservable.clear() }, e }(), lT = function () { function e(e) { this._name = "", this._isInput = !1, this._isTeleportOut = !1, this._isTeleportIn = !1, this._isUnique = !1, this._buildExecutionTime = 0, this.onBuildObservable = new u, this._inputs = new Array, this._outputs = new Array, this._codeVariableName = "", this.visibleInInspector = !1, this.visibleOnFrame = !1, this._name = e, this._isInput = "GeometryInputBlock" === this.getClassName(), this._isTeleportOut = "TeleportOutBlock" === this.getClassName(), this._isTeleportIn = "TeleportInBlock" === this.getClassName(), this.uniqueId = yr.UniqueId } return Object.defineProperty(e.prototype, "buildExecutionTime", { get: function () { return this._buildExecutionTime }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "inputs", { get: function () { return this._inputs }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "outputs", { get: function () { return this._outputs }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "name", { get: function () { return this._name }, set: function (e) { this._name = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isInput", { get: function () { return this._isInput }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isTeleportOut", { get: function () { return this._isTeleportOut }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isTeleportIn", { get: function () { return this._isTeleportIn }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isUnique", { get: function () { return this._isUnique }, enumerable: !1, configurable: !0 }), e.prototype.getClassName = function () { return "NodeGeometryBlock" }, e.prototype._inputRename = function (e) { return e }, e.prototype._outputRename = function (e) { return e }, e.prototype.isAnAncestorOf = function (e) { for (var t = 0, i = this._outputs; t < i.length; t++) { var r = i[t]; if (r.hasEndpoints) for (var n = 0, o = r.endpoints; n < o.length; n++) { var a = o[n]; if (a.ownerBlock === e) return !0; if (a.ownerBlock.isAnAncestorOf(e)) return !0 } } return !1 }, e.prototype.isAnAncestorOfType = function (e) { if (this.getClassName() === e) return !0; for (var t = 0, i = this._outputs; t < i.length; t++) { var r = i[t]; if (r.hasEndpoints) for (var n = 0, o = r.endpoints; n < o.length; n++)if (o[n].ownerBlock.isAnAncestorOfType(e)) return !0 } return !1 }, e.prototype.registerInput = function (e, t, i, r, n, o) { void 0 === i && (i = !1); var a = new sT(e, this, eT.Input); return a.type = t, a.isOptional = i, a.value = r, a.valueMin = n, a.valueMax = o, this._inputs.push(a), this }, e.prototype.registerOutput = function (e, t, i) { return (i = null != i ? i : new sT(e, this, eT.Output)).type = t, this._outputs.push(i), this }, e.prototype._buildBlock = function (e) { }, e.prototype._customBuildStep = function (e) { }, e.prototype.build = function (e) { if (this._buildId === e.buildId) return !0; if (this._outputs.length > 0 && !this._outputs.some((function (e) { return e.hasEndpoints }))) return !1; this._buildId = e.buildId; for (var t = 0, i = this._inputs; t < i.length; t++) { var r = i[t]; r.connectedPoint ? (c = r.connectedPoint.ownerBlock) && c !== this && c.build(e) : r.isOptional || e.notConnectedNonOptionalInputs.push(r) } this._customBuildStep(e), e.verbose && console.log("Building ".concat(this.name, " [").concat(this.getClassName(), "]")); var n = at.Now; this._buildBlock(e), this._buildExecutionTime = at.Now - n; for (var o = 0, a = this._outputs; o < a.length; o++)for (var s = 0, l = a[o].endpoints; s < l.length; s++) { var c; (c = l[s].ownerBlock) && c.build(e) } return this.onBuildObservable.notifyObservers(this), !1 }, e.prototype._linkConnectionTypes = function (e, t, i) { void 0 === i && (i = !1), i ? this._inputs[t]._acceptedConnectionPointType = this._inputs[e] : this._inputs[e]._linkedConnectionSource = this._inputs[t], this._inputs[t]._linkedConnectionSource = this._inputs[e] }, e.prototype.initialize = function () { }, e.prototype.autoConfigure = function () { }, 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.serialize = function (e) { var t = {}; t.customType = "BABYLON." + this.getClassName(), t.id = this.uniqueId, t.name = this.name, t.inputs = [], t.outputs = []; for (var i = 0, r = this.inputs; i < r.length; i++) { var n = r[i]; t.inputs.push(n.serialize()) } for (var o = 0, a = this.outputs; o < a.length; o++) { var s = a[o]; t.outputs.push(s.serialize(!1)) } return t }, e.prototype._deserialize = function (e) { this._name = e.name, this.comments = e.comments, this.visibleInInspector = !!e.visibleInInspector, this.visibleOnFrame = !!e.visibleOnFrame, this._deserializePortDisplayNamesAndExposedOnFrame(e) }, e.prototype._deserializePortDisplayNamesAndExposedOnFrame = function (e) { var t = this, i = e.inputs, r = e.outputs; i && i.forEach((function (e, i) { if (e.displayName && (t.inputs[i].displayName = e.displayName), e.isExposedOnFrame && (t.inputs[i].isExposedOnFrame = e.isExposedOnFrame, t.inputs[i].exposedPortPosition = e.exposedPortPosition), void 0 !== e.value && null !== e.value) if ("number" === e.valueType) t.inputs[i].value = e.value; else { var r = T(e.valueType); r && (t.inputs[i].value = r.FromArray(e.value)) } })), r && r.forEach((function (e, i) { e.displayName && (t.outputs[i].displayName = e.displayName), e.isExposedOnFrame && (t.outputs[i].isExposedOnFrame = e.isExposedOnFrame, t.outputs[i].exposedPortPosition = e.exposedPortPosition) })) }, e.prototype._dumpPropertiesCode = function () { var e = this._codeVariableName; return "".concat(e, ".visibleInInspector = ").concat(this.visibleInInspector, ";\n").concat(e, ".visibleOnFrame = ").concat(this.visibleOnFrame, ";\n") }, e.prototype._dumpCodeForOutputConnections = function (e) { var t = ""; if (-1 !== e.indexOf(this)) return t; e.push(this); for (var i = 0, r = this.inputs; i < r.length; i++) { var n = r[i]; if (n.isConnected) { var o = n.connectedPoint, a = o.ownerBlock; t += a._dumpCodeForOutputConnections(e), t += "".concat(a._codeVariableName, ".").concat(a._outputRename(o.name), ".connectTo(").concat(this._codeVariableName, ".").concat(this._inputRename(n.name), ");\n") } } return t }, e.prototype._dumpCode = function (e, t) { t.push(this); var i = this.name.replace(/[^A-Za-z_]+/g, ""); if (this._codeVariableName = i || "".concat(this.getClassName(), "_").concat(this.uniqueId), -1 !== e.indexOf(this._codeVariableName)) { var r = 0; do { r++, this._codeVariableName = i + r } while (-1 !== e.indexOf(this._codeVariableName)) } e.push(this._codeVariableName); var n = "\n// ".concat(this.getClassName(), "\n"); this.comments && (n += "// ".concat(this.comments, "\n")), n += "var ".concat(this._codeVariableName, " = new BABYLON.").concat(this.getClassName(), '("').concat(this.name, '");\n'), n += this._dumpPropertiesCode(); for (var o = 0, a = this.inputs; o < a.length; o++) { var s = a[o]; if (s.isConnected) { var l = s.connectedPoint.ownerBlock; -1 === t.indexOf(l) && (n += l._dumpCode(e, t)) } } for (var c = 0, u = this.outputs; c < u.length; c++) { var h = u[c]; if (h.hasEndpoints) for (var d = 0, p = h.endpoints; d < p.length; d++)(l = p[d].ownerBlock) && -1 === t.indexOf(l) && (n += l._dumpCode(e, t)) } return n }, e.prototype.clone = function () { var e = this.serialize(), t = T(e.customType); if (t) { var i = new t; return i._deserialize(e), i } return null }, e.prototype.dispose = function () { for (var e = 0, t = this.inputs; e < t.length; e++)t[e].dispose(); for (var i = 0, r = this.outputs; i < r.length; i++)r[i].dispose(); this.onBuildObservable.clear() }, X([xe("comment")], e.prototype, "comments", void 0), e }(), cT = function (e) { function t(t) { var i = e.call(this, t) || this; return i._vertexData = null, i._isUnique = !0, i.registerInput("geometry", Jb.Geometry), i } return W(t, e), Object.defineProperty(t.prototype, "currentVertexData", { get: function () { return this._vertexData }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function () { return "GeometryOutputBlock" }, Object.defineProperty(t.prototype, "geometry", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function (e) { e.vertexData = this.geometry.getConnectedValue(e), this._vertexData = e.vertexData }, t }(lT); b("BABYLON.GeometryOutputBlock", cT), function (e) { e[e.None = 0] = "None", e[e.Positions = 1] = "Positions", e[e.Normals = 2] = "Normals", e[e.Tangents = 3] = "Tangents", e[e.UV = 4] = "UV", 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", e[e.Colors = 10] = "Colors", e[e.VertexID = 11] = "VertexID", e[e.FaceID = 12] = "FaceID" }(aT || (aT = {})); var uT = function () { function e() { this._rotationMatrix = new I, this._scalingMatrix = new I, this._positionMatrix = new I, this._scalingRotationMatrix = new I, this._transformMatrix = new I, this._tempVector3 = new R, this.notConnectedNonOptionalInputs = [], this.vertexData = null, this.geometryContext = null, this.executionContext = null } return e.prototype.getContextualValue = function (e) { if (!this.executionContext || !this.geometryContext) return null; var t = this.executionContext.getExecutionIndex(); switch (e) { case aT.Positions: return this.executionContext.getOverridePositionsContextualValue ? this.executionContext.getOverridePositionsContextualValue() : this.geometryContext.positions ? R.FromArray(this.geometryContext.positions, 3 * t) : R.Zero(); case aT.Normals: return this.executionContext.getOverrideNormalsContextualValue ? this.executionContext.getOverrideNormalsContextualValue() : this.geometryContext.normals ? R.FromArray(this.geometryContext.normals, 3 * t) : R.Zero(); case aT.Colors: return this.geometryContext.colors ? C.FromArray(this.geometryContext.colors, 4 * t) : C.Zero(); case aT.Tangents: return this.geometryContext.tangents ? C.FromArray(this.geometryContext.tangents, 4 * t) : C.Zero(); case aT.UV: return this.geometryContext.uvs ? A.FromArray(this.geometryContext.uvs, 2 * t) : A.Zero(); case aT.UV2: return this.geometryContext.uvs2 ? A.FromArray(this.geometryContext.uvs2, 2 * t) : A.Zero(); case aT.UV3: return this.geometryContext.uvs3 ? A.FromArray(this.geometryContext.uvs3, 2 * t) : A.Zero(); case aT.UV4: return this.geometryContext.uvs4 ? A.FromArray(this.geometryContext.uvs4, 2 * t) : A.Zero(); case aT.UV5: return this.geometryContext.uvs5 ? A.FromArray(this.geometryContext.uvs5, 2 * t) : A.Zero(); case aT.UV6: return this.geometryContext.uvs6 ? A.FromArray(this.geometryContext.uvs6, 2 * t) : A.Zero(); case aT.VertexID: return t; case aT.FaceID: return this.executionContext.getExecutionFaceIndex() }return null }, e.prototype.adapt = function (e, t) { var i = e.getConnectedValue(this); if (e.type === t) return i; switch (t) { case Jb.Vector2: return new A(i, i); case Jb.Vector3: return new R(i, i, i); case Jb.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 Jb.Vector2: return new A(n, n); case Jb.Vector3: return new R(n, n, n); case Jb.Vector4: return new C(n, n, n, n) }return null }, e.prototype.emitErrors = function () { for (var e = "", t = 0, i = this.notConnectedNonOptionalInputs; t < i.length; t++) { var r = i[t]; e += "input ".concat(r.name, " from block ").concat(r.ownerBlock.name, "[").concat(r.ownerBlock.getClassName(), "] is not connected and is not optional.\n") } if (e) throw "Build of NodeGeometry failed:\n" + e }, e.prototype._instantiate = function (e, t, i, r, n) { I.ScalingToRef(r.x, r.y, r.z, this._scalingMatrix), I.RotationYawPitchRollToRef(i.y, i.x, i.z, this._rotationMatrix), I.TranslationToRef(t.x, t.y, t.z, this._positionMatrix), this._scalingMatrix.multiplyToRef(this._rotationMatrix, this._scalingRotationMatrix), this._scalingRotationMatrix.multiplyToRef(this._positionMatrix, this._transformMatrix); for (var o = 0; o < e.positions.length; o += 3)this._tempVector3.fromArray(e.positions, o), R.TransformCoordinatesToRef(this._tempVector3, this._transformMatrix, this._tempVector3), this._tempVector3.toArray(e.positions, o), e.normals && (this._tempVector3.fromArray(e.normals, o), R.TransformNormalToRef(this._tempVector3, this._scalingRotationMatrix, this._tempVector3), this._tempVector3.toArray(e.normals, o)); n.push(e) }, e }(), hT = function (e) { function t(t, i) { void 0 === i && (i = Jb.AutoDetect); var r = e.call(this, t) || this; return r._type = Jb.Undefined, r._contextualSource = aT.None, r.min = 0, r.max = 0, r.groupInInspector = "", r.onValueChangedObservable = new u, r._type = i, r.setDefaultValue(), r.registerOutput("output", i), r } return W(t, e), Object.defineProperty(t.prototype, "type", { get: function () { if (this._type === Jb.AutoDetect && null != this.value) { if (!isNaN(this.value)) return this._type = Jb.Float, this._type; switch (this.value.getClassName()) { case "Vector2": return this._type = Jb.Vector2, this._type; case "Vector3": return this._type = Jb.Vector3, this._type; case "Vector4": return this._type = Jb.Vector4, this._type; case "Matrix": return this._type = Jb.Matrix, this._type } } return this._type }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isContextual", { get: function () { return this._contextualSource !== aT.None }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "contextualValue", { get: function () { return this._contextualSource }, set: function (e) { switch (this._contextualSource = e, e) { case aT.Positions: case aT.Normals: this._type = Jb.Vector3; break; case aT.Colors: case aT.Tangents: this._type = Jb.Vector4; break; case aT.UV: case aT.UV2: case aT.UV3: case aT.UV4: case aT.UV5: case aT.UV6: this._type = Jb.Vector2; break; case aT.VertexID: case aT.FaceID: this._type = Jb.Int } }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "value", { get: function () { return this._storedValue }, set: function (e) { this.type === Jb.Float && this.min !== this.max && (e = Math.max(this.min, e), e = Math.min(this.max, e)), this._storedValue = e, this.onValueChangedObservable.notifyObservers(this) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "valueCallback", { get: function () { return this._valueCallback }, set: function (e) { this._valueCallback = e }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function () { return "GeometryInputBlock" }, Object.defineProperty(t.prototype, "output", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype.setDefaultValue = function () { switch (this.type) { case Jb.Int: case Jb.Float: this.value = 0; break; case Jb.Vector2: this.value = A.Zero(); break; case Jb.Vector3: this.value = R.Zero(); break; case Jb.Vector4: this.value = C.Zero(); break; case Jb.Matrix: this.value = I.Identity() } }, t.prototype._buildBlock = function (t) { var i = this; e.prototype._buildBlock.call(this, t), this.isContextual ? (this.output._storedValue = null, this.output._storedFunction = function (e) { return e.getContextualValue(i._contextualSource) }) : (this.output._storedFunction = null, this.output._storedValue = this.value) }, t.prototype.dispose = function () { this.onValueChangedObservable.clear(), e.prototype.dispose.call(this) }, t.prototype._dumpPropertiesCode = function () { var t = this._codeVariableName; if (this.isContextual) return e.prototype._dumpPropertiesCode.call(this) + "".concat(t, ".contextualValue = BABYLON.NodeGeometryContextualSources.").concat(aT[this._contextualSource], ";\n"); var i = [], r = ""; switch (this.type) { case Jb.Float: case Jb.Int: r = "".concat(this.value); break; case Jb.Vector2: r = "new BABYLON.Vector2(".concat(this.value.x, ", ").concat(this.value.y, ")"); break; case Jb.Vector3: r = "new BABYLON.Vector3(".concat(this.value.x, ", ").concat(this.value.y, ", ").concat(this.value.z, ")"); break; case Jb.Vector4: r = "new BABYLON.Vector4(".concat(this.value.x, ", ").concat(this.value.y, ", ").concat(this.value.z, ", ").concat(this.value.w, ")") }return i.push("".concat(t, ".value = ").concat(r)), this.type !== Jb.Float && this.type !== Jb.Int || i.push("".concat(t, ".min = ").concat(this.min), "".concat(t, ".max = ").concat(this.max)), i.push(""), e.prototype._dumpPropertiesCode.call(this) + i.join(";\n") }, t.prototype.serialize = function () { var t = e.prototype.serialize.call(this); return t.type = this.type, t.contextualValue = this.contextualValue, t.min = this.min, t.max = this.max, t.groupInInspector = this.groupInInspector, null === this._storedValue || this.isContextual || (this._storedValue.asArray ? (t.valueType = "BABYLON." + this._storedValue.getClassName(), t.value = this._storedValue.asArray()) : (t.valueType = "number", t.value = this._storedValue)), t }, t.prototype._deserialize = function (t) { if (e.prototype._deserialize.call(this, t), this._type = t.type, this.contextualValue = t.contextualValue, this.min = t.min || 0, this.max = t.max || 0, this.groupInInspector = t.groupInInspector || "", t.valueType) if ("number" === t.valueType) this._storedValue = t.value; else { var i = T(t.valueType); i && (this._storedValue = i.FromArray(t.value)) } }, t }(lT); b("BABYLON.GeometryInputBlock", hT); var dT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.evaluateContext = !1, i.registerInput("size", Jb.Float, !0, 1), i.registerInput("width", Jb.Float, !0, 0), i.registerInput("height", Jb.Float, !0, 0), i.registerInput("depth", Jb.Float, !0, 0), i.registerInput("subdivisions", Jb.Int, !0, 1), i.registerInput("subdivisionsX", Jb.Int, !0, 0), i.registerInput("subdivisionsY", Jb.Int, !0, 0), i.registerInput("subdivisionsZ", Jb.Int, !0, 0), i.registerOutput("geometry", Jb.Geometry), i } return W(t, e), t.prototype.getClassName = function () { return "BoxBlock" }, Object.defineProperty(t.prototype, "size", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "width", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "height", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "depth", { get: function () { return this._inputs[3] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subdivisions", { get: function () { return this._inputs[4] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subdivisionsX", { get: function () { return this._inputs[5] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subdivisionsY", { get: function () { return this._inputs[6] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subdivisionsZ", { get: function () { return this._inputs[7] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function () { if (!this.size.isConnected) { if (!this.width.isConnected && !this.height.isConnected && !this.depth.isConnected) { var e = new hT("Size"); return e.value = 1, void e.output.connectTo(this.size) } if (!this.width.isConnected) { var t = new hT("Width"); t.value = 1, t.output.connectTo(this.width) } if (!this.height.isConnected) { var i = new hT("Height"); i.value = 1, i.output.connectTo(this.height) } if (!this.depth.isConnected) { var r = new hT("Depth"); r.value = 1, r.output.connectTo(this.depth) } } }, t.prototype._buildBlock = function (e) { var t = this, i = {}, r = function (e) { i.size = t.size.getConnectedValue(e), i.width = t.width.getConnectedValue(e), i.height = t.height.getConnectedValue(e), i.depth = t.depth.getConnectedValue(e); var r = t.subdivisions.getConnectedValue(e), n = t.subdivisionsX.getConnectedValue(e), o = t.subdivisionsY.getConnectedValue(e), a = t.subdivisionsZ.getConnectedValue(e); return r && (i.segments = r), n && (i.widthSegments = n), o && (i.heightSegments = o), a && (i.depthSegments = a), mu(i) }; this.evaluateContext ? this.geometry._storedFunction = r : this.geometry._storedValue = r(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([ha("Evaluate context", ca.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t }(lT); b("BABYLON.BoxBlock", dT); var pT = function () { function e(t) { this._buildId = e._BuildIdGenerator++, this._buildWasSuccessful = !1, this._vertexData = null, this._buildExecutionTime = 0, this.BJSNODEGEOMETRYEDITOR = this._getGlobalNodeGeometryEditor(), this.editorData = null, this.attachedBlocks = new Array, this.onBuildObservable = new u, this.outputBlock = null, this.name = t } return e.prototype._getGlobalNodeGeometryEditor = function () { return "undefined" != typeof NODEGEOMETRYEDITOR ? NODEGEOMETRYEDITOR : "undefined" != typeof BABYLON && void 0 !== BABYLON.NodeGeometryEditor ? BABYLON : void 0 }, Object.defineProperty(e.prototype, "buildExecutionTime", { get: function () { return this._buildExecutionTime }, enumerable: !1, configurable: !0 }), e.prototype.getClassName = function () { return "NodeGeometry" }, e.prototype.getBlockByName = function (e) { for (var t = null, i = 0, r = this.attachedBlocks; i < r.length; i++) { var n = r[i]; if (n.name === e) { if (t) return xi.Warn("More than one block was found with the name `" + e + "`"), t; t = n } } return t }, e.prototype.getBlockByPredicate = function (e) { for (var t = 0, i = this.attachedBlocks; t < i.length; t++) { var r = i[t]; if (e(r)) return r } return null }, e.prototype.getInputBlocks = function () { for (var e = [], t = 0, i = this.attachedBlocks; t < i.length; t++) { var r = i[t]; r.isInput && e.push(r) } return e }, e.prototype.edit = function (t) { var i = this; return new Promise((function (r) { if (i.BJSNODEGEOMETRYEDITOR = i.BJSNODEGEOMETRYEDITOR || i._getGlobalNodeGeometryEditor(), void 0 === i.BJSNODEGEOMETRYEDITOR) { var n = t && t.editorURL ? t.editorURL : e.EditorURL; xi.LoadScript(n, (function () { i.BJSNODEGEOMETRYEDITOR = i.BJSNODEGEOMETRYEDITOR || i._getGlobalNodeGeometryEditor(), i._createNodeEditor(null == t ? void 0 : t.nodeGeometryEditorConfig), r() })) } else i._createNodeEditor(null == t ? void 0 : t.nodeGeometryEditorConfig), r() })) }, e.prototype._createNodeEditor = function (e) { var t = H({ nodeGeometry: this }, e); this.BJSNODEGEOMETRYEDITOR.NodeGeometryEditor.Show(t) }, e.prototype.build = function (t, i, r) { if (void 0 === t && (t = !1), void 0 === i && (i = !0), void 0 === r && (r = !1), this._buildWasSuccessful = !1, !this.outputBlock) throw "You must define the outputBlock property before building the geometry"; var n = at.Now; this._initializeBlock(this.outputBlock, r); var o = new uT; o.buildId = this._buildId, o.verbose = t, this.outputBlock.build(o), i && (this._buildId = e._BuildIdGenerator++), this._buildExecutionTime = at.Now - n, o.emitErrors(), this._buildWasSuccessful = !0, this._vertexData = o.vertexData, this.onBuildObservable.notifyObservers(this) }, e.prototype.createMesh = function (e, t) { if (void 0 === t && (t = null), this._buildWasSuccessful || this.build(), !this._vertexData) return null; var i = new Jn(e, t); return this._vertexData.applyToMesh(i), i._internalMetadata = i._internalMetadata || {}, i._internalMetadata.nodeGeometry = this, i }, e.prototype._initializeBlock = function (e, t) { void 0 === t && (t = !0), e.initialize(), t && e.autoConfigure(), e._preparationId = this._buildId, -1 === this.attachedBlocks.indexOf(e) && this.attachedBlocks.push(e); for (var i = 0, r = e.inputs; i < r.length; i++) { var n = r[i].connectedPoint; if (n) { var o = n.ownerBlock; o !== e && this._initializeBlock(o, t) } } }, e.prototype.clear = function () { this.outputBlock = null, this.attachedBlocks.length = 0 }, e.prototype.removeBlock = function (e) { var t = this.attachedBlocks.indexOf(e); 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; r < n.length; r++) { var o = T((h = n[r]).customType); o && ((d = new o)._deserialize(h), i[h.id] = d, this.attachedBlocks.push(d)) } for (var a = 0, s = this.attachedBlocks; a < s.length; a++)if ((d = s[a]).isTeleportOut) { var l = d, c = l._tempEntryPointUniqueId; c && i[c].attachToEndpoint(l) } for (var u = 0; u < e.blocks.length; u++) { var h, d; (d = i[(h = e.blocks[u]).id]) && (d.inputs.length && h.inputs.some((function (e) { return e.targetConnectionName })) && !t || this._restoreConnections(d, e, i)) } if (e.outputNodeId && (this.outputBlock = i[e.outputNodeId]), e.locations || e.editorData && e.editorData.locations) { for (var p = e.locations || e.editorData.locations, f = 0, _ = p; f < _.length; f++) { var m = _[f]; i[m.blockId] && (m.blockId = i[m.blockId].uniqueId) } t && this.editorData && this.editorData.locations && p.concat(this.editorData.locations), e.locations ? this.editorData = { locations: p } : (this.editorData = e.editorData, this.editorData.locations = p); var g = []; for (var v in i) g[v] = i[v].uniqueId; this.editorData.map = g } this.comment = e.comment }, e.prototype._restoreConnections = function (e, t, i) { for (var r = 0, n = e.outputs; r < n.length; r++)for (var o = n[r], a = 0, s = t.blocks; a < s.length; a++) { var l = s[a], c = i[l.id]; if (c) for (var u = 0, h = l.inputs; u < h.length; u++) { var d = h[u]; if (i[d.targetBlockId] !== e || d.targetConnectionName !== o.name); else { var p = c.getInputByName(d.inputName); if (!p || p.isConnected) continue; o.connectTo(p, !0), this._restoreConnections(c, t, i) } } } }, e.prototype.generateCode = function () { var e = [], t = [], i = ["const", "var", "let"]; this.outputBlock && this._gatherBlocks(this.outputBlock, t); for (var r = 'let nodeGeometry = new BABYLON.NodeGeometry("'.concat(this.name || "node geometry", '");\n'), n = 0, o = t; n < o.length; n++) { var a = o[n]; a.isInput && -1 === e.indexOf(a) && (r += a._dumpCode(i, e)) } return this.outputBlock && (e = [], r += "\n`;// Connections\n`;", r += this.outputBlock._dumpCodeForOutputConnections(e), r += "\n`;// Output nodes\n`;", r += "nodeGeometry.outputBlock = ".concat(this.outputBlock._codeVariableName, ";\n"), r += "nodeGeometry.build();\n"), r }, e.prototype._gatherBlocks = function (e, t) { if (-1 === t.indexOf(e)) { t.push(e); for (var i = 0, r = e.inputs; i < r.length; i++) { var n = r[i].connectedPoint; n && (o = n.ownerBlock) !== e && this._gatherBlocks(o, t) } var o; e.isTeleportOut && (o = e).entryPoint && this._gatherBlocks(o.entryPoint, t) } }, e.prototype.setToDefault = function () { this.clear(), this.editorData = null; var e = new dT("Box"); e.autoConfigure(); var t = new cT("Geometry Output"); e.geometry.connectTo(t.geometry), this.outputBlock = t }, e.prototype.clone = function (t) { var i = this.serialize(), r = Ue.Clone((function () { return new e(t) }), this); return r.name = t, r.parseSerializedObject(i), r._buildId = this._buildId, r.build(!1), r }, e.prototype.serialize = function (e, t) { var i = t ? {} : Ue.Serialize(this); i.editorData = JSON.parse(JSON.stringify(this.editorData)); var r = []; t ? r = t : (i.customType = "BABYLON.NodeGeometry", this.outputBlock && (i.outputNodeId = this.outputBlock.uniqueId)), i.blocks = []; for (var n = 0, o = r; n < o.length; n++) { var a = o[n]; i.blocks.push(a.serialize(e)) } if (!t) for (var s = 0, l = this.attachedBlocks; s < l.length; s++)a = l[s], -1 === r.indexOf(a) && i.blocks.push(a.serialize(e)); return i }, e.prototype.dispose = function () { for (var e = 0, t = this.attachedBlocks; e < t.length; e++)t[e].dispose(); this.attachedBlocks.length = 0, this.onBuildObservable.clear() }, e.CreateDefault = function (t) { var i = new e(t); return i.setToDefault(), i.build(), i }, e.Parse = function (t) { var i = Ue.Parse((function () { return new e(t.name) }), t, null); return i.parseSerializedObject(t), i.build(), i }, e.ParseFromSnippetAsync = function (t, i, r) { var n = this; return void 0 === r && (r = !1), "_BLANK" === t ? Promise.resolve(e.CreateDefault("blank")) : new Promise((function (o, a) { var s = new He; s.addEventListener("readystatechange", (function () { if (4 == s.readyState) if (200 == s.status) { var n = JSON.parse(JSON.parse(s.responseText).jsonPayload), l = JSON.parse(n.nodeGeometry); i || (i = Ue.Parse((function () { return new e(t) }), l, null)), i.parseSerializedObject(l), i.snippetId = t; try { r || i.build(), o(i) } catch (e) { a(e) } } else a("Unable to load the snippet " + t) })), s.open("GET", n.SnippetUrl + "/" + t.replace(/#/g, "/")), s.send() })) }, e._BuildIdGenerator = 0, e.EditorURL = "https://unpkg.com/babylonjs-node-geometry-editor@".concat(In.Version, "/babylon.nodeGeometryEditor.js"), e.SnippetUrl = a.SnippetUrl, X([xe()], e.prototype, "name", void 0), X([xe("comment")], e.prototype, "comment", void 0), e }(), fT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.evaluateContext = !1, i.epsilon = _, i.registerInput("geometry", Jb.Geometry), i.registerOutput("output", Jb.Geometry), i } return W(t, e), t.prototype.getClassName = function () { return "GeometryOptimizeBlock" }, 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 (e) { var t = this, i = function (e) { if (!t.geometry.isConnected) return null; for (var i = t.geometry.getConnectedValue(e), r = [], n = {}, o = 0; o < i.positions.length; o += 3) { for (var a = i.positions[o], s = i.positions[o + 1], l = i.positions[o + 2], c = !1, u = 0; u < r.length; u += 3)h.WithinEpsilon(a, r[u], t.epsilon) && h.WithinEpsilon(s, r[u + 1], t.epsilon) && h.WithinEpsilon(l, r[u + 2], t.epsilon) && (n[o / 3] = u / 3, c = !0); c || (n[o / 3] = r.length / 3, r.push(a, s, l)) } var d = new En; return d.positions = r, d.indices = i.indices.map((function (e) { return n[e] })), d }; this.evaluateContext ? this.output._storedFunction = i : 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, ".epsilon = ").concat(this.epsilon, ";\n") }, t.prototype.serialize = function () { var t = e.prototype.serialize.call(this); return t.evaluateContext = this.evaluateContext, t.epsilon = this.epsilon, t }, t.prototype._deserialize = function (t) { e.prototype._deserialize.call(this, t), this.evaluateContext = t.evaluateContext, this.epsilon = t.epsilon }, X([ha("Evaluate context", ca.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), X([ha("Epsilon", ca.Float, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "epsilon", void 0), t }(lT); b("BABYLON.GeometryOptimizeBlock", fT); var _T = function (e) { function t(t) { var i = e.call(this, t) || this; return i.evaluateContext = !1, i.registerInput("size", Jb.Float, !0, 1), i.registerInput("width", Jb.Float, !0, 0), i.registerInput("height", Jb.Float, !0, 0), i.registerOutput("geometry", Jb.Geometry), i } return W(t, e), t.prototype.getClassName = function () { return "PlaneBlock" }, Object.defineProperty(t.prototype, "size", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "width", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "height", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function () { if (!this.size.isConnected) { if (!this.width.isConnected && !this.height.isConnected) { var e = new hT("Size"); return e.value = 1, void e.output.connectTo(this.size) } if (!this.width.isConnected) { var t = new hT("Width"); t.value = 1, t.output.connectTo(this.width) } if (!this.height.isConnected) { var i = new hT("Height"); i.value = 1, i.output.connectTo(this.height) } } }, t.prototype._buildBlock = function (e) { var t = this, i = {}, r = function (e) { return i.size = t.size.getConnectedValue(e), i.width = t.width.getConnectedValue(e), i.height = t.height.getConnectedValue(e), Do(i) }; this.evaluateContext ? this.geometry._storedFunction = r : this.geometry._storedValue = r(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([ha("Evaluate context", ca.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t }(lT); b("BABYLON.PlaneBlock", _T); var mT = function (e) { function t(t) { var i = e.call(this, t) || this; return i._cachedVertexData = null, i.registerOutput("geometry", Jb.Geometry), i } return W(t, e), Object.defineProperty(t.prototype, "mesh", { get: function () { return this._mesh }, set: function (e) { this._mesh = e }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function () { return "MeshBlock" }, Object.defineProperty(t.prototype, "geometry", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function () { this._mesh ? (this.geometry._storedValue = En.ExtractFromMesh(this._mesh, !1, !0), this._cachedVertexData = null) : this._cachedVertexData ? this.geometry._storedValue = this._cachedVertexData.clone() : this.geometry._storedValue = null }, t.prototype.serialize = function (t) { var i = e.prototype.serialize.call(this); return t && (this._mesh ? i.cachedVertexData = En.ExtractFromMesh(this._mesh, !1, !0).serialize() : this._cachedVertexData && (i.cachedVertexData = this._cachedVertexData.serialize())), i }, t.prototype._deserialize = function (t) { e.prototype._deserialize.call(this, t), t.cachedVertexData && (this._cachedVertexData = En.Parse(t.cachedVertexData)) }, t }(lT); b("BABYLON.MeshBlock", mT); var gT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.evaluateContext = !1, i.registerInput("radius", Jb.Float, !0, 1), i.registerInput("radiusX", Jb.Float, !0, 0), i.registerInput("radiusY", Jb.Float, !0, 0), i.registerInput("radiusZ", Jb.Float, !0, 0), i.registerInput("subdivisions", Jb.Int, !0, 4), i.registerOutput("geometry", Jb.Geometry), i } return W(t, e), t.prototype.getClassName = function () { return "IcoSphereBlock" }, Object.defineProperty(t.prototype, "radius", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "radiusX", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "radiusY", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "radiusZ", { get: function () { return this._inputs[3] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subdivisions", { get: function () { return this._inputs[4] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function () { if (!this.radius.isConnected) { var e = new hT("Radius"); e.value = .2, e.output.connectTo(this.radius) } }, t.prototype._buildBlock = function (e) { var t = this, i = {}, r = function (e) { return i.radius = t.radius.getConnectedValue(e), i.subdivisions = t.subdivisions.getConnectedValue(e), i.radiusX = t.radiusX.getConnectedValue(e), i.radiusY = t.radiusY.getConnectedValue(e), i.radiusZ = t.radiusZ.getConnectedValue(e), ls(i) }; this.evaluateContext ? this.geometry._storedFunction = r : this.geometry._storedValue = r(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([ha("Evaluate context", ca.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t }(lT); b("BABYLON.IcoSphereBlock", gT); var vT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.evaluateContext = !1, i.registerInput("segments", Jb.Int, !0, 32), i.registerInput("diameter", Jb.Float, !0, 1), i.registerInput("diameterX", Jb.Float, !0, 0), i.registerInput("diameterY", Jb.Float, !0, 0), i.registerInput("diameterZ", Jb.Float, !0, 0), i.registerInput("arc", Jb.Float, !0, 1), i.registerInput("slice", Jb.Float, !0, 1), i.registerOutput("geometry", Jb.Geometry), i } return W(t, e), t.prototype.getClassName = function () { return "SphereBlock" }, Object.defineProperty(t.prototype, "segments", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "diameter", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "diameterX", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "diameterY", { get: function () { return this._inputs[3] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "diameterZ", { get: function () { return this._inputs[4] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "arc", { get: function () { return this._inputs[5] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "slice", { get: function () { return this._inputs[6] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function () { if (!this.diameter.isConnected) { var e = new hT("Diameter"); e.value = 1, e.output.connectTo(this.diameter) } }, t.prototype._buildBlock = function (e) { var t = this, i = {}, r = function (e) { return i.segments = t.segments.getConnectedValue(e), i.diameter = t.diameter.getConnectedValue(e), i.diameterX = t.diameterX.getConnectedValue(e), i.diameterY = t.diameterY.getConnectedValue(e), i.diameterZ = t.diameterZ.getConnectedValue(e), i.arc = t.arc.getConnectedValue(e), i.slice = t.slice.getConnectedValue(e), yu(i) }; this.evaluateContext ? this.geometry._storedFunction = r : this.geometry._storedValue = r(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([ha("Evaluate context", ca.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t }(lT); b("BABYLON.SphereBlock", vT); var yT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.evaluateContext = !1, i.registerInput("width", Jb.Float, !0, 1), i.registerInput("height", Jb.Float, !0, 1), i.registerInput("subdivisions", Jb.Int, !0, 1), i.registerInput("subdivisionsX", Jb.Int, !0, 0), i.registerInput("subdivisionsY", Jb.Int, !0, 0), i.registerOutput("geometry", Jb.Geometry), i } return W(t, e), t.prototype.getClassName = function () { return "GridBlock" }, Object.defineProperty(t.prototype, "width", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "height", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subdivisions", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subdivisionsX", { get: function () { return this._inputs[3] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subdivisionsY", { get: function () { return this._inputs[4] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function () { if (!this.width.isConnected) { var e = new hT("Width"); e.value = 1, e.output.connectTo(this.width) } if (!this.height.isConnected) { var t = new hT("Height"); t.value = 1, t.output.connectTo(this.height) } }, t.prototype._buildBlock = function (e) { var t = this, i = {}, r = function (e) { return i.width = t.width.getConnectedValue(e), i.height = t.height.getConnectedValue(e), i.subdivisions = t.subdivisions.getConnectedValue(e), i.subdivisionsX = t.subdivisionsX.getConnectedValue(e), i.subdivisionsY = t.subdivisionsY.getConnectedValue(e), Uc(i) }; this.evaluateContext ? this.geometry._storedFunction = r : this.geometry._storedValue = r(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([ha("Evaluate context", ca.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t }(lT); b("BABYLON.GridBlock", yT); var bT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.evaluateContext = !1, i.registerInput("diameter", Jb.Float, !0, 1), i.registerInput("thickness", Jb.Float, !0, .5), i.registerInput("tessellation", Jb.Int, !0, 16), i.registerOutput("geometry", Jb.Geometry), i } return W(t, e), t.prototype.getClassName = function () { return "TorusBlock" }, Object.defineProperty(t.prototype, "diameter", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "thickness", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tessellation", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function () { if (!this.diameter.isConnected) { var e = new hT("Diameter"); e.value = 1, e.output.connectTo(this.diameter) } }, t.prototype._buildBlock = function (e) { var t = this, i = {}, r = function (e) { return i.thickness = t.thickness.getConnectedValue(e), i.diameter = t.diameter.getConnectedValue(e), i.tessellation = t.tessellation.getConnectedValue(e), Fc(i) }; this.evaluateContext ? this.geometry._storedFunction = r : this.geometry._storedValue = r(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([ha("Evaluate context", ca.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t }(lT); b("BABYLON.TorusBlock", bT); var TT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.evaluateContext = !1, i.registerInput("height", Jb.Float, !0, 25), i.registerInput("diameter", Jb.Float, !0, 1), i.registerInput("diameterTop", Jb.Float, !0, 0), i.registerInput("diameterBottom", Jb.Float, !0, 0), i.registerInput("subdivisions", Jb.Int, !0, 1), i.registerInput("tessellation", Jb.Int, !0, 24), i.registerInput("arc", Jb.Float, !0, 1), i.registerOutput("geometry", Jb.Geometry), i } return W(t, e), t.prototype.getClassName = function () { return "CylinderBlock" }, Object.defineProperty(t.prototype, "height", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "diameter", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "diameterTop", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "diameterBottom", { get: function () { return this._inputs[3] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subdivisions", { get: function () { return this._inputs[4] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tessellation", { get: function () { return this._inputs[5] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "arc", { get: function () { return this._inputs[6] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function () { if (!this.diameter.isConnected) { var e = new hT("Diameter"); e.value = 1, e.output.connectTo(this.diameter) } if (!this.height.isConnected) { var t = new hT("Height"); t.value = 1, t.output.connectTo(this.height) } }, t.prototype._buildBlock = function (e) { var t = this, i = {}, r = function (e) { return i.height = t.height.getConnectedValue(e), i.diameter = t.diameter.getConnectedValue(e), i.diameter || (i.diameterTop = t.diameterTop.getConnectedValue(e), i.diameterBottom = t.diameterBottom.getConnectedValue(e)), i.tessellation = t.tessellation.getConnectedValue(e), i.subdivisions = t.subdivisions.getConnectedValue(e), i.arc = t.arc.getConnectedValue(e), Oc(i) }; this.evaluateContext ? this.geometry._storedFunction = r : this.geometry._storedValue = r(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([ha("Evaluate context", ca.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t }(lT); b("BABYLON.CylinderBlock", TT); var ET = function (e) { function t(t) { var i = e.call(this, t) || this; return i.evaluateContext = !1, i.registerInput("height", Jb.Float, !0, 1), i.registerInput("radius", Jb.Float, !0, .25), i.registerInput("tessellation", Jb.Int, !0, 16), i.registerInput("subdivisions", Jb.Int, !0, 2), i.registerOutput("geometry", Jb.Geometry), i } return W(t, e), t.prototype.getClassName = function () { return "CapsuleBlock" }, Object.defineProperty(t.prototype, "height", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "radius", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tessellation", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subdivisions", { get: function () { return this._inputs[3] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function () { if (!this.height.isConnected) { var e = new hT("Height"); e.value = 1, e.output.connectTo(this.height) } if (!this.radius.isConnected) { var t = new hT("Radius"); t.value = .2, t.output.connectTo(this.radius) } }, t.prototype._buildBlock = function (e) { var t = this, i = {}, r = function (e) { return i.height = t.height.getConnectedValue(e), i.radius = t.radius.getConnectedValue(e), i.tessellation = t.tessellation.getConnectedValue(e), i.subdivisions = t.subdivisions.getConnectedValue(e), Eu(i) }; this.evaluateContext ? this.geometry._storedFunction = r : this.geometry._storedValue = r(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([ha("Evaluate context", ca.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t }(lT); b("BABYLON.CapsuleBlock", ET); var ST = function (e) { function t(t) { var i = e.call(this, t) || this; return i.evaluateContext = !1, i.registerInput("radius", Jb.Float, !0, .5), i.registerInput("tessellation", Jb.Int, !0, 64), i.registerInput("arc", Jb.Float, !0, 1), i.registerOutput("geometry", Jb.Geometry), i } return W(t, e), t.prototype.getClassName = function () { return "DiscBlock" }, Object.defineProperty(t.prototype, "radius", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tessellation", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "arc", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "geometry", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function () { if (!this.radius.isConnected) { var e = new hT("Radius"); e.value = .2, e.output.connectTo(this.radius) } }, t.prototype._buildBlock = function (e) { var t = this, i = {}, r = function (e) { return i.radius = t.radius.getConnectedValue(e), i.tessellation = t.tessellation.getConnectedValue(e), i.arc = t.arc.getConnectedValue(e), Pu(i) }; this.evaluateContext ? this.geometry._storedFunction = r : this.geometry._storedValue = r(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([ha("Evaluate context", ca.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t }(lT); b("BABYLON.DiscBlock", ST); var xT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.registerOutput("geometry", Jb.Geometry), i } return W(t, e), t.prototype.getClassName = function () { return "NullBlock" }, Object.defineProperty(t.prototype, "geometry", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function () { this.geometry._storedValue = null }, t }(lT); b("BABYLON.NullBlock", xT); var AT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.registerInput("geometry", Jb.Geometry), i.registerInput("positions", Jb.Vector3), i.registerOutput("output", Jb.Geometry), i } return W(t, e), t.prototype.getExecutionIndex = function () { return this._currentIndex }, t.prototype.getExecutionFaceIndex = function () { return 0 }, t.prototype.getClassName = function () { return "SetPositionsBlock" }, Object.defineProperty(t.prototype, "geometry", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "positions", { 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) { if (e.executionContext = this, this._vertexData = this.geometry.getConnectedValue(e), e.geometryContext = this._vertexData, !this._vertexData || !this._vertexData.positions || !this.positions.isConnected) return e.executionContext = null, e.geometryContext = null, void (this.output._storedValue = null); var t = this._vertexData.positions.length / 3; for (this._currentIndex = 0; this._currentIndex < t; this._currentIndex++) { var i = this.positions.getConnectedValue(e); i && i.toArray(this._vertexData.positions, 3 * this._currentIndex) } this.output._storedValue = this._vertexData, e.executionContext = null, e.geometryContext = null }, t }(lT); b("BABYLON.SetPositionsBlock", AT); var RT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.registerInput("geometry", Jb.Geometry), i.registerInput("normals", Jb.Vector3), i.registerOutput("output", Jb.Geometry), i } return W(t, e), t.prototype.getExecutionIndex = function () { return this._currentIndex }, t.prototype.getExecutionFaceIndex = function () { return 0 }, t.prototype.getClassName = function () { return "SetNormalsBlock" }, Object.defineProperty(t.prototype, "geometry", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "normals", { 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) { if (e.executionContext = this, this._vertexData = this.geometry.getConnectedValue(e), e.geometryContext = this._vertexData, !this._vertexData || !this._vertexData.positions) return e.executionContext = null, e.geometryContext = null, void (this.output._storedValue = null); if (!this.normals.isConnected) return e.executionContext = null, e.geometryContext = null, void (this.output._storedValue = this._vertexData); this._vertexData.normals || (this._vertexData.normals = []); var t = this._vertexData.positions.length / 3; for (this._currentIndex = 0; this._currentIndex < t; this._currentIndex++) { var i = this.normals.getConnectedValue(e); i && i.toArray(this._vertexData.normals, 3 * this._currentIndex) } this.output._storedValue = this._vertexData, e.executionContext = null, e.geometryContext = null }, t }(lT); b("BABYLON.SetNormalsBlock", RT); var CT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.textureCoordinateIndex = 0, i.registerInput("geometry", Jb.Geometry), i.registerInput("uvs", Jb.Vector2), i.registerOutput("output", Jb.Geometry), i } return W(t, e), t.prototype.getExecutionIndex = function () { return this._currentIndex }, t.prototype.getExecutionFaceIndex = function () { return 0 }, t.prototype.getClassName = function () { return "SetUVsBlock" }, Object.defineProperty(t.prototype, "geometry", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "uvs", { 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) { if (e.executionContext = this, this._vertexData = this.geometry.getConnectedValue(e), e.geometryContext = this._vertexData, !this._vertexData || !this._vertexData.positions) return e.executionContext = null, e.geometryContext = null, void (this.output._storedValue = null); if (!this.uvs.isConnected) return e.executionContext = null, e.geometryContext = null, void (this.output._storedValue = this._vertexData); var t = [], i = this._vertexData.positions.length / 3; for (this._currentIndex = 0; this._currentIndex < i; this._currentIndex++) { var r = this.uvs.getConnectedValue(e); r && r.toArray(t, 2 * this._currentIndex) } switch (this.textureCoordinateIndex) { case 0: this._vertexData.uvs = t; break; case 1: this._vertexData.uvs2 = t; break; case 2: this._vertexData.uvs3 = t; break; case 3: this._vertexData.uvs4 = t; break; case 4: this._vertexData.uvs5 = t; break; case 5: this._vertexData.uvs6 = t }this.output._storedValue = this._vertexData, e.executionContext = null, e.geometryContext = null }, t.prototype._dumpPropertiesCode = function () { return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".textureCoordinateIndex};\n") }, t.prototype.serialize = function () { var t = e.prototype.serialize.call(this); return t.textureCoordinateIndex = this.textureCoordinateIndex, t }, t.prototype._deserialize = function (t) { e.prototype._deserialize.call(this, t), this.textureCoordinateIndex = t.textureCoordinateIndex }, X([ha("Texture coordinates index", ca.List, "ADVANCED", { notifiers: { update: !0 }, options: [{ label: "UV1", value: 0 }, { label: "UV2", value: 1 }, { label: "UV3", value: 2 }, { label: "UV4", value: 3 }, { label: "UV5", value: 4 }, { label: "UV6", value: 5 }] })], t.prototype, "textureCoordinateIndex", void 0), t }(lT); b("BABYLON.SetUVsBlock", CT); var PT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.registerInput("geometry", Jb.Geometry), i.registerInput("colors", Jb.Vector4), i.registerOutput("output", Jb.Geometry), i } return W(t, e), t.prototype.getExecutionIndex = function () { return this._currentIndex }, t.prototype.getExecutionFaceIndex = function () { return 0 }, t.prototype.getClassName = function () { return "SetColorsBlock" }, Object.defineProperty(t.prototype, "geometry", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "colors", { 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) { if (e.executionContext = this, this._vertexData = this.geometry.getConnectedValue(e), e.geometryContext = this._vertexData, !this._vertexData || !this._vertexData.positions) return e.executionContext = null, e.geometryContext = null, void (this.output._storedValue = null); if (!this.colors.isConnected) return e.executionContext = null, e.geometryContext = null, void (this.output._storedValue = this._vertexData); this._vertexData.colors || (this._vertexData.colors = []); var t = this._vertexData.positions.length / 3; for (this._currentIndex = 0; this._currentIndex < t; this._currentIndex++) { var i = this.colors.getConnectedValue(e); i && i.toArray(this._vertexData.colors, 4 * this._currentIndex) } this.output._storedValue = this._vertexData, e.executionContext = null, e.geometryContext = null }, t }(lT); b("BABYLON.SetColorsBlock", PT); var IT, MT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.registerInput("geometry", Jb.Geometry), i.registerInput("tangents", Jb.Vector4), i.registerOutput("output", Jb.Geometry), i } return W(t, e), t.prototype.getExecutionIndex = function () { return this._currentIndex }, t.prototype.getExecutionFaceIndex = function () { return 0 }, t.prototype.getClassName = function () { return "SetTangentsBlock" }, Object.defineProperty(t.prototype, "geometry", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tangents", { 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) { if (e.executionContext = this, this._vertexData = this.geometry.getConnectedValue(e), e.geometryContext = this._vertexData, !this._vertexData || !this._vertexData.positions) return e.executionContext = null, e.geometryContext = null, void (this.output._storedValue = null); if (!this.tangents.isConnected) return e.executionContext = null, e.geometryContext = null, void (this.output._storedValue = this._vertexData); this._vertexData.tangents || (this._vertexData.tangents = []); var t = this._vertexData.positions.length / 3; for (this._currentIndex = 0; this._currentIndex < t; this._currentIndex++) { var i = this.tangents.getConnectedValue(e); i && i.toArray(this._vertexData.tangents, 4 * this._currentIndex) } this.output._storedValue = this._vertexData, e.executionContext = null, e.geometryContext = null }, t }(lT); b("BABYLON.SetTangentsBlock", MT), function (e) { e[e.Add = 0] = "Add", e[e.Subtract = 1] = "Subtract", e[e.Multiply = 2] = "Multiply", e[e.Divide = 3] = "Divide", e[e.Max = 4] = "Max", e[e.Min = 5] = "Min" }(IT || (IT = {})); var OT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.operation = IT.Add, i.registerInput("left", Jb.AutoDetect), i.registerInput("right", Jb.AutoDetect), i.registerOutput("output", Jb.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._inputs[0].excludedConnectionPointTypes.push(Jb.Matrix), i._inputs[0].excludedConnectionPointTypes.push(Jb.Geometry), i._inputs[1].excludedConnectionPointTypes.push(Jb.Matrix), i._inputs[1].excludedConnectionPointTypes.push(Jb.Geometry), i._linkConnectionTypes(0, 1), i } return W(t, e), t.prototype.getClassName = function () { return "MathBlock" }, 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 () { var e, t = this.left, i = this.right; if (!t.isConnected || !i.isConnected) return this.output._storedFunction = null, void (this.output._storedValue = null); var r = t.type === Jb.Float || t.type === Jb.Int; switch (this.operation) { case IT.Add: e = r ? function (e) { return t.getConnectedValue(e) + i.getConnectedValue(e) } : function (e) { return t.getConnectedValue(e).add(e.adapt(i, t.type)) }; break; case IT.Subtract: e = r ? function (e) { return t.getConnectedValue(e) - i.getConnectedValue(e) } : function (e) { return t.getConnectedValue(e).subtract(e.adapt(i, t.type)) }; break; case IT.Multiply: e = r ? function (e) { return t.getConnectedValue(e) * i.getConnectedValue(e) } : function (e) { return t.getConnectedValue(e).multiply(e.adapt(i, t.type)) }; break; case IT.Divide: e = r ? function (e) { return t.getConnectedValue(e) / i.getConnectedValue(e) } : function (e) { return t.getConnectedValue(e).divide(e.adapt(i, t.type)) }; break; case IT.Min: if (r) e = function (e) { return Math.min(t.getConnectedValue(e), i.getConnectedValue(e)) }; else switch (t.type) { case Jb.Vector2: e = function (e) { return A.Minimize(t.getConnectedValue(e), e.adapt(i, t.type)) }; break; case Jb.Vector3: e = function (e) { return R.Minimize(t.getConnectedValue(e), e.adapt(i, t.type)) }; break; case Jb.Vector4: e = function (e) { return C.Minimize(t.getConnectedValue(e), e.adapt(i, t.type)) } }break; case IT.Max: if (!r) { switch (t.type) { case Jb.Vector2: e = function (e) { return A.Maximize(t.getConnectedValue(e), e.adapt(i, t.type)) }; break; case Jb.Vector3: e = function (e) { return R.Maximize(t.getConnectedValue(e), e.adapt(i, t.type)) }; break; case Jb.Vector4: e = function (e) { return C.Maximize(t.getConnectedValue(e), e.adapt(i, t.type)) } }break } e = function (e) { return Math.max(t.getConnectedValue(e), i.getConnectedValue(e)) } }this.output._storedFunction = function (i) { return t.type === Jb.Int ? 0 | e(i) : e(i) } }, t.prototype._dumpPropertiesCode = function () { return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".operation = BABYLON.MathBlockOperations.").concat(IT[this.operation], ";\n") }, 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 }, X([ha("Operation", ca.List, "ADVANCED", { notifiers: { rebuild: !0 }, options: [{ label: "Add", value: IT.Add }, { label: "Subtract", value: IT.Subtract }, { label: "Multiply", value: IT.Multiply }, { label: "Divide", value: IT.Divide }, { label: "Max", value: IT.Max }, { label: "Min", value: IT.Min }] })], t.prototype, "operation", void 0), t }(lT); b("BABYLON.MathBlock", OT); var DT, NT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.registerInput("value", Jb.AutoDetect), i.registerInput("fromMin", Jb.Float, !0, 0), i.registerInput("fromMax", Jb.Float, !0, 1), i.registerInput("toMin", Jb.Float, !0, 0), i.registerInput("toMax", Jb.Float, !0, 1), i.registerOutput("output", Jb.BasedOnInput), i._inputs[0].excludedConnectionPointTypes.push(Jb.Matrix), i._inputs[0].excludedConnectionPointTypes.push(Jb.Geometry), i._outputs[0]._typeConnectionSource = i._inputs[0], i } return W(t, e), t.prototype.getClassName = function () { return "MapRangeBlock" }, Object.defineProperty(t.prototype, "value", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fromMin", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fromMax", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "toMin", { get: function () { return this._inputs[3] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "toMax", { 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 () { var e = this; if (!this.value.isConnected) return this.output._storedFunction = null, void (this.output._storedValue = null); this.output._storedFunction = function (t) { var i = e.value.getConnectedValue(t), r = e.fromMin.getConnectedValue(t), n = e.fromMax.getConnectedValue(t), o = e.toMin.getConnectedValue(t); return (i - r) / (n - r) * (e.toMax.getConnectedValue(t) - o) + o } }, t }(lT); b("BABYLON.MapRangeBlock", NT), function (e) { e[e.Equal = 0] = "Equal", e[e.NotEqual = 1] = "NotEqual", e[e.LessThan = 2] = "LessThan", e[e.GreaterThan = 3] = "GreaterThan", e[e.LessOrEqual = 4] = "LessOrEqual", e[e.GreaterOrEqual = 5] = "GreaterOrEqual", e[e.Xor = 6] = "Xor", e[e.Or = 7] = "Or", e[e.And = 8] = "And" }(DT || (DT = {})); var FT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.test = DT.Equal, i.registerInput("left", Jb.Float), i.registerInput("right", Jb.Float, !0, 0), i.registerInput("ifTrue", Jb.AutoDetect), i.registerInput("ifFalse", Jb.AutoDetect), i.registerOutput("output", Jb.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[2], i._inputs[0].acceptedConnectionPointTypes.push(Jb.Int), i._inputs[1].acceptedConnectionPointTypes.push(Jb.Int), i._linkConnectionTypes(2, 3), i } return W(t, e), t.prototype.getClassName = function () { return "ConditionBlock" }, 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, "ifTrue", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "ifFalse", { 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._buildBlock = function () { var e = this; if (!this.left.isConnected || !this.ifTrue.isConnected || !this.ifFalse.isConnected) return this.output._storedFunction = null, void (this.output._storedValue = null); this.output._storedFunction = function (t) { return function (t) { var i = e.left.getConnectedValue(t), r = e.right.getConnectedValue(t), n = !1; switch (e.test) { case DT.Equal: n = i === r; break; case DT.NotEqual: n = i !== r; break; case DT.LessThan: n = i < r; break; case DT.GreaterThan: n = i > r; break; case DT.LessOrEqual: n = i <= r; break; case DT.GreaterOrEqual: n = i >= r; break; case DT.Xor: n = !!i && !r || !i && !!r; break; case DT.Or: n = !!i || !!r; break; case DT.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(DT[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([ha("Test", ca.List, "ADVANCED", { notifiers: { rebuild: !0 }, options: [{ label: "Equal", value: DT.Equal }, { label: "NotEqual", value: DT.NotEqual }, { label: "LessThan", value: DT.LessThan }, { label: "GreaterThan", value: DT.GreaterThan }, { label: "LessOrEqual", value: DT.LessOrEqual }, { label: "GreaterOrEqual", value: DT.GreaterOrEqual }, { label: "Xor", value: DT.Xor }, { label: "Or", value: DT.Or }, { label: "And", value: DT.And }] })], t.prototype, "test", void 0), t }(lT); b("BABYLON.ConditionBlock", FT); var LT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.registerInput("min", Jb.AutoDetect), i.registerInput("max", Jb.AutoDetect), i.registerOutput("output", Jb.BasedOnInput), i._inputs[0].excludedConnectionPointTypes.push(Jb.Matrix), i._inputs[0].excludedConnectionPointTypes.push(Jb.Geometry), i._inputs[1].excludedConnectionPointTypes.push(Jb.Matrix), i._inputs[1].excludedConnectionPointTypes.push(Jb.Geometry), 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 hT("Min"); e.value = 0, e.output.connectTo(this.min) } if (!this.max.isConnected) { var t = new hT("Max"); t.value = 1, t.output.connectTo(this.max) } }, t.prototype._buildBlock = function () { var e = this, t = null; switch (this.min.type) { case Jb.Int: case Jb.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 Jb.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 Jb.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 Jb.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.output._storedFunction = t }, t }(lT); b("BABYLON.RandomBlock", LT); var wT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.registerInput("octaves", Jb.Float, !0, 2, 0, 16), i.registerInput("roughness", Jb.Float, !0, .5, 0, 1), i.registerOutput("output", Jb.Float), i } return W(t, e), t.prototype.getClassName = function () { return "NoiseBlock" }, Object.defineProperty(t.prototype, "octaves", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "roughness", { 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._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 << t | 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) { for (var r = 1, n = 1, o = 0, a = 0, s = 0 | (e = h.Clamp(e, 0, 15)), l = 0; l <= s; l++)a += this._perlin(i.scale(r)) * n, o += n, n *= h.Clamp(t, 0, 1), r *= 2; var c = e - Math.floor(e); if (0 == c) return a / o; var u = a + this._perlin(i.scale(r)) * n; return (1 - c) * (a /= o) + c * (u / (o + n)) }, t.prototype._buildBlock = function () { var e = this; this.output._storedFunction = function (t) { var i = t.getContextualValue(aT.Positions), r = e.octaves.getConnectedValue(t), n = e.roughness.getConnectedValue(t); return e.noise(r, n, i) } }, t }(lT); b("BABYLON.NoiseBlock", wT); var BT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.evaluateContext = !1, i.registerInput("geometry0", Jb.Geometry), i.registerInput("geometry1", Jb.Geometry, !0), i.registerInput("geometry2", Jb.Geometry, !0), i.registerInput("geometry3", Jb.Geometry, !0), i.registerInput("geometry4", Jb.Geometry, !0), i.registerOutput("output", Jb.Geometry), i._outputs[0]._typeConnectionSource = i._inputs[0], i._linkConnectionTypes(0, 1), 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 = t.geometry0.getConnectedValue(e), r = []; return t.geometry1.isConnected && r.push(t.geometry1.getConnectedValue(e)), t.geometry2.isConnected && r.push(t.geometry2.getConnectedValue(e)), t.geometry3.isConnected && r.push(t.geometry3.getConnectedValue(e)), t.geometry4.isConnected && r.push(t.geometry4.getConnectedValue(e)), r.length && i && (i = i.merge(r, !0, !1, !0, !0)), i }; this.evaluateContext ? this.output._storedFunction = i : 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([ha("Evaluate context", ca.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t }(lT); b("BABYLON.MergeGeometryBlock", BT); var UT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.registerInput("input", Jb.AutoDetect), i.registerOutput("output", Jb.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 }(lT); b("BABYLON.GeometryElbowBlock", UT); var VT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.registerInput("geometry", Jb.Geometry), i.registerOutput("output", Jb.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 En.ComputeNormals(i.positions, i.indices, i.normals), i } }, t }(lT); b("BABYLON.ComputeNormalsBlock", VT); var kT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.registerInput("xyzw ", Jb.Vector4, !0), i.registerInput("xyz ", Jb.Vector3, !0), i.registerInput("xy ", Jb.Vector2, !0), i.registerInput("zw ", Jb.Vector2, !0), i.registerInput("x ", Jb.Float, !0), i.registerInput("y ", Jb.Float, !0), i.registerInput("z ", Jb.Float, !0), i.registerInput("w ", Jb.Float, !0), i.registerOutput("xyzw", Jb.Vector4), i.registerOutput("xyz", Jb.Vector3), i.registerOutput("xy", Jb.Vector2), i.registerOutput("zw", Jb.Vector2), i.registerOutput("x", Jb.Float), i.registerOutput("y", Jb.Float), i.registerOutput("z", Jb.Float), i.registerOutput("w", Jb.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 }(lT); b("BABYLON.VectorConverterBlock", kT); var GT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.registerInput("input", Jb.AutoDetect), i.registerOutput("output", Jb.BasedOnInput), i._inputs[0].excludedConnectionPointTypes.push(Jb.Float), i._inputs[0].excludedConnectionPointTypes.push(Jb.Matrix), i._inputs[0].excludedConnectionPointTypes.push(Jb.Geometry), 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 }(lT); b("BABYLON.NormalizeVectorBlock", GT); var zT, WT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.evaluateContext = !0, i.registerInput("geometry", Jb.Geometry), i.registerInput("id", Jb.Int, !0, 0), i.registerOutput("output", Jb.Geometry), i.id.acceptedConnectionPointTypes.push(Jb.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 Tn; 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._storedValue = i(e) }, X([ha("Evaluate context", ca.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t }(lT); b("BABYLON.SetMaterialIDBlock", WT), 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" }(zT || (zT = {})); var HT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.operation = zT.Cos, i.registerInput("input", Jb.AutoDetect), i.registerOutput("output", Jb.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._inputs[0].excludedConnectionPointTypes.push(Jb.Matrix), i._inputs[0].excludedConnectionPointTypes.push(Jb.Geometry), 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 zT.Cos: r = function (e) { return Math.cos(e) }; break; case zT.Sin: r = function (e) { return Math.sin(e) }; break; case zT.Abs: r = function (e) { return Math.abs(e) }; break; case zT.Exp: r = function (e) { return Math.exp(e) }; break; case zT.Round: r = function (e) { return Math.round(e) }; break; case zT.Floor: r = function (e) { return Math.floor(e) }; break; case zT.Ceiling: r = function (e) { return Math.ceil(e) }; break; case zT.Sqrt: r = function (e) { return Math.sqrt(e) }; break; case zT.Log: r = function (e) { return Math.log(e) }; break; case zT.Tan: r = function (e) { return Math.tan(e) }; break; case zT.ArcTan: r = function (e) { return Math.atan(e) }; break; case zT.ArcCos: r = function (e) { return Math.acos(e) }; break; case zT.ArcSin: r = function (e) { return Math.asin(e) }; break; case zT.Sign: r = function (e) { return Math.sign(e) }; break; case zT.Negate: r = function (e) { return -e }; break; case zT.OneMinus: r = function (e) { return 1 - e }; break; case zT.Reciprocal: r = function (e) { return 1 / e }; break; case zT.ToRadians: r = function (e) { return e * Math.PI / 180 }; break; case zT.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 Jb.Int: case Jb.Float: this.output._storedFunction = function (e) { var t = i.input.getConnectedValue(e); return r(t) }; break; case Jb.Vector2: this.output._storedFunction = function (e) { var t = i.input.getConnectedValue(e); return new A(r(t.x), r(t.y)) }; break; case Jb.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 Jb.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(zT[this.operation], ";\n") }, X([ha("Operation", ca.List, "ADVANCED", { notifiers: { rebuild: !0 }, options: [{ label: "Cos", value: zT.Cos }, { label: "Sin", value: zT.Sin }, { label: "Abs", value: zT.Abs }, { label: "Exp", value: zT.Exp }, { label: "Round", value: zT.Round }, { label: "Floor", value: zT.Floor }, { label: "Ceiling", value: zT.Ceiling }, { label: "Sqrt", value: zT.Sqrt }, { label: "Log", value: zT.Log }, { label: "Tan", value: zT.Tan }, { label: "ArcTan", value: zT.ArcTan }, { label: "ArcCos", value: zT.ArcCos }, { label: "ArcSin", value: zT.ArcSin }, { label: "Sign", value: zT.Sign }, { label: "Negate", value: zT.Negate }, { label: "OneMinus", value: zT.OneMinus }, { label: "Reciprocal", value: zT.Reciprocal }, { label: "ToDegrees", value: zT.ToDegrees }, { label: "ToRadians", value: zT.ToRadians }] })], t.prototype, "operation", void 0), t }(lT); b("BABYLON.GeometryTrigonometryBlock", HT); var XT = 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", Jb.AutoDetect), i.registerInput("matrix", Jb.Matrix, !0), i.registerInput("translation", Jb.Vector3, !0, R.Zero()), i.registerInput("rotation", Jb.Vector3, !0, R.Zero()), i.registerInput("scaling", Jb.Vector3, !0, R.One()), i.registerOutput("output", Jb.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._inputs[0].excludedConnectionPointTypes.push(Jb.Float), i._inputs[0].excludedConnectionPointTypes.push(Jb.Matrix), 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 Jb.Geometry: var s = r.clone(); return s.transform(i), s; case Jb.Vector2: return A.Transform(r, i); case Jb.Vector3: return R.TransformCoordinates(r, i); case Jb.Vector4: return C.TransformCoordinates(r, i) }return null }; this.evaluateContext ? this.output._storedFunction = i : 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([ha("Evaluate context", ca.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t }(lT); b("BABYLON.GeometryTransformBlock", XT); var jT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.registerInput("angle", Jb.Float, !1, 0), i.registerOutput("matrix", Jb.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 hT("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 }(lT); b("BABYLON.RotationXBlock", jT); var YT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.registerInput("angle", Jb.Float, !1, 0), i.registerOutput("matrix", Jb.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 hT("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 }(lT); b("BABYLON.RotationYBlock", YT); var KT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.registerInput("angle", Jb.Float, !1, 0), i.registerOutput("matrix", Jb.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 hT("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 }(lT); b("BABYLON.RotationZBlock", KT); var QT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.registerInput("scale", Jb.Vector3, !1, R.One()), i.registerOutput("matrix", Jb.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 hT("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 }(lT); b("BABYLON.ScalingBlock", QT); var qT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.registerInput("source", Jb.Vector3, !0, R.Up()), i.registerInput("target", Jb.Vector3, !0, R.Left()), i.registerOutput("matrix", Jb.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), n } }, t }(lT); b("BABYLON.AlignBlock", qT); var ZT = function (e) { function t(t) { var i = e.call(this, t) || this; return i.registerInput("translation", Jb.Vector3, !1, R.Zero()), i.registerOutput("matrix", Jb.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 hT("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 }(lT); b("BABYLON.TranslationBlock", ZT); var JT = function (e) { function t(t) { var i = e.call(this, t) || this; return i._indexTranslation = null, i.removeDuplicatedPositions = !0, i.registerInput("geometry", Jb.Geometry), i.registerInput("instance", Jb.Geometry, !0), i.registerInput("rotation", Jb.Vector3, !0, R.Zero()), i.registerInput("scaling", Jb.Vector3, !0, R.One()), i.registerInput("density", Jb.Float, !0, 1, 0, 1), i.scaling.acceptedConnectionPointTypes.push(Jb.Float), i.registerOutput("output", Jb.Geometry), i } return W(t, e), t.prototype.getExecutionIndex = function () { return this._indexTranslation ? this._indexTranslation[this._currentIndex] : this._currentIndex }, 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, "rotation", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "scaling", { get: function () { return this._inputs[3] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "density", { 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) { if (e.executionContext = this, this._vertexData = this.geometry.getConnectedValue(e), e.geometryContext = this._vertexData, !this._vertexData || !this._vertexData.positions || !this.instance.isConnected) return e.executionContext = null, e.geometryContext = null, void (this.output._storedValue = null); var t = this._vertexData.positions.length / 3, i = [], r = new R, n = new Array, o = this._vertexData.positions; if (this.removeDuplicatedPositions) { for (this._indexTranslation = {}, this._currentIndex = 0; this._currentIndex < t; this._currentIndex++) { for (var a = o[3 * this._currentIndex], s = o[3 * this._currentIndex + 1], l = o[3 * this._currentIndex + 2], c = !1, u = 0; u < n.length; u += 3)if (Math.abs(n[u] - a) < _ && Math.abs(n[u + 1] - s) < _ && Math.abs(n[u + 2] - l) < _) { c = !0; break } c || (this._indexTranslation[n.length / 3] = this._currentIndex, n.push(a, s, l)) } t = (o = n).length / 3 } else this._indexTranslation = null; for (this._currentIndex = 0; this._currentIndex < t; this._currentIndex++) { var h = this.instance.getConnectedValue(e); if (h && h.positions && 0 !== h.positions.length) { var d = this.density.getConnectedValue(e); if (!(d < 1 && Math.random() > d)) { r.fromArray(o, 3 * this._currentIndex); var p = h.clone(), f = e.adaptInput(this.scaling, Jb.Vector3, R.OneReadOnly), m = this.rotation.getConnectedValue(e) || R.ZeroReadOnly; e._instantiate(p, r, m, f, i) } } } if (i.length) if (1 === i.length) this._vertexData = i[0]; else { var g = i.splice(0, 1)[0]; this._vertexData = g.merge(i, !0, !1, !0, !0) } this.output._storedValue = this._vertexData, e.executionContext = null, e.geometryContext = null }, t.prototype._dumpPropertiesCode = function () { return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".removeDuplicatedPositions = ").concat(this.removeDuplicatedPositions ? "true" : "false", ";\n") }, t.prototype.serialize = function () { var t = e.prototype.serialize.call(this); return t.removeDuplicatedPositions = this.removeDuplicatedPositions, t }, t.prototype._deserialize = function (t) { e.prototype._deserialize.call(this, t), this.removeDuplicatedPositions = t.removeDuplicatedPositions }, X([ha("Remove duplicated positions", ca.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "removeDuplicatedPositions", void 0), t }(lT); b("BABYLON.InstantiateOnVerticesBlock", JT); var $T = 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._tempVector0 = new R, i._tempVector1 = new R, i.evaluateContext = !0, i.registerInput("geometry", Jb.Geometry), i.registerInput("instance", Jb.Geometry, !0), i.registerInput("rotation", Jb.Vector3, !0, R.Zero()), i.registerInput("scaling", Jb.Vector3, !0, R.One()), i.registerInput("count", Jb.Int, !0, 256), i.scaling.acceptedConnectionPointTypes.push(Jb.Float), i.registerOutput("output", Jb.Geometry), i } return W(t, e), t.prototype.getExecutionIndex = function () { return 0 }, t.prototype.getExecutionFaceIndex = function () { return this._currentFaceIndex }, 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.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, "rotation", { get: function () { return this._inputs[2] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "scaling", { get: function () { return this._inputs[3] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "count", { 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) { if (e.executionContext = this, this._vertexData = this.geometry.getConnectedValue(e), e.geometryContext = this._vertexData, !(this._vertexData && this._vertexData.positions && this._vertexData.indices && this.instance.isConnected)) return e.executionContext = null, e.geometryContext = null, void (this.output._storedValue = null); var t = null; if (!(this.evaluateContext || (t = this.instance.getConnectedValue(e)) && t.positions && 0 !== t.positions.length)) return e.executionContext = null, e.geometryContext = null, void (this.output._storedValue = null); var i = this.count.getConnectedValue(e), r = this._vertexData.indices.length / 3, n = i / r, o = 0, a = [], s = 0; for (this._currentFaceIndex = 0; this._currentFaceIndex < r; this._currentFaceIndex++) { this._vertex0.fromArray(this._vertexData.positions, 3 * this._vertexData.indices[3 * this._currentFaceIndex]), this._vertex1.fromArray(this._vertexData.positions, 3 * this._vertexData.indices[3 * this._currentFaceIndex + 1]), this._vertex2.fromArray(this._vertexData.positions, 3 * this._vertexData.indices[3 * this._currentFaceIndex + 2]); var l = (0 | (o += n)) - s; if (!(l < 1)) for (var c = 0; c < l && !(s >= i); c++) { var u = Math.random(), h = Math.random(); if (u > h) { var d = u; u = h, h = d } var p = u, f = h - u, _ = 1 - p - f; if (this._currentPosition.set(p * this._vertex0.x + f * this._vertex1.x + _ * this._vertex2.x, p * this._vertex0.y + f * this._vertex1.y + _ * this._vertex2.y, p * this._vertex0.z + f * this._vertex1.z + _ * this._vertex2.z), !this.evaluateContext || (t = this.instance.getConnectedValue(e)) && t.positions && 0 !== t.positions.length) { var m = t.clone(), g = e.adaptInput(this.scaling, Jb.Vector3, R.OneReadOnly), v = this.rotation.getConnectedValue(e) || R.ZeroReadOnly; e._instantiate(m, this._currentPosition, v, g, a), s++ } } } if (a.length) if (1 === a.length) this._vertexData = a[0]; else { var y = a.splice(0, 1)[0]; this._vertexData = y.merge(a, !0, !1, !0, !0) } this.output._storedValue = this._vertexData, e.executionContext = null, e.geometryContext = null }, 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([ha("Evaluate context", ca.Boolean, "ADVANCED", { notifiers: { rebuild: !0 } })], t.prototype, "evaluateContext", void 0), t }(lT); b("BABYLON.InstantiateOnFacesBlock", $T); var eE = function (e) { function t(t) { var i = e.call(this, t) || this; return i.registerInput("float ", Jb.Float, !0), i.registerInput("int ", Jb.Int, !0), i.registerOutput("float", Jb.Float), i.registerOutput("int", Jb.Int), i } return W(t, e), t.prototype.getClassName = function () { return "IntFloatConverterBlock" }, Object.defineProperty(t.prototype, "floatIn", { get: function () { return this._inputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "intIn", { get: function () { return this._inputs[1] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "floatOut", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "intOut", { get: function () { return this._outputs[1] }, enumerable: !1, configurable: !0 }), t.prototype._inputRename = function (e) { return "float " === e ? "floatIn" : "int " === e ? "intIn" : e }, t.prototype._buildBlock = function () { var e = this; this.floatOut._storedFunction = function (t) { return e.floatIn.isConnected ? e.floatIn.getConnectedValue(t) : e.intIn.isConnected ? e.intIn.getConnectedValue(t) : 0 }, this.intOut._storedFunction = function (t) { return e.floatIn.isConnected ? 0 | e.floatIn.getConnectedValue(t) : e.intIn.isConnected ? 0 | e.intIn.getConnectedValue(t) : 0 } }, t }(lT); b("BABYLON.IntFloatConverterBlock", eE); var tE = function (e) { function t(t) { var i = e.call(this, t) || this; return i.log = [], i.registerInput("input", Jb.AutoDetect), i.registerOutput("output", Jb.BasedOnInput), i._outputs[0]._typeConnectionSource = i._inputs[0], i._inputs[0].excludedConnectionPointTypes.push(Jb.Geometry), i } return W(t, e), Object.defineProperty(t.prototype, "buildExecutionTime", { get: function () { return 0 }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function () { return "DebugBlock" }, 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 () { var e = this; if (!this.input.isConnected) return this.output._storedFunction = null, void (this.output._storedValue = null); this.log = [], this.output._storedFunction = function (t) { var i = e.input.getConnectedValue(t); return e.log.push(i ? i.toString() : "null"), i } }, t }(lT); b("BABYLON.DebugBlock", tE); var iE = function (e) { function t(t) { var i = e.call(this, t) || this; return i._endpoints = [], i.registerInput("input", Jb.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 < o.length; n++) { var a = o[n]; -1 === i.indexOf(a) && (r += a._dumpCode(t, i)) } return r }, t.prototype.attachToEndpoint = function (e) { e.detach(), this._endpoints.push(e), e._entryPoint = this, e._outputs[0]._typeConnectionSource = this._inputs[0], e._tempEntryPointUniqueId = null }, 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 < i.length; t++)i[t].output._storedFunction = function (t) { return e.input.getConnectedValue(t) } }, t }(lT); b("BABYLON.TeleportInBlock", iE); var rE = function (e) { function t(t) { var i = e.call(this, t) || this; return i._entryPoint = null, i._tempEntryPointUniqueId = null, i.registerOutput("output", Jb.BasedOnInput), i } return W(t, e), Object.defineProperty(t.prototype, "entryPoint", { get: function () { return this._entryPoint }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function () { return "TeleportOutBlock" }, Object.defineProperty(t.prototype, "output", { get: function () { return this._outputs[0] }, enumerable: !1, configurable: !0 }), t.prototype.detach = function () { this._entryPoint && this._entryPoint.detachFromEndpoint(this) }, t.prototype._buildBlock = function () { }, t.prototype._customBuildStep = function (e) { this.entryPoint && this.entryPoint.build(e) }, t.prototype._dumpCode = function (t, i) { var r = ""; return this.entryPoint && -1 === i.indexOf(this.entryPoint) && (r += this.entryPoint._dumpCode(t, i)), r + e.prototype._dumpCode.call(this, t, i) }, t.prototype._dumpCodeForOutputConnections = function (t) { var i = e.prototype._dumpCodeForOutputConnections.call(this, t); return this.entryPoint && (i += this.entryPoint._dumpCodeForOutputConnections(t)), i }, t.prototype.clone = function () { var t = e.prototype.clone.call(this); return this.entryPoint && this.entryPoint.attachToEndpoint(t), t }, t.prototype._dumpPropertiesCode = function () { var t = e.prototype._dumpPropertiesCode.call(this); return this.entryPoint && (t += "".concat(this.entryPoint._codeVariableName, ".attachToEndpoint(").concat(this._codeVariableName, ");\n")), t }, t.prototype.serialize = function () { var t, i, r = e.prototype.serialize.call(this); return r.entryPoint = null !== (i = null === (t = this.entryPoint) || void 0 === t ? void 0 : t.uniqueId) && void 0 !== i ? i : "", r }, t.prototype._deserialize = function (t) { e.prototype._deserialize.call(this, t), this._tempEntryPointUniqueId = t.entryPoint }, t }(lT); b("BABYLON.TeleportOutBlock", rE); var nE = 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 < e.length; r++)if (e[r]) { var c = e[r], u = c.getIndices(); if (!u) continue; var h = c.getVerticesData(Hi.PositionKind, !1, !1); if (!h) continue; var d = [], p = c.computeWorldMatrix(!0); if (c.hasThinInstances) for (var f = c.thinInstanceGetWorldMatrices(), _ = 0; _ < f.length; _++) { var m = new I; f[_].multiplyToRef(p, m), d.push(m) } else d.push(p); for (var g = 0; g < d.length; g++) { var v = d[g]; for (n = 0; n < u.length; n++)a.push(u[n] + l); var y = R.Zero(), b = R.Zero(); for (o = 0; o < h.length; o += 3)R.FromArrayToRef(h, o, b), R.TransformCoordinatesToRef(b, v, y), s.push(y.x, y.y, y.z); l += h.length / 3 } } if (this._worker && i) this._worker.postMessage([s, l, a, a.length, t]), this._worker.onmessage = function (e) { i(e.data) }; else { var T = new this.bjsRECAST.rcConfig; T.cs = t.cs, T.ch = t.ch, T.borderSize = t.borderSize ? t.borderSize : 0, T.tileSize = t.tileSize ? t.tileSize : 0, T.walkableSlopeAngle = t.walkableSlopeAngle, T.walkableHeight = t.walkableHeight, T.walkableClimb = t.walkableClimb, T.walkableRadius = t.walkableRadius, T.maxEdgeLen = t.maxEdgeLen, T.maxSimplificationError = t.maxSimplificationError, T.minRegionArea = t.minRegionArea, T.mergeRegionArea = t.mergeRegionArea, T.maxVertsPerPoly = t.maxVertsPerPoly, T.detailSampleDist = t.detailSampleDist, T.detailSampleMaxError = t.detailSampleMaxError, this.navMesh.build(s, l, a, a.length, T) } }, e.prototype.createDebugNavMesh = function (e) { var t, i, r = this.navMesh.getDebugNavMesh(), n = r.getTriangleCount(), o = [], a = []; for (t = 0; t < 3 * n; t++)o.push(t); for (t = 0; t < n; t++)for (i = 0; i < 3; i++) { var s = r.getTriangle(t).getPoint(i); a.push(s.x, s.y, s.z) } var l = new Jn("NavMeshDebug", e), c = new En; return c.indices = o, c.positions = a, c.applyToMesh(l, !1), l }, e.prototype.getClosestPoint = function (e) { this._tempVec1.x = e.x, this._tempVec1.y = e.y, this._tempVec1.z = e.z; var t = this.navMesh.getClosestPoint(this._tempVec1); return new R(t.x, t.y, t.z) }, e.prototype.getClosestPointToRef = function (e, t) { this._tempVec1.x = e.x, this._tempVec1.y = e.y, this._tempVec1.z = e.z; var i = this.navMesh.getClosestPoint(this._tempVec1); t.set(i.x, i.y, i.z) }, e.prototype.getRandomPointAround = function (e, t) { this._tempVec1.x = e.x, this._tempVec1.y = e.y, this._tempVec1.z = e.z; var i = this.navMesh.getRandomPointAround(this._tempVec1, t); return new R(i.x, i.y, i.z) }, e.prototype.getRandomPointAroundToRef = function (e, t, i) { this._tempVec1.x = e.x, this._tempVec1.y = e.y, this._tempVec1.z = e.z; var r = this.navMesh.getRandomPointAround(this._tempVec1, t); i.set(r.x, r.y, r.z) }, e.prototype.moveAlong = function (e, t) { this._tempVec1.x = e.x, this._tempVec1.y = e.y, this._tempVec1.z = e.z, this._tempVec2.x = t.x, this._tempVec2.y = t.y, this._tempVec2.z = t.z; var i = this.navMesh.moveAlong(this._tempVec1, this._tempVec2); return new R(i.x, i.y, i.z) }, e.prototype.moveAlongToRef = function (e, t, i) { this._tempVec1.x = e.x, this._tempVec1.y = e.y, this._tempVec1.z = e.z, this._tempVec2.x = t.x, this._tempVec2.y = t.y, this._tempVec2.z = t.z; var r = this.navMesh.moveAlong(this._tempVec1, this._tempVec2); i.set(r.x, r.y, r.z) }, e.prototype.computePath = function (e, t) { var i; this._tempVec1.x = e.x, this._tempVec1.y = e.y, this._tempVec1.z = e.z, this._tempVec2.x = t.x, this._tempVec2.y = t.y, this._tempVec2.z = t.z; var r = this.navMesh.computePath(this._tempVec1, this._tempVec2), n = r.getPointCount(), o = []; for (i = 0; i < n; i++) { var a = r.getPoint(i); o.push(new R(a.x, a.y, a.z)) } return o }, e.prototype.createCrowd = function (e, t, i) { return new oE(this, e, t, i) }, e.prototype.setDefaultQueryExtent = function (e) { this._tempVec1.x = e.x, this._tempVec1.y = e.y, this._tempVec1.z = e.z, this.navMesh.setDefaultQueryExtent(this._tempVec1) }, e.prototype.getDefaultQueryExtent = function () { var e = this.navMesh.getDefaultQueryExtent(); return new R(e.x, e.y, e.z) }, e.prototype.buildFromNavmeshData = function (e) { var t = e.length * e.BYTES_PER_ELEMENT, i = this.bjsRECAST._malloc(t), r = new Uint8Array(this.bjsRECAST.HEAPU8.buffer, i, t); r.set(e); var n = new this.bjsRECAST.NavmeshData; n.dataPointer = r.byteOffset, n.size = e.length, this.navMesh = new this.bjsRECAST.NavMesh, this.navMesh.buildFromNavmeshData(n), this.bjsRECAST._free(r.byteOffset) }, e.prototype.getNavmeshData = function () { var e = this.navMesh.getNavmeshData(), t = new Uint8Array(this.bjsRECAST.HEAPU8.buffer, e.dataPointer, e.size), i = new Uint8Array(e.size); return i.set(t), this.navMesh.freeNavmeshData(e), i }, e.prototype.getDefaultQueryExtentToRef = function (e) { var t = this.navMesh.getDefaultQueryExtent(); e.set(t.x, t.y, t.z) }, e.prototype.dispose = function () { }, e.prototype.addCylinderObstacle = function (e, t, i) { return this._tempVec1.x = e.x, this._tempVec1.y = e.y, this._tempVec1.z = e.z, this.navMesh.addCylinderObstacle(this._tempVec1, t, i) }, e.prototype.addBoxObstacle = function (e, t, i) { return this._tempVec1.x = e.x, this._tempVec1.y = e.y, this._tempVec1.z = e.z, this._tempVec2.x = t.x, this._tempVec2.y = t.y, this._tempVec2.z = t.z, this.navMesh.addBoxObstacle(this._tempVec1, this._tempVec2, i) }, e.prototype.removeObstacle = function (e) { this.navMesh.removeObstacle(e) }, e.prototype.isSupported = function () { return void 0 !== this.bjsRECAST }, e }(), oE = function () { function e(e, t, i, r) { var n = this; this.recastCrowd = {}, this.transforms = new Array, this.agents = new Array, this.reachRadii = new Array, this._agentDestinationArmed = new Array, this._agentDestination = new Array, this._onBeforeAnimationsObserver = null, this.onReachTargetObservable = new u, this.bjsRECASTPlugin = e, this.recastCrowd = new this.bjsRECASTPlugin.bjsRECAST.Crowd(t, i, this.bjsRECASTPlugin.navMesh.getNavMesh()), this._scene = r, this._onBeforeAnimationsObserver = r.onBeforeAnimationsObservable.add((function () { n.update(.001 * r.getEngine().getDeltaTime() * e.timeFactor) })) } return e.prototype.addAgent = function (e, t, i) { var r = new this.bjsRECASTPlugin.bjsRECAST.dtCrowdAgentParams; r.radius = t.radius, r.height = t.height, r.maxAcceleration = t.maxAcceleration, r.maxSpeed = t.maxSpeed, r.collisionQueryRange = t.collisionQueryRange, r.pathOptimizationRange = t.pathOptimizationRange, r.separationWeight = t.separationWeight, r.updateFlags = 7, r.obstacleAvoidanceType = 0, r.queryFilterType = 0, r.userData = 0; var n = this.recastCrowd.addAgent(new this.bjsRECASTPlugin.bjsRECAST.Vec3(e.x, e.y, e.z), r); return this.transforms.push(i), this.agents.push(n), this.reachRadii.push(t.reachRadius ? t.reachRadius : t.radius), this._agentDestinationArmed.push(!1), this._agentDestination.push(new R(0, 0, 0)), n }, e.prototype.getAgentPosition = function (e) { var t = this.recastCrowd.getAgentPosition(e); return new R(t.x, t.y, t.z) }, e.prototype.getAgentPositionToRef = function (e, t) { var i = this.recastCrowd.getAgentPosition(e); t.set(i.x, i.y, i.z) }, e.prototype.getAgentVelocity = function (e) { var t = this.recastCrowd.getAgentVelocity(e); return new R(t.x, t.y, t.z) }, e.prototype.getAgentVelocityToRef = function (e, t) { var i = this.recastCrowd.getAgentVelocity(e); t.set(i.x, i.y, i.z) }, e.prototype.getAgentNextTargetPath = function (e) { var t = this.recastCrowd.getAgentNextTargetPath(e); return new R(t.x, t.y, t.z) }, e.prototype.getAgentNextTargetPathToRef = function (e, t) { var i = this.recastCrowd.getAgentNextTargetPath(e); t.set(i.x, i.y, i.z) }, e.prototype.getAgentState = function (e) { return this.recastCrowd.getAgentState(e) }, e.prototype.overOffmeshConnection = function (e) { return this.recastCrowd.overOffmeshConnection(e) }, e.prototype.agentGoto = function (e, t) { this.recastCrowd.agentGoto(e, new this.bjsRECASTPlugin.bjsRECAST.Vec3(t.x, t.y, t.z)); var i = this.agents.indexOf(e); i > -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; o < r; o++)this.recastCrowd.update(n) } for (var a = 0; a < this.agents.length; a++) { var s = this.agents[a], l = this.getAgentPosition(s); if (this.transforms[a].position = l, this._agentDestinationArmed[a]) { var c = l.x - this._agentDestination[a].x, u = l.z - this._agentDestination[a].z, h = this.reachRadii[a], d = this._agentDestination[a].y - this.reachRadii[a], p = this._agentDestination[a].y + this.reachRadii[a], f = c * c + u * u; l.y > d && l.y < p && f < h * h && (this.onReachTargetObservable.notifyObservers({ agentIndex: s, destination: this._agentDestination[a] }), this._agentDestinationArmed[a] = !1) } } } }, e.prototype.setDefaultQueryExtent = function (e) { var t = new this.bjsRECASTPlugin.bjsRECAST.Vec3(e.x, e.y, e.z); this.recastCrowd.setDefaultQueryExtent(t) }, e.prototype.getDefaultQueryExtent = function () { var e = this.recastCrowd.getDefaultQueryExtent(); return new R(e.x, e.y, e.z) }, e.prototype.getDefaultQueryExtentToRef = function (e) { var t = this.recastCrowd.getDefaultQueryExtent(); e.set(t.x, t.y, t.z) }, e.prototype.getCorners = function (e) { var t, i = this.recastCrowd.getCorners(e), r = i.getPointCount(), n = []; for (t = 0; t < r; t++) { var o = i.getPoint(t); n.push(new R(o.x, o.y, o.z)) } return n }, e.prototype.dispose = function () { this.recastCrowd.destroy(), this._scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver), this._onBeforeAnimationsObserver = null, this.onReachTargetObservable.clear() }, e }(); In.OfflineProviderFactory = function (e, t, i) { return void 0 === i && (i = !1), new aE(e, t, i) }; var aE = function () { function e(t, i, r) { void 0 === r && (r = !1), this._idbFactory = "undefined" != typeof indexedDB ? indexedDB : void 0, this._currentSceneUrl = e._ReturnFullUrlLocation(t), this._db = null, this._enableSceneOffline = !1, this._enableTexturesOffline = !1, this._manifestVersionFound = 0, this._mustUpdateRessources = !1, this._hasReachedQuota = !1, e.IDBStorageEnabled ? r ? (this._enableSceneOffline = !0, this._enableTexturesOffline = !0, this._manifestVersionFound = 1, xi.SetImmediate((function () { i(!0) }))) : this._checkManifestFile(i) : i(!0) } return Object.defineProperty(e.prototype, "enableSceneOffline", { get: function () { return this._enableSceneOffline }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "enableTexturesOffline", { get: function () { return this._enableTexturesOffline }, enumerable: !1, configurable: !0 }), e.prototype._checkManifestFile = function (t) { var i = this, r = function () { i._enableSceneOffline = !1, i._enableTexturesOffline = !1, t(!1) }, n = function () { try { if ("function" == typeof URL && 0 === i._currentSceneUrl.indexOf("http")) { var e = new URL(i._currentSceneUrl); return e.pathname += ".manifest", e.toString() } } catch (e) { } return "".concat(i._currentSceneUrl, ".manifest") }, o = !1, a = n(), s = new He; navigator.onLine && (o = !0, a = a + (null == a.match(/\?/) ? "?" : "&") + Date.now()), s.open("GET", a), s.addEventListener("load", (function () { if (200 === s.status || e._ValidateXHRData(s, 1)) try { var n = JSON.parse(s.response); i._enableSceneOffline = n.enableSceneOffline, i._enableTexturesOffline = n.enableTexturesOffline && e._IsUASupportingBlobStorage, n.version && !isNaN(parseInt(n.version)) && (i._manifestVersionFound = n.version), t(!0) } catch (e) { r() } else r() }), !1), s.addEventListener("error", (function () { if (o) { o = !1; var e = n(); s.open("GET", e), s.send() } else r() }), !1); try { s.send() } catch (e) { $.Error("Error on XHR send request."), t(!1) } }, e.prototype.open = function (e, t) { var i = this, r = function () { i._isSupported = !1, t && t() }; if (this._idbFactory && (this._enableSceneOffline || this._enableTexturesOffline)) if (this._db) e && e(); else { this._hasReachedQuota = !1, this._isSupported = !0; var n = this._idbFactory.open("babylonjs", 1); n.onerror = function () { r() }, n.onblocked = function () { $.Error("IDB request blocked. Please reload the page."), r() }, n.onsuccess = function () { i._db = n.result, e() }, n.onupgradeneeded = function (e) { if (i._db = e.target.result, i._db) try { i._db.createObjectStore("scenes", { keyPath: "sceneUrl" }), i._db.createObjectStore("versions", { keyPath: "sceneUrl" }), i._db.createObjectStore("textures", { keyPath: "textureUrl" }) } catch (e) { $.Error("Error while creating object stores. Exception: " + e.message), r() } } } else this._isSupported = !1, t && t() }, e.prototype.loadImage = function (t, i) { var r = this, n = e._ReturnFullUrlLocation(t), o = function () { r._hasReachedQuota || null === r._db ? i.src = t : r._saveImageIntoDBAsync(n, i) }; this._mustUpdateRessources ? o() : this._loadImageFromDBAsync(n, i, o) }, e.prototype._loadImageFromDBAsync = function (e, t, i) { if (this._isSupported && null !== this._db) { var r, n = this._db.transaction(["textures"]); n.onabort = function () { t.src = e }, n.oncomplete = function () { var n; r && "function" == typeof URL ? (n = URL.createObjectURL(r.data), t.onerror = function () { $.Error("Error loading image from blob URL: " + n + " switching back to web url: " + e), t.src = e }, t.src = n) : i() }; var o = n.objectStore("textures").get(e); o.onsuccess = function (e) { r = e.target.result }, o.onerror = function () { $.Error("Error loading texture " + e + " from DB."), t.src = e } } else $.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."), t.src = e }, e.prototype._saveImageIntoDBAsync = function (t, i) { var r, n = this; if (this._isSupported) { var o = function () { var e; if (r && "function" == typeof URL) try { e = URL.createObjectURL(r) } catch (t) { e = URL.createObjectURL(r) } e && (i.src = e) }; if (e._IsUASupportingBlobStorage) { var a = new He; a.open("GET", t), a.responseType = "blob", a.addEventListener("load", (function () { if (200 === a.status && n._db) { r = a.response; var s = n._db.transaction(["textures"], "readwrite"); s.onabort = function (e) { try { var t = e.target.error; t && "QuotaExceededError" === t.name && (n._hasReachedQuota = !0) } catch (e) { } o() }, s.oncomplete = function () { o() }; var l = { textureUrl: t, data: r }; try { var c = s.objectStore("textures").put(l); c.onsuccess = function () { }, c.onerror = function () { o() } } catch (r) { 25 === r.code && (e._IsUASupportingBlobStorage = !1, n._enableTexturesOffline = !1), i.src = t } } else i.src = t }), !1), a.addEventListener("error", (function () { $.Error("Error in XHR request in BABYLON.Database."), i.src = t }), !1), a.send() } else i.src = t } else $.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."), i.src = t }, e.prototype._checkVersionFromDB = function (e, t) { var i = this; this._loadVersionFromDBAsync(e, t, (function () { i._saveVersionIntoDBAsync(e, t) })) }, e.prototype._loadVersionFromDBAsync = function (e, t, i) { var r, n = this; if (this._isSupported && this._db) try { var o = this._db.transaction(["versions"]); o.oncomplete = function () { r ? n._manifestVersionFound !== r.data ? (n._mustUpdateRessources = !0, i()) : t(r.data) : (n._mustUpdateRessources = !0, i()) }, o.onabort = function () { t(-1) }; var a = o.objectStore("versions").get(e); a.onsuccess = function (e) { r = e.target.result }, a.onerror = function () { $.Error("Error loading version for scene " + e + " from DB."), t(-1) } } catch (e) { $.Error("Error while accessing 'versions' object store (READ OP). Exception: " + e.message), t(-1) } else $.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."), t(-1) }, e.prototype._saveVersionIntoDBAsync = function (e, t) { var i = this; if (this._isSupported && !this._hasReachedQuota && this._db) try { var r = this._db.transaction(["versions"], "readwrite"); r.onabort = function (e) { try { var r = e.target.error; r && "QuotaExceededError" === r.name && (i._hasReachedQuota = !0) } catch (e) { } t(-1) }, r.oncomplete = function () { t(i._manifestVersionFound) }; var n = { sceneUrl: e, data: this._manifestVersionFound }, o = r.objectStore("versions").put(n); o.onsuccess = function () { }, o.onerror = function () { $.Error("Error in DB add version request in BABYLON.Database.") } } catch (e) { $.Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + e.message), t(-1) } else t(-1) }, e.prototype.loadFile = function (t, i, r, n, o) { var a = this, s = e._ReturnFullUrlLocation(t), l = function () { a._saveFileAsync(s, i, r, o, n) }; this._checkVersionFromDB(s, (function (e) { -1 !== e ? a._mustUpdateRessources ? a._saveFileAsync(s, i, r, o, n) : a._loadFileAsync(s, i, l) : n && n() })) }, e.prototype._loadFileAsync = function (e, t, i) { if (this._isSupported && this._db) { var r, n; n = -1 !== e.indexOf(".babylon") ? "scenes" : "textures"; var o = this._db.transaction([n]); o.oncomplete = function () { r ? t(r.data) : i() }, o.onabort = function () { i() }; var a = o.objectStore(n).get(e); a.onsuccess = function (e) { r = e.target.result }, a.onerror = function () { $.Error("Error loading file " + e + " from DB."), i() } } else $.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."), t() }, e.prototype._saveFileAsync = function (t, i, r, n, o) { var a = this; if (this._isSupported) { var s; s = -1 !== t.indexOf(".babylon") ? "scenes" : "textures"; var l, c = new He; c.open("GET", t + (null == t.match(/\?/) ? "?" : "&") + Date.now()), n && (c.responseType = "arraybuffer"), r && (c.onprogress = r), c.addEventListener("load", (function () { if (200 === c.status || c.status < 400 && e._ValidateXHRData(c, n ? 6 : 1)) if (l = n ? c.response : c.responseText, !a._hasReachedQuota && a._db) { var r = a._db.transaction([s], "readwrite"); r.onabort = function (e) { try { var t = e.target.error; t && "QuotaExceededError" === t.name && (a._hasReachedQuota = !0) } catch (e) { } i(l) }, r.oncomplete = function () { i(l) }; var u; u = "scenes" === s ? { sceneUrl: t, data: l, version: a._manifestVersionFound } : { textureUrl: t, data: l }; try { var h = r.objectStore(s).put(u); h.onsuccess = function () { }, h.onerror = function () { $.Error("Error in DB add file request in BABYLON.Database.") } } catch (e) { i(l) } } else i(l); else c.status >= 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 = Yg(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 }(), sE = 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 }(); Ut.ShadersStore.gpuUpdateParticlesPixelShader = "#version 300 es\nvoid main() {discard;}\n"; Ut.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 lE = 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 za && 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 Vt("gpuUpdateParticles", this._updateEffectOptions, this._engine), new sE(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) }, e.prototype.createParticleBuffer = function (e) { return e }, e.prototype.bindDrawBuffers = function (e) { 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; e < this._updateVAO.length; e++)this._engine.releaseVertexArrayObject(this._updateVAO[e]); for (this._updateVAO.length = 0, e = 0; e < this._renderVAO.length; e++)this._engine.releaseVertexArrayObject(this._renderVAO[e]); this._renderVAO.length = 0 }, e.prototype._createUpdateVAO = function (e) { var t = {}; t.position = e.createVertexBuffer("position", 0, 3); var i = 3; t.age = e.createVertexBuffer("age", i, 1), i += 1, t.size = e.createVertexBuffer("size", i, 3), i += 3, t.life = e.createVertexBuffer("life", i, 1), i += 1, t.seed = e.createVertexBuffer("seed", i, 4), i += 4, t.direction = e.createVertexBuffer("direction", i, 3), i += 3, this._parent.particleEmitterType instanceof za && (t.initialPosition = e.createVertexBuffer("initialPosition", i, 3), i += 3), this._parent._colorGradientsTexture || (t.color = e.createVertexBuffer("color", i, 4), i += 4), this._parent._isBillboardBased || (t.initialDirection = e.createVertexBuffer("initialDirection", i, 3), i += 3), this._parent.noiseTexture && (t.noiseCoordinates1 = e.createVertexBuffer("noiseCoordinates1", i, 3), i += 3, t.noiseCoordinates2 = e.createVertexBuffer("noiseCoordinates2", i, 3), i += 3), this._parent._angularSpeedGradientsTexture ? (t.angle = e.createVertexBuffer("angle", i, 1), i += 1) : (t.angle = e.createVertexBuffer("angle", i, 2), i += 2), this._parent._isAnimationSheetEnabled && (t.cellIndex = e.createVertexBuffer("cellIndex", i, 1), i += 1, this._parent.spriteRandomStartCell && (t.cellStartOffset = e.createVertexBuffer("cellStartOffset", i, 1), i += 1)); var r = this._engine.recordVertexArrayObject(t, null, this._updateEffect); return this._engine.bindArrayBuffer(null), r }, e }(); b("BABYLON.WebGL2ParticleSystem", lE); Ut.ShadersStoreWGSL.gpuUpdateParticlesComputeShader = "struct Particle {position : vec3,\nage : f32,\nsize : vec3,\nlife : f32,\nseed : vec4,\ndirection : vec3,\ndummy0: f32,\n#ifdef CUSTOMEMITTER\ninitialPosition : vec3,\ndummy1: f32,\n#endif\n#ifndef COLORGRADIENTS\ncolor : vec4,\n#endif\n#ifndef BILLBOARD\ninitialDirection : vec3,\ndummy2: f32,\n#endif\n#ifdef NOISE\nnoiseCoordinates1 : vec3,\ndummy3: f32,\nnoiseCoordinates2 : vec3,\ndummy4: f32,\n#endif\n#ifdef ANGULARSPEEDGRADIENTS\nangle : f32,\n#else\nangle : vec2,\n#endif\n#ifdef ANIMATESHEET\ncellIndex : f32,\n#ifdef ANIMATESHEETRANDOMSTART\ncellStartOffset : f32,\n#endif\n#endif\n};struct Particles {particles : array,};struct SimParams {currentCount : f32,\ntimeDelta : f32,\nstopFactor : f32,\nrandomTextureSize: i32,\nlifeTime : vec2,\nemitPower : vec2,\n#ifndef COLORGRADIENTS\ncolor1 : vec4,\ncolor2 : vec4,\n#endif\nsizeRange : vec2,\nscaleRange : vec4,\nangleRange : vec4,\ngravity : vec3,\n#ifdef LIMITVELOCITYGRADIENTS\nlimitVelocityDamping : f32,\n#endif\n#ifdef ANIMATESHEET\ncellInfos : vec4,\n#endif\n#ifdef NOISE\nnoiseStrength : vec3,\n#endif\n#ifndef LOCAL\nemitterWM : mat4x4,\n#endif\n#ifdef BOXEMITTER\ndirection1 : vec3,\ndirection2 : vec3,\nminEmitBox : vec3,\nmaxEmitBox : vec3,\n#endif\n#ifdef CONEEMITTER\nradius : vec2,\nconeAngle : f32,\nheight : vec2,\ndirectionRandomizer : f32,\n#endif\n#ifdef CYLINDEREMITTER\nradius : f32,\nheight : f32,\nradiusRange : f32,\n#ifdef DIRECTEDCYLINDEREMITTER\ndirection1 : vec3,\ndirection2 : vec3,\n#else\ndirectionRandomizer : f32,\n#endif\n#endif\n#ifdef HEMISPHERICEMITTER\nradius : f32,\nradiusRange : f32,\ndirectionRandomizer : f32,\n#endif\n#ifdef POINTEMITTER\ndirection1 : vec3,\ndirection2 : vec3,\n#endif\n#ifdef SPHEREEMITTER\nradius : f32,\nradiusRange : f32,\n#ifdef DIRECTEDSPHEREEMITTER\ndirection1 : vec3,\ndirection2 : vec3,\n#else\ndirectionRandomizer : f32,\n#endif\n#endif\n};@binding(0) @group(0) var params : SimParams;@binding(1) @group(0) var particlesIn : Particles;@binding(2) @group(0) var particlesOut : Particles;@binding(3) @group(0) var randomTexture : texture_2d;@binding(4) @group(0) var randomTexture2 : texture_2d;\n#ifdef SIZEGRADIENTS\n@binding(0) @group(1) var sizeGradientSampler : sampler;@binding(1) @group(1) var sizeGradientTexture : texture_2d;\n#endif \n#ifdef ANGULARSPEEDGRADIENTS\n@binding(2) @group(1) var angularSpeedGradientSampler : sampler;@binding(3) @group(1) var angularSpeedGradientTexture : texture_2d;\n#endif \n#ifdef VELOCITYGRADIENTS\n@binding(4) @group(1) var velocityGradientSampler : sampler;@binding(5) @group(1) var velocityGradientTexture : texture_2d;\n#endif\n#ifdef LIMITVELOCITYGRADIENTS\n@binding(6) @group(1) var limitVelocityGradientSampler : sampler;@binding(7) @group(1) var limitVelocityGradientTexture : texture_2d;\n#endif\n#ifdef DRAGGRADIENTS\n@binding(8) @group(1) var dragGradientSampler : sampler;@binding(9) @group(1) var dragGradientTexture : texture_2d;\n#endif\n#ifdef NOISE\n@binding(10) @group(1) var noiseSampler : sampler;@binding(11) @group(1) var noiseTexture : texture_2d;\n#endif\nfn getRandomVec3(offset : f32,vertexID : f32)->vec3 {return textureLoad(randomTexture2,vec2(i32(vertexID*offset/params.currentCount*f32(params.randomTextureSize)) % params.randomTextureSize,0),0).rgb;}\nfn getRandomVec4(offset : f32,vertexID : f32)->vec4 {return textureLoad(randomTexture,vec2(i32(vertexID*offset/params.currentCount*f32(params.randomTextureSize)) % params.randomTextureSize,0),0);}\n@compute @workgroup_size(64)\nfn main(@builtin(global_invocation_id) GlobalInvocationID : vec3) {let index : u32=GlobalInvocationID.x;let vertexID : f32=f32(index);if (index>=u32(params.currentCount)) {return;}\nlet PI : f32=3.14159;let timeDelta : f32=params.timeDelta;let newAge : f32=particlesIn.particles[index].age+timeDelta;let life : f32=particlesIn.particles[index].life;let seed : vec4=particlesIn.particles[index].seed;let direction : vec3=particlesIn.particles[index].direction;if (newAge>=life && params.stopFactor != 0.) {var newPosition : vec3;var newDirection : vec3;let randoms : vec4=getRandomVec4(seed.x,vertexID);let outLife : f32=params.lifeTime.x+(params.lifeTime.y-params.lifeTime.x)*randoms.r;particlesOut.particles[index].life=outLife;particlesOut.particles[index].age=newAge-life;particlesOut.particles[index].seed=seed;var sizex : f32;\n#ifdef SIZEGRADIENTS \nsizex=textureSampleLevel(sizeGradientTexture,sizeGradientSampler,vec2(0.,0.),0.).r;\n#else\nsizex=params.sizeRange.x+(params.sizeRange.y-params.sizeRange.x)*randoms.g;\n#endif\nparticlesOut.particles[index].size=vec3(\nsizex,\nparams.scaleRange.x+(params.scaleRange.y-params.scaleRange.x)*randoms.b,\nparams.scaleRange.z+(params.scaleRange.w-params.scaleRange.z)*randoms.a);\n#ifndef COLORGRADIENTS\nparticlesOut.particles[index].color=params.color1+(params.color2-params.color1)*randoms.b;\n#endif\n#ifndef ANGULARSPEEDGRADIENTS \nparticlesOut.particles[index].angle=vec2(\nparams.angleRange.z+(params.angleRange.w-params.angleRange.z)*randoms.r,\nparams.angleRange.x+(params.angleRange.y-params.angleRange.x)*randoms.a);\n#else\nparticlesOut.particles[index].angle=params.angleRange.z+(params.angleRange.w-params.angleRange.z)*randoms.r;\n#endif \n#if defined(POINTEMITTER)\nlet randoms2 : vec3=getRandomVec3(seed.y,vertexID);let randoms3 : vec3=getRandomVec3(seed.z,vertexID);newPosition=vec3(0.,0.,0.);newDirection=params.direction1+(params.direction2-params.direction1)*randoms3;\n#elif defined(BOXEMITTER)\nlet randoms2 : vec3=getRandomVec3(seed.y,vertexID);let randoms3 : vec3=getRandomVec3(seed.z,vertexID);newPosition=params.minEmitBox+(params.maxEmitBox-params.minEmitBox)*randoms2;newDirection=params.direction1+(params.direction2-params.direction1)*randoms3; \n#elif defined(HEMISPHERICEMITTER)\nlet randoms2 : vec3=getRandomVec3(seed.y,vertexID);let randoms3 : vec3=getRandomVec3(seed.z,vertexID);let phi : f32=2.0*PI*randoms2.x;let theta : f32=acos(-1.0+2.0*randoms2.y);let randX : f32=cos(phi)*sin(theta);let randY : f32=cos(theta);let randZ : f32=sin(phi)*sin(theta);newPosition=(params.radius-(params.radius*params.radiusRange*randoms2.z))*vec3(randX,abs(randY),randZ);newDirection=normalize(newPosition+params.directionRandomizer*randoms3);\n#elif defined(SPHEREEMITTER)\nlet randoms2 : vec3=getRandomVec3(seed.y,vertexID);let randoms3 : vec3=getRandomVec3(seed.z,vertexID);let phi : f32=2.0*PI*randoms2.x;let theta : f32=acos(-1.0+2.0*randoms2.y);let randX : f32=cos(phi)*sin(theta);let randY : f32=cos(theta);let randZ : f32=sin(phi)*sin(theta);newPosition=(params.radius-(params.radius*params.radiusRange*randoms2.z))*vec3(randX,randY,randZ);\n#ifdef DIRECTEDSPHEREEMITTER\nnewDirection=normalize(params.direction1+(params.direction2-params.direction1)*randoms3);\n#else\nnewDirection=normalize(newPosition+params.directionRandomizer*randoms3);\n#endif\n#elif defined(CYLINDEREMITTER)\nlet randoms2 : vec3=getRandomVec3(seed.y,vertexID);let randoms3 : vec3=getRandomVec3(seed.z,vertexID);let yPos : f32=(-0.5+randoms2.x)*params.height;var angle : f32=randoms2.y*PI*2.;let inverseRadiusRangeSquared : f32=(1.-params.radiusRange)*(1.-params.radiusRange);let positionRadius : f32=params.radius*sqrt(inverseRadiusRangeSquared+randoms2.z*(1.-inverseRadiusRangeSquared));let xPos : f32=positionRadius*cos(angle);let zPos : f32=positionRadius*sin(angle);newPosition=vec3(xPos,yPos,zPos);\n#ifdef DIRECTEDCYLINDEREMITTER\nnewDirection=params.direction1+(params.direction2-params.direction1)*randoms3;\n#else\nangle=angle+(-0.5+randoms3.x)*PI*params.directionRandomizer;newDirection=vec3(cos(angle),(-0.5+randoms3.y)*params.directionRandomizer,sin(angle));newDirection=normalize(newDirection);\n#endif\n#elif defined(CONEEMITTER)\nlet randoms2 : vec3=getRandomVec3(seed.y,vertexID);let s : f32=2.0*PI*randoms2.x;\n#ifdef CONEEMITTERSPAWNPOINT\nlet h : f32=0.0001;\n#else\nvar h : f32=randoms2.y*params.height.y;h=1.-h*h; \n#endif\nvar lRadius : f32=params.radius.x-params.radius.x*randoms2.z*params.radius.y;lRadius=lRadius*h;let randX : f32=lRadius*sin(s);let randZ : f32=lRadius*cos(s);let randY : f32=h *params.height.x;newPosition=vec3(randX,randY,randZ); \nif (abs(cos(params.coneAngle))==1.0) {newDirection=vec3(0.,1.0,0.);} else {let randoms3 : vec3=getRandomVec3(seed.z,vertexID);newDirection=normalize(newPosition+params.directionRandomizer*randoms3); }\n#elif defined(CUSTOMEMITTER)\nnewPosition=particlesIn.particles[index].initialPosition;particlesOut.particles[index].initialPosition=newPosition;\n#else \nnewPosition=vec3(0.,0.,0.);newDirection=2.0*(getRandomVec3(seed.w,vertexID)-vec3(0.5,0.5,0.5));\n#endif\nlet power : f32=params.emitPower.x+(params.emitPower.y-params.emitPower.x)*randoms.a;\n#ifdef LOCAL\nparticlesOut.particles[index].position=newPosition;\n#else\nparticlesOut.particles[index].position=(params.emitterWM*vec4(newPosition,1.)).xyz;\n#endif\n#ifdef CUSTOMEMITTER\nparticlesOut.particles[index].direction=direction;\n#ifndef BILLBOARD \nparticlesOut.particles[index].initialDirection=direction;\n#endif\n#else\n#ifdef LOCAL\nlet initial : vec3=newDirection;\n#else \nlet initial : vec3=(params.emitterWM*vec4(newDirection,0.)).xyz;\n#endif\nparticlesOut.particles[index].direction=initial*power;\n#ifndef BILLBOARD \nparticlesOut.particles[index].initialDirection=initial;\n#endif\n#endif\n#ifdef ANIMATESHEET \nparticlesOut.particles[index].cellIndex=params.cellInfos.x;\n#ifdef ANIMATESHEETRANDOMSTART\nparticlesOut.particles[index].cellStartOffset=randoms.a*outLife;\n#endif \n#endif\n#ifdef NOISE\nparticlesOut.particles[index].noiseCoordinates1=particlesIn.particles[index].noiseCoordinates1;particlesOut.particles[index].noiseCoordinates2=particlesIn.particles[index].noiseCoordinates2;\n#endif\n} else {var directionScale : f32=timeDelta;particlesOut.particles[index].age=newAge;let ageGradient : f32=newAge/life;\n#ifdef VELOCITYGRADIENTS\ndirectionScale=directionScale*textureSampleLevel(velocityGradientTexture,velocityGradientSampler,vec2(ageGradient,0.),0.).r;\n#endif\n#ifdef DRAGGRADIENTS\ndirectionScale=directionScale*(1.0-textureSampleLevel(dragGradientTexture,dragGradientSampler,vec2(ageGradient,0.),0.).r);\n#endif\nlet position : vec3=particlesIn.particles[index].position;\n#if defined(CUSTOMEMITTER)\nparticlesOut.particles[index].position=position+(direction-position)*ageGradient; \nparticlesOut.particles[index].initialPosition=particlesIn.particles[index].initialPosition;\n#else\nparticlesOut.particles[index].position=position+direction*directionScale;\n#endif\nparticlesOut.particles[index].life=life;particlesOut.particles[index].seed=seed;\n#ifndef COLORGRADIENTS \nparticlesOut.particles[index].color=particlesIn.particles[index].color;\n#endif\n#ifdef SIZEGRADIENTS\nparticlesOut.particles[index].size=vec3(\ntextureSampleLevel(sizeGradientTexture,sizeGradientSampler,vec2(ageGradient,0.),0.).r,\nparticlesIn.particles[index].size.yz);\n#else\nparticlesOut.particles[index].size=particlesIn.particles[index].size;\n#endif \n#ifndef BILLBOARD \nparticlesOut.particles[index].initialDirection=particlesIn.particles[index].initialDirection;\n#endif\n#ifdef CUSTOMEMITTER\nparticlesOut.particles[index].direction=direction;\n#else\nvar updatedDirection : vec3=direction+params.gravity*timeDelta;\n#ifdef LIMITVELOCITYGRADIENTS\nlet limitVelocity : f32=textureSampleLevel(limitVelocityGradientTexture,limitVelocityGradientSampler,vec2(ageGradient,0.),0.).r;let currentVelocity : f32=length(updatedDirection);if (currentVelocity>limitVelocity) {updatedDirection=updatedDirection*params.limitVelocityDamping;}\n#endif\nparticlesOut.particles[index].direction=updatedDirection;\n#ifdef NOISE\nlet noiseCoordinates1 : vec3=particlesIn.particles[index].noiseCoordinates1;let noiseCoordinates2 : vec3=particlesIn.particles[index].noiseCoordinates2;let fetchedR : f32=textureSampleLevel(noiseTexture,noiseSampler,vec2(noiseCoordinates1.x,noiseCoordinates1.y)*vec2(0.5,0.5)+vec2(0.5,0.5),0.).r;let fetchedG : f32=textureSampleLevel(noiseTexture,noiseSampler,vec2(noiseCoordinates1.z,noiseCoordinates2.x)*vec2(0.5,0.5)+vec2(0.5,0.5),0.).r;let fetchedB : f32=textureSampleLevel(noiseTexture,noiseSampler,vec2(noiseCoordinates2.y,noiseCoordinates2.z)*vec2(0.5,0.5)+vec2(0.5,0.5),0.).r;let force : vec3=vec3(-1.+2.*fetchedR,-1.+2.*fetchedG,-1.+2.*fetchedB)*params.noiseStrength;particlesOut.particles[index].direction=particlesOut.particles[index].direction+force*timeDelta;particlesOut.particles[index].noiseCoordinates1=noiseCoordinates1;particlesOut.particles[index].noiseCoordinates2=noiseCoordinates2;\n#endif \n#endif \n#ifdef ANGULARSPEEDGRADIENTS\nlet angularSpeed : f32=textureSampleLevel(angularSpeedGradientTexture,angularSpeedGradientSampler,vec2(ageGradient,0.),0.).r;particlesOut.particles[index].angle=particlesIn.particles[index].angle+angularSpeed*timeDelta;\n#else\nlet angle : vec2=particlesIn.particles[index].angle;particlesOut.particles[index].angle=vec2(angle.x+angle.y*timeDelta,angle.y);\n#endif\n#ifdef ANIMATESHEET \nvar offsetAge : f32=particlesOut.particles[index].age;let dist : f32=params.cellInfos.y-params.cellInfos.x;\n#ifdef ANIMATESHEETRANDOMSTART\nlet cellStartOffset : f32=particlesIn.particles[index].cellStartOffset;particlesOut.particles[index].cellStartOffset=cellStartOffset;offsetAge=offsetAge+cellStartOffset;\n#else\nlet cellStartOffset : f32=0.;\n#endif \nvar ratio : f32;if (params.cellInfos.w==1.0) {ratio=clamp(((cellStartOffset+params.cellInfos.z*offsetAge) % life)/life,0.,1.0);}\nelse {ratio=clamp((cellStartOffset+params.cellInfos.z*offsetAge)/life,0.,1.0);}\nparticlesOut.particles[index].cellIndex=f32(i32(params.cellInfos.x+ratio*dist));\n#endif\n}}\n"; var cE = function () { function e(e, t) { this._bufferComputeShader = [], this._renderVertexBuffers = [], this.alignDataInBuffer = !0, this._parent = e, this._engine = t } return e.prototype.contextLost = function () { this._updateComputeShader = void 0, this._bufferComputeShader.length = 0, this._renderVertexBuffers.length = 0 }, e.prototype.isUpdateBufferCreated = function () { return !!this._updateComputeShader }, e.prototype.isUpdateBufferReady = function () { var e, t; return null !== (t = null === (e = this._updateComputeShader) || void 0 === e ? void 0 : e.isReady()) && void 0 !== t && t }, e.prototype.createUpdateBuffer = function (e) { var t, i = { params: { group: 0, binding: 0 }, particlesIn: { group: 0, binding: 1 }, particlesOut: { group: 0, binding: 2 }, randomTexture: { group: 0, binding: 3 }, randomTexture2: { group: 0, binding: 4 } }; return this._parent._sizeGradientsTexture && (i.sizeGradientTexture = { group: 1, binding: 1 }), this._parent._angularSpeedGradientsTexture && (i.angularSpeedGradientTexture = { group: 1, binding: 3 }), this._parent._velocityGradientsTexture && (i.velocityGradientTexture = { group: 1, binding: 5 }), this._parent._limitVelocityGradientsTexture && (i.limitVelocityGradientTexture = { group: 1, binding: 7 }), this._parent._dragGradientsTexture && (i.dragGradientTexture = { group: 1, binding: 9 }), this._parent.noiseTexture && (i.noiseTexture = { group: 1, binding: 11 }), this._updateComputeShader = new iu("updateParticles", this._engine, "gpuUpdateParticles", { bindingsMapping: i, defines: e.split("\n") }), null === (t = this._simParamsComputeShader) || void 0 === t || t.dispose(), this._simParamsComputeShader = new zi(this._engine), this._simParamsComputeShader.addUniform("currentCount", 1), this._simParamsComputeShader.addUniform("timeDelta", 1), this._simParamsComputeShader.addUniform("stopFactor", 1), this._simParamsComputeShader.addUniform("randomTextureSize", 1), this._simParamsComputeShader.addUniform("lifeTime", 2), this._simParamsComputeShader.addUniform("emitPower", 2), this._parent._colorGradientsTexture || (this._simParamsComputeShader.addUniform("color1", 4), this._simParamsComputeShader.addUniform("color2", 4)), this._simParamsComputeShader.addUniform("sizeRange", 2), this._simParamsComputeShader.addUniform("scaleRange", 4), this._simParamsComputeShader.addUniform("angleRange", 4), this._simParamsComputeShader.addUniform("gravity", 3), this._parent._limitVelocityGradientsTexture && this._simParamsComputeShader.addUniform("limitVelocityDamping", 1), this._parent.isAnimationSheetEnabled && this._simParamsComputeShader.addUniform("cellInfos", 4), this._parent.noiseTexture && this._simParamsComputeShader.addUniform("noiseStrength", 3), this._parent.isLocal || this._simParamsComputeShader.addUniform("emitterWM", 16), this._parent.particleEmitterType && this._parent.particleEmitterType.buildUniformLayout(this._simParamsComputeShader), this._updateComputeShader.setUniformBuffer("params", this._simParamsComputeShader), new sE(this._simParamsComputeShader) }, e.prototype.createVertexBuffers = function (e, t) { this._renderVertexBuffers.push(t) }, e.prototype.createParticleBuffer = function (e) { var t = new As(this._engine, 4 * e.length, a.BUFFER_CREATIONFLAG_READWRITE | a.BUFFER_CREATIONFLAG_VERTEX); return t.update(e), this._bufferComputeShader.push(t), t.getBuffer() }, e.prototype.bindDrawBuffers = function (e, t) { this._engine.bindBuffers(this._renderVertexBuffers[e], null, t) }, e.prototype.preUpdateParticleBuffer = function () { }, e.prototype.updateParticleBuffer = function (e, t, i) { this._simParamsComputeShader.update(), this._updateComputeShader.setTexture("randomTexture", this._parent._randomTexture, !1), this._updateComputeShader.setTexture("randomTexture2", this._parent._randomTexture2, !1), this._parent._sizeGradientsTexture && this._updateComputeShader.setTexture("sizeGradientTexture", this._parent._sizeGradientsTexture), this._parent._angularSpeedGradientsTexture && this._updateComputeShader.setTexture("angularSpeedGradientTexture", this._parent._angularSpeedGradientsTexture), this._parent._velocityGradientsTexture && this._updateComputeShader.setTexture("velocityGradientTexture", this._parent._velocityGradientsTexture), this._parent._limitVelocityGradientsTexture && this._updateComputeShader.setTexture("limitVelocityGradientTexture", this._parent._limitVelocityGradientsTexture), this._parent._dragGradientsTexture && this._updateComputeShader.setTexture("dragGradientTexture", this._parent._dragGradientsTexture), this._parent.noiseTexture && this._updateComputeShader.setTexture("noiseTexture", this._parent.noiseTexture), this._updateComputeShader.setStorageBuffer("particlesIn", this._bufferComputeShader[e]), this._updateComputeShader.setStorageBuffer("particlesOut", this._bufferComputeShader[1 ^ e]), this._updateComputeShader.dispatch(Math.ceil(i / 64)) }, e.prototype.releaseBuffers = function () { for (var e, t = 0; t < this._bufferComputeShader.length; ++t)this._bufferComputeShader[t].dispose(); this._bufferComputeShader.length = 0, null === (e = this._simParamsComputeShader) || void 0 === e || e.dispose(), this._simParamsComputeShader = null, this._updateComputeShader = null }, e.prototype.releaseVertexBuffers = function () { this._renderVertexBuffers.length = 0 }, e }(); b("BABYLON.ComputeShaderParticleSystem", cE); var uE, hE = function () { function e(e, t, i) { this.gradient = e, this.color1 = t, this.color2 = i } return e.prototype.getColorToRef = function (e) { this.color2 ? U.LerpToRef(this.color1, this.color2, Math.random(), e) : e.copyFrom(this.color1) }, e }(), dE = function (e, t) { this.gradient = e, this.color = t }, pE = function () { function e(e, t, i) { this.gradient = e, this.factor1 = t, this.factor2 = i } return e.prototype.getFactor = function () { return void 0 === this.factor2 || this.factor2 === this.factor1 ? this.factor1 : this.factor1 + (this.factor2 - this.factor1) * Math.random() }, e }(), fE = function () { function e() { } return e.GetCurrentGradient = function (e, t, i) { if (t[0].gradient > e) i(t[0], t[0], 1); else { for (var r = 0; r < t.length - 1; r++) { var n = t[r], o = t[r + 1]; if (e >= 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 }(), _E = 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" }(uE || (uE = {})); var mE = function () { function e(e) { if (this.particleSystem = e, this.type = uE.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), ge("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 }(); Ut.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}"; Ut.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+translationPivot;\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.;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.;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.;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.;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 gE = 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 _E(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 === uE.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 === uE.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 Jt(s._engine) }, s._customWrappers[0].effect = n, s._drawWrappers = [], s._useInstancing = s._engine.getCaps().instancedArrays, s._createIndexBuffer(), s._createVertexBuffers(), s.particleEmitterType = new Fa; 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; a < e.length; a++)o(a), a = r }, s } return W(t, e), 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, "useRampGradients", { get: function () { return this._useRampGradients }, set: function (e) { this._useRampGradients !== e && (this._useRampGradients = e, this._resetEffect()) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "particles", { get: function () { return this._particles }, enumerable: !1, configurable: !0 }), t.prototype.getActiveCount = function () { return this._particles.length }, t.prototype.getClassName = function () { return "ParticleSystem" }, t.prototype.isStopping = function () { return this._stopped && this.isAlive() }, 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 Jt(this._engine), this._customWrappers[t].effect = e, this._customWrappers[t].drawContext && (this._customWrappers[t].drawContext.useInstancing = this._useInstancing) }, 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 "particles" }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "vertexBuffers", { get: function () { return this._vertexBuffers }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "indexBuffer", { get: function () { return this._indexBuffer }, enumerable: !1, configurable: !0 }), t.prototype._addFactorGradient = function (e, t, i, r) { var n = new pE(t, i, r); e.push(n), e.sort((function (e, t) { return e.gradient < t.gradient ? -1 : e.gradient > t.gradient ? 1 : 0 })) }, t.prototype._removeFactorGradient = function (e, t) { if (e) for (var i = 0, r = 0, n = e; r < n.length; r++) { if (n[r].gradient === t) { e.splice(i, 1); break } i++ } }, t.prototype.addLifeTimeGradient = function (e, t, i) { return this._lifeTimeGradients || (this._lifeTimeGradients = []), this._addFactorGradient(this._lifeTimeGradients, e, t, i), this }, t.prototype.removeLifeTimeGradient = function (e) { return this._removeFactorGradient(this._lifeTimeGradients, e), this }, t.prototype.addSizeGradient = function (e, t, i) { return this._sizeGradients || (this._sizeGradients = []), this._addFactorGradient(this._sizeGradients, e, t, i), this }, t.prototype.removeSizeGradient = function (e) { return this._removeFactorGradient(this._sizeGradients, e), this }, t.prototype.addColorRemapGradient = function (e, t, i) { return this._colorRemapGradients || (this._colorRemapGradients = []), this._addFactorGradient(this._colorRemapGradients, e, t, i), this }, t.prototype.removeColorRemapGradient = function (e) { return this._removeFactorGradient(this._colorRemapGradients, e), this }, t.prototype.addAlphaRemapGradient = function (e, t, i) { return this._alphaRemapGradients || (this._alphaRemapGradients = []), this._addFactorGradient(this._alphaRemapGradients, e, t, i), this }, t.prototype.removeAlphaRemapGradient = function (e) { return this._removeFactorGradient(this._alphaRemapGradients, e), this }, t.prototype.addAngularSpeedGradient = function (e, t, i) { return this._angularSpeedGradients || (this._angularSpeedGradients = []), this._addFactorGradient(this._angularSpeedGradients, e, t, i), this }, t.prototype.removeAngularSpeedGradient = function (e) { return this._removeFactorGradient(this._angularSpeedGradients, e), this }, t.prototype.addVelocityGradient = function (e, t, i) { return this._velocityGradients || (this._velocityGradients = []), this._addFactorGradient(this._velocityGradients, e, t, i), this }, t.prototype.removeVelocityGradient = function (e) { return this._removeFactorGradient(this._velocityGradients, e), this }, t.prototype.addLimitVelocityGradient = function (e, t, i) { return this._limitVelocityGradients || (this._limitVelocityGradients = []), this._addFactorGradient(this._limitVelocityGradients, e, t, i), this }, t.prototype.removeLimitVelocityGradient = function (e) { return this._removeFactorGradient(this._limitVelocityGradients, e), this }, t.prototype.addDragGradient = function (e, t, i) { return this._dragGradients || (this._dragGradients = []), this._addFactorGradient(this._dragGradients, e, t, i), this }, t.prototype.removeDragGradient = function (e) { return this._removeFactorGradient(this._dragGradients, e), this }, t.prototype.addEmitRateGradient = function (e, t, i) { return this._emitRateGradients || (this._emitRateGradients = []), this._addFactorGradient(this._emitRateGradients, e, t, i), this }, t.prototype.removeEmitRateGradient = function (e) { return this._removeFactorGradient(this._emitRateGradients, e), this }, t.prototype.addStartSizeGradient = function (e, t, i) { return this._startSizeGradients || (this._startSizeGradients = []), this._addFactorGradient(this._startSizeGradients, e, t, i), this }, t.prototype.removeStartSizeGradient = function (e) { return this._removeFactorGradient(this._startSizeGradients, e), this }, t.prototype._createRampGradientTexture = function () { if (this._rampGradients && this._rampGradients.length && !this._rampGradientsTexture && this._scene) { for (var e = new Uint8Array(4 * this._rawTextureWidth), t = V.Color3[0], i = function (i) { var n = i / r._rawTextureWidth; fE.GetCurrentGradient(n, r._rampGradients, (function (r, n, o) { B.LerpToRef(r.color, n.color, o, t), e[4 * i] = 255 * t.r, e[4 * i + 1] = 255 * t.g, e[4 * i + 2] = 255 * t.b, e[4 * i + 3] = 255 })) }, r = this, n = 0; n < this._rawTextureWidth; n++)i(n); this._rampGradientsTexture = Eo.CreateRGBATexture(e, this._rawTextureWidth, 1, this._scene, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE) } }, t.prototype.getRampGradients = function () { return this._rampGradients }, t.prototype.forceRefreshGradients = function () { this._syncRampGradientTexture() }, t.prototype._syncRampGradientTexture = function () { this._rampGradients && (this._rampGradients.sort((function (e, t) { return e.gradient < t.gradient ? -1 : e.gradient > t.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 hE(e, t, i); return this._colorGradients.push(r), this._colorGradients.sort((function (e, t) { return e.gradient < t.gradient ? -1 : e.gradient > t.gradient ? 1 : 0 })), this }, t.prototype.removeColorGradient = function (e) { if (!this._colorGradients) return this; for (var t = 0, i = 0, r = this._colorGradients; i < r.length; i++) { if (r[i].gradient === e) { this._colorGradients.splice(t, 1); break } t++ } return this }, t.prototype.resetDrawCache = function () { for (var e = 0, t = this._drawWrappers; e < t.length; e++) { var i = t[e]; if (i) for (var r = 0, n = i; r < n.length; r++) { var o = n[r]; null == o || o.dispose() } } this._drawWrappers = [] }, t.prototype._fetchR = function (e, t, i, r, n) { return n[4 * (((e = .5 * Math.abs(e) + .5) * i % i | 0) + ((t = .5 * Math.abs(t) + .5) * r % r | 0) * i)] / 255 }, t.prototype._reset = function () { this._resetEffect() }, t.prototype._resetEffect = function () { this._vertexBuffer && (this._vertexBuffer.dispose(), this._vertexBuffer = null), this._spriteBuffer && (this._spriteBuffer.dispose(), this._spriteBuffer = null), this._vertexArrayObject && (this._engine.releaseVertexArrayObject(this._vertexArrayObject), this._vertexArrayObject = null), this._createVertexBuffers() }, t.prototype._createVertexBuffers = function () { this._vertexBufferSize = this._useInstancing ? 10 : 12, this._isAnimationSheetEnabled && (this._vertexBufferSize += 1), this._isBillboardBased && this.billboardMode !== t.BILLBOARDMODE_STRETCHED && this.billboardMode !== t.BILLBOARDMODE_STRETCHED_LOCAL || (this._vertexBufferSize += 3), this._useRampGradients && (this._vertexBufferSize += 4); var e = this._engine, i = this._vertexBufferSize * (this._useInstancing ? 1 : 4); this._vertexData = new Float32Array(this._capacity * i), this._vertexBuffer = new Wi(e, this._vertexData, !0, i); var r = 0, n = this._vertexBuffer.createVertexBuffer(Hi.PositionKind, r, 3, this._vertexBufferSize, this._useInstancing); this._vertexBuffers[Hi.PositionKind] = n, r += 3; var o = this._vertexBuffer.createVertexBuffer(Hi.ColorKind, r, 4, this._vertexBufferSize, this._useInstancing); this._vertexBuffers[Hi.ColorKind] = o, r += 4; var a = this._vertexBuffer.createVertexBuffer("angle", r, 1, this._vertexBufferSize, this._useInstancing); this._vertexBuffers.angle = a, r += 1; var s, l = this._vertexBuffer.createVertexBuffer("size", r, 2, this._vertexBufferSize, this._useInstancing); if (this._vertexBuffers.size = l, r += 2, this._isAnimationSheetEnabled) { var c = this._vertexBuffer.createVertexBuffer("cellIndex", r, 1, this._vertexBufferSize, this._useInstancing); this._vertexBuffers.cellIndex = c, r += 1 } if (!this._isBillboardBased || this.billboardMode === t.BILLBOARDMODE_STRETCHED || this.billboardMode === t.BILLBOARDMODE_STRETCHED_LOCAL) { var u = this._vertexBuffer.createVertexBuffer("direction", r, 3, this._vertexBufferSize, this._useInstancing); this._vertexBuffers.direction = u, r += 3 } if (this._useRampGradients) { var h = this._vertexBuffer.createVertexBuffer("remapData", r, 4, this._vertexBufferSize, this._useInstancing); this._vertexBuffers.remapData = h, r += 4 } if (this._useInstancing) { var d = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]); this._spriteBuffer = new Wi(e, d, !1, 2), s = this._spriteBuffer.createVertexBuffer("offset", 0, 2) } else s = this._vertexBuffer.createVertexBuffer("offset", r, 2, this._vertexBufferSize, this._useInstancing), r += 2; this._vertexBuffers.offset = s, this.resetDrawCache() }, t.prototype._createIndexBuffer = function () { if (!this._useInstancing) { for (var e = [], t = 0, i = 0; i < this._capacity; i++)e.push(t), e.push(t + 1), e.push(t + 2), e.push(t), e.push(t + 2), e.push(t + 3), t += 4; this._indexBuffer = this._engine.createIndexBuffer(e) } }, t.prototype.getCapacity = function () { return this._capacity }, t.prototype.isAlive = function () { return this._alive }, t.prototype.isStarted = function () { return this._started }, t.prototype._prepareSubEmitterInternalArray = function () { var e = this; this._subEmitters = new Array, this.subEmitters && this.subEmitters.forEach((function (i) { i instanceof t ? e._subEmitters.push([new mE(i)]) : i instanceof mE ? e._subEmitters.push([i]) : i instanceof Array && e._subEmitters.push(i) })) }, t.prototype.start = function (e) { var t, i = this; if (void 0 === e && (e = this.startDelay), !this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set"; if (e) setTimeout((function () { i.start(0) }), e); else { if (this._prepareSubEmitterInternalArray(), this._started = !0, this._stopped = !1, this._actualFrame = 0, this._subEmitters && 0 != this._subEmitters.length && (this.activeSubSystems = new Array), this._emitRateGradients && (this._emitRateGradients.length > 0 && (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; e < i.preWarmCycles; e++)i.animate(!0), r.render() })) })); else for (var n = 0; n < this.preWarmCycles; n++)this.animate(!0) } this.beginAnimationOnStart && this.animations && this.animations.length > 0 && 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 < e && "break" !== o(); s++); }, t._GetAttributeNamesOrOptions = function (e, t, i) { void 0 === e && (e = !1), void 0 === t && (t = !1), void 0 === i && (i = !1); var r = [Hi.PositionKind, Hi.ColorKind, "angle", "offset", "size"]; return e && r.push("cellIndex"), t || r.push("direction"), i && r.push("remapData"), r }, t._GetEffectCreationOptions = function (e, t) { void 0 === e && (e = !1), void 0 === t && (t = !1); var i = ["invView", "view", "projection", "textureMask", "translationPivot", "eyePosition"]; return wn(i), e && i.push("particlesInfos"), t && i.push("logarithmicDepthConstant"), i }, t.prototype.fillDefines = function (e, i) { if (this._scene && Bn(this, this._scene, e), this._isAnimationSheetEnabled && e.push("#define ANIMATESHEET"), this.useLogarithmicDepth && e.push("#define LOGARITHMICDEPTH"), i === t.BLENDMODE_MULTIPLY && e.push("#define BLENDMULTIPLYMODE"), this._useRampGradients && e.push("#define RAMPGRADIENT"), this._isBillboardBased) switch (e.push("#define BILLBOARD"), this.billboardMode) { case t.BILLBOARDMODE_Y: e.push("#define BILLBOARDY"); break; case t.BILLBOARDMODE_STRETCHED: case t.BILLBOARDMODE_STRETCHED_LOCAL: e.push("#define BILLBOARDSTRETCHED"), this.billboardMode === t.BILLBOARDMODE_STRETCHED_LOCAL && e.push("#define BILLBOARDSTRETCHED_LOCAL"); break; case t.BILLBOARDMODE_ALL: e.push("#define BILLBOARDMODE_ALL") }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._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== t.BILLBOARDMODE_STRETCHED && this.billboardMode !== t.BILLBOARDMODE_STRETCHED_LOCAL, this._useRampGradients)), e.push.apply(e, t._GetEffectCreationOptions(this._isAnimationSheetEnabled, this.useLogarithmicDepth)), r.push("diffuseSampler", "rampSampler"), this._imageProcessingConfiguration && (Ni.PrepareUniforms(e, this._imageProcessingConfigurationDefines), Ni.PrepareSamplers(r, this._imageProcessingConfigurationDefines)) }, 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._engine._features.supportRenderPasses ? this._engine.currentRenderPassId : a.RENDERPASS_MAIN, n = this._drawWrappers[r]; n || (n = this._drawWrappers[r] = []); var o = n[e]; o || ((o = new Jt(this._engine)).drawContext && (o.drawContext.useInstancing = this._useInstancing), n[e] = o); var s = i.join("\n"); if (o.defines !== s) { var l = [], c = [], u = []; this.fillUniformsAttributesAndSamplerNames(c, l, u), o.setEffect(this._engine.createEffect("particles", l, c, u, s), s) } return o }, t.prototype.animate = function (e) { var t, i = this; if (void 0 === e && (e = !1), this._started) { if (!e && this._scene) { if (!this.isReady()) return; if (this._currentRenderId === this._scene.getFrameId()) return; this._currentRenderId = this._scene.getFrameId() } var r; if (this._scaledUpdateSpeed = this.updateSpeed * (e ? this.preWarmStepOffset : (null === (t = this._scene) || void 0 === t ? void 0 : t.getAnimationRatio()) || 1), this.manualEmitCount > -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 < this._particles.length; s++) { var l = this._particles[s]; this._appendParticleVertices(a, l), a += this._useInstancing ? 1 : 4 } this._vertexBuffer && this._vertexBuffer.updateDirectly(this._vertexData, 0, this._particles.length) } 0 === this.manualEmitCount && this.disposeOnStop && this.stop() } }, t.prototype._appendParticleVertices = function (e, t) { this._appendParticleVertex(e++, t, 0, 0), this._useInstancing || (this._appendParticleVertex(e++, t, 1, 0), this._appendParticleVertex(e++, t, 1, 1), this._appendParticleVertex(e++, t, 0, 1)) }, t.prototype.rebuild = function () { var e, t; for (var i in this._engine.getCaps().vertexArrayObject && (this._vertexArrayObject = null), this._createIndexBuffer(), null === (e = this._spriteBuffer) || void 0 === e || e._rebuild(), null === (t = this._vertexBuffer) || void 0 === t || t._rebuild(), this._vertexBuffers) this._vertexBuffers[i]._rebuild(); this.resetDrawCache() }, t.prototype.isReady = function () { if (!this.emitter || this._imageProcessingConfiguration && !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady()) return !1; if (this.blendMode !== t.BLENDMODE_MULTIPLYADD) { if (!this._getWrapper(this.blendMode).effect.isReady()) return !1 } else { if (!this._getWrapper(t.BLENDMODE_MULTIPLY).effect.isReady()) return !1; if (!this._getWrapper(t.BLENDMODE_ADD).effect.isReady()) return !1 } return !0 }, t.prototype._render = function (e) { var i, r, n = this._getWrapper(e), o = n.effect, s = this._engine; s.enableEffect(n); var l = null !== (i = this.defaultViewMatrix) && void 0 !== i ? i : this._scene.getViewMatrix(); if (o.setTexture("diffuseSampler", this.particleTexture), o.setMatrix("view", l), o.setMatrix("projection", null !== (r = this.defaultProjectionMatrix) && void 0 !== r ? r : this._scene.getProjectionMatrix()), this._isAnimationSheetEnabled && this.particleTexture) { var c = this.particleTexture.getBaseSize(); o.setFloat3("particlesInfos", this.spriteCellWidth / c.width, this.spriteCellHeight / c.height, this.spriteCellWidth / c.width) } if (o.setVector2("translationPivot", this.translationPivot), o.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a), this._isBillboardBased && this._scene) { var u = this._scene.activeCamera; o.setVector3("eyePosition", u.globalPosition) } this._rampGradientsTexture && (this._rampGradients && this._rampGradients.length || (this._rampGradientsTexture.dispose(), this._rampGradientsTexture = null), o.setTexture("rampSampler", this._rampGradientsTexture)); var h = o.defines; switch (this._scene && Vn(o, this, this._scene), h.indexOf("#define BILLBOARDMODE_ALL") >= 0 && (l.invertToRef(O.Matrix[0]), o.setMatrix("invView", O.Matrix[0])), void 0 !== this._vertexArrayObject ? (this._vertexArrayObject || (this._vertexArrayObject = this._engine.recordVertexArrayObject(this._vertexBuffers, this._indexBuffer, o)), this._engine.bindVertexArrayObject(this._vertexArrayObject, this._indexBuffer)) : s.bindBuffers(this._vertexBuffers, this._indexBuffer, o), this.useLogarithmicDepth && this._scene && zn.BindLogDepth(h, o, this._scene), this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess && this._imageProcessingConfiguration.bind(o), e) { case t.BLENDMODE_ADD: s.setAlphaMode(a.ALPHA_ADD); break; case t.BLENDMODE_ONEONE: s.setAlphaMode(a.ALPHA_ONEONE); break; case t.BLENDMODE_STANDARD: s.setAlphaMode(a.ALPHA_COMBINE); break; case t.BLENDMODE_MULTIPLY: s.setAlphaMode(a.ALPHA_MULTIPLY) }return this._onBeforeDrawParticlesObservable && this._onBeforeDrawParticlesObservable.notifyObservers(o), this._useInstancing ? s.drawArraysType(a.MATERIAL_TriangleStripDrawMode, 0, 4, this._particles.length) : s.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._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 < this._subEmitters.length; t++)for (var i = 0, r = this._subEmitters[t]; i < r.length; i++)r[i].dispose(); this._subEmitters = [], this.subEmitters = [] } this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose && this.emitter.dispose(!0), this._onBeforeDrawParticlesObservable && this._onBeforeDrawParticlesObservable.clear(), this._scene && ((t = this._scene.particleSystems.indexOf(this)) > -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; r < n.length; r++) { for (var o = [], a = 0, s = n[r]; a < s.length; a++) { var l = s[a]; o.push(l.serialize(e)) } i.subEmitters.push(o) } } return i }, t._Serialize = function (e, t, i) { if (e.name = t.name, e.id = t.id, e.capacity = t.getCapacity(), e.disposeOnStop = t.disposeOnStop, e.manualEmitCount = t.manualEmitCount, t.emitter.position) { var r = t.emitter; e.emitterId = r.id } else { var n = t.emitter; e.emitter = n.asArray() } t.particleEmitterType && (e.particleEmitterType = t.particleEmitterType.serialize()), t.particleTexture && (i ? e.texture = t.particleTexture.serialize() : (e.textureName = t.particleTexture.name, e.invertY = !!t.particleTexture._invertY)), e.isLocal = t.isLocal, Ue.AppendSerializedAnimations(t, e), e.beginAnimationOnStart = t.beginAnimationOnStart, e.beginAnimationFrom = t.beginAnimationFrom, e.beginAnimationTo = t.beginAnimationTo, e.beginAnimationLoop = t.beginAnimationLoop, e.startDelay = t.startDelay, e.renderingGroupId = t.renderingGroupId, e.isBillboardBased = t.isBillboardBased, e.billboardMode = t.billboardMode, e.minAngularSpeed = t.minAngularSpeed, e.maxAngularSpeed = t.maxAngularSpeed, e.minSize = t.minSize, e.maxSize = t.maxSize, e.minScaleX = t.minScaleX, e.maxScaleX = t.maxScaleX, e.minScaleY = t.minScaleY, e.maxScaleY = t.maxScaleY, e.minEmitPower = t.minEmitPower, e.maxEmitPower = t.maxEmitPower, e.minLifeTime = t.minLifeTime, e.maxLifeTime = t.maxLifeTime, e.emitRate = t.emitRate, e.gravity = t.gravity.asArray(), e.noiseStrength = t.noiseStrength.asArray(), e.color1 = t.color1.asArray(), e.color2 = t.color2.asArray(), e.colorDead = t.colorDead.asArray(), e.updateSpeed = t.updateSpeed, e.targetStopDuration = t.targetStopDuration, e.blendMode = t.blendMode, e.preWarmCycles = t.preWarmCycles, e.preWarmStepOffset = t.preWarmStepOffset, e.minInitialRotation = t.minInitialRotation, e.maxInitialRotation = t.maxInitialRotation, e.startSpriteCellID = t.startSpriteCellID, e.spriteCellLoop = t.spriteCellLoop, e.endSpriteCellID = t.endSpriteCellID, e.spriteCellChangeSpeed = t.spriteCellChangeSpeed, e.spriteCellWidth = t.spriteCellWidth, e.spriteCellHeight = t.spriteCellHeight, e.spriteRandomStartCell = t.spriteRandomStartCell, e.isAnimationSheetEnabled = t.isAnimationSheetEnabled, e.useLogarithmicDepth = t.useLogarithmicDepth; var o = t.getColorGradients(); if (o) { e.colorGradients = []; for (var a = 0, s = o; a < s.length; a++) { var l = s[a], c = { gradient: l.gradient, color1: l.color1.asArray() }; l.color2 ? c.color2 = l.color2.asArray() : c.color2 = l.color1.asArray(), e.colorGradients.push(c) } } var u = t.getRampGradients(); if (u) { e.rampGradients = []; for (var h = 0, d = u; h < d.length; h++) { var p = d[h]; c = { gradient: p.gradient, color: p.color.asArray() }, e.rampGradients.push(c) } e.useRampGradients = t.useRampGradients } var f = t.getColorRemapGradients(); if (f) { e.colorRemapGradients = []; for (var _ = 0, m = f; _ < m.length; _++) { var g = m[_]; c = { gradient: g.gradient, factor1: g.factor1 }, void 0 !== g.factor2 ? c.factor2 = g.factor2 : c.factor2 = g.factor1, e.colorRemapGradients.push(c) } } var v = t.getAlphaRemapGradients(); if (v) { e.alphaRemapGradients = []; for (var y = 0, b = v; y < b.length; y++) { var T = b[y]; c = { gradient: T.gradient, factor1: T.factor1 }, void 0 !== T.factor2 ? c.factor2 = T.factor2 : c.factor2 = T.factor1, e.alphaRemapGradients.push(c) } } var E = t.getSizeGradients(); if (E) { e.sizeGradients = []; for (var S = 0, x = E; S < x.length; S++) { var A = x[S]; c = { gradient: A.gradient, factor1: A.factor1 }, void 0 !== A.factor2 ? c.factor2 = A.factor2 : c.factor2 = A.factor1, e.sizeGradients.push(c) } } var R = t.getAngularSpeedGradients(); if (R) { e.angularSpeedGradients = []; for (var C = 0, P = R; C < P.length; C++) { var I = P[C]; c = { gradient: I.gradient, factor1: I.factor1 }, void 0 !== I.factor2 ? c.factor2 = I.factor2 : c.factor2 = I.factor1, e.angularSpeedGradients.push(c) } } var M = t.getVelocityGradients(); if (M) { e.velocityGradients = []; for (var O = 0, D = M; O < D.length; O++) { var N = D[O]; c = { gradient: N.gradient, factor1: N.factor1 }, void 0 !== N.factor2 ? c.factor2 = N.factor2 : c.factor2 = N.factor1, e.velocityGradients.push(c) } } var F = t.getDragGradients(); if (F) { e.dragGradients = []; for (var L = 0, w = F; L < w.length; L++) { var B = w[L]; c = { gradient: B.gradient, factor1: B.factor1 }, void 0 !== B.factor2 ? c.factor2 = B.factor2 : c.factor2 = B.factor1, e.dragGradients.push(c) } } var U = t.getEmitRateGradients(); if (U) { e.emitRateGradients = []; for (var V = 0, k = U; V < k.length; V++) { var G = k[V]; c = { gradient: G.gradient, factor1: G.factor1 }, void 0 !== G.factor2 ? c.factor2 = G.factor2 : c.factor2 = G.factor1, e.emitRateGradients.push(c) } } var z = t.getStartSizeGradients(); if (z) { e.startSizeGradients = []; for (var W = 0, H = z; W < H.length; W++) { var X = H[W]; c = { gradient: X.gradient, factor1: X.factor1 }, void 0 !== X.factor2 ? c.factor2 = X.factor2 : c.factor2 = X.factor1, e.startSizeGradients.push(c) } } var j = t.getLifeTimeGradients(); if (j) { e.lifeTimeGradients = []; for (var Y = 0, K = j; Y < K.length; Y++) { var Q = K[Y]; c = { gradient: Q.gradient, factor1: Q.factor1 }, void 0 !== Q.factor2 ? c.factor2 = Q.factor2 : c.factor2 = Q.factor1, e.lifeTimeGradients.push(c) } } var q = t.getLimitVelocityGradients(); if (q) { e.limitVelocityGradients = []; for (var Z = 0, J = q; Z < J.length; Z++) { var $ = J[Z]; c = { gradient: $.gradient, factor1: $.factor1 }, void 0 !== $.factor2 ? c.factor2 = $.factor2 : c.factor2 = $.factor1, e.limitVelocityGradients.push(c) } e.limitVelocityDamping = t.limitVelocityDamping } t.noiseTexture && (e.noiseTexture = t.noiseTexture.serialize()) }, t._Parse = function (e, t, i, r) { var n, o, a, s; s = i instanceof ti ? null : i; var l, c = T("BABYLON.Texture"); if (c && s && (e.texture ? t.particleTexture = c.Parse(e.texture, s, r) : e.textureName && (t.particleTexture = new c(r + e.textureName, s, !1, void 0 === e.invertY || e.invertY), t.particleTexture.name = e.textureName)), e.emitterId || 0 === e.emitterId || void 0 !== e.emitter ? e.emitterId && s ? t.emitter = s.getLastMeshById(e.emitterId) : t.emitter = R.FromArray(e.emitter) : t.emitter = R.Zero(), t.isLocal = !!e.isLocal, void 0 !== e.renderingGroupId && (t.renderingGroupId = e.renderingGroupId), void 0 !== e.isBillboardBased && (t.isBillboardBased = e.isBillboardBased), void 0 !== e.billboardMode && (t.billboardMode = e.billboardMode), void 0 !== e.useLogarithmicDepth && (t.useLogarithmicDepth = e.useLogarithmicDepth), e.animations) { for (var u = 0; u < e.animations.length; u++) { var h = e.animations[u], d = T("BABYLON.Animation"); d && t.animations.push(d.Parse(h)) } t.beginAnimationOnStart = e.beginAnimationOnStart, t.beginAnimationFrom = e.beginAnimationFrom, t.beginAnimationTo = e.beginAnimationTo, t.beginAnimationLoop = e.beginAnimationLoop } if (e.autoAnimate && s && s.beginAnimation(t, e.autoAnimateFrom, e.autoAnimateTo, e.autoAnimateLoop, e.autoAnimateSpeed || 1), t.startDelay = 0 | e.startDelay, t.minAngularSpeed = e.minAngularSpeed, t.maxAngularSpeed = e.maxAngularSpeed, t.minSize = e.minSize, t.maxSize = e.maxSize, e.minScaleX && (t.minScaleX = e.minScaleX, t.maxScaleX = e.maxScaleX, t.minScaleY = e.minScaleY, t.maxScaleY = e.maxScaleY), void 0 !== e.preWarmCycles && (t.preWarmCycles = e.preWarmCycles, t.preWarmStepOffset = e.preWarmStepOffset), void 0 !== e.minInitialRotation && (t.minInitialRotation = e.minInitialRotation, t.maxInitialRotation = e.maxInitialRotation), t.minLifeTime = e.minLifeTime, t.maxLifeTime = e.maxLifeTime, t.minEmitPower = e.minEmitPower, t.maxEmitPower = e.maxEmitPower, t.emitRate = e.emitRate, t.gravity = R.FromArray(e.gravity), e.noiseStrength && (t.noiseStrength = R.FromArray(e.noiseStrength)), t.color1 = U.FromArray(e.color1), t.color2 = U.FromArray(e.color2), t.colorDead = U.FromArray(e.colorDead), t.updateSpeed = e.updateSpeed, t.targetStopDuration = e.targetStopDuration, t.blendMode = e.blendMode, e.colorGradients) for (var p = 0, f = e.colorGradients; p < f.length; p++) { var _ = f[p]; t.addColorGradient(_.gradient, U.FromArray(_.color1), _.color2 ? U.FromArray(_.color2) : void 0) } if (e.rampGradients) { for (var m = 0, g = e.rampGradients; m < g.length; m++) { var v = g[m]; t.addRampGradient(v.gradient, B.FromArray(v.color)) } t.useRampGradients = e.useRampGradients } if (e.colorRemapGradients) for (var y = 0, b = e.colorRemapGradients; y < b.length; y++) { var E = b[y]; t.addColorRemapGradient(E.gradient, void 0 !== E.factor1 ? E.factor1 : E.factor, E.factor2) } if (e.alphaRemapGradients) for (var S = 0, x = e.alphaRemapGradients; S < x.length; S++) { var A = x[S]; t.addAlphaRemapGradient(A.gradient, void 0 !== A.factor1 ? A.factor1 : A.factor, A.factor2) } if (e.sizeGradients) for (var C = 0, P = e.sizeGradients; C < P.length; C++) { var I = P[C]; t.addSizeGradient(I.gradient, void 0 !== I.factor1 ? I.factor1 : I.factor, I.factor2) } if (e.angularSpeedGradients) for (var M = 0, O = e.angularSpeedGradients; M < O.length; M++) { var D = O[M]; t.addAngularSpeedGradient(D.gradient, void 0 !== D.factor1 ? D.factor1 : D.factor, D.factor2) } if (e.velocityGradients) for (var N = 0, F = e.velocityGradients; N < F.length; N++) { var L = F[N]; t.addVelocityGradient(L.gradient, void 0 !== L.factor1 ? L.factor1 : L.factor, L.factor2) } if (e.dragGradients) for (var w = 0, V = e.dragGradients; w < V.length; w++) { var k = V[w]; t.addDragGradient(k.gradient, void 0 !== k.factor1 ? k.factor1 : k.factor, k.factor2) } if (e.emitRateGradients) for (var G = 0, z = e.emitRateGradients; G < z.length; G++) { var W = z[G]; t.addEmitRateGradient(W.gradient, void 0 !== W.factor1 ? W.factor1 : W.factor, W.factor2) } if (e.startSizeGradients) for (var H = 0, X = e.startSizeGradients; H < X.length; H++) { var j = X[H]; t.addStartSizeGradient(j.gradient, void 0 !== j.factor1 ? j.factor1 : j.factor, j.factor2) } if (e.lifeTimeGradients) for (var Y = 0, K = e.lifeTimeGradients; Y < K.length; Y++) { var Q = K[Y]; t.addLifeTimeGradient(Q.gradient, void 0 !== Q.factor1 ? Q.factor1 : Q.factor, Q.factor2) } if (e.limitVelocityGradients) { for (var q = 0, Z = e.limitVelocityGradients; q < Z.length; q++) { var J = Z[q]; t.addLimitVelocityGradient(J.gradient, void 0 !== J.factor1 ? J.factor1 : J.factor, J.factor2) } t.limitVelocityDamping = e.limitVelocityDamping } if (e.noiseTexture && s) { var $ = T("BABYLON.ProceduralTexture"); t.noiseTexture = $.Parse(e.noiseTexture, s, r) } if (e.particleEmitterType) { switch (e.particleEmitterType.type) { case "SphereParticleEmitter": l = new ka; break; case "SphereDirectedParticleEmitter": l = new Ga; break; case "ConeEmitter": case "ConeParticleEmitter": l = new La; break; case "CylinderParticleEmitter": l = new wa; break; case "CylinderDirectedParticleEmitter": l = new Ba; break; case "HemisphericParticleEmitter": l = new Ua; break; case "PointParticleEmitter": l = new Va; break; case "MeshParticleEmitter": l = new Wa; break; default: l = new Fa }l.parse(e.particleEmitterType, s) } else (l = new Fa).parse(e, s); t.particleEmitterType = l, t.startSpriteCellID = e.startSpriteCellID, t.endSpriteCellID = e.endSpriteCellID, t.spriteCellLoop = null === (n = e.spriteCellLoop) || void 0 === n || n, t.spriteCellWidth = e.spriteCellWidth, t.spriteCellHeight = e.spriteCellHeight, t.spriteCellChangeSpeed = e.spriteCellChangeSpeed, t.spriteRandomStartCell = e.spriteRandomStartCell, t.disposeOnStop = null !== (o = e.disposeOnStop) && void 0 !== o && o, t.manualEmitCount = null !== (a = e.manualEmitCount) && void 0 !== a ? a : -1 }, t.Parse = function (e, i, r, n, o) { void 0 === n && (n = !1); var a, s = e.name, l = null, c = null; if (a = i instanceof ti ? i : i.getEngine(), e.customShader && a.createEffectForParticles) { var u = (c = e.customShader).shaderOptions.defines.length > 0 ? 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; d < p.length; d++) { for (var f = [], _ = 0, m = p[d]; _ < m.length; _++) { var g = m[_]; f.push(mE.Parse(g, i, r)) } h.subEmitters.push(f) } } return t._Parse(e, h, i, r), e.textureMask && (h.textureMask = U.FromArray(e.textureMask)), e.preventAutoStart && (h.preventAutoStart = e.preventAutoStart), n || h.preventAutoStart || h.start(), h }, t.BILLBOARDMODE_Y = a.PARTICLES_BILLBOARDMODE_Y, t.BILLBOARDMODE_ALL = a.PARTICLES_BILLBOARDMODE_ALL, t.BILLBOARDMODE_STRETCHED = a.PARTICLES_BILLBOARDMODE_STRETCHED, t.BILLBOARDMODE_STRETCHED_LOCAL = a.PARTICLES_BILLBOARDMODE_STRETCHED_LOCAL, t }(Ha); mE._ParseParticleSystem = gE.Parse; Ut.IncludesShadersStore.clipPlaneFragmentDeclaration2 = "#ifdef CLIPPLANE\nin float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nin float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nin float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nin float fClipDistance4;\n#endif\n#ifdef CLIPPLANE5\nin float fClipDistance5;\n#endif\n#ifdef CLIPPLANE6\nin float fClipDistance6;\n#endif\n"; Ut.ShadersStore.gpuRenderParticlesPixelShader = "precision highp float;\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nuniform sampler2D diffuseSampler;varying vec2 vUV;varying vec4 vColor;\n#include \n#include\n#include\n#include\n#include\nvoid main() {\n#include \nvec4 textureColor=texture2D(diffuseSampler,vUV);gl_FragColor=textureColor*vColor;\n#ifdef BLENDMULTIPLYMODE\nfloat alpha=vColor.a*textureColor.a;gl_FragColor.rgb=gl_FragColor.rgb*alpha+vec3(1.0)*(1.0-alpha);\n#endif \n#include\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ngl_FragColor.rgb=toLinearSpace(gl_FragColor.rgb);\n#else\n#ifdef IMAGEPROCESSING\ngl_FragColor.rgb=toLinearSpace(gl_FragColor.rgb);gl_FragColor=applyImageProcessing(gl_FragColor);\n#endif\n#endif\n}\n"; Ut.IncludesShadersStore.clipPlaneVertexDeclaration2 = "#ifdef CLIPPLANE\nuniform vec4 vClipPlane;out float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nuniform vec4 vClipPlane2;out float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nuniform vec4 vClipPlane3;out float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nuniform vec4 vClipPlane4;out float fClipDistance4;\n#endif\n#ifdef CLIPPLANE5\nuniform vec4 vClipPlane5;out float fClipDistance5;\n#endif\n#ifdef CLIPPLANE6\nuniform vec4 vClipPlane6;out float fClipDistance6;\n#endif\n"; Ut.ShadersStore.gpuRenderParticlesVertexShader = "precision highp float;uniform mat4 view;uniform mat4 projection;uniform vec2 translationPivot;uniform vec3 worldOffset;\n#ifdef LOCAL\nuniform mat4 emitterWM;\n#endif\nattribute vec3 position;attribute float age;attribute float life;attribute vec3 size;\n#ifndef BILLBOARD\nattribute vec3 initialDirection;\n#endif\n#ifdef BILLBOARDSTRETCHED\nattribute vec3 direction;\n#endif\nattribute float angle;\n#ifdef ANIMATESHEET\nattribute float cellIndex;\n#endif\nattribute vec2 offset;attribute vec2 uv;varying vec2 vUV;varying vec4 vColor;varying vec3 vPositionW;\n#if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)\nuniform mat4 invView;\n#endif\n#include\n#include\n#ifdef COLORGRADIENTS\nuniform sampler2D colorGradientSampler;\n#else\nuniform vec4 colorDead;attribute vec4 color;\n#endif\n#ifdef ANIMATESHEET\nuniform vec3 sheetInfos;\n#endif\n#ifdef BILLBOARD\nuniform vec3 eyePosition;\n#endif\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {vec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));vec3 zaxis=normalize(cross(yaxis,xaxis));vec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);vec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);vec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);mat3 rotMatrix= mat3(row0,row1,row2);vec3 alignedCorner=rotMatrix*rotatedCorner;\n#ifdef LOCAL\nreturn ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner;\n#else\nreturn (position+worldOffset)+alignedCorner;\n#endif\n}\n#ifdef BILLBOARDSTRETCHED\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {vec3 normalizedToCamera=normalize(toCamera);vec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));vec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));vec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);vec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);vec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);mat3 rotMatrix= mat3(row0,row1,row2);vec3 alignedCorner=rotMatrix*rotatedCorner;\n#ifdef LOCAL\nreturn ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner;\n#else\nreturn (position+worldOffset)+alignedCorner;\n#endif\n}\n#endif\nvoid main() {\n#ifdef ANIMATESHEET\nfloat rowOffset=floor(cellIndex/sheetInfos.z);float columnOffset=cellIndex-rowOffset*sheetInfos.z;vec2 uvScale=sheetInfos.xy;vec2 uvOffset=vec2(uv.x ,1.0-uv.y);vUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\n#else\nvUV=uv;\n#endif\nfloat ratio=age/life;\n#ifdef COLORGRADIENTS\nvColor=texture2D(colorGradientSampler,vec2(ratio,0));\n#else\nvColor=color*vec4(1.0-ratio)+colorDead*vec4(ratio);\n#endif\nvec2 cornerPos=(offset-translationPivot)*size.yz*size.x+translationPivot;\n#ifdef BILLBOARD\nvec4 rotatedCorner;rotatedCorner.w=0.;\n#ifdef BILLBOARDY\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.y=0.;vec3 yaxis=(position+worldOffset)-eyePosition;yaxis.y=0.;vPositionW=rotate(normalize(yaxis),rotatedCorner.xyz);vec4 viewPosition=(view*vec4(vPositionW,1.0));\n#elif defined(BILLBOARDSTRETCHED)\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.z=0.;vec3 toCamera=(position+worldOffset)-eyePosition;vPositionW=rotateAlign(toCamera,rotatedCorner.xyz);vec4 viewPosition=(view*vec4(vPositionW,1.0));\n#else\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.z=0.;\n#ifdef LOCAL\nvec4 viewPosition=view*vec4(((emitterWM*vec4(position,1.0)).xyz+worldOffset),1.0)+rotatedCorner;\n#else\nvec4 viewPosition=view*vec4((position+worldOffset),1.0)+rotatedCorner;\n#endif\nvPositionW=(invView*viewPosition).xyz;\n#endif\n#else\nvec3 rotatedCorner;rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.y=0.;rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);vec3 yaxis=normalize(initialDirection);vPositionW=rotate(yaxis,rotatedCorner);vec4 viewPosition=view*vec4(vPositionW,1.0);\n#endif\ngl_Position=projection*viewPosition;\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\nvec4 worldPos=vec4(vPositionW,1.0);\n#endif\n#include\n#include\n}"; var vE = function (e) { function t(t, i, r, n, o) { void 0 === n && (n = null), void 0 === o && (o = !1); var s = e.call(this, t) || this; if (s.layerMask = 268435455, s._accumulatedCount = 0, s._renderVertexBuffers = [], s._targetIndex = 0, s._currentRenderId = -1, s._currentRenderingCameraUniqueId = -1, s._started = !1, s._stopped = !1, s._timeDelta = 0, s.updateInAnimate = !1, s._actualFrame = 0, s._rawTextureWidth = 256, s.onDisposeObservable = new u, s.onStoppedObservable = new u, s.forceDepthWrite = !1, s._preWarmDone = !1, s.isLocal = !1, s.isGPU = !0, s._onBeforeDrawParticlesObservable = null, 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().supportComputeShaders) { if (!T("BABYLON.ComputeShaderParticleSystem")) throw new Error("The ComputeShaderParticleSystem class is not available! Make sure you have imported it."); s._platform = new (T("BABYLON.ComputeShaderParticleSystem"))(s, s._engine) } else { if (!T("BABYLON.WebGL2ParticleSystem")) throw new Error("The WebGL2ParticleSystem class is not available! Make sure you have imported it."); s._platform = new (T("BABYLON.WebGL2ParticleSystem"))(s, s._engine) } s._customWrappers = { 0: new Jt(s._engine) }, s._customWrappers[0].effect = n, s._drawWrappers = { 0: new Jt(s._engine) }, s._drawWrappers[0].drawContext && (s._drawWrappers[0].drawContext.useInstancing = !0), s._attachImageProcessingConfiguration(null), (i = null != i ? i : {}).randomTextureSize || delete i.randomTextureSize; var l = H({ capacity: 5e4, randomTextureSize: s._engine.getCaps().maxTextureSize }, i), c = i; isFinite(c) && (l.capacity = c), s._capacity = l.capacity, s._maxActiveParticleCount = l.capacity, s._currentActiveCount = 0, s._isAnimationSheetEnabled = o, s.particleEmitterType = new Fa; for (var h = Math.min(s._engine.getCaps().maxTextureSize, l.randomTextureSize), d = [], p = 0; p < h; ++p)d.push(Math.random()), d.push(Math.random()), d.push(Math.random()), d.push(Math.random()); for (s._randomTexture = new Eo(new Float32Array(d), h, 1, a.TEXTUREFORMAT_RGBA, r, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE, a.TEXTURETYPE_FLOAT), s._randomTexture.name = "GPUParticleSystem_random1", s._randomTexture.wrapU = a.TEXTURE_WRAP_ADDRESSMODE, s._randomTexture.wrapV = a.TEXTURE_WRAP_ADDRESSMODE, d = [], p = 0; p < h; ++p)d.push(Math.random()), d.push(Math.random()), d.push(Math.random()), d.push(Math.random()); return s._randomTexture2 = new Eo(new Float32Array(d), h, 1, a.TEXTUREFORMAT_RGBA, r, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE, a.TEXTURETYPE_FLOAT), s._randomTexture2.name = "GPUParticleSystem_random2", s._randomTexture2.wrapU = a.TEXTURE_WRAP_ADDRESSMODE, s._randomTexture2.wrapV = a.TEXTURE_WRAP_ADDRESSMODE, s._randomTextureSize = h, s } return W(t, e), Object.defineProperty(t, "IsSupported", { get: function () { if (!S.LastCreatedEngine) return !1; var e = S.LastCreatedEngine.getCaps(); return e.supportTransformFeedbacks || e.supportComputeShaders }, enumerable: !1, configurable: !0 }), t.prototype.getCapacity = function () { return this._capacity }, Object.defineProperty(t.prototype, "maxActiveParticleCount", { get: function () { return this._maxActiveParticleCount }, set: function (e) { this._maxActiveParticleCount = Math.min(e, this._capacity) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "activeParticleCount", { get: function () { return this.maxActiveParticleCount }, set: function (e) { this.maxActiveParticleCount = e }, enumerable: !1, configurable: !0 }), t.prototype.isReady = function () { if (!this.emitter || this._imageProcessingConfiguration && !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady()) return !1; if (this.blendMode !== gE.BLENDMODE_MULTIPLYADD) { if (!this._getWrapper(this.blendMode).effect.isReady()) return !1 } else { if (!this._getWrapper(gE.BLENDMODE_MULTIPLY).effect.isReady()) return !1; if (!this._getWrapper(gE.BLENDMODE_ADD).effect.isReady()) return !1 } return this._platform.isUpdateBufferCreated() ? this._platform.isUpdateBufferReady() : (this._recreateUpdateEffect(), !1) }, t.prototype.isStarted = function () { return this._started }, t.prototype.isStopped = function () { return this._stopped }, t.prototype.isStopping = function () { return !1 }, t.prototype.getActiveCount = function () { return this._currentActiveCount }, t.prototype.start = function (e) { var t = this; if (void 0 === e && (e = this.startDelay), !this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set"; e ? setTimeout((function () { t.start(0) }), e) : (this._started = !0, this._stopped = !1, this._preWarmDone = !1, this.beginAnimationOnStart && this.animations && this.animations.length > 0 && 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 Jt(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 hE(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.gradient < t.gradient ? -1 : e.gradient > t.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 pE(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.gradient < t.gradient ? -1 : e.gradient > t.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 === gE.BILLBOARDMODE_STRETCHED && (r.direction = t.createVertexBuffer("direction", n, 3, this._attributesStrideSize, !0)), n += 3, this._platform.alignDataInBuffer && (n += 1), this.particleEmitterType instanceof za && (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 za && (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 za, n = O.Vector3[0], o = 0, a = 0; a < this._capacity; a++)if (i.push(0), i.push(0), i.push(0), i.push(0), i.push(0), i.push(0), i.push(0), i.push(0), i.push(Math.random()), i.push(Math.random()), i.push(Math.random()), i.push(Math.random()), r ? (this.particleEmitterType.particleDestinationGenerator(a, null, n), i.push(n.x), i.push(n.y), i.push(n.z)) : (i.push(0), i.push(0), i.push(0)), this._platform.alignDataInBuffer && i.push(0), o += 16, r && (this.particleEmitterType.particlePositionGenerator(a, null, n), i.push(n.x), i.push(n.y), i.push(n.z), this._platform.alignDataInBuffer && i.push(0), o += 4), this._colorGradientsTexture || (i.push(0), i.push(0), i.push(0), i.push(0), o += 4), this.isBillboardBased || (i.push(0), i.push(0), i.push(0), this._platform.alignDataInBuffer && i.push(0), o += 4), this.noiseTexture && (i.push(Math.random()), i.push(Math.random()), i.push(Math.random()), this._platform.alignDataInBuffer && i.push(0), i.push(Math.random()), i.push(Math.random()), i.push(Math.random()), this._platform.alignDataInBuffer && i.push(0), o += 8), i.push(0), o += 1, this._angularSpeedGradientsTexture || (i.push(0), o += 1), this._isAnimationSheetEnabled && (i.push(0), o += 1, this.spriteRandomStartCell && (i.push(0), o += 1)), this._platform.alignDataInBuffer) { var s = 3 - (o + 3 & 3); for (o += s; s-- > 0;)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 Wi(t, c, !1, this._attributesStrideSize), this._buffer1 = new Wi(t, u, !1, this._attributesStrideSize), this._spriteBuffer = new Wi(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 Jt(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 = [Hi.PositionKind, "age", "life", "size", "angle"]; return e || n.push(Hi.ColorKind), t && n.push("cellIndex"), i || n.push("initialDirection"), r && n.push("direction"), n.push("offset", Hi.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 wn(i), e && i.push("sheetInfos"), t && i.push("logarithmicDepthConstant"), i }, t.prototype.fillDefines = function (e, t) { if (void 0 === t && (t = 0), this._scene && Bn(this, this._scene, e), t === gE.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 gE.BILLBOARDMODE_Y: e.push("#define BILLBOARDY"); break; case gE.BILLBOARDMODE_STRETCHED: e.push("#define BILLBOARDSTRETCHED"); break; case gE.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 === gE.BILLBOARDMODE_STRETCHED)), e.push.apply(e, t._GetEffectCreationOptions(this._isAnimationSheetEnabled, this.useLogarithmicDepth)), r.push("diffuseSampler", "colorGradientSampler"), this._imageProcessingConfiguration && (Ni.PrepareUniforms(e, this._imageProcessingConfigurationDefines), Ni.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 < this._rawTextureWidth; s++)n(s); this[t] = Eo.CreateRTexture(r, this._rawTextureWidth, 1, this._scene || this._engine, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE), this[t].name = t.substring(1) } }, t.prototype._createSizeGradientTexture = function () { this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture") }, t.prototype._createAngularSpeedGradientTexture = function () { this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture") }, t.prototype._createVelocityGradientTexture = function () { this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture") }, t.prototype._createLimitVelocityGradientTexture = function () { this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture") }, t.prototype._createDragGradientTexture = function () { this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture") }, t.prototype._createColorGradientTexture = function () { if (this._colorGradients && this._colorGradients.length && !this._colorGradientsTexture) { for (var e = new Uint8Array(4 * this._rawTextureWidth), t = V.Color4[0], i = function (i) { var n = i / r._rawTextureWidth; fE.GetCurrentGradient(n, r._colorGradients, (function (r, n, o) { U.LerpToRef(r.color1, n.color1, o, t), e[4 * i] = 255 * t.r, e[4 * i + 1] = 255 * t.g, e[4 * i + 2] = 255 * t.b, e[4 * i + 3] = 255 * t.a })) }, r = this, n = 0; n < this._rawTextureWidth; n++)i(n); this._colorGradientsTexture = Eo.CreateRGBATexture(e, this._rawTextureWidth, 1, this._scene, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE), this._colorGradientsTexture.name = "colorGradients" } }, t.prototype._render = function (e, t) { var i, r, n = this._getWrapper(e), o = n.effect; this._engine.enableEffect(n); var s = (null === (i = this._scene) || void 0 === i ? void 0 : i.getViewMatrix()) || I.IdentityReadOnly; if (o.setMatrix("view", s), o.setMatrix("projection", null !== (r = this.defaultProjectionMatrix) && void 0 !== r ? r : this._scene.getProjectionMatrix()), o.setTexture("diffuseSampler", this.particleTexture), o.setVector2("translationPivot", this.translationPivot), o.setVector3("worldOffset", this.worldOffset), this.isLocal && o.setMatrix("emitterWM", t), this._colorGradientsTexture ? o.setTexture("colorGradientSampler", this._colorGradientsTexture) : o.setDirectColor4("colorDead", this.colorDead), this._isAnimationSheetEnabled && this.particleTexture) { var l = this.particleTexture.getBaseSize(); o.setFloat3("sheetInfos", this.spriteCellWidth / l.width, this.spriteCellHeight / l.height, l.width / this.spriteCellWidth) } if (this._isBillboardBased && this._scene) { var c = this._scene.activeCamera; o.setVector3("eyePosition", c.globalPosition) } var u = o.defines; if (this._scene && Vn(o, this, this._scene), u.indexOf("#define BILLBOARDMODE_ALL") >= 0) { var h = s.clone(); h.invert(), o.setMatrix("invView", h) } switch (this.useLogarithmicDepth && this._scene && zn.BindLogDepth(u, o, this._scene), this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess && this._imageProcessingConfiguration.bind(o), e) { case gE.BLENDMODE_ADD: this._engine.setAlphaMode(a.ALPHA_ADD); break; case gE.BLENDMODE_ONEONE: this._engine.setAlphaMode(a.ALPHA_ONEONE); break; case gE.BLENDMODE_STANDARD: this._engine.setAlphaMode(a.ALPHA_COMBINE); break; case gE.BLENDMODE_MULTIPLY: this._engine.setAlphaMode(a.ALPHA_MULTIPLY) }return this._platform.bindDrawBuffers(this._targetIndex, o), this._onBeforeDrawParticlesObservable && this._onBeforeDrawParticlesObservable.notifyObservers(o), this._engine.drawArraysType(a.MATERIAL_TriangleStripDrawMode, 0, 4, this._currentActiveCount), this._engine.setAlphaMode(a.ALPHA_DISABLE), 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; i < this.preWarmCycles; i++)this.animate(!0), this.render(!0, !0); this._preWarmDone = !0 } if (this._currentRenderId === this._scene.getRenderId() && (!this._scene.activeCamera || this._scene.activeCamera && this._currentRenderingCameraUniqueId === this._scene.activeCamera.uniqueId)) return 0; this._currentRenderId = this._scene.getRenderId(), this._scene.activeCamera && (this._currentRenderingCameraUniqueId = this._scene.activeCamera.uniqueId) } if (this._initialize(), this._accumulatedCount += this.emitRate * this._timeDelta, this._accumulatedCount > 1) { 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 === gE.BLENDMODE_MULTIPLYADD ? this._render(gE.BLENDMODE_MULTIPLY, n) + this._render(gE.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._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; r < this._renderVertexBuffers.length; ++r) { var n = this._renderVertexBuffers[r]; for (var o in n) n[o].dispose() } this._renderVertexBuffers = [], this._colorGradientsTexture && (this._colorGradientsTexture.dispose(), this._colorGradientsTexture = null), this._sizeGradientsTexture && (this._sizeGradientsTexture.dispose(), this._sizeGradientsTexture = null), this._angularSpeedGradientsTexture && (this._angularSpeedGradientsTexture.dispose(), this._angularSpeedGradientsTexture = null), this._velocityGradientsTexture && (this._velocityGradientsTexture.dispose(), this._velocityGradientsTexture = null), this._limitVelocityGradientsTexture && (this._limitVelocityGradientsTexture.dispose(), this._limitVelocityGradientsTexture = null), this._dragGradientsTexture && (this._dragGradientsTexture.dispose(), this._dragGradientsTexture = null), this._randomTexture && (this._randomTexture.dispose(), this._randomTexture = null), this._randomTexture2 && (this._randomTexture2.dispose(), this._randomTexture2 = null), e && this.particleTexture && (this.particleTexture.dispose(), this.particleTexture = null), e && this.noiseTexture && (this.noiseTexture.dispose(), this.noiseTexture = null), this.onStoppedObservable.clear(), this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear() }, 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") : ""; 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 gE._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 ti ? 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), gE._Parse(e, l, i, r), e.preventAutoStart && (l.preventAutoStart = e.preventAutoStart), n || l.preventAutoStart || l.start(), l }, t }(Ha), yE = 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; t < i.length; t++)i[t].emitter = e; this._emitterNode = e }, enumerable: !1, configurable: !0 }), e.prototype.setEmitterAsSphere = function (e, t, i) { this._emitterNodeIsOwned && this._emitterNode && this._emitterNode.dispose && this._emitterNode.dispose(), this._emitterNodeIsOwned = !0, this._emitterCreationOptions = { kind: "Sphere", options: e, renderingGroupId: t }; var r = bu("emitterSphere", { diameter: e.diameter, segments: e.segments }, i); r.renderingGroupId = t; var n = new mc("emitterSphereMaterial", i); n.emissiveColor = e.color, r.material = n; for (var o = 0, a = this.systems; o < a.length; o++)a[o].emitter = r; this._emitterNode = r }, e.prototype.start = function (e) { for (var t = 0, i = this.systems; t < i.length; t++) { var r = i[t]; e && (r.emitter = e), r.start() } }, e.prototype.dispose = function () { for (var e = 0, t = this.systems; e < t.length; e++)t[e].dispose(); this.systems.length = 0, this._emitterNode && (this._emitterNode.dispose && this._emitterNode.dispose(), this._emitterNode = null) }, e.prototype.serialize = function (e) { void 0 === e && (e = !1); for (var t = { systems: [] }, i = 0, r = this.systems; i < r.length; i++) { var n = r[i]; t.systems.push(n.serialize(e)) } return this._emitterNode && (t.emitter = this._emitterCreationOptions), t }, e.Parse = function (t, i, r, n) { void 0 === r && (r = !1); var o = new e, a = this.BaseAssetsUrl + "/textures/"; i = i || S.LastCreatedScene; for (var s = 0, l = t.systems; s < l.length; s++) { var c = l[s]; o.systems.push(r ? vE.Parse(c, i, a, !0, n) : gE.Parse(c, i, a, !0, n)) } if (t.emitter) { var u = t.emitter.options; "Sphere" === t.emitter.kind && o.setEmitterAsSphere({ diameter: u.diameter, segments: u.segments, color: B.FromArray(u.color) }, t.emitter.renderingGroupId, i) } return o }, e.BaseAssetsUrl = "https://assets.babylonjs.com/particles", e }(), bE = function () { function e() { } return e.CreateDefault = function (e, t, i, r) { var n; return void 0 === t && (t = 500), void 0 === r && (r = !1), (n = r ? new vE("default system", { capacity: t }, i) : new gE("default system", t, i)).emitter = e, n.particleTexture = new vo("https://assets.babylonjs.com/textures/flare.png", n.getScene()), n.createConeEmitter(.1, Math.PI / 4), n.color1 = new U(1, 1, 1, 1), n.color2 = new U(1, 1, 1, 1), n.colorDead = new U(1, 1, 1, 0), n.minSize = .1, n.maxSize = .1, n.minEmitPower = 2, n.maxEmitPower = 2, n.updateSpeed = 1 / 60, n.emitRate = 30, n }, e.CreateAsync = function (t, i, r, n) { void 0 === r && (r = !1), i || (i = S.LastCreatedScene); var o = {}; return i.addPendingData(o), new Promise((function (a, s) { if (r && !vE.IsSupported) return i.removePendingData(o), s("Particle system with GPU is not supported."); xi.LoadFile("".concat(e.BaseAssetsUrl, "/systems/").concat(t, ".json"), (function (e) { i.removePendingData(o); var t = JSON.parse(e.toString()); return a(yE.Parse(t, i, r, n)) }), void 0, void 0, void 0, (function () { return i.removePendingData(o), s("An error occurred with the creation of your particle system. Check if your type '".concat(t, "' exists.")) })) })) }, e.ExportSet = function (e) { for (var t = new yE, i = 0, r = e; i < r.length; i++) { var n = r[i]; t.systems.push(n) } return t }, e.ParseFromFileAsync = function (e, t, i, r, n, o) { return void 0 === r && (r = !1), void 0 === n && (n = ""), new Promise((function (a, s) { var l = new He; l.addEventListener("readystatechange", (function () { if (4 == l.readyState) if (200 == l.status) { var t = JSON.parse(l.responseText), c = void 0; c = r ? vE.Parse(t, i, n, !1, o) : gE.Parse(t, i, n, !1, o), e && (c.name = e), a(c) } else s("Unable to load the particle system") })), l.open("GET", t), l.send() })) }, e.ParseFromSnippetAsync = function (e, t, i, r, n) { var o = this; if (void 0 === i && (i = !1), void 0 === r && (r = ""), "_BLANK" === e) { var a = this.CreateDefault(null); return a.start(), Promise.resolve(a) } return new Promise((function (a, s) { var l = new He; l.addEventListener("readystatechange", (function () { if (4 == l.readyState) if (200 == l.status) { var o = JSON.parse(JSON.parse(l.responseText).jsonPayload), c = JSON.parse(o.particleSystem), u = void 0; (u = i ? vE.Parse(c, t, r, !1, n) : gE.Parse(c, t, r, !1, n)).snippetId = e, a(u) } else s("Unable to load the snippet " + e) })), l.open("GET", o.SnippetUrl + "/" + e.replace(/#/g, "/")), l.send() })) }, e.BaseAssetsUrl = yE.BaseAssetsUrl, e.SnippetUrl = a.SnippetUrl, e.CreateFromSnippetAsync = e.ParseFromSnippetAsync, e }(); o.AddParser(qi.NAME_PARTICLESYSTEM, (function (e, t, i, r) { var n = o.GetIndividualParser(qi.NAME_PARTICLESYSTEM); if (n && void 0 !== e.particleSystems && null !== e.particleSystems) for (var a = 0, s = e.particleSystems.length; a < s; a++) { var l = e.particleSystems[a]; i.particleSystems.push(n(l, t, r)) } })), o.AddIndividualParser(qi.NAME_PARTICLESYSTEM, (function (e, t, i) { return e.activeParticleCount ? vE.Parse(e, t, i) : gE.Parse(e, t, i) })), In.prototype.createEffectForParticles = function (e, t, i, r, n, o, a, s) { var l; void 0 === t && (t = []), void 0 === i && (i = []), void 0 === r && (r = ""); var c = [], u = [], h = []; return s ? s.fillUniformsAttributesAndSamplerNames(u, c, h) : (c = gE._GetAttributeNamesOrOptions(), u = gE._GetEffectCreationOptions()), -1 === r.indexOf(" BILLBOARD") && (r += "\n#define BILLBOARD\n"), (null == s ? void 0 : s.isAnimationSheetEnabled) && -1 === r.indexOf(" ANIMATESHEET") && (r += "\n#define ANIMATESHEET\n"), -1 === i.indexOf("diffuseSampler") && i.push("diffuseSampler"), this.createEffect({ vertex: null !== (l = null == s ? void 0 : s.vertexShaderName) && void 0 !== l ? l : "particles", fragmentElement: e }, c, u.concat(t), h.concat(i), r, n, o, a) }, Jn.prototype.getEmittedParticleSystems = function () { for (var e = new Array, t = 0; t < this.getScene().particleSystems.length; t++) { var i = this.getScene().particleSystems[t]; i.emitter === this && e.push(i) } return e }, Jn.prototype.getHierarchyEmittedParticleSystems = function () { var e = new Array, t = this.getDescendants(); t.push(this); for (var i = 0; i < this.getScene().particleSystems.length; i++) { var r = this.getScene().particleSystems[i], n = r.emitter; n.position && -1 !== t.indexOf(n) && e.push(r) } return e }; var TE, EE = function () { function e(e, t, i, r, n, o, a, s, l, c) { void 0 === l && (l = null), void 0 === c && (c = null), this.idx = 0, this.id = 0, this.color = new U(1, 1, 1, 1), this.position = R.Zero(), this.rotation = R.Zero(), this.scaling = R.One(), this.uvs = new C(0, 0, 1, 1), this.velocity = R.Zero(), this.pivot = R.Zero(), this.translateFromPivot = !1, this.alive = !0, this.isVisible = !0, this._pos = 0, this._ind = 0, this.shapeId = 0, this.idxInShape = 0, this._stillInvisible = !1, this._rotationMatrix = [1, 0, 0, 0, 1, 0, 0, 0, 1], this.parentId = null, this.materialIndex = null, this.props = null, this.cullingStrategy = Ln.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY, this._globalPosition = R.Zero(), this.idx = e, this.id = t, this._pos = i, this._ind = r, this._model = n, this.shapeId = o, this.idxInShape = a, this._sps = s, l && (this._modelBoundingInfo = l, this._boundingInfo = new mn(l.minimum, l.maximum)), null !== c && (this.materialIndex = c) } return e.prototype.getBoundingInfo = function () { return this._boundingInfo }, Object.defineProperty(e.prototype, "hasBoundingInfo", { get: function () { return null !== this._boundingInfo }, enumerable: !1, configurable: !0 }), e.prototype.copyToRef = function (e) { return e.position.copyFrom(this.position), e.rotation.copyFrom(this.rotation), this.rotationQuaternion && (e.rotationQuaternion ? e.rotationQuaternion.copyFrom(this.rotationQuaternion) : e.rotationQuaternion = this.rotationQuaternion.clone()), e.scaling.copyFrom(this.scaling), this.color && (e.color ? e.color.copyFrom(this.color) : e.color = this.color.clone()), e.uvs.copyFrom(this.uvs), e.velocity.copyFrom(this.velocity), e.pivot.copyFrom(this.pivot), e.translateFromPivot = this.translateFromPivot, e.alive = this.alive, e.isVisible = this.isVisible, e.parentId = this.parentId, e.cullingStrategy = this.cullingStrategy, null !== this.materialIndex && (e.materialIndex = this.materialIndex), this }, Object.defineProperty(e.prototype, "scale", { get: function () { return this.scaling }, set: function (e) { this.scaling = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "quaternion", { get: function () { return this.rotationQuaternion }, set: function (e) { this.rotationQuaternion = e }, enumerable: !1, configurable: !0 }), e.prototype.intersectsMesh = function (e) { return !(!this._boundingInfo || !e.hasBoundingInfo) && (this._sps._bSphereOnly ? hn.Intersects(this._boundingInfo.boundingSphere, e.getBoundingInfo().boundingSphere) : this._boundingInfo.intersects(e.getBoundingInfo(), !1)) }, e.prototype.isInFrustum = function (e) { return null !== this._boundingInfo && this._boundingInfo.isInFrustum(e, this.cullingStrategy) }, e.prototype.getRotationMatrix = function (e) { var t; if (this.rotationQuaternion) t = this.rotationQuaternion; else { t = O.Quaternion[0]; var i = this.rotation; P.RotationYawPitchRollToRef(i.y, i.x, i.z, t) } t.toRotationMatrix(e) }, e }(), SE = function () { function e(e, t, i, r, n, o, a, s, l) { this._indicesLength = 0, this.shapeId = e, this._shape = t, this._indices = i, this._indicesLength = i.length, this._shapeUV = o, this._shapeColors = n, this._normals = r, this._positionFunction = a, this._vertexFunction = s, this._material = l } return Object.defineProperty(e.prototype, "shapeID", { get: function () { return this.shapeId }, set: function (e) { this.shapeId = e }, enumerable: !1, configurable: !0 }), e }(), xE = function (e, t, i, r) { this.idx = 0, this.ind = 0, this.indicesLength = 0, this.sqDistance = 0, this.materialIndex = 0, this.idx = e, this.ind = t, this.indicesLength = i, this.materialIndex = r }, AE = function () { function e() { this.position = R.Zero(), this.color = new U(1, 1, 1, 1), this.uv = A.Zero() } return Object.defineProperty(e.prototype, "x", { get: function () { return this.position.x }, set: function (e) { this.position.x = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "y", { get: function () { return this.position.y }, set: function (e) { this.position.y = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "z", { get: function () { return this.position.z }, set: function (e) { this.position.z = e }, enumerable: !1, configurable: !0 }), e }(), RE = function () { function e(e, t, i) { this.particles = new Array, this.nbParticles = 0, this.billboard = !1, this.recomputeNormals = !1, this.counter = 0, this.vars = {}, this._bSphereOnly = !1, this._bSphereRadiusFactor = 1, this._positions = new Array, this._indices = new Array, this._normals = new Array, this._colors = new Array, this._uvs = new Array, this._index = 0, this._updatable = !0, this._pickable = !1, this._isVisibilityBoxLocked = !1, this._alwaysVisible = !1, this._depthSort = !1, this._expandable = !1, this._shapeCounter = 0, this._copy = new EE(0, 0, 0, 0, null, 0, 0, this), this._color = new U(0, 0, 0, 0), this._computeParticleColor = !0, this._computeParticleTexture = !0, this._computeParticleRotation = !0, this._computeParticleVertex = !1, this._computeBoundingBox = !1, this._autoFixFaceOrientation = !1, this._depthSortParticles = !0, this._mustUnrotateFixedNormals = !1, this._particlesIntersect = !1, this._needs32Bits = !1, this._isNotBuilt = !0, this._lastParticleId = 0, this._idxOfId = [], this._multimaterialEnabled = !1, this._useModelMaterial = !1, this._depthSortFunction = function (e, t) { return t.sqDistance - e.sqDistance }, this._materialSortFunction = function (e, t) { return e.materialIndex - t.materialIndex }, this._autoUpdateSubMeshes = !1, this._recomputeInvisibles = !1, this.name = e, this._scene = t || S.LastCreatedScene, this._camera = t.activeCamera, this._pickable = !!i && i.isPickable, this._depthSort = !!i && i.enableDepthSort, this._multimaterialEnabled = !!i && i.enableMultiMaterial, this._useModelMaterial = !!i && i.useModelMaterial, this._multimaterialEnabled = !!this._useModelMaterial || this._multimaterialEnabled, this._expandable = !!i && i.expandable, this._particlesIntersect = !!i && i.particleIntersection, this._bSphereOnly = !!i && i.boundingSphereOnly, this._bSphereRadiusFactor = i && i.bSphereRadiusFactor ? i.bSphereRadiusFactor : 1, this._computeBoundingBox = !!(null == i ? void 0 : i.computeBoundingBox) && i.computeBoundingBox, this._autoFixFaceOrientation = !!(null == i ? void 0 : i.autoFixFaceOrientation) && i.autoFixFaceOrientation, i && void 0 !== i.updatable ? this._updatable = i.updatable : this._updatable = !0, this._pickable && (this.pickedBySubMesh = [[]], this.pickedParticles = this.pickedBySubMesh[0]), (this._depthSort || this._multimaterialEnabled) && (this.depthSortedParticles = []), this._multimaterialEnabled && (this._multimaterial = new Xn(this.name + "MultiMaterial", this._scene), this._materials = [], this._materialIndexesById = {}), this._tmpVertex = new AE } return e.prototype.buildMesh = function () { if (!this._isNotBuilt && this.mesh) return this.mesh; if (0 === this.nbParticles && !this.mesh) { var e = Iu("", { radius: 1, tessellation: 3 }, this._scene); this.addShape(e, 1), e.dispose() } if (this._indices32 = this._needs32Bits ? new Uint32Array(this._indices) : new Uint16Array(this._indices), this._positions32 = new Float32Array(this._positions), this._uvs32 = new Float32Array(this._uvs), this._colors32 = new Float32Array(this._colors), !this.mesh) { var t = new Jn(this.name, this._scene); this.mesh = t } !this._updatable && this._multimaterialEnabled && this._sortParticlesByMaterial(), this.recomputeNormals && En.ComputeNormals(this._positions32, this._indices32, this._normals), this._normals32 = new Float32Array(this._normals), this._fixedNormal32 = new Float32Array(this._normals), this._mustUnrotateFixedNormals && this._unrotateFixedNormals(); var i = new En; if (i.indices = this._depthSort ? this._indices : this._indices32, i.set(this._positions32, Hi.PositionKind), i.set(this._normals32, Hi.NormalKind), this._uvs32.length > 0 && i.set(this._uvs32, Hi.UVKind), this._colors32.length > 0 && i.set(this._colors32, Hi.ColorKind), i.applyToMesh(this.mesh, this._updatable), this.mesh.isPickable = this._pickable, this._pickable) for (var r = 0, n = 0; n < this.nbParticles; n++)for (var o = this.particles[n], a = o._model._indicesLength, s = 0; s < a; s++)if (0 == s % 3) { var l = { idx: o.idx, faceId: r }; this.pickedParticles[r] = l, r++ } return this._multimaterialEnabled && this.setMultiMaterial(this._materials), this._expandable || (this._depthSort || this._multimaterialEnabled || this._autoFixFaceOrientation || (this._indices = null), this._positions = null, this._normals = null, this._uvs = null, this._colors = null, this._updatable || (this.particles.length = 0)), this._isNotBuilt = !1, this.recomputeNormals = !1, this._recomputeInvisibles = !0, this.mesh }, e.prototype.digest = function (e, t) { var i = t && t.facetNb || 1, r = t && t.number || 0, n = t && t.delta || 0, o = e.getVerticesData(Hi.PositionKind), a = e.getIndices(), s = e.getVerticesData(Hi.UVKind), l = e.getVerticesData(Hi.ColorKind), c = e.getVerticesData(Hi.NormalKind), u = t && t.storage ? t.storage : null, h = 0, d = a.length / 3; r ? (r = r > d ? d : r, i = Math.round(d / r), n = 0) : i = i > d ? d : i; for (var p = [], f = [], _ = [], m = [], g = [], v = R.Zero(), y = i; h < d;) { h > d - (i = y + Math.floor((1 + n) * Math.random())) && (i = d - h), p.length = 0, f.length = 0, _.length = 0, m.length = 0, g.length = 0; for (var b = 0, T = 3 * h; T < 3 * (h + i); T++) { _.push(b); var E = a[T], S = 3 * E; if (p.push(o[S], o[S + 1], o[S + 2]), f.push(c[S], c[S + 1], c[S + 2]), s) { var x = 2 * E; m.push(s[x], s[x + 1]) } if (l) { var A = 4 * E; g.push(l[A], l[A + 1], l[A + 2], l[A + 3]) } b++ } var C = this.nbParticles, P = this._posToShape(p), I = this._uvsToShapeUV(m), M = _.slice(), O = g.slice(), D = f.slice(); v.copyFromFloats(0, 0, 0); var N = void 0; for (N = 0; N < P.length; N++)v.addInPlace(P[N]); v.scaleInPlace(1 / P.length); var F = new R(1 / 0, 1 / 0, 1 / 0), L = new R(-1 / 0, -1 / 0, -1 / 0); for (N = 0; N < P.length; N++)P[N].subtractInPlace(v), F.minimizeInPlaceFromFloats(P[N].x, P[N].y, P[N].z), L.maximizeInPlaceFromFloats(P[N].x, P[N].y, P[N].z); var w = void 0; this._particlesIntersect && (w = new mn(F, L)); var B = null; this._useModelMaterial && (B = e.material ? e.material : this._setDefaultMaterial()); var U = new SE(this._shapeCounter, P, M, D, O, I, null, null, B), V = this._positions.length, k = this._indices.length; this._meshBuilder(this._index, k, P, this._positions, M, this._indices, m, this._uvs, O, this._colors, D, this._normals, C, 0, null, U), this._addParticle(C, this._lastParticleId, V, k, U, this._shapeCounter, 0, w, u), this.particles[this.nbParticles].position.addInPlace(v), u || (this._index += P.length, C++, this.nbParticles++, this._lastParticleId++), this._shapeCounter++, h += i } return this._isNotBuilt = !0, this }, e.prototype._unrotateFixedNormals = function () { for (var e = 0, t = 0, i = O.Vector3[0], r = O.Quaternion[0], n = O.Matrix[0], o = 0; o < this.particles.length; o++) { var a = this.particles[o], s = a._model._shape; if (a.rotationQuaternion) a.rotationQuaternion.conjugateToRef(r); else { var l = a.rotation; P.RotationYawPitchRollToRef(l.y, l.x, l.z, r), r.conjugateInPlace() } r.toRotationMatrix(n); for (var c = 0; c < s.length; c++)t = e + 3 * c, R.TransformNormalFromFloatsToRef(this._normals32[t], this._normals32[t + 1], this._normals32[t + 2], n, i), i.toArray(this._fixedNormal32, t); e = t + 3 } }, e.prototype._resetCopy = function () { var e = this._copy; e.position.setAll(0), e.rotation.setAll(0), e.rotationQuaternion = null, e.scaling.setAll(1), e.uvs.copyFromFloats(0, 0, 1, 1), e.color = null, e.translateFromPivot = !1, e.shapeId = 0, e.materialIndex = null }, e.prototype._meshBuilder = function (e, t, i, r, n, o, a, s, l, c, u, h, d, p, f, _) { var m, g = 0, v = 0, y = 0; this._resetCopy(); var b = this._copy, T = !(!f || !f.storage); if (b.idx = d, b.idxInShape = p, b.shapeId = _.shapeId, this._useModelMaterial) { var E = _._material.uniqueId, S = this._materialIndexesById; Object.prototype.hasOwnProperty.call(S, E) || (S[E] = this._materials.length, this._materials.push(_._material)); var x = S[E]; b.materialIndex = x } if (f && f.positionFunction && (f.positionFunction(b, d, p), this._mustUnrotateFixedNormals = !0), T) return b; var A = O.Matrix[0], C = this._tmpVertex, P = C.position, M = C.color, D = C.uv, N = O.Vector3[1], F = O.Vector3[2], L = O.Vector3[3]; I.IdentityToRef(A), b.getRotationMatrix(A), b.pivot.multiplyToRef(b.scaling, L), b.translateFromPivot ? F.setAll(0) : F.copyFrom(L); var w = f && f.vertexFunction; for (m = 0; m < i.length; m++) { if (P.copyFrom(i[m]), b.color && M.copyFrom(b.color), a && D.copyFromFloats(a[g], a[g + 1]), w && f.vertexFunction(b, C, m), P.multiplyInPlace(b.scaling).subtractInPlace(L), R.TransformCoordinatesToRef(P, A, N), N.addInPlace(F).addInPlace(b.position), r.push(N.x, N.y, N.z), a) { var B = b.uvs; s.push((B.z - B.x) * D.x + B.x, (B.w - B.y) * D.y + B.y), g += 2 } if (b.color) this._color.copyFrom(M); else { var U = this._color; l && void 0 !== l[v] ? (U.r = l[v], U.g = l[v + 1], U.b = l[v + 2], U.a = l[v + 3]) : (U.r = 1, U.g = 1, U.b = 1, U.a = 1) } c.push(this._color.r, this._color.g, this._color.b, this._color.a), v += 4, !this.recomputeNormals && u && (R.TransformNormalFromFloatsToRef(u[y], u[y + 1], u[y + 2], A, P), h.push(P.x, P.y, P.z), y += 3) } for (m = 0; m < n.length; m++) { var V = e + n[m]; o.push(V), V > 65535 && (this._needs32Bits = !0) } if (this._depthSort || this._multimaterialEnabled) { var k = null !== b.materialIndex ? b.materialIndex : 0; this.depthSortedParticles.push(new xE(d, t, n.length, k)) } return b }, e.prototype._posToShape = function (e) { for (var t = [], i = 0; i < e.length; i += 3)t.push(R.FromArray(e, i)); return t }, e.prototype._uvsToShapeUV = function (e) { var t = []; if (e) for (var i = 0; i < e.length; i++)t.push(e[i]); return t }, e.prototype._addParticle = function (e, t, i, r, n, o, a, s, l) { void 0 === s && (s = null), void 0 === l && (l = null); var c = new EE(e, t, i, r, n, o, a, this, s); return (l || this.particles).push(c), c }, e.prototype.addShape = function (e, t, i) { var r = e.getVerticesData(Hi.PositionKind), n = e.getIndices(), o = e.getVerticesData(Hi.UVKind), a = e.getVerticesData(Hi.ColorKind), s = e.getVerticesData(Hi.NormalKind); this.recomputeNormals = !s; var l = Array.from(n), c = Array.from(s), u = a ? Array.from(a) : [], h = i && i.storage ? i.storage : null, d = null; this._particlesIntersect && (d = e.getBoundingInfo()); var p = this._posToShape(r), f = this._uvsToShapeUV(o), _ = i ? i.positionFunction : null, m = i ? i.vertexFunction : null, g = null; this._useModelMaterial && (g = e.material ? e.material : this._setDefaultMaterial()); for (var v = new SE(this._shapeCounter, p, l, c, u, f, _, m, g), y = 0; y < t; y++)this._insertNewParticle(this.nbParticles, y, v, p, n, o, a, s, d, h, i); return this._shapeCounter++, this._isNotBuilt = !0, this._shapeCounter - 1 }, e.prototype._rebuildParticle = function (e, t) { void 0 === t && (t = !1), this._resetCopy(); var i = this._copy; e._model._positionFunction && e._model._positionFunction(i, e.idx, e.idxInShape); var r = O.Matrix[0], n = O.Vector3[0], o = O.Vector3[1], a = O.Vector3[2], s = O.Vector3[3]; i.getRotationMatrix(r), e.pivot.multiplyToRef(e.scaling, s), i.translateFromPivot ? a.copyFromFloats(0, 0, 0) : a.copyFrom(s); for (var l = e._model._shape, c = 0; c < l.length; c++)n.copyFrom(l[c]), e._model._vertexFunction && e._model._vertexFunction(i, n, c), n.multiplyInPlace(i.scaling).subtractInPlace(s), R.TransformCoordinatesToRef(n, r, o), o.addInPlace(a).addInPlace(i.position).toArray(this._positions32, e._pos + 3 * c); t && (e.position.setAll(0), e.rotation.setAll(0), e.rotationQuaternion = null, e.scaling.setAll(1), e.uvs.setAll(0), e.pivot.setAll(0), e.translateFromPivot = !1, e.parentId = null) }, e.prototype.rebuildMesh = function (e) { void 0 === e && (e = !1); for (var t = 0; t < this.particles.length; t++)this._rebuildParticle(this.particles[t], e); return this.mesh.updateVerticesData(Hi.PositionKind, this._positions32, !1, !1), this }, e.prototype.removeParticles = function (e, t) { var i = t - e + 1; if (!this._expandable || i <= 0 || i >= this.nbParticles || !this._updatable) return []; var r = this.particles, n = this.nbParticles; if (t < n - 1) for (var o = t + 1, a = r[o]._pos - r[e]._pos, s = r[o]._ind - r[e]._ind, l = o; l < n; l++) { var c = r[l]; c._pos -= a, c._ind -= s } var u = r.splice(e, i); this._positions.length = 0, this._indices.length = 0, this._colors.length = 0, this._uvs.length = 0, this._normals.length = 0, this._index = 0, this._idxOfId.length = 0, (this._depthSort || this._multimaterialEnabled) && (this.depthSortedParticles = []); for (var h = 0, d = r.length, p = 0; p < d; p++) { var f = r[p], _ = f._model, m = _._shape, g = _._indices, v = _._normals, y = _._shapeColors, b = _._shapeUV; f.idx = p, this._idxOfId[f.id] = p, this._meshBuilder(this._index, h, m, this._positions, g, this._indices, b, this._uvs, y, this._colors, v, this._normals, f.idx, f.idxInShape, null, _), this._index += m.length, h += g.length } return this.nbParticles -= i, this._isNotBuilt = !0, u }, e.prototype.insertParticlesFromArray = function (e) { if (!this._expandable) return this; for (var t = 0, i = e[0].shapeId, r = e.length, n = 0; n < r; n++) { var o = e[n], a = o._model, s = a._shape, l = a._indices, c = a._shapeUV, u = a._shapeColors, h = a._normals, d = !h; this.recomputeNormals = d || this.recomputeNormals; var p = o.getBoundingInfo(), f = this._insertNewParticle(this.nbParticles, t, a, s, l, c, u, h, p, null, null); o.copyToRef(f), t++, i != o.shapeId && (i = o.shapeId, t = 0) } return this._isNotBuilt = !0, this }, e.prototype._insertNewParticle = function (e, t, i, r, n, o, a, s, l, c, u) { var h = this._positions.length, d = this._indices.length, p = this._meshBuilder(this._index, d, r, this._positions, n, this._indices, o, this._uvs, a, this._colors, s, this._normals, e, t, u, i), f = null; return this._updatable && ((f = this._addParticle(this.nbParticles, this._lastParticleId, h, d, i, this._shapeCounter, t, l, c)).position.copyFrom(p.position), f.rotation.copyFrom(p.rotation), p.rotationQuaternion && (f.rotationQuaternion ? f.rotationQuaternion.copyFrom(p.rotationQuaternion) : f.rotationQuaternion = p.rotationQuaternion.clone()), p.color && (f.color ? f.color.copyFrom(p.color) : f.color = p.color.clone()), f.scaling.copyFrom(p.scaling), f.uvs.copyFrom(p.uvs), null !== p.materialIndex && (f.materialIndex = p.materialIndex), this.expandable && (this._idxOfId[f.id] = f.idx)), c || (this._index += r.length, this.nbParticles++, this._lastParticleId++), f }, e.prototype.setParticles = function (e, t, i) { if (void 0 === e && (e = 0), void 0 === t && (t = this.nbParticles - 1), void 0 === i && (i = !0), !this._updatable || this._isNotBuilt) return this; this.beforeUpdateParticles(e, t, i); var r = O.Matrix[0], n = O.Matrix[1], o = this.mesh, a = this._colors32, s = this._positions32, l = this._normals32, c = this._uvs32, u = this._indices32, h = this._indices, d = this._fixedNormal32, p = this._depthSort && this._depthSortParticles, f = O.Vector3, _ = f[5].copyFromFloats(1, 0, 0), m = f[6].copyFromFloats(0, 1, 0), g = f[7].copyFromFloats(0, 0, 1), v = f[8].setAll(Number.MAX_VALUE), y = f[9].setAll(-Number.MAX_VALUE), b = f[10].setAll(0), T = this._tmpVertex, E = T.position, S = T.color, x = T.uv; if ((this.billboard || this._depthSort) && (this.mesh.computeWorldMatrix(!0), this.mesh._worldMatrix.invertToRef(n)), this.billboard) { var A = f[0]; this._camera.getDirectionToRef(Ar.Z, A), R.TransformNormalToRef(A, n, g), g.normalize(); var C = this._camera.getViewMatrix(!0); R.TransformNormalFromFloatsToRef(C.m[1], C.m[5], C.m[9], n, m), R.CrossToRef(m, g, _), m.normalize(), _.normalize() } this._depthSort && R.TransformCoordinatesToRef(this._camera.globalPosition, n, b), I.IdentityToRef(r); var P = 0, M = 0, D = 0, N = 0, F = 0, L = 0, w = 0; if (this.mesh.isFacetDataEnabled && (this._computeBoundingBox = !0), t = 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; w < G.length; w++) { P = M + 3 * w, D = N + 4 * w, F = L + 2 * w; var ne = 2 * w, oe = ne + 1; E.copyFrom(G[w]), this._computeParticleColor && k.color && S.copyFrom(k.color), this._computeParticleTexture && x.copyFromFloats(z[ne], z[oe]), this._computeParticleVertex && this.updateParticleVertex(k, T, w); var ae = E.x * j.x - Q.x, se = E.y * j.y - Q.y, le = E.z * j.z - Q.z; ee = ae * W[0] + se * W[3] + le * W[6], $ = ae * W[1] + se * W[4] + le * W[7], te = ae * W[2] + se * W[5] + le * W[8], ee += re.x, $ += re.y, te += re.z; var ce = s[P] = Y.x + _.x * ee + m.x * $ + g.x * te, ue = s[P + 1] = Y.y + _.y * ee + m.y * $ + g.y * te, he = s[P + 2] = Y.z + _.z * ee + m.z * $ + g.z * te; if (this._computeBoundingBox && (v.minimizeInPlaceFromFloats(ce, ue, he), y.maximizeInPlaceFromFloats(ce, ue, he)), !this._computeParticleVertex) { var de = d[P], pe = d[P + 1], fe = d[P + 2], _e = de * W[0] + pe * W[3] + fe * W[6], me = de * W[1] + pe * W[4] + fe * W[7], ge = de * W[2] + pe * W[5] + fe * W[8]; l[P] = _.x * _e + m.x * me + g.x * ge, l[P + 1] = _.y * _e + m.y * me + g.y * ge, l[P + 2] = _.z * _e + m.z * me + g.z * ge } if (this._computeParticleColor && k.color) { var ve = this._colors32; ve[D] = S.r, ve[D + 1] = S.g, ve[D + 2] = S.b, ve[D + 3] = S.a } if (this._computeParticleTexture) { var ye = k.uvs; c[F] = x.x * (ye.z - ye.x) + ye.x, c[F + 1] = x.y * (ye.w - ye.y) + ye.y } } } else for (k._stillInvisible = !0, w = 0; w < G.length; w++) { if (D = N + 4 * w, F = L + 2 * w, s[P = M + 3 * w] = s[P + 1] = s[P + 2] = 0, l[P] = l[P + 1] = l[P + 2] = 0, this._computeParticleColor && k.color) { var be = k.color; a[D] = be.r, a[D + 1] = be.g, a[D + 2] = be.b, a[D + 3] = be.a } this._computeParticleTexture && (ye = k.uvs, c[F] = z[2 * w] * (ye.z - ye.x) + ye.x, c[F + 1] = z[2 * w + 1] * (ye.w - ye.y) + ye.y) } if (this._particlesIntersect) { var Te = k.getBoundingInfo(), Ee = Te.boundingBox, Se = Te.boundingSphere, xe = k._modelBoundingInfo; if (!this._bSphereOnly) { var Ae = xe.boundingBox.vectors, Re = f[1], Ce = f[2]; Re.setAll(Number.MAX_VALUE), Ce.setAll(-Number.MAX_VALUE); for (var Pe = 0; Pe < 8; Pe++) { var Ie = Ae[Pe].x * j.x, Me = Ae[Pe].y * j.y, Oe = Ae[Pe].z * j.z, De = (ee = Ie * W[0] + Me * W[3] + Oe * W[6], $ = Ie * W[1] + Me * W[4] + Oe * W[7], te = Ie * W[2] + Me * W[5] + Oe * W[8], H.x + _.x * ee + m.x * $ + g.x * te), Ne = H.y + _.y * ee + m.y * $ + g.y * te, Fe = H.z + _.z * ee + m.z * $ + g.z * te; Re.minimizeInPlaceFromFloats(De, Ne, Fe), Ce.maximizeInPlaceFromFloats(De, Ne, Fe) } Ee.reConstruct(Re, Ce, o._worldMatrix) } var Le = xe.minimum.multiplyToRef(j, f[1]), we = xe.maximum.multiplyToRef(j, f[2]), Be = we.addToRef(Le, f[3]).scaleInPlace(.5).addInPlace(Y), Ue = we.subtractToRef(Le, f[4]).scaleInPlace(.5 * this._bSphereRadiusFactor), Ve = Be.subtractToRef(Ue, f[1]), ke = Be.addToRef(Ue, f[2]); Se.reConstruct(Ve, ke, o._worldMatrix) } M = P + 3, N = D + 4, L = F + 2 } else M += 3 * (w = G.length), N += 4 * w, L += 2 * w } if (i) { this._computeParticleColor && ((He = o.getVertexBuffer(Hi.ColorKind)) && !o.isPickable ? He.updateDirectly(a, 0) : o.updateVerticesData(Hi.ColorKind, a, !1, !1)), this._computeParticleTexture && ((He = o.getVertexBuffer(Hi.UVKind)) && !o.isPickable ? He.updateDirectly(c, 0) : o.updateVerticesData(Hi.UVKind, c, !1, !1)); var Ge = o.getVertexBuffer(Hi.PositionKind); if (Ge && !o.isPickable ? Ge.updateDirectly(s, 0) : o.updateVerticesData(Hi.PositionKind, s, !1, !1), !o.areNormalsFrozen || o.isFacetDataEnabled) { if (this._computeParticleVertex || o.isFacetDataEnabled) { var ze = o.isFacetDataEnabled ? o.getFacetDataParameters() : null; En.ComputeNormals(s, u, l, ze); for (var We = 0; We < l.length; We++)d[We] = l[We] } var He; o.areNormalsFrozen || ((He = o.getVertexBuffer(Hi.NormalKind)) && !o.isPickable ? He.updateDirectly(l, 0) : o.updateVerticesData(Hi.NormalKind, l, !1, !1)) } if (p) { var Xe = this.depthSortedParticles; Xe.sort(this._depthSortFunction); for (var je = Xe.length, Ye = 0, Ke = 0, Qe = 0; Qe < je; Qe++) { var qe = Xe[Qe], Ze = qe.indicesLength, Je = qe.ind; for (We = 0; We < Ze; We++)if (u[Ye] = h[Je + We], Ye++, this._pickable && 0 == We % 3) { var $e = this.pickedParticles[Ke]; $e.idx = qe.idx, $e.faceId = Ke, Ke++ } } } if (this._autoFixFaceOrientation) for (var et = 0, tt = 0; tt < this.particles.length; tt++) { if ((k = p ? this.particles[this.depthSortedParticles[tt].idx] : this.particles[tt]).scale.x * k.scale.y * k.scale.z < 0) for (var it = 0; it < k._model._indicesLength; it += 3) { var rt = h[k._ind + it]; u[et + it] = h[k._ind + it + 1], u[et + it + 1] = rt } et += k._model._indicesLength } (p || this._autoFixFaceOrientation) && o.updateIndices(u) } return this._computeBoundingBox && (o.hasBoundingInfo ? o.getBoundingInfo().reConstruct(v, y, o._worldMatrix) : o.buildBoundingInfo(v, y, o._worldMatrix)), this._autoUpdateSubMeshes && this.computeSubMeshes(), this._recomputeInvisibles = !1, this.afterUpdateParticles(e, t, i), this }, e.prototype.dispose = function () { this.mesh.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._normals32 = null, this._fixedNormal32 = null, this._uvs32 = null, this._colors32 = null, this.pickedParticles = null, this.pickedBySubMesh = null, this._materials = null, this._materialIndexes = null, this._indicesByMaterial = null, this._idxOfId = null }, e.prototype.pickedParticle = function (e) { if (e.hit) { var t = e.subMeshId, i = e.faceId - this.mesh.subMeshes[t].indexStart / 3, r = this.pickedBySubMesh; if (r[t] && r[t][i]) return r[t][i] } return null }, e.prototype.getParticleById = function (e) { var t = this.particles[e]; if (t && t.id == e) return t; var i = this.particles, r = this._idxOfId[e]; if (void 0 !== r) return i[r]; for (var n = 0, o = this.nbParticles; n < o;) { var a = i[n]; if (a.id == e) return a; n++ } return null }, e.prototype.getParticlesByShapeId = function (e) { var t = []; return this.getParticlesByShapeIdToRef(e, t), t }, e.prototype.getParticlesByShapeIdToRef = function (e, t) { t.length = 0; for (var i = 0; i < this.nbParticles; i++) { var r = this.particles[i]; r.shapeId == e && t.push(r) } return this }, e.prototype.computeSubMeshes = function () { if (!this.mesh || !this._multimaterialEnabled) return this; var e = this.depthSortedParticles; if (this.particles.length > 0) for (var t = 0; t < this.particles.length; t++) { var i = this.particles[t]; i.materialIndex || (i.materialIndex = 0); var r = e[t]; r.materialIndex = i.materialIndex, r.ind = i._ind, r.indicesLength = i._model._indicesLength, r.idx = i.idx } this._sortParticlesByMaterial(); var n = this._indicesByMaterial, o = this._materialIndexes, a = this.mesh; a.subMeshes = []; for (var s = a.getTotalVertices(), l = 0; l < o.length; l++) { var c = n[l], u = n[l + 1] - c, h = o[l]; new bn(h, 0, s, c, u, a) } return this }, e.prototype._sortParticlesByMaterial = function () { var e = [0]; this._indicesByMaterial = e; var t = []; this._materialIndexes = t; var i = this.depthSortedParticles; i.sort(this._materialSortFunction); var r = i.length, n = this._indices32, o = this._indices, a = 0, s = 0, l = 0, c = i[0].materialIndex; t.push(c), this._pickable && (this.pickedBySubMesh = [[]], this.pickedParticles = this.pickedBySubMesh[0]); for (var u = 0; u < r; u++) { var h = i[u], d = h.indicesLength, p = h.ind; h.materialIndex !== c && (c = h.materialIndex, e.push(l), t.push(c), this._pickable && (a++, this.pickedBySubMesh[a] = [], s = 0)); for (var f = 0, _ = 0; _ < d; _++) { if (n[l] = o[p + _], this._pickable && 0 == _ % 3) { var m = this.pickedBySubMesh[a][s]; m ? (m.idx = h.idx, m.faceId = f) : this.pickedBySubMesh[a][s] = { idx: h.idx, faceId: f }, s++, f++ } l++ } } return e.push(n.length), this._updatable && this.mesh.updateIndices(n), this }, e.prototype._setMaterialIndexesById = function () { this._materialIndexesById = {}; for (var e = 0; e < this._materials.length; e++) { var t = this._materials[e].uniqueId; this._materialIndexesById[t] = e } }, e.prototype._filterUniqueMaterialId = function (e) { return e.filter((function (e, t, i) { return i.indexOf(e) === t })) }, e.prototype._setDefaultMaterial = function () { return this._defaultMaterial || (this._defaultMaterial = new mc(this.name + "DefaultMaterial", this._scene)), this._defaultMaterial }, e.prototype.refreshVisibleSize = function () { return this._isVisibilityBoxLocked || this.mesh.refreshBoundingInfo(), this }, e.prototype.setVisibilityBox = function (e) { 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._alwaysVisible = e, this.mesh.alwaysSelectAsActiveMesh = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isVisibilityBoxLocked", { get: function () { return this._isVisibilityBoxLocked }, set: function (e) { this._isVisibilityBoxLocked = e, this.mesh.getBoundingInfo().isLocked = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "computeParticleRotation", { get: function () { return this._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, "computeParticleVertex", { get: function () { return this._computeParticleVertex }, set: function (e) { this._computeParticleVertex = 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 }), Object.defineProperty(e.prototype, "depthSortParticles", { get: function () { return this._depthSortParticles }, set: function (e) { this._depthSortParticles = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "expandable", { get: function () { return this._expandable }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "multimaterialEnabled", { get: function () { return this._multimaterialEnabled }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "useModelMaterial", { get: function () { return this._useModelMaterial }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "materials", { get: function () { return this._materials }, enumerable: !1, configurable: !0 }), e.prototype.setMultiMaterial = function (e) { this._materials = this._filterUniqueMaterialId(e), this._setMaterialIndexesById(), this._multimaterial && this._multimaterial.dispose(), this._multimaterial = new Xn(this.name + "MultiMaterial", this._scene); for (var t = 0; t < this._materials.length; t++)this._multimaterial.subMaterials.push(this._materials[t]); this.computeSubMeshes(), this.mesh.material = this._multimaterial }, Object.defineProperty(e.prototype, "multimaterial", { get: function () { return this._multimaterial }, set: function (e) { this._multimaterial = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "autoUpdateSubMeshes", { get: function () { return this._autoUpdateSubMeshes }, set: function (e) { this._autoUpdateSubMeshes = 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.updateParticleVertex = function (e, t, i) { return this }, e.prototype.beforeUpdateParticles = function (e, t, i) { }, e.prototype.afterUpdateParticles = function (e, t, i) { }, e }(), CE = function () { function e(e, t, i, r, n) { this.idx = 0, this.color = new U(1, 1, 1, 1), this.position = R.Zero(), this.rotation = R.Zero(), this.uv = new A(0, 0), this.velocity = R.Zero(), this.pivot = R.Zero(), this.translateFromPivot = !1, this._pos = 0, this._ind = 0, this.groupId = 0, this.idxInGroup = 0, this._stillInvisible = !1, this._rotationMatrix = [1, 0, 0, 0, 1, 0, 0, 0, 1], this.parentId = null, this._globalPosition = R.Zero(), this.idx = e, this._group = t, this.groupId = i, this.idxInGroup = r, this._pcs = n } return Object.defineProperty(e.prototype, "size", { get: function () { return this.size }, set: function (e) { this.size = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "quaternion", { get: function () { return this.rotationQuaternion }, set: function (e) { this.rotationQuaternion = e }, enumerable: !1, configurable: !0 }), e.prototype.intersectsMesh = function (e, t) { if (!e.hasBoundingInfo) return !1; if (!this._pcs.mesh) throw new Error("Point Cloud System doesnt contain the Mesh"); if (t) return e.getBoundingInfo().boundingSphere.intersectsPoint(this.position.add(this._pcs.mesh.position)); var i = e.getBoundingInfo().boundingBox, r = i.maximumWorld.x, n = i.minimumWorld.x, o = i.maximumWorld.y, a = i.minimumWorld.y, s = i.maximumWorld.z, l = i.minimumWorld.z, c = this.position.x + this._pcs.mesh.position.x, u = this.position.y + this._pcs.mesh.position.y, h = this.position.z + this._pcs.mesh.position.z; return n <= c && c <= r && a <= u && u <= o && l <= h && h <= s }, e.prototype.getRotationMatrix = function (e) { var t; if (this.rotationQuaternion) t = this.rotationQuaternion; else { t = O.Quaternion[0]; var i = this.rotation; P.RotationYawPitchRollToRef(i.y, i.x, i.z, t) } t.toRotationMatrix(e) }, e }(), PE = function () { function e(e, t) { this.groupId = e, this._positionFunction = t } return Object.defineProperty(e.prototype, "groupID", { get: function () { return this.groupId }, set: function (e) { this.groupId = e }, enumerable: !1, configurable: !0 }), e }(); !function (e) { e[e.Color = 2] = "Color", e[e.UV = 1] = "UV", e[e.Random = 0] = "Random", e[e.Stated = 3] = "Stated" }(TE || (TE = {})); var IE = function () { function e(e, t, i, r) { this.particles = new Array, this.nbParticles = 0, this.counter = 0, this.vars = {}, this._promises = [], this._positions = new Array, this._indices = new Array, this._normals = new Array, this._colors = new Array, this._uvs = new Array, this._updatable = !0, this._isVisibilityBoxLocked = !1, this._alwaysVisible = !1, this._groups = new Array, this._groupCounter = 0, this._computeParticleColor = !0, this._computeParticleTexture = !0, this._computeParticleRotation = !0, this._computeBoundingBox = !1, this._isReady = !1, this.name = e, this._size = t, this._scene = i || S.LastCreatedScene, r && void 0 !== r.updatable ? this._updatable = r.updatable : this._updatable = !0 } return Object.defineProperty(e.prototype, "positions", { get: function () { return this._positions32 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "colors", { get: function () { return this._colors32 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "uvs", { get: function () { return this._uvs32 }, enumerable: !1, configurable: !0 }), e.prototype.buildMeshAsync = function (e) { var t = this; return Promise.all(this._promises).then((function () { return t._isReady = !0, t._buildMesh(e) })) }, e.prototype._buildMesh = function (e) { 0 === this.nbParticles && this.addPoints(1), this._positions32 = new Float32Array(this._positions), this._uvs32 = new Float32Array(this._uvs), this._colors32 = new Float32Array(this._colors); var t = new En; t.set(this._positions32, Hi.PositionKind), this._uvs32.length > 0 && t.set(this._uvs32, Hi.UVKind); var i = 0; this._colors32.length > 0 && (i = 1, t.set(this._colors32, Hi.ColorKind)); var r = new Jn(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 mc("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 CE(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) { i && e.updateFacetData(); var s = 2 * e.getBoundingInfo().boundingSphere.radius, l = e.getVerticesData(Hi.PositionKind), c = e.getIndices(), u = e.getVerticesData(Hi.UVKind), d = e.getVerticesData(Hi.ColorKind), p = R.Zero(); e.computeWorldMatrix(); var f = e.getWorldMatrix(); if (!f.isIdentity()) { l = l.slice(0); for (var _ = 0; _ < l.length / 3; _++)R.TransformCoordinatesFromFloatsToRef(l[3 * _], l[3 * _ + 1], l[3 * _ + 2], f, p), l[3 * _] = p.x, l[3 * _ + 1] = p.y, l[3 * _ + 2] = p.z } var m, g, v = 0, y = 0, b = 0, T = 0, E = 0, S = 0, x = 0, P = 0, I = 0, M = 0, O = 0, D = 0, N = 0, F = R.Zero(), L = R.Zero(), w = R.Zero(), V = R.Zero(), k = R.Zero(), G = 0, z = 0, W = 0, H = 0, X = 0, j = 0, Y = A.Zero(), K = A.Zero(), Q = A.Zero(), q = A.Zero(), Z = A.Zero(), J = 0, $ = 0, ee = 0, te = 0, ie = 0, re = 0, ne = 0, oe = 0, ae = 0, se = 0, le = 0, ce = 0, ue = C.Zero(), he = C.Zero(), de = C.Zero(), pe = C.Zero(), fe = C.Zero(), _e = 0, me = 0; a = a || 0; for (var ge, ve = new C(0, 0, 0, 0), ye = R.Zero(), be = R.Zero(), Te = R.Zero(), Ee = 0, Se = R.Zero(), xe = 0, Ae = 0, Re = new Mo(R.Zero(), new R(1, 0, 0)), Ce = R.Zero(), Pe = 0; Pe < c.length / 3; Pe++) { y = c[3 * Pe], b = c[3 * Pe + 1], T = c[3 * Pe + 2], E = l[3 * y], S = l[3 * y + 1], x = l[3 * y + 2], P = l[3 * b], I = l[3 * b + 1], M = l[3 * b + 2], O = l[3 * T], D = l[3 * T + 1], N = l[3 * T + 2], F.set(E, S, x), L.set(P, I, M), w.set(O, D, N), L.subtractToRef(F, V), w.subtractToRef(L, k), u && (G = u[2 * y], z = u[2 * y + 1], W = u[2 * b], H = u[2 * b + 1], X = u[2 * T], j = u[2 * T + 1], Y.set(G, z), K.set(W, H), Q.set(X, j), K.subtractToRef(Y, q), Q.subtractToRef(K, Z)), d && r && (J = d[4 * y], $ = d[4 * y + 1], ee = d[4 * y + 2], te = d[4 * y + 3], ie = d[4 * b], re = d[4 * b + 1], ne = d[4 * b + 2], oe = d[4 * b + 3], ae = d[4 * T], se = d[4 * T + 1], le = d[4 * T + 2], ce = d[4 * T + 3], ue.set(J, $, ee, te), he.set(ie, re, ne, oe), de.set(ae, se, le, ce), he.subtractToRef(ue, pe), de.subtractToRef(he, fe)); for (var Ie = void 0, Me = void 0, Oe = void 0, De = void 0, Ne = void 0, Fe = void 0, Le = void 0, we = void 0, Be = new B(0, 0, 0), Ue = new B(0, 0, 0), Ve = void 0, ke = void 0, Ge = 0; Ge < t._groupDensity[Pe]; Ge++)v = this.particles.length, this._addParticle(v, t, this._groupCounter, Pe + Ge), ke = this.particles[v], _e = h.RandomRange(0, 1), me = h.RandomRange(0, 1), m = F.add(V.scale(_e)).add(k.scale(_e * me)), i && (ye = e.getFacetNormal(Pe).normalize().scale(-1), be = V.clone().normalize(), Te = R.Cross(ye, be), Ee = h.RandomRange(0, 2 * Math.PI), Se = be.scale(Math.cos(Ee)).add(Te.scale(Math.sin(Ee))), Ee = h.RandomRange(.1, Math.PI / 2), Ce = Se.scale(Math.cos(Ee)).add(ye.scale(Math.sin(Ee))), Re.origin = m.add(Ce.scale(1e-5)), Re.direction = Ce, Re.length = s, (ge = Re.intersectsMesh(e)).hit && (Ae = ge.pickedPoint.subtract(m).length(), xe = h.RandomRange(0, 1) * Ae, m.addInPlace(Ce.scale(xe)))), ke.position = m.clone(), this._positions.push(ke.position.x, ke.position.y, ke.position.z), void 0 !== r ? u && (g = Y.add(q.scale(_e)).add(Z.scale(_e * me)), r ? n && null !== t._groupImageData ? (Ie = t._groupImgWidth, Me = t._groupImgHeight, Ve = this._getColorIndicesForCoord(t, Math.round(g.x * Ie), Math.round(g.y * Me), Ie), ke.color = Ve, this._colors.push(Ve.r, Ve.g, Ve.b, Ve.a)) : d ? (ve = ue.add(pe.scale(_e)).add(fe.scale(_e * me)), ke.color = new U(ve.x, ve.y, ve.z, ve.w), this._colors.push(ve.x, ve.y, ve.z, ve.w)) : (ve = ue.set(Math.random(), Math.random(), Math.random(), 1), ke.color = new U(ve.x, ve.y, ve.z, ve.w), this._colors.push(ve.x, ve.y, ve.z, ve.w)) : (ke.uv = g.clone(), this._uvs.push(ke.uv.x, ke.uv.y))) : (o ? (Be.set(o.r, o.g, o.b), Oe = h.RandomRange(-a, a), De = h.RandomRange(-a, a), Ne = (we = Be.toHSV()).r, (Fe = we.g + Oe) < 0 && (Fe = 0), Fe > 1 && (Fe = 1), (Le = we.b + De) < 0 && (Le = 0), Le > 1 && (Le = 1), B.HSVtoRGBToRef(Ne, Fe, Le, Ue), ve.set(Ue.r, Ue.g, Ue.b, 1)) : ve = ue.set(Math.random(), Math.random(), Math.random(), 1), ke.color = new U(ve.x, ve.y, ve.z, ve.w), this._colors.push(ve.x, ve.y, ve.z, ve.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) { po.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), 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; O < M; O++)r = i[3 * O], n = i[3 * O + 1], o = i[3 * O + 2], a = t[3 * r], s = t[3 * r + 1], l = t[3 * r + 2], c = t[3 * n], u = t[3 * n + 1], h = t[3 * n + 2], d = t[3 * o], p = t[3 * o + 1], f = t[3 * o + 2], T.set(a, s, l), E.set(c, u, h), S.set(d, p, f), E.subtractToRef(T, x), S.subtractToRef(E, A), S.subtractToRef(T, C), v = ((_ = x.length()) + (m = A.length()) + (g = C.length())) / 2, I += y = Math.sqrt(v * (v - _) * (v - m) * (v - g)), P[O] = y; var D = 0; for (O = 0; O < M; O++)b[O] = Math.floor(e * P[O] / I), D += b[O]; var N = e - D, F = Math.floor(N / M), L = N % M; for (F > 0 && (b = b.map((function (e) { return e + F }))), O = 0; O < L; O++)b[O] += 1; return b }, e.prototype.addPoints = function (e, t) { void 0 === t && (t = this._randomUnitVector); for (var i, r = new PE(this._groupCounter, t), n = this.nbParticles, o = 0; o < e; o++)i = this._addParticle(n, r, this._groupCounter, o), r && r._positionFunction && r._positionFunction(i, n, o), this._positions.push(i.position.x, i.position.y, i.position.z), i.color && this._colors.push(i.color.r, i.color.g, i.color.b, i.color.a), i.uv && this._uvs.push(i.uv.x, i.uv.y), n++; return this.nbParticles += e, this._groupCounter++, this._groupCounter }, e.prototype.addSurfacePoints = function (e, t, i, r, n) { var o = i || TE.Random; (isNaN(o) || o < 0 || o > 3) && (o = TE.Random); var a = e.getVerticesData(Hi.PositionKind), s = e.getIndices(); this._groups.push(this._groupCounter); var l = new PE(this._groupCounter, null); switch (l._groupDensity = this._calculateDensity(t, a, s), o === TE.Color ? l._textureNb = r || 0 : r = r || new U(1, 1, 1, 1), o) { case TE.Color: this._colorFromTexture(e, l, !1); break; case TE.UV: this._setPointsColorOrUV(e, l, !1, !1, !1); break; case TE.Random: this._setPointsColorOrUV(e, l, !1); break; case TE.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 || TE.Random; (isNaN(o) || o < 0 || o > 3) && (o = TE.Random); var a = e.getVerticesData(Hi.PositionKind), s = e.getIndices(); this._groups.push(this._groupCounter); var l = new PE(this._groupCounter, null); switch (l._groupDensity = this._calculateDensity(t, a, s), o === TE.Color ? l._textureNb = r || 0 : r = r || new U(1, 1, 1, 1), o) { case TE.Color: this._colorFromTexture(e, l, !0); break; case TE.UV: this._setPointsColorOrUV(e, l, !0, !1, !1); break; case TE.Random: this._setPointsColorOrUV(e, l, !0); break; case TE.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(Hi.ColorKind, s, !1, !1), this._computeParticleTexture && a.updateVerticesData(Hi.UVKind, c, !1, !1), a.updateVerticesData(Hi.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(Ln.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 }), Ln.prototype.getPhysicsImpostor = function () { return this.physicsImpostor }, Ln.prototype.applyImpulse = function (e, t) { return this.physicsImpostor ? (this.physicsImpostor.applyImpulse(e, t), this) : this }, Ln.prototype.setPhysicsLinkWith = function (e, t, i, r) { return this.physicsImpostor && e.physicsImpostor ? (this.physicsImpostor.createJoint(e.physicsImpostor, Xo.HingeJoint, { mainPivot: t, connectedPivot: i, nativeParams: r }), this) : this }; var ME, OE, DE, NE, FE, LE, wE, BE = 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 ge("") }, 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 hg; return this._physicsPlugin.raycast(e, t, r, i), r }, e }(), UE = function () { function e(e, t, i, r) { var n = this; if (this._pluginData = void 0, this._pluginDataInstances = [], this._collisionCBEnabled = !1, this.disablePreStep = !0, 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.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.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.setCollisionCallbackEnabled = function (e) { this._collisionCBEnabled = e, this._physicsPlugin.setCollisionCallbackEnabled(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(Er.WORLD, t, s), s.multiplyToRef(n, a.rotationQuaternion) } else e.getRotationQuaternionToRef(Er.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; i < this._pluginDataInstances.length; i++)e(this, i); else e(this, void 0) }, e.prototype.setGravityFactor = function (e, t) { this._physicsPlugin.setGravityFactor(this, e, t) }, e.prototype.getGravityFactor = function (e) { return this._physicsPlugin.getGravityFactor(this, e) }, e.prototype.setTargetTransform = function (e, t, i) { this._physicsPlugin.setTargetTransform(this, e, t, i) }, e.prototype.dispose = function () { this._collisionCBEnabled && this.setCollisionCallbackEnabled(!1), this._nodeDisposeObserver && (this.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver), this._nodeDisposeObserver = null), this._physicsEngine.removeBody(this), this._physicsPlugin.removeBody(this), this._physicsPlugin.disposeBody(this), this.transformNode.physicsBody = null, this._pluginData = null, this._pluginDataInstances.length = 0 }, e }(); !function (e) { e[e.FREE = 0] = "FREE", e[e.LIMITED = 1] = "LIMITED", e[e.LOCKED = 2] = "LOCKED" }(ME || (ME = {})), function (e) { e[e.LINEAR_X = 0] = "LINEAR_X", e[e.LINEAR_Y = 1] = "LINEAR_Y", e[e.LINEAR_Z = 2] = "LINEAR_Z", e[e.ANGULAR_X = 3] = "ANGULAR_X", e[e.ANGULAR_Y = 4] = "ANGULAR_Y", e[e.ANGULAR_Z = 5] = "ANGULAR_Z", e[e.LINEAR_DISTANCE = 6] = "LINEAR_DISTANCE" }(OE || (OE = {})), function (e) { e[e.BALL_AND_SOCKET = 1] = "BALL_AND_SOCKET", e[e.DISTANCE = 2] = "DISTANCE", e[e.HINGE = 3] = "HINGE", e[e.SLIDER = 4] = "SLIDER", e[e.LOCK = 5] = "LOCK", e[e.PRISMATIC = 6] = "PRISMATIC", e[e.SIX_DOF = 7] = "SIX_DOF" }(DE || (DE = {})), function (e) { e[e.SPHERE = 0] = "SPHERE", e[e.CAPSULE = 1] = "CAPSULE", e[e.CYLINDER = 2] = "CYLINDER", e[e.BOX = 3] = "BOX", e[e.CONVEX_HULL = 4] = "CONVEX_HULL", e[e.CONTAINER = 5] = "CONTAINER", e[e.MESH = 6] = "MESH", e[e.HEIGHTFIELD = 7] = "HEIGHTFIELD" }(NE || (NE = {})), function (e) { e[e.NONE = 0] = "NONE", e[e.VELOCITY = 1] = "VELOCITY", e[e.POSITION = 2] = "POSITION" }(FE || (FE = {})), function (e) { e.COLLISION_STARTED = "COLLISION_STARTED", e.COLLISION_CONTINUED = "COLLISION_CONTINUED", e.COLLISION_FINISHED = "COLLISION_FINISHED", e.TRIGGER_ENTERED = "TRIGGER_ENTERED", e.TRIGGER_EXITED = "TRIGGER_EXITED" }(LE || (LE = {})), function (e) { e[e.STATIC = 0] = "STATIC", e[e.ANIMATED = 1] = "ANIMATED", e[e.DYNAMIC = 2] = "DYNAMIC" }(wE || (wE = {})); var VE, kE = function () { function e(e, t) { var i; if (this._pluginData = void 0, this._isTrigger = !1, t) { var r = t.getPhysicsEngine(); if (!r) throw new Error("No Physics Engine available."); if (2 != r.getPluginVersion()) throw new Error("Plugin version is incorrect. Expected version 2."); var n = r.getPhysicsPlugin(); if (!n) throw new Error("No Physics Plugin available."); if (this._physicsPlugin = n, void 0 !== e.pluginData && null !== e.pluginData) this._pluginData = e.pluginData, this._type = this._physicsPlugin.getShapeType(this); else if (void 0 !== e.type && null !== e.type) { this._type = e.type; var o = null !== (i = e.parameters) && void 0 !== i ? i : {}; this._physicsPlugin.initShape(this, e.type, o) } } } return e.prototype.getClassName = function () { return "PhysicsShape" }, Object.defineProperty(e.prototype, "type", { get: function () { return this._type }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "filterMembershipMask", { get: function () { return this._physicsPlugin.getShapeFilterMembershipMask(this) }, set: function (e) { this._physicsPlugin.setShapeFilterMembershipMask(this, e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "filterCollideMask", { get: function () { return this._physicsPlugin.getShapeFilterCollideMask(this) }, set: function (e) { this._physicsPlugin.setShapeFilterCollideMask(this, e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "material", { get: function () { return this._material }, set: function (e) { this._physicsPlugin.setMaterial(this, e), this._material = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "density", { get: function () { return this._physicsPlugin.getDensity(this) }, set: function (e) { this._physicsPlugin.setDensity(this, e) }, enumerable: !1, configurable: !0 }), e.prototype.addChildFromParent = function (e, t, i) { var r = i.computeWorldMatrix(!0), n = e.computeWorldMatrix(!0), o = O.Matrix[0]; r.multiplyToRef(I.Invert(n), o); var a = O.Vector3[0], s = O.Quaternion[0], l = O.Vector3[1]; o.decompose(l, s, a), this._physicsPlugin.addChild(this, t, a, s, l) }, e.prototype.addChild = function (e, t, i, r) { this._physicsPlugin.addChild(this, e, t, i, r) }, e.prototype.removeChild = function (e) { this._physicsPlugin.removeChild(this, e) }, e.prototype.getNumChildren = function () { return this._physicsPlugin.getNumChildren(this) }, e.prototype.getBoundingBox = function () { return this._physicsPlugin.getBoundingBox(this) }, Object.defineProperty(e.prototype, "isTrigger", { get: function () { return this._isTrigger }, set: function (e) { this._isTrigger !== e && (this._isTrigger = e, this._physicsPlugin.setTrigger(this, e)) }, enumerable: !1, configurable: !0 }), e.prototype.dispose = function () { this._physicsPlugin.disposeShape(this) }, e }(), GE = function (e) { function t(t, i, r) { return e.call(this, { type: NE.SPHERE, parameters: { center: t, radius: i } }, r) || this } return W(t, e), t.FromMesh = function (e) { var i = e.getBoundingInfo(), r = i.boundingSphere.center, n = i.boundingBox.extendSize; return new t(r, Math.max(n.x, n.y, n.z), e.getScene()) }, t }(kE), zE = function (e) { function t(t, i, r, n) { return e.call(this, { type: NE.CAPSULE, parameters: { pointA: t, pointB: i, radius: r } }, n) || this } return W(t, e), t.FromMesh = function (e) { var i = e.getBoundingInfo(), r = i.boundingBox.extendSize.x, n = new R(0, i.boundingBox.extendSize.y - r, 0); return new t(i.boundingBox.center.add(n), i.boundingBox.center.subtract(n), r, e.getScene()) }, t }(kE), WE = function (e) { function t(t, i, r, n) { return e.call(this, { type: NE.CYLINDER, parameters: { pointA: t, pointB: i, radius: r } }, n) || this } return W(t, e), t.FromMesh = function (e) { var i = e.getBoundingInfo(), r = i.boundingBox.extendSize.x, n = new R(0, i.boundingBox.extendSize.y, 0); return new t(i.boundingBox.center.add(n), i.boundingBox.center.subtract(n), r, e.getScene()) }, t }(kE), HE = function (e) { function t(t, i, r, n) { return e.call(this, { type: NE.BOX, parameters: { center: t, rotation: i, extents: r } }, n) || this } return W(t, e), t.FromMesh = function (e) { var i = e.getBoundingInfo(), r = i.boundingBox.center, n = i.boundingBox.extendSize.scale(2); return new t(r, P.Identity(), n, e.getScene()) }, t }(kE), XE = function (e) { function t(t, i) { return e.call(this, { type: NE.CONVEX_HULL, parameters: { mesh: t } }, i) || this } return W(t, e), t }(kE), jE = function (e) { function t(t, i) { return e.call(this, { type: NE.MESH, parameters: { mesh: t } }, i) || this } return W(t, e), t }(kE), YE = function (e) { function t(t) { return e.call(this, { type: NE.CONTAINER, parameters: {} }, t) || this } return W(t, e), t }(kE), KE = function () { function e(e, t, i) { if (this._pluginData = void 0, !i) throw new Error("Missing scene parameter for constraint constructor."); var r = i.getPhysicsEngine(); if (!r) throw new Error("No Physics Engine available."); if (2 != r.getPluginVersion()) throw new Error("Plugin version is incorrect. Expected version 2."); var n = r.getPhysicsPlugin(); if (!n) throw new Error("No Physics Plugin available."); this._physicsPlugin = n, this._options = t, this._type = e } return Object.defineProperty(e.prototype, "type", { get: function () { return this._type }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "options", { get: function () { return this._options }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isEnabled", { get: function () { return this._physicsPlugin.getEnabled(this) }, set: function (e) { this._physicsPlugin.setEnabled(this, e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isCollisionsEnabled", { get: function () { return this._physicsPlugin.getCollisionsEnabled(this) }, set: function (e) { this._physicsPlugin.setCollisionsEnabled(this, e) }, enumerable: !1, configurable: !0 }), e.prototype.dispose = function () { this._physicsPlugin.disposeConstraint(this) }, e }(), QE = function () { }, qE = function (e) { function t(t, i, r) { var n = e.call(this, DE.SIX_DOF, t, r) || this; return n.limits = i, n } return W(t, e), t.prototype.setAxisFriction = function (e, t) { this._physicsPlugin.setAxisFriction(this, e, t) }, t.prototype.getAxisFriction = function (e) { return this._physicsPlugin.getAxisFriction(this, e) }, t.prototype.setAxisMode = function (e, t) { this._physicsPlugin.setAxisMode(this, e, t) }, t.prototype.getAxisMode = function (e) { return this._physicsPlugin.getAxisMode(this, e) }, t.prototype.setAxisMinLimit = function (e, t) { this._physicsPlugin.setAxisMinLimit(this, e, t) }, t.prototype.getAxisMinLimit = function (e) { return this._physicsPlugin.getAxisMinLimit(this, e) }, t.prototype.setAxisMaxLimit = function (e, t) { this._physicsPlugin.setAxisMaxLimit(this, e, t) }, t.prototype.getAxisMaxLimit = function (e) { return this._physicsPlugin.getAxisMaxLimit(this, e) }, t.prototype.setAxisMotorType = function (e, t) { this._physicsPlugin.setAxisMotorType(this, e, t) }, t.prototype.getAxisMotorType = function (e) { return this._physicsPlugin.getAxisMotorType(this, e) }, t.prototype.setAxisMotorTarget = function (e, t) { this._physicsPlugin.setAxisMotorTarget(this, e, t) }, t.prototype.getAxisMotorTarget = function (e) { return this._physicsPlugin.getAxisMotorTarget(this, e) }, t.prototype.setAxisMotorMaxForce = function (e, t) { this._physicsPlugin.setAxisMotorMaxForce(this, e, t) }, t.prototype.getAxisMotorMaxForce = function (e) { return this._physicsPlugin.getAxisMotorMaxForce(this, e) }, t }(KE), ZE = function (e) { function t(t, i, r, n, o) { return e.call(this, DE.BALL_AND_SOCKET, { pivotA: t, pivotB: i, axisA: r, axisB: n }, o) || this } return W(t, e), t }(KE), JE = function (e) { function t(t, i) { return e.call(this, DE.DISTANCE, { maxDistance: t }, i) || this } return W(t, e), t }(KE), $E = function (e) { function t(t, i, r, n, o) { return e.call(this, DE.HINGE, { pivotA: t, pivotB: i, axisA: r, axisB: n }, o) || this } return W(t, e), t }(KE), eS = function (e) { function t(t, i, r, n, o) { return e.call(this, DE.SLIDER, { pivotA: t, pivotB: i, axisA: r, axisB: n }, o) || this } return W(t, e), t }(KE), tS = function (e) { function t(t, i, r, n, o) { return e.call(this, DE.LOCK, { pivotA: t, pivotB: i, axisA: r, axisB: n }, o) || this } return W(t, e), t }(KE), iS = function (e) { function t(t, i, r, n, o) { return e.call(this, DE.PRISMATIC, { pivotA: t, pivotB: i, axisA: r, axisB: n }, o) || this } return W(t, e), t }(KE), rS = function (e) { function t(t, i, r, n, o, a, s, l, c) { return e.call(this, { pivotA: t, pivotB: i, axisA: r, axisB: n }, [{ axis: OE.LINEAR_DISTANCE, minLimit: o, maxLimit: a, stiffness: s, damping: l }], c) || this } return W(t, e), t }(qE); !function (e) { e[e.GEOMETRIC_MEAN = 0] = "GEOMETRIC_MEAN", e[e.MINIMUM = 1] = "MINIMUM", e[e.MAXIMUM = 2] = "MAXIMUM", e[e.ARITHMETIC_MEAN = 3] = "ARITHMETIC_MEAN", e[e.MULTIPLY = 4] = "MULTIPLY" }(VE || (VE = {})); var nS = function () { function e(e, t, i, r) { void 0 === i && (i = { mass: 0 }); var n, o = this; if (this.transformNode = e, this.type = t, this._options = i, this._scene = r, this._disposeShapeWhenDisposed = !0, this.transformNode) { var a = e; if (this.transformNode.parent && 0 !== this._options.mass && a.hasThinInstances && $.Warn("A physics body has been created for an object which has a parent and thin instances. Babylon physics currently works in local space so unexpected issues may occur."), !this._scene && e.getScene && (this._scene = e.getScene()), this._scene) { this._options.mass = void 0 === i.mass ? 0 : i.mass, this._options.friction = void 0 === i.friction ? .2 : i.friction, this._options.restitution = void 0 === i.restitution ? .2 : i.restitution; var s = 0 === this._options.mass ? wE.STATIC : wE.DYNAMIC, l = null !== (n = this._options.startAsleep) && void 0 !== n && n; this.body = new UE(e, s, l, this._scene), this._addSizeOptions(), t.getClassName && "PhysicsShape" === t.getClassName() ? (this.shape = t, this._disposeShapeWhenDisposed = !1) : this.shape = new kE({ type: t, parameters: this._options }, this._scene), this._options.isTriggerShape && (this.shape.isTrigger = !0), this.material = { friction: this._options.friction, restitution: this._options.restitution }, this.body.shape = this.shape, this.shape.material = this.material, this.body.setMassProperties({ mass: this._options.mass }), this._nodeDisposeObserver = this.transformNode.onDisposeObservable.add((function () { o.dispose() })) } } else $.Error("No object was provided. A physics object is obligatory") } return e.prototype._getObjectBoundingBox = function () { return this.transformNode.getRawBoundingInfo ? this.transformNode.getRawBoundingInfo().boundingBox : new un(new R(-.5, -.5, -.5), new R(.5, .5, .5)) }, e.prototype._hasVertices = function (e) { return (null == e ? void 0 : e.getTotalVertices()) > 0 }, 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); 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 NE.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 NE.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 NE.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 NE.MESH: case NE.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 NE.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 }(), oS = 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 Jn ? this._addMesh(e, r) : e instanceof $n && 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 Jn ? i._addMesh(e, r) : e instanceof $n && i._addMesh(e.sourceMesh, r) })) } }, e.prototype._addMesh = function (e, t) { for (var i = e.getVerticesData(Hi.PositionKind) || [], r = i.length / 3, n = this._vertices.length, o = 0; o < r; o++) { var a = new R(i[3 * o + 0], i[3 * o + 1], i[3 * o + 2]); this._vertices.push(R.TransformCoordinates(a, t)) } if (this._collectIndices) { var s = e.getIndices(); if (s) for (var l = 0; l < s.length; l += 3)this._isRightHanded ? (this._indices.push(s[l + 0] + n), this._indices.push(s[l + 1] + n), this._indices.push(s[l + 2] + n)) : (this._indices.push(s[l + 2] + n), this._indices.push(s[l + 1] + n), this._indices.push(s[l + 0] + n)) } }, e.prototype.getVertices = function (e) { for (var t = 3 * this._vertices.length, i = 4 * t, r = e._malloc(i), n = new Float32Array(e.HEAPU8.buffer, r, t), o = 0; o < this._vertices.length; o++)n[3 * o + 0] = this._vertices[o].x, n[3 * o + 1] = this._vertices[o].y, n[3 * o + 2] = this._vertices[o].z; return { offset: r, numObjects: t } }, e.prototype.freeBuffer = function (e, t) { e._free(t.offset) }, e.prototype.getTriangles = function (e) { for (var t = 4 * this._indices.length, i = e._malloc(t), r = new Int32Array(e.HEAPU8.buffer, i, this._indices.length), n = 0; n < this._indices.length; n++)r[n] = this._indices[n]; return { offset: i, numObjects: this._indices.length } }, e }(), aS = function (e) { this.hpBodyId = e, this.userMassProps = { centerOfMass: void 0, mass: void 0, inertia: void 0, inertiaOrientation: void 0 } }, sS = function () { this.bodyId = BigInt(0), this.position = new R, this.normal = new R }, lS = function () { function e() { this.contactOnA = new sS, this.contactOnB = new sS, this.impulseApplied = 0, this.type = 0 } return e.readToRef = function (e, t, i) { var r = new Int32Array(e, t), n = new Float32Array(e, t); i.contactOnA.bodyId = BigInt(r[2]), i.contactOnA.position.set(n[10], n[11], n[12]), i.contactOnA.normal.set(n[13], n[14], n[15]), i.contactOnB.bodyId = BigInt(r[18]), i.contactOnB.position.set(n[26], n[27], n[28]), i.contactOnB.normal.set(n[29], n[30], n[31]), i.impulseApplied = n[34], i.type = r[0] }, e }(), cS = function () { function e() { this.bodyIdA = BigInt(0), this.bodyIdB = BigInt(0), this.type = 0 } return e.readToRef = function (e, t, i) { var r = new Int32Array(e, t); i.type = r[0], i.bodyIdA = BigInt(r[2]), i.bodyIdB = BigInt(r[6]) }, e }(), uS = function () { function e(e, t) { void 0 === e && (e = !0), void 0 === t && (t = HK), this._useDeltaForWorldStep = e, this._hknp = {}, this.name = "HavokPlugin", this._fixedTimeStep = 1 / 60, this._timeStep = 1 / 60, this._tmpVec3 = m.BuildArray(3, R.Zero), this._bodies = new Map, this._bodyCollisionObservable = new Map, this.onCollisionObservable = new u, this.onCollisionEndedObservable = new u, this.onTriggerCollisionObservable = new u, "function" != typeof t ? (this._hknp = t, this.isSupported() ? (this.world = this._hknp.HP_World_Create()[1], this._queryCollector = this._hknp.HP_QueryCollector_Create(1)[1]) : $.Error("Havok is not available. Please make sure you included the js file.")) : $.Error("Havok is not ready. Please make sure you await HK() before using the plugin.") } return e.prototype.isSupported = function () { return void 0 !== this._hknp }, e.prototype.setGravity = function (e) { this._hknp.HP_World_SetGravity(this.world, this._bVecToV3(e)) }, e.prototype.setTimeStep = function (e) { this._fixedTimeStep = e }, e.prototype.getTimeStep = function () { return this._fixedTimeStep }, e.prototype.executeStep = function (e, t) { for (var i = 0, r = t; i < r.length; i++)(a = r[i]).disablePreStep || this.setPhysicsBodyTransformation(a, a.transformNode); this._hknp.HP_World_Step(this.world, this._useDeltaForWorldStep ? e : this._timeStep), this._bodyBuffer = this._hknp.HP_World_GetBodyBuffer(this.world)[1]; for (var n = 0, o = t; n < o.length; n++) { var a = o[n]; this.sync(a) } this._notifyCollisions(), this._notifyTriggers() }, e.prototype.getPluginVersion = function () { return 2 }, e.prototype.initBody = function (e, t, i, r) { e._pluginData = new aS(this._hknp.HP_Body_Create()[1]), this._internalSetMotionType(e._pluginData, t); var n = [this._bVecToV3(i), this._bQuatToV4(r)]; this._hknp.HP_Body_SetQTransform(e._pluginData.hpBodyId, n), this._hknp.HP_World_AddBody(this.world, e._pluginData.hpBodyId, e.startAsleep), this._bodies.set(e._pluginData.hpBodyId[0], { body: e, index: 0 }) }, e.prototype.removeBody = function (e) { if (e._pluginDataInstances && e._pluginDataInstances.length > 0) for (var t = 0, i = e._pluginDataInstances; t < i.length; t++) { var r = i[t]; this._bodyCollisionObservable.delete(r.hpBodyId[0]), this._hknp.HP_World_RemoveBody(this.world, r.hpBodyId) } e._pluginData && (this._bodyCollisionObservable.delete(e._pluginData.hpBodyId[0]), this._hknp.HP_World_RemoveBody(this.world, e._pluginData.hpBodyId)) }, e.prototype.initBodyInstances = function (e, t, i) { var r, n, o = this, a = null !== (n = null === (r = i._thinInstanceDataStorage) || void 0 === r ? void 0 : r.instancesCount) && void 0 !== n ? n : 0, s = i._thinInstanceDataStorage.matrixData; s && (this._createOrUpdateBodyInstances(e, t, s, 0, a, !1), e._pluginDataInstances.forEach((function (t, i) { o._bodies.set(t.hpBodyId[0], { body: e, index: i }) }))) }, e.prototype._createOrUpdateBodyInstances = function (e, t, i, r, n, o) { for (var a = O.Quaternion[0], s = I.Identity(), l = r; l < n; l++) { var c, u = [i[16 * l + 12], i[16 * l + 13], i[16 * l + 14]]; c = o ? e._pluginDataInstances[l].hpBodyId : this._hknp.HP_Body_Create()[1], s.setRowFromFloats(0, i[16 * l + 0], i[16 * l + 1], i[16 * l + 2], 0), s.setRowFromFloats(1, i[16 * l + 4], i[16 * l + 5], i[16 * l + 6], 0), s.setRowFromFloats(2, i[16 * l + 8], i[16 * l + 9], i[16 * l + 10], 0), P.FromRotationMatrixToRef(s, a); var h = [u, [a.x, a.y, a.z, a.w]]; if (this._hknp.HP_Body_SetQTransform(c, h), !o) { var d = new aS(c); e._pluginDataInstances.length && (d.userMassProps = e._pluginDataInstances[0].userMassProps), this._internalSetMotionType(d, t), this._internalUpdateMassProperties(d), e._pluginDataInstances.push(d), this._hknp.HP_World_AddBody(this.world, c, e.startAsleep), d.worldTransformOffset = this._hknp.HP_Body_GetWorldTransformOffset(c)[1] } } }, e.prototype.updateBodyInstances = function (e, t) { var i, r, n = null !== (r = null === (i = t._thinInstanceDataStorage) || void 0 === i ? void 0 : i.instancesCount) && void 0 !== r ? r : 0, o = t._thinInstanceDataStorage.matrixData; if (o) { var a = e._pluginDataInstances.length, s = this.getMotionType(e); if (n > a) { this._createOrUpdateBodyInstances(e, s, o, a, n, !1); for (var l = this._hknp.HP_Body_GetShape(e._pluginDataInstances[0].hpBodyId)[1], c = a; c < n; c++)this._hknp.HP_Body_SetShape(e._pluginDataInstances[c].hpBodyId, l), this._internalUpdateMassProperties(e._pluginDataInstances[c]), this._bodies.set(e._pluginDataInstances[c].hpBodyId[0], { body: e, index: c }) } else if (n < a) { var u = a - n; for (c = 0; c < u; c++) { var h = e._pluginDataInstances.pop(); this._bodies.delete(h.hpBodyId[0]), this._hknp.HP_World_RemoveBody(this.world, h.hpBodyId), this._hknp.HP_Body_Release(h.hpBodyId) } this._createOrUpdateBodyInstances(e, s, o, 0, n, !0) } } }, e.prototype.sync = function (e) { this.syncTransform(e, e.transformNode) }, e.prototype.syncTransform = function (e, t) { var i; if (e._pluginDataInstances.length) { var r = t, n = r._thinInstanceDataStorage.matrixData; if (!n) return; for (var o = e._pluginDataInstances.length, a = 0; a < o; a++) { for (var s = e._pluginDataInstances[a].worldTransformOffset, l = new Float32Array(this._hknp.HEAPU8.buffer, this._bodyBuffer + s, 16), c = 16 * a, u = 0; u < 15; u++)3 != (3 & u) && (n[c + u] = l[u]); n[c + 15] = 1 } r.thinInstanceBufferUpdated("matrix") } else try { var h = this._hknp.HP_Body_GetQTransform(e._pluginData.hpBodyId)[1], d = h[0], p = h[1], f = O.Quaternion[0]; f.set(p[0], p[1], p[2], p[3]); var _ = t.parent; if (_ && !_.getWorldMatrix().isIdentity()) { _.computeWorldMatrix(!0), f.normalize(); var m = O.Matrix[0], g = O.Vector3[0]; g.copyFromFloats(d[0], d[1], d[2]), I.ComposeToRef(t.absoluteScaling, f, g, m); var v = O.Matrix[1]; _.getWorldMatrix().invertToRef(v); var y = O.Matrix[2]; m.multiplyToRef(v, y), y.decomposeToTransformNode(t), null === (i = t.rotationQuaternion) || void 0 === i || i.normalize() } else t.position.set(d[0], d[1], d[2]), t.rotationQuaternion ? t.rotationQuaternion.copyFrom(f) : f.toEulerAnglesToRef(t.rotation) } catch (e) { console.log("Syncing transform failed for node ".concat(t.name, ": ").concat(e.message, "...")) } }, e.prototype.setShape = function (e, t) { var i, r, n, o = t && t._pluginData ? t._pluginData : BigInt(0); if (!(e.transformNode instanceof Jn && (null === (i = e.transformNode._thinInstanceDataStorage) || void 0 === i ? void 0 : i.matrixData))) return this._hknp.HP_Body_SetShape(e._pluginData.hpBodyId, o), void this._internalUpdateMassProperties(e._pluginData); for (var a = null !== (n = null === (r = e.transformNode._thinInstanceDataStorage) || void 0 === r ? void 0 : r.instancesCount) && void 0 !== n ? n : 0, s = 0; s < a; s++)this._hknp.HP_Body_SetShape(e._pluginDataInstances[s].hpBodyId, o), this._internalUpdateMassProperties(e._pluginDataInstances[s]) }, e.prototype._getPluginReference = function (e, t) { var i; return (null === (i = e._pluginDataInstances) || void 0 === i ? void 0 : i.length) ? e._pluginDataInstances[null != t ? t : 0] : e._pluginData }, e.prototype.getShape = function (e) { var t = this._getPluginReference(e), i = this._hknp.HP_Body_GetShape(t.hpBodyId)[1]; if (0 != i) { var r = e.transformNode.getScene(); return new kE({ pluginData: i }, r) } return null }, e.prototype.getShapeType = function (e) { return e.type ? e.type : this._hknp.HP_Shape_GetType(e._pluginData) }, e.prototype.setEventMask = function (e, t, i) { var r = this; this._applyToBodyOrInstances(e, (function (e) { r._hknp.HP_Body_SetEventMask(e.hpBodyId, t) }), i) }, e.prototype.getEventMask = function (e, t) { var i = this._getPluginReference(e, t); return this._hknp.HP_Body_GetEventMask(i.hpBodyId)[1] }, e.prototype._fromMassPropertiesTuple = function (e) { return { centerOfMass: R.FromArray(e[0]), mass: e[1], inertia: R.FromArray(e[2]), inertiaOrientation: P.FromArray(e[3]) } }, e.prototype._internalUpdateMassProperties = function (e) { var t = this._internalComputeMassProperties(e), i = e.userMassProps; i.centerOfMass && (t[0] = i.centerOfMass.asArray()), null != i.mass && (t[1] = i.mass), i.inertia && (t[2] = i.inertia.asArray()), i.inertiaOrientation && (t[3] = i.inertiaOrientation.asArray()), this._hknp.HP_Body_SetMassProperties(e.hpBodyId, t) }, e.prototype._internalSetMotionType = function (e, t) { switch (t) { case wE.STATIC: this._hknp.HP_Body_SetMotionType(e.hpBodyId, this._hknp.MotionType.STATIC); break; case wE.ANIMATED: this._hknp.HP_Body_SetMotionType(e.hpBodyId, this._hknp.MotionType.KINEMATIC); break; case wE.DYNAMIC: this._hknp.HP_Body_SetMotionType(e.hpBodyId, this._hknp.MotionType.DYNAMIC) } }, e.prototype.setMotionType = function (e, t, i) { var r = this; this._applyToBodyOrInstances(e, (function (e) { r._internalSetMotionType(e, t) }), i) }, e.prototype.getMotionType = function (e, t) { var i = this._getPluginReference(e, t), r = this._hknp.HP_Body_GetMotionType(i.hpBodyId)[1]; switch (r) { case this._hknp.MotionType.STATIC: return wE.STATIC; case this._hknp.MotionType.KINEMATIC: return wE.ANIMATED; case this._hknp.MotionType.DYNAMIC: return wE.DYNAMIC }throw new Error("Unknown motion type: " + r) }, e.prototype._internalComputeMassProperties = function (e) { var t = this._hknp.HP_Body_GetShape(e.hpBodyId); if (t[0] == this._hknp.Result.RESULT_OK) { var i = this._hknp.HP_Shape_BuildMassProperties(t[1]); if (i[0] == this._hknp.Result.RESULT_OK) return i[1] } return [[0, 0, 0], 1, [1, 1, 1], [0, 0, 0, 1]] }, e.prototype.computeMassProperties = function (e, t) { var i = this._getPluginReference(e, t), r = this._internalComputeMassProperties(i); return this._fromMassPropertiesTuple(r) }, e.prototype.setMassProperties = function (e, t, i) { var r = this; this._applyToBodyOrInstances(e, (function (e) { e.userMassProps = t, r._internalUpdateMassProperties(e) }), i) }, e.prototype.getMassProperties = function (e, t) { var i = this._getPluginReference(e, t), r = this._hknp.HP_Body_GetMassProperties(i.hpBodyId)[1]; return this._fromMassPropertiesTuple(r) }, e.prototype.setLinearDamping = function (e, t, i) { var r = this; this._applyToBodyOrInstances(e, (function (e) { r._hknp.HP_Body_SetLinearDamping(e.hpBodyId, t) }), i) }, e.prototype.getLinearDamping = function (e, t) { var i = this._getPluginReference(e, t); return this._hknp.HP_Body_GetLinearDamping(i.hpBodyId)[1] }, e.prototype.setAngularDamping = function (e, t, i) { var r = this; this._applyToBodyOrInstances(e, (function (e) { r._hknp.HP_Body_SetAngularDamping(e.hpBodyId, t) }), i) }, e.prototype.getAngularDamping = function (e, t) { var i = this._getPluginReference(e, t); return this._hknp.HP_Body_GetAngularDamping(i.hpBodyId)[1] }, e.prototype.setLinearVelocity = function (e, t, i) { var r = this; this._applyToBodyOrInstances(e, (function (e) { r._hknp.HP_Body_SetLinearVelocity(e.hpBodyId, r._bVecToV3(t)) }), i) }, e.prototype.getLinearVelocityToRef = function (e, t, i) { var r = this._getPluginReference(e, i), n = this._hknp.HP_Body_GetLinearVelocity(r.hpBodyId)[1]; this._v3ToBvecRef(n, t) }, e.prototype._applyToBodyOrInstances = function (e, t, i) { var r; if ((null === (r = e._pluginDataInstances) || void 0 === r ? void 0 : r.length) > 0 && void 0 === i) for (var n = 0; n < e._pluginDataInstances.length; n++)t(e._pluginDataInstances[n]); else t(this._getPluginReference(e, i)) }, e.prototype.applyImpulse = function (e, t, i, r) { var n = this; this._applyToBodyOrInstances(e, (function (e) { n._hknp.HP_Body_ApplyImpulse(e.hpBodyId, n._bVecToV3(i), n._bVecToV3(t)) }), r) }, e.prototype.applyForce = function (e, t, i, r) { t.scaleToRef(this.getTimeStep(), this._tmpVec3[0]), this.applyImpulse(e, this._tmpVec3[0], i, r) }, e.prototype.setAngularVelocity = function (e, t, i) { var r = this; this._applyToBodyOrInstances(e, (function (e) { r._hknp.HP_Body_SetAngularVelocity(e.hpBodyId, r._bVecToV3(t)) }), i) }, e.prototype.getAngularVelocityToRef = function (e, t, i) { var r = this._getPluginReference(e, i), n = this._hknp.HP_Body_GetAngularVelocity(r.hpBodyId)[1]; this._v3ToBvecRef(n, t) }, e.prototype.setPhysicsBodyTransformation = function (e, t) { var i = e.transformNode; if (e.numInstances > 0) { 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; t < i.length; t++) { var r = i[t]; this._hknp.HP_Body_Release(r.hpBodyId), r.hpBodyId = void 0 } e._pluginData && (this._hknp.HP_Body_Release(e._pluginData.hpBodyId), e._pluginData.hpBodyId = void 0) }, e.prototype.initShape = function (e, t, i) { switch (t) { case NE.SPHERE: var r = i.radius || 1, n = i.center ? this._bVecToV3(i.center) : [0, 0, 0]; e._pluginData = this._hknp.HP_Shape_CreateSphere(n, r)[1]; break; case NE.BOX: var o = i.rotation ? this._bQuatToV4(i.rotation) : [0, 0, 0, 1], a = i.extents ? this._bVecToV3(i.extents) : [1, 1, 1]; n = i.center ? this._bVecToV3(i.center) : [0, 0, 0], e._pluginData = this._hknp.HP_Shape_CreateBox(n, o, a)[1]; break; case NE.CAPSULE: var s = i.pointA ? this._bVecToV3(i.pointA) : [0, 0, 0], l = i.pointB ? this._bVecToV3(i.pointB) : [0, 1, 0]; r = i.radius || 0, e._pluginData = this._hknp.HP_Shape_CreateCapsule(s, l, r)[1]; break; case NE.CONTAINER: e._pluginData = this._hknp.HP_Shape_CreateContainer()[1]; break; case NE.CYLINDER: s = i.pointA ? this._bVecToV3(i.pointA) : [0, 0, 0], l = i.pointB ? this._bVecToV3(i.pointB) : [0, 1, 0], r = i.radius || 0, e._pluginData = this._hknp.HP_Shape_CreateCylinder(s, l, r)[1]; break; case NE.CONVEX_HULL: case NE.MESH: var c = i.mesh; if (!c) throw new Error("No mesh provided to create physics shape."); var u = !!i.includeChildMeshes, h = t != NE.CONVEX_HULL, d = new oS(c, h, null == c ? void 0 : c.getScene()); d.addNodeMeshes(c, u); var p = d.getVertices(this._hknp), f = p.numObjects / 3; if (t == NE.CONVEX_HULL) e._pluginData = this._hknp.HP_Shape_CreateConvexHull(p.offset, f)[1]; else { var _ = d.getTriangles(this._hknp), m = _.numObjects / 3; e._pluginData = this._hknp.HP_Shape_CreateMesh(p.offset, f, _.offset, m)[1], d.freeBuffer(this._hknp, _) } d.freeBuffer(this._hknp, p); break; default: throw new Error("Unsupported Shape Type.") } }, e.prototype.setShapeFilterMembershipMask = function (e, t) { var i = this._hknp.HP_Shape_GetFilterInfo(e._pluginData)[1][1]; this._hknp.HP_Shape_SetFilterInfo(e._pluginData, [t, i]) }, e.prototype.getShapeFilterMembershipMask = function (e) { return this._hknp.HP_Shape_GetFilterInfo(e._pluginData)[1][0] }, e.prototype.setShapeFilterCollideMask = function (e, t) { var i = this._hknp.HP_Shape_GetFilterInfo(e._pluginData)[1][0]; this._hknp.HP_Shape_SetFilterInfo(e._pluginData, [i, t]) }, e.prototype.getShapeFilterCollideMask = function (e) { return this._hknp.HP_Shape_GetFilterInfo(e._pluginData)[1][1] }, e.prototype.setMaterial = function (e, t) { var i, r, n, o, a, s = null !== (i = t.friction) && void 0 !== i ? i : .5, l = null !== (r = t.staticFriction) && void 0 !== r ? r : s, c = null !== (n = t.restitution) && void 0 !== n ? n : 0, u = null !== (o = t.frictionCombine) && void 0 !== o ? o : VE.MINIMUM, h = null !== (a = t.restitutionCombine) && void 0 !== a ? a : VE.MAXIMUM, d = [l, s, c, this._materialCombineToNative(u), this._materialCombineToNative(h)]; this._hknp.HP_Shape_SetMaterial(e._pluginData, d) }, e.prototype.setDensity = function (e, t) { this._hknp.HP_Shape_SetDensity(e._pluginData, t) }, e.prototype.getDensity = function (e) { return this._hknp.HP_Shape_GetDensity(e._pluginData)[1] }, e.prototype._getTransformInfos = function (e) { if (e.parent) return e.computeWorldMatrix(!0), [this._bVecToV3(e.absolutePosition), this._bQuatToV4(e.absoluteRotationQuaternion)]; var t = O.Quaternion[0]; if (e.rotationQuaternion) t = e.rotationQuaternion; else { var i = e.rotation; P.FromEulerAnglesToRef(i.x, i.y, i.z, t) } return [this._bVecToV3(e.position), this._bQuatToV4(t)] }, e.prototype.addChild = function (e, t, i, r, n) { var o = [i ? this._bVecToV3(i) : [0, 0, 0], r ? this._bQuatToV4(r) : [0, 0, 0, 1], n ? this._bVecToV3(n) : [1, 1, 1]]; this._hknp.HP_Shape_AddChild(e._pluginData, t._pluginData, o) }, e.prototype.removeChild = function (e, t) { this._hknp.HP_Shape_RemoveChild(e._pluginData, t) }, e.prototype.getNumChildren = function (e) { return this._hknp.HP_Shape_GetNumChildren(e._pluginData)[1] }, e.prototype.setTrigger = function (e, t) { this._hknp.HP_Shape_SetTrigger(e._pluginData, t) }, e.prototype.getBoundingBox = function (e) { return {} }, e.prototype.getBodyGeometry = function (e) { var t, i = (null === (t = e._pluginDataInstances) || void 0 === t ? void 0 : t.length) > 0 ? 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 = e.type, u = e.options; if (c && u) 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 { var h = this._hknp.HP_Constraint_Create()[1]; e._pluginData = h; var d = this._getPluginReference(t, r).hpBodyId, p = this._getPluginReference(i, n).hpBodyId; this._hknp.HP_Constraint_SetParentBody(h, d), this._hknp.HP_Constraint_SetChildBody(h, p); var f = u.pivotA ? this._bVecToV3(u.pivotA) : this._bVecToV3(R.Zero()), _ = null !== (o = u.axisA) && void 0 !== o ? o : new R(1, 0, 0), m = this._tmpVec3[0]; u.perpAxisA ? m.copyFrom(u.perpAxisA) : _.getNormalToRef(m), this._hknp.HP_Constraint_SetAnchorInParent(h, f, this._bVecToV3(_), this._bVecToV3(m)); var g = u.pivotB ? this._bVecToV3(u.pivotB) : this._bVecToV3(R.Zero()), v = null !== (a = u.axisB) && void 0 !== a ? a : new R(1, 0, 0), y = this._tmpVec3[0]; if (u.perpAxisB ? y.copyFrom(u.perpAxisB) : v.getNormalToRef(y), this._hknp.HP_Constraint_SetAnchorInChild(h, g, this._bVecToV3(v), this._bVecToV3(y)), c == DE.LOCK) this._hknp.HP_Constraint_SetAxisMode(h, this._hknp.ConstraintAxis.LINEAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(h, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(h, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(h, this._hknp.ConstraintAxis.ANGULAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(h, this._hknp.ConstraintAxis.ANGULAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(h, this._hknp.ConstraintAxis.ANGULAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED); else if (c == DE.DISTANCE) { var b = u.maxDistance || 0, T = this._hknp.ConstraintAxis.LINEAR_DISTANCE; this._hknp.HP_Constraint_SetAxisMode(h, T, this._hknp.ConstraintAxisLimitMode.LIMITED), this._hknp.HP_Constraint_SetAxisMinLimit(h, T, b), this._hknp.HP_Constraint_SetAxisMaxLimit(h, T, b) } else if (c == DE.HINGE) this._hknp.HP_Constraint_SetAxisMode(h, this._hknp.ConstraintAxis.LINEAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(h, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(h, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(h, this._hknp.ConstraintAxis.ANGULAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(h, this._hknp.ConstraintAxis.ANGULAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED); else if (c == DE.PRISMATIC) this._hknp.HP_Constraint_SetAxisMode(h, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(h, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(h, this._hknp.ConstraintAxis.ANGULAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(h, this._hknp.ConstraintAxis.ANGULAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(h, this._hknp.ConstraintAxis.ANGULAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED); else if (c == DE.SLIDER) this._hknp.HP_Constraint_SetAxisMode(h, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(h, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(h, this._hknp.ConstraintAxis.ANGULAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(h, this._hknp.ConstraintAxis.ANGULAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED); else if (c == DE.BALL_AND_SOCKET) this._hknp.HP_Constraint_SetAxisMode(h, this._hknp.ConstraintAxis.LINEAR_X, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(h, this._hknp.ConstraintAxis.LINEAR_Y, this._hknp.ConstraintAxisLimitMode.LOCKED), this._hknp.HP_Constraint_SetAxisMode(h, this._hknp.ConstraintAxis.LINEAR_Z, this._hknp.ConstraintAxisLimitMode.LOCKED); else { if (c != DE.SIX_DOF) throw new Error("Unsupported Constraint Type."); for (var E = 0, S = e.limits; E < S.length; E++) { var x = S[E], A = this._constraintAxisToNative(x.axis); 0 == (null !== (s = x.minLimit) && void 0 !== s ? s : -1) && 0 == (null !== (l = x.maxLimit) && void 0 !== l ? l : -1) ? this._hknp.HP_Constraint_SetAxisMode(h, A, this._hknp.ConstraintAxisLimitMode.LOCKED) : (null != x.minLimit && (this._hknp.HP_Constraint_SetAxisMode(h, A, this._hknp.ConstraintAxisLimitMode.LIMITED), this._hknp.HP_Constraint_SetAxisMinLimit(h, A, x.minLimit)), null != x.maxLimit && (this._hknp.HP_Constraint_SetAxisMode(h, A, this._hknp.ConstraintAxisLimitMode.LIMITED), this._hknp.HP_Constraint_SetAxisMaxLimit(h, A, x.maxLimit))), x.stiffness && this._hknp.HP_Constraint_SetAxisStiffness(h, A, x.stiffness), x.damping && this._hknp.HP_Constraint_SetAxisDamping(h, A, x.damping) } } var C = !!u.collision; this._hknp.HP_Constraint_SetCollisionsEnabled(h, C), this._hknp.HP_Constraint_SetEnabled(h, !0) } else $.Warn("No constraint type or options. Constraint is invalid.") }, e.prototype.addConstraint = function (e, t, i, r, n) { this.initConstraint(i, e, t, r, n) }, e.prototype.setEnabled = function (e, t) { this._hknp.HP_Constraint_SetEnabled(e._pluginData, t) }, e.prototype.getEnabled = function (e) { return this._hknp.HP_Constraint_GetEnabled(e._pluginData)[1] }, e.prototype.setCollisionsEnabled = function (e, t) { this._hknp.HP_Constraint_SetCollisionsEnabled(e._pluginData, t) }, e.prototype.getCollisionsEnabled = function (e) { return this._hknp.HP_Constraint_GetCollisionsEnabled(e._pluginData)[1] }, e.prototype.setAxisFriction = function (e, t, i) { this._hknp.HP_Constraint_SetAxisFriction(e._pluginData, this._constraintAxisToNative(t), i) }, e.prototype.getAxisFriction = function (e, t) { return this._hknp.HP_Constraint_GetAxisFriction(e._pluginData, this._constraintAxisToNative(t))[1] }, e.prototype.setAxisMode = function (e, t, i) { this._hknp.HP_Constraint_SetAxisMode(e._pluginData, this._constraintAxisToNative(t), this._limitModeToNative(i)) }, e.prototype.getAxisMode = function (e, t) { var i = this._hknp.HP_Constraint_GetAxisMode(e._pluginData, this._constraintAxisToNative(t))[1]; return this._nativeToLimitMode(i) }, e.prototype.setAxisMinLimit = function (e, t, i) { this._hknp.HP_Constraint_SetAxisMinLimit(e._pluginData, this._constraintAxisToNative(t), i) }, e.prototype.getAxisMinLimit = function (e, t) { return this._hknp.HP_Constraint_GetAxisMinLimit(e._pluginData, this._constraintAxisToNative(t))[1] }, e.prototype.setAxisMaxLimit = function (e, t, i) { this._hknp.HP_Constraint_SetAxisMaxLimit(e._pluginData, this._constraintAxisToNative(t), i) }, e.prototype.getAxisMaxLimit = function (e, t) { return this._hknp.HP_Constraint_GetAxisMaxLimit(e._pluginData, this._constraintAxisToNative(t))[1] }, e.prototype.setAxisMotorType = function (e, t, i) { this._hknp.HP_Constraint_SetAxisMotorType(e._pluginData, this._constraintAxisToNative(t), this._constraintMotorTypeToNative(i)) }, e.prototype.getAxisMotorType = function (e, t) { return this._nativeToMotorType(this._hknp.HP_Constraint_GetAxisMotorType(e._pluginData, this._constraintAxisToNative(t))[1]) }, e.prototype.setAxisMotorTarget = function (e, t, i) { this._hknp.HP_Constraint_SetAxisMotorTarget(e._pluginData, this._constraintAxisToNative(t), i) }, e.prototype.getAxisMotorTarget = function (e, t) { return this._hknp.HP_Constraint_GetAxisMotorTarget(e._pluginData, this._constraintAxisToNative(t))[1] }, e.prototype.setAxisMotorMaxForce = function (e, t, i) { this._hknp.HP_Constraint_SetAxisMotorMaxForce(e._pluginData, this._constraintAxisToNative(t), i) }, e.prototype.getAxisMotorMaxForce = function (e, t) { return this._hknp.HP_Constraint_GetAxisMotorMaxForce(e._pluginData, this._constraintAxisToNative(t))[1] }, e.prototype.disposeConstraint = function (e) { var t = e._pluginData; this._hknp.HP_Constraint_SetEnabled(t, !1), this._hknp.HP_Constraint_Release(t), e._pluginData = void 0 }, e.prototype.raycast = function (e, t, i, r) { var n, o, a = null !== (n = null == r ? void 0 : r.membership) && void 0 !== n ? n : -1, s = null !== (o = null == r ? void 0 : r.collideWith) && void 0 !== o ? o : -1; i.reset(e, t); var l = [this._bVecToV3(e), this._bVecToV3(t), [a, s]]; if (this._hknp.HP_World_CastRayWithCollector(this.world, this._queryCollector, l), this._hknp.HP_QueryCollector_GetNumHits(this._queryCollector)[1] > 0) { 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.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._notifyTriggers = function () { for (var e = this._hknp.HP_World_GetTriggerEvents(this.world)[1], t = new cS; e;) { cS.readToRef(this._hknp.HEAPU8.buffer, e, t); var i = this._bodies.get(t.bodyIdA), r = this._bodies.get(t.bodyIdB), 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 lS, i = Number(this.world); e;) { lS.readToRef(this._hknp.HEAPU8.buffer, e, t); var r = this._bodies.get(t.contactOnA.bodyId), n = this._bodies.get(t.contactOnB.bodyId), o = { collider: r.body, colliderIndex: r.index, collidedAgainst: n.body, collidedAgainstIndex: n.index, type: this._nativeCollisionValueToCollisionType(t.type) }; if (o.type === LE.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 !== LE.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)) } 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 FE.POSITION: return this._hknp.ConstraintMotorType.POSITION; case FE.VELOCITY: return this._hknp.ConstraintMotorType.VELOCITY }return this._hknp.ConstraintMotorType.NONE }, e.prototype._nativeToMotorType = function (e) { switch (e) { case this._hknp.ConstraintMotorType.POSITION: return FE.POSITION; case this._hknp.ConstraintMotorType.VELOCITY: return FE.VELOCITY }return FE.NONE }, e.prototype._materialCombineToNative = function (e) { switch (e) { case VE.GEOMETRIC_MEAN: return this._hknp.MaterialCombine.GEOMETRIC_MEAN; case VE.MINIMUM: return this._hknp.MaterialCombine.MINIMUM; case VE.MAXIMUM: return this._hknp.MaterialCombine.MAXIMUM; case VE.ARITHMETIC_MEAN: return this._hknp.MaterialCombine.ARITHMETIC_MEAN; case VE.MULTIPLY: return this._hknp.MaterialCombine.MULTIPLY } }, e.prototype._constraintAxisToNative = function (e) { switch (e) { case OE.LINEAR_X: return this._hknp.ConstraintAxis.LINEAR_X; case OE.LINEAR_Y: return this._hknp.ConstraintAxis.LINEAR_Y; case OE.LINEAR_Z: return this._hknp.ConstraintAxis.LINEAR_Z; case OE.ANGULAR_X: return this._hknp.ConstraintAxis.ANGULAR_X; case OE.ANGULAR_Y: return this._hknp.ConstraintAxis.ANGULAR_Y; case OE.ANGULAR_Z: return this._hknp.ConstraintAxis.ANGULAR_Z; case OE.LINEAR_DISTANCE: return this._hknp.ConstraintAxis.LINEAR_DISTANCE } }, e.prototype._nativeToLimitMode = function (e) { switch (e) { case this._hknp.ConstraintAxisLimitMode.FREE: return ME.FREE; case this._hknp.ConstraintAxisLimitMode.LIMITED: return ME.LIMITED; case this._hknp.ConstraintAxisLimitMode.LOCKED: return ME.LOCKED }return ME.FREE }, e.prototype._limitModeToNative = function (e) { switch (e) { case ME.FREE: return this._hknp.ConstraintAxisLimitMode.FREE; case ME.LIMITED: return this._hknp.ConstraintAxisLimitMode.LIMITED; case ME.LOCKED: return this._hknp.ConstraintAxisLimitMode.LOCKED } }, e.prototype._nativeCollisionValueToCollisionType = function (e) { switch (e) { case this._hknp.EventType.COLLISION_STARTED.value: return LE.COLLISION_STARTED; case this._hknp.EventType.COLLISION_FINISHED.value: return LE.COLLISION_FINISHED; case this._hknp.EventType.COLLISION_CONTINUED.value: return LE.COLLISION_CONTINUED }return LE.COLLISION_STARTED }, e.prototype._nativeTriggerCollisionValueToCollisionType = function (e) { switch (e) { case 8: return LE.TRIGGER_ENTERED; case 16: return LE.TRIGGER_EXITED }return LE.TRIGGER_ENTERED }, e }(); Sr.prototype.getPhysicsEngine = function () { return this._physicsEngine }, Sr.prototype.enablePhysics = function (e, t) { if (void 0 === e && (e = null), this._physicsEngine) return !0; var i = this._getComponent(qi.NAME_PHYSICSENGINE); i || (i = new hS(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 BE(e, t) } else this._physicsEngine = new dg(e, t); return this._physicsTimeAccumulator = 0, !0 } catch (e) { return $.Error(e.message), !1 } }, Sr.prototype.disablePhysicsEngine = function () { this._physicsEngine && (this._physicsEngine.dispose(), this._physicsEngine = null) }, Sr.prototype.isPhysicsEnabled = function () { return void 0 !== this._physicsEngine }, Sr.prototype.deleteCompoundImpostor = function (e) { var t = e.parts[0].mesh; t.physicsImpostor && (t.physicsImpostor.dispose(), t.physicsImpostor = null) }, Sr.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 hS = function () { function e(e) { var t = this; this.name = qi.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(On.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 }), On.prototype.getPhysicsBody = function () { return this.physicsBody }, On.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, pS, 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 Mo(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) === wE.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 }(), _S = 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 bS).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 mS(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 bS).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 mS(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(); s < l.length; s++)l[s].iterateOverAllInstances((function (s, l) { e.getBodyHitData(s, t, i, l) && (n(s, i), r && a.push({ body: s, hitData: o._copyPhysicsHitData(i) })) })); e.triggerAffectedBodiesCallback(a) }, e.prototype.gravitationalField = function (e, t, i, r) { 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; if ("number" == typeof t) { var n = t; (t = new bS).radius = n, t.strength = null != i ? i : t.strength, t.falloff = null != r ? r : t.falloff } var o = new gS(this, this._scene, e, t); return o.dispose(!1), o }, e.prototype.updraft = function (e, t, i, r, n) { 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; if ("number" == typeof t) { var o = t; (t = new TS).radius = o, t.strength = null != i ? i : t.strength, t.height = null != r ? r : t.height, t.updraftMode = null != n ? n : t.updraftMode } var a = new vS(this._scene, e, t); return a.dispose(!1), a }, e.prototype.vortex = function (e, t, i, r) { 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; if ("number" == typeof t) { var n = t; (t = new ES).radius = n, t.strength = null != i ? i : t.strength, t.height = null != r ? r : t.height } var o = new yS(this._scene, e, t); return o.dispose(!1), o }, e.prototype._copyPhysicsHitData = function (e) { return { force: e.force.clone(), contactPoint: e.contactPoint.clone(), distanceFromOrigin: e.distanceFromOrigin, instanceIndex: e.instanceIndex } }, e }(), mS = function () { function e(e, t) { this._scene = e, this._options = t, this._dataFetched = !1, this._options = H(H({}, new bS), this._options) } return e.prototype.getData = function () { return this._dataFetched = !0, { sphere: this._sphere } }, e.prototype._getHitData = function (e, t, i, r) { var n = O.Vector3[0]; n.copyFrom(t).subtractInPlace(i); var o = O.Vector3[1]; if (!fS.GetContactPointToRef(e, i, n, o, r.instanceIndex)) return !1; var a = R.Distance(i, o); if (a > this._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 = bu("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 }(), gS = function () { function e(e, t, i, r) { this._physicsHelper = e, this._scene = t, this._origin = i, this._options = r, this._dataFetched = !1, this._options = H(H({}, new bS), this._options), this._tickCallback = this._tick.bind(this), 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 }(), vS = function () { function e(e, t, i) { 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 TS), 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 === pS.Perpendicular && (this._originDirection = this._origin.subtract(this._originTop).normalize()), this._tickCallback = this._tick.bind(this), 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 === pS.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 = Dc("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 }(), yS = function () { function e(e, t, i) { 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 ES), 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 = this._tick.bind(this), 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 = Dc("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 }(), bS = function () { this.radius = 5, this.strength = 10, this.falloff = dS.Constant, this.sphere = { segments: 32, diameter: 1 } }, TS = function () { this.radius = 5, this.strength = 10, this.height = 10, this.updraftMode = pS.Center }, ES = 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" }(pS || (pS = {})); Ut.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 SS = 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 Ue.Parse((function () { return new t(e.name, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.reusable) }), e, r, n) }, X([xe()], t.prototype, "degree", void 0), t }(Ia); b("BABYLON.BlackAndWhitePostProcess", SS); var xS = 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; i < t.length; i++)if (!t[i].isSupported) return !1; return !0 }, enumerable: !1, configurable: !0 }), e.prototype._update = function () { }, e.prototype._attachCameras = function (e) { var t, i = this, r = xi.MakeArray(e || this._cameras); if (r) for (var n = function (e) { var n = r[e]; if (!n) return "continue"; var a = n.name; if (t = o._singleInstance ? 0 : a, !o._postProcesses[t]) { var s = o._getPostProcesses(); s && (o._postProcesses[t] = Array.isArray(s) ? s : [s]) } o._indicesForCamera[a] || (o._indicesForCamera[a] = []), o._postProcesses[t].forEach((function (e) { var t = n.attachPostProcess(e); i._indicesForCamera[a].push(t) })), o._cameras[a] || (o._cameras[a] = n) }, o = this, a = 0; a < r.length; a++)n(a) }, e.prototype._detachCameras = function (e) { var t = xi.MakeArray(e || this._cameras); if (t) for (var i = function (e) { var i = t[e], n = i.name, o = r._postProcesses[r._singleInstance ? 0 : n]; o && o.forEach((function (e) { i.detachPostProcess(e) })), r._cameras[n] && (r._cameras[n] = null), delete r._indicesForCamera[n] }, r = this, n = 0; n < t.length; n++)i(n) }, e.prototype._enable = function (e) { var t = xi.MakeArray(e || this._cameras); if (t) for (var i = 0; i < t.length; i++)for (var r = t[i], n = r.name, o = this._singleInstance ? 0 : n, a = 0; a < this._indicesForCamera[n].length; a++) { var s = this._indicesForCamera[n][a]; null == r._postProcesses[s] && t[i].attachPostProcess(this._postProcesses[o][a], s) } }, e.prototype._disable = function (e) { var t = xi.MakeArray(e || this._cameras); if (t) for (var i = function (e) { var i = t[e], n = i.name; r._postProcesses[r._singleInstance ? 0 : n].forEach((function (e) { i.detachPostProcess(e) })) }, r = this, n = 0; n < t.length; n++)i(n) }, e.prototype.getPostProcesses = function (e) { return this._singleInstance ? this._postProcesses[0] : e ? this._postProcesses[e.name] : null }, e }(); Ut.ShadersStore.extractHighlightsPixelShader = "#include\nvarying vec2 vUV;uniform sampler2D textureSampler;uniform float threshold;uniform float exposure;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{gl_FragColor=texture2D(textureSampler,vUV);float luma=dot(LuminanceEncodeApprox,gl_FragColor.rgb*exposure);gl_FragColor.rgb=step(threshold,luma)*gl_FragColor.rgb;}"; var AS = 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, "extractHighlights", ["threshold", "exposure"], null, i, r, n, o, s, null, l, void 0, null, c) || this; return u.threshold = .9, u._exposure = 1, u._inputPostProcess = null, u.onApplyObservable.add((function (e) { u.externalTextureSamplerBinding = !!u._inputPostProcess, u._inputPostProcess && e.setTextureFromPostProcess("textureSampler", u._inputPostProcess), e.setFloat("threshold", Math.pow(u.threshold, d)), e.setFloat("exposure", u._exposure) })), u } return W(t, e), t.prototype.getClassName = function () { return "ExtractHighlightsPostProcess" }, X([xe()], t.prototype, "threshold", void 0), t }(Ia); b("BABYLON.ExtractHighlightsPostProcess", AS); Ut.ShadersStore.bloomMergePixelShader = "uniform sampler2D textureSampler;uniform sampler2D bloomBlur;varying vec2 vUV;uniform float bloomWeight;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{gl_FragColor=texture2D(textureSampler,vUV);vec3 blurred=texture2D(bloomBlur,vUV).rgb;gl_FragColor.rgb=gl_FragColor.rgb+(blurred.rgb*bloomWeight); }\n"; var RS = function (e) { function t(t, i, r, n, o, s, l, c, u, h, d) { void 0 === h && (h = a.TEXTURETYPE_UNSIGNED_INT), void 0 === d && (d = !1); var p = e.call(this, t, "bloomMerge", ["bloomWeight"], ["bloomBlur"], o, s, l, c, u, null, h, void 0, null, !0) || this; return p.weight = 1, p.weight = n, p.externalTextureSamplerBinding = !0, p.onApplyObservable.add((function (e) { e.setTextureFromPostProcess("textureSampler", i), e.setTextureFromPostProcessOutput("bloomBlur", r), e.setFloat("bloomWeight", p.weight) })), d || p.updateEffect(), p } return W(t, e), t.prototype.getClassName = function () { return "BloomMergePostProcess" }, X([xe()], t.prototype, "weight", void 0), t }(Ia); b("BABYLON.BloomMergePostProcess", RS); var CS = function (e) { function t(t, i, r, n, o, a) { void 0 === o && (o = 0), void 0 === a && (a = !1); var s = e.call(this, t.getEngine(), "bloom", (function () { return s._effects }), !0) || this; return s._bloomScale = i, s._effects = [], s._downscale = new AS("highlights", 1, null, vo.BILINEAR_SAMPLINGMODE, t.getEngine(), !1, o, a), s._blurX = new c_("horizontal blur", new A(1, 0), 10, i, null, vo.BILINEAR_SAMPLINGMODE, t.getEngine(), !1, o, void 0, a), s._blurX.alwaysForcePOT = !0, s._blurX.autoClear = !1, s._blurY = new c_("vertical blur", new A(0, 1), 10, i, null, vo.BILINEAR_SAMPLINGMODE, t.getEngine(), !1, o, void 0, a), s._blurY.alwaysForcePOT = !0, s._blurY.autoClear = !1, s.kernel = n, s._effects = [s._downscale, s._blurX, s._blurY], s._merge = new RS("bloomMerge", s._downscale, s._blurY, r, i, null, vo.BILINEAR_SAMPLINGMODE, t.getEngine(), !1, o, a), s._merge.autoClear = !1, s._effects.push(s._merge), s } return W(t, e), Object.defineProperty(t.prototype, "threshold", { get: function () { return this._downscale.threshold }, set: function (e) { this._downscale.threshold = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "weight", { get: function () { return this._merge.weight }, set: function (e) { this._merge.weight = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "kernel", { get: function () { return this._blurX.kernel / this._bloomScale }, set: function (e) { this._blurX.kernel = e * this._bloomScale, this._blurY.kernel = e * this._bloomScale }, enumerable: !1, configurable: !0 }), t.prototype.disposeEffects = function (e) { for (var t = 0; t < this._effects.length; t++)this._effects[t].dispose(e) }, t.prototype._updateEffects = function () { for (var e = 0; e < this._effects.length; e++)this._effects[e].updateEffect() }, t.prototype._isReady = function () { for (var e = 0; e < this._effects.length; e++)if (!this._effects[e].isReady()) return !1; return !0 }, t }(xS); Ut.ShadersStore.chromaticAberrationPixelShader = "uniform sampler2D textureSampler; \nuniform float chromatic_aberration;uniform float radialIntensity;uniform vec2 direction;uniform vec2 centerPosition;uniform float screen_width;uniform float screen_height;varying vec2 vUV;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{vec2 centered_screen_pos=vec2(vUV.x-centerPosition.x,vUV.y-centerPosition.y);vec2 directionOfEffect=direction;if(directionOfEffect.x==0. && directionOfEffect.y==0.){directionOfEffect=normalize(centered_screen_pos);}\nfloat radius2=centered_screen_pos.x*centered_screen_pos.x\n+ centered_screen_pos.y*centered_screen_pos.y;float radius=sqrt(radius2);vec4 original=texture2D(textureSampler,vUV);vec3 ref_indices=vec3(-0.3,0.0,0.3);float ref_shiftX=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.x/screen_width;float ref_shiftY=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.y/screen_height;vec2 ref_coords_r=vec2(vUV.x+ref_indices.r*ref_shiftX,vUV.y+ref_indices.r*ref_shiftY*0.5);vec2 ref_coords_g=vec2(vUV.x+ref_indices.g*ref_shiftX,vUV.y+ref_indices.g*ref_shiftY*0.5);vec2 ref_coords_b=vec2(vUV.x+ref_indices.b*ref_shiftX,vUV.y+ref_indices.b*ref_shiftY*0.5);original.r=texture2D(textureSampler,ref_coords_r).r;original.g=texture2D(textureSampler,ref_coords_g).g;original.b=texture2D(textureSampler,ref_coords_b).b;original.a=clamp(texture2D(textureSampler,ref_coords_r).a+texture2D(textureSampler,ref_coords_g).a+texture2D(textureSampler,ref_coords_b).a,0.,1.);gl_FragColor=original;}"; var PS = function (e) { function t(t, i, r, n, o, s, l, c, u, h) { void 0 === u && (u = a.TEXTURETYPE_UNSIGNED_INT), void 0 === h && (h = !1); var d = e.call(this, t, "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], [], n, o, s, l, c, null, u, void 0, null, h) || this; return d.aberrationAmount = 30, d.radialIntensity = 0, d.direction = new A(.707, .707), d.centerPosition = new A(.5, .5), d.screenWidth = i, d.screenHeight = r, d.onApplyObservable.add((function (e) { e.setFloat("chromatic_aberration", d.aberrationAmount), e.setFloat("screen_width", i), e.setFloat("screen_height", r), e.setFloat("radialIntensity", d.radialIntensity), e.setFloat2("direction", d.direction.x, d.direction.y), e.setFloat2("centerPosition", d.centerPosition.x, d.centerPosition.y) })), d } return W(t, e), t.prototype.getClassName = function () { return "ChromaticAberrationPostProcess" }, t._Parse = function (e, i, r, n) { return Ue.Parse((function () { return new t(e.name, e.screenWidth, e.screenHeight, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.reusable, e.textureType, !1) }), e, r, n) }, X([xe()], t.prototype, "aberrationAmount", void 0), X([xe()], t.prototype, "radialIntensity", void 0), X([xe()], t.prototype, "direction", void 0), X([xe()], t.prototype, "centerPosition", void 0), X([xe()], t.prototype, "screenWidth", void 0), X([xe()], t.prototype, "screenHeight", void 0), t }(Ia); b("BABYLON.ChromaticAberrationPostProcess", PS); Ut.ShadersStore.circleOfConfusionPixelShader = "uniform sampler2D depthSampler;varying vec2 vUV;uniform vec2 cameraMinMaxZ;uniform float focusDistance;uniform float cocPrecalculation;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{float depth=texture2D(depthSampler,vUV).r;\n#define CUSTOM_COC_DEPTH\nfloat pixelDistance=(cameraMinMaxZ.x+cameraMinMaxZ.y*depth)*1000.0; \n#define CUSTOM_COC_PIXELDISTANCE\nfloat coc=abs(cocPrecalculation*((focusDistance-pixelDistance)/pixelDistance));coc=clamp(coc,0.0,1.0);gl_FragColor=vec4(coc,coc,coc,1.0);}\n"; var IS = function (e) { function t(t, i, r, n, o, s, l, c, u) { void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT), void 0 === u && (u = !1); var h = e.call(this, t, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], r, n, o, s, l, null, c, void 0, null, u) || this; return h.lensSize = 50, h.fStop = 1.4, h.focusDistance = 2e3, h.focalLength = 50, h._depthTexture = null, h._depthTexture = i, h.onApplyObservable.add((function (e) { if (h._depthTexture) { e.setTexture("depthSampler", h._depthTexture); var t = h.lensSize / h.fStop * h.focalLength / (h.focusDistance - h.focalLength); e.setFloat("focusDistance", h.focusDistance), e.setFloat("cocPrecalculation", t); var i = h._depthTexture.activeCamera; e.setFloat2("cameraMinMaxZ", i.minZ, i.maxZ - i.minZ) } else $.Warn("No depth texture set on CircleOfConfusionPostProcess") })), h } return W(t, e), t.prototype.getClassName = function () { return "CircleOfConfusionPostProcess" }, Object.defineProperty(t.prototype, "depthTexture", { set: function (e) { this._depthTexture = e }, enumerable: !1, configurable: !0 }), X([xe()], t.prototype, "lensSize", void 0), X([xe()], t.prototype, "fStop", void 0), X([xe()], t.prototype, "focusDistance", void 0), X([xe()], t.prototype, "focalLength", void 0), t }(Ia); b("BABYLON.CircleOfConfusionPostProcess", IS); Ut.ShadersStore.colorCorrectionPixelShader = "uniform sampler2D textureSampler; \nuniform sampler2D colorTable; \nvarying vec2 vUV;const float SLICE_COUNT=16.0; \nvec4 sampleAs3DTexture(sampler2D textureSampler,vec3 uv,float width) {float sliceSize=1.0/width; \nfloat slicePixelSize=sliceSize/width; \nfloat sliceInnerSize=slicePixelSize*(width-1.0); \nfloat zSlice0=min(floor(uv.z*width),width-1.0);float zSlice1=min(zSlice0+1.0,width-1.0);float xOffset=slicePixelSize*0.5+uv.x*sliceInnerSize;float s0=xOffset+(zSlice0*sliceSize);float s1=xOffset+(zSlice1*sliceSize);vec4 slice0Color=texture2D(textureSampler,vec2(s0,uv.y));vec4 slice1Color=texture2D(textureSampler,vec2(s1,uv.y));float zOffset=mod(uv.z*width,1.0);vec4 result=mix(slice0Color,slice1Color,zOffset);return result;}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{vec4 screen_color=texture2D(textureSampler,vUV);gl_FragColor=sampleAs3DTexture(colorTable,screen_color.rgb,SLICE_COUNT);}"; var MS = function (e) { function t(t, i, r, n, o, a, s) { var l = e.call(this, t, "colorCorrection", null, ["colorTable"], r, n, o, a, s) || this, c = (null == n ? void 0 : n.getScene()) || null; return l._colorTableTexture = new vo(i, c, !0, !1, vo.TRILINEAR_SAMPLINGMODE), l._colorTableTexture.anisotropicFilteringLevel = 1, l._colorTableTexture.wrapU = vo.CLAMP_ADDRESSMODE, l._colorTableTexture.wrapV = vo.CLAMP_ADDRESSMODE, l.colorTableUrl = i, l.onApply = function (e) { e.setTexture("colorTable", l._colorTableTexture) }, l } return W(t, e), t.prototype.getClassName = function () { return "ColorCorrectionPostProcess" }, t._Parse = function (e, i, r, n) { return Ue.Parse((function () { return new t(e.name, e.colorTableUrl, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.reusable) }), e, r, n) }, X([xe()], t.prototype, "colorTableUrl", void 0), t }(Ia); b("BABYLON.ColorCorrectionPostProcess", MS); Ut.ShadersStore.convolutionPixelShader = "varying vec2 vUV;uniform sampler2D textureSampler;uniform vec2 screenSize;uniform float kernel[9];\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{vec2 onePixel=vec2(1.0,1.0)/screenSize;vec4 colorSum =\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,-1))*kernel[0] +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,-1))*kernel[1] +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,-1))*kernel[2] +\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,0))*kernel[3] +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,0))*kernel[4] +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,0))*kernel[5] +\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,1))*kernel[6] +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,1))*kernel[7] +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,1))*kernel[8];float kernelWeight =\nkernel[0] +\nkernel[1] +\nkernel[2] +\nkernel[3] +\nkernel[4] +\nkernel[5] +\nkernel[6] +\nkernel[7] +\nkernel[8];if (kernelWeight<=0.0) {kernelWeight=1.0;}\ngl_FragColor=vec4((colorSum/kernelWeight).rgb,1);}"; var OS = function (e) { function t(t, i, r, n, o, s, l, c) { void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT); var u = e.call(this, t, "convolution", ["kernel", "screenSize"], null, r, n, o, s, l, null, c) || this; return u.kernel = i, u.onApply = function (e) { e.setFloat2("screenSize", u.width, u.height), e.setArray("kernel", u.kernel) }, u } return W(t, e), t.prototype.getClassName = function () { return "ConvolutionPostProcess" }, t._Parse = function (e, i, r, n) { return Ue.Parse((function () { return new t(e.name, e.kernel, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.reusable, e.textureType) }), e, r, n) }, t.EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1], t.EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0], t.EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1], t.SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0], t.EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2], t.GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0], X([xe()], t.prototype, "kernel", void 0), t }(Ia); b("BABYLON.ConvolutionPostProcess", OS); var DS = function (e) { function t(t, i, r, n, o, s, l, c, u, h, d, p, f, _) { void 0 === c && (c = null), void 0 === u && (u = vo.BILINEAR_SAMPLINGMODE), void 0 === p && (p = a.TEXTURETYPE_UNSIGNED_INT), void 0 === f && (f = !1), void 0 === _ && (_ = a.TEXTUREFORMAT_RGBA); var m = e.call(this, t, r, n, o, s, u = a.TEXTURE_BILINEAR_SAMPLINGMODE, h, d, p, "#define DOF 1\n", f, _) || this; return m.direction = r, m.externalTextureSamplerBinding = !!c, m.onApplyObservable.add((function (e) { null != c && e.setTextureFromPostProcess("textureSampler", c), e.setTextureFromPostProcessOutput("circleOfConfusionSampler", l) })), m } return W(t, e), t.prototype.getClassName = function () { return "DepthOfFieldBlurPostProcess" }, X([xe()], t.prototype, "direction", void 0), t }(c_); b("BABYLON.DepthOfFieldBlurPostProcess", DS); Ut.ShadersStore.depthOfFieldMergePixelShader = "#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 sampler2D circleOfConfusionSampler;uniform sampler2D blurStep0;\n#if BLUR_LEVEL>0\nuniform sampler2D blurStep1;\n#endif\n#if BLUR_LEVEL>1\nuniform sampler2D blurStep2;\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{float coc=TEXTUREFUNC(circleOfConfusionSampler,vUV,0.0).r;\n#if BLUR_LEVEL==0\nvec4 original=TEXTUREFUNC(textureSampler,vUV,0.0);vec4 blurred0=TEXTUREFUNC(blurStep0,vUV,0.0);gl_FragColor=mix(original,blurred0,coc);\n#endif\n#if BLUR_LEVEL==1\nif(coc<0.5){vec4 original=TEXTUREFUNC(textureSampler,vUV,0.0);vec4 blurred1=TEXTUREFUNC(blurStep1,vUV,0.0);gl_FragColor=mix(original,blurred1,coc/0.5);}else{vec4 blurred0=TEXTUREFUNC(blurStep0,vUV,0.0);vec4 blurred1=TEXTUREFUNC(blurStep1,vUV,0.0);gl_FragColor=mix(blurred1,blurred0,(coc-0.5)/0.5);}\n#endif\n#if BLUR_LEVEL==2\nif(coc<0.33){vec4 original=TEXTUREFUNC(textureSampler,vUV,0.0);vec4 blurred2=TEXTUREFUNC(blurStep2,vUV,0.0);gl_FragColor=mix(original,blurred2,coc/0.33);}else if(coc<0.66){vec4 blurred1=TEXTUREFUNC(blurStep1,vUV,0.0);vec4 blurred2=TEXTUREFUNC(blurStep2,vUV,0.0);gl_FragColor=mix(blurred2,blurred1,(coc-0.33)/0.33);}else{vec4 blurred0=TEXTUREFUNC(blurStep0,vUV,0.0);vec4 blurred1=TEXTUREFUNC(blurStep1,vUV,0.0);gl_FragColor=mix(blurred1,blurred0,(coc-0.66)/0.34);}\n#endif\n}\n"; var NS, FS = function (e) { function t(t, i, r, n, o, s, l, c, u, h, d) { void 0 === h && (h = a.TEXTURETYPE_UNSIGNED_INT), void 0 === d && (d = !1); var p = e.call(this, t, "depthOfFieldMerge", [], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2"], o, s, l, c, u, null, h, void 0, null, !0) || this; return p._blurSteps = n, p.externalTextureSamplerBinding = !0, p.onApplyObservable.add((function (e) { e.setTextureFromPostProcess("textureSampler", i), e.setTextureFromPostProcessOutput("circleOfConfusionSampler", r), n.forEach((function (t, i) { e.setTextureFromPostProcessOutput("blurStep" + (n.length - i - 1), t) })) })), d || p.updateEffect(), p } return W(t, e), t.prototype.getClassName = function () { return "DepthOfFieldMergePostProcess" }, t.prototype.updateEffect = function (t, i, r, n, o, a) { void 0 === t && (t = null), void 0 === i && (i = null), void 0 === r && (r = null), t || (t = "", t += "#define BLUR_LEVEL " + (this._blurSteps.length - 1) + "\n"), e.prototype.updateEffect.call(this, t, i, r, n, o, a) }, t }(Ia); !function (e) { e[e.Low = 0] = "Low", e[e.Medium = 1] = "Medium", e[e.High = 2] = "High" }(NS || (NS = {})); var LS = function (e) { function t(t, i, r, n, o) { void 0 === r && (r = NS.Low), void 0 === n && (n = 0), void 0 === o && (o = !1); var s = e.call(this, t.getEngine(), "depth of field", (function () { return s._effects }), !0) || this; s._effects = []; var l = t.getEngine(), c = l.isWebGPU || l.webGLVersion > 1 ? a.TEXTUREFORMAT_RED : a.TEXTUREFORMAT_RGBA; s._circleOfConfusion = new IS("circleOfConfusion", i, 1, null, vo.BILINEAR_SAMPLINGMODE, l, !1, n, o), s._depthOfFieldBlurY = [], s._depthOfFieldBlurX = []; var u = 1, h = 15; switch (r) { case NS.High: u = 3, h = 51; break; case NS.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 < u; f++) { var _ = new DS("vertical blur", t, new A(0, 1), d, p, null, s._circleOfConfusion, 0 == f ? s._circleOfConfusion : null, vo.BILINEAR_SAMPLINGMODE, l, !1, n, o, 0 == f ? c : a.TEXTUREFORMAT_RGBA); _.autoClear = !1, p = .75 / Math.pow(2, f); var m = new DS("horizontal blur", t, new A(1, 0), d, p, null, s._circleOfConfusion, null, vo.BILINEAR_SAMPLINGMODE, l, !1, n, o); m.autoClear = !1, s._depthOfFieldBlurY.push(_), s._depthOfFieldBlurX.push(m) } for (s._effects = [s._circleOfConfusion], f = 0; f < s._depthOfFieldBlurX.length; f++)s._effects.push(s._depthOfFieldBlurY[f]), s._effects.push(s._depthOfFieldBlurX[f]); return s._dofMerge = new FS("dofMerge", s._circleOfConfusion, s._circleOfConfusion, s._depthOfFieldBlurX, p, null, vo.BILINEAR_SAMPLINGMODE, l, !1, n, o), s._dofMerge.autoClear = !1, s._effects.push(s._dofMerge), s } return W(t, e), Object.defineProperty(t.prototype, "focalLength", { get: function () { return this._circleOfConfusion.focalLength }, set: function (e) { this._circleOfConfusion.focalLength = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fStop", { get: function () { return this._circleOfConfusion.fStop }, set: function (e) { this._circleOfConfusion.fStop = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "focusDistance", { get: function () { return this._circleOfConfusion.focusDistance }, set: function (e) { this._circleOfConfusion.focusDistance = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "lensSize", { get: function () { return this._circleOfConfusion.lensSize }, set: function (e) { this._circleOfConfusion.lensSize = e }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function () { return "DepthOfFieldEffect" }, Object.defineProperty(t.prototype, "depthTexture", { set: function (e) { this._circleOfConfusion.depthTexture = e }, enumerable: !1, configurable: !0 }), t.prototype.disposeEffects = function (e) { for (var t = 0; t < this._effects.length; t++)this._effects[t].dispose(e) }, t.prototype._updateEffects = function () { for (var e = 0; e < this._effects.length; e++)this._effects[e].updateEffect() }, t.prototype._isReady = function () { for (var e = 0; e < this._effects.length; e++)if (!this._effects[e].isReady()) return !1; return !0 }, t }(xS); Ut.ShadersStore.displayPassPixelShader = "varying vec2 vUV;uniform sampler2D textureSampler;uniform sampler2D passSampler;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{gl_FragColor=texture2D(passSampler,vUV);}"; var wS = function (e) { function t(t, i, r, n, o, a) { return e.call(this, t, "displayPass", ["passSampler"], ["passSampler"], i, r, n, o, a) || this } return W(t, e), t.prototype.getClassName = function () { return "DisplayPassPostProcess" }, t._Parse = function (e, i, r, n) { return Ue.Parse((function () { return new t(e.name, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.reusable) }), e, r, n) }, t }(Ia); b("BABYLON.DisplayPassPostProcess", wS); Ut.ShadersStore.filterPixelShader = "varying vec2 vUV;uniform sampler2D textureSampler;uniform mat4 kernelMatrix;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{vec3 baseColor=texture2D(textureSampler,vUV).rgb;vec3 updatedColor=(kernelMatrix*vec4(baseColor,1.0)).rgb;gl_FragColor=vec4(updatedColor,1.0);}"; var BS = function (e) { function t(t, i, r, n, o, a, s) { var l = e.call(this, t, "filter", ["kernelMatrix"], null, r, n, o, a, s) || this; return l.kernelMatrix = i, l.onApply = function (e) { e.setMatrix("kernelMatrix", l.kernelMatrix) }, l } return W(t, e), t.prototype.getClassName = function () { return "FilterPostProcess" }, t._Parse = function (e, i, r, n) { return Ue.Parse((function () { return new t(e.name, e.kernelMatrix, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.reusable) }), e, r, n) }, X([Le()], t.prototype, "kernelMatrix", void 0), t }(Ia); b("BABYLON.FilterPostProcess", BS); Ut.ShadersStore.fxaaPixelShader = "#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\n#define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l)\n#else\n#define TEXTUREFUNC(s,c,b) texture2D(s,c,b)\n#endif\nuniform sampler2D textureSampler;uniform vec2 texelSize;varying vec2 vUV;varying vec2 sampleCoordS;varying vec2 sampleCoordE;varying vec2 sampleCoordN;varying vec2 sampleCoordW;varying vec2 sampleCoordNW;varying vec2 sampleCoordSE;varying vec2 sampleCoordNE;varying vec2 sampleCoordSW;const float fxaaQualitySubpix=1.0;const float fxaaQualityEdgeThreshold=0.166;const float fxaaQualityEdgeThresholdMin=0.0833;const vec3 kLumaCoefficients=vec3(0.2126,0.7152,0.0722);\n#define FxaaLuma(rgba) dot(rgba.rgb,kLumaCoefficients)\nvoid main(){vec2 posM;posM.x=vUV.x;posM.y=vUV.y;vec4 rgbyM=TEXTUREFUNC(textureSampler,vUV,0.0);float lumaM=FxaaLuma(rgbyM);float lumaS=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordS,0.0));float lumaE=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordE,0.0));float lumaN=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordN,0.0));float lumaW=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordW,0.0));float maxSM=max(lumaS,lumaM);float minSM=min(lumaS,lumaM);float maxESM=max(lumaE,maxSM);float minESM=min(lumaE,minSM);float maxWN=max(lumaN,lumaW);float minWN=min(lumaN,lumaW);float rangeMax=max(maxWN,maxESM);float rangeMin=min(minWN,minESM);float rangeMaxScaled=rangeMax*fxaaQualityEdgeThreshold;float range=rangeMax-rangeMin;float rangeMaxClamped=max(fxaaQualityEdgeThresholdMin,rangeMaxScaled);\n#ifndef MALI\nif(range=edgeVert;float subpixA=subpixNSWE*2.0+subpixNWSWNESE;if (!horzSpan)\n{lumaN=lumaW;}\nif (!horzSpan) \n{lumaS=lumaE;}\nif (horzSpan) \n{lengthSign=texelSize.y;}\nfloat subpixB=(subpixA*(1.0/12.0))-lumaM;float gradientN=lumaN-lumaM;float gradientS=lumaS-lumaM;float lumaNN=lumaN+lumaM;float lumaSS=lumaS+lumaM;bool pairN=abs(gradientN)>=abs(gradientS);float gradient=max(abs(gradientN),abs(gradientS));if (pairN)\n{lengthSign=-lengthSign;}\nfloat subpixC=clamp(abs(subpixB)*subpixRcpRange,0.0,1.0);vec2 posB;posB.x=posM.x;posB.y=posM.y;vec2 offNP;offNP.x=(!horzSpan) ? 0.0 : texelSize.x;offNP.y=(horzSpan) ? 0.0 : texelSize.y;if (!horzSpan) \n{posB.x+=lengthSign*0.5;}\nif (horzSpan)\n{posB.y+=lengthSign*0.5;}\nvec2 posN;posN.x=posB.x-offNP.x*1.5;posN.y=posB.y-offNP.y*1.5;vec2 posP;posP.x=posB.x+offNP.x*1.5;posP.y=posB.y+offNP.y*1.5;float subpixD=((-2.0)*subpixC)+3.0;float lumaEndN=FxaaLuma(TEXTUREFUNC(textureSampler,posN,0.0));float subpixE=subpixC*subpixC;float lumaEndP=FxaaLuma(TEXTUREFUNC(textureSampler,posP,0.0));if (!pairN) \n{lumaNN=lumaSS;}\nfloat gradientScaled=gradient*1.0/4.0;float lumaMM=lumaM-lumaNN*0.5;float subpixF=subpixD*subpixE;bool lumaMLTZero=lumaMM<0.0;lumaEndN-=lumaNN*0.5;lumaEndP-=lumaNN*0.5;bool doneN=abs(lumaEndN)>=gradientScaled;bool doneP=abs(lumaEndP)>=gradientScaled;if (!doneN) \n{posN.x-=offNP.x*3.0;}\nif (!doneN) \n{posN.y-=offNP.y*3.0;}\nbool doneNP=(!doneN) || (!doneP);if (!doneP) \n{posP.x+=offNP.x*3.0;}\nif (!doneP)\n{posP.y+=offNP.y*3.0;}\nif (doneNP)\n{if (!doneN) lumaEndN=FxaaLuma(TEXTUREFUNC(textureSampler,posN.xy,0.0));if (!doneP) lumaEndP=FxaaLuma(TEXTUREFUNC(textureSampler,posP.xy,0.0));if (!doneN) lumaEndN=lumaEndN-lumaNN*0.5;if (!doneP) lumaEndP=lumaEndP-lumaNN*0.5;doneN=abs(lumaEndN)>=gradientScaled;doneP=abs(lumaEndP)>=gradientScaled;if (!doneN) posN.x-=offNP.x*12.0;if (!doneN) posN.y-=offNP.y*12.0;doneNP=(!doneN) || (!doneP);if (!doneP) posP.x+=offNP.x*12.0;if (!doneP) posP.y+=offNP.y*12.0;}\nfloat dstN=posM.x-posN.x;float dstP=posP.x-posM.x;if (!horzSpan)\n{dstN=posM.y-posN.y;}\nif (!horzSpan) \n{dstP=posP.y-posM.y;}\nbool goodSpanN=(lumaEndN<0.0) != lumaMLTZero;float spanLength=(dstP+dstN);bool goodSpanP=(lumaEndP<0.0) != lumaMLTZero;float spanLengthRcp=1.0/spanLength;bool directionN=dstN -1 ? "#define MALI 1\n" : null }, t._Parse = function (e, i, r, n) { return Ue.Parse((function () { return new t(e.name, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.reusable) }), e, r, n) }, t }(Ia); b("BABYLON.FxaaPostProcess", US); Ut.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 VS = 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 Ue.Parse((function () { return new t(e.name, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.reusable) }), e, r, n) }, X([xe()], t.prototype, "intensity", void 0), X([xe()], t.prototype, "animated", void 0), t }(Ia); b("BABYLON.GrainPostProcess", VS); Ut.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 kS = 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 }(Ia); Ut.IncludesShadersStore.mrtFragmentDeclaration = "#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n"; Ut.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\nnormalOutput=normalize(vec3(vWorldView*vec4(normalW,0.0)));\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"; Ut.IncludesShadersStore.geometryVertexDeclaration = "uniform mat4 viewProjection;uniform mat4 view;"; Ut.IncludesShadersStore.geometryUboDeclaration = "#include\n"; Ut.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\nvNormalV=normalize(vec3((view*finalWorld)*vec4(normalUpdated,0.0)));\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 GS = ["world", "mBones", "viewProjection", "diffuseMatrix", "view", "previousWorld", "previousViewProjection", "mPreviousBones", "bumpMatrix", "reflectivityMatrix", "albedoMatrix", "reflectivityColor", "albedoColor", "metallic", "glossiness", "vTangentSpaceParams", "vBumpInfos", "morphTargetInfluences", "morphTargetTextureInfo", "morphTargetTextureIndices"]; wn(GS); var zS = 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._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; 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 = [Hi.PositionKind, Hi.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 && ic.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(Hi.UVKind) && (n.push(Hi.UVKind), r.push("#define UV1")), o.isVerticesDataPresent(Hi.UV2Kind) && (n.push(Hi.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)), o.useBones && o.computeBonesUsingShaders ? (n.push(Hi.MatricesIndicesKind), n.push(Hi.MatricesWeightsKind), o.numBoneInfluencers > 4 && (n.push(Hi.MatricesIndicesExtraKind), n.push(Hi.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"), zn.PrepareAttributesForMorphTargetsInfluencers(n, o, c)), t && (r.push("#define INSTANCES"), zn.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), Bn(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: GS, 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 hv("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 = vo.CLAMP_ADDRESSMODE, this._multiRenderTarget.wrapV = vo.CLAMP_ADDRESSMODE, this._multiRenderTarget.refreshRate = 1, this._multiRenderTarget.renderParticles = !1, this._multiRenderTarget.renderList = null; for (var s = [!0], l = [!1], c = [!0], u = 1; u < r; ++u)s.push(!0), c.push(!1), l.push(!0); var h = i.buildTextureLayout(s), d = i.buildTextureLayout(l), p = i.buildTextureLayout(c); this._multiRenderTarget.onClearObservable.add((function (e) { e.bindAttachments(t.useSpecificClearForDepthTexture ? d : h), e.clear(t._clearColor, !0, !0, !0), t.useSpecificClearForDepthTexture && (e.bindAttachments(p), e.clear(t._clearDepthColor, !0, !0, !0)), e.bindAttachments(h) })), this._resizeObserver = i.onResizeObservable.add((function () { t._multiRenderTarget && t._multiRenderTarget.resize({ width: i.getRenderWidth() * t._ratio, height: i.getRenderHeight() * t._ratio }) })); var f = function (e) { var i = e.getRenderingMesh(), r = e.getEffectiveMesh(), n = t._scene, o = n.getEngine(), a = e.getMaterial(); if (a) { if (r._internalAbstractMeshDataInfo._isActiveIntermediate = !1, t._enableVelocity && !t._previousTransformationMatrices[r.uniqueId] && (t._previousTransformationMatrices[r.uniqueId] = { world: I.Identity(), viewProjection: n.getTransformMatrix() }, i.skeleton)) { var s = i.skeleton.getTransformMatrices(i); t._previousBonesTransformationMatrices[i.uniqueId] = t._copyBonesTransformationMatrices(s, new Float32Array(s.length)) } var l = i._getInstancesRenderList(e._id, !!e.getReplacementMesh()); if (!l.mustReturn) { var c = o.getCaps().instancedArrays && (null !== l.visibleInstances[e._id] || i.hasThinInstances), u = r.getWorldMatrix(); if (t.isReady(e, c)) { var h = e._getDrawWrapper(); if (!h) return; var d = h.effect; o.enableEffect(h), c || i._bind(e, d, a.fillMode), t._useUbo ? (zn.BindSceneUniformBuffer(d, t._scene.getSceneUniformBuffer()), t._scene.finalizeSceneUbo()) : (d.setMatrix("viewProjection", n.getTransformMatrix()), d.setMatrix("view", n.getViewMatrix())); var p = void 0, f = i._instanceDataStorage; if (f.isFrozen || !a.backFaceCulling && null === i.overrideMaterialSideOrientation) p = f.sideOrientation; else { var _ = r._getWorldMatrixDeterminant(); null === (p = i.overrideMaterialSideOrientation) && (p = a.sideOrientation), _ < 0 && (p = p === Hn.ClockWiseSideOrientation ? Hn.CounterClockWiseSideOrientation : Hn.ClockWiseSideOrientation) } if (a._preBind(h, p), a.needAlphaTesting()) { var m = a.getAlphaTestTexture(); m && (d.setTexture("diffuseSampler", m), d.setMatrix("diffuseMatrix", m.getTextureMatrix())) } a.bumpTexture && n.getEngine().getCaps().standardDerivatives && ic.BumpTextureEnabled && (d.setFloat3("vBumpInfos", a.bumpTexture.coordinatesIndex, 1 / a.bumpTexture.level, a.parallaxScaleBias), d.setMatrix("bumpMatrix", a.bumpTexture.getTextureMatrix()), d.setTexture("bumpSampler", a.bumpTexture), d.setFloat2("vTangentSpaceParams", a.invertNormalMapX ? -1 : 1, a.invertNormalMapY ? -1 : 1)), t._enableReflectivity && ("PBRMetallicRoughnessMaterial" === a.getClassName() ? (null !== a.metallicRoughnessTexture && (d.setTexture("reflectivitySampler", a.metallicRoughnessTexture), d.setMatrix("reflectivityMatrix", a.metallicRoughnessTexture.getTextureMatrix())), null !== a.metallic && d.setFloat("metallic", a.metallic), null !== a.roughness && d.setFloat("glossiness", 1 - a.roughness), null !== a.baseTexture && (d.setTexture("albedoSampler", a.baseTexture), d.setMatrix("albedoMatrix", a.baseTexture.getTextureMatrix())), null !== a.baseColor && d.setColor3("albedoColor", a.baseColor)) : "PBRSpecularGlossinessMaterial" === a.getClassName() ? (null !== a.specularGlossinessTexture ? (d.setTexture("reflectivitySampler", a.specularGlossinessTexture), d.setMatrix("reflectivityMatrix", a.specularGlossinessTexture.getTextureMatrix())) : null !== a.specularColor && d.setColor3("reflectivityColor", a.specularColor), null !== a.glossiness && d.setFloat("glossiness", a.glossiness)) : "PBRMaterial" === a.getClassName() ? (null !== a.metallicTexture && (d.setTexture("reflectivitySampler", a.metallicTexture), d.setMatrix("reflectivityMatrix", a.metallicTexture.getTextureMatrix())), null !== a.metallic && d.setFloat("metallic", a.metallic), null !== a.roughness && d.setFloat("glossiness", 1 - a.roughness), null !== a.roughness || null !== a.metallic || null !== a.metallicTexture ? (null !== a.albedoTexture && (d.setTexture("albedoSampler", a.albedoTexture), d.setMatrix("albedoMatrix", a.albedoTexture.getTextureMatrix())), null !== a.albedoColor && d.setColor3("albedoColor", a.albedoColor)) : (null !== a.reflectivityTexture ? (d.setTexture("reflectivitySampler", a.reflectivityTexture), d.setMatrix("reflectivityMatrix", a.reflectivityTexture.getTextureMatrix())) : null !== a.reflectivityColor && d.setColor3("reflectivityColor", a.reflectivityColor), null !== a.microSurface && d.setFloat("glossiness", a.microSurface))) : "StandardMaterial" === a.getClassName() && (null !== a.specularTexture && (d.setTexture("reflectivitySampler", a.specularTexture), d.setMatrix("reflectivityMatrix", a.specularTexture.getTextureMatrix())), null !== a.specularColor && d.setColor3("reflectivityColor", a.specularColor))), Vn(d, a, t._scene), i.useBones && i.computeBonesUsingShaders && i.skeleton && (d.setMatrices("mBones", i.skeleton.getTransformMatrices(i)), t._enableVelocity && d.setMatrices("mPreviousBones", t._previousBonesTransformationMatrices[i.uniqueId])), zn.BindMorphTargetParameters(i, d), i.morphTargetManager && i.morphTargetManager.isUsingTextureForTargets && i.morphTargetManager._bind(d), t._enableVelocity && (d.setMatrix("previousWorld", t._previousTransformationMatrices[r.uniqueId].world), d.setMatrix("previousViewProjection", t._previousTransformationMatrices[r.uniqueId].viewProjection)), c && i.hasThinInstances && d.setMatrix("world", u), i._processRendering(r, e, d, a.fillMode, l, c, (function (e, t) { e || d.setMatrix("world", t) })) } t._enableVelocity && (t._previousTransformationMatrices[r.uniqueId].world = u.clone(), t._previousTransformationMatrices[r.uniqueId].viewProjection = t._scene.getTransformMatrix().clone(), i.skeleton && t._copyBonesTransformationMatrices(i.skeleton.getTransformMatrices(i), t._previousBonesTransformationMatrices[r.uniqueId])) } } }; this._multiRenderTarget.customIsReadyFunction = function (e, r, n) { if ((n || 0 === r) && e.subMeshes) for (var o = 0; o < e.subMeshes.length; ++o) { var a = e.subMeshes[o], s = a.getMaterial(), l = a.getRenderingMesh(); if (s) { var c = l._getInstancesRenderList(a._id, !!a.getReplacementMesh()), u = i.getCaps().instancedArrays && (null !== c.visibleInstances[a._id] || l.hasThinInstances); if (!t.isReady(a, u)) return !1 } } return !0 }, this._multiRenderTarget.customRenderFunction = function (e, r, n, o) { var a; if (t._linkedWithPrePass) { if (!t._prePassRenderer.enabled) return; t._scene.getEngine().bindAttachments(t._attachmentsFromPrePass) } if (o.length) { for (i.setColorWrite(!1), a = 0; a < o.length; a++)f(o.data[a]); i.setColorWrite(!0) } for (a = 0; a < e.length; a++)f(e.data[a]); for (i.setDepthWrite(!1), a = 0; a < r.length; a++)f(r.data[a]); if (t.renderTransparentMeshes) for (a = 0; a < n.length; a++)f(n.data[a]); i.setDepthWrite(!0) } } }, e.prototype._copyBonesTransformationMatrices = function (e, t) { for (var i = 0; i < e.length; i++)t[i] = e[i]; return t }, e.DEPTH_TEXTURE_TYPE = 0, e.NORMAL_TEXTURE_TYPE = 1, e.POSITION_TEXTURE_TYPE = 2, e.VELOCITY_TEXTURE_TYPE = 3, e.REFLECTIVITY_TEXTURE_TYPE = 4, e._SceneComponentInitialization = function (e) { throw ge("GeometryBufferRendererSceneComponent") }, e }(), WS = function () { this.enabled = !1, this.name = "motionBlur", this.texturesRequired = [a.PREPASS_VELOCITY_TEXTURE_TYPE] }; Object.defineProperty(Sr.prototype, "geometryBufferRenderer", { get: function () { return this._geometryBufferRenderer }, set: function (e) { e && e.isSupported && (this._geometryBufferRenderer = e) }, enumerable: !0, configurable: !0 }), Sr.prototype.enableGeometryBufferRenderer = function (e, t) { return void 0 === e && (e = 1), void 0 === t && (t = a.TEXTUREFORMAT_DEPTH16), this._geometryBufferRenderer || (this._geometryBufferRenderer = new zS(this, e, t), this._geometryBufferRenderer.isSupported || (this._geometryBufferRenderer = null)), this._geometryBufferRenderer }, Sr.prototype.disableGeometryBufferRenderer = function () { this._geometryBufferRenderer && (this._geometryBufferRenderer.dispose(), this._geometryBufferRenderer = null) }; var HS = function () { function e(e) { this.name = qi.NAME_GEOMETRYBUFFERRENDERER, this.scene = e } return e.prototype.register = function () { this.scene._gatherRenderTargetsStage.registerStep(qi.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER, this, this._gatherRenderTargets) }, e.prototype.rebuild = function () { }, e.prototype.dispose = function () { }, e.prototype._gatherRenderTargets = function (e) { this.scene._geometryBufferRenderer && e.push(this.scene._geometryBufferRenderer.getGBuffer()) }, e }(); zS._SceneComponentInitialization = function (e) { var t = e._getComponent(qi.NAME_GEOMETRYBUFFERRENDERER); t || (t = new HS(e), e._addComponent(t)) }; Ut.ShadersStore.motionBlurPixelShader = "varying vec2 vUV;uniform sampler2D textureSampler;uniform float motionStrength;uniform float motionScale;uniform vec2 screenSize;\n#ifdef OBJECT_BASED\nuniform sampler2D velocitySampler;\n#else\nuniform sampler2D depthSampler;uniform mat4 inverseViewProjection;uniform mat4 prevViewProjection;uniform mat4 projection;\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\n#ifdef GEOMETRY_SUPPORTED\n#ifdef OBJECT_BASED\nvec2 texelSize=1.0/screenSize;vec4 velocityColor=texture2D(velocitySampler,vUV);velocityColor.rg=velocityColor.rg*2.0-vec2(1.0);vec2 velocity=vec2(pow(velocityColor.r,3.0),pow(velocityColor.g,3.0))*velocityColor.a;velocity*=motionScale*motionStrength;float speed=length(velocity/texelSize);int samplesCount=int(clamp(speed,1.0,SAMPLES));velocity=normalize(velocity)*texelSize;float hlim=float(-samplesCount)*0.5+0.5;vec4 result=texture2D(textureSampler,vUV);for (int i=1; i=samplesCount)\nbreak;vec2 offset=vUV+velocity*(hlim+float(i));\n#if defined(WEBGPU)\nresult+=texture2DLodEXT(textureSampler,offset,0.0);\n#else\nresult+=texture2D(textureSampler,offset);\n#endif\n}\ngl_FragColor=result/float(samplesCount);gl_FragColor.a=1.0;\n#else\nvec2 texelSize=1.0/screenSize;float depth=texture2D(depthSampler,vUV).r;depth=projection[2].z+projection[3].z/depth; \nvec4 cpos=vec4(vUV*2.0-1.0,depth,1.0);cpos=inverseViewProjection*cpos;cpos/=cpos.w;vec4 ppos=prevViewProjection*cpos;ppos/=ppos.w;ppos.xy=ppos.xy*0.5+0.5;vec2 velocity=(ppos.xy-vUV)*motionScale*motionStrength;float speed=length(velocity/texelSize);int nSamples=int(clamp(speed,1.0,SAMPLES));vec4 result=texture2D(textureSampler,vUV);for (int i=1; i=nSamples)\nbreak;vec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5);\n#if defined(WEBGPU)\nresult+=texture2DLodEXT(textureSampler,offset1,0.0);\n#else\nresult+=texture2D(textureSampler,offset1);\n#endif\n}\ngl_FragColor=result/float(nSamples);\n#endif\n#else\ngl_FragColor=texture2D(textureSampler,vUV);\n#endif\n}\n"; var XS = function (e) { function t(t, i, r, n, o, s, l, c, u, h) { void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT), void 0 === u && (u = !1), void 0 === h && (h = !1); var d = e.call(this, t, "motionBlur", ["motionStrength", "motionScale", "screenSize", "inverseViewProjection", "prevViewProjection", "projection"], ["velocitySampler", "depthSampler"], r, n, o, s, l, "#define GEOMETRY_SUPPORTED\n#define SAMPLES 64.0\n#define OBJECT_BASED", c, void 0, null, u) || this; return d.motionStrength = 1, d._motionBlurSamples = 32, d._isObjectBased = !0, d._forceGeometryBuffer = !1, d._invViewProjection = null, d._previousViewProjection = null, d._forceGeometryBuffer = h, d._forceGeometryBuffer ? (i.enableGeometryBufferRenderer(), d._geometryBufferRenderer && (d._geometryBufferRenderer.enableVelocity = !0)) : (i.enablePrePassRenderer(), d._prePassRenderer && (d._prePassRenderer.markAsDirty(), d._prePassEffectConfiguration = new WS)), d._applyMode(), d } return W(t, e), Object.defineProperty(t.prototype, "motionBlurSamples", { get: function () { return this._motionBlurSamples }, set: function (e) { this._motionBlurSamples = e, this._updateEffect() }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isObjectBased", { get: function () { return this._isObjectBased }, set: function (e) { this._isObjectBased !== e && (this._isObjectBased = e, this._applyMode()) }, enumerable: !1, configurable: !0 }), 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 }), t.prototype.getClassName = function () { return "MotionBlurPostProcess" }, t.prototype.excludeSkinnedMesh = function (e) { if (e.skeleton) { var t = void 0; if (this._geometryBufferRenderer) t = this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity; else { if (!this._prePassRenderer) return; t = this._prePassRenderer.excludedSkinnedMesh } t.push(e) } }, t.prototype.removeExcludedSkinnedMesh = function (e) { if (e.skeleton) { var t = void 0; if (this._geometryBufferRenderer) t = this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity; else { if (!this._prePassRenderer) return; t = this._prePassRenderer.excludedSkinnedMesh } var i = t.indexOf(e); -1 !== i && t.splice(i, 1) } }, t.prototype.dispose = function (t) { this._geometryBufferRenderer && (this._geometryBufferRenderer._previousTransformationMatrices = {}, this._geometryBufferRenderer._previousBonesTransformationMatrices = {}, this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity = []), e.prototype.dispose.call(this, t) }, t.prototype._applyMode = function () { var e = this; if (!this._geometryBufferRenderer && !this._prePassRenderer) return $.Warn("Multiple Render Target support needed to compute object based motion blur"), this.updateEffect(); this._updateEffect(), this._invViewProjection = null, this._previousViewProjection = null, this.isObjectBased ? (this._prePassRenderer && this._prePassEffectConfiguration && (this._prePassEffectConfiguration.texturesRequired[0] = a.PREPASS_VELOCITY_TEXTURE_TYPE), this.onApply = function (t) { return e._onApplyObjectBased(t) }) : (this._invViewProjection = I.Identity(), this._previousViewProjection = this._scene.getTransformMatrix().clone(), this._prePassRenderer && this._prePassEffectConfiguration && (this._prePassEffectConfiguration.texturesRequired[0] = a.PREPASS_DEPTH_TEXTURE_TYPE), this.onApply = function (t) { return e._onApplyScreenBased(t) }) }, t.prototype._onApplyObjectBased = function (e) { if (e.setVector2("screenSize", new A(this.width, this.height)), e.setFloat("motionScale", this._scene.getAnimationRatio()), e.setFloat("motionStrength", this.motionStrength), this._geometryBufferRenderer) { var t = this._geometryBufferRenderer.getTextureIndex(zS.VELOCITY_TEXTURE_TYPE); e.setTexture("velocitySampler", this._geometryBufferRenderer.getGBuffer().textures[t]) } else this._prePassRenderer && (t = this._prePassRenderer.getIndex(a.PREPASS_VELOCITY_TEXTURE_TYPE), e.setTexture("velocitySampler", this._prePassRenderer.getRenderTarget().textures[t])) }, t.prototype._onApplyScreenBased = function (e) { var t = O.Matrix[0]; if (t.copyFrom(this._scene.getTransformMatrix()), t.invertToRef(this._invViewProjection), e.setMatrix("inverseViewProjection", this._invViewProjection), e.setMatrix("prevViewProjection", this._previousViewProjection), this._previousViewProjection.copyFrom(t), e.setMatrix("projection", this._scene.getProjectionMatrix()), e.setVector2("screenSize", new A(this.width, this.height)), e.setFloat("motionScale", this._scene.getAnimationRatio()), e.setFloat("motionStrength", this.motionStrength), this._geometryBufferRenderer) { var i = this._geometryBufferRenderer.getTextureIndex(zS.DEPTH_TEXTURE_TYPE); e.setTexture("depthSampler", this._geometryBufferRenderer.getGBuffer().textures[i]) } else this._prePassRenderer && (i = this._prePassRenderer.getIndex(a.PREPASS_DEPTH_TEXTURE_TYPE), e.setTexture("depthSampler", this._prePassRenderer.getRenderTarget().textures[i])) }, t.prototype._updateEffect = function () { if (this._geometryBufferRenderer || this._prePassRenderer) { var e = ["#define GEOMETRY_SUPPORTED", "#define SAMPLES " + this._motionBlurSamples.toFixed(1), this._isObjectBased ? "#define OBJECT_BASED" : "#define SCREEN_BASED"]; this.updateEffect(e.join("\n")) } }, t._Parse = function (e, i, r, n) { return Ue.Parse((function () { return new t(e.name, r, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.reusable, e.textureType, !1) }), e, r, n) }, X([xe()], t.prototype, "motionStrength", void 0), X([xe()], t.prototype, "motionBlurSamples", null), X([xe()], t.prototype, "isObjectBased", null), t }(Ia); b("BABYLON.MotionBlurPostProcess", XS); Ut.ShadersStore.refractionPixelShader = "varying vec2 vUV;uniform sampler2D textureSampler;uniform sampler2D refractionSampler;uniform vec3 baseColor;uniform float depth;uniform float colorLevel;void main() {float ref=1.0-texture2D(refractionSampler,vUV).r;vec2 uv=vUV-vec2(0.5);vec2 offset=uv*depth*ref;vec3 sourceColor=texture2D(textureSampler,vUV-offset).rgb;gl_FragColor=vec4(sourceColor+sourceColor*ref*colorLevel,1.0);}"; var jS = function (e) { function t(t, i, r, n, o, a, s, l, c, u) { var h = e.call(this, t, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], a, s, l, c, u) || this; return h._ownRefractionTexture = !0, h.color = r, h.depth = n, h.colorLevel = o, h.refractionTextureUrl = i, h.onActivateObservable.add((function (e) { h._refTexture = h._refTexture || new vo(i, e.getScene()) })), h.onApplyObservable.add((function (e) { e.setColor3("baseColor", h.color), e.setFloat("depth", h.depth), e.setFloat("colorLevel", h.colorLevel), e.setTexture("refractionSampler", h._refTexture) })), h } return W(t, e), Object.defineProperty(t.prototype, "refractionTexture", { get: function () { return this._refTexture }, set: function (e) { this._refTexture && this._ownRefractionTexture && this._refTexture.dispose(), this._refTexture = e, this._ownRefractionTexture = !1 }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function () { return "RefractionPostProcess" }, t.prototype.dispose = function (t) { this._refTexture && this._ownRefractionTexture && (this._refTexture.dispose(), this._refTexture = null), e.prototype.dispose.call(this, t) }, t._Parse = function (e, i, r, n) { return Ue.Parse((function () { return new t(e.name, e.refractionTextureUrl, e.color, e.depth, e.colorLevel, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.reusable) }), e, r, n) }, X([xe()], t.prototype, "color", void 0), X([xe()], t.prototype, "depth", void 0), X([xe()], t.prototype, "colorLevel", void 0), X([xe()], t.prototype, "refractionTextureUrl", void 0), t }(Ia); b("BABYLON.RefractionPostProcess", jS); Ut.ShadersStore.sharpenPixelShader = "varying vec2 vUV;uniform sampler2D textureSampler;uniform vec2 screenSize;uniform vec2 sharpnessAmounts;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{vec2 onePixel=vec2(1.0,1.0)/screenSize;vec4 color=texture2D(textureSampler,vUV);vec4 edgeDetection=texture2D(textureSampler,vUV+onePixel*vec2(0,-1)) +\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,0)) +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,0)) +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,1)) -\ncolor*4.0;gl_FragColor=max(vec4(color.rgb*sharpnessAmounts.y,color.a)-(sharpnessAmounts.x*vec4(edgeDetection.rgb,0)),0.);}"; var YS = 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, "sharpen", ["sharpnessAmounts", "screenSize"], null, i, r, n, o, s, null, l, void 0, null, c) || this; return u.colorAmount = 1, u.edgeAmount = .3, u.onApply = function (e) { e.setFloat2("screenSize", u.width, u.height), e.setFloat2("sharpnessAmounts", u.edgeAmount, u.colorAmount) }, u } return W(t, e), t.prototype.getClassName = function () { return "SharpenPostProcess" }, t._Parse = function (e, i, r, n) { return Ue.Parse((function () { return new t(e.name, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.textureType, e.reusable) }), e, r, n) }, X([xe()], t.prototype, "colorAmount", void 0), X([xe()], t.prototype, "edgeAmount", void 0), t }(Ia); b("BABYLON.SharpenPostProcess", YS); var KS = function () { function e(e, t) { this._engine = e, this._name = t, this._renderEffects = {}, this._renderEffectsForIsolatedPass = new Array, this._cameras = [] } return Object.defineProperty(e.prototype, "name", { get: function () { return this._name }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "cameras", { get: function () { return this._cameras }, enumerable: !1, configurable: !0 }), e.prototype.getClassName = function () { return "PostProcessRenderPipeline" }, Object.defineProperty(e.prototype, "isSupported", { get: function () { for (var e in this._renderEffects) if (Object.prototype.hasOwnProperty.call(this._renderEffects, e) && !this._renderEffects[e].isSupported) return !1; return !0 }, enumerable: !1, configurable: !0 }), e.prototype.addEffect = function (e) { this._renderEffects[e._name] = e }, e.prototype._rebuild = function () { }, e.prototype._enableEffect = function (e, t) { var i = this._renderEffects[e]; i && i._enable(xi.MakeArray(t || this._cameras)) }, e.prototype._disableEffect = function (e, t) { var i = this._renderEffects[e]; i && i._disable(xi.MakeArray(t || this._cameras)) }, e.prototype._attachCameras = function (e, t) { var i = xi.MakeArray(e || this._cameras); if (i) { var r, n = []; for (r = 0; r < i.length; r++) { var o = i[r]; o && (-1 === this._cameras.indexOf(o) ? this._cameras.push(o) : t && n.push(r)) } for (r = 0; r < n.length; r++)i.splice(n[r], 1); for (var a in this._renderEffects) Object.prototype.hasOwnProperty.call(this._renderEffects, a) && this._renderEffects[a]._attachCameras(i) } }, e.prototype._detachCameras = function (e) { var t = xi.MakeArray(e || this._cameras); if (t) { for (var i in this._renderEffects) Object.prototype.hasOwnProperty.call(this._renderEffects, i) && this._renderEffects[i]._detachCameras(t); for (var r = 0; r < t.length; r++)this._cameras.splice(this._cameras.indexOf(t[r]), 1) } }, e.prototype._update = function () { for (var e in this._renderEffects) Object.prototype.hasOwnProperty.call(this._renderEffects, e) && this._renderEffects[e]._update(); for (var t = 0; t < this._cameras.length; t++)if (this._cameras[t]) { var i = this._cameras[t].name; this._renderEffectsForIsolatedPass[i] && this._renderEffectsForIsolatedPass[i]._update() } }, e.prototype._reset = function () { this._renderEffects = {}, this._renderEffectsForIsolatedPass = new Array }, e.prototype._enableMSAAOnFirstPostProcess = function (e) { if (!this._engine._features.supportMSAA) return !1; var t = Object.keys(this._renderEffects); if (t.length > 0) { var i = this._renderEffects[t[0]].getPostProcesses(); i && (i[0].samples = e) } return !0 }, e.prototype.setPrePassRenderer = function (e) { return !1 }, e.prototype.dispose = function () { }, X([xe()], e.prototype, "_name", void 0), e }(), QS = function () { function e() { this._renderPipelines = {} } return Object.defineProperty(e.prototype, "supportedPipelines", { get: function () { var e = []; for (var t in this._renderPipelines) if (Object.prototype.hasOwnProperty.call(this._renderPipelines, t)) { var i = this._renderPipelines[t]; i.isSupported && e.push(i) } return e }, enumerable: !1, configurable: !0 }), e.prototype.addPipeline = function (e) { this._renderPipelines[e._name] = e }, e.prototype.removePipeline = function (e) { delete this._renderPipelines[e] }, e.prototype.attachCamerasToRenderPipeline = function (e, t, i) { void 0 === i && (i = !1); var r = this._renderPipelines[e]; r && r._attachCameras(t, i) }, e.prototype.detachCamerasFromRenderPipeline = function (e, t) { var i = this._renderPipelines[e]; i && i._detachCameras(t) }, e.prototype.enableEffectInPipeline = function (e, t, i) { var r = this._renderPipelines[e]; r && r._enableEffect(t, i) }, e.prototype.disableEffectInPipeline = function (e, t, i) { var r = this._renderPipelines[e]; r && r._disableEffect(t, i) }, e.prototype.update = function () { for (var e in this._renderPipelines) if (Object.prototype.hasOwnProperty.call(this._renderPipelines, e)) { var t = this._renderPipelines[e]; t.isSupported ? t._update() : (t.dispose(), delete this._renderPipelines[e]) } }, e.prototype._rebuild = function () { for (var e in this._renderPipelines) Object.prototype.hasOwnProperty.call(this._renderPipelines, e) && this._renderPipelines[e]._rebuild() }, e.prototype.dispose = function () { for (var e in this._renderPipelines) Object.prototype.hasOwnProperty.call(this._renderPipelines, e) && this._renderPipelines[e].dispose() }, e }(); Object.defineProperty(Sr.prototype, "postProcessRenderPipelineManager", { get: function () { if (!this._postProcessRenderPipelineManager) { var e = this._getComponent(qi.NAME_POSTPROCESSRENDERPIPELINEMANAGER); e || (e = new qS(this), this._addComponent(e)), this._postProcessRenderPipelineManager = new QS } return this._postProcessRenderPipelineManager }, enumerable: !0, configurable: !0 }); var qS = function () { function e(e) { this.name = qi.NAME_POSTPROCESSRENDERPIPELINEMANAGER, this.scene = e } return e.prototype.register = function () { this.scene._gatherRenderTargetsStage.registerStep(qi.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets) }, e.prototype.rebuild = function () { this.scene._postProcessRenderPipelineManager && this.scene._postProcessRenderPipelineManager._rebuild() }, e.prototype.dispose = function () { this.scene._postProcessRenderPipelineManager && this.scene._postProcessRenderPipelineManager.dispose() }, e.prototype._gatherRenderTargets = function () { this.scene._postProcessRenderPipelineManager && this.scene._postProcessRenderPipelineManager.update() }, e }(), ZS = function (e) { function t(t, i, r, n, o) { void 0 === t && (t = ""), void 0 === i && (i = !0), void 0 === r && (r = S.LastCreatedScene), void 0 === o && (o = !0); var s = e.call(this, r.getEngine(), t) || this; s._camerasToBeAttached = [], s.SharpenPostProcessId = "SharpenPostProcessEffect", s.ImageProcessingPostProcessId = "ImageProcessingPostProcessEffect", s.FxaaPostProcessId = "FxaaPostProcessEffect", s.ChromaticAberrationPostProcessId = "ChromaticAberrationPostProcessEffect", s.GrainPostProcessId = "GrainPostProcessEffect", s._glowLayer = null, s.animations = [], s._imageProcessingConfigurationObserver = null, s._sharpenEnabled = !1, s._bloomEnabled = !1, s._depthOfFieldEnabled = !1, s._depthOfFieldBlurLevel = NS.Low, s._fxaaEnabled = !1, s._imageProcessingEnabled = !0, s._bloomScale = .5, s._chromaticAberrationEnabled = !1, s._grainEnabled = !1, s._buildAllowed = !0, s.onBuildObservable = new u, s._resizeObserver = null, s._hardwareScaleLevel = 1, s._bloomKernel = 64, s._bloomWeight = .15, s._bloomThreshold = .9, s._samples = 1, s._hasCleared = !1, s._prevPostProcess = null, s._prevPrevPostProcess = null, s._depthOfFieldSceneObserver = null, s._activeCameraChangedObserver = null, s._activeCamerasChangedObserver = null, s._cameras = n || r.cameras, s._cameras = s._cameras.slice(), s._camerasToBeAttached = s._cameras.slice(), s._buildAllowed = o, s._scene = r; var l = s._scene.getEngine().getCaps(); s._hdr = i && (l.textureHalfFloatRender || l.textureFloatRender), s._hdr ? l.textureHalfFloatRender ? s._defaultPipelineTextureType = a.TEXTURETYPE_HALF_FLOAT : l.textureFloatRender && (s._defaultPipelineTextureType = a.TEXTURETYPE_FLOAT) : s._defaultPipelineTextureType = a.TEXTURETYPE_UNSIGNED_INT, r.postProcessRenderPipelineManager.addPipeline(s); var c = s._scene.getEngine(); return s.sharpen = new YS("sharpen", 1, null, vo.BILINEAR_SAMPLINGMODE, c, !1, s._defaultPipelineTextureType, !0), s._sharpenEffect = new xS(c, s.SharpenPostProcessId, (function () { return s.sharpen }), !0), s.depthOfField = new LS(s._scene, null, s._depthOfFieldBlurLevel, s._defaultPipelineTextureType, !0), s._hardwareScaleLevel = c.getHardwareScalingLevel(), s._resizeObserver = c.onResizeObservable.add((function () { s._hardwareScaleLevel = c.getHardwareScalingLevel(), s.bloomKernel = s._bloomKernel })), s.bloom = new CS(s._scene, s._bloomScale, s._bloomWeight, s.bloomKernel / s._hardwareScaleLevel, s._defaultPipelineTextureType, !0), s.chromaticAberration = new PS("ChromaticAberration", c.getRenderWidth(), c.getRenderHeight(), 1, null, vo.BILINEAR_SAMPLINGMODE, c, !1, s._defaultPipelineTextureType, !0), s._chromaticAberrationEffect = new xS(c, s.ChromaticAberrationPostProcessId, (function () { return s.chromaticAberration }), !0), s.grain = new VS("Grain", 1, null, vo.BILINEAR_SAMPLINGMODE, c, !1, s._defaultPipelineTextureType, !0), s._grainEffect = new xS(c, s.GrainPostProcessId, (function () { return s.grain }), !0), s._imageProcessingConfigurationObserver = s._scene.imageProcessingConfiguration.onUpdateParameters.add((function () { s.bloom._downscale._exposure = s._scene.imageProcessingConfiguration.exposure, s.imageProcessingEnabled !== s._scene.imageProcessingConfiguration.isEnabled && (s._imageProcessingEnabled = s._scene.imageProcessingConfiguration.isEnabled, xi.SetImmediate((function () { s._buildPipeline() }))) })), s._buildPipeline(), s } return W(t, e), Object.defineProperty(t.prototype, "automaticBuild", { get: function () { return this._buildAllowed }, set: function (e) { this._buildAllowed = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "scene", { get: function () { return this._scene }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sharpenEnabled", { get: function () { return this._sharpenEnabled }, set: function (e) { this._sharpenEnabled !== e && (this._sharpenEnabled = e, this._buildPipeline()) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "bloomKernel", { get: function () { return this._bloomKernel }, set: function (e) { this._bloomKernel = e, this.bloom.kernel = e / this._hardwareScaleLevel }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "bloomWeight", { get: function () { return this._bloomWeight }, set: function (e) { this._bloomWeight !== e && (this.bloom.weight = e, this._bloomWeight = e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "bloomThreshold", { get: function () { return this._bloomThreshold }, set: function (e) { this._bloomThreshold !== e && (this.bloom.threshold = e, this._bloomThreshold = e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "bloomScale", { get: function () { return this._bloomScale }, set: function (e) { this._bloomScale !== e && (this._bloomScale = e, this._rebuildBloom(), 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 }), t.prototype._rebuildBloom = function () { var e = this.bloom; this.bloom = new CS(this._scene, this.bloomScale, this._bloomWeight, this.bloomKernel / this._hardwareScaleLevel, this._defaultPipelineTextureType, !1), this.bloom.threshold = e.threshold; for (var t = 0; t < this._cameras.length; t++)e.disposeEffects(this._cameras[t]) }, 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, "depthOfFieldBlurLevel", { get: function () { return this._depthOfFieldBlurLevel }, set: function (e) { if (this._depthOfFieldBlurLevel !== e) { this._depthOfFieldBlurLevel = e; var t = this.depthOfField; this.depthOfField = new LS(this._scene, null, this._depthOfFieldBlurLevel, this._defaultPipelineTextureType, !1), this.depthOfField.focalLength = t.focalLength, this.depthOfField.focusDistance = t.focusDistance, this.depthOfField.fStop = t.fStop, this.depthOfField.lensSize = t.lensSize; for (var i = 0; i < this._cameras.length; i++)t.disposeEffects(this._cameras[i]); 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, "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, "imageProcessingEnabled", { get: function () { return this._imageProcessingEnabled }, set: function (e) { this._imageProcessingEnabled !== e && (this._scene.imageProcessingConfiguration.isEnabled = e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "glowLayerEnabled", { get: function () { return null != this._glowLayer }, set: function (e) { e && !this._glowLayer ? this._glowLayer = new Bm("", this._scene) : !e && this._glowLayer && (this._glowLayer.dispose(), this._glowLayer = null) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "glowLayer", { get: function () { return this._glowLayer }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "chromaticAberrationEnabled", { get: function () { return this._chromaticAberrationEnabled }, set: function (e) { this._chromaticAberrationEnabled !== e && (this._chromaticAberrationEnabled = e, this._buildPipeline()) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "grainEnabled", { get: function () { return this._grainEnabled }, set: function (e) { this._grainEnabled !== e && (this._grainEnabled = e, this._buildPipeline()) }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function () { return "DefaultRenderingPipeline" }, t.prototype.prepare = function () { var e = this._buildAllowed; this._buildAllowed = !0, this._buildPipeline(), this._buildAllowed = e }, t.prototype._setAutoClearAndTextureSharing = function (e, t) { void 0 === t && (t = !1), this._hasCleared ? e.autoClear = !1 : (e.autoClear = !0, this._scene.autoClear = !1, this._hasCleared = !0), t || (this._prevPrevPostProcess ? e.shareOutputWith(this._prevPrevPostProcess) : e.useOwnOutput(), this._prevPostProcess && (this._prevPrevPostProcess = this._prevPostProcess), this._prevPostProcess = e) }, t.prototype._buildPipeline = function () { var e = this; if (this._buildAllowed) { this._scene.autoClear = !0; var t = this._scene.getEngine(); if (this._disposePostProcesses(), null !== this._cameras && (this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras), this._cameras = this._camerasToBeAttached.slice()), this._reset(), this._prevPostProcess = null, this._prevPrevPostProcess = null, this._hasCleared = !1, this.depthOfFieldEnabled) { if (this._cameras.length > 1) { for (var i = 0, r = this._cameras; i < r.length; i++) { var n = r[i]; (o = this._scene.enableDepthRenderer(n)).useOnlyInActiveCamera = !0 } this._depthOfFieldSceneObserver = this._scene.onAfterRenderTargetsRenderObservable.add((function (t) { e._cameras.indexOf(t.activeCamera) > -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 bc("imageProcessing", 1, null, vo.BILINEAR_SAMPLINGMODE, t, !1, this._defaultPipelineTextureType, this.scene.imageProcessingConfiguration), this._hdr ? (this.addEffect(new xS(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 US("fxaa", 1, null, vo.BILINEAR_SAMPLINGMODE, t, !1, this._defaultPipelineTextureType), this.addEffect(new xS(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._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; t < this._cameras.length; t++) { var i = this._cameras[t]; this.imageProcessing && this.imageProcessing.dispose(i), this.fxaa && this.fxaa.dispose(i), e && (this.sharpen && this.sharpen.dispose(i), this.depthOfField && (this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver), this.depthOfField.disposeEffects(i)), this.bloom && this.bloom.disposeEffects(i), this.chromaticAberration && this.chromaticAberration.dispose(i), this.grain && this.grain.dispose(i), this._glowLayer && this._glowLayer.dispose()) } this.imageProcessing = null, this.fxaa = null, e && (this.sharpen = null, this._sharpenEffect = null, this.depthOfField = null, this.bloom = null, this.chromaticAberration = null, this._chromaticAberrationEffect = null, this.grain = null, this._grainEffect = null, this._glowLayer = null) }, 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 () { this._buildAllowed = !1, this.onBuildObservable.clear(), this._disposePostProcesses(!0), this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras), this._scene._postProcessRenderPipelineManager.removePipeline(this.name), this._scene.autoClear = !0, this._resizeObserver && (this._scene.getEngine().onResizeObservable.remove(this._resizeObserver), this._resizeObserver = null), this._scene.onActiveCameraChanged.remove(this._activeCameraChangedObserver), this._scene.onActiveCamerasChanged.remove(this._activeCamerasChangedObserver), this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver), e.prototype.dispose.call(this) }, t.prototype.serialize = function () { var e = Ue.Serialize(this); return e.customType = "DefaultRenderingPipeline", e }, t.Parse = function (e, i, r) { return Ue.Parse((function () { return new t(e._name, e._name._hdr, i) }), e, i, r) }, X([xe()], t.prototype, "sharpenEnabled", null), X([xe()], t.prototype, "bloomKernel", null), X([xe()], t.prototype, "_bloomWeight", void 0), X([xe()], t.prototype, "_bloomThreshold", void 0), X([xe()], t.prototype, "_hdr", void 0), X([xe()], t.prototype, "bloomWeight", null), X([xe()], t.prototype, "bloomThreshold", null), X([xe()], t.prototype, "bloomScale", null), X([xe()], t.prototype, "bloomEnabled", null), X([xe()], t.prototype, "depthOfFieldEnabled", null), X([xe()], t.prototype, "depthOfFieldBlurLevel", null), X([xe()], t.prototype, "fxaaEnabled", null), X([xe()], t.prototype, "samples", null), X([xe()], t.prototype, "imageProcessingEnabled", null), X([xe()], t.prototype, "glowLayerEnabled", null), X([xe()], t.prototype, "chromaticAberrationEnabled", null), X([xe()], t.prototype, "grainEnabled", null), t }(KS); b("BABYLON.DefaultRenderingPipeline", ZS); Ut.ShadersStore.lensHighlightsPixelShader = "uniform sampler2D textureSampler; \nuniform float gain;uniform float threshold;uniform float screen_width;uniform float screen_height;varying vec2 vUV;vec4 highlightColor(vec4 color) {vec4 highlight=color;float luminance=dot(highlight.rgb,vec3(0.2125,0.7154,0.0721));float lum_threshold;if (threshold>1.0) { lum_threshold=0.94+0.01*threshold; }\nelse { lum_threshold=0.5+0.44*threshold; }\nluminance=clamp((luminance-lum_threshold)*(1.0/(1.0-lum_threshold)),0.0,1.0);highlight*=luminance*gain;highlight.a=1.0;return highlight;}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{vec4 original=texture2D(textureSampler,vUV);if (gain==-1.0) {gl_FragColor=vec4(0.0,0.0,0.0,1.0);return;}\nfloat w=2.0/screen_width;float h=2.0/screen_height;float weight=1.0;vec4 blurred=vec4(0.0,0.0,0.0,0.0);\n#ifdef PENTAGON\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.84*w,0.43*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.48*w,-1.29*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.61*w,1.51*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.55*w,-0.74*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.71*w,-0.52*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.94*w,1.59*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.40*w,-1.87*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.62*w,1.16*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.09*w,0.25*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.46*w,-1.71*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.08*w,2.42*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.85*w,-1.89*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.89*w,0.16*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.29*w,1.88*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.40*w,-2.81*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.54*w,2.26*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.60*w,-0.61*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.31*w,-1.30*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.83*w,2.53*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.12*w,-2.48*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.60*w,1.11*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.99*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.50*w,-2.81*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.85*w,3.33*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.94*w,-1.92*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.27*w,-0.53*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.95*w,2.48*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.23*w,-3.04*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.17*w,2.05*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.97*w,-0.04*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.25*w,-2.00*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.31*w,3.08*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.94*w,-2.59*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.37*w,0.64*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.13*w,1.93*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.03*w,-3.65*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.60*w,3.17*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.14*w,-1.19*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.00*w,-1.19*h)));\n#else\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.85*w,0.36*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.52*w,-1.14*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.46*w,1.42*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.46*w,-0.83*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.79*w,-0.42*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.11*w,1.62*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.29*w,-2.07*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.69*w,1.39*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.28*w,0.12*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.65*w,-1.69*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.08*w,2.44*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.63*w,-1.90*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.55*w,0.31*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.13*w,1.52*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.56*w,-2.61*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.38*w,2.34*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.64*w,-0.81*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.53*w,-1.21*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.06*w,2.63*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.00*w,-2.69*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.59*w,1.32*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.78*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.57*w,-2.50*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.54*w,2.93*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.39*w,-1.81*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,-0.28*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.04*w,2.25*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.02*w,-3.05*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.09*w,2.25*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.07*w,-0.25*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.44*w,-1.90*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.52*w,3.05*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.68*w,-2.61*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,0.79*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.76*w,1.46*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.05*w,-2.94*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.21*w,2.88*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.84*w,-1.30*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.98*w,-0.96*h)));\n#endif\nblurred/=39.0;gl_FragColor=blurred;}"; Ut.ShadersStore.depthOfFieldPixelShader = "uniform sampler2D textureSampler;uniform sampler2D highlightsSampler;uniform sampler2D depthSampler;uniform sampler2D grainSampler;uniform float grain_amount;uniform bool blur_noise;uniform float screen_width;uniform float screen_height;uniform float distortion;uniform bool dof_enabled;uniform float screen_distance; \nuniform float aperture;uniform float darken;uniform float edge_blur;uniform bool highlights;uniform float near;uniform float far;varying vec2 vUV;\n#define PI 3.14159265\n#define TWOPI 6.28318530\n#define inverse_focal_length 0.1 \nvec2 centered_screen_pos;vec2 distorted_coords;float radius2;float radius;vec2 rand(vec2 co)\n{float noise1=(fract(sin(dot(co,vec2(12.9898,78.233)))*43758.5453));float noise2=(fract(sin(dot(co,vec2(12.9898,78.233)*2.0))*43758.5453));return clamp(vec2(noise1,noise2),0.0,1.0);}\nvec2 getDistortedCoords(vec2 coords) {if (distortion==0.0) { return coords; }\nvec2 direction=1.0*normalize(centered_screen_pos);vec2 dist_coords=vec2(0.5,0.5);dist_coords.x=0.5+direction.x*radius2*1.0;dist_coords.y=0.5+direction.y*radius2*1.0;float dist_amount=clamp(distortion*0.23,0.0,1.0);dist_coords=mix(coords,dist_coords,dist_amount);return dist_coords;}\nfloat sampleScreen(inout vec4 color,in vec2 offset,in float weight) {vec2 coords=distorted_coords;float angle=rand(coords*100.0).x*TWOPI;coords+=vec2(offset.x*cos(angle)-offset.y*sin(angle),offset.x*sin(angle)+offset.y*cos(angle));color+=texture2D(textureSampler,coords)*weight;return weight;}\nfloat getBlurLevel(float size) {return min(3.0,ceil(size/1.0));}\nvec4 getBlurColor(float size) {vec4 col=texture2D(textureSampler,distorted_coords);float blur_level=getBlurLevel(size);float w=(size/screen_width);float h=(size/screen_height);float total_weight=1.0;vec2 sample_coords;total_weight+=sampleScreen(col,vec2(-0.50*w,0.24*h),0.93);total_weight+=sampleScreen(col,vec2(0.30*w,-0.75*h),0.90);total_weight+=sampleScreen(col,vec2(0.36*w,0.96*h),0.87);total_weight+=sampleScreen(col,vec2(-1.08*w,-0.55*h),0.85);total_weight+=sampleScreen(col,vec2(1.33*w,-0.37*h),0.83);total_weight+=sampleScreen(col,vec2(-0.82*w,1.31*h),0.80);total_weight+=sampleScreen(col,vec2(-0.31*w,-1.67*h),0.78);total_weight+=sampleScreen(col,vec2(1.47*w,1.11*h),0.76);total_weight+=sampleScreen(col,vec2(-1.97*w,0.19*h),0.74);total_weight+=sampleScreen(col,vec2(1.42*w,-1.57*h),0.72);if (blur_level>1.0) {total_weight+=sampleScreen(col,vec2(0.01*w,2.25*h),0.70);total_weight+=sampleScreen(col,vec2(-1.62*w,-1.74*h),0.67);total_weight+=sampleScreen(col,vec2(2.49*w,0.20*h),0.65);total_weight+=sampleScreen(col,vec2(-2.07*w,1.61*h),0.63);total_weight+=sampleScreen(col,vec2(0.46*w,-2.70*h),0.61);total_weight+=sampleScreen(col,vec2(1.55*w,2.40*h),0.59);total_weight+=sampleScreen(col,vec2(-2.88*w,-0.75*h),0.56);total_weight+=sampleScreen(col,vec2(2.73*w,-1.44*h),0.54);total_weight+=sampleScreen(col,vec2(-1.08*w,3.02*h),0.52);total_weight+=sampleScreen(col,vec2(-1.28*w,-3.05*h),0.49);}\nif (blur_level>2.0) {total_weight+=sampleScreen(col,vec2(3.11*w,1.43*h),0.46);total_weight+=sampleScreen(col,vec2(-3.36*w,1.08*h),0.44);total_weight+=sampleScreen(col,vec2(1.80*w,-3.16*h),0.41);total_weight+=sampleScreen(col,vec2(0.83*w,3.65*h),0.38);total_weight+=sampleScreen(col,vec2(-3.16*w,-2.19*h),0.34);total_weight+=sampleScreen(col,vec2(3.92*w,-0.53*h),0.31);total_weight+=sampleScreen(col,vec2(-2.59*w,3.12*h),0.26);total_weight+=sampleScreen(col,vec2(-0.20*w,-4.15*h),0.22);total_weight+=sampleScreen(col,vec2(3.02*w,3.00*h),0.15);}\ncol/=total_weight; \nif (darken>0.0) {col.rgb*=clamp(0.3,1.0,1.05-size*0.5*darken);}\nreturn col;}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{centered_screen_pos=vec2(vUV.x-0.5,vUV.y-0.5);radius2=centered_screen_pos.x*centered_screen_pos.x+centered_screen_pos.y*centered_screen_pos.y;radius=sqrt(radius2);distorted_coords=getDistortedCoords(vUV); \nvec2 texels_coords=vec2(vUV.x*screen_width,vUV.y*screen_height); \nfloat depth=texture2D(depthSampler,distorted_coords).r; \nfloat distance=near+(far-near)*depth; \nvec4 color=texture2D(textureSampler,vUV); \nfloat coc=abs(aperture*(screen_distance*(inverse_focal_length-1.0/distance)-1.0));if (dof_enabled==false || coc<0.07) { coc=0.0; }\nfloat edge_blur_amount=0.0;if (edge_blur>0.0) {edge_blur_amount=clamp((radius*2.0-1.0+0.15*edge_blur)*1.5,0.0,1.0)*1.3;}\nfloat blur_amount=max(edge_blur_amount,coc);if (blur_amount==0.0) {gl_FragColor=texture2D(textureSampler,distorted_coords);}\nelse {gl_FragColor=getBlurColor(blur_amount*1.7);if (highlights) {gl_FragColor.rgb+=clamp(coc,0.0,1.0)*texture2D(highlightsSampler,distorted_coords).rgb;}\nif (blur_noise) {vec2 noise=rand(distorted_coords)*0.01*blur_amount;vec2 blurred_coord=vec2(distorted_coords.x+noise.x,distorted_coords.y+noise.y);gl_FragColor=0.04*texture2D(textureSampler,blurred_coord)+0.96*gl_FragColor;}}\nif (grain_amount>0.0) {vec4 grain_color=texture2D(grainSampler,texels_coords*0.003);gl_FragColor.rgb+=(-0.5+grain_color.rgb)*0.30*grain_amount;}}\n"; var JS = function (e) { function t(t, i, r, n, o) { void 0 === n && (n = 1); var a = e.call(this, r.getEngine(), t) || this; return a.LensChromaticAberrationEffect = "LensChromaticAberrationEffect", a.HighlightsEnhancingEffect = "HighlightsEnhancingEffect", a.LensDepthOfFieldEffect = "LensDepthOfFieldEffect", a._pentagonBokehIsEnabled = !1, a._scene = r, a._depthTexture = r.enableDepthRenderer().getDepthMap(), i.grain_texture ? a._grainTexture = i.grain_texture : a._createGrainTexture(), a._edgeBlur = i.edge_blur ? i.edge_blur : 0, a._grainAmount = i.grain_amount ? i.grain_amount : 0, a._chromaticAberration = i.chromatic_aberration ? i.chromatic_aberration : 0, a._distortion = i.distortion ? i.distortion : 0, a._highlightsGain = void 0 !== i.dof_gain ? i.dof_gain : -1, a._highlightsThreshold = i.dof_threshold ? i.dof_threshold : 1, a._dofDistance = void 0 !== i.dof_focus_distance ? i.dof_focus_distance : -1, a._dofAperture = i.dof_aperture ? i.dof_aperture : 1, a._dofDarken = i.dof_darken ? i.dof_darken : 0, a._dofPentagon = void 0 === i.dof_pentagon || i.dof_pentagon, a._blurNoise = void 0 === i.blur_noise || i.blur_noise, a._createChromaticAberrationPostProcess(n), a._createHighlightsPostProcess(n), a._createDepthOfFieldPostProcess(n / 4), a.addEffect(new xS(r.getEngine(), a.LensChromaticAberrationEffect, (function () { return a._chromaticAberrationPostProcess }), !0)), a.addEffect(new xS(r.getEngine(), a.HighlightsEnhancingEffect, (function () { return a._highlightsPostProcess }), !0)), a.addEffect(new xS(r.getEngine(), a.LensDepthOfFieldEffect, (function () { return a._depthOfFieldPostProcess }), !0)), -1 === a._highlightsGain && a._disableEffect(a.HighlightsEnhancingEffect, null), r.postProcessRenderPipelineManager.addPipeline(a), o && r.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(t, o), a } return W(t, e), t.prototype.getClassName = function () { return "LensRenderingPipeline" }, Object.defineProperty(t.prototype, "scene", { get: function () { return this._scene }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "edgeBlur", { get: function () { return this._edgeBlur }, set: function (e) { this.setEdgeBlur(e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "grainAmount", { get: function () { return this._grainAmount }, set: function (e) { this.setGrainAmount(e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "chromaticAberration", { get: function () { return this._chromaticAberration }, set: function (e) { this.setChromaticAberration(e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dofAperture", { get: function () { return this._dofAperture }, set: function (e) { this.setAperture(e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "edgeDistortion", { get: function () { return this._distortion }, set: function (e) { this.setEdgeDistortion(e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dofDistortion", { get: function () { return this._dofDistance }, set: function (e) { this.setFocusDistance(e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "darkenOutOfFocus", { get: function () { return this._dofDarken }, set: function (e) { this.setDarkenOutOfFocus(e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "blurNoise", { get: function () { return this._blurNoise }, set: function (e) { this._blurNoise = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "pentagonBokeh", { get: function () { return this._pentagonBokehIsEnabled }, set: function (e) { e ? this.enablePentagonBokeh() : this.disablePentagonBokeh() }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "highlightsGain", { get: function () { return this._highlightsGain }, set: function (e) { this.setHighlightsGain(e) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "highlightsThreshold", { get: function () { return this._highlightsThreshold }, set: function (e) { this.setHighlightsThreshold(e) }, enumerable: !1, configurable: !0 }), t.prototype.setEdgeBlur = function (e) { this._edgeBlur = e }, t.prototype.disableEdgeBlur = function () { this._edgeBlur = 0 }, t.prototype.setGrainAmount = function (e) { this._grainAmount = e }, t.prototype.disableGrain = function () { this._grainAmount = 0 }, t.prototype.setChromaticAberration = function (e) { this._chromaticAberration = e }, t.prototype.disableChromaticAberration = function () { this._chromaticAberration = 0 }, t.prototype.setEdgeDistortion = function (e) { this._distortion = e }, t.prototype.disableEdgeDistortion = function () { this._distortion = 0 }, t.prototype.setFocusDistance = function (e) { this._dofDistance = e }, t.prototype.disableDepthOfField = function () { this._dofDistance = -1 }, t.prototype.setAperture = function (e) { this._dofAperture = e }, t.prototype.setDarkenOutOfFocus = function (e) { this._dofDarken = e }, t.prototype.enablePentagonBokeh = function () { this._highlightsPostProcess.updateEffect("#define PENTAGON\n"), this._pentagonBokehIsEnabled = !0 }, t.prototype.disablePentagonBokeh = function () { this._pentagonBokehIsEnabled = !1, this._highlightsPostProcess.updateEffect() }, t.prototype.enableNoiseBlur = function () { this._blurNoise = !0 }, t.prototype.disableNoiseBlur = function () { this._blurNoise = !1 }, t.prototype.setHighlightsGain = function (e) { this._highlightsGain = e }, t.prototype.setHighlightsThreshold = function (e) { -1 === this._highlightsGain && (this._highlightsGain = 1), this._highlightsThreshold = e }, t.prototype.disableHighlights = function () { this._highlightsGain = -1 }, t.prototype.dispose = function (e) { void 0 === e && (e = !1), this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras), this._chromaticAberrationPostProcess = null, this._highlightsPostProcess = null, this._depthOfFieldPostProcess = null, this._grainTexture.dispose(), e && this._scene.disableDepthRenderer() }, t.prototype._createChromaticAberrationPostProcess = function (e) { var t = this; this._chromaticAberrationPostProcess = new Ia("LensChromaticAberration", "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], [], e, null, vo.TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1), this._chromaticAberrationPostProcess.onApply = function (e) { e.setFloat("chromatic_aberration", t._chromaticAberration), e.setFloat("screen_width", t._scene.getEngine().getRenderWidth()), e.setFloat("screen_height", t._scene.getEngine().getRenderHeight()), e.setFloat("radialIntensity", 1), e.setFloat2("direction", 17, 17), e.setFloat2("centerPosition", .5, .5) } }, t.prototype._createHighlightsPostProcess = function (e) { var t = this; this._highlightsPostProcess = new Ia("LensHighlights", "lensHighlights", ["gain", "threshold", "screen_width", "screen_height"], [], e, null, vo.TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, this._dofPentagon ? "#define PENTAGON\n" : ""), this._highlightsPostProcess.externalTextureSamplerBinding = !0, this._highlightsPostProcess.onApply = function (e) { e.setFloat("gain", t._highlightsGain), e.setFloat("threshold", t._highlightsThreshold), e.setTextureFromPostProcess("textureSampler", t._chromaticAberrationPostProcess), e.setFloat("screen_width", t._scene.getEngine().getRenderWidth()), e.setFloat("screen_height", t._scene.getEngine().getRenderHeight()) } }, t.prototype._createDepthOfFieldPostProcess = function (e) { var t = this; this._depthOfFieldPostProcess = new Ia("LensDepthOfField", "depthOfField", ["grain_amount", "blur_noise", "screen_width", "screen_height", "distortion", "dof_enabled", "screen_distance", "aperture", "darken", "edge_blur", "highlights", "near", "far"], ["depthSampler", "grainSampler", "highlightsSampler"], e, null, vo.TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1), this._depthOfFieldPostProcess.externalTextureSamplerBinding = !0, this._depthOfFieldPostProcess.onApply = function (e) { e.setTexture("depthSampler", t._depthTexture), e.setTexture("grainSampler", t._grainTexture), e.setTextureFromPostProcess("textureSampler", t._highlightsPostProcess), e.setTextureFromPostProcess("highlightsSampler", t._depthOfFieldPostProcess), e.setFloat("grain_amount", t._grainAmount), e.setBool("blur_noise", t._blurNoise), e.setFloat("screen_width", t._scene.getEngine().getRenderWidth()), e.setFloat("screen_height", t._scene.getEngine().getRenderHeight()), e.setFloat("distortion", t._distortion), e.setBool("dof_enabled", -1 !== t._dofDistance), e.setFloat("screen_distance", 1 / (.1 - 1 / t._dofDistance)), e.setFloat("aperture", t._dofAperture), e.setFloat("darken", t._dofDarken), e.setFloat("edge_blur", t._edgeBlur), e.setBool("highlights", -1 !== t._highlightsGain), t._scene.activeCamera && (e.setFloat("near", t._scene.activeCamera.minZ), e.setFloat("far", t._scene.activeCamera.maxZ)) } }, t.prototype._createGrainTexture = function () { this._grainTexture = new gc("LensNoiseTexture", 512, this._scene, !1, vo.BILINEAR_SAMPLINGMODE), this._grainTexture.wrapU = vo.WRAP_ADDRESSMODE, this._grainTexture.wrapV = vo.WRAP_ADDRESSMODE; for (var e, t = this._grainTexture.getContext(), i = 0; i < 512; i++)for (var r = 0; r < 512; r++)e = Math.floor(255 * (.42, .58, Math.random() * (.58 - .42) + .42)), t.fillStyle = "rgb(" + e + ", " + e + ", " + e + ")", t.fillRect(i, r, 1, 1); this._grainTexture.update(!1) }, t }(KS), $S = function () { this.enabled = !1, this.name = "ssao2", this.texturesRequired = [a.PREPASS_NORMAL_TEXTURE_TYPE, a.PREPASS_DEPTH_TEXTURE_TYPE] }; Ut.ShadersStore.ssao2PixelShader = "precision highp float;uniform sampler2D textureSampler;varying vec2 vUV;\n#ifdef SSAO\nfloat scales[16]=float[16](\n0.1,\n0.11406250000000001,\n0.131640625,\n0.15625,\n0.187890625,\n0.2265625,\n0.272265625,\n0.325,\n0.384765625,\n0.4515625,\n0.525390625,\n0.60625,\n0.694140625,\n0.7890625,\n0.891015625,\n1.0\n);uniform float near;uniform float radius;uniform sampler2D depthSampler;uniform sampler2D randomSampler;uniform sampler2D normalSampler;uniform float randTextureTiles;uniform float samplesFactor;uniform vec3 sampleSphere[SAMPLES];uniform float totalStrength;uniform float base;uniform float xViewport;uniform float yViewport;uniform mat3 depthProjection;uniform float maxZ;uniform float minZAspect;uniform vec2 texelSize;uniform mat4 projection;void main()\n{vec3 random=textureLod(randomSampler,vUV*randTextureTiles,0.0).rgb;float depth=textureLod(depthSampler,vUV,0.0).r;float depthSign=depth/abs(depth);depth=depth*depthSign;vec3 normal=textureLod(normalSampler,vUV,0.0).rgb;float occlusion=0.0;float correctedRadius=min(radius,minZAspect*depth/near);vec3 vViewRay=vec3((vUV.x*2.0-1.0)*xViewport,(vUV.y*2.0-1.0)*yViewport,depthSign);vec3 vDepthFactor=depthProjection*vec3(1.0,1.0,depth);vec3 origin=vViewRay*vDepthFactor;vec3 rvec=random*2.0-1.0;rvec.z=0.0;float dotProduct=dot(rvec,normal);rvec=1.0-abs(dotProduct)>1e-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; i 0 ? 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; r < t;) { if (t < 16) e = this._hemisphereSample_uniform(Math.random(), Math.random()); else { var n = this._hammersley(r, t); e = this._hemisphereSample_uniform(n[0], n[1]) } i.push(e.x, e.y, e.z), r++ } return i }, t.prototype._getDefinesForSSAO = function () { return "#define SSAO\n#define SAMPLES ".concat(this.samples, "\n#define EPSILON ").concat(this.epsilon.toFixed(4)) }, t.prototype._createSSAOPostProcess = function (e, i) { var r = this; this._sampleSphere = this._generateHemisphere(); var n = this._getDefinesForSSAO(); this._ssaoPostProcess = new Ia("ssao2", "ssao2", ["sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius", "base", "range", "projection", "near", "texelSize", "xViewport", "yViewport", "maxZ", "minZAspect", "depthProjection"], ["randomSampler", "depthSampler", "normalSampler"], e, null, vo.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, n, i), this._ssaoPostProcess.onApply = function (e) { var i, n, o, s; if (r._scene.activeCamera) { if (e.setArray3("sampleSphere", r._sampleSphere), e.setFloat("randTextureTiles", 32), e.setFloat("samplesFactor", 1 / r.samples), e.setFloat("totalStrength", r.totalStrength), e.setFloat2("texelSize", 1 / r._ssaoPostProcess.width, 1 / r._ssaoPostProcess.height), e.setFloat("radius", r.radius), e.setFloat("maxZ", r.maxZ), e.setFloat("minZAspect", r.minZAspect), e.setFloat("base", r.base), e.setFloat("near", r._scene.activeCamera.minZ), r._scene.activeCamera.mode === ln.PERSPECTIVE_CAMERA) e.setMatrix3x3("depthProjection", t.PERSPECTIVE_DEPTH_PROJECTION), e.setFloat("xViewport", Math.tan(r._scene.activeCamera.fov / 2) * r._scene.getEngine().getAspectRatio(r._scene.activeCamera, !0)), e.setFloat("yViewport", Math.tan(r._scene.activeCamera.fov / 2)); else { var l = r._scene.getEngine().getRenderWidth() / 2, c = r._scene.getEngine().getRenderHeight() / 2, u = null !== (i = r._scene.activeCamera.orthoLeft) && void 0 !== i ? i : -l, h = null !== (n = r._scene.activeCamera.orthoRight) && void 0 !== n ? n : l, d = null !== (o = r._scene.activeCamera.orthoBottom) && void 0 !== o ? o : -c, p = null !== (s = r._scene.activeCamera.orthoTop) && void 0 !== s ? s : c; e.setMatrix3x3("depthProjection", t.ORTHO_DEPTH_PROJECTION), e.setFloat("xViewport", .5 * (h - u)), e.setFloat("yViewport", .5 * (p - d)) } e.setMatrix("projection", r._scene.getProjectionMatrix()), r._geometryBufferRenderer ? (e.setTexture("depthSampler", r._geometryBufferRenderer.getGBuffer().textures[0]), e.setTexture("normalSampler", r._geometryBufferRenderer.getGBuffer().textures[1])) : r._prePassRenderer && (e.setTexture("depthSampler", r._prePassRenderer.getRenderTarget().textures[r._prePassRenderer.getIndex(a.PREPASS_DEPTH_TEXTURE_TYPE)]), e.setTexture("normalSampler", r._prePassRenderer.getRenderTarget().textures[r._prePassRenderer.getIndex(a.PREPASS_NORMAL_TEXTURE_TYPE)])), e.setTexture("randomSampler", r._randomTexture) } }, this._ssaoPostProcess.samples = this.textureSamples, this._forceGeometryBuffer || (this._ssaoPostProcess._prePassEffectConfiguration = new $S) }, t.prototype._createSSAOCombinePostProcess = function (e, t) { var i = this; this._ssaoCombinePostProcess = new Ia("ssaoCombine", "ssaoCombine", [], ["originalColor", "viewport"], e, null, vo.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, void 0, t), this._ssaoCombinePostProcess.onApply = function (e) { var t = i._scene.activeCamera.viewport; e.setVector4("viewport", O.Vector4[0].copyFromFloats(t.x, t.y, t.width, t.height)), e.setTextureFromPostProcessOutput("originalColor", i._originalColorPostProcess) }, this._ssaoCombinePostProcess.samples = this.textureSamples }, t.prototype._createRandomTexture = function () { this._randomTexture = new gc("SSAORandomTexture", 128, this._scene, !1, vo.BILINEAR_SAMPLINGMODE), this._randomTexture.wrapU = vo.WRAP_ADDRESSMODE, this._randomTexture.wrapV = vo.WRAP_ADDRESSMODE; for (var e = this._randomTexture.getContext(), t = function (e, t) { return Math.random() * (t - e) + e }, i = R.Zero(), r = 0; r < 128; r++)for (var n = 0; n < 128; n++)i.x = t(0, 1), i.y = t(0, 1), i.z = 0, i.normalize(), i.scaleInPlace(255), i.x = Math.floor(i.x), i.y = Math.floor(i.y), e.fillStyle = "rgb(" + i.x + ", " + i.y + ", " + i.z + ")", e.fillRect(r, n, 1, 1); this._randomTexture.update(!1) }, t.prototype.serialize = function () { var e = Ue.Serialize(this); return e.customType = "SSAO2RenderingPipeline", e }, t.Parse = function (e, i, r) { return Ue.Parse((function () { return new t(e._name, i, e._ratio, void 0, e._forceGeometryBuffer, e._textureType) }), e, i, r) }, t.ORTHO_DEPTH_PROJECTION = [1, 0, 0, 0, 1, 0, 0, 0, 1], t.PERSPECTIVE_DEPTH_PROJECTION = [0, 0, 0, 0, 0, 0, 1, 1, 1], X([xe()], t.prototype, "totalStrength", void 0), X([xe()], t.prototype, "maxZ", void 0), X([xe()], t.prototype, "minZAspect", void 0), X([xe("epsilon")], t.prototype, "_epsilon", void 0), X([xe("samples")], t.prototype, "_samples", void 0), X([xe("textureSamples")], t.prototype, "_textureSamples", void 0), X([xe()], t.prototype, "_forceGeometryBuffer", void 0), X([xe()], t.prototype, "_ratio", void 0), X([xe()], t.prototype, "_textureType", void 0), X([xe()], t.prototype, "radius", void 0), X([xe()], t.prototype, "base", void 0), X([xe("bypassBlur")], t.prototype, "_bypassBlur", void 0), X([xe("expensiveBlur")], t.prototype, "_expensiveBlur", void 0), X([xe()], t.prototype, "bilateralSamples", void 0), X([xe()], t.prototype, "bilateralSoften", void 0), X([xe()], t.prototype, "bilateralTolerance", void 0), t }(KS); b("BABYLON.SSAO2RenderingPipeline", ex); Ut.ShadersStore.ssaoPixelShader = "uniform sampler2D textureSampler;varying vec2 vUV;\n#ifdef SSAO\nuniform sampler2D randomSampler;uniform float randTextureTiles;uniform float samplesFactor;uniform vec3 sampleSphere[SAMPLES];uniform float totalStrength;uniform float radius;uniform float area;uniform float fallOff;uniform float base;vec3 normalFromDepth(float depth,vec2 coords)\n{vec2 offset1=vec2(0.0,radius);vec2 offset2=vec2(radius,0.0);float depth1=texture2D(textureSampler,coords+offset1).r;float depth2=texture2D(textureSampler,coords+offset2).r;vec3 p1=vec3(offset1,depth1-depth);vec3 p2=vec3(offset2,depth2-depth);vec3 normal=cross(p1,p2);normal.z=-normal.z;return normalize(normal);}\nvoid main()\n{vec3 random=normalize(texture2D(randomSampler,vUV*randTextureTiles).rgb);float depth=texture2D(textureSampler,vUV).r;vec3 position=vec3(vUV,depth);vec3 normal=normalFromDepth(depth,vUV);float radiusDepth=radius/depth;float occlusion=0.0;vec3 ray;vec3 hemiRay;float occlusionDepth;float difference;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 Ue.Parse((function () { return new t(e.name, r, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.textureType, e.reusable) }), e, r, n) }, X([xe()], t.prototype, "threshold", void 0), X([xe()], t.prototype, "strength", void 0), X([xe()], t.prototype, "reflectionSpecularFalloffExponent", void 0), X([xe()], t.prototype, "step", void 0), X([xe()], t.prototype, "roughnessFactor", void 0), X([xe()], t.prototype, "enableSmoothReflections", null), X([xe()], t.prototype, "reflectionSamples", null), X([xe()], t.prototype, "smoothSteps", null), t }(Ia); b("BABYLON.ScreenSpaceReflectionPostProcess", rx); Ut.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 nx = 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 rx("HDRPass", i, t, null, vo.BILINEAR_SAMPLINGMODE, i.getEngine(), !1, this._floatTextureType), this.screenSpaceReflectionPostProcess.onApplyObservable.add((function () { e._currentDepthOfFieldSource = e.screenSpaceReflectionPostProcess })), this.addEffect(new xS(i.getEngine(), "HDRScreenSpaceReflections", (function () { return e.screenSpaceReflectionPostProcess }), !0))), this._basePostProcess ? this.originalPostProcess = this._basePostProcess : this.originalPostProcess = new Ia("HDRPass", "standard", [], [], t, null, vo.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 xS(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 Ia("HDRDepthOfFieldSource", "standard", [], [], t, null, vo.BILINEAR_SAMPLINGMODE, i.getEngine(), !1, "#define PASS_POST_PROCESS", a.TEXTURETYPE_UNSIGNED_INT), this.addEffect(new xS(i.getEngine(), "HDRBaseDepthOfFieldSource", (function () { return e.textureAdderFinalPostProcess }), !0))), this._vlsEnabled && (this._createVolumetricLightPostProcess(i, t), this.volumetricLightFinalPostProcess = new Ia("HDRVLSFinal", "standard", [], [], t, null, vo.BILINEAR_SAMPLINGMODE, i.getEngine(), !1, "#define PASS_POST_PROCESS", a.TEXTURETYPE_UNSIGNED_INT), this.addEffect(new xS(i.getEngine(), "HDRVLSFinal", (function () { return e.volumetricLightFinalPostProcess }), !0))), this._lensFlareEnabled && (this._createLensFlarePostProcess(i, t), this.lensFlareFinalPostProcess = new Ia("HDRPostLensFlareDepthOfFieldSource", "standard", [], [], t, null, vo.BILINEAR_SAMPLINGMODE, i.getEngine(), !1, "#define PASS_POST_PROCESS", a.TEXTURETYPE_UNSIGNED_INT), this.addEffect(new xS(i.getEngine(), "HDRPostLensFlareDepthOfFieldSource", (function () { return e.lensFlareFinalPostProcess }), !0))), this._hdrEnabled && (this._createLuminancePostProcesses(i, this._floatTextureType), this._createHdrPostProcess(i, t), this.hdrFinalPostProcess = new Ia("HDRPostHDReDepthOfFieldSource", "standard", [], [], t, null, vo.BILINEAR_SAMPLINGMODE, i.getEngine(), !1, "#define PASS_POST_PROCESS", a.TEXTURETYPE_UNSIGNED_INT), this.addEffect(new xS(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 US("fxaa", 1, null, vo.BILINEAR_SAMPLINGMODE, i.getEngine(), !1, a.TEXTURETYPE_UNSIGNED_INT), this.addEffect(new xS(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 Ia("HDRDownSampleX4", "standard", ["dsOffsets"], [], t, null, vo.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 xS(e.getEngine(), "HDRDownSampleX4", (function () { return i.downSampleX4PostProcess }), !0)) }, t.prototype._createBrightPassPostProcess = function (e, t) { var i = this, r = new Array(8); this.brightPassPostProcess = new Ia("HDRBrightPass", "standard", ["dsOffsets", "brightThreshold"], [], t, null, vo.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 xS(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 c_("HDRBlurH_" + i, new A(1, 0), this[r], t, null, vo.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, this._floatTextureType), s = new c_("HDRBlurV_" + i, new A(0, 1), this[r], t, null, vo.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 xS(e.getEngine(), "HDRBlurH" + i, (function () { return a }), !0)), this.addEffect(new xS(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 Ia("HDRTextureAdder", "standard", ["exposure"], ["otherSampler", "lensSampler"], t, null, vo.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 xS(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 Ia("HDRVLS", "standard", ["shadowViewProjection", "cameraPosition", "sunDirection", "sunColor", "scatteringCoefficient", "scatteringPower", "depthValues"], ["shadowMapSampler", "positionSampler"], t / 8, null, vo.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 xS(e.getEngine(), "HDRVLS", (function () { return i.volumetricLightPostProcess }), !0)), this._createBlurPostProcesses(e, t / 4, 0, "volumetricLightBlurScale"), this.volumetricLightMergePostProces = new Ia("HDRVLSMerge", "standard", [], ["originalSampler"], t, null, vo.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 xS(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 Ia("HDRLuminance", "standard", ["lumOffsets"], [], { width: n, height: n }, null, vo.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 xS(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 Ia("HDRLuminanceDownSample" + a, "standard", ["dsOffsets", "halfDestPixelSize"], [], { width: n, height: n }, null, vo.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 xS(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 Ia("HDR", "standard", ["averageLuminance"], ["textureAdderSampler"], t, null, vo.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._hdrCurrentLuminance < n + i.hdrDecreaseRate * r ? n += i.hdrDecreaseRate * r : i._hdrCurrentLuminance > n - 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 xS(e.getEngine(), "HDR", (function () { return i.hdrPostProcess }), !0)) }, t.prototype._createLensFlarePostProcess = function (e, t) { var i = this; this.lensFlarePostProcess = new Ia("HDRLensFlare", "standard", ["strength", "ghostDispersal", "haloWidth", "resolution", "distortionStrength"], ["lensColorSampler"], t / 2, null, vo.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, "#define LENS_FLARE", a.TEXTURETYPE_UNSIGNED_INT), this.addEffect(new xS(e.getEngine(), "HDRLensFlare", (function () { return i.lensFlarePostProcess }), !0)), this._createBlurPostProcesses(e, t / 4, 2, "lensFlareBlurWidth"), this.lensFlareComposePostProcess = new Ia("HDRLensFlareCompose", "standard", ["lensStarMatrix"], ["otherSampler", "lensDirtSampler", "lensStarSampler"], t, null, vo.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, "#define LENS_FLARE_COMPOSE", a.TEXTURETYPE_UNSIGNED_INT), this.addEffect(new xS(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 Ia("HDRDepthOfField", "standard", ["distance"], ["otherSampler", "depthSampler"], t, null, vo.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 xS(e.getEngine(), "HDRDepthOfField", (function () { return i.depthOfFieldPostProcess }), !0)) }, t.prototype._createMotionBlurPostProcess = function (e, t) { var i = this; if (this._isObjectBasedMotionBlur) { var r = new XS("HDRMotionBlur", e, t, null, vo.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, a.TEXTURETYPE_UNSIGNED_INT); r.motionStrength = this.motionStrength, r.motionBlurSamples = this.motionBlurSamples, this.motionBlurPostProcess = r } else { this.motionBlurPostProcess = new Ia("HDRMotionBlur", "standard", ["inverseViewProjection", "prevViewProjection", "screenSize", "motionScale", "motionStrength"], ["depthSampler"], t, null, vo.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 xS(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; e < this._cameras.length; e++) { var t = this._cameras[e]; this.originalPostProcess && this.originalPostProcess.dispose(t), this.screenSpaceReflectionPostProcess && this.screenSpaceReflectionPostProcess.dispose(t), this.downSampleX4PostProcess && this.downSampleX4PostProcess.dispose(t), this.brightPassPostProcess && this.brightPassPostProcess.dispose(t), this.textureAdderPostProcess && this.textureAdderPostProcess.dispose(t), this.volumetricLightPostProcess && this.volumetricLightPostProcess.dispose(t), this.volumetricLightSmoothXPostProcess && this.volumetricLightSmoothXPostProcess.dispose(t), this.volumetricLightSmoothYPostProcess && this.volumetricLightSmoothYPostProcess.dispose(t), this.volumetricLightMergePostProces && this.volumetricLightMergePostProces.dispose(t), this.volumetricLightFinalPostProcess && this.volumetricLightFinalPostProcess.dispose(t), this.lensFlarePostProcess && this.lensFlarePostProcess.dispose(t), this.lensFlareComposePostProcess && this.lensFlareComposePostProcess.dispose(t); for (var i = 0; i < this.luminanceDownSamplePostProcesses.length; i++)this.luminanceDownSamplePostProcesses[i].dispose(t); for (this.luminancePostProcess && this.luminancePostProcess.dispose(t), this.hdrPostProcess && this.hdrPostProcess.dispose(t), this.hdrFinalPostProcess && this.hdrFinalPostProcess.dispose(t), this.depthOfFieldPostProcess && this.depthOfFieldPostProcess.dispose(t), this.motionBlurPostProcess && this.motionBlurPostProcess.dispose(t), this.fxaaPostProcess && this.fxaaPostProcess.dispose(t), i = 0; i < this.blurHPostProcesses.length; i++)this.blurHPostProcesses[i].dispose(t); for (i = 0; i < this.blurVPostProcesses.length; i++)this.blurVPostProcesses[i].dispose(t) } this.originalPostProcess = null, this.downSampleX4PostProcess = null, this.brightPassPostProcess = null, this.textureAdderPostProcess = null, this.textureAdderFinalPostProcess = null, this.volumetricLightPostProcess = null, this.volumetricLightSmoothXPostProcess = null, this.volumetricLightSmoothYPostProcess = null, this.volumetricLightMergePostProces = null, this.volumetricLightFinalPostProcess = null, this.lensFlarePostProcess = null, this.lensFlareComposePostProcess = null, this.luminancePostProcess = null, this.hdrPostProcess = null, this.hdrFinalPostProcess = null, this.depthOfFieldPostProcess = null, this.motionBlurPostProcess = null, this.fxaaPostProcess = null, this.screenSpaceReflectionPostProcess = null, this.luminanceDownSamplePostProcesses.length = 0, this.blurHPostProcesses.length = 0, this.blurVPostProcesses.length = 0 }, t.prototype.dispose = function () { this._disposePostProcesses(), this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras), e.prototype.dispose.call(this) }, t.prototype.serialize = function () { var e = Ue.Serialize(this); return this.sourceLight && (e.sourceLightId = this.sourceLight.id), this.screenSpaceReflectionPostProcess && (e.screenSpaceReflectionPostProcess = Ue.Serialize(this.screenSpaceReflectionPostProcess)), e.customType = "StandardRenderingPipeline", e }, t.Parse = function (e, i, r) { var n = Ue.Parse((function () { return new t(e._name, i, e._ratio) }), e, i, r); return e.sourceLightId && (n.sourceLight = i.getLightById(e.sourceLightId)), e.screenSpaceReflectionPostProcess && Ue.Parse((function () { return n.screenSpaceReflectionPostProcess }), e.screenSpaceReflectionPostProcess, i, r), n }, t.LuminanceSteps = 6, X([xe()], t.prototype, "brightThreshold", void 0), X([xe()], t.prototype, "blurWidth", void 0), X([xe()], t.prototype, "horizontalBlur", void 0), X([xe()], t.prototype, "exposure", null), X([Ae("lensTexture")], t.prototype, "lensTexture", void 0), X([xe()], t.prototype, "volumetricLightCoefficient", void 0), X([xe()], t.prototype, "volumetricLightPower", void 0), X([xe()], t.prototype, "volumetricLightBlurScale", void 0), X([xe()], t.prototype, "hdrMinimumLuminance", void 0), X([xe()], t.prototype, "hdrDecreaseRate", void 0), X([xe()], t.prototype, "hdrIncreaseRate", void 0), X([xe()], t.prototype, "hdrAutoExposure", null), X([Ae("lensColorTexture")], t.prototype, "lensColorTexture", void 0), X([xe()], t.prototype, "lensFlareStrength", void 0), X([xe()], t.prototype, "lensFlareGhostDispersal", void 0), X([xe()], t.prototype, "lensFlareHaloWidth", void 0), X([xe()], t.prototype, "lensFlareDistortionStrength", void 0), X([xe()], t.prototype, "lensFlareBlurWidth", void 0), X([Ae("lensStarTexture")], t.prototype, "lensStarTexture", void 0), X([Ae("lensFlareDirtTexture")], t.prototype, "lensFlareDirtTexture", void 0), X([xe()], t.prototype, "depthOfFieldDistance", void 0), X([xe()], t.prototype, "depthOfFieldBlurWidth", void 0), X([xe()], t.prototype, "motionStrength", null), X([xe()], t.prototype, "objectBasedMotionBlur", null), X([xe()], t.prototype, "_ratio", void 0), X([xe()], t.prototype, "BloomEnabled", null), X([xe()], t.prototype, "DepthOfFieldEnabled", null), X([xe()], t.prototype, "LensFlareEnabled", null), X([xe()], t.prototype, "HDREnabled", null), X([xe()], t.prototype, "VLSEnabled", null), X([xe()], t.prototype, "MotionBlurEnabled", null), X([xe()], t.prototype, "fxaaEnabled", null), X([xe()], t.prototype, "screenSpaceReflectionsEnabled", null), X([xe()], t.prototype, "volumetricLightStepsCount", null), X([xe()], t.prototype, "motionBlurSamples", null), X([xe()], t.prototype, "samples", null), t }(KS); b("BABYLON.StandardRenderingPipeline", nx); var ox = function () { this.enabled = !1, this.name = "screenSpaceReflections2", this.texturesRequired = [a.PREPASS_NORMAL_TEXTURE_TYPE, a.PREPASS_REFLECTIVITY_TEXTURE_TYPE, a.PREPASS_DEPTH_TEXTURE_TYPE] }; Ut.IncludesShadersStore.screenSpaceRayTrace = "float distanceSquared(vec2 a,vec2 b) { a-=b; return dot(a,a); }\n/**\nparam csOrigin Camera-space ray origin,which must be \nwithin the view volume and must have z>0.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"; Ut.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"; Ut.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"; Ut.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 ax = I.Compose(new R(.5, .5, .5), P.Identity(), new R(.5, .5, .5)), sx = I.Compose(new R(.5, .5, 1), P.Identity(), new R(.5, .5, 0)), lx = 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) } else { var c = i.enablePrePassRenderer(); c && (c.useSpecificClearForDepthTexture = !0, c.markAsDirty()) } 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 jm(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 xS(i, this.SSRRenderEffect, (function () { return t._ssrPostProcess }), !0)), this._useBlur() && (this._createBlurAndCombinerPostProcesses(), this.addEffect(new xS(i, this.SSRBlurRenderEffect, (function () { return [t._blurPostProcessX, t._blurPostProcessY] }), !0)), this.addEffect(new xS(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; n < this._cameras.length; n++) { var o = this._cameras[n]; null === (e = this._ssrPostProcess) || void 0 === e || e.dispose(o), null === (t = this._blurPostProcessX) || void 0 === t || t.dispose(o), null === (i = this._blurPostProcessY) || void 0 === i || i.dispose(o), null === (r = this._blurCombinerPostProcess) || void 0 === r || r.dispose(o) } this._ssrPostProcess = null, this._blurPostProcessX = null, this._blurPostProcessY = null, this._blurCombinerPostProcess = null }, t.prototype._createSSRPostProcess = function () { var e = this; this._ssrPostProcess = new Ia("ssr", "screenSpaceReflection2", ["projection", "invProjectionMatrix", "view", "invView", "thickness", "reflectionSpecularFalloffExponent", "strength", "stepSize", "maxSteps", "roughnessFactor", "projectionPixel", "nearPlaneZ", "maxDistance", "selfCollisionNumSkip", "vReflectionPosition", "vReflectionSize", "backSizeFactor", "reflectivityThreshold"], ["textureSampler", "normalSampler", "reflectivitySampler", "depthSampler", "envCubeSampler", "backDepthSampler"], 1, null, this._textureType, this._scene.getEngine(), !1, "", this._textureType), this._updateEffectDefines(), this._ssrPostProcess.onApply = function (t) { e._resizeDepthRenderer(); var i = e._geometryBufferRenderer, r = e._prePassRenderer; if (r || i) { if (i) { var n = i.getTextureIndex(zS.REFLECTIVITY_TEXTURE_TYPE); t.setTexture("normalSampler", i.getGBuffer().textures[1]), t.setTexture("reflectivitySampler", i.getGBuffer().textures[n]), t.setTexture("depthSampler", i.getGBuffer().textures[0]) } else if (r) { var o = r.getIndex(a.PREPASS_DEPTH_TEXTURE_TYPE), s = (n = r.getIndex(a.PREPASS_REFLECTIVITY_TEXTURE_TYPE), r.getIndex(a.PREPASS_NORMAL_TEXTURE_TYPE)); t.setTexture("normalSampler", r.getRenderTarget().textures[s]), t.setTexture("depthSampler", r.getRenderTarget().textures[o]), t.setTexture("reflectivitySampler", r.getRenderTarget().textures[n]) } e._enableAutomaticThicknessComputation && e._depthRenderer && (t.setTexture("backDepthSampler", e._depthRenderer.getDepthMap()), t.setFloat("backSizeFactor", e._backfaceDepthTextureDownsample + 1)); var l = e._scene.activeCamera; if (l) { var c = l.getViewMatrix(!0), u = l.getProjectionMatrix(!0); u.invertToRef(O.Matrix[0]), c.invertToRef(O.Matrix[1]), t.setMatrix("projection", u), t.setMatrix("view", c), t.setMatrix("invView", O.Matrix[1]), t.setMatrix("invProjectionMatrix", O.Matrix[0]), t.setFloat("thickness", e.thickness), t.setFloat("reflectionSpecularFalloffExponent", e.reflectionSpecularFalloffExponent), t.setFloat("strength", e.strength), t.setFloat("stepSize", e.step), t.setFloat("maxSteps", e.maxSteps), t.setFloat("roughnessFactor", e.roughnessFactor), t.setFloat("nearPlaneZ", l.minZ), t.setFloat("maxDistance", e.maxDistance), t.setFloat("selfCollisionNumSkip", e.selfCollisionNumSkip), t.setFloat("reflectivityThreshold", e._reflectivityThreshold); var h = e._getTextureSize(); I.ScalingToRef(h.width, h.height, 1, O.Matrix[2]), u.multiplyToRef(e._scene.getEngine().isWebGPU ? sx : ax, O.Matrix[3]), O.Matrix[3].multiplyToRef(O.Matrix[2], O.Matrix[4]), t.setMatrix("projectionPixel", O.Matrix[4]), e._environmentTexture && (t.setTexture("envCubeSampler", e._environmentTexture), e._environmentTexture.boundingBoxSize && (t.setVector3("vReflectionPosition", e._environmentTexture.boundingBoxPosition), t.setVector3("vReflectionSize", e._environmentTexture.boundingBoxSize))) } } }, this._ssrPostProcess.samples = this.samples, this._forceGeometryBuffer || (this._ssrPostProcess._prePassEffectConfiguration = new ox) }, t.prototype._createBlurAndCombinerPostProcesses = function () { var e = this, t = this._scene.getEngine(); this._blurPostProcessX = new Ia("SSRblurX", "screenSpaceReflection2Blur", ["texelOffsetScale"], ["textureSampler"], this._useBlur() ? 1 / (this._ssrDownsample + 1) : 1, null, a.TEXTURE_BILINEAR_SAMPLINGMODE, t, !1, "", this._textureType), this._blurPostProcessX.autoClear = !1, this._blurPostProcessX.onApplyObservable.add((function (t) { var i, r, n = null !== (r = null === (i = e._blurPostProcessX) || void 0 === i ? void 0 : i.inputTexture.width) && void 0 !== r ? r : e._scene.getEngine().getRenderWidth(); t.setFloat2("texelOffsetScale", e._blurDispersionStrength / n, 0) })), this._blurPostProcessY = new Ia("SSRblurY", "screenSpaceReflection2Blur", ["texelOffsetScale"], ["textureSampler"], this._useBlur() ? 1 / (this._blurDownsample + 1) : 1, null, a.TEXTURE_BILINEAR_SAMPLINGMODE, t, !1, "", this._textureType), this._blurPostProcessY.autoClear = !1, this._blurPostProcessY.onApplyObservable.add((function (t) { var i, r, n = null !== (r = null === (i = e._blurPostProcessY) || void 0 === i ? void 0 : i.inputTexture.height) && void 0 !== r ? r : e._scene.getEngine().getRenderHeight(); t.setFloat2("texelOffsetScale", 0, e._blurDispersionStrength / n) })); var i = ["strength", "reflectionSpecularFalloffExponent", "reflectivityThreshold"], r = ["textureSampler", "mainSampler", "reflectivitySampler"], n = ""; this._debug && (n += "#define SSRAYTRACE_DEBUG\n"), this._inputTextureColorIsInGammaSpace && (n += "#define SSR_INPUT_IS_GAMMA_SPACE\n"), this._generateOutputInGammaSpace && (n += "#define SSR_OUTPUT_IS_GAMMA_SPACE\n"), this.useFresnel && (n += "#define SSR_BLEND_WITH_FRESNEL\n", i.push("projection", "invProjectionMatrix"), r.push("depthSampler", "normalSampler")), 0 === this._reflectivityThreshold && (n += "#define SSR_DISABLE_REFLECTIVITY_TEST"), this._blurCombinerPostProcess = new Ia("SSRblurCombiner", "screenSpaceReflection2BlurCombiner", i, r, this._useBlur() ? 1 / (this._blurDownsample + 1) : 1, null, a.TEXTURE_NEAREST_SAMPLINGMODE, t, !1, n, this._textureType), this._blurCombinerPostProcess.autoClear = !1, this._blurCombinerPostProcess.onApplyObservable.add((function (t) { var i, r = e._geometryBufferRenderer, n = e._prePassRenderer; if (n || r) { if (n && (null === (i = e._scene.activeCamera) || void 0 === i ? void 0 : i._getFirstPostProcess()) === e._ssrPostProcess) { var o = n.getRenderTarget(); o && o.textures && t.setTexture("mainSampler", o.textures[n.getIndex(a.PREPASS_COLOR_TEXTURE_TYPE)]) } else t.setTextureFromPostProcess("mainSampler", e._ssrPostProcess); if (r) { var s = r.getTextureIndex(zS.REFLECTIVITY_TEXTURE_TYPE); t.setTexture("reflectivitySampler", r.getGBuffer().textures[s]), e.useFresnel && (t.setTexture("normalSampler", r.getGBuffer().textures[1]), t.setTexture("depthSampler", r.getGBuffer().textures[0])) } else if (n && (s = n.getIndex(a.PREPASS_REFLECTIVITY_TEXTURE_TYPE), t.setTexture("reflectivitySampler", n.getRenderTarget().textures[s]), e.useFresnel)) { var l = n.getIndex(a.PREPASS_DEPTH_TEXTURE_TYPE), c = n.getIndex(a.PREPASS_NORMAL_TEXTURE_TYPE); t.setTexture("normalSampler", n.getRenderTarget().textures[c]), t.setTexture("depthSampler", n.getRenderTarget().textures[l]) } if (t.setFloat("strength", e.strength), t.setFloat("reflectionSpecularFalloffExponent", e.reflectionSpecularFalloffExponent), t.setFloat("reflectivityThreshold", e._reflectivityThreshold), e.useFresnel) { var u = e._scene.activeCamera; if (u) { var h = u.getProjectionMatrix(); h.invertToRef(O.Matrix[0]), t.setMatrix("projection", h), t.setMatrix("invProjectionMatrix", O.Matrix[0]) } } } })) }, t.prototype.serialize = function () { var e = Ue.Serialize(this); return e.customType = "SSRRenderingPipeline", e }, t.Parse = function (e, i, r) { return Ue.Parse((function () { return new t(e._name, i, e._ratio) }), e, i, r) }, X([xe()], t.prototype, "samples", null), X([xe()], t.prototype, "maxDistance", void 0), X([xe()], t.prototype, "step", void 0), X([xe()], t.prototype, "thickness", void 0), X([xe()], t.prototype, "strength", void 0), X([xe()], t.prototype, "reflectionSpecularFalloffExponent", void 0), X([xe()], t.prototype, "maxSteps", void 0), X([xe()], t.prototype, "roughnessFactor", void 0), X([xe()], t.prototype, "selfCollisionNumSkip", void 0), X([xe()], t.prototype, "_reflectivityThreshold", void 0), X([xe("_ssrDownsample")], t.prototype, "_ssrDownsample", void 0), X([xe()], t.prototype, "ssrDownsample", null), X([xe("blurDispersionStrength")], t.prototype, "_blurDispersionStrength", void 0), X([xe("blurDownsample")], t.prototype, "_blurDownsample", void 0), X([xe("enableSmoothReflections")], t.prototype, "_enableSmoothReflections", void 0), X([xe("environmentTexture")], t.prototype, "_environmentTexture", void 0), X([xe("environmentTextureIsProbe")], t.prototype, "_environmentTextureIsProbe", void 0), X([xe("attenuateScreenBorders")], t.prototype, "_attenuateScreenBorders", void 0), X([xe("attenuateIntersectionDistance")], t.prototype, "_attenuateIntersectionDistance", void 0), X([xe("attenuateIntersectionIterations")], t.prototype, "_attenuateIntersectionIterations", void 0), X([xe("attenuateFacingCamera")], t.prototype, "_attenuateFacingCamera", void 0), X([xe("attenuateBackfaceReflection")], t.prototype, "_attenuateBackfaceReflection", void 0), X([xe("clipToFrustum")], t.prototype, "_clipToFrustum", void 0), X([xe("useFresnel")], t.prototype, "_useFresnel", void 0), X([xe("enableAutomaticThicknessComputation")], t.prototype, "_enableAutomaticThicknessComputation", void 0), X([xe("backfaceDepthTextureDownsample")], t.prototype, "_backfaceDepthTextureDownsample", void 0), X([xe("backfaceForceDepthWriteTransparentMeshes")], t.prototype, "_backfaceForceDepthWriteTransparentMeshes", void 0), X([xe("isEnabled")], t.prototype, "_isEnabled", void 0), X([xe("inputTextureColorIsInGammaSpace")], t.prototype, "_inputTextureColorIsInGammaSpace", void 0), X([xe("generateOutputInGammaSpace")], t.prototype, "_generateOutputInGammaSpace", void 0), X([xe("debug")], t.prototype, "_debug", void 0), t }(KS); b("BABYLON.SSRRenderingPipeline", lx); var cx; Ut.ShadersStore.tonemapPixelShader = "varying vec2 vUV;uniform sampler2D textureSampler;uniform float _ExposureAdjustment;\n#if defined(HABLE_TONEMAPPING)\nconst float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;const float W=11.2;\n#endif\nfloat Luminance(vec3 c)\n{return dot(c,vec3(0.22,0.707,0.071));}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{vec3 colour=texture2D(textureSampler,vUV).rgb;\n#if defined(REINHARD_TONEMAPPING)\nfloat lum=Luminance(colour.rgb); \nfloat lumTm=lum*_ExposureAdjustment;float scale=lumTm/(1.0+lumTm); \ncolour*=scale/lum;\n#elif defined(HABLE_TONEMAPPING)\ncolour*=_ExposureAdjustment;const float ExposureBias=2.0;vec3 x=ExposureBias*colour;vec3 curr=((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;x=vec3(W,W,W);vec3 whiteScale=1.0/(((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F);colour=curr*whiteScale;\n#elif defined(OPTIMIZED_HEJIDAWSON_TONEMAPPING)\ncolour*=_ExposureAdjustment;vec3 X=max(vec3(0.0,0.0,0.0),colour-0.004);vec3 retColor=(X*(6.2*X+0.5))/(X*(6.2*X+1.7)+0.06);colour=retColor*retColor;\n#elif defined(PHOTOGRAPHIC_TONEMAPPING)\ncolour= vec3(1.0,1.0,1.0)-exp2(-_ExposureAdjustment*colour);\n#endif\ngl_FragColor=vec4(colour.rgb,1.0);}", function (e) { e[e.Hable = 0] = "Hable", e[e.Reinhard = 1] = "Reinhard", e[e.HejiDawson = 2] = "HejiDawson", e[e.Photographic = 3] = "Photographic" }(cx || (cx = {})); var ux = function (e) { function t(t, i, r, n, o, s, l, c) { void 0 === o && (o = a.TEXTURE_BILINEAR_SAMPLINGMODE), void 0 === l && (l = a.TEXTURETYPE_UNSIGNED_INT); var u = e.call(this, t, "tonemap", ["_ExposureAdjustment"], null, 1, n, o, s, c, null, l) || this; u._operator = i, u.exposureAdjustment = r; var h = "#define "; return u._operator === cx.Hable ? h += "HABLE_TONEMAPPING" : u._operator === cx.Reinhard ? h += "REINHARD_TONEMAPPING" : u._operator === cx.HejiDawson ? h += "OPTIMIZED_HEJIDAWSON_TONEMAPPING" : u._operator === cx.Photographic && (h += "PHOTOGRAPHIC_TONEMAPPING"), u.updateEffect(h), u.onApply = function (e) { e.setFloat("_ExposureAdjustment", u.exposureAdjustment) }, u } return W(t, e), t.prototype.getClassName = function () { return "TonemapPostProcess" }, t }(Ia); Ut.ShadersStore.volumetricLightScatteringPixelShader = "uniform sampler2D textureSampler;uniform sampler2D lightScatteringSampler;uniform float decay;uniform float exposure;uniform float weight;uniform float density;uniform vec2 meshPositionOnScreen;varying vec2 vUV;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec2 tc=vUV;vec2 deltaTexCoord=(tc-meshPositionOnScreen.xy);deltaTexCoord*=1.0/float(NUM_SAMPLES)*density;float illuminationDecay=1.0;vec4 color=texture2D(lightScatteringSampler,tc)*0.4;for(int i=0; i 0 && -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 es("volumetricLightScatteringMap", { width: r.getRenderWidth() * t, height: r.getRenderHeight() * t }, e, !1, !0, a.TEXTURETYPE_UNSIGNED_INT), this._volumetricLightScatteringRTT.wrapU = vo.CLAMP_ADDRESSMODE, this._volumetricLightScatteringRTT.wrapV = vo.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, Hn.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; o < e.subMeshes.length; ++o) { var a = e.subMeshes[o], s = a.getMaterial(), l = a.getRenderingMesh(); if (s) { var c = l._getInstancesRenderList(a._id, !!a.getReplacementMesh()), u = r.getCaps().instancedArrays && (null !== c.visibleInstances[a._id] || l.hasThinInstances); if (!i._isReady(a, u)) return !1 } } return !0 }, this._volumetricLightScatteringRTT.customRenderFunction = function (t, i, r, n) { var o, l = e.getEngine(); if (n.length) { for (l.setColorWrite(!1), o = 0; o < n.length; o++)s(n.data[o]); l.setColorWrite(!0) } for (o = 0; o < t.length; o++)s(t.data[o]); for (o = 0; o < i.length; o++)s(i.data[o]); if (r.length) { for (o = 0; o < r.length; o++) { var c = r.data[o], u = c.getBoundingInfo(); u && e.activeCamera && (c._alphaIndex = c.getMesh().alphaIndex, c._distanceToCamera = u.boundingSphere.centerWorld.subtract(e.activeCamera.position).length()) } var h = r.data.slice(0, r.length); for (h.sort((function (e, t) { return e._alphaIndex > t._alphaIndex ? 1 : e._alphaIndex < t._alphaIndex ? -1 : e._distanceToCamera < t._distanceToCamera ? 1 : e._distanceToCamera > t._distanceToCamera ? -1 : 0 })), l.setAlphaMode(a.ALPHA_COMBINE), o = 0; o < h.length; o++)s(h[o]); l.setAlphaMode(a.ALPHA_DISABLE) } } }, t.prototype._updateMeshScreenCoordinates = function (e) { var t, i = e.getTransformMatrix(); t = this.useCustomMeshPosition ? this.customMeshPosition : this.attachedNode ? this.attachedNode.position : this.mesh.parent ? this.mesh.getAbsolutePosition() : this.mesh.position; var r = R.Project(t, I.Identity(), i, this._viewPort); this._screenCoordinates.x = r.x / this._viewPort.width, this._screenCoordinates.y = r.y / this._viewPort.height, this.invert && (this._screenCoordinates.y = 1 - this._screenCoordinates.y) }, t.CreateDefaultMesh = function (e, t) { var i = No(e, { size: 1 }, t); i.billboardMode = Ln.BILLBOARDMODE_ALL; var r = new mc(e + "Material", t); return r.emissiveColor = new B(1, 1, 1), i.material = r, i }, X([Ie()], t.prototype, "customMeshPosition", void 0), X([xe()], t.prototype, "useCustomMeshPosition", void 0), X([xe()], t.prototype, "invert", void 0), X([Me()], t.prototype, "mesh", void 0), X([xe()], t.prototype, "excludedMeshes", void 0), X([xe()], t.prototype, "includedMeshes", void 0), X([xe()], t.prototype, "exposure", void 0), X([xe()], t.prototype, "decay", void 0), X([xe()], t.prototype, "weight", void 0), X([xe()], t.prototype, "density", void 0), t }(Ia); b("BABYLON.VolumetricLightScatteringPostProcess", hx); Ut.ShadersStore.screenSpaceCurvaturePixelShader = "precision highp float;varying vec2 vUV;uniform sampler2D textureSampler;uniform sampler2D normalSampler;uniform float curvature_ridge;uniform float curvature_valley;\n#ifndef CURVATURE_OFFSET\n#define CURVATURE_OFFSET 1\n#endif\nfloat curvature_soft_clamp(float curvature,float control)\n{if (curvature<0.5/control)\nreturn curvature*(1.0-curvature*control);return 0.25/control;}\nfloat calculate_curvature(ivec2 texel,float ridge,float valley)\n{vec2 normal_up =texelFetch(normalSampler,texel+ivec2(0, CURVATURE_OFFSET),0).rb;vec2 normal_down =texelFetch(normalSampler,texel+ivec2(0,-CURVATURE_OFFSET),0).rb;vec2 normal_left =texelFetch(normalSampler,texel+ivec2(-CURVATURE_OFFSET,0),0).rb;vec2 normal_right=texelFetch(normalSampler,texel+ivec2( CURVATURE_OFFSET,0),0).rb;float normal_diff=((normal_up.g-normal_down.g)+(normal_right.r-normal_left.r));if (normal_diff<0.0)\nreturn -2.0*curvature_soft_clamp(-normal_diff,valley);return 2.0*curvature_soft_clamp(normal_diff,ridge);}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{ivec2 texel=ivec2(gl_FragCoord.xy);vec4 baseColor=texture2D(textureSampler,vUV);float curvature=calculate_curvature(texel,curvature_ridge,curvature_valley);baseColor.rgb*=curvature+1.0;gl_FragColor=baseColor;}"; var dx = function (e) { function t(t, i, r, n, o, s, l, c, u) { void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT), void 0 === u && (u = !1); var h = e.call(this, t, "screenSpaceCurvature", ["curvature_ridge", "curvature_valley"], ["textureSampler", "normalSampler"], r, n, o, s, l, void 0, c, void 0, null, u) || this; return h.ridge = 1, h.valley = 1, h._geometryBufferRenderer = i.enableGeometryBufferRenderer(), h._geometryBufferRenderer ? h.onApply = function (e) { e.setFloat("curvature_ridge", .5 / Math.max(h.ridge * h.ridge, 1e-4)), e.setFloat("curvature_valley", .7 / Math.max(h.valley * h.valley, 1e-4)); var t = h._geometryBufferRenderer.getGBuffer().textures[1]; e.setTexture("normalSampler", t) } : $.Error("Multiple Render Target support needed for screen space curvature post process. Please use IsSupported test first."), h } return W(t, e), t.prototype.getClassName = function () { return "ScreenSpaceCurvaturePostProcess" }, Object.defineProperty(t, "IsSupported", { get: function () { var e = S.LastCreatedEngine; return !!e && e.getCaps().drawBuffersExtension }, enumerable: !1, configurable: !0 }), t._Parse = function (e, i, r, n) { return Ue.Parse((function () { return new t(e.name, r, e.options, i, e.renderTargetSamplingMode, r.getEngine(), e.textureType, e.reusable) }), e, r, n) }, X([xe()], t.prototype, "ridge", void 0), X([xe()], t.prototype, "valley", void 0), t }(Ia); b("BABYLON.ScreenSpaceCurvaturePostProcess", dx); Ut.IncludesShadersStore.boundingBoxRendererFragmentDeclaration = "uniform vec4 color;\n"; Ut.IncludesShadersStore.boundingBoxRendererUboDeclaration = "#ifdef WEBGL2\nuniform vec4 color;uniform mat4 world;uniform mat4 viewProjection;\n#ifdef MULTIVIEW\nuniform mat4 viewProjectionR;\n#endif\n#else\nlayout(std140,column_major) uniform;uniform BoundingBoxRenderer {vec4 color;mat4 world;mat4 viewProjection;mat4 viewProjectionR;};\n#endif\n"; Ut.ShadersStore.boundingBoxRendererPixelShader = "#include<__decl__boundingBoxRendererFragment>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\ngl_FragColor=color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}"; Ut.IncludesShadersStore.boundingBoxRendererVertexDeclaration = "uniform mat4 world;uniform mat4 viewProjection;\n#ifdef MULTIVIEW\nuniform mat4 viewProjectionR;\n#endif\n"; Ut.ShadersStore.boundingBoxRendererVertexShader = "attribute vec3 position;\n#include<__decl__boundingBoxRendererVertex>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec4 worldPos=world*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#define CUSTOM_VERTEX_MAIN_END\n}\n", Object.defineProperty(Sr.prototype, "forceShowBoundingBoxes", { get: function () { return this._forceShowBoundingBoxes || !1 }, set: function (e) { this._forceShowBoundingBoxes = e, e && this.getBoundingBoxRenderer() }, enumerable: !0, configurable: !0 }), Sr.prototype.getBoundingBoxRenderer = function () { return this._boundingBoxRenderer || (this._boundingBoxRenderer = new px(this)), this._boundingBoxRenderer }, Object.defineProperty(Ln.prototype, "showBoundingBox", { get: function () { return this._showBoundingBox || !1 }, set: function (e) { this._showBoundingBox = e, e && this.getScene().getBoundingBoxRenderer() }, enumerable: !0, configurable: !0 }); var px = function () { function e(e) { this.name = qi.NAME_BOUNDINGBOXRENDERER, this.frontColor = new B(1, 1, 1), this.backColor = new B(.1, .1, .1), this.showBackLines = !0, this.onBeforeBoxRenderingObservable = new u, this.onAfterBoxRenderingObservable = new u, this.onResourcesReadyObservable = new u, this.enabled = !0, this.renderList = new Ci(32), this._vertexBuffers = {}, this._fillIndexBuffer = null, this._fillIndexData = null, this.scene = e, e._addComponent(this), this._uniformBufferFront = new zi(this.scene.getEngine(), void 0, void 0, "BoundingBoxRendererFront", !this.scene.getEngine().isWebGPU), this._buildUniformLayout(this._uniformBufferFront), this._uniformBufferBack = new zi(this.scene.getEngine(), void 0, void 0, "BoundingBoxRendererBack", !this.scene.getEngine().isWebGPU), this._buildUniformLayout(this._uniformBufferBack) } return e.prototype._buildUniformLayout = function (e) { e.addUniform("color", 4), e.addUniform("world", 16), e.addUniform("viewProjection", 16), e.addUniform("viewProjectionR", 16), e.create() }, e.prototype.register = function () { this.scene._beforeEvaluateActiveMeshStage.registerStep(qi.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset), this.scene._preActiveMeshStage.registerStep(qi.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER, this, this._preActiveMesh), this.scene._evaluateSubMeshStage.registerStep(qi.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh), this.scene._afterRenderingGroupDrawStage.registerStep(qi.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render) }, e.prototype._evaluateSubMesh = function (e, t) { if (e.showSubMeshesBoundingBox) { var i = t.getBoundingInfo(); null != i && (i.boundingBox._tag = e.renderingGroupId, this.renderList.push(i.boundingBox)) } }, e.prototype._preActiveMesh = function (e) { if (e.showBoundingBox || this.scene.forceShowBoundingBoxes) { var t = e.getBoundingInfo(); t.boundingBox._tag = e.renderingGroupId, this.renderList.push(t.boundingBox) } }, e.prototype._prepareResources = function () { if (!this._colorShader) { this._colorShader = new Gu("colorShader", this.scene, "boundingBoxRenderer", { attributes: [Hi.PositionKind], uniforms: ["world", "viewProjection", "viewProjectionR", "color"], uniformBuffers: ["BoundingBoxRenderer"] }, !1), this._colorShader.doNotSerialize = !0, this._colorShader.reservedDataStore = { hidden: !0 }, this._colorShaderForOcclusionQuery = new Gu("colorShaderOccQuery", this.scene, "boundingBoxRenderer", { attributes: [Hi.PositionKind], uniforms: ["world", "viewProjection", "viewProjectionR", "color"], uniformBuffers: ["BoundingBoxRenderer"] }, !0), this._colorShaderForOcclusionQuery.doNotSerialize = !0, this._colorShaderForOcclusionQuery.reservedDataStore = { hidden: !0 }; var e = this.scene.getEngine(), t = _u({ size: 1 }); this._vertexBuffers[Hi.PositionKind] = new Hi(e, t.positions, Hi.PositionKind, !1), this._createIndexBuffer(), this._fillIndexData = t.indices, this.onResourcesReadyObservable.notifyObservers(this) } }, e.prototype._createIndexBuffer = function () { var e = this.scene.getEngine(); this._indexBuffer = e.createIndexBuffer([0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 7, 1, 6, 2, 5, 3, 4]) }, e.prototype.rebuild = function () { var e = this._vertexBuffers[Hi.PositionKind]; e && e._rebuild(), this._createIndexBuffer() }, e.prototype.reset = function () { this.renderList.reset() }, e.prototype.render = function (e) { var t, i; if (0 !== this.renderList.length && this.enabled && (this._prepareResources(), this._colorShader.isReady())) { var r = this.scene.getEngine(); r.setDepthWrite(!1); for (var n = this.scene.getTransformMatrix(), o = 0; o < this.renderList.length; o++) { var a = this.renderList.data[o]; if (a._tag === e) { this._createWrappersForBoundingBox(a), this.onBeforeBoxRenderingObservable.notifyObservers(a); var s = a.minimum, l = a.maximum.subtract(s), c = s.add(l.scale(.5)), u = I.Scaling(l.x, l.y, l.z).multiply(I.Translation(c.x, c.y, c.z)).multiply(a.getWorldMatrix()), h = r.useReverseDepthBuffer; if (this.showBackLines) { var d = null !== (t = a._drawWrapperBack) && void 0 !== t ? t : this._colorShader._getDrawWrapper(); this._colorShader._preBind(d), r.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect()), h ? r.setDepthFunctionToLessOrEqual() : r.setDepthFunctionToGreaterOrEqual(), this._uniformBufferBack.bindToEffect(d.effect, "BoundingBoxRenderer"), this._uniformBufferBack.updateColor4("color", this.backColor, 1), this._uniformBufferBack.updateMatrix("world", u), this._uniformBufferBack.updateMatrix("viewProjection", n), this._uniformBufferBack.update(), r.drawElementsType(Hn.LineListDrawMode, 0, 24) } var p = null !== (i = a._drawWrapperFront) && void 0 !== i ? i : this._colorShader._getDrawWrapper(); this._colorShader._preBind(p), r.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect()), h ? r.setDepthFunctionToGreater() : r.setDepthFunctionToLess(), this._uniformBufferFront.bindToEffect(p.effect, "BoundingBoxRenderer"), this._uniformBufferFront.updateColor4("color", this.frontColor, 1), this._uniformBufferFront.updateMatrix("world", u), this._uniformBufferFront.updateMatrix("viewProjection", n), this._uniformBufferFront.update(), r.drawElementsType(Hn.LineListDrawMode, 0, 24), this.onAfterBoxRenderingObservable.notifyObservers(a) } } this._colorShader.unbind(), r.setDepthFunctionToLessOrEqual(), r.setDepthWrite(!0) } }, e.prototype._createWrappersForBoundingBox = function (e) { if (!e._drawWrapperFront) { var t = this.scene.getEngine(); e._drawWrapperFront = new Jt(t), e._drawWrapperBack = new Jt(t), e._drawWrapperFront.setEffect(this._colorShader.getEffect()), e._drawWrapperBack.setEffect(this._colorShader.getEffect()) } }, e.prototype.renderOcclusionBoundingBox = function (e) { var t = this.scene.getEngine(); void 0 === this._renderPassIdForOcclusionQuery && (this._renderPassIdForOcclusionQuery = t.createRenderPassId("Render pass for occlusion query")); var i = t.currentRenderPassId; t.currentRenderPassId = this._renderPassIdForOcclusionQuery, this._prepareResources(); var r = e.subMeshes[0]; if (this._colorShaderForOcclusionQuery.isReady(e, void 0, r) && e.hasBoundingInfo) { this._fillIndexBuffer || (this._fillIndexBuffer = t.createIndexBuffer(this._fillIndexData)); var n = t.useReverseDepthBuffer; t.setDepthWrite(!1), t.setColorWrite(!1); var o = e.getBoundingInfo().boundingBox, a = o.minimum, s = o.maximum.subtract(a), l = a.add(s.scale(.5)), c = I.Scaling(s.x, s.y, s.z).multiply(I.Translation(l.x, l.y, l.z)).multiply(o.getWorldMatrix()), u = r._drawWrapper; this._colorShaderForOcclusionQuery._preBind(u), t.bindBuffers(this._vertexBuffers, this._fillIndexBuffer, u.effect), n ? t.setDepthFunctionToGreater() : t.setDepthFunctionToLess(), this.scene.resetCachedMaterial(), this._uniformBufferFront.bindToEffect(u.effect, "BoundingBoxRenderer"), this._uniformBufferFront.updateMatrix("world", c), this._uniformBufferFront.updateMatrix("viewProjection", this.scene.getTransformMatrix()), this._uniformBufferFront.update(), t.drawElementsType(Hn.TriangleFillMode, 0, 36), this._colorShaderForOcclusionQuery.unbind(), t.setDepthFunctionToLessOrEqual(), t.setDepthWrite(!0), t.setColorWrite(!0), t.currentRenderPassId = i } else t.currentRenderPassId = i }, e.prototype.dispose = function () { if (void 0 !== this._renderPassIdForOcclusionQuery && (this.scene.getEngine().releaseRenderPassId(this._renderPassIdForOcclusionQuery), this._renderPassIdForOcclusionQuery = void 0), this._colorShader) { this.onBeforeBoxRenderingObservable.clear(), this.onAfterBoxRenderingObservable.clear(), this.onResourcesReadyObservable.clear(), this.renderList.dispose(), this._colorShader.dispose(), this._colorShaderForOcclusionQuery.dispose(), this._uniformBufferFront.dispose(), this._uniformBufferBack.dispose(); var e = this._vertexBuffers[Hi.PositionKind]; e && (e.dispose(), this._vertexBuffers[Hi.PositionKind] = null), this.scene.getEngine()._releaseBuffer(this._indexBuffer), this._fillIndexBuffer && (this.scene.getEngine()._releaseBuffer(this._fillIndexBuffer), this._fillIndexBuffer = null) } }, e }(); Sr.prototype.enableDepthRenderer = function (e, t, i, r, n) { if (void 0 === t && (t = !1), void 0 === i && (i = !1), void 0 === r && (r = a.TEXTURE_TRILINEAR_SAMPLINGMODE), void 0 === n && (n = !1), !(e = e || this.activeCamera)) throw "No camera available to enable depth renderer"; if (this._depthRenderer || (this._depthRenderer = {}), !this._depthRenderer[e.id]) { var o, s = !!this.getEngine().getCaps().textureFloatRender; o = !this.getEngine().getCaps().textureHalfFloatRender || i && s ? s ? a.TEXTURETYPE_FLOAT : a.TEXTURETYPE_UNSIGNED_BYTE : a.TEXTURETYPE_HALF_FLOAT, this._depthRenderer[e.id] = new jm(this, o, e, t, r, n) } return this._depthRenderer[e.id] }, Sr.prototype.disableDepthRenderer = function (e) { (e = e || this.activeCamera) && this._depthRenderer && this._depthRenderer[e.id] && this._depthRenderer[e.id].dispose() }; var fx = function () { function e(e) { this.name = qi.NAME_DEPTHRENDERER, this.scene = e } return e.prototype.register = function () { this.scene._gatherRenderTargetsStage.registerStep(qi.STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets), this.scene._gatherActiveCameraRenderTargetsStage.registerStep(qi.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets) }, e.prototype.rebuild = function () { }, e.prototype.dispose = function () { for (var e in this.scene._depthRenderer) this.scene._depthRenderer[e].dispose() }, e.prototype._gatherRenderTargets = function (e) { if (this.scene._depthRenderer) for (var t in this.scene._depthRenderer) { var i = this.scene._depthRenderer[t]; i.enabled && !i.useOnlyInActiveCamera && e.push(i.getDepthMap()) } }, e.prototype._gatherActiveCameraRenderTargets = function (e) { if (this.scene._depthRenderer) for (var t in this.scene._depthRenderer) { var i = this.scene._depthRenderer[t]; i.enabled && i.useOnlyInActiveCamera && this.scene.activeCamera.id === t && e.push(i.getDepthMap()) } }, e }(); jm._SceneComponentInitialization = function (e) { var t = e._getComponent(qi.NAME_DEPTHRENDERER); t || (t = new fx(e), e._addComponent(t)) }; Ut.ShadersStore.oitFinalPixelShader = "precision highp float;uniform sampler2D uFrontColor;uniform sampler2D uBackColor;void main() {ivec2 fragCoord=ivec2(gl_FragCoord.xy);vec4 frontColor=texelFetch(uFrontColor,fragCoord,0);vec4 backColor=texelFetch(uBackColor,fragCoord,0);float alphaMultiplier=1.0-frontColor.a;glFragColor=vec4(\nfrontColor.rgb+alphaMultiplier*backColor.rgb,\nfrontColor.a+backColor.a\n);}"; Ut.ShadersStore.oitBackBlendPixelShader = "precision highp float;uniform sampler2D uBackColor;void main() {glFragColor=texelFetch(uBackColor,ivec2(gl_FragCoord.xy),0);if (glFragColor.a==0.0) { \ndiscard;}}"; var _x = function () { this.enabled = !0, this.name = "depthPeeling", this.texturesRequired = [a.PREPASS_COLOR_TEXTURE_TYPE] }, mx = function () { function e(t, i) { if (void 0 === i && (i = 5), this._thinTextures = [], this._currentPingPongState = 0, this._layoutCacheFormat = [[!0], [!0, !0], [!0, !0, !0]], this._layoutCache = [], this._candidateSubMeshes = new Ci(10), this._excludedSubMeshes = new Ci(10), this._excludedMeshes = [], this._colorCache = [new U(e._DEPTH_CLEAR_VALUE, e._DEPTH_CLEAR_VALUE, 0, 0), new U(-e._MIN_DEPTH, e._MAX_DEPTH, 0, 0), new U(0, 0, 0, 0)], this._scene = t, this._engine = t.getEngine(), this._passCount = i, t.enablePrePassRenderer()) { for (var r = 0; r < this._layoutCacheFormat.length; ++r)this._layoutCache[r] = this._engine.buildTextureLayout(this._layoutCacheFormat[r]); this._renderPassIds = [], this.useRenderPasses = !1, this._prePassEffectConfiguration = new _x, this._createTextures(), this._createEffects() } else $.Warn("Depth peeling for order independant transparency could not enable PrePass, aborting.") } return Object.defineProperty(e.prototype, "passCount", { get: function () { return this._passCount }, set: function (e) { this._passCount !== e && (this._passCount = e, this._createRenderPassIds()) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "useRenderPasses", { get: function () { return this._useRenderPasses }, set: function (e) { this._useRenderPasses !== e && (this._useRenderPasses = e, this._createRenderPassIds()) }, enumerable: !1, configurable: !0 }), e.prototype.addExcludedMesh = function (e) { -1 === this._excludedMeshes.indexOf(e.uniqueId) && this._excludedMeshes.push(e.uniqueId) }, e.prototype.removeExcludedMesh = function (e) { var t = this._excludedMeshes.indexOf(e.uniqueId); -1 !== t && this._excludedMeshes.splice(t, 1) }, e.prototype._createRenderPassIds = function () { if (this._releaseRenderPassIds(), this._useRenderPasses) for (var e = 0; e < this._passCount + 1; ++e)this._renderPassIds[e] || (this._renderPassIds[e] = this._engine.createRenderPassId("DepthPeelingRenderer - pass #".concat(e))) }, e.prototype._releaseRenderPassIds = function () { for (var e = 0; e < this._renderPassIds.length; ++e)this._engine.releaseRenderPassId(this._renderPassIds[e]); this._renderPassIds = [] }, e.prototype._createTextures = function () { var e = { width: this._engine.getRenderWidth(), height: this._engine.getRenderHeight() }; this._depthMrts = [new hv("depthPeelingDepth0", e, 3, this._scene), new hv("depthPeelingDepth1", e, 3, this._scene)], this._colorMrts = [new hv("depthPeelingColor0", e, 2, this._scene, { generateDepthBuffer: !1 }), new hv("depthPeelingColor1", e, 2, this._scene, { generateDepthBuffer: !1 })], this._blendBackMrt = new hv("depthPeelingBack", e, 1, this._scene, { generateDepthBuffer: !1 }), this._outputRT = new es("depthPeelingOutput", e, this._scene, !1); for (var t = [{ format: a.TEXTUREFORMAT_RG, samplingMode: a.TEXTURE_NEAREST_SAMPLINGMODE, type: this._engine.getCaps().textureFloatLinearFiltering ? a.TEXTURETYPE_FLOAT : a.TEXTURETYPE_HALF_FLOAT, label: "DepthPeelingRenderer-DepthTexture" }, { format: a.TEXTUREFORMAT_RGBA, samplingMode: a.TEXTURE_NEAREST_SAMPLINGMODE, type: a.TEXTURETYPE_HALF_FLOAT, label: "DepthPeelingRenderer-ColorTexture" }], i = 0; i < 2; i++) { var r = this._engine._createInternalTexture(e, t[0], !1), n = this._engine._createInternalTexture(e, t[1], !1), o = this._engine._createInternalTexture(e, t[1], !1); this._depthMrts[i].setInternalTexture(r, 0), this._depthMrts[i].setInternalTexture(n, 1), this._depthMrts[i].setInternalTexture(o, 2), this._colorMrts[i].setInternalTexture(n, 0), this._colorMrts[i].setInternalTexture(o, 1), this._thinTextures.push(new ho(r), new ho(n), new ho(o)) } }, e.prototype._disposeTextures = function () { for (var e = 0; e < this._thinTextures.length; e++)6 !== e && this._thinTextures[e].dispose(); for (e = 0; e < 2; e++)this._depthMrts[e].dispose(!0), this._colorMrts[e].dispose(!0), this._blendBackMrt.dispose(!0); this._outputRT.dispose(), this._thinTextures = [], this._colorMrts = [], this._depthMrts = [] }, e.prototype._updateTextures = function () { return this._depthMrts[0].getSize().width === this._engine.getRenderWidth() && this._depthMrts[0].getSize().height === this._engine.getRenderHeight() || (this._disposeTextures(), this._createTextures()), this._updateTextureReferences() }, e.prototype._updateTextureReferences = function () { var e, t = this._scene.prePassRenderer; if (!t) return !1; var i = t.getIndex(a.PREPASS_COLOR_TEXTURE_TYPE), r = (null === (e = t.defaultRT.textures) || void 0 === e ? void 0 : e.length) ? t.defaultRT.textures[i].getInternalTexture() : null; return !!r && (this._blendBackTexture !== r && (this._blendBackTexture = r, this._blendBackMrt.setInternalTexture(this._blendBackTexture, 0), this._thinTextures[6] && this._thinTextures[6].dispose(), this._thinTextures[6] = new ho(this._blendBackTexture), t.defaultRT.renderTarget._shareDepth(this._depthMrts[0].renderTarget)), !0) }, e.prototype._createEffects = function () { this._blendBackEffectWrapper = new Ka({ fragmentShader: "oitBackBlend", useShaderStore: !0, engine: this._engine, samplerNames: ["uBackColor"], uniformNames: [] }), this._blendBackEffectWrapperPingPong = new Ka({ fragmentShader: "oitBackBlend", useShaderStore: !0, engine: this._engine, samplerNames: ["uBackColor"], uniformNames: [] }), this._finalEffectWrapper = new Ka({ fragmentShader: "oitFinal", useShaderStore: !0, engine: this._engine, samplerNames: ["uFrontColor", "uBackColor"], uniformNames: [] }), this._effectRenderer = new Ya(this._engine) }, e.prototype.setPrePassRenderer = function (e) { e.addEffectConfiguration(this._prePassEffectConfiguration) }, e.prototype.bind = function (e) { e.setTexture("oitDepthSampler", this._thinTextures[3 * this._currentPingPongState]), e.setTexture("oitFrontColorSampler", this._thinTextures[3 * this._currentPingPongState + 1]) }, e.prototype._renderSubMeshes = function (e) { var t; this._useRenderPasses && (t = {}); for (var i = 0; i < e.length; i++) { var r = e.data[i].getMaterial(), n = !0, o = !1, a = e.data[i], s = void 0, l = !1; if (this._useRenderPasses && (l = !(s = a._getDrawWrapper())), r && (n = r.allowShaderHotSwapping, o = r.backFaceCulling, r.allowShaderHotSwapping = !1, r.backFaceCulling = !1), a.render(!1), l && (s = a._getDrawWrapper()).materialContext) { var c = t[s.materialContext.uniqueId]; c || (c = t[s.materialContext.uniqueId] = this._engine.createMaterialContext()), a._getDrawWrapper().materialContext = c } r && (r.allowShaderHotSwapping = n, r.backFaceCulling = o) } }, e.prototype._finalCompose = function (e) { var t; (null === (t = this._scene.prePassRenderer) || void 0 === t ? void 0 : t.setCustomOutput(this._outputRT)) ? this._engine.bindFramebuffer(this._outputRT.renderTarget) : this._engine.restoreDefaultFramebuffer(), this._engine.setAlphaMode(a.ALPHA_DISABLE), this._engine.applyStates(), this._engine.enableEffect(this._finalEffectWrapper._drawWrapper), this._finalEffectWrapper.effect.setTexture("uFrontColor", this._thinTextures[3 * e + 1]), this._finalEffectWrapper.effect.setTexture("uBackColor", this._thinTextures[6]), this._effectRenderer.render(this._finalEffectWrapper) }, e.prototype.render = function (e) { if (this._candidateSubMeshes.length = 0, this._excludedSubMeshes.length = 0, !(this._blendBackEffectWrapper.effect.isReady() && this._blendBackEffectWrapperPingPong.effect.isReady() && this._finalEffectWrapper.effect.isReady() && this._updateTextures())) return this._excludedSubMeshes; for (var t = 0; t < e.length; t++) { var i = e.data[t], r = i.getMaterial(), n = r && i.getRenderingMesh()._getRenderingFillMode(r.fillMode); !r || n !== Hn.TriangleFanDrawMode && n !== Hn.TriangleFillMode && n !== Hn.TriangleStripDrawMode || -1 !== this._excludedMeshes.indexOf(i.getMesh().uniqueId) ? this._excludedSubMeshes.push(i) : this._candidateSubMeshes.push(i) } if (!this._candidateSubMeshes.length) return this._engine.bindFramebuffer(this._colorMrts[1].renderTarget), this._engine.bindAttachments(this._layoutCache[1]), this._engine.clear(this._colorCache[2], !0, !1, !1), this._engine.unBindFramebuffer(this._colorMrts[1].renderTarget), this._finalCompose(1), this._excludedSubMeshes; var o = this._engine.currentRenderPassId; this._scene.prePassRenderer._enabled = !1, this._useRenderPasses && (this._engine.currentRenderPassId = this._renderPassIds[0]), this._engine.bindFramebuffer(this._depthMrts[0].renderTarget), this._engine.bindAttachments(this._layoutCache[0]), this._engine.clear(this._colorCache[0], !0, !1, !1), this._engine.unBindFramebuffer(this._depthMrts[0].renderTarget), this._engine.bindFramebuffer(this._depthMrts[1].renderTarget), this._engine.bindAttachments(this._layoutCache[0]), this._engine.clear(this._colorCache[1], !0, !1, !1), this._engine.unBindFramebuffer(this._depthMrts[1].renderTarget), this._engine.bindFramebuffer(this._colorMrts[0].renderTarget), this._engine.bindAttachments(this._layoutCache[1]), this._engine.clear(this._colorCache[2], !0, !1, !1), this._engine.unBindFramebuffer(this._colorMrts[0].renderTarget), this._engine.bindFramebuffer(this._colorMrts[1].renderTarget), this._engine.bindAttachments(this._layoutCache[1]), this._engine.clear(this._colorCache[2], !0, !1, !1), this._engine.unBindFramebuffer(this._colorMrts[1].renderTarget), this._engine.bindFramebuffer(this._depthMrts[0].renderTarget), this._engine.bindAttachments(this._layoutCache[0]), this._engine.setAlphaMode(a.ALPHA_ONEONE_ONEONE), this._engine.setAlphaEquation(a.ALPHA_EQUATION_MAX), this._engine.depthCullingState.depthMask = !1, this._engine.depthCullingState.depthTest = !0, this._engine.applyStates(), this._currentPingPongState = 1, this._renderSubMeshes(this._candidateSubMeshes), this._engine.unBindFramebuffer(this._depthMrts[0].renderTarget), this._scene.resetCachedMaterial(); var s = 0, l = 0; for (t = 0; t < this._passCount; t++) { l = 1 - (s = t % 2), this._currentPingPongState = s, this._useRenderPasses && (this._engine.currentRenderPassId = this._renderPassIds[t + 1]), this._engine.bindFramebuffer(this._depthMrts[l].renderTarget), this._engine.bindAttachments(this._layoutCache[0]), this._engine.clear(this._colorCache[0], !0, !1, !1), this._engine.unBindFramebuffer(this._depthMrts[l].renderTarget), this._engine.bindFramebuffer(this._colorMrts[l].renderTarget), this._engine.bindAttachments(this._layoutCache[1]), this._engine.clear(this._colorCache[2], !0, !1, !1), this._engine.unBindFramebuffer(this._colorMrts[l].renderTarget), this._engine.bindFramebuffer(this._depthMrts[l].renderTarget), this._engine.bindAttachments(this._layoutCache[2]), this._engine.setAlphaMode(a.ALPHA_ONEONE_ONEONE), this._engine.setAlphaEquation(a.ALPHA_EQUATION_MAX), this._engine.depthCullingState.depthTest = !1, this._engine.applyStates(), this._renderSubMeshes(this._candidateSubMeshes), this._engine.unBindFramebuffer(this._depthMrts[l].renderTarget), this._scene.resetCachedMaterial(), this._engine.bindFramebuffer(this._blendBackMrt.renderTarget), this._engine.bindAttachments(this._layoutCache[0]), this._engine.setAlphaEquation(a.ALPHA_EQUATION_ADD), this._engine.setAlphaMode(a.ALPHA_LAYER_ACCUMULATE), this._engine.applyStates(); var c = 0 !== l && this._useRenderPasses ? this._blendBackEffectWrapperPingPong : this._blendBackEffectWrapper; this._engine.enableEffect(c._drawWrapper), c.effect.setTexture("uBackColor", this._thinTextures[3 * l + 2]), this._effectRenderer.render(c), this._engine.unBindFramebuffer(this._blendBackMrt.renderTarget) } return this._engine.currentRenderPassId = o, this._finalCompose(l), this._scene.prePassRenderer._enabled = !0, this._engine.depthCullingState.depthMask = !0, this._engine.depthCullingState.depthTest = !0, this._excludedSubMeshes }, e.prototype.dispose = function () { this._disposeTextures(), this._blendBackEffectWrapper.dispose(), this._finalEffectWrapper.dispose(), this._effectRenderer.dispose(), this._releaseRenderPassIds() }, e._DEPTH_CLEAR_VALUE = -99999, e._MIN_DEPTH = 0, e._MAX_DEPTH = 1, e }(); Object.defineProperty(Sr.prototype, "depthPeelingRenderer", { get: function () { if (!this._depthPeelingRenderer) { var e = this._getComponent(qi.NAME_DEPTHPEELINGRENDERER); e || (e = new gx(this), this._addComponent(e)) } return this._depthPeelingRenderer }, set: function (e) { this._depthPeelingRenderer = e }, enumerable: !0, configurable: !0 }), Object.defineProperty(Sr.prototype, "useOrderIndependentTransparency", { get: function () { return this._useOrderIndependentTransparency }, set: function (e) { var t; this._useOrderIndependentTransparency !== e && (this._useOrderIndependentTransparency = e, this.markAllMaterialsAsDirty(a.MATERIAL_AllDirtyFlag), null === (t = this.prePassRenderer) || void 0 === t || t.markAsDirty()) }, enumerable: !0, configurable: !0 }); var gx = function () { function e(e) { this.name = qi.NAME_DEPTHPEELINGRENDERER, this.scene = e, e.depthPeelingRenderer = new mx(e) } return e.prototype.register = function () { }, e.prototype.rebuild = function () { }, e.prototype.dispose = function () { var e; null === (e = this.scene.depthPeelingRenderer) || void 0 === e || e.dispose(), this.scene.depthPeelingRenderer = null }, e }(); Ut.ShadersStore.linePixelShader = "#include\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}"; Ut.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}", Ln.prototype.disableEdgesRendering = function () { return this._edgesRenderer && (this._edgesRenderer.dispose(), this._edgesRenderer = null), this }, Ln.prototype.enableEdgesRendering = function (e, t, i) { return void 0 === e && (e = .95), void 0 === t && (t = !1), this.disableEdgesRendering(), this._edgesRenderer = new yx(this, e, t, !0, i), this }, Object.defineProperty(Ln.prototype, "edgesRenderer", { get: function () { return this._edgesRenderer }, enumerable: !0, configurable: !0 }), zu.prototype.enableEdgesRendering = function (e, t) { return void 0 === e && (e = .95), void 0 === t && (t = !1), this.disableEdgesRendering(), this._edgesRenderer = new bx(this, e, t), this }, Wu.prototype.enableEdgesRendering = function (e, t) { return void 0 === e && (e = .95), void 0 === t && (t = !1), zu.prototype.enableEdgesRendering.apply(this, arguments), this }; var vx = function () { this.edges = new Array, this.edgesConnectedCount = 0 }, yx = 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 Ci(32), this._source = e, this._checkVerticesInsteadOfIndices = i, this._options = null != n ? n : null, this._epsilon = t, this._source.getScene().getEngine().isWebGPU && (this._drawWrapper = new Jt(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 Gu("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[Hi.PositionKind]; e && e._rebuild(), (e = this._buffers[Hi.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[Hi.PositionKind]; t && (t.dispose(), this._buffers[Hi.PositionKind] = null), (t = this._buffers[Hi.NormalKind]) && (t.dispose(), this._buffers[Hi.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]) < this._epsilon) && this.createLine(r, n, this._linesPositions.length / 3) }, e.prototype.createLine = function (e, t, i) { this._linesPositions.push(e.x, e.y, e.z, e.x, e.y, e.z, t.x, t.y, t.z, t.x, t.y, t.z), this._linesNormals.push(t.x, t.y, t.z, -1, t.x, t.y, t.z, 1, e.x, e.y, e.z, -1, e.x, e.y, e.z, 1), this._linesIndices.push(i, i + 1, i + 2, i, i + 2, i + 3) }, e.prototype._tessellateTriangle = function (e, t, i, r) { var n = function (e, t, i) { i >= 0 && t.push(i); for (var r = 0; r < e.length; ++r)t.push(e[r][0]) }, o = 0; e[1].length >= 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 : e[1] > t[1] ? 1 : 0 })) : e[a].sort((function (e, t) { return e[1] > t[1] ? -1 : e[1] < t[1] ? 1 : 0 })); var s = [], l = []; n(e[o], s, -1); for (var c = s.length, u = o + 2; u >= 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(Hi.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; g < u.length; g += 3) { var v = u[g + 0], y = u[g + 1], b = u[g + 2]; if (void 0 !== m[ie = v.toFixed(p) + "|" + y.toFixed(p) + "|" + b.toFixed(p)]) f.push(m[ie]); else { var T = g / 3; m[ie] = T, f.push(T), _.push(T) } } else for (g = 0; g < u.length; g += 3) { v = u[g + 0], y = u[g + 1], b = u[g + 2]; for (var E = !1, S = 0; S < g && !E; S += 3) { var x = u[S + 0], A = u[S + 1], C = u[S + 2]; if (Math.abs(v - x) < p && Math.abs(y - A) < p && Math.abs(b - C) < p) { f.push(S / 3), E = !0; break } } E || (f.push(g / 3), _.push(g / 3)) } if (null === (a = this._options) || void 0 === a ? void 0 : a.applyTessellation) { for (var P = null !== (l = null === (s = this._options) || void 0 === s ? void 0 : s.epsilonVertexAligned) && void 0 !== l ? l : 1e-6, I = [], M = 0; M < h.length; M += 3)for (var D = void 0, N = 0; N < 3; ++N) { var F = f[h[M + N]], L = f[h[M + (N + 1) % 3]], w = f[h[M + (N + 2) % 3]]; if (F !== L) for (var B = u[3 * F + 0], U = u[3 * F + 1], V = u[3 * F + 2], k = u[3 * L + 0], G = u[3 * L + 1], z = u[3 * L + 2], W = Math.sqrt((k - B) * (k - B) + (G - U) * (G - U) + (z - V) * (z - V)), H = 0; H < _.length - 1; H++) { var X = _[H]; if (X !== F && X !== L && X !== w) { var j = u[3 * X + 0], Y = u[3 * X + 1], K = u[3 * X + 2], Q = Math.sqrt((j - B) * (j - B) + (Y - U) * (Y - U) + (K - V) * (K - V)), q = Math.sqrt((j - k) * (j - k) + (Y - G) * (Y - G) + (K - z) * (K - z)); Math.abs(Q + q - W) < P && (D || (D = { index: M, edgesPoints: [[], [], []] }, I.push(D)), D.edgesPoints[N].push([X, Q])) } } } for (var Z = 0; Z < I.length; ++Z) { var J = I[Z]; this._tessellateTriangle(J.edgesPoints, J.index, h, f) } I.length = 0 } var $ = {}; for (M = 0; M < h.length; M += 3) { var ee = void 0; for (N = 0; N < 3; ++N)if (F = f[h[M + N]], L = f[h[M + (N + 1) % 3]], w = f[h[M + (N + 2) % 3]], F !== L && (F !== w && L !== w || !(null === (c = this._options) || void 0 === c ? void 0 : c.removeDegeneratedTriangles))) { if (O.Vector3[0].copyFromFloats(u[3 * F + 0], u[3 * F + 1], u[3 * F + 2]), O.Vector3[1].copyFromFloats(u[3 * L + 0], u[3 * L + 1], u[3 * L + 2]), O.Vector3[2].copyFromFloats(u[3 * w + 0], u[3 * w + 1], u[3 * w + 2]), ee || (O.Vector3[1].subtractToRef(O.Vector3[0], O.Vector3[3]), O.Vector3[2].subtractToRef(O.Vector3[1], O.Vector3[4]), (ee = R.Cross(O.Vector3[3], O.Vector3[4])).normalize()), F > L) { var te = F; F = L, L = te } (re = $[ie = F + "_" + L]) ? re.done || (R.Dot(ee, re.normal) < this._epsilon && this.createLine(O.Vector3[0], O.Vector3[1], this._linesPositions.length / 3), re.done = !0) : $[ie] = { normal: ee, done: !1, index: M, i: N } } } for (var ie in $) { var re; (re = $[ie]).done || (F = f[h[re.index + re.i]], L = f[h[re.index + (re.i + 1) % 3]], O.Vector3[0].copyFromFloats(u[3 * F + 0], u[3 * F + 1], u[3 * F + 2]), O.Vector3[1].copyFromFloats(u[3 * L + 0], u[3 * L + 1], u[3 * L + 2]), this.createLine(O.Vector3[0], O.Vector3[1], this._linesPositions.length / 3)) } var ne = this._source.getScene().getEngine(); this._buffers[Hi.PositionKind] = new Hi(ne, this._linesPositions, Hi.PositionKind, !1), this._buffers[Hi.NormalKind] = new Hi(ne, this._linesNormals, Hi.NormalKind, !1, !1, 4), this._buffersForInstances[Hi.PositionKind] = this._buffers[Hi.PositionKind], this._buffersForInstances[Hi.NormalKind] = this._buffers[Hi.NormalKind], this._ib = ne.createIndexBuffer(this._linesIndices), this._indicesCount = this._linesIndices.length } }, e.prototype._generateEdgesLines = function () { var e = this._source.getVerticesData(Hi.PositionKind), t = this._source.getIndices(); if (t && e) { var i, r, n = new Array, o = new Array; for (i = 0; i < t.length; i += 3) { r = new vx; var a = t[i], s = t[i + 1], l = t[i + 2]; r.p0 = new R(e[3 * a], e[3 * a + 1], e[3 * a + 2]), r.p1 = new R(e[3 * s], e[3 * s + 1], e[3 * s + 2]), r.p2 = new R(e[3 * l], e[3 * l + 1], e[3 * l + 2]); var c = R.Cross(r.p1.subtract(r.p0), r.p2.subtract(r.p1)); c.normalize(), o.push(c), n.push(r) } for (i = 0; i < n.length; i++) { r = n[i]; for (var u = i + 1; u < n.length; u++) { var h = n[u]; if (3 === r.edgesConnectedCount) break; if (3 !== h.edgesConnectedCount) for (var d = t[3 * u], p = t[3 * u + 1], f = t[3 * u + 2], _ = 0; _ < 3; _++) { var m = 0; if (void 0 === r.edges[_]) { switch (_) { case 0: m = this._checkVerticesInsteadOfIndices ? this._processEdgeForAdjacenciesWithVertices(r.p0, r.p1, h.p0, h.p1, h.p2) : this._processEdgeForAdjacencies(t[3 * i], t[3 * i + 1], d, p, f); break; case 1: m = this._checkVerticesInsteadOfIndices ? this._processEdgeForAdjacenciesWithVertices(r.p1, r.p2, h.p0, h.p1, h.p2) : this._processEdgeForAdjacencies(t[3 * i + 1], t[3 * i + 2], d, p, f); break; case 2: m = this._checkVerticesInsteadOfIndices ? this._processEdgeForAdjacenciesWithVertices(r.p2, r.p0, h.p0, h.p1, h.p2) : this._processEdgeForAdjacencies(t[3 * i + 2], t[3 * i], d, p, f) }if (-1 !== m && (r.edges[_] = u, h.edges[m] = i, r.edgesConnectedCount++, h.edgesConnectedCount++, 3 === r.edgesConnectedCount)) break } } } } for (i = 0; i < n.length; i++) { var g = n[i]; this._checkEdge(i, g.edges[0], o, g.p0, g.p1), this._checkEdge(i, g.edges[1], o, g.p1, g.p2), this._checkEdge(i, g.edges[2], o, g.p2, g.p0) } var v = this._source.getScene().getEngine(); this._buffers[Hi.PositionKind] = new Hi(v, this._linesPositions, Hi.PositionKind, !1), this._buffers[Hi.NormalKind] = new Hi(v, this._linesNormals, Hi.NormalKind, !1, !1, 4), this._buffersForInstances[Hi.PositionKind] = this._buffers[Hi.PositionKind], this._buffersForInstances[Hi.NormalKind] = this._buffers[Hi.NormalKind], this._ib = v.createIndexBuffer(this._linesIndices), this._indicesCount = this._linesIndices.length } }, e.prototype.isReady = function () { return this._lineShader.isReady(this._source, this._source.hasInstances && this.customInstances.length > 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; l < n; ++l)this.customInstances.data[l].copyToArray(o.instancesData, s), s += 16; o.instancesBuffer.updateDirectly(o.instancesData, 0, n) } } else n = this._source.thinInstanceCount; var c = e.getEngine(); this._lineShader._preBind(), 1 !== this._source.edgesColor.a ? c.setAlphaMode(a.ALPHA_COMBINE) : c.setAlphaMode(a.ALPHA_DISABLE), c.bindBuffers(r ? this._buffersForInstances : this._buffers, this._ib, this._lineShader.getEffect()), e.resetCachedMaterial(), this._lineShader.setColor4("color", this._source.edgesColor), e.activeCamera.mode === ln.ORTHOGRAPHIC_CAMERA ? this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForOrthographic) : this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForPerspective), this._lineShader.setFloat("aspectRatio", c.getAspectRatio(e.activeCamera)), this._lineShader.bind(this._source.getWorldMatrix()), c.drawElementsType(Hn.TriangleFillMode, 0, this._indicesCount, n), this._lineShader.unbind(), r && c.unbindInstanceAttributes(), this._source.getScene()._activeMeshesFrozen || this.customInstances.reset(), this._lineShader._setDrawWrapper(t) } else this._lineShader._setDrawWrapper(t) }, e }(), bx = function (e) { function t(t, i, r) { void 0 === i && (i = .95), void 0 === r && (r = !1); var n = e.call(this, t, i, r, !1) || this; return n._generateEdgesLines(), n } return W(t, e), t.prototype._generateEdgesLines = function () { var e = this._source.getVerticesData(Hi.PositionKind), t = this._source.getIndices(); if (t && e) { for (var i = O.Vector3[0], r = O.Vector3[1], n = t.length - 1, o = 0, a = 0; o < n; o += 2, a += 4)R.FromArrayToRef(e, 3 * t[o], i), R.FromArrayToRef(e, 3 * t[o + 1], r), this.createLine(i, r, a); var s = this._source.getScene().getEngine(); this._buffers[Hi.PositionKind] = new Hi(s, this._linesPositions, Hi.PositionKind, !1), this._buffers[Hi.NormalKind] = new Hi(s, this._linesNormals, Hi.NormalKind, !1, !1, 4), this._ib = s.createIndexBuffer(this._linesIndices), this._indicesCount = this._linesIndices.length } }, t }(yx), Tx = function (e) { function t(t, i, r, n, o, a) { var s = e.call(this, t, r, n, o, a) || this; return s._beforeCompositionPostProcesses = [], s._internalTextureDirty = !1, s.enabled = !1, s.renderTargetTexture = null, s.renderTargetTexture = i, s } return W(t, e), t.prototype._createCompositionEffect = function () { this.imageProcessingPostProcess = new bc("prePassComposition", 1, null, void 0, this._engine), this.imageProcessingPostProcess._updateParameters() }, t.prototype._checkSize = function () { var e = this._engine.getRenderWidth(!0), t = this._engine.getRenderHeight(!0), i = this.getRenderWidth(), r = this.getRenderHeight(); i === e && r === t || (this.resize({ width: e, height: t }), this._internalTextureDirty = !0) }, t.prototype.updateCount = function (t, i, r) { e.prototype.updateCount.call(this, t, i, r), this._internalTextureDirty = !0 }, t.prototype._resetPostProcessChain = function () { this._beforeCompositionPostProcesses.length = 0 }, t.prototype.dispose = function () { var t = this._scene; if (e.prototype.dispose.call(this), t && t.prePassRenderer) { var i = t.prePassRenderer.renderTargets.indexOf(this); -1 !== i && t.prePassRenderer.renderTargets.splice(i, 1) } this.imageProcessingPostProcess && this.imageProcessingPostProcess.dispose(), this.renderTargetTexture && (this.renderTargetTexture._prePassRenderTarget = null), this._outputPostProcess && (this._outputPostProcess.autoClear = !0, this._outputPostProcess.restoreDefaultInputTexture()) }, t }(hv), Ex = function () { function e(t) { this.excludedSkinnedMesh = [], this.excludedMaterials = [], this.mrtCount = 0, this._mrtTypes = [], this._mrtFormats = [], this._mrtLayout = [], this._mrtNames = [], this._textureIndices = [], this._useSpecificClearForDepthTexture = !1, this._isDirty = !0, this._effectConfigurations = [], this.doNotUseGeometryRendererFallback = !0, this.renderTargets = [], this._clearColor = new U(0, 0, 0, 0), this._clearDepthColor = new U(1e8, 0, 0, 1), this._enabled = !1, this._needsCompositionForThisPass = !1, this.disableGammaTransform = !1, this._scene = t, this._engine = t.getEngine(); var i = a.TEXTURETYPE_UNSIGNED_BYTE; if (this._engine._caps.textureFloat && this._engine._caps.textureFloatLinearFiltering ? i = a.TEXTURETYPE_FLOAT : this._engine._caps.textureHalfFloat && this._engine._caps.textureHalfFloatLinearFiltering && (i = a.TEXTURETYPE_HALF_FLOAT), i !== a.TEXTURETYPE_FLOAT) for (var r = 0; r < e.TextureFormats.length; ++r)e.TextureFormats[r].type === a.TEXTURETYPE_FLOAT && (e.TextureFormats[a.PREPASS_DEPTH_TEXTURE_TYPE].type = i); e._SceneComponentInitialization(this._scene), this.defaultRT = this._createRenderTarget("sceneprePassRT", null), this._currentTarget = this.defaultRT } return e.prototype.getIndex = function (e) { return this._textureIndices[e] }, Object.defineProperty(e.prototype, "samples", { get: function () { return this.defaultRT.samples }, set: function (e) { this.defaultRT.samples = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "useSpecificClearForDepthTexture", { get: function () { return this._useSpecificClearForDepthTexture }, set: function (e) { this._useSpecificClearForDepthTexture !== e && (this._useSpecificClearForDepthTexture = e, this._isDirty = !0) }, enumerable: !1, configurable: !0 }), e.prototype.getRenderTarget = function () { return this._currentTarget }, e.prototype._setRenderTarget = function (e) { var t, i; e ? this._currentTarget = e : (this._currentTarget = this.defaultRT, this._engine.currentRenderPassId = null !== (i = null === (t = this._scene.activeCamera) || void 0 === t ? void 0 : t.renderPassId) && void 0 !== i ? i : this._currentTarget.renderPassId) }, Object.defineProperty(e.prototype, "currentRTisSceneRT", { get: function () { return this._currentTarget === this.defaultRT }, enumerable: !1, configurable: !0 }), e.prototype._refreshGeometryBufferRendererLink = function () { if (this.doNotUseGeometryRendererFallback) this._geometryBuffer && this._geometryBuffer._unlinkPrePassRenderer(), this._geometryBuffer = null, this._scene.disableGeometryBufferRenderer(); else { if (this._geometryBuffer = this._scene.enableGeometryBufferRenderer(), !this._geometryBuffer) return void (this.doNotUseGeometryRendererFallback = !0); this._geometryBuffer._linkPrePassRenderer(this) } }, Object.defineProperty(e.prototype, "enabled", { get: function () { return this._enabled }, enumerable: !1, configurable: !0 }), e.prototype._createRenderTarget = function (e, t) { var i = new Tx(e, t, { width: this._engine.getRenderWidth(), height: this._engine.getRenderHeight() }, 0, this._scene, { generateMipMaps: !1, generateStencilBuffer: this._engine.isStencilEnable, defaultType: a.TEXTURETYPE_UNSIGNED_INT, types: [], drawOnlyOnFirstAttachmentByDefault: !0 }); return this.renderTargets.push(i), this._enabled && this._update(), i }, Object.defineProperty(e.prototype, "isSupported", { get: function () { return this._scene.getEngine().getCaps().drawBuffersExtension }, enumerable: !1, configurable: !0 }), e.prototype.bindAttachmentsForEffect = function (e, t) { var i = t.getMaterial(), r = i && i.isPrePassCapable, n = i && -1 !== this.excludedMaterials.indexOf(i); this.enabled && this._currentTarget.enabled && (e._multiTarget && r && !n ? this._engine.bindAttachments(this._multiRenderAttachments) : (this._engine._currentRenderTarget ? this._engine.bindAttachments(this._defaultAttachments) : this._engine.restoreSingleAttachment(), this._geometryBuffer && this.currentRTisSceneRT && !n && this._geometryBuffer.renderList.push(t.getRenderingMesh()))) }, e.prototype._reinitializeAttachments = function () { for (var e = [], t = [!1], i = [!1], r = [!0], n = 0; n < this.mrtCount; n++)e.push(!0), n > 0 && (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 < e.TextureFormats.length; t++)this._textureIndices[e.TextureFormats[t].purpose] = -1; this._textureIndices[a.PREPASS_COLOR_TEXTURE_TYPE] = 0, this._mrtLayout = [a.PREPASS_COLOR_TEXTURE_TYPE], this._mrtTypes = [e.TextureFormats[a.PREPASS_COLOR_TEXTURE_TYPE].type], this._mrtFormats = [e.TextureFormats[a.PREPASS_COLOR_TEXTURE_TYPE].format], this._mrtNames = [e.TextureFormats[a.PREPASS_COLOR_TEXTURE_TYPE].name], this.mrtCount = 1 }, e.prototype._updateGeometryBufferLayout = function () { if (this._refreshGeometryBufferRendererLink(), this._geometryBuffer) { this._geometryBuffer._resetLayout(); for (var e = [], t = 0; t < this._mrtLayout.length; t++)e.push(!1); this._geometryBuffer._linkInternalTexture(this.defaultRT.getInternalTexture()); var i = [{ prePassConstant: a.PREPASS_DEPTH_TEXTURE_TYPE, geometryBufferConstant: zS.DEPTH_TEXTURE_TYPE }, { prePassConstant: a.PREPASS_NORMAL_TEXTURE_TYPE, geometryBufferConstant: zS.NORMAL_TEXTURE_TYPE }, { prePassConstant: a.PREPASS_POSITION_TEXTURE_TYPE, geometryBufferConstant: zS.POSITION_TEXTURE_TYPE }, { prePassConstant: a.PREPASS_REFLECTIVITY_TEXTURE_TYPE, geometryBufferConstant: zS.REFLECTIVITY_TEXTURE_TYPE }, { prePassConstant: a.PREPASS_VELOCITY_TEXTURE_TYPE, geometryBufferConstant: zS.VELOCITY_TEXTURE_TYPE }]; for (t = 0; t < i.length; t++) { var r = this._mrtLayout.indexOf(i[t].prePassConstant); -1 !== r && (this._geometryBuffer._forceTextureType(i[t].geometryBufferConstant, r), e[r] = !0) } this._geometryBuffer._setAttachments(this._engine.buildTextureLayout(e)) } }, e.prototype.restoreAttachments = function () { this.enabled && this._currentTarget.enabled && this._defaultAttachments && (this._engine._currentRenderTarget ? this._engine.bindAttachments(this._defaultAttachments) : this._engine.restoreSingleAttachment()) }, e.prototype._beforeDraw = function (e, t, i) { this._isDirty && this._update(), this._enabled && this._currentTarget.enabled && (this._geometryBuffer && (this._geometryBuffer.renderList = []), this._setupOutputForThisPass(this._currentTarget, e)) }, e.prototype._prepareFrame = function (e, t, i) { e.renderTargetTexture ? e.renderTargetTexture._prepareFrame(this._scene, t, i, e.renderTargetTexture.useCameraPostProcesses) : this._postProcessesSourceForThisPass.length ? this._scene.postProcessManager._prepareFrame() : this._engine.restoreDefaultFramebuffer() }, e.prototype.setCustomOutput = function (e) { var t = this._postProcessesSourceForThisPass[0]; return !!t && (t.inputTexture = e.renderTarget, !0) }, e.prototype._renderPostProcesses = function (e, t) { var i, r = this._postProcessesSourceForThisPass[0], n = r ? r.inputTexture : e.renderTargetTexture ? e.renderTargetTexture.renderTarget : null, o = this._currentTarget._beforeCompositionPostProcesses; this._needsCompositionForThisPass && (o = o.concat([this._currentTarget.imageProcessingPostProcess])), o.length && (this._scene.postProcessManager._prepareFrame(null === (i = this._currentTarget.renderTarget) || void 0 === i ? void 0 : i.texture, o), this._scene.postProcessManager.directRender(o, n, !1, t)) }, e.prototype._afterDraw = function (e, t) { this._enabled && this._currentTarget.enabled && (this._prepareFrame(this._currentTarget, e, t), this._renderPostProcesses(this._currentTarget, e)) }, e.prototype._clear = function () { this._enabled && this._currentTarget.enabled && (this._bindFrameBuffer(this._currentTarget), this._engine.bindAttachments(this._clearAttachments), this._engine.clear(this._clearColor, !0, !1, !1), this._useSpecificClearForDepthTexture && (this._engine.bindAttachments(this._clearDepthAttachments), this._engine.clear(this._clearDepthColor, !0, !1, !1)), this._engine.bindAttachments(this._defaultAttachments)) }, e.prototype._bindFrameBuffer = function (e) { if (this._enabled && this._currentTarget.enabled) { this._currentTarget._checkSize(); var t = this._currentTarget.renderTarget; t && this._engine.bindFramebuffer(t) } }, e.prototype._setEnabled = function (e) { this._enabled = e }, e.prototype._setRenderTargetEnabled = function (e, t) { e.enabled = t, t || this._unlinkInternalTexture(e) }, e.prototype.addEffectConfiguration = function (e) { for (var t = 0; t < this._effectConfigurations.length; t++)if (this._effectConfigurations[t].name === e.name) return this._effectConfigurations[t]; return this._effectConfigurations.push(e), e }, e.prototype._enable = function () { for (var e = this.mrtCount, t = 0; t < this._effectConfigurations.length; t++)this._effectConfigurations[t].enabled && this._enableTextures(this._effectConfigurations[t].texturesRequired); for (t = 0; t < this.renderTargets.length; t++) { this.mrtCount === e && this.renderTargets[t].count === this.mrtCount || this.renderTargets[t].updateCount(this.mrtCount, { types: this._mrtTypes, formats: this._mrtFormats }, this._mrtNames.concat("prePass_DepthBuffer")), this.renderTargets[t]._resetPostProcessChain(); for (var i = 0; i < this._effectConfigurations.length; i++)this._effectConfigurations[i].enabled && (!this._effectConfigurations[i].postProcess && this._effectConfigurations[i].createPostProcess && this._effectConfigurations[i].createPostProcess(), this._effectConfigurations[i].postProcess && this.renderTargets[t]._beforeCompositionPostProcesses.push(this._effectConfigurations[i].postProcess)) } this._reinitializeAttachments(), this._setEnabled(!0), this._updateGeometryBufferLayout() }, e.prototype._disable = function () { this._setEnabled(!1); for (var e = 0; e < this.renderTargets.length; e++)this._setRenderTargetEnabled(this.renderTargets[e], !1); for (this._resetLayout(), e = 0; e < this._effectConfigurations.length; e++)this._effectConfigurations[e].enabled = !1 }, e.prototype._getPostProcessesSource = function (e, t) { if (t) return t._postProcesses; if (e.renderTargetTexture) { if (e.renderTargetTexture.useCameraPostProcesses) { var i = e.renderTargetTexture.activeCamera ? e.renderTargetTexture.activeCamera : this._scene.activeCamera; return i ? i._postProcesses : [] } return e.renderTargetTexture.postProcesses ? e.renderTargetTexture.postProcesses : [] } return this._scene.activeCamera ? this._scene.activeCamera._postProcesses : [] }, e.prototype._setupOutputForThisPass = function (e, t) { var i = t && this._scene.activeCameras && !!this._scene.activeCameras.length && 0 !== this._scene.activeCameras.indexOf(t); this._postProcessesSourceForThisPass = this._getPostProcessesSource(e, t), this._postProcessesSourceForThisPass = this._postProcessesSourceForThisPass.filter((function (e) { return null != e })), this._scene.autoClear = !0; var r = this._hasImageProcessing(this._postProcessesSourceForThisPass); this._needsCompositionForThisPass = !r && !this.disableGammaTransform && this._needsImageProcessing() && !i; var n = this._getFirstPostProcess(this._postProcessesSourceForThisPass), o = e._beforeCompositionPostProcesses && e._beforeCompositionPostProcesses[0], a = null; this._scene.imageProcessingConfiguration.applyByPostProcess = this._needsCompositionForThisPass || r, this._needsCompositionForThisPass && !e.imageProcessingPostProcess && e._createCompositionEffect(), o ? a = o : this._needsCompositionForThisPass ? a = e.imageProcessingPostProcess : n && (a = n), this._bindFrameBuffer(e), this._linkInternalTexture(e, a) }, e.prototype._linkInternalTexture = function (e, t) { t && (t.autoClear = !1, t.inputTexture = e.renderTarget), e._outputPostProcess !== t && (e._outputPostProcess && this._unlinkInternalTexture(e), e._outputPostProcess = t), e._internalTextureDirty && (this._updateGeometryBufferLayout(), e._internalTextureDirty = !1) }, e.prototype._unlinkInternalTexture = function (e) { e._outputPostProcess && (e._outputPostProcess.autoClear = !0, e._outputPostProcess.restoreDefaultInputTexture(), e._outputPostProcess = null) }, e.prototype._needsImageProcessing = function () { for (var e = 0; e < this._effectConfigurations.length; e++)if (this._effectConfigurations[e].enabled && this._effectConfigurations[e].needsImageProcessing) return !0; return !1 }, e.prototype._hasImageProcessing = function (e) { var t, i = !1; if (e) for (var r = 0; r < e.length; r++)if ("ImageProcessingPostProcess" === (null === (t = e[r]) || void 0 === t ? void 0 : t.getClassName())) { i = !0; break } return i }, e.prototype._getFirstPostProcess = function (e) { for (var t = 0; t < e.length; t++)if (null !== e[t]) return e[t]; return null }, e.prototype.markAsDirty = function () { this._isDirty = !0 }, e.prototype._enableTextures = function (t) { this._scene.needsPreviousWorldMatrices = !1; for (var i = 0; i < t.length; i++) { var r = t[i]; -1 === this._textureIndices[r] && (this._textureIndices[r] = this._mrtLayout.length, this._mrtLayout.push(r), this._mrtTypes.push(e.TextureFormats[r].type), this._mrtFormats.push(e.TextureFormats[r].format), this._mrtNames.push(e.TextureFormats[r].name), this.mrtCount++), r === a.PREPASS_VELOCITY_TEXTURE_TYPE && (this._scene.needsPreviousWorldMatrices = !0) } }, e.prototype.update = function () { this._isDirty && this._update() }, e.prototype._update = function () { this._disable(); var e, t = !1; this._scene.imageProcessingConfiguration.applyByPostProcess = !1, this._scene._depthPeelingRenderer && this._scene.useOrderIndependentTransparency && (this._scene._depthPeelingRenderer.setPrePassRenderer(this), t = !0); for (var i = 0; i < this._scene.materials.length; i++)this._scene.materials[i].setPrePassRenderer(this) && (t = !0); for (t && this._setRenderTargetEnabled(this.defaultRT, !0), i = 0; i < this.renderTargets.length; i++) { if (this.renderTargets[i].renderTargetTexture) e = this._getPostProcessesSource(this.renderTargets[i]); else { var r = this._scene.activeCamera; if (!r) continue; e = r._postProcesses } if (e && (e = e.filter((function (e) { return null != e })))) { for (var n = 0; n < e.length; n++)e[n].setPrePassRenderer(this) && (this._setRenderTargetEnabled(this.renderTargets[i], !0), t = !0); this._hasImageProcessing(e) && (this._scene.imageProcessingConfiguration.applyByPostProcess = !0) } } this._markAllMaterialsAsPrePassDirty(), this._isDirty = !1, t && this._enable() }, e.prototype._markAllMaterialsAsPrePassDirty = function () { for (var e = this._scene.materials, t = 0; t < e.length; t++)e[t].markAsDirty(Hn.PrePassDirtyFlag) }, e.prototype.dispose = function () { for (var e = this.renderTargets.length - 1; e >= 0; e--)this.renderTargets[e].dispose(); for (e = 0; e < this._effectConfigurations.length; e++)this._effectConfigurations[e].dispose && this._effectConfigurations[e].dispose() }, e._SceneComponentInitialization = function (e) { throw ge("PrePassRendererSceneComponent") }, e.TextureFormats = [{ purpose: a.PREPASS_IRRADIANCE_TEXTURE_TYPE, type: a.TEXTURETYPE_HALF_FLOAT, format: a.TEXTUREFORMAT_RGBA, name: "prePass_Irradiance" }, { purpose: a.PREPASS_POSITION_TEXTURE_TYPE, type: a.TEXTURETYPE_HALF_FLOAT, format: a.TEXTUREFORMAT_RGBA, name: "prePass_Position" }, { purpose: a.PREPASS_VELOCITY_TEXTURE_TYPE, type: a.TEXTURETYPE_UNSIGNED_INT, format: a.TEXTUREFORMAT_RGBA, name: "prePass_Velocity" }, { purpose: a.PREPASS_REFLECTIVITY_TEXTURE_TYPE, type: a.TEXTURETYPE_UNSIGNED_INT, format: a.TEXTUREFORMAT_RGBA, name: "prePass_Reflectivity" }, { purpose: a.PREPASS_COLOR_TEXTURE_TYPE, type: a.TEXTURETYPE_HALF_FLOAT, format: a.TEXTUREFORMAT_RGBA, name: "prePass_Color" }, { purpose: a.PREPASS_DEPTH_TEXTURE_TYPE, type: a.TEXTURETYPE_FLOAT, format: a.TEXTUREFORMAT_R, name: "prePass_Depth" }, { purpose: a.PREPASS_NORMAL_TEXTURE_TYPE, type: a.TEXTURETYPE_HALF_FLOAT, format: a.TEXTUREFORMAT_RGBA, name: "prePass_Normal" }, { purpose: a.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE, type: a.TEXTURETYPE_UNSIGNED_INT, format: a.TEXTUREFORMAT_RGBA, name: "prePass_Albedo" }], e }(); Object.defineProperty(Sr.prototype, "prePassRenderer", { get: function () { return this._prePassRenderer }, set: function (e) { e && e.isSupported && (this._prePassRenderer = e) }, enumerable: !0, configurable: !0 }), Sr.prototype.enablePrePassRenderer = function () { return this._prePassRenderer || (this._prePassRenderer = new Ex(this), this._prePassRenderer.isSupported || (this._prePassRenderer = null, $.Error("PrePassRenderer needs WebGL 2 support.\nMaybe you tried to use the following features that need the PrePassRenderer :\n + Subsurface Scattering"))), this._prePassRenderer }, Sr.prototype.disablePrePassRenderer = function () { this._prePassRenderer && (this._prePassRenderer.dispose(), this._prePassRenderer = null) }; var Sx = function () { function e(e) { this.name = qi.NAME_PREPASSRENDERER, this.scene = e } return e.prototype.register = function () { this.scene._beforeCameraDrawStage.registerStep(qi.STEP_BEFORECAMERADRAW_PREPASS, this, this._beforeCameraDraw), this.scene._afterCameraDrawStage.registerStep(qi.STEP_AFTERCAMERADRAW_PREPASS, this, this._afterCameraDraw), this.scene._beforeRenderTargetDrawStage.registerStep(qi.STEP_BEFORERENDERTARGETDRAW_PREPASS, this, this._beforeRenderTargetDraw), this.scene._afterRenderTargetDrawStage.registerStep(qi.STEP_AFTERCAMERADRAW_PREPASS, this, this._afterRenderTargetDraw), this.scene._beforeClearStage.registerStep(qi.STEP_BEFORECLEAR_PREPASS, this, this._beforeClearStage), this.scene._beforeRenderTargetClearStage.registerStep(qi.STEP_BEFORERENDERTARGETCLEAR_PREPASS, this, this._beforeRenderTargetClearStage), this.scene._beforeRenderingMeshStage.registerStep(qi.STEP_BEFORERENDERINGMESH_PREPASS, this, this._beforeRenderingMeshStage), this.scene._afterRenderingMeshStage.registerStep(qi.STEP_AFTERRENDERINGMESH_PREPASS, this, this._afterRenderingMeshStage) }, e.prototype._beforeRenderTargetDraw = function (e, t, i) { this.scene.prePassRenderer && !e.noPrePassRenderer && (this.scene.prePassRenderer._setRenderTarget(e._prePassRenderTarget), this.scene.prePassRenderer._beforeDraw(void 0, t, i)) }, e.prototype._afterRenderTargetDraw = function (e, t, i) { this.scene.prePassRenderer && !e.noPrePassRenderer && this.scene.prePassRenderer._afterDraw(t, i) }, e.prototype._beforeRenderTargetClearStage = function (e) { this.scene.prePassRenderer && !e.noPrePassRenderer && (e._prePassRenderTarget || (e._prePassRenderTarget = this.scene.prePassRenderer._createRenderTarget(e.name + "_prePassRTT", e)), this.scene.prePassRenderer._setRenderTarget(e._prePassRenderTarget), this.scene.prePassRenderer._clear()) }, e.prototype._beforeCameraDraw = function (e) { this.scene.prePassRenderer && (this.scene.prePassRenderer._setRenderTarget(null), this.scene.prePassRenderer._beforeDraw(e)) }, e.prototype._afterCameraDraw = function () { this.scene.prePassRenderer && this.scene.prePassRenderer._afterDraw() }, e.prototype._beforeClearStage = function () { this.scene.prePassRenderer && (this.scene.prePassRenderer._setRenderTarget(null), this.scene.prePassRenderer._clear()) }, e.prototype._beforeRenderingMeshStage = function (e, t, i, r) { if (r) { var n = e.getScene(); n.prePassRenderer && n.prePassRenderer.bindAttachmentsForEffect(r, t) } }, e.prototype._afterRenderingMeshStage = function (e) { var t = e.getScene(); t.prePassRenderer && t.prePassRenderer.restoreAttachments() }, e.prototype.rebuild = function () { this.scene.disablePrePassRenderer(), this.scene.enablePrePassRenderer() }, e.prototype.dispose = function () { this.scene.disablePrePassRenderer() }, e }(); Ex._SceneComponentInitialization = function (e) { var t = e._getComponent(qi.NAME_PREPASSRENDERER); t || (t = new Sx(e), e._addComponent(t)) }; Ut.IncludesShadersStore.fibonacci = "#define rcp(x) 1./x\n#define GOLDEN_RATIO 1.618033988749895\n#define TWO_PI 6.2831855\nvec2 Golden2dSeq(int i,float n)\n{return vec2(float(i)/n+(0.5/n),fract(float(i)*rcp(GOLDEN_RATIO)));}\nvec2 SampleDiskGolden(int i,int sampleCount)\n{vec2 f=Golden2dSeq(i,float(sampleCount));return vec2(sqrt(f.x),TWO_PI*f.y);}"; Ut.IncludesShadersStore.diffusionProfile = "uniform vec3 diffusionS[5];uniform float diffusionD[5];uniform float filterRadii[5];"; Ut.ShadersStore.subSurfaceScatteringPixelShader = "#include\n#include\n#include\n#include\nvarying vec2 vUV;uniform vec2 texelSize;uniform sampler2D textureSampler;uniform sampler2D irradianceSampler;uniform sampler2D depthSampler;uniform sampler2D albedoSampler;uniform vec2 viewportSize;uniform float metersPerUnit;const float LOG2_E=1.4426950408889634;const float SSS_PIXELS_PER_SAMPLE=4.;const int _SssSampleBudget=40;\n#define rcp(x) 1./x\n#define Sq(x) x*x\n#define SSS_BILATERAL_FILTER true\nvec3 EvalBurleyDiffusionProfile(float r,vec3 S)\n{vec3 exp_13=exp2(((LOG2_E*(-1.0/3.0))*r)*S); \nvec3 expSum=exp_13*(1.+exp_13*exp_13); \nreturn (S*rcp(8.*PI))*expSum; }\nvec2 SampleBurleyDiffusionProfile(float u,float rcpS)\n{u=1.-u; \nfloat g=1.+(4.*u)*(2.*u+sqrt(1.+(4.*u)*u));float n=exp2(log2(g)*(-1.0/3.0)); \nfloat p=(g*n)*n; \nfloat c=1.+p+n; \nfloat d=(3./LOG2_E*2.)+(3./LOG2_E)*log2(u); \nfloat x=(3./LOG2_E)*log2(c)-d; \nfloat rcpExp=((c*c)*c)*rcp((4.*u)*((c*c)+(4.*u)*(4.*u)));float r=x*rcpS;float rcpPdf=(8.*PI*rcpS)*rcpExp; \nreturn vec2(r,rcpPdf);}\nvec3 ComputeBilateralWeight(float xy2,float z,float mmPerUnit,vec3 S,float rcpPdf)\n{\n#ifndef SSS_BILATERAL_FILTER\nz=0.;\n#endif\nfloat r=sqrt(xy2+(z*mmPerUnit)*(z*mmPerUnit));float area=rcpPdf;\n#if SSS_CLAMP_ARTIFACT\nreturn clamp(EvalBurleyDiffusionProfile(r,S)*area,0.0,1.0);\n#else\nreturn EvalBurleyDiffusionProfile(r,S)*area;\n#endif\n}\nvoid EvaluateSample(int i,int n,vec3 S,float d,vec3 centerPosVS,float mmPerUnit,float pixelsPerMm,\nfloat phase,inout vec3 totalIrradiance,inout vec3 totalWeight)\n{float scale =rcp(float(n));float offset=rcp(float(n))*0.5;float sinPhase,cosPhase;sinPhase=sin(phase);cosPhase=cos(phase);vec2 bdp=SampleBurleyDiffusionProfile(float(i)*scale+offset,d);float r=bdp.x;float rcpPdf=bdp.y;float phi=SampleDiskGolden(i,n).y;float sinPhi,cosPhi;sinPhi=sin(phi);cosPhi=cos(phi);float sinPsi=cosPhase*sinPhi+sinPhase*cosPhi; \nfloat cosPsi=cosPhase*cosPhi-sinPhase*sinPhi; \nvec2 vec=r*vec2(cosPsi,sinPsi);vec2 position; \nfloat xy2;position=vUV+round((pixelsPerMm*r)*vec2(cosPsi,sinPsi))*texelSize;xy2 =r*r;vec4 textureSample=texture2D(irradianceSampler,position);float viewZ=texture2D(depthSampler,position).r;vec3 irradiance =textureSample.rgb;if (testLightingForSSS(textureSample.a))\n{float relZ=viewZ-centerPosVS.z;vec3 weight=ComputeBilateralWeight(xy2,relZ,mmPerUnit,S,rcpPdf);totalIrradiance+=weight*irradiance;totalWeight +=weight;}\nelse\n{}}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{vec4 irradianceAndDiffusionProfile =texture2D(irradianceSampler,vUV);vec3 centerIrradiance=irradianceAndDiffusionProfile.rgb;int diffusionProfileIndex=int(round(irradianceAndDiffusionProfile.a*255.));float centerDepth =0.;vec4 inputColor=texture2D(textureSampler,vUV);bool passedStencilTest=testLightingForSSS(irradianceAndDiffusionProfile.a);if (passedStencilTest)\n{centerDepth=texture2D(depthSampler,vUV).r;}\nif (!passedStencilTest) { \ngl_FragColor=inputColor;return;}\nfloat distScale =1.;vec3 S =diffusionS[diffusionProfileIndex];float d =diffusionD[diffusionProfileIndex];float filterRadius=filterRadii[diffusionProfileIndex];vec2 centerPosNDC=vUV;vec2 cornerPosNDC=vUV+0.5*texelSize;vec3 centerPosVS =vec3(centerPosNDC*viewportSize,1.0)*centerDepth; \nvec3 cornerPosVS =vec3(cornerPosNDC*viewportSize,1.0)*centerDepth; \nfloat mmPerUnit =1000.*(metersPerUnit*rcp(distScale));float unitsPerMm=rcp(mmPerUnit);float unitsPerPixel=2.*abs(cornerPosVS.x-centerPosVS.x);float pixelsPerMm =rcp(unitsPerPixel)*unitsPerMm;float filterArea =PI*Sq(filterRadius*pixelsPerMm);int sampleCount =int(filterArea*rcp(SSS_PIXELS_PER_SAMPLE));int sampleBudget=_SssSampleBudget;int texturingMode=0;vec3 albedo =texture2D(albedoSampler,vUV).rgb;if (distScale==0. || sampleCount<1)\n{\n#ifdef DEBUG_SSS_SAMPLES\nvec3 green=vec3(0.,1.,0.);gl_FragColor=vec4(green,1.0);return;\n#endif\ngl_FragColor=vec4(inputColor.rgb+albedo*centerIrradiance,1.0);return;}\n#ifdef DEBUG_SSS_SAMPLES\nvec3 red =vec3(1.,0.,0.);vec3 blue=vec3(0.,0.,1.);gl_FragColor=vec4(mix(blue,red,clamp(float(sampleCount)/float(sampleBudget),0.0,1.0)),1.0);return;\n#endif\nfloat phase=0.;int n=min(sampleCount,sampleBudget);vec3 centerWeight =vec3(0.); \nvec3 totalIrradiance=vec3(0.);vec3 totalWeight =vec3(0.);for (int i=0; i= 5) return $.Error("You already reached the maximum number of diffusion profiles."), 0; for (var t = 0; t < this._ssDiffusionS.length / 3; t++)if (this._ssDiffusionS[3 * t] === e.r && this._ssDiffusionS[3 * t + 1] === e.g && this._ssDiffusionS[3 * t + 2] === e.b) return t; return this._ssDiffusionS.push(e.r, e.b, e.g), this._ssDiffusionD.push(Math.max(Math.max(e.r, e.b), e.g)), this._ssFilterRadii.push(this.getDiffusionProfileParameters(e)), this.ssDiffusionProfileColors.push(e), this._ssDiffusionD.length - 1 }, e.prototype.createPostProcess = function () { return this.postProcess = new xx("subSurfaceScattering", this._scene, 1, null, void 0, this._scene.getEngine()), this.postProcess.autoClear = !1, this.postProcess }, e.prototype.clearAllDiffusionProfiles = function () { this._ssDiffusionD = [], this._ssDiffusionS = [], this._ssFilterRadii = [], this.ssDiffusionProfileColors = [] }, e.prototype.dispose = function () { this.clearAllDiffusionProfiles(), this.postProcess && this.postProcess.dispose() }, e.prototype.getDiffusionProfileParameters = function (e) { var t = Math.max(e.r, e.g, e.b); return this._sampleBurleyDiffusionProfile(.997, t) }, e.prototype._sampleBurleyDiffusionProfile = function (e, t) { var i = 1 + 4 * (e = 1 - e) * (2 * e + Math.sqrt(1 + 4 * e * e)), r = Math.pow(i, -1 / 3), n = 1 + i * r * r + r; return 3 * Math.log(n / (4 * e)) * t }, e._SceneComponentInitialization = function (e) { throw ge("SubSurfaceSceneComponent") }, e }(); o.AddParser(qi.NAME_SUBSURFACE, (function (e, t) { if (void 0 !== e.ssDiffusionProfileColors && null !== e.ssDiffusionProfileColors && (t.enableSubSurfaceForPrePass(), t.subSurfaceConfiguration)) for (var i = 0, r = e.ssDiffusionProfileColors.length; i < r; i++) { var n = e.ssDiffusionProfileColors[i]; t.subSurfaceConfiguration.addDiffusionProfile(new B(n.r, n.g, n.b)) } })), Object.defineProperty(Sr.prototype, "subSurfaceConfiguration", { get: function () { return this._subSurfaceConfiguration }, set: function (e) { e && this.enablePrePassRenderer() && (this._subSurfaceConfiguration = e) }, enumerable: !0, configurable: !0 }), Sr.prototype.enableSubSurfaceForPrePass = function () { if (this._subSurfaceConfiguration) return this._subSurfaceConfiguration; var e = this.enablePrePassRenderer(); return e ? (this._subSurfaceConfiguration = new Ax(this), e.addEffectConfiguration(this._subSurfaceConfiguration), this._subSurfaceConfiguration) : null }, Sr.prototype.disableSubSurfaceForPrePass = function () { this._subSurfaceConfiguration && (this._subSurfaceConfiguration.dispose(), this._subSurfaceConfiguration = null) }; var Rx = function () { function e(e) { this.name = qi.NAME_PREPASSRENDERER, this.scene = e } return e.prototype.register = function () { }, e.prototype.serialize = function (e) { if (this.scene.subSurfaceConfiguration) { var t = this.scene.subSurfaceConfiguration.ssDiffusionProfileColors; e.ssDiffusionProfileColors = []; for (var i = 0; i < t.length; i++)e.ssDiffusionProfileColors.push({ r: t[i].r, g: t[i].g, b: t[i].b }) } }, e.prototype.addFromContainer = function () { }, e.prototype.removeFromContainer = function () { this.scene.prePassRenderer && this.scene.subSurfaceConfiguration && this.scene.subSurfaceConfiguration.clearAllDiffusionProfiles() }, e.prototype.rebuild = function () { }, e.prototype.dispose = function () { }, e }(); Ax._SceneComponentInitialization = function (e) { var t = e._getComponent(qi.NAME_SUBSURFACE); t || (t = new Rx(e), e._addComponent(t)) }; Ut.ShadersStore.outlinePixelShader = "#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nuniform vec4 color;\n#ifdef ALPHATEST\nvarying vec2 vUV;uniform sampler2D diffuseSampler;\n#endif\n#include\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\n#include\ngl_FragColor=color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}"; Ut.ShadersStore.outlineVertexShader = "attribute vec3 position;attribute vec3 normal;\n#include\n#include\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\nuniform float offset;\n#include\nuniform mat4 viewProjection;\n#ifdef ALPHATEST\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#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]\nvec3 offsetPosition=positionUpdated+(normalUpdated*offset);\n#include\n#include\n#include\nvec4 worldPos=finalWorld*vec4(offsetPosition,1.0);gl_Position=viewProjection*worldPos;\n#ifdef ALPHATEST\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#include\n}\n", Sr.prototype.getOutlineRenderer = function () { return this._outlineRenderer || (this._outlineRenderer = new Px(this)), this._outlineRenderer }, Object.defineProperty(Jn.prototype, "renderOutline", { get: function () { return this._renderOutline }, set: function (e) { e && this.getScene().getOutlineRenderer(), this._renderOutline = e }, enumerable: !0, configurable: !0 }), Object.defineProperty(Jn.prototype, "renderOverlay", { get: function () { return this._renderOverlay }, set: function (e) { e && this.getScene().getOutlineRenderer(), this._renderOverlay = e }, enumerable: !0, configurable: !0 }); var Cx, Px = function () { function e(e) { this.name = qi.NAME_OUTLINERENDERER, this.zOffset = 1, this.zOffsetUnits = 4, this.scene = e, this._engine = e.getEngine(), this.scene._addComponent(this), this._passIdForDrawWrapper = []; for (var t = 0; t < 4; ++t)this._passIdForDrawWrapper[t] = this._engine.createRenderPassId("Outline Renderer (".concat(t, ")")) } return e.prototype.register = function () { this.scene._beforeRenderingMeshStage.registerStep(qi.STEP_BEFORERENDERINGMESH_OUTLINE, this, this._beforeRenderingMesh), this.scene._afterRenderingMeshStage.registerStep(qi.STEP_AFTERRENDERINGMESH_OUTLINE, this, this._afterRenderingMesh) }, e.prototype.rebuild = function () { }, e.prototype.dispose = function () { for (var e = 0; e < this._passIdForDrawWrapper.length; ++e)this._engine.releaseRenderPassId(this._passIdForDrawWrapper[e]) }, e.prototype.render = function (e, t, i, r) { void 0 === i && (i = !1), r = null != r ? r : this._passIdForDrawWrapper[0]; var n = this.scene, o = n.getEngine(), a = o.getCaps().instancedArrays && (null !== t.visibleInstances[e._id] && void 0 !== t.visibleInstances[e._id] || e.getRenderingMesh().hasThinInstances); if (this.isReady(e, a, r)) { var s = e.getMesh(), l = s._internalAbstractMeshDataInfo._actAsRegularMesh ? s : null, c = e.getRenderingMesh(), u = l || c, h = e.getMaterial(); if (h && n.activeCamera) { var d = e._getDrawWrapper(r), p = Jt.GetEffect(d); if (o.enableEffect(d), h.useLogarithmicDepth && p.setFloat("logarithmicDepthConstant", 2 / (Math.log(n.activeCamera.maxZ + 1) / Math.LN2)), p.setFloat("offset", i ? 0 : c.outlineWidth), p.setColor4("color", i ? c.overlayColor : c.outlineColor, i ? c.overlayAlpha : h.alpha), p.setMatrix("viewProjection", n.getTransformMatrix()), p.setMatrix("world", u.getWorldMatrix()), c.useBones && c.computeBonesUsingShaders && c.skeleton && p.setMatrices("mBones", c.skeleton.getTransformMatrices(c)), c.morphTargetManager && c.morphTargetManager.isUsingTextureForTargets && c.morphTargetManager._bind(p), zn.BindMorphTargetParameters(c, p), a || c._bind(e, p, h.fillMode), h && h.needAlphaTesting()) { var f = h.getAlphaTestTexture(); f && (p.setTexture("diffuseSampler", f), p.setMatrix("diffuseMatrix", f.getTextureMatrix())) } Vn(p, h, n), o.setZOffset(-this.zOffset), o.setZOffsetUnits(-this.zOffsetUnits), c._processRendering(u, e, p, h.fillMode, t, a, (function (e, t) { p.setMatrix("world", t) })), o.setZOffset(0), o.setZOffsetUnits(0) } } }, e.prototype.isReady = function (e, t, i) { i = null != i ? i : this._passIdForDrawWrapper[0]; var r = [], n = [Hi.PositionKind, Hi.NormalKind], o = e.getMesh(), a = e.getMaterial(); if (!a) return !1; var s = o.getScene(); a.needAlphaTesting() && (r.push("#define ALPHATEST"), o.isVerticesDataPresent(Hi.UVKind) && (n.push(Hi.UVKind), r.push("#define UV1")), o.isVerticesDataPresent(Hi.UV2Kind) && (n.push(Hi.UV2Kind), r.push("#define UV2"))), a.useLogarithmicDepth && r.push("#define LOGARITHMICDEPTH"), Bn(a, s, r), o.useBones && o.computeBonesUsingShaders ? (n.push(Hi.MatricesIndicesKind), n.push(Hi.MatricesWeightsKind), o.numBoneInfluencers > 4 && (n.push(Hi.MatricesIndicesExtraKind), n.push(Hi.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"), zn.PrepareAttributesForMorphTargetsInfluencers(n, o, c)), t && (r.push("#define INSTANCES"), zn.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"]; wn(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 }(), Ix = 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 Ka({ engine: this._engine, useShaderStore: !0, vertexShader: "fluidRenderingParticleDepth", fragmentShader: "fluidRenderingParticleDepth", attributeNames: t, uniformNames: e, samplerNames: [], defines: i }), e.push("particleAlpha"), this._thicknessEffectWrapper = new Ka({ 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 }(), Mx = 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 }(Ix), Ox = 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 vo(null, this._scene), this._texture.name = "rtt" + this._name, this._texture._texture = e, this._texture.wrapU = vo.CLAMP_ADDRESSMODE, this._texture.wrapV = vo.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 vo(null, this._scene); if (p.name = "rttBlurred" + n, p._texture = d, p.wrapU = vo.CLAMP_ADDRESSMODE, p.wrapV = vo.CLAMP_ADDRESSMODE, p.anisotropicFilteringLevel = 1, o) { var f = new Ia("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 = vo.CLAMP_ADDRESSMODE, e.texture.wrapV = vo.CLAMP_ADDRESSMODE })) })), this._fixReusablePostProcess(f); var _ = new Ia("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 = vo.CLAMP_ADDRESSMODE, e.texture.wrapV = vo.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 Ia("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 = vo.CLAMP_ADDRESSMODE, e.texture.wrapV = vo.CLAMP_ADDRESSMODE })) })), this._fixReusablePostProcess(y); var b = new Ia("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 = vo.CLAMP_ADDRESSMODE, e.texture.wrapV = vo.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" }(Cx || (Cx = {})); var Dx, Nx = 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 = Cx.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 Ox("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 Ox("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 Ox("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 === Cx.Normals ? o.push("#define FLUIDRENDERING_DEBUG_SHOWNORMAL") : this._debugFeature === Cx.DiffuseRendering ? o.push("#define FLUIDRENDERING_DEBUG_DIFFUSERENDERING") : (o.push("#define FLUIDRENDERING_DEBUG_TEXTURE"), n.push("debugSampler"), this._debugFeature !== Cx.DepthTexture && this._debugFeature !== Cx.DepthBlurredTexture || o.push("#define FLUIDRENDERING_DEBUG_DEPTH"))), this._renderPostProcess = new Ia("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 Cx.DepthTexture: P = t._depthRenderTarget.texture; break; case Cx.DepthBlurredTexture: P = t._depthRenderTarget.enableBlur ? t._depthRenderTarget.textureBlur : t._depthRenderTarget.texture; break; case Cx.ThicknessTexture: P = null !== (b = null === (y = t._thicknessRenderTarget) || void 0 === y ? void 0 : y.texture) && void 0 !== b ? b : null; break; case Cx.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 Cx.DiffuseTexture: t._diffuseRenderTarget && (P = t._diffuseRenderTarget.texture) }t._debugFeature !== Cx.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 }(), Fx = 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 Hi(this._engine, e[t], t, !0, !1, i, r) } }, t.prototype._createEffects = function () { e.prototype._createEffects.call(this), this._diffuseEffectWrapper = new Ka({ 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 Hi(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 }(Ix); Ut.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" }(Dx || (Dx = {})); var Lx = function () { function e(e, t) { void 0 === t && (t = !1); var i = this; this._engine = e, this._isDepthTexture = t, this._renderer = new Ya(e), this._effectWrapper = new Ka({ 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 = Dx.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 }(), wx = function () { function e(e, t, i, r) { void 0 === r && (r = 1), this._engine = e, this._copyTextureToTexture = new Lx(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 }(); Ut.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"; Ut.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"; Ut.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"; Ut.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"; Ut.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"; Ut.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"; Ut.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"; Ut.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 Bx(e) { return !!e.particleSystem } Ut.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(Sr.prototype, "fluidRenderer", { get: function () { return this._fluidRenderer }, set: function (e) { this._fluidRenderer = e }, enumerable: !0, configurable: !0 }), Sr.prototype.enableFluidRenderer = function () { return this._fluidRenderer || (this._fluidRenderer = new Vx(this)), this._fluidRenderer }, Sr.prototype.disableFluidRenderer = function () { var e; null === (e = this._fluidRenderer) || void 0 === e || e.dispose(), this._fluidRenderer = null }; var Ux = function () { function e(e) { this.name = qi.NAME_FLUIDRENDERER, this.scene = e } return e.prototype.register = function () { this.scene._gatherActiveCameraRenderTargetsStage.registerStep(qi.STEP_GATHERACTIVECAMERARENDERTARGETS_FLUIDRENDERER, this, this._gatherActiveCameraRenderTargets), this.scene._afterCameraDrawStage.registerStep(qi.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 }(), Vx = 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(qi.NAME_FLUIDRENDERER); t || (t = new Ux(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 = new Mx(this._scene, e); n.onParticleSizeChanged.add(this._setParticleSizeForRenderTargets.bind(this)), i || (i = new Nx(this._scene, r), this.targetRenderers.push(i)), i._onUseVelocityChanged.hasObservers() || i._onUseVelocityChanged.add(this._setUseVelocityForRenderObject.bind(this)), void 0 !== t && (i.generateDiffuseTexture = t); var o = { object: n, targetRenderer: i }; return this.renderObjects.push(o), this._sortRenderingObjects(), this._setParticleSizeForRenderTargets(), o }, e.prototype.addCustomParticles = function (e, t, i, r, n) { var o = new Fx(this._scene, e, t); o.onParticleSizeChanged.add(this._setParticleSizeForRenderTargets.bind(this)), r || (r = new Nx(this._scene, n), this.targetRenderers.push(r)), r._onUseVelocityChanged.hasObservers() || r._onUseVelocityChanged.add(this._setUseVelocityForRenderObject.bind(this)), void 0 !== i && (r.generateDiffuseTexture = i); var a = { object: o, targetRenderer: r }; return this.renderObjects.push(a), this._sortRenderingObjects(), this._setParticleSizeForRenderTargets(), a }, 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.priority < t.object.priority ? -1 : e.object.priority > t.object.priority ? 1 : 0 })) }, e.prototype._removeUnusedTargetRenderers = function () { for (var e, t = {}, i = 0; i < this.renderObjects.length; ++i) { var r = this.renderObjects[i].targetRenderer; t[this.targetRenderers.indexOf(r)] = !0 } var n = !1, o = []; for (i = 0; i < this.targetRenderers.length; ++i)t[i] ? o.push(this.targetRenderers[i]) : (this.targetRenderers[i].dispose(), n = !0); return n && (this.targetRenderers.length = 0, (e = this.targetRenderers).push.apply(e, o)), n }, e.prototype._getParticleSystemIndex = function (e) { for (var t = 0; t < this.renderObjects.length; ++t) { var i = this.renderObjects[t].object; if (Bx(i) && i.particleSystem === e) return t } return -1 }, e.prototype._initialize = function () { for (var e = this, t = 0; t < this.targetRenderers.length; ++t)this.targetRenderers[t].dispose(); var i = new Map; for (t = 0; t < this.targetRenderers.length; ++t) { var r = this.targetRenderers[t]; r._initialize(), r.camera && r._renderPostProcess && ((l = i.get(r.camera)) || (l = [[], {}], i.set(r.camera, l)), l[0].push(r), r.camera.attachPostProcess(r._renderPostProcess, t)) } for (var n = i.keys(), o = function (t) { var r = t.value, n = i.get(r), o = r._getFirstPostProcess(); if (!o) return "continue"; var s = n[0], l = n[1]; o.onSizeChangedObservable.add((function () { var t; o.inputTexture.depthStencilTexture || o.inputTexture.createDepthStencilTexture(0, !0, e._engine.isStencilEnable, s[0].samples, e._engine.isStencilEnable ? a.TEXTUREFORMAT_DEPTH24_STENCIL8 : a.TEXTUREFORMAT_DEPTH32_FLOAT, "PostProcessRTTDepthStencil-".concat(o.name)); for (var i = 0, r = s; i < r.length; i++) { var n = null === (t = r[i]._thicknessRenderTarget) || void 0 === t ? void 0 : t.renderTarget, c = null == n ? void 0 : n.texture; if (n && c) { var u = c.width + "_" + c.height, h = l[u]; h || (h = l[u] = new wx(e._engine, c.width, c.height)), h.depthRTWrapper._shareDepth(n) } } })) }, s = n.next(); !0 !== s.done; s = n.next())o(s); for (s = (n = this._cameras.keys()).next(); !0 !== s.done; s = n.next()) { var l, c = s.value, u = (l = this._cameras.get(c))[1], h = i.get(c); if (h) for (var d in u) h[1][d] || u[d].dispose(); else for (var p in u) u[p].dispose() } this._cameras.clear(), this._cameras = i, this._setParticleSizeForRenderTargets() }, e.prototype._setParticleSizeForRenderTargets = function () { for (var e = new Map, t = 0; t < this.renderObjects.length; ++t) { var i = this.renderObjects[t], r = e.get(i.targetRenderer); void 0 === r && (r = 0), e.set(i.targetRenderer, Math.max(r, i.object.particleSize)) } e.forEach((function (e, t) { t._depthRenderTarget && (t._depthRenderTarget.particleSize = e) })) }, e.prototype._setUseVelocityForRenderObject = function () { for (var e = 0, t = this.renderObjects; e < t.length; e++) { var i = t[e]; i.object.useVelocity = i.targetRenderer.useVelocity } }, e.prototype._prepareRendering = function () { for (var e = 0, t = this.targetRenderers; e < t.length; e++)if (t[e].needInitialization) return void this._initialize() }, e.prototype._render = function (e) { for (var t, i = 0; i < this.targetRenderers.length; ++i)e && this.targetRenderers[i].camera !== e || this.targetRenderers[i]._clearTargets(); for (var r = this._cameras.keys(), n = r.next(); !0 !== n.done; n = r.next()) { var o = n.value, a = this._cameras.get(o); if (!e || o === e) { var s = o._getFirstPostProcess(); if (s) { var l = null === (t = s.inputTexture) || void 0 === t ? void 0 : t.depthStencilTexture; if (l) { for (var c = a[0], u = a[1], h = 0, d = c; h < d.length; h++)d[h]._bgDepthTexture = l; for (var p in u) u[p].copy(l) } } } } for (i = 0; i < this.renderObjects.length; ++i) { var f = this.renderObjects[i]; e && f.targetRenderer.camera !== e || f.targetRenderer._render(f.object) } }, e.prototype.dispose = function () { this._engine.onResizeObservable.remove(this._onEngineResizeObserver), this._onEngineResizeObserver = null; for (var e = 0; e < this.renderObjects.length; ++e)this.renderObjects[e].object.dispose(); for (e = 0; e < this.targetRenderers.length; ++e)this.targetRenderers[e].dispose(); this._cameras.forEach((function (e) { var t = e[1]; for (var i in t) t[i].dispose() })), this.renderObjects = [], this.targetRenderers = [], this._cameras.clear() }, e }(), kx = function (e) { function t(t, i) { var r = e.call(this) || this; return r.name = t, r.animations = new Array, r.isPickable = !1, r.useAlphaForPicking = !1, r.onDisposeObservable = new u, r._onAnimationEnd = null, r._endAnimation = function () { r._onAnimationEnd && r._onAnimationEnd(), r.disposeWhenFinishedAnimating && r.dispose() }, r.color = new U(1, 1, 1, 1), r.position = R.Zero(), r._manager = i, r._manager.sprites.push(r), r.uniqueId = r._manager.scene.getUniqueId(), r } return W(t, e), Object.defineProperty(t.prototype, "size", { get: function () { return this.width }, set: function (e) { this.width = e, this.height = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "manager", { get: function () { return this._manager }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function () { return "Sprite" }, Object.defineProperty(t.prototype, "fromIndex", { get: function () { return this._fromIndex }, set: function (e) { this.playAnimation(e, this._toIndex, this._loopAnimation, this._delay, this._onAnimationEnd) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "toIndex", { get: function () { return this._toIndex }, set: function (e) { this.playAnimation(this._fromIndex, e, this._loopAnimation, this._delay, this._onAnimationEnd) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "loopAnimation", { get: function () { return this._loopAnimation }, set: function (e) { this.playAnimation(this._fromIndex, this._toIndex, e, this._delay, this._onAnimationEnd) }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "delay", { get: function () { return Math.max(this._delay, 1) }, set: function (e) { this.playAnimation(this._fromIndex, this._toIndex, this._loopAnimation, e, this._onAnimationEnd) }, enumerable: !1, configurable: !0 }), t.prototype.playAnimation = function (t, i, r, n, o) { void 0 === o && (o = null), this._onAnimationEnd = o, e.prototype.playAnimation.call(this, t, i, r, n, this._endAnimation) }, t.prototype.dispose = function () { for (var e = 0; e < this._manager.sprites.length; e++)this._manager.sprites[e] == this && this._manager.sprites.splice(e, 1); this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear() }, t.prototype.serialize = function () { var e = {}; return e.name = this.name, e.position = this.position.asArray(), e.color = this.color.asArray(), e.width = this.width, e.height = this.height, e.angle = this.angle, e.cellIndex = this.cellIndex, e.cellRef = this.cellRef, e.invertU = this.invertU, e.invertV = this.invertV, e.disposeWhenFinishedAnimating = this.disposeWhenFinishedAnimating, e.isPickable = this.isPickable, e.isVisible = this.isVisible, e.useAlphaForPicking = this.useAlphaForPicking, e.animationStarted = this.animationStarted, e.fromIndex = this.fromIndex, e.toIndex = this.toIndex, e.loopAnimation = this.loopAnimation, e.delay = this.delay, e }, t.Parse = function (e, i) { var r = new t(e.name, i); return r.position = R.FromArray(e.position), r.color = U.FromArray(e.color), r.width = e.width, r.height = e.height, r.angle = e.angle, r.cellIndex = e.cellIndex, r.cellRef = e.cellRef, r.invertU = e.invertU, r.invertV = e.invertV, r.disposeWhenFinishedAnimating = e.disposeWhenFinishedAnimating, r.isPickable = e.isPickable, r.isVisible = e.isVisible, r.useAlphaForPicking = e.useAlphaForPicking, r.fromIndex = e.fromIndex, r.toIndex = e.toIndex, r.loopAnimation = e.loopAnimation, r.delay = e.delay, e.animationStarted && r.playAnimation(r.fromIndex, r.toIndex, r.loopAnimation, r.delay), r }, t }(function () { function e() { this.width = 1, this.height = 1, this.angle = 0, this.invertU = !1, this.invertV = !1, this.isVisible = !0, this._animationStarted = !1, this._loopAnimation = !1, this._fromIndex = 0, this._toIndex = 0, this._delay = 0, this._direction = 1, this._time = 0, this._onBaseAnimationEnd = null, this.position = { x: 1, y: 1, z: 1 }, this.color = { r: 1, g: 1, b: 1, a: 1 } } return Object.defineProperty(e.prototype, "animationStarted", { get: function () { return this._animationStarted }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "fromIndex", { get: function () { return this._fromIndex }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "toIndex", { get: function () { return this._toIndex }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "loopAnimation", { get: function () { return this._loopAnimation }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "delay", { get: function () { return Math.max(this._delay, 1) }, enumerable: !1, configurable: !0 }), e.prototype.playAnimation = function (e, t, i, r, n) { this._fromIndex = e, this._toIndex = t, this._loopAnimation = i, this._delay = r || 1, this._animationStarted = !0, this._onBaseAnimationEnd = n, e < t ? this._direction = 1 : (this._direction = -1, this._toIndex = e, this._fromIndex = t), this.cellIndex = e, this._time = 0 }, e.prototype.stopAnimation = function () { this._animationStarted = !1 }, e.prototype._animate = function (e) { this._animationStarted && (this._time += e, this._time > this._delay && (this._time = this._time % this._delay, this.cellIndex += this._direction, (this._direction > 0 && this.cellIndex > this._toIndex || this._direction < 0 && this.cellIndex < this._fromIndex) && (this._loopAnimation ? this.cellIndex = this._direction > 0 ? this._fromIndex : this._toIndex : (this.cellIndex = this._toIndex, this._animationStarted = !1, this._onBaseAnimationEnd && this._onBaseAnimationEnd())))) }, e }()); Sr.prototype._internalPickSprites = function (e, t, i, r) { if (!Xi) 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 < this.spriteManagers.length; o++) { var a = this.spriteManagers[o]; if (a.isPickable) { var s = a.intersects(e, r, t, i); if (s && s.hit && (i || null == n || !(s.distance >= n.distance)) && (n = s, i)) break } } return n || new Xi }, Sr.prototype._internalMultiPickSprites = function (e, t, i) { if (!Xi) 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; n < this.spriteManagers.length; n++) { var o = this.spriteManagers[n]; if (o.isPickable) { var a = o.multiIntersects(e, i, t); null !== a && (r = r.concat(a)) } } return r }, Sr.prototype.pickSprite = function (e, t, i, r, n) { if (!this._tempSpritePickingRay) return null; this.createPickingRayInCameraSpaceToRef(e, t, this._tempSpritePickingRay, n); var o = this._internalPickSprites(this._tempSpritePickingRay, i, r, n); return o && (o.ray = this.createPickingRayInCameraSpace(e, t, n)), o }, Sr.prototype.pickSpriteWithRay = function (e, t, i, r) { if (!this._tempSpritePickingRay) return null; if (!r) { if (!this.activeCamera) return null; r = this.activeCamera } Mo.TransformToRef(e, r.getViewMatrix(), this._tempSpritePickingRay); var n = this._internalPickSprites(this._tempSpritePickingRay, t, i, r); return n && (n.ray = e), n }, Sr.prototype.multiPickSprite = function (e, t, i, r) { return this.createPickingRayInCameraSpaceToRef(e, t, this._tempSpritePickingRay, r), this._internalMultiPickSprites(this._tempSpritePickingRay, i, r) }, Sr.prototype.multiPickSpriteWithRay = function (e, t, i) { if (!this._tempSpritePickingRay) return null; if (!i) { if (!this.activeCamera) return null; i = this.activeCamera } return Mo.TransformToRef(e, i.getViewMatrix(), this._tempSpritePickingRay), this._internalMultiPickSprites(this._tempSpritePickingRay, t, i) }, Sr.prototype.setPointerOverSprite = function (e) { this._pointerOverSprite !== e && (this._pointerOverSprite && this._pointerOverSprite.actionManager && this._pointerOverSprite.actionManager.processTrigger(a.ACTION_OnPointerOutTrigger, G.CreateNewFromSprite(this._pointerOverSprite, this)), this._pointerOverSprite = e, this._pointerOverSprite && this._pointerOverSprite.actionManager && this._pointerOverSprite.actionManager.processTrigger(a.ACTION_OnPointerOverTrigger, G.CreateNewFromSprite(this._pointerOverSprite, this))) }, Sr.prototype.getPointerOverSprite = function () { return this._pointerOverSprite }; var Gx = function () { function e(e) { this.name = qi.NAME_SPRITE, this.scene = e, this.scene.spriteManagers = new Array, this.scene._tempSpritePickingRay = Mo ? Mo.Zero() : null, this.scene.onBeforeSpritesRenderingObservable = new u, this.scene.onAfterSpritesRenderingObservable = new u, this._spritePredicate = function (e) { return !!e.actionManager && e.isPickable && e.actionManager.hasPointerTriggers } } return e.prototype.register = function () { this.scene._pointerMoveStage.registerStep(qi.STEP_POINTERMOVE_SPRITE, this, this._pointerMove), this.scene._pointerDownStage.registerStep(qi.STEP_POINTERDOWN_SPRITE, this, this._pointerDown), this.scene._pointerUpStage.registerStep(qi.STEP_POINTERUP_SPRITE, this, this._pointerUp) }, e.prototype.rebuild = function () { }, e.prototype.dispose = function () { this.scene.onBeforeSpritesRenderingObservable.clear(), this.scene.onAfterSpritesRenderingObservable.clear(); var e = this.scene.spriteManagers; if (e) for (; e.length;)e[0].dispose() }, e.prototype._pickSpriteButKeepRay = function (e, t, i, r, n) { var o = this.scene.pickSprite(t, i, this._spritePredicate, r, n); return o && (o.ray = e ? e.ray : null), o }, e.prototype._pointerMove = function (e, t, i, r, n) { var o = this.scene; return r ? o.setPointerOverSprite(null) : (i = this._pickSpriteButKeepRay(i, e, t, !1, o.cameraToUseForPointers || void 0)) && i.hit && i.pickedSprite ? (o.setPointerOverSprite(i.pickedSprite), !o.doNotHandleCursors && n && (o._pointerOverSprite && o._pointerOverSprite.actionManager && o._pointerOverSprite.actionManager.hoverCursor ? n.style.cursor = o._pointerOverSprite.actionManager.hoverCursor : n.style.cursor = o.hoverCursor)) : o.setPointerOverSprite(null), i }, e.prototype._pointerDown = function (e, t, i, r) { var n = this.scene; if (n._pickedDownSprite = null, n.spriteManagers && n.spriteManagers.length > 0 && (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 }(); Ut.IncludesShadersStore.imageProcessingCompatibility = "#ifdef IMAGEPROCESSINGPOSTPROCESS\ngl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(2.2));\n#endif\n"; Ut.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}"; Ut.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 zx = 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 Wi(e, this._vertexData, !0, this._vertexBufferSize); var n, o = this._buffer.createVertexBuffer(Hi.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 Wi(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(Hi.ColorKind, l + 6, 4, this._vertexBufferSize, this._useInstancing); this._vertexBuffers[Hi.PositionKind] = o, this._vertexBuffers.options = s, this._vertexBuffers.offsets = n, this._vertexBuffers.inverts = u, this._vertexBuffers.cellInfo = h, this._vertexBuffers[Hi.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 Jt(this._engine), this._drawWrapperFog = new Jt(this._engine), this._drawWrapperDepth = new Jt(this._engine, !1), this._drawWrapperFogDepth = new Jt(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", [Hi.PositionKind, "options", "offsets", "inverts", "cellInfo", Hi.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", [Hi.PositionKind, "options", "offsets", "inverts", "cellInfo", Hi.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 < p; m++) { var g = e[m]; g && g.isVisible && (_ = !1, g._animate(t), this._appendSpriteVertex(f++, g, 0, 0, d, h, n), this._useInstancing || (this._appendSpriteVertex(f++, g, 1, 0, d, h, n), this._appendSpriteVertex(f++, g, 1, 1, d, h, n), this._appendSpriteVertex(f++, g, 0, 1, d, h, n))) } if (!_) { this._buffer.update(this._vertexData); var v = !!u.depthCullingState.cull, y = u.depthCullingState.zOffset, b = u.depthCullingState.zOffsetUnits; if (u.setState(v, y, !1, !1, void 0, void 0, b), u.enableEffect(o), c.setTexture("diffuseSampler", this.texture), c.setMatrix("view", i), c.setMatrix("projection", r), l) { var T = this._scene; c.setFloat4("vFogInfos", T.fogMode, T.fogStart, T.fogEnd, T.fogDensity), c.setColor3("vFogColor", T.fogColor) } this._useVAO ? (this._vertexArrayObject || (this._vertexArrayObject = u.recordVertexArrayObject(this._vertexBuffers, this._indexBuffer, c)), u.bindVertexArrayObject(this._vertexArrayObject, this._indexBuffer)) : u.bindBuffers(this._vertexBuffers, this._indexBuffer, c), u.depthCullingState.depthFunc = u.useReverseDepthBuffer ? a.GEQUAL : a.LEQUAL, this.disableDepthWrite || (c.setBool("alphaTest", !0), u.setColorWrite(!1), u.enableEffect(s), this._useInstancing ? u.drawArraysType(a.MATERIAL_TriangleStripDrawMode, 0, 4, f) : u.drawElementsType(a.MATERIAL_TriangleFillMode, 0, f / 4 * 6), u.enableEffect(o), u.setColorWrite(!0), c.setBool("alphaTest", !1)), u.setAlphaMode(this.blendMode), this._useInstancing ? u.drawArraysType(a.MATERIAL_TriangleStripDrawMode, 0, 4, f) : u.drawElementsType(a.MATERIAL_TriangleFillMode, 0, f / 4 * 6), this.autoResetAlpha && u.setAlphaMode(a.ALPHA_DISABLE), h && this._scene.getEngine().setState(v, y, !1, !0, void 0, void 0, b), u.unbindInstanceAttributes() } } } }, e.prototype._appendSpriteVertex = function (e, t, i, r, n, o, a) { var s = e * this._vertexBufferSize; if (0 === i ? i = this._epsilon : 1 === i && (i = 1 - this._epsilon), 0 === r ? r = this._epsilon : 1 === r && (r = 1 - this._epsilon), a) a(t, n); else { t.cellIndex || (t.cellIndex = 0); var l = n.width / this.cellWidth, c = t.cellIndex / l >> 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; i < this._capacity; i++)e.push(t), e.push(t + 1), e.push(t + 2), e.push(t), e.push(t + 2), e.push(t + 3), t += 4; this._indexBuffer = this._engine.createIndexBuffer(e) }, e.prototype.rebuild = function () { var e; for (var t in this._indexBuffer && this._buildIndexBuffer(), this._useVAO && (this._vertexArrayObject = void 0), this._buffer._rebuild(), this._vertexBuffers) this._vertexBuffers[t]._rebuild(); null === (e = this._spriteBuffer) || void 0 === e || e._rebuild() }, e.prototype.dispose = function () { this._buffer && (this._buffer.dispose(), this._buffer = null), this._spriteBuffer && (this._spriteBuffer.dispose(), this._spriteBuffer = null), this._indexBuffer && (this._engine._releaseBuffer(this._indexBuffer), this._indexBuffer = null), this._vertexArrayObject && (this._engine.releaseVertexArrayObject(this._vertexArrayObject), this._vertexArrayObject = null), this.texture && (this.texture.dispose(), this.texture = null), this._drawWrapperBase.dispose(), this._drawWrapperFog.dispose(), this._drawWrapperDepth.dispose(), this._drawWrapperFogDepth.dispose() }, e }(), Wx = function () { function e(e, t, i, r, n, o, a, s, l) { void 0 === o && (o = .01), void 0 === a && (a = vo.TRILINEAR_SAMPLINGMODE), void 0 === s && (s = !1), void 0 === l && (l = null); var c = this; this.name = e, this.sprites = new Array, this.renderingGroupId = 0, this.layerMask = 268435455, this.isPickable = !1, this.metadata = null, this._wasDispatched = !1, this.onDisposeObservable = new u, this._disableDepthWrite = !1, this._packedAndReady = !1, this._customUpdate = function (e, t) { e.cellRef || (e.cellIndex = 0); var i = e.cellIndex; "number" == typeof i && isFinite(i) && Math.floor(i) === i && (e.cellRef = c._spriteMap[e.cellIndex]), e._xOffset = c._cellData[e.cellRef].frame.x / t.width, e._yOffset = c._cellData[e.cellRef].frame.y / t.height, e._xSize = c._cellData[e.cellRef].frame.w, e._ySize = c._cellData[e.cellRef].frame.h }, n || (n = S.LastCreatedScene), n._getComponent(qi.NAME_SPRITE) || n._addComponent(new Gx(n)), this._fromPacked = s, this._scene = n; var h = this._scene.getEngine(); if (this._spriteRenderer = new zx(h, i, o, n), r.width && r.height) this.cellWidth = r.width, this.cellHeight = r.height; else { if (void 0 === r) return void (this._spriteRenderer = null); this.cellWidth = r, this.cellHeight = r } this._scene.spriteManagers && this._scene.spriteManagers.push(this), this.uniqueId = this.scene.getUniqueId(), t && (this.texture = new vo(t, n, !0, !1, a)), this._fromPacked && this._makePacked(t, l) } return 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, "children", { get: function () { return this.sprites }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "scene", { get: function () { return this._scene }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "capacity", { get: function () { return this._spriteRenderer.capacity }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "texture", { get: function () { return this._spriteRenderer.texture }, set: function (e) { e.wrapU = vo.CLAMP_ADDRESSMODE, e.wrapV = vo.CLAMP_ADDRESSMODE, this._spriteRenderer.texture = e, this._textureContent = null }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "cellWidth", { get: function () { return this._spriteRenderer.cellWidth }, set: function (e) { this._spriteRenderer.cellWidth = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "cellHeight", { get: function () { return this._spriteRenderer.cellHeight }, set: function (e) { this._spriteRenderer.cellHeight = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "fogEnabled", { get: function () { return this._spriteRenderer.fogEnabled }, set: function (e) { this._spriteRenderer.fogEnabled = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "blendMode", { get: function () { return this._spriteRenderer.blendMode }, set: function (e) { this._spriteRenderer.blendMode = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "disableDepthWrite", { get: function () { return this._disableDepthWrite }, set: function (e) { this._disableDepthWrite = e, this._spriteRenderer.disableDepthWrite = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "pixelPerfect", { get: function () { return this._spriteRenderer.pixelPerfect }, set: function (e) { this._spriteRenderer.pixelPerfect = e, e && this.texture.samplingMode !== a.TEXTURE_TRILINEAR_SAMPLINGMODE && this.texture.updateSamplingMode(a.TEXTURE_TRILINEAR_SAMPLINGMODE) }, enumerable: !1, configurable: !0 }), e.prototype.getClassName = function () { return "SpriteManager" }, e.prototype._makePacked = function (e, t) { var i = this; if (null !== t) try { var r = void 0; if ((r = "string" == typeof t ? JSON.parse(t) : t).frames.length) { for (var n = {}, o = 0; o < r.frames.length; o++) { var a = r.frames[o]; if ("string" != typeof Object.keys(a)[0]) throw new Error("Invalid JSON Format. Check the frame values and make sure the name is the first parameter."); n[a[Object.keys(a)[0]]] = a } r.frames = n } var s = Reflect.ownKeys(r.frames); this._spriteMap = s, this._packedAndReady = !0, this._cellData = r.frames } catch (e) { throw this._fromPacked = !1, this._packedAndReady = !1, new Error("Invalid JSON from string. Spritesheet managed with constant cell size.") } else { var l = /\./g, c = void 0; do { c = l.lastIndex, l.test(e) } while (l.lastIndex > 0); var u = e.substring(0, c - 1) + ".json"; xi.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; f < n; f++) { var _ = this.sprites[f]; if (_) { if (i) { if (!i(_)) continue } else if (!_.isPickable) continue; if (R.TransformCoordinatesToRef(_.position, h, u), _.angle ? (I.TranslationToRef(-u.x, -u.y, 0, O.Matrix[1]), I.TranslationToRef(u.x, u.y, 0, O.Matrix[2]), I.RotationZToRef(-_.angle, O.Matrix[3]), O.Matrix[1].multiplyToRef(O.Matrix[3], O.Matrix[4]), O.Matrix[4].multiplyToRef(O.Matrix[2], O.Matrix[0]), d = e.clone(), R.TransformCoordinatesToRef(e.origin, O.Matrix[0], d.origin), R.TransformNormalToRef(e.direction, O.Matrix[0], d.direction)) : d = e, o.copyFromFloats(u.x - _.width / 2, u.y - _.height / 2, u.z), a.copyFromFloats(u.x + _.width / 2, u.y + _.height / 2, u.z), d.intersectsBoxMinMax(o, a)) { var m = R.Distance(u, d.origin); if (s > m) { if (!this._checkTextureAlpha(_, d, m, o, a)) continue; if (p = d, s = m, l = _, r) break } } } } if (l) { var g = new Xi; 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; h < n; h++) { var d = this.sprites[h]; if (d) { if (i) { if (!i(d)) continue } else if (!d.isPickable) continue; if (R.TransformCoordinatesToRef(d.position, u, c), o.copyFromFloats(c.x - d.width / 2, c.y - d.height / 2, c.z), a.copyFromFloats(c.x + d.width / 2, c.y + d.height / 2, c.z), e.intersectsBoxMinMax(o, a)) { if (r = R.Distance(c, e.origin), !this._checkTextureAlpha(d, e, r, o, a)) continue; var p = new Xi; s.push(p), u.invertToRef(O.Matrix[0]), p.hit = !0, p.pickedSprite = d, p.distance = r; var f = O.Vector3[2]; f.copyFrom(e.direction), f.normalize(), f.scaleInPlace(r), e.origin.addToRef(f, l), p.pickedPoint = R.TransformCoordinates(l, O.Matrix[0]) } } } return s }, e.prototype.render = function () { if (!this._fromPacked || this._packedAndReady && this._spriteMap && this._cellData) { var e = this._scene.getEngine().getDeltaTime(); this._packedAndReady ? this._spriteRenderer.render(this.sprites, e, this._scene.getViewMatrix(), this._scene.getProjectionMatrix(), this._customUpdate) : this._spriteRenderer.render(this.sprites, e, this._scene.getViewMatrix(), this._scene.getProjectionMatrix()) } }, e.prototype.rebuild = function () { var e; null === (e = this._spriteRenderer) || void 0 === e || e.rebuild() }, e.prototype.dispose = function () { if (this._spriteRenderer && (this._spriteRenderer.dispose(), this._spriteRenderer = null), this._textureContent = null, this._scene.spriteManagers) { var e = this._scene.spriteManagers.indexOf(this); this._scene.spriteManagers.splice(e, 1) } this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear(), this.metadata = null }, e.prototype.serialize = function (e) { void 0 === e && (e = !1); var t = {}; t.name = this.name, t.capacity = this.capacity, t.cellWidth = this.cellWidth, t.cellHeight = this.cellHeight, t.fogEnabled = this.fogEnabled, t.blendMode = this.blendMode, t.disableDepthWrite = this.disableDepthWrite, t.pixelPerfect = this.pixelPerfect, this.texture && (e ? t.texture = this.texture.serialize() : (t.textureUrl = this.texture.name, t.invertY = this.texture._invertY)), t.sprites = []; for (var i = 0, r = this.sprites; i < r.length; i++) { var n = r[i]; t.sprites.push(n.serialize()) } return t.metadata = this.metadata, t }, e.Parse = function (t, i, r) { var n = new e(t.name, "", t.capacity, { width: t.cellWidth, height: t.cellHeight }, i); void 0 !== t.fogEnabled && (n.fogEnabled = t.fogEnabled), void 0 !== t.blendMode && (n.blendMode = t.blendMode), void 0 !== t.disableDepthWrite && (n.disableDepthWrite = t.disableDepthWrite), void 0 !== t.pixelPerfect && (n.pixelPerfect = t.pixelPerfect), void 0 !== t.metadata && (n.metadata = t.metadata), t.texture ? n.texture = vo.Parse(t.texture, i, r) : t.textureName && (n.texture = new vo(r + t.textureUrl, i, !1, void 0 === t.invertY || t.invertY)); for (var o = 0, a = t.sprites; o < a.length; o++) { var s = a[o]; kx.Parse(s, n) } return n }, e.ParseFromFileAsync = function (t, i, r, n) { return void 0 === n && (n = ""), new Promise((function (o, a) { var s = new He; s.addEventListener("readystatechange", (function () { if (4 == s.readyState) if (200 == s.status) { var i = JSON.parse(s.responseText), l = e.Parse(i, r || S.LastCreatedScene, n); t && (l.name = t), o(l) } else a("Unable to load the sprite manager") })), s.open("GET", i), s.send() })) }, e.ParseFromSnippetAsync = function (t, i, r) { var n = this; return void 0 === r && (r = ""), "_BLANK" === t ? Promise.resolve(new e("Default sprite manager", "//playground.babylonjs.com/textures/player.png", 500, 64, i)) : new Promise((function (o, a) { var s = new He; s.addEventListener("readystatechange", (function () { if (4 == s.readyState) if (200 == s.status) { var n = JSON.parse(JSON.parse(s.responseText).jsonPayload), l = JSON.parse(n.spriteManager), c = e.Parse(l, i || S.LastCreatedScene, r); c.snippetId = t, o(c) } else a("Unable to load the snippet " + t) })), s.open("GET", n.SnippetUrl + "/" + t.replace(/#/g, "/")), s.send() })) }, e.SnippetUrl = a.SnippetUrl, e.CreateFromSnippetAsync = e.ParseFromSnippetAsync, e }(); Ut.ShadersStore.spriteMapPixelShader = "#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\n#define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l)\n#else\n#define TEXTUREFUNC(s,c,b) texture2D(s,c,b)\n#endif\nprecision highp float;varying vec3 vPosition;varying vec2 vUV;varying vec2 tUV;uniform float time;uniform float spriteCount;uniform sampler2D spriteSheet;uniform vec2 spriteMapSize;uniform vec2 outputSize;uniform vec2 stageSize;uniform sampler2D frameMap;uniform sampler2D tileMaps[LAYERS];uniform sampler2D animationMap;uniform vec3 colorMul;float mt;const float fdStep=1./4.;const float aFrameSteps=1./MAX_ANIMATION_FRAMES;mat4 getFrameData(float frameID){float fX=frameID/spriteCount;return mat4(\ntexture2D(frameMap,vec2(fX,0.),0.),\ntexture2D(frameMap,vec2(fX,fdStep*1.),0.),\ntexture2D(frameMap,vec2(fX,fdStep*2.),0.),\nvec4(0.)\n);}\nvoid main(){vec4 color=vec4(0.);vec2 tileUV=fract(tUV);\n#ifdef FLIPU\ntileUV.y=1.0-tileUV.y;\n#endif\nvec2 tileID=floor(tUV);vec2 sheetUnits=1./spriteMapSize;float spriteUnits=1./spriteCount;vec2 stageUnits=1./stageSize;for(int i=0; i0.) {mt=mod(time*animationData.z,1.0);for(float f=0.; fmt){frameID=animationData.x;break;}\nanimationData=TEXTUREFUNC(animationMap,vec2((frameID+0.5)/spriteCount,aFrameSteps*f),0.);}}\nmat4 frameData=getFrameData(frameID+0.5);vec2 frameSize=(frameData[0].zw)/spriteMapSize;vec2 offset=frameData[0].xy*sheetUnits;vec2 ratio=frameData[2].xy/frameData[0].zw;if (frameData[2].z==1.){tileUV.xy=tileUV.yx;}\nvec4 nc=texture2D(spriteSheet,tileUV*frameSize+offset);if (i==0){color=nc;} else {float alpha=min(color.a+nc.a,1.0);vec3 mixed=mix(color.xyz,nc.xyz,nc.a);color=vec4(mixed,alpha);}}\ncolor.xyz*=colorMul;gl_FragColor=color;}"; Ut.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 Hx, Xx = 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; a < r.layerCount; a++)this._tileMaps.push(this._createTileBuffer(null, a)); this._animationMap = this._createTileAnimationBuffer(null); var s = []; s.push("#define LAYERS " + r.layerCount), r.flipU && s.push("#define FLIPU"), s.push("#define MAX_ANIMATION_FRAMES ".concat(r.maxAnimationFrames, ".0")); var l, c = Vt.ShadersStore.spriteMapPixelShader; if (n.getEngine()._features.supportSwitchCaseInShader) { for (l = "switch(i) {", a = 0; a < r.layerCount; a++)l += "case " + a + " : frameID = texture(tileMaps[" + a + "], (tileID + 0.5) / stageSize, 0.).x;", l += "break;"; l += "}" } else { l = ""; for (a = 0; a < r.layerCount; a++)l += "if (".concat(a, " == i) { frameID = texture2D(tileMaps[").concat(a, "], (tileID + 0.5) / stageSize, 0.).x; }") } Vt.ShadersStore["spriteMap" + this.name + "PixelShader"] = c.replace("#define LAYER_ID_SWITCH", l), this._material = new Gu("spriteMap:" + this.name, this._scene, { vertex: "spriteMap", fragment: "spriteMap" + this.name }, { defines: s, attributes: ["position", "normal", "uv"], uniforms: ["worldViewProjection", "time", "stageSize", "outputSize", "spriteMapSize", "spriteCount", "time", "colorMul", "mousePosition", "curTile", "flipU"], samplers: ["spriteSheet", "frameMap", "tileMaps", "animationMap"], needAlphaBlending: !0 }), this._time = 0, this._material.setFloat("spriteCount", this.spriteCount), this._material.setVector2("stageSize", r.stageSize), this._material.setVector2("outputSize", r.outputSize), this._material.setTexture("spriteSheet", this.spriteSheet), this._material.setVector2("spriteMapSize", new A(1, 1)), this._material.setVector3("colorMul", r.colorMultiply); var u = 0, h = function () { o.spriteSheet && o.spriteSheet.isReady() && o.spriteSheet._texture ? o._material.setVector2("spriteMapSize", new A(o.spriteSheet._texture.baseWidth || 1, o.spriteSheet._texture.baseHeight || 1)) : u < 100 && setTimeout((function () { u++, h() }), 100) }; h(), this._material.setVector3("colorMul", r.colorMultiply), this._material.setTexture("frameMap", this._frameMap), this._material.setTextureArray("tileMaps", this._tileMaps), this._material.setTexture("animationMap", this._animationMap), this._material.setFloat("time", this._time), this._output = No(e + ":output", { size: 1, updatable: !0 }, n), this._output.scaling.x = r.outputSize.x, this._output.scaling.y = r.outputSize.y, this.position = r.outputPosition, this.rotation = r.outputRotation, this._scene.onBeforeRenderObservable.add((function () { o._time += o._scene.getEngine().getDeltaTime(), o._material.setFloat("time", o._time) })), this._output.material = this._material } return Object.defineProperty(e.prototype, "spriteCount", { get: function () { return this.sprites.length }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "position", { get: function () { return this._output.position }, set: function (e) { this._output.position = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "rotation", { get: function () { return this._output.rotation }, set: function (e) { this._output.rotation = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "animationMap", { get: function () { return this._animationMap }, set: function (e) { var t = e._texture._bufferView, i = this._createTileAnimationBuffer(t); this._animationMap.dispose(), this._animationMap = i, this._material.setTexture("animationMap", this._animationMap) }, enumerable: !1, configurable: !0 }), e.prototype.getTileID = function () { var e = this.getMousePosition(); return e.multiplyInPlace(this.options.stageSize || A.Zero()), e.x = Math.floor(e.x), e.y = Math.floor(e.y), e }, e.prototype.getMousePosition = function () { var e = this._output, t = this._scene.pick(this._scene.pointerX, this._scene.pointerY, (function (t) { return t === e })); return t && t.hit && t.getTextureCoordinates && t.getTextureCoordinates() || new A(-1, -1) }, e.prototype._createFrameBuffer = function () { for (var e = new Array, t = 0; t < this.spriteCount; t++)e.push(0, 0, 0, 0), e.push(0, 0, 0, 0), e.push(0, 0, 0, 0), e.push(0, 0, 0, 0); for (t = 0; t < this.spriteCount; t++) { var i = this.sprites[t].frame, r = this.sprites[t].spriteSourceSize, n = this.sprites[t].sourceSize, o = this.sprites[t].rotated ? 1 : 0, a = this.sprites[t].trimmed ? 1 : 0; e[4 * t] = i.x, e[4 * t + 1] = i.y, e[4 * t + 2] = i.w, e[4 * t + 3] = i.h, e[4 * t + 4 * this.spriteCount] = r.x, e[4 * t + 1 + 4 * this.spriteCount] = r.y, e[4 * t + 3 + 4 * this.spriteCount] = r.h, e[4 * t + 8 * this.spriteCount] = n.w, e[4 * t + 1 + 8 * this.spriteCount] = n.h, e[4 * t + 2 + 8 * this.spriteCount] = o, e[4 * t + 3 + 8 * this.spriteCount] = a } var s = new Float32Array(e); return Eo.CreateRGBATexture(s, this.spriteCount, 4, this._scene, !1, !1, vo.NEAREST_NEAREST, In.TEXTURETYPE_FLOAT) }, e.prototype._createTileBuffer = function (e, t) { void 0 === t && (t = 0); var i = new Array, r = this.options.stageSize.y || 0, n = this.options.stageSize.x || 0; if (e) i = e; else { var o = this.options.baseTile; 0 != t && (o = 0); for (var a = 0; a < r; a++)for (var s = 0; s < 4 * n; s += 4)i.push(o, 0, 0, 0) } var l = new Float32Array(i); return Eo.CreateRGBATexture(l, n, r, this._scene, !1, !1, vo.NEAREST_NEAREST, In.TEXTURETYPE_FLOAT) }, e.prototype.changeTiles = function (e, t, i) { void 0 === e && (e = 0), void 0 === i && (i = 0); var r = this._tileMaps[e]._texture._bufferView; if (null !== r) { var n = new Array; t instanceof A ? n.push(t) : n = t; for (var o = this.options.stageSize.x || 0, a = 0; a < n.length; a++) { var s = n[a]; s.x = Math.floor(s.x), s.y = Math.floor(s.y), r[4 * s.x + s.y * (4 * o)] = i } var l = this._createTileBuffer(r); this._tileMaps[e].dispose(), this._tileMaps[e] = l, this._material.setTextureArray("tileMap", this._tileMaps) } }, e.prototype._createTileAnimationBuffer = function (e) { var t, i = new Array; if (e) t = e; else { for (var r = 0; r < this.spriteCount; r++) { i.push(0, 0, 0, 0); for (var n = 1; n < (this.options.maxAnimationFrames || 4);)i.push(0, 0, 0, 0), n++ } t = new Float32Array(i) } return Eo.CreateRGBATexture(t, this.spriteCount, this.options.maxAnimationFrames || 4, this._scene, !1, !1, vo.NEAREST_NEAREST, In.TEXTURETYPE_FLOAT) }, e.prototype.addAnimationToTile = function (e, t, i, r, n) { void 0 === e && (e = 0), void 0 === t && (t = 0), void 0 === i && (i = 0), void 0 === r && (r = 0), void 0 === n && (n = 1); var o = this._animationMap._texture._bufferView, a = 4 * e + 4 * this.spriteCount * t; if (o) { o[a] = i, o[a + 1] = r, o[a + 2] = n; var s = this._createTileAnimationBuffer(o); this._animationMap.dispose(), this._animationMap = s, this._material.setTexture("animationMap", this._animationMap) } }, e.prototype.saveTileMaps = function () { for (var e = "", t = 0; t < this._tileMaps.length; t++)t > 0 && (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 < r; n++) { var o = e[n].split(",").map(Number), a = t._createTileBuffer(o); t._tileMaps[n].dispose(), t._tileMaps[n] = a } t._material.setTextureArray("tileMap", t._tileMaps) }, i.send() }, e.prototype.dispose = function () { this._output.dispose(), this._material.dispose(), this._animationMap.dispose(), this._tileMaps.forEach((function (e) { e.dispose() })), this._frameMap.dispose() }, e }(), jx = function (e) { function t(t, i, r, n, o, a, s) { void 0 === o && (o = null), void 0 === a && (a = .01), void 0 === s && (s = vo.TRILINEAR_SAMPLINGMODE); var l = e.call(this, t, i, r, 64, n, a, s, !0, o) || this; return l.name = t, l } return W(t, e), t }(Wx); !function (e) { e[e.INIT = 0] = "INIT", e[e.RUNNING = 1] = "RUNNING", e[e.DONE = 2] = "DONE", e[e.ERROR = 3] = "ERROR" }(Hx || (Hx = {})); var Yx = function () { function e(e) { this.name = e, this._isCompleted = !1, this._taskState = Hx.INIT } return Object.defineProperty(e.prototype, "isCompleted", { get: function () { return this._isCompleted }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "taskState", { get: function () { return this._taskState }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "errorObject", { get: function () { return this._errorObject }, enumerable: !1, configurable: !0 }), e.prototype._setErrorObject = function (e, t) { this._errorObject || (this._errorObject = { message: e, exception: t }) }, e.prototype.run = function (e, t, i) { var r = this; this._taskState = Hx.RUNNING, this.runTask(e, (function () { r._onDoneCallback(t, i) }), (function (e, t) { r._onErrorCallback(i, e, t) })) }, e.prototype.runTask = function (e, t, i) { throw new Error("runTask is not implemented") }, e.prototype.reset = function () { this._taskState = Hx.INIT }, e.prototype._onErrorCallback = function (e, t, i) { this._taskState = Hx.ERROR, this._errorObject = { message: t, exception: i }, this.onError && this.onError(this, t, i), e() }, e.prototype._onDoneCallback = function (e, t) { try { this._taskState = Hx.DONE, this._isCompleted = !0, this.onSuccess && this.onSuccess(this), e() } catch (e) { this._onErrorCallback(t, "Task is done, error executing success callback(s)", e) } }, e }(), Kx = function (e, t, i) { this.remainingCount = e, this.totalCount = t, this.task = i }, Qx = function (e) { function t(t, i, r, n, o) { var a = e.call(this, t) || this; return a.name = t, a.meshesNames = i, a.rootUrl = r, a.sceneFilename = n, a.extension = o, a } return W(t, e), t.prototype.runTask = function (e, t, i) { var r = this; ea.LoadAssetContainer(this.rootUrl, this.sceneFilename, e, (function (e) { r.loadedContainer = e, r.loadedMeshes = e.meshes, r.loadedTransformNodes = e.transformNodes, r.loadedParticleSystems = e.particleSystems, r.loadedSkeletons = e.skeletons, r.loadedAnimationGroups = e.animationGroups, t() }), null, (function (e, t, r) { i(t, r) }), this.extension) }, t }(Yx), qx = function (e) { function t(t, i, r, n, o) { var a = e.call(this, t) || this; return a.name = t, a.meshesNames = i, a.rootUrl = r, a.sceneFilename = n, a.extension = o, a } return W(t, e), t.prototype.runTask = function (e, t, i) { var r = this; ea.ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, e, (function (e, i, n, o, a) { r.loadedMeshes = e, r.loadedTransformNodes = a, r.loadedParticleSystems = i, r.loadedSkeletons = n, r.loadedAnimationGroups = o, t() }), null, (function (e, t, r) { i(t, r) }), this.extension) }, t }(Yx), Zx = function (e) { function t(t, i, r, n, o) { var a = e.call(this, t) || this; return a.name = t, a.rootUrl = i, a.filename = r, a.targetConverter = n, a.extension = o, a } return W(t, e), t.prototype.runTask = function (e, t, i) { var r = this, n = e.animatables.length, o = e.animationGroups.length; this.loadedAnimatables = [], this.loadedAnimationGroups = [], ea.ImportAnimations(this.rootUrl, this.filename, e, !1, qo.NoSync, this.targetConverter, (function () { r.loadedAnimatables = e.animatables.slice(n), r.loadedAnimationGroups = e.animationGroups.slice(o), t() }), null, (function (e, t, r) { i(t, r) }), this.extension) }, t }(Yx), Jx = function (e) { function t(t, i) { var r = e.call(this, t) || this; return r.name = t, r.url = i, r } return W(t, e), t.prototype.runTask = function (e, t, i) { var r = this; e._loadFile(this.url, (function (e) { r.text = e, t() }), void 0, !1, !1, (function (e, t) { e && i(e.status + " " + e.statusText, t) })) }, t }(Yx), $x = function (e) { function t(t, i) { var r = e.call(this, t) || this; return r.name = t, r.url = i, r } return W(t, e), t.prototype.runTask = function (e, t, i) { var r = this; e._loadFile(this.url, (function (e) { r.data = e, t() }), void 0, !0, !0, (function (e, t) { e && i(e.status + " " + e.statusText, t) })) }, t }(Yx), eA = function (e) { function t(t, i) { var r = e.call(this, t) || this; return r.name = t, r.url = i, r } return W(t, e), t.prototype.runTask = function (e, t, i) { var r = this, n = new Image; xi.SetCorsBehavior(this.url, n), n.onload = function () { r.image = n, t() }, n.onerror = function (e) { i("Error loading image", e) }, n.src = this.url }, t }(Yx), tA = function (e) { function t(t, i, r, n, o) { void 0 === n && (n = !0), void 0 === o && (o = vo.TRILINEAR_SAMPLINGMODE); var a = e.call(this, t) || this; return a.name = t, a.url = i, a.noMipmap = r, a.invertY = n, a.samplingMode = o, a } return W(t, e), t.prototype.runTask = function (e, t, i) { this.texture = new vo(this.url, e, this.noMipmap, this.invertY, this.samplingMode, (function () { t() }), (function (e, t) { i(e, t) })) }, t }(Yx), iA = function (e) { function t(t, i, r, n, o, a) { var s = e.call(this, t) || this; return s.name = t, s.url = i, s.extensions = r, s.noMipmap = n, s.files = o, s.prefiltered = a, s } return W(t, e), t.prototype.runTask = function (e, t, i) { this.texture = new h_(this.url, e, this.extensions, this.noMipmap, this.files, (function () { t() }), (function (e, t) { i(e, t) }), void 0, this.prefiltered) }, t }(Yx), rA = function (e) { function t(t, i, r, n, o, a, s) { void 0 === n && (n = !1), void 0 === o && (o = !0), void 0 === a && (a = !1), void 0 === s && (s = !1); var l = e.call(this, t) || this; return l.name = t, l.url = i, l.size = r, l.noMipmap = n, l.generateHarmonics = o, l.gammaSpace = a, l.reserved = s, l } return W(t, e), t.prototype.runTask = function (e, t, i) { this.texture = new sg(this.url, e, this.size, this.noMipmap, this.generateHarmonics, this.gammaSpace, this.reserved, (function () { t() }), (function (e, t) { i(e, t) })) }, t }(Yx), nA = function (e) { function t(t, i, r, n, o) { void 0 === n && (n = !1), void 0 === o && (o = !0); var a = e.call(this, t) || this; return a.name = t, a.url = i, a.size = r, a.noMipmap = n, a.gammaSpace = o, a } return W(t, e), t.prototype.runTask = function (e, t, i) { this.texture = new Ng(this.url, e, this.size, this.noMipmap, this.gammaSpace, (function () { t() }), (function (e, t) { i(e, t) })) }, t }(Yx), oA = function () { function e(e) { this._isLoading = !1, this._tasks = new Array, this._waitingTasksCount = 0, this._totalTasksCount = 0, this.onTaskSuccessObservable = new u, this.onTaskErrorObservable = new u, this.onTasksDoneObservable = new u, this.onProgressObservable = new u, this.useDefaultLoadingScreen = !0, this.autoHideLoadingUI = !0, this._scene = e || S.LastCreatedScene } return e.prototype.addContainerTask = function (e, t, i, r, n) { var o = new Qx(e, t, i, r, n); return this._tasks.push(o), o }, e.prototype.addMeshTask = function (e, t, i, r, n) { var o = new qx(e, t, i, r, n); return this._tasks.push(o), o }, e.prototype.addTextFileTask = function (e, t) { var i = new Jx(e, t); return this._tasks.push(i), i }, e.prototype.addBinaryFileTask = function (e, t) { var i = new $x(e, t); return this._tasks.push(i), i }, e.prototype.addImageTask = function (e, t) { var i = new eA(e, t); return this._tasks.push(i), i }, e.prototype.addTextureTask = function (e, t, i, r, n) { void 0 === n && (n = vo.TRILINEAR_SAMPLINGMODE); var o = new tA(e, t, i, r, n); return this._tasks.push(o), o }, e.prototype.addCubeTextureTask = function (e, t, i, r, n, o) { var a = new iA(e, t, i, r, n, o); return this._tasks.push(a), a }, e.prototype.addHDRCubeTextureTask = function (e, t, i, r, n, o, a) { void 0 === r && (r = !1), void 0 === n && (n = !0), void 0 === o && (o = !1), void 0 === a && (a = !1); var s = new rA(e, t, i, r, n, o, a); return this._tasks.push(s), s }, e.prototype.addEquiRectangularCubeTextureAssetTask = function (e, t, i, r, n) { void 0 === r && (r = !1), void 0 === n && (n = !0); var o = new nA(e, t, i, r, n); return this._tasks.push(o), o }, e.prototype.removeTask = function (e) { var t = this._tasks.indexOf(e); t > -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 Kx(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 < r.length; i++) { var n = r[i]; if (n.taskState === Hx.DONE) { var o = this._tasks.indexOf(n); o > -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 < this._tasks.length; e++) { var t = this._tasks[e]; t.taskState === Hx.INIT && this._runTask(t) } return this }, e.prototype.loadAsync = function () { var e = this; return new Promise((function (t, i) { e._isLoading ? t() : (e.onTasksDoneObservable.addOnce((function (e) { e && e.length ? i(e) : t() })), e.load()) })) }, e }(), aA = function () { function e() { var e = this; this.promise = new Promise((function (t, i) { e._resolve = t, e._reject = i })) } return Object.defineProperty(e.prototype, "resolve", { get: function () { return this._resolve }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "reject", { get: function () { return this._reject }, enumerable: !1, configurable: !0 }), e }(), sA = function () { function e(e, t) { this._meshesOrigins = [], this._toCenterVectors = [], this._scaledDirection = new R(1, 1, 1), this._newPosition = R.Zero(), this._centerPosition = R.Zero(), this._meshes = e.slice(), t ? this._centerMesh = t : this._setCenterMesh(), this._centerMesh.computeWorldMatrix(!0); var i = this._meshes.indexOf(this._centerMesh); i >= 0 && this._meshes.splice(i, 1), this._centerPosition = this._centerMesh.getAbsolutePosition().clone(); for (var r = 0; r < this._meshes.length; r++)if (this._meshes[r]) { var n = this._meshes[r]; this._meshesOrigins[r] = n.getAbsolutePosition().clone(), this._toCenterVectors[r] = R.Zero(), n.hasBoundingInfo && this._centerMesh.hasBoundingInfo && (n.computeWorldMatrix(!0), n.getBoundingInfo().boundingBox.centerWorld.subtractToRef(this._centerMesh.getBoundingInfo().boundingBox.centerWorld, this._toCenterVectors[r])) } } return e.prototype._setCenterMesh = function () { for (var e = R.Zero(), t = R.Zero(), i = Number.MAX_VALUE, r = 0; r < this._meshes.length; r++)this._meshes[r] && (o = (n = this._meshes[r]).getBoundingInfo()) && t.addInPlace(o.boundingBox.centerWorld); for (e = t.scale(1 / this._meshes.length), r = 0; r < this._meshes.length; r++) { var n, o; if (this._meshes[r] && (o = (n = this._meshes[r]).getBoundingInfo())) { var a = o.boundingBox.centerWorld.subtract(e).lengthSquared(); a < i && (this._centerMesh = n, i = a) } } }, e.prototype.getClassName = function () { return "MeshExploder" }, e.prototype.getMeshes = function () { var e = this._meshes.slice(); return e.unshift(this._centerMesh), e }, e.prototype.explode = function (e) { void 0 === e && (e = 1); for (var t = 0; t < this._meshes.length; t++)this._meshes[t] && this._meshesOrigins[t] && this._toCenterVectors[t] && (this._toCenterVectors[t].scaleToRef(e, this._scaledDirection), this._meshesOrigins[t].addToRef(this._scaledDirection, this._newPosition), this._meshes[t].setAbsolutePosition(this._newPosition)); this._centerMesh.setAbsolutePosition(this._centerPosition) }, e }(), lA = function () { function e(e, t, i, r, n, o, a, s, l, c) { void 0 === c && (c = !1); var u = this; this.useAppend = c, this.onProcessFileCallback = function () { return !0 }, this.displayLoadingUI = !0, this.loadAsync = function (e, t) { return u.useAppend ? ea.AppendAsync("file:", e, u._currentScene, t) : ea.LoadAsync("file:", e, u._engine, t) }, this._engine = e, this._currentScene = t, this._sceneLoadedCallback = i, this._progressCallback = r, this._additionalRenderLoopLogicCallback = n, this._textureLoadingCallback = o, this._startingProcessingFilesCallback = a, this._onReloadCallback = s, this._errorCallback = l } return Object.defineProperty(e, "FilesToLoad", { get: function () { return st.FilesToLoad }, enumerable: !1, configurable: !0 }), e.prototype.monitorElementForDragNDrop = function (e) { var t = this; e && (this._elementToMonitor = e, this._dragEnterHandler = function (e) { t._drag(e) }, this._dragOverHandler = function (e) { t._drag(e) }, this._dropHandler = function (e) { t._drop(e) }, this._elementToMonitor.addEventListener("dragenter", this._dragEnterHandler, !1), this._elementToMonitor.addEventListener("dragover", this._dragOverHandler, !1), this._elementToMonitor.addEventListener("drop", this._dropHandler, !1)) }, Object.defineProperty(e.prototype, "filesToLoad", { get: function () { return this._filesToLoad }, enumerable: !1, configurable: !0 }), e.prototype.dispose = function () { this._elementToMonitor && (this._elementToMonitor.removeEventListener("dragenter", this._dragEnterHandler), this._elementToMonitor.removeEventListener("dragover", this._dragOverHandler), this._elementToMonitor.removeEventListener("drop", this._dropHandler)) }, e.prototype._renderFunction = function () { if (this._additionalRenderLoopLogicCallback && this._additionalRenderLoopLogicCallback(), this._currentScene) { if (this._textureLoadingCallback) { var e = this._currentScene.getWaitingItemsCount(); e > 0 && 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; o < s.length; o++) { var l = s[o]; l.isFile ? l.file((function (e) { e.correctName = a + e.name, t.push(e), 0 == --i.count && r() })) : l.isDirectory && n._traverseFolder(l, t, i, r) } 0 == --i.count && r() })) }, e.prototype._processFiles = function (t) { for (var i = this, r = 0; r < t.length; r++) { var n = t[r].correctName.toLowerCase(), o = n.split(".").pop(); this.onProcessFileCallback(t[r], n, o, (function (e) { return i._sceneFileToLoad = e })) && (ea.IsPluginForExtensionAvailable("." + o) && (this._sceneFileToLoad = t[r]), e.FilesToLoad[n] = t[r]) } }, e.prototype.loadFiles = function (e) { var t = this; if (e && e.dataTransfer && e.dataTransfer.files && (this._filesToLoad = e.dataTransfer.files), e && e.target && e.target.files && (this._filesToLoad = e.target.files), this._filesToLoad && 0 !== this._filesToLoad.length && (this._startingProcessingFilesCallback && this._startingProcessingFilesCallback(this._filesToLoad), this._filesToLoad && this._filesToLoad.length > 0)) { for (var i = new Array, r = [], n = e.dataTransfer ? e.dataTransfer.items : null, o = 0; o < this._filesToLoad.length; o++) { var a = this._filesToLoad[o], s = a.name.toLowerCase(), l = void 0; if (a.correctName = s, n) { var c = n[o]; c.getAsEntry ? l = c.getAsEntry() : c.webkitGetAsEntry && (l = c.webkitGetAsEntry()) } l && l.isDirectory ? r.push(l) : i.push(a) } if (0 === r.length) this._processFiles(i), this._processReload(); else for (var u = { count: r.length }, h = 0, d = r; h < d.length; h++) { var p = d[h]; this._traverseFolder(p, i, u, (function () { t._processFiles(i), 0 === u.count && t._processReload() })) } } }, e.prototype._processReload = function () { this._onReloadCallback ? this._onReloadCallback(this._sceneFileToLoad) : this.reload() }, e.prototype.reload = function () { var e = this; this._sceneFileToLoad ? (this.useAppend || this._currentScene && ($.errorsCount > 0 && $.ClearLogCache(), this._engine.stopRenderLoop()), ea.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 }(), cA = function () { function e() { } return e.prototype.dispose = function () { if (this._observers && this._observables) for (var e = 0; e < this._observers.length; e++)this._observables[e].remove(this._observers[e]); this._observers = null, this._observables = null }, e.Watch = function (t, i, r, n) { void 0 === r && (r = -1), void 0 === n && (n = null); var o = new e; o._observers = new Array, o._observables = t; for (var a = 0, s = t; a < s.length; a++) { var l = s[a].add(i, r, !1, n); l && o._observers.push(l) } return o }, e }(); u.prototype.notifyObserversWithPromise = function (e, t, i, r, n) { return void 0 === t && (t = -1), j(this, void 0, void 0, (function () { var o, a, s = this; return Y(this, (function (l) { switch (l.label) { case 0: return o = Promise.resolve(e), this.observers.length ? ((a = this._eventState).mask = t, a.target = i, a.currentTarget = r, a.skipNextObservers = !1, a.userInfo = n, this.observers.forEach((function (i) { a.skipNextObservers || i._willBeUnregistered || i.mask & t && (o = i.scope ? o.then((function (t) { return a.lastReturnValue = t, i.callback.apply(i.scope, [e, a]) })) : o.then((function (t) { return a.lastReturnValue = t, i.callback(e, a) })), i.unregisterOnNextCall && s._deferUnregister(i)) })), [4, o]) : [2, o]; case 1: return l.sent(), [2, e] } })) })) }; var uA = function () { function e(e) { void 0 === e && (e = 0), this.priority = e } return e.prototype.getDescription = function () { return "" }, e.prototype.apply = function (e, t) { return !0 }, e }(), hA = function (e) { function t(t, i, r) { void 0 === t && (t = 0), void 0 === i && (i = 1024), void 0 === r && (r = .5); var n = e.call(this, t) || this; return n.priority = t, n.maximumSize = i, n.step = r, n } return W(t, e), t.prototype.getDescription = function () { return "Reducing render target texture size to " + this.maximumSize }, t.prototype.apply = function (e, t) { for (var i = !0, r = 0; r < e.textures.length; r++) { var n = e.textures[r]; if (n.canRescale && !n.getContext) { var o = n.getSize(); Math.max(o.width, o.height) > this.maximumSize && (n.scale(this.step), i = !1) } } return i }, t }(uA), dA = 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 }(uA), pA = 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 }(uA), fA = 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 }(uA), _A = 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 }(uA), mA = 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 }(uA), gA = 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 }(uA), 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 }(uA), yA = function (e) { function t() { var t = null !== e && e.apply(this, arguments) || this; return t._canBeMerged = function (e) { if (!(e instanceof Jn)) 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 < o; a++) { var s = new Array, l = n[a]; if (this._canBeMerged(l)) { s.push(l); for (var c = a + 1; c < o; c++) { var u = n[c]; this._canBeMerged(u) && u.material === l.material && u.checkCollisions === l.checkCollisions && (s.push(u), o--, n.splice(c, 1), c--) } s.length < 2 || Jn.MergeMeshes(s, void 0, !0) } } var h = e; return h.createOrUpdateSelectionOctree && (null != r ? r && h.createOrUpdateSelectionOctree() : t.UpdateSelectionTree && h.createOrUpdateSelectionOctree()), !0 }, t._UpdateSelectionTree = !1, t }(uA), bA = function () { function e(e, t) { void 0 === e && (e = 60), void 0 === t && (t = 2e3), this.targetFrameRate = e, this.trackerDuration = t, this.optimizations = new Array } return e.prototype.addOptimization = function (e) { return this.optimizations.push(e), this }, e.prototype.addCustomOptimization = function (e, t, i) { void 0 === i && (i = 0); var r = new mA(i); return r.onApply = e, r.onGetDescription = t, this.optimizations.push(r), this }, e.LowDegradationAllowed = function (t) { var i = new e(t), r = 0; return i.addOptimization(new yA(r)), i.addOptimization(new pA(r)), i.addOptimization(new _A(r)), r++, i.addOptimization(new fA(r)), i.addOptimization(new gA(r)), r++, i.addOptimization(new hA(r, 1024)), i }, e.ModerateDegradationAllowed = function (t) { var i = new e(t), r = 0; return i.addOptimization(new yA(r)), i.addOptimization(new pA(r)), i.addOptimization(new _A(r)), r++, i.addOptimization(new fA(r)), i.addOptimization(new gA(r)), r++, i.addOptimization(new hA(r, 512)), r++, i.addOptimization(new vA(r)), r++, i.addOptimization(new dA(r, 2)), i }, e.HighDegradationAllowed = function (t) { var i = new e(t), r = 0; return i.addOptimization(new yA(r)), i.addOptimization(new pA(r)), i.addOptimization(new _A(r)), r++, i.addOptimization(new fA(r)), i.addOptimization(new gA(r)), r++, i.addOptimization(new hA(r, 256)), r++, i.addOptimization(new vA(r)), r++, i.addOptimization(new dA(r, 4)), i }, e }(), TA = function () { function e(e, t, i, r) { void 0 === i && (i = !0), void 0 === r && (r = !1); var n = this; if (this._isRunning = !1, this._currentPriorityLevel = 0, this._targetFrameRate = 60, this._trackerDuration = 2e3, this._currentFrameRate = 0, this._improvementMode = !1, this.onSuccessObservable = new u, this.onNewOptimizationAppliedObservable = new u, this.onFailureObservable = new u, this._options = t || new bA, this._options.targetFrameRate && (this._targetFrameRate = this._options.targetFrameRate), this._options.trackerDuration && (this._trackerDuration = this._options.trackerDuration), i) for (var o = 0, a = 0, s = this._options.optimizations; a < s.length; a++)s[a].priority = o++; this._improvementMode = r, this._scene = e || S.LastCreatedScene, this._sceneDisposeObserver = this._scene.onDisposeObservable.add((function () { n._sceneDisposeObserver = null, n.dispose() })) } return Object.defineProperty(e.prototype, "isInImprovementMode", { get: function () { return this._improvementMode }, set: function (e) { this._improvementMode = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "currentPriorityLevel", { get: function () { return this._currentPriorityLevel }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "currentFrameRate", { get: function () { return this._currentFrameRate }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "targetFrameRate", { get: function () { return this._targetFrameRate }, set: function (e) { this._targetFrameRate = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "trackerDuration", { get: function () { return this._trackerDuration }, set: function (e) { this._trackerDuration = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "optimizations", { get: function () { return this._options.optimizations }, enumerable: !1, configurable: !0 }), e.prototype.stop = function () { this._isRunning = !1 }, e.prototype.reset = function () { this._currentPriorityLevel = 0 }, e.prototype.start = function () { var e = this; this._isRunning || (this._isRunning = !0, this._scene.executeWhenReady((function () { setTimeout((function () { e._checkCurrentState() }), e._trackerDuration) }))) }, e.prototype._checkCurrentState = function () { var e = this; if (this._isRunning) { var t = this._scene, i = this._options; if (this._currentFrameRate = Math.round(t.getEngine().getFps()), this._improvementMode && this._currentFrameRate <= this._targetFrameRate || !this._improvementMode && this._currentFrameRate >= this._targetFrameRate) return this._isRunning = !1, void this.onSuccessObservable.notifyObservers(this); for (var r = !0, n = !0, o = 0; o < i.optimizations.length; o++) { var a = i.optimizations[o]; a.priority === this._currentPriorityLevel && (n = !1, r = r && a.apply(t, this), this.onNewOptimizationAppliedObservable.notifyObservers(a)) } if (n) return this._isRunning = !1, void this.onFailureObservable.notifyObservers(this); r && this._currentPriorityLevel++, t.executeWhenReady((function () { setTimeout((function () { e._checkCurrentState() }), e._trackerDuration) })) } }, e.prototype.dispose = function () { this.stop(), this.onSuccessObservable.clear(), this.onFailureObservable.clear(), this.onNewOptimizationAppliedObservable.clear(), this._sceneDisposeObserver && this._scene.onDisposeObservable.remove(this._sceneDisposeObserver) }, e.OptimizeAsync = function (t, i, r, n) { var o = new e(t, i || bA.ModerateDegradationAllowed(), !1); return r && o.onSuccessObservable.add((function () { r() })), n && o.onFailureObservable.add((function () { n() })), o.start(), o }, e }(), EA = [], SA = function (e, t) { e.doNotSerialize || (t.vertexData.push(e.serializeVerticeData()), EA[e.id] = !0) }, xA = function (e, t) { var i = {}, r = e._geometry; return r && (e.getScene().getGeometryById(r.id) || SA(r, t.geometries)), e.serialize && e.serialize(i), i }, AA = function () { function e() { } return e.ClearCache = function () { EA = [] }, e.Serialize = function (t) { return e._Serialize(t) }, e._Serialize = function (t, i) { void 0 === i && (i = !0); var r, n, o, s = {}; if (i && !t.getEngine()._features.supportSyncTextureRead && vo.ForceSerializeBuffers && console.warn("The serialization object may not contain the proper base64 encoded texture data! You should use the SerializeAsync method instead."), e.ClearCache(), s.useDelayedTextureLoading = t.useDelayedTextureLoading, s.autoClear = t.autoClear, s.clearColor = t.clearColor.asArray(), s.ambientColor = t.ambientColor.asArray(), s.gravity = t.gravity.asArray(), s.collisionsEnabled = t.collisionsEnabled, s.useRightHandedSystem = t.useRightHandedSystem, t.fogMode && 0 !== t.fogMode && (s.fogMode = t.fogMode, s.fogColor = t.fogColor.asArray(), s.fogStart = t.fogStart, s.fogEnd = t.fogEnd, s.fogDensity = t.fogDensity), t.isPhysicsEnabled && t.isPhysicsEnabled()) { var l = t.getPhysicsEngine(); l && (s.physicsEnabled = !0, s.physicsGravity = l.gravity.asArray(), s.physicsEngine = l.getPhysicsPluginName()) } t.metadata && (s.metadata = t.metadata), s.morphTargetManagers = []; for (var c = 0, u = t.meshes; c < u.length; c++) { var h = (b = u[c]).morphTargetManager; h && s.morphTargetManagers.push(h.serialize()) } for (s.lights = [], r = 0; r < t.lights.length; r++)(n = t.lights[r]).doNotSerialize || s.lights.push(n.serialize()); for (s.cameras = [], r = 0; r < t.cameras.length; r++) { var d = t.cameras[r]; d.doNotSerialize || s.cameras.push(d.serialize()) } if (t.activeCamera && (s.activeCameraID = t.activeCamera.id), Ue.AppendSerializedAnimations(t, s), t.animationGroups && t.animationGroups.length > 0) { s.animationGroups = []; for (var p = 0; p < t.animationGroups.length; p++) { var f = t.animationGroups[p]; s.animationGroups.push(f.serialize()) } } if (t.reflectionProbes && t.reflectionProbes.length > 0) for (s.reflectionProbes = [], r = 0; r < t.reflectionProbes.length; r++) { var _ = t.reflectionProbes[r]; s.reflectionProbes.push(_.serialize()) } for (s.materials = [], s.multiMaterials = [], r = 0; r < t.materials.length; r++)(o = t.materials[r]).doNotSerialize || s.materials.push(o.serialize()); for (s.multiMaterials = [], r = 0; r < t.multiMaterials.length; r++) { var m = t.multiMaterials[r]; s.multiMaterials.push(m.serialize()) } for (t.environmentTexture && (t.environmentTexture._files ? s.environmentTexture = t.environmentTexture.serialize() : (s.environmentTexture = t.environmentTexture.name, s.environmentTextureRotationY = t.environmentTexture.rotationY)), s.environmentIntensity = t.environmentIntensity, s.skeletons = [], r = 0; r < t.skeletons.length; r++) { var g = t.skeletons[r]; g.doNotSerialize || s.skeletons.push(g.serialize()) } for (s.transformNodes = [], r = 0; r < t.transformNodes.length; r++)t.transformNodes[r].doNotSerialize || s.transformNodes.push(t.transformNodes[r].serialize()); s.geometries = {}, s.geometries.boxes = [], s.geometries.spheres = [], s.geometries.cylinders = [], s.geometries.toruses = [], s.geometries.grounds = [], s.geometries.planes = [], s.geometries.torusKnots = [], s.geometries.vertexData = [], EA = []; var v = t.getGeometries(); for (r = 0; r < v.length; r++) { var y = v[r]; y.isReady() && SA(y, s.geometries) } for (s.meshes = [], r = 0; r < t.meshes.length; r++) { var b; if ((b = t.meshes[r]) instanceof Jn) { var T = b; T.doNotSerialize || T.delayLoadState !== a.DELAYLOADSTATE_LOADED && T.delayLoadState !== a.DELAYLOADSTATE_NONE || s.meshes.push(xA(T, s)) } } for (s.particleSystems = [], r = 0; r < t.particleSystems.length; r++)s.particleSystems.push(t.particleSystems[r].serialize(!1)); for (s.postProcesses = [], r = 0; r < t.postProcesses.length; r++)s.postProcesses.push(t.postProcesses[r].serialize()); t.actionManager && (s.actions = t.actionManager.serialize("scene")); for (var E = 0, S = t._serializableComponents; E < S.length; E++)S[E].serialize(s); return s }, e.SerializeAsync = function (t) { var i = e._Serialize(t, !1), r = []; return this._CollectPromises(i, r), Promise.all(r).then((function () { return i })) }, e._CollectPromises = function (e, t) { if (Array.isArray(e)) for (var i = function (i) { var n = e[i]; n instanceof Promise ? t.push(n.then((function (t) { return e[i] = t }))) : (n instanceof Object || Array.isArray(n)) && r._CollectPromises(n, t) }, r = this, n = 0; n < e.length; ++n)i(n); else if (e instanceof Object) { var o = function (i) { if (Object.prototype.hasOwnProperty.call(e, i)) { var r = e[i]; r instanceof Promise ? t.push(r.then((function (t) { return e[i] = t }))) : (r instanceof Object || Array.isArray(r)) && a._CollectPromises(r, t) } }, a = this; for (var s in e) o(s) } }, e.SerializeMesh = function (t, i, r) { void 0 === i && (i = !1), void 0 === r && (r = !1); var n = { meshes: [], transformNodes: [], cameras: [], lights: [] }; if (e.ClearCache(), t = t instanceof Array ? t : [t], i || r) for (var o = 0; o < t.length; ++o)r && t[o].getDescendants().forEach((function (e) { t.indexOf(e) < 0 && !e.doNotSerialize && t.push(e) })), i && t[o].parent && t.indexOf(t[o].parent) < 0 && !t[o].parent.doNotSerialize && t.push(t[o].parent); return t.forEach((function (e) { !function (e, t) { if (e._isMesh) { var i = e; if (i.delayLoadState === a.DELAYLOADSTATE_LOADED || i.delayLoadState === a.DELAYLOADSTATE_NONE) { var r = function (e) { t.materials = t.materials || [], i.material && !t.materials.some((function (e) { return e.id === i.material.id })) && t.materials.push(e.serialize()) }; if (i.material && !i.material.doNotSerialize) if (i.material instanceof Xn) { if (t.multiMaterials = t.multiMaterials || [], !t.multiMaterials.some((function (e) { return e.id === i.material.id }))) { t.multiMaterials.push(i.material.serialize()); for (var n = 0, o = i.material.subMaterials; n < o.length; n++) { var s = o[n]; s && r(s) } } } else r(i.material); else i.material || r(i.getScene().defaultMaterial); var l = i._geometry; l && (t.geometries || (t.geometries = {}, t.geometries.boxes = [], t.geometries.spheres = [], t.geometries.cylinders = [], t.geometries.toruses = [], t.geometries.grounds = [], t.geometries.planes = [], t.geometries.torusKnots = [], t.geometries.vertexData = []), SA(l, t.geometries)), i.skeleton && !i.skeleton.doNotSerialize && (t.skeletons = t.skeletons || [], t.skeletons.push(i.skeleton.serialize())), t.meshes = t.meshes || [], t.meshes.push(xA(i, t)) } } else if ("TransformNode" === e.getClassName()) { var c = e; t.transformNodes.push(c.serialize()) } else if (-1 !== e.getClassName().indexOf("Camera")) { var u = e; t.cameras.push(u.serialize()) } else if (-1 !== e.getClassName().indexOf("Light")) { var h = e; t.lights.push(h.serialize()) } }(e, n) })), n }, e }(), RA = function () { function e(t, i) { if (void 0 === i && (i = {}), !e.IsSupported(t)) throw "Your browser does not support recording so far."; var r = t.getRenderingCanvas(); if (!r) throw "The babylon engine must have a canvas to be recorded"; this._canvas = r, this._canvas.isRecording = !1, this._options = H(H({}, e._DefaultOptions), i); var n = this._canvas.captureStream(this._options.fps); if (this._options.audioTracks) for (var o = 0, a = this._options.audioTracks; o < a.length; o++) { var s = a[o]; n.addTrack(s) } this._mediaRecorder = new MediaRecorder(n, { mimeType: this._options.mimeType }), this._mediaRecorder.ondataavailable = this._handleDataAvailable.bind(this), this._mediaRecorder.onerror = this._handleError.bind(this), this._mediaRecorder.onstop = this._handleStop.bind(this) } return e.IsSupported = function (e) { var t = e.getRenderingCanvas(); return !!t && "function" == typeof t.captureStream }, Object.defineProperty(e.prototype, "isRecording", { get: function () { return !!this._canvas && this._canvas.isRecording }, enumerable: !1, configurable: !0 }), e.prototype.stopRecording = function () { this._canvas && this._mediaRecorder && this.isRecording && (this._canvas.isRecording = !1, this._mediaRecorder.stop()) }, e.prototype.startRecording = function (e, t) { var i = this; if (void 0 === e && (e = "babylonjs.webm"), void 0 === t && (t = 7), !this._canvas || !this._mediaRecorder) throw "Recorder has already been disposed"; if (this.isRecording) throw "Recording already in progress"; return t > 0 && 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 && xi.Download(e, this._fileName) }, e._DefaultOptions = { mimeType: "video/webm", fps: 25, recordChunckSize: 3e3 }, e }(), CA = null; function PA(e, t, i, r, n, o, a) { void 0 === n && (n = "image/png"), void 0 === o && (o = !1); var s = NA(e, t, i), l = s.height, c = s.width; if (l && c) { CA || (CA = document.createElement("canvas")), CA.width = c, CA.height = l; var u = CA.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 ? OA(e, t, i, (function (e) { if (o) { var t = new Blob([e]); xi.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), CA && (o ? (xi.EncodeScreenshotCanvasData(CA, void 0, n, void 0, a), r && r("")) : xi.EncodeScreenshotCanvasData(CA, r, n, void 0, a)) })) } else $.Error("Invalid 'size' parameter !") } function IA(e, t, i, r, n) { return void 0 === r && (r = "image/png"), new Promise((function (o, a) { PA(e, t, i, (function (e) { void 0 !== e ? o(e) : a(new Error("Data is undefined")) }), r, void 0, n) })) } function MA(e, t, i, r, n, o) { return void 0 === n && (n = "image/png"), new Promise((function (a) { PA(e, t, { width: i, height: r }, (function () { a() }), n, !0, o) })) } function OA(e, t, i, r, n, o, s, l, c, u, h, d) { 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 p = NA(e, t, i), f = p.height, _ = p.width, m = p.finalWidth, g = p.finalHeight, v = { width: _, height: f }; if (f && _) { var y = { width: e.getRenderWidth(), height: e.getRenderHeight() }; e.setSize(_, f); var b = t.getScene(), T = new es("screenShot", v, b, !1, !1, a.TEXTURETYPE_UNSIGNED_INT, !1, vo.BILINEAR_SAMPLINGMODE, void 0, u, void 0, void 0, void 0, o); T.renderList = b.meshes.slice(), T.samples = o, T.renderSprites = c, T.activeCamera = t, T.forceLayerMaskCheck = h; var E = function () { e.onEndFrameObservable.addOnce((function () { m === _ && g === f ? T.readPixels(void 0, void 0, void 0, !1).then((function (e) { $a.DumpData(_, f, e, r, n, l, !0, void 0, d), T.dispose() })) : ad("pass", T.getInternalTexture(), b, void 0, void 0, void 0, m, g).then((function (t) { e._readTexturePixels(t, m, g, -1, 0, null, !0, !1, 0, 0).then((function (e) { $a.DumpData(m, g, e, r, n, l, !0, void 0, d), t.dispose() })) })) })), b.incrementRenderId(), b.resetCachedMaterial(), T.render(!0), b.incrementRenderId(), b.resetCachedMaterial(), e.setSize(y.width, y.height), t.getProjectionMatrix(!0), b.render() }; if (s) { var S = new US("antialiasing", 1, b.activeCamera); T.addPostProcess(S), S.getEffect().isReady() ? E() : S.getEffect().onCompiled = function () { E() } } else E() } else $.Error("Invalid 'size' parameter !") } function DA(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) { OA(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 NA(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 FA, LA = { CreateScreenshot: PA, CreateScreenshotAsync: IA, CreateScreenshotWithResizeAsync: MA, CreateScreenshotUsingRenderTarget: OA, CreateScreenshotUsingRenderTargetAsync: DA }; xi.CreateScreenshot = PA, xi.CreateScreenshotAsync = IA, xi.CreateScreenshotUsingRenderTarget = OA, xi.CreateScreenshotUsingRenderTargetAsync = DA, 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" }(FA || (FA = {})); var wA, BA = 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 ft(this.readUint8Array(e)) }, e.prototype.skipBytes = function (e) { this._dataByteOffset += e, this.byteOffset += e }, e }(), UA = 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 }(), VA = function () { function e() { this._trackedScene = null } return e.prototype.track = function (e) { this._trackedScene = e, Ue.AllowLoadingUniqueId = !0, this._savedJSON = AA.Serialize(e), Ue.AllowLoadingUniqueId = !1 }, e.prototype.getDelta = function () { if (!this._trackedScene) return null; var e = vo.ForceSerializeBuffers; vo.ForceSerializeBuffers = !1, Ue.AllowLoadingUniqueId = !0; var t = AA.Serialize(this._trackedScene); Ue.AllowLoadingUniqueId = !1; var i = {}; for (var r in t) this._compareCollections(r, this._savedJSON[r], t[r], i); return vo.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; n < t.length; n++)if (t[n] !== i[n]) return r[e] = i, !1; return !0 } var o = [], a = function (n) { var a = t[n], l = a.uniqueId; o.push(l); var c = i.filter((function (e) { return e.uniqueId === l })); if (c.length) { var u = c[0], h = {}; s._compareObjects(a, u, h) || (r[e] || (r[e] = []), h.__state = { id: u.id || u.name }, r[e].push(h)) } else h = { __state: { deleteId: a.id || a.name } }, r[e] || (r[e] = []), r[e].push(h) }, s = this; for (n = 0; n < t.length; n++)a(n); for (n = 0; n < i.length; n++) { var l = i[n], c = l.uniqueId; -1 === o.indexOf(c) && (r[e] || (r[e] = []), r[e].push(l)) } return !0 }, e.prototype._compareObjects = function (e, t, i) { var r = !1; for (var n in e) if (Object.prototype.hasOwnProperty.call(e, n)) { var o = e[n], a = t[n], s = !1; if (Array.isArray(o)) s = JSON.stringify(o) !== JSON.stringify(a); else if (isNaN(o) && "[object String]" != Object.prototype.toString.call(o)) { if ("object" == typeof o && "object" == typeof a) { var l = {}; this._compareObjects(o, a, l) || (i[n] = l, r = !0) } } else s = o !== a; s && (r = !0, i[n] = a) } return !r }, e.prototype._compareCollections = function (e, t, i, r) { if (t !== i && t && i) if (Array.isArray(t) && Array.isArray(i)) { if (this._compareArray(e, t, i, r)) return } else if ("object" == typeof t && "object" == typeof i) { var n = {}; return void (this._compareObjects(t, i, n) || (r[e] = n)) } }, e.GetShadowGeneratorById = function (e, t) { for (var i = 0, r = e.lights.map((function (e) { return e.getShadowGenerators() })); i < r.length; i++) { var n = r[i]; if (n) for (var o = n.values(), a = o.next(); !0 !== a.done; a = o.next()) { var s = a.value; if (s && s.id === t) return s } } return null }, e.ApplyDelta = function (e, t) { var i = this; "string" == typeof e && (e = JSON.parse(e)); var r = t; for (var n in e) { var o = e[n], a = r[n]; if (Array.isArray(a) || "shadowGenerators" === n) switch (n) { case "cameras": this._ApplyDeltaForEntity(o, t, t.getCameraById.bind(t), (function (e) { return ln.Parse(e, t) })); break; case "lights": this._ApplyDeltaForEntity(o, t, t.getLightById.bind(t), (function (e) { return eo.Parse(e, t) })); break; case "shadowGenerators": this._ApplyDeltaForEntity(o, t, (function (e) { return i.GetShadowGeneratorById(t, e) }), (function (e) { return Xm.Parse(e, t) })); break; case "meshes": this._ApplyDeltaForEntity(o, t, t.getMeshById.bind(t), (function (e) { return Jn.Parse(e, t, "") })); break; case "skeletons": this._ApplyDeltaForEntity(o, t, t.getSkeletonById.bind(t), (function (e) { return xs.Parse(e, t) })); break; case "materials": this._ApplyDeltaForEntity(o, t, t.getMaterialById.bind(t), (function (e) { return Hn.Parse(e, t, "") })); break; case "multiMaterials": this._ApplyDeltaForEntity(o, t, t.getMaterialById.bind(t), (function (e) { return Xn.Parse(e, t, "") })); break; case "transformNodes": this._ApplyDeltaForEntity(o, t, t.getTransformNodeById.bind(t), (function (e) { return On.Parse(e, t, "") })); break; case "particleSystems": this._ApplyDeltaForEntity(o, t, t.getParticleSystemById.bind(t), (function (e) { return gE.Parse(e, t, "") })); break; case "morphTargetManagers": this._ApplyDeltaForEntity(o, t, t.getMorphTargetById.bind(t), (function (e) { return ug.Parse(e, t) })); break; case "postProcesses": this._ApplyDeltaForEntity(o, t, t.getPostProcessByName.bind(t), (function (e) { return Ia.Parse(e, t, "") })) } else isNaN(a) ? a.fromArray && a.fromArray(o) : r[n] = o } }, e._ApplyPropertiesToEntity = function (e, t) { for (var i in e) { var r = e[i], n = t[i]; void 0 !== n && (!isNaN(n) || Array.isArray(n) ? t[i] = r : n.fromArray ? n.fromArray(r) : "object" == typeof n && null !== n && this._ApplyPropertiesToEntity(r, n)) } }, e._ApplyDeltaForEntity = function (e, t, i, r) { for (var n = 0, o = e; n < o.length; n++) { var a = o[n]; if (a.__state && void 0 !== a.__state.id) { var s = i(a.__state.id); s && (this._ApplyPropertiesToEntity(a, s), Ue.ParseProperties(a, s, t, null)) } else if (a.__state && void 0 !== a.__state.deleteId) { var l = i(a.__state.deleteId); null == l || l.dispose() } else r(a) } }, e }(); !function (e) { var t = function () { function e(e, t, i, r) { var n; void 0 === t && (t = null), void 0 === i && (i = null), void 0 === r && (r = null), t = null != t ? t : function () { return 1 }, i = null != i ? i : function () { return 1 }, r = null != r ? r : function (e, t) { return e === t ? 0 : 1 }, this._characterToIdx = new Map, this._insertionCosts = new Array(e.length), this._deletionCosts = new Array(e.length), this._substitutionCosts = new Array(e.length); for (var o = 0; o < e.length; ++o) { n = e[o], this._characterToIdx.set(n, o), this._insertionCosts[o] = t(n), this._deletionCosts[o] = i(n), this._substitutionCosts[o] = new Array(e.length); for (var a = o; a < e.length; ++a)this._substitutionCosts[o][a] = r(n, e[a]) } } return e.prototype.serialize = function () { var e = {}, t = new Array(this._characterToIdx.size); return this._characterToIdx.forEach((function (e, i) { t[e] = i })), e.characters = t, e.insertionCosts = this._insertionCosts, e.deletionCosts = this._deletionCosts, e.substitutionCosts = this._substitutionCosts, JSON.stringify(e) }, e.Deserialize = function (t) { var i = JSON.parse(t), r = new e(i.characters); return r._insertionCosts = i.insertionCosts, r._deletionCosts = i.deletionCosts, r._substitutionCosts = i.substitutionCosts, r }, e.prototype.getCharacterIdx = function (e) { return this._characterToIdx.get(e) }, e.prototype.getInsertionCost = function (e) { return this._insertionCosts[e] }, e.prototype.getDeletionCost = function (e) { return this._deletionCosts[e] }, e.prototype.getSubstitutionCost = function (e, t) { var i = Math.min(e, t), r = Math.max(e, t); return this._substitutionCosts[i][r] }, e }(); e.Alphabet = t; var i = function () { function e(t, i) { var r = this; if (t.length > e._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 < a; ++c)l[c + 1][0] = l[c][0] + r.getInsertionCost(n[c]); for (c = 0; c < s; ++c)l[0][c + 1] = l[0][c] + r.getInsertionCost(o[c]); for (var u = 0; u < a; ++u)for (var h = 0; h < s; ++h)e._InsertionCost = l[u + 1][h] + r.getInsertionCost(o[h]), e._DeletionCost = l[u][h + 1] + r.getDeletionCost(n[u]), e._SubstitutionCost = l[u][h] + r.getSubstitutionCost(n[u], o[h]), l[u + 1][h + 1] = Math.min(e._InsertionCost, e._DeletionCost, e._SubstitutionCost); return l[a][s] }, e._MAX_SEQUENCE_LENGTH = 256, e._CostMatrix = K([], Array(e._MAX_SEQUENCE_LENGTH + 1), !0).map((function () { return new Array(e._MAX_SEQUENCE_LENGTH + 1) })), e }(); e.Sequence = i }(wA || (wA = {})); var kA = function () { function e(e) { void 0 === e && (e = .01), this._points = [], this._segmentLength = e } return e.prototype.serialize = function () { return JSON.stringify(this) }, e.Deserialize = function (t) { var i = JSON.parse(t), r = new e(i._segmentLength); return r._points = i._points.map((function (e) { return new R(e._x, e._y, e._z) })), r }, e.prototype.getLength = function () { return this._points.length * this._segmentLength }, e.prototype.add = function (e) { var t = this, i = this._points.length; if (0 === i) this._points.push(e.clone()); else for (var r = function () { return t._segmentLength / R.Distance(t._points[i - 1], e) }, n = r(); n <= 1; n = r()) { var o = this._points[i - 1].scale(1 - n); e.scaleAndAddToRef(n, o), this._points.push(o), ++i } }, e.prototype.resampleAtTargetResolution = function (t) { var i = new e(this.getLength() / t); return this._points.forEach((function (e) { i.add(e) })), i }, e.prototype.tokenize = function (t) { for (var i = [], r = new R, n = 2; n < this._points.length; ++n)e._TransformSegmentDirToRef(this._points[n - 2], this._points[n - 1], this._points[n], r) && i.push(e._TokenizeSegment(r, t)); return i }, e._TransformSegmentDirToRef = function (t, i, r, n) { return i.subtractToRef(t, e._ForwardDir), e._ForwardDir.normalize(), i.scaleToRef(-1, e._InverseFromVec), e._InverseFromVec.normalize(), !(Math.abs(R.Dot(e._ForwardDir, e._InverseFromVec)) > .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; r < i.length; ++r)e._Score = R.Dot(t, i[r]), e._Score > e._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 }(), GA = 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; c < t; ++c)l.chars[c] = new R(Math.random() - .5, Math.random() - .5, Math.random() - .5), l.chars[c].normalize(); for (c = 0; c < o.length; ++c)l.chars[c].copyFrom(o[c]); for (var u, h = new R, d = new R, p = 0; p < i; ++p) { a = (1 - (u = p / (i - 1))) * r + u * n; var f = function (e) { h.copyFromFloats(0, 0, 0), l.chars.forEach((function (t) { l.chars[e].subtractToRef(t, d), (s = d.lengthSquared()) > 1e-6 && d.scaleAndAddToRef(1 / (d.lengthSquared() * s), h) })), h.scaleInPlace(a), l.chars[e].addInPlace(h), l.chars[e].normalize() }; for (c = o.length; c < l.chars.length; ++c)f(c) } return l }, e.prototype.serialize = function () { return JSON.stringify(this.chars) }, e.Deserialize = function (t) { for (var i = JSON.parse(t), r = new e(i.length), n = 0; n < i.length; ++n)r.chars[n] = new R(i[n]._x, i[n]._y, i[n]._z); return r }, e }(), zA = function () { function e() { this._sequences = [] } return e.prototype.serialize = function () { return JSON.stringify(this._sequences.map((function (e) { return e.serialize() }))) }, e.Deserialize = function (t, i) { var r = new e; return r._sequences = JSON.parse(t).map((function (e) { return wA.Sequence.Deserialize(e, i) })), r }, e.CreateFromTrajectory = function (t, i, r) { return e.CreateFromTokenizationPyramid(e._GetTokenizationPyramid(t, i), r) }, e.CreateFromTokenizationPyramid = function (t, i) { var r = new e; return r._sequences = t.map((function (e) { return new wA.Sequence(e, i) })), r }, e._GetTokenizationPyramid = function (t, i, r) { void 0 === r && (r = e._FINEST_DESCRIPTOR_RESOLUTION); for (var n = [], o = r; o > 4; 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; i < this._sequences.length; ++i)t += Math.pow(2, i) * this._sequences[i].distance(e._sequences[i]); return t }, e._FINEST_DESCRIPTOR_RESOLUTION = 32, e }(), WA = function () { function e(e) { void 0 === e && (e = []), this._descriptors = e, this._centroidIdx = -1, this._averageDistance = 0, this._refreshDescription() } return e.prototype.serialize = function () { var e = {}; return e.descriptors = this._descriptors.map((function (e) { return e.serialize() })), e.centroidIdx = this._centroidIdx, e.averageDistance = this._averageDistance, JSON.stringify(e) }, e.Deserialize = function (t, i) { var r = JSON.parse(t), n = new e; return n._descriptors = r.descriptors.map((function (e) { return zA.Deserialize(e, i) })), n._centroidIdx = r.centroidIdx, n._averageDistance = r.averageDistance, n }, e.prototype.add = function (e) { this._descriptors.push(e), this._refreshDescription() }, e.prototype.getMatchCost = function (e) { return e.distance(this._descriptors[this._centroidIdx]) / this._averageDistance }, e.prototype.getMatchMinimumDistance = function (e) { return Math.min.apply(Math, this._descriptors.map((function (t) { return t.distance(e) }))) }, e.prototype._refreshDescription = function () { var t, i = this; this._centroidIdx = -1; for (var r = this._descriptors.map((function (e) { return t = 0, i._descriptors.forEach((function (i) { t += e.distance(i) })), t })), n = 0; n < r.length; ++n)(this._centroidIdx < 0 || r[n] < r[this._centroidIdx]) && (this._centroidIdx = n); this._averageDistance = 0, this._descriptors.forEach((function (e) { i._averageDistance += e.distance(i._descriptors[i._centroidIdx]) })), this._descriptors.length > 0 && (this._averageDistance = Math.max(this._averageDistance / this._descriptors.length, e._MIN_AVERAGE_DISTANCE)) }, e._MIN_AVERAGE_DISTANCE = 1, e }(), HA = 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 = GA.Deserialize(i.vector3Alphabet), r._levenshteinAlphabet = wA.Alphabet.Deserialize(i.levenshteinAlphabet); for (var n = 0; n < i.nameToDescribedTrajectory.length; n += 2)r._nameToDescribedTrajectory.set(i.nameToDescribedTrajectory[n], WA.Deserialize(i.nameToDescribedTrajectory[n + 1], r._levenshteinAlphabet)); return r }, e.Generate = function () { for (var t = GA.Generate(64, 256, .1, .001, [R.Forward()]), i = new Array(t.chars.length), r = 0; r < i.length; ++r)i[r] = r; var n = new wA.Alphabet(i, (function (e) { return 0 === e ? 0 : 1 }), (function (e) { return 0 === e ? 0 : 1 }), (function (e, i) { return Math.min(1 - R.Dot(t.chars[e], t.chars[i]), 1) })), o = new e; return o._vector3Alphabet = t, o._levenshteinAlphabet = n, o }, e.prototype.addTrajectoryToClassification = function (e, t) { this._nameToDescribedTrajectory.has(t) || this._nameToDescribedTrajectory.set(t, new WA), this._nameToDescribedTrajectory.get(t).add(zA.CreateFromTrajectory(e, this._vector3Alphabet, this._levenshteinAlphabet)) }, e.prototype.deleteClassification = function (e) { return this._nameToDescribedTrajectory.delete(e) }, e.prototype.classifyTrajectory = function (e) { var t = this, i = zA.CreateFromTrajectory(e, this._vector3Alphabet, this._levenshteinAlphabet), r = []; if (this._nameToDescribedTrajectory.forEach((function (e, n) { e.getMatchCost(i) < t._maximumAllowableMatchCost && r.push(n) })), 0 === r.length) return null; for (var n, o = 0, a = this._nameToDescribedTrajectory.get(r[o]).getMatchMinimumDistance(i), s = 0; s < r.length; ++s)(n = this._nameToDescribedTrajectory.get(r[s]).getMatchMinimumDistance(i)) < a && (a = n, o = s); return r[o] }, e }(), XA = function () { function e(t, i, r) { var n = this; this._scene = t, $.Log("[Reflector] Connecting to ws://".concat(i, ":").concat(r)), this._webSocket = new WebSocket("ws://".concat(i, ":").concat(r)), this._webSocket.onmessage = function (t) { var i = t.data; if (i.startsWith(e._SERVER_PREFIX)) { var r = i.substr(e._SERVER_PREFIX.length); return $.Log("[Reflector] Received server message: ".concat(r.substr(0, 64))), void n._handleServerMessage(r) } $.Log("[Reflector] Received client message: ".concat(i.substr(0, 64))), n._handleClientMessage() }, this._webSocket.onclose = function (e) { $.Log("[Reflector] Disconnected ".concat(e.code, " ").concat(e.reason)) } } return e.prototype.close = function () { this._webSocket.close() }, e.prototype._handleServerMessage = function (e) { var t = this; "connected" === e && AA.SerializeAsync(this._scene).then((function (e) { t._webSocket.send("load|".concat(JSON.stringify(e))) })) }, e.prototype._handleClientMessage = function () { }, e._SERVER_PREFIX = "$$", e }(), jA = function () { function e(t) { var i = this; this._observer = null, this._currentState = [], this.onPressureChanged = new u, e.IsAvailable && (this._observer = new PressureObserver((function (e) { i._currentState = e, i.onPressureChanged.notifyObservers(e) }), t)) } return Object.defineProperty(e, "IsAvailable", { get: function () { return "undefined" != typeof PressureObserver && PressureObserver.supportedSources.includes("cpu") }, enumerable: !1, configurable: !0 }), e.prototype.observe = function (e) { var t; try { null === (t = this._observer) || void 0 === t || t.observe(e), this.onPressureChanged.notifyObservers(this._currentState) } catch (e) { } }, e.prototype.unobserve = function (e) { var t; try { null === (t = this._observer) || void 0 === t || t.unobserve(e) } catch (e) { } }, e.prototype.dispose = function () { var e; null === (e = this._observer) || void 0 === e || e.disconnect(), this._observer = null, this.onPressureChanged.clear() }, e }(), YA = function () { function e(e) { this._view = new Float32Array(e), this._itemLength = 0 } return Object.defineProperty(e.prototype, "itemLength", { get: function () { return this._itemLength }, enumerable: !1, configurable: !0 }), e.prototype.at = function (e) { return e < 0 || e >= 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 }(), KA = 1800, QA = "timestamp", qA = "numPoints", ZA = /\r/g, JA = function () { function e(t, i) { var r = this; this._scene = t, this._collectDataAtFrame = function () { var t = at.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; l++)s.push(r.datasets.data.at(o + e.SliceDataOffset + l)); r.datasetObservable.notifyObservers(s) } }, this.datasets = { ids: [], data: new YA(KA), startingIndices: new YA(KA) }, this._strategies = new Map, this._datasetMeta = new Map, this._eventRestoreSet = new Set, this._customEventObservable = new u, this.datasetObservable = new u, this.metadataObservable = new u((function (e) { return e.callback(r._datasetMeta, new l(0)) })), i && this.addCollectionStrategies.apply(this, i) } return Object.defineProperty(e, "SliceDataOffset", { get: function () { return 2 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "NumberOfPointsOffset", { get: function () { return 1 }, enumerable: !1, configurable: !0 }), e.prototype.registerEvent = function (e, t, i) { var r, n = this; if (!this._strategies.has(e) || t) { this._strategies.has(e) && t && (null === (r = this._strategies.get(e)) || void 0 === r || r.dispose(), this._strategies.delete(e)); var o = { name: e }; return this._eventRestoreSet.add(e), this.addCollectionStrategies({ strategyCallback: function (t) { var i = 0, r = 0, o = t.onAfterRenderObservable.add((function () { r = i, i = 0 })), a = n._customEventObservable.add((function (t) { e === t.name && (void 0 !== t.value ? i = t.value : i++) })); return { id: e, getData: function () { return r }, dispose: function () { t.onAfterRenderObservable.remove(o), n._customEventObservable.remove(a) } } }, category: i }), o } }, e.prototype.sendEvent = function (e) { this._customEventObservable.notifyObservers(e) }, e.prototype._restoreStringEvents = function () { var e = this; this._eventRestoreSet.size !== this._customEventObservable.observers.length && this._eventRestoreSet.forEach((function (t) { e.registerEvent(t, !0) })) }, e.prototype.addCollectionStrategies = function () { for (var e = [], t = 0; t < arguments.length; t++)e[t] = arguments[t]; for (var i = 0, r = e; i < r.length; i++) { var n = r[i], o = n.strategyCallback, a = n.category, s = n.hidden, l = o(this._scene); this._strategies.has(l.id) ? l.dispose() : (this.datasets.ids.push(l.id), a && (a = a.replace(new RegExp("@", "g"), "")), this._datasetMeta.set(l.id, { color: this._getHexColorFromId(l.id), category: a, hidden: s }), this._strategies.set(l.id, l)) } this.metadataObservable.notifyObservers(this._datasetMeta) }, e.prototype._getHexColorFromId = function (e) { for (var t = 0, i = 0; i < e.length; i++)t = e.charCodeAt(i) + ((t << 5) - t); var r = "#"; for (i = 0; i < 24; i += 8)r += ("0" + (t >> i & 255).toString(16)).substr(-2); return r }, e.prototype.getCurrentSlice = function () { var e = this, t = [at.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 YA(KA), this.datasets.ids.length = 0, this.datasets.startingIndices = new YA(KA), 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(ZA, "").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 YA(KA), startingIndices: new YA(KA) }, a = r[0], s = r.slice(1); if (a.length < 2 || a[0] !== QA || a[n] !== qA) return !1; for (var l = new Map, c = e.SliceDataOffset; c < a.length; c++) { var u = a[c].split("@"), h = u[0], d = u[1]; o.ids.push(h), l.set(h, d) } for (var p = 0, f = 0, _ = s; f < _.length; f++) { var m = _[f]; if (m.length < 2) return !1; var g = parseFloat(m[0]), v = parseInt(m[n]); if (isNaN(v) || isNaN(g)) return !1; if (o.data.push(g), o.data.push(v), v + e.SliceDataOffset !== m.length) return !1; for (c = e.SliceDataOffset; c < m.length; c++) { var y = parseFloat(m[c]); if (isNaN(y)) return !1; o.data.push(y) } o.startingIndices.push(p), p += m.length } if (this.datasets.ids = o.ids, this.datasets.data = o.data, this.datasets.startingIndices = o.startingIndices, i || this._datasetMeta.clear(), this._strategies.forEach((function (e) { return e.dispose() })), this._strategies.clear(), !i) for (var b = 0, T = this.datasets.ids; b < T.length; b++)h = T[b], d = l.get(h), this._datasetMeta.set(h, { category: d, color: this._getHexColorFromId(h) }); return this.metadataObservable.notifyObservers(this._datasetMeta), this._hasLoadedData = !0, !0 }, e.prototype.exportDataToCsv = function () { var t = ""; t += "".concat(QA, ",").concat(qA); for (var i = 0; i < this.datasets.ids.length; i++)if (t += ",".concat(this.datasets.ids[i]), this._datasetMeta) { var r = this._datasetMeta.get(this.datasets.ids[i]); (null == r ? void 0 : r.category) && (t += "".concat("@").concat(r.category)) } for (t += "\n", i = 0; i < this.datasets.startingIndices.itemLength; i++) { var n = this.datasets.startingIndices.at(i), o = this.datasets.data.at(n), a = this.datasets.data.at(n + e.NumberOfPointsOffset); t += "".concat(o, ",").concat(a); for (var s = 0; s < a; s++)t += ",".concat(this.datasets.data.at(n + e.SliceDataOffset + s)); for (var l = 0; l < this.datasets.ids.length - a; l++)t += ","; t += "\n" } var c = "".concat((new Date).toISOString(), "-perfdata.csv"); xi.Download(new Blob([t], { type: "text/csv" }), c) }, e.prototype.start = function (e) { e ? void 0 === this._startingTimestamp && (this._startingTimestamp = at.Now) : (this.datasets.data = new YA(KA), this.datasets.startingIndices = new YA(KA), this._startingTimestamp = at.Now), this._scene.onAfterRenderObservable.add(this._collectDataAtFrame), this._restoreStringEvents(), this._isStarted = !0 }, e.prototype.stop = function () { this._scene.onAfterRenderObservable.removeCallback(this._collectDataAtFrame), this._isStarted = !1 }, Object.defineProperty(e.prototype, "isStarted", { get: function () { return this._isStarted }, enumerable: !1, configurable: !0 }), e.prototype.dispose = function () { this._scene.onAfterRenderObservable.removeCallback(this._collectDataAtFrame), this._datasetMeta.clear(), this._strategies.forEach((function (e) { e.dispose() })), this.datasetObservable.clear(), this.metadataObservable.clear(), this._isStarted = !1, this.datasets = null }, e }(), $A = function () { }, eR = function () { function e() { } return e.FpsStrategy = function () { return function (e) { var t = e.getEngine(); return { id: "FPS", getData: function () { return t.getFps() }, dispose: $A } } }, e.ThermalStrategy = function () { return this._PressureStrategy("Thermal utilization", "thermal") }, e.PowerSupplyStrategy = function () { return this._PressureStrategy("Power supply utilization", "power-supply") }, e.PressureStrategy = function () { return this._PressureStrategy("Pressure") }, e._PressureStrategy = function (e, t) { return void 0 === t && (t = null), function () { var i = 0, r = new jA; return r.observe("cpu"), r.onPressureChanged.add((function (e) { for (var r = 0, n = e; r < n.length; r++) { var o = n[r]; if (t && o.factors.includes(t) || !t && 0 === o.factors.length) switch (o.state) { case "nominal": i = 0; break; case "fair": i = .25; break; case "serious": i = .5; break; case "critical": i = 1 } } })), { id: e, getData: function () { return i }, dispose: function () { return r.dispose() } } } }, e.TotalMeshesStrategy = function () { return function (e) { return { id: "Total meshes", getData: function () { return e.meshes.length }, dispose: $A } } }, e.ActiveMeshesStrategy = function () { return function (e) { return { id: "Active meshes", getData: function () { return e.getActiveMeshes().length }, dispose: $A } } }, e.ActiveIndicesStrategy = function () { return function (e) { return { id: "Active indices", getData: function () { return e.getActiveIndices() }, dispose: $A } } }, e.ActiveFacesStrategy = function () { return function (e) { return { id: "Active faces", getData: function () { return e.getActiveIndices() / 3 }, dispose: $A } } }, e.ActiveBonesStrategy = function () { return function (e) { return { id: "Active bones", getData: function () { return e.getActiveBones() }, dispose: $A } } }, e.ActiveParticlesStrategy = function () { return function (e) { return { id: "Active particles", getData: function () { return e.getActiveParticles() }, dispose: $A } } }, e.DrawCallsStrategy = function () { return function (e) { var t = 0, i = e.onBeforeAnimationsObservable.add((function () { e.getEngine()._drawCalls.fetchNewFrame() })), r = e.onAfterRenderObservable.add((function () { t = e.getEngine()._drawCalls.current })); return { id: "Draw calls", getData: function () { return t }, dispose: function () { e.onBeforeAnimationsObservable.remove(i), e.onAfterRenderObservable.remove(r) } } } }, e.TotalLightsStrategy = function () { return function (e) { return { id: "Total lights", getData: function () { return e.lights.length }, dispose: $A } } }, e.TotalVerticesStrategy = function () { return function (e) { return { id: "Total vertices", getData: function () { return e.getTotalVertices() }, dispose: $A } } }, e.TotalMaterialsStrategy = function () { return function (e) { return { id: "Total materials", getData: function () { return e.materials.length }, dispose: $A } } }, e.TotalTexturesStrategy = function () { return function (e) { return { id: "Total textures", getData: function () { return e.textures.length }, dispose: $A } } }, e.AbsoluteFpsStrategy = function () { return function (e) { var t = new Fm(e); return t.captureFrameTime = !0, { id: "Absolute FPS", getData: function () { return 1e3 / t.frameTimeCounter.lastSecAverage }, dispose: $A } } }, e.MeshesSelectionStrategy = function () { return function (e) { var t = at.Now, i = 0, r = e.onBeforeActiveMeshesEvaluationObservable.add((function () { t = at.Now })), n = e.onAfterActiveMeshesEvaluationObservable.add((function () { i = at.Now - t })); return { id: "Meshes Selection", getData: function () { return i }, dispose: function () { e.onBeforeActiveMeshesEvaluationObservable.remove(r), e.onAfterActiveMeshesEvaluationObservable.remove(n) } } } }, e.RenderTargetsStrategy = function () { return function (e) { var t = at.Now, i = 0, r = e.onBeforeRenderTargetsRenderObservable.add((function () { t = at.Now })), n = e.onAfterRenderTargetsRenderObservable.add((function () { i = at.Now - t })); return { id: "Render Targets", getData: function () { return i }, dispose: function () { e.onBeforeRenderTargetsRenderObservable.remove(r), e.onAfterRenderTargetsRenderObservable.remove(n) } } } }, e.ParticlesStrategy = function () { return function (e) { var t = at.Now, i = 0, r = e.onBeforeParticlesRenderingObservable.add((function () { t = at.Now })), n = e.onAfterParticlesRenderingObservable.add((function () { i = at.Now - t })); return { id: "Particles", getData: function () { return i }, dispose: function () { e.onBeforeParticlesRenderingObservable.remove(r), e.onAfterParticlesRenderingObservable.remove(n) } } } }, e.SpritesStrategy = function () { return function (e) { var t, i, r = at.Now, n = 0, o = null === (t = e.onBeforeSpritesRenderingObservable) || void 0 === t ? void 0 : t.add((function () { r = at.Now })), a = null === (i = e.onAfterSpritesRenderingObservable) || void 0 === i ? void 0 : i.add((function () { n = at.Now - r })); return { id: "Sprites", getData: function () { return n }, dispose: function () { var t, i; null === (t = e.onBeforeSpritesRenderingObservable) || void 0 === t || t.remove(o), null === (i = e.onAfterSpritesRenderingObservable) || void 0 === i || i.remove(a) } } } }, e.AnimationsStrategy = function () { return function (e) { var t = at.Now, i = 0, r = e.onBeforeAnimationsObservable.add((function () { t = at.Now })), n = e.onAfterAnimationsObservable.add((function () { i = at.Now - t })); return { id: "Animations", getData: function () { return i }, dispose: function () { e.onBeforeAnimationsObservable.remove(r), e.onAfterAnimationsObservable.remove(n) } } } }, e.PhysicsStrategy = function () { return function (e) { var t, i, r = at.Now, n = 0, o = null === (t = e.onBeforePhysicsObservable) || void 0 === t ? void 0 : t.add((function () { r = at.Now })), a = null === (i = e.onAfterPhysicsObservable) || void 0 === i ? void 0 : i.add((function () { n = at.Now - r })); return { id: "Physics", getData: function () { return n }, dispose: function () { var t, i; null === (t = e.onBeforePhysicsObservable) || void 0 === t || t.remove(o), null === (i = e.onAfterPhysicsObservable) || void 0 === i || i.remove(a) } } } }, e.RenderStrategy = function () { return function (e) { var t = at.Now, i = 0, r = e.onBeforeDrawPhaseObservable.add((function () { t = at.Now })), n = e.onAfterDrawPhaseObservable.add((function () { i = at.Now - t })); return { id: "Render", getData: function () { return i }, dispose: function () { e.onBeforeDrawPhaseObservable.remove(r), e.onAfterDrawPhaseObservable.remove(n) } } } }, e.FrameTotalStrategy = function () { return function (e) { var t = at.Now, i = 0, r = e.onBeforeAnimationsObservable.add((function () { t = at.Now })), n = e.onAfterRenderObservable.add((function () { i = at.Now - t })); return { id: "Frame Total", getData: function () { return i }, dispose: function () { e.onBeforeAnimationsObservable.remove(r), e.onAfterRenderObservable.remove(n) } } } }, e.InterFrameStrategy = function () { return function (e) { var t = at.Now, i = 0, r = e.onBeforeAnimationsObservable.add((function () { i = at.Now - t })), n = e.onAfterRenderObservable.add((function () { t = at.Now })); return { id: "Inter-frame", getData: function () { return i }, dispose: function () { e.onBeforeAnimationsObservable.remove(r), e.onAfterRenderObservable.remove(n) } } } }, e.GpuFrameTimeStrategy = function () { return function (e) { var t = new Nm(e.getEngine()); return t.captureGPUFrameTime = !0, { id: "GPU frame time", getData: function () { return Math.max(1e-6 * t.gpuFrameTimeCounter.current, 0) }, dispose: function () { t.dispose() } } } }, e }(); Sr.prototype.getPerfCollector = function () { return this._perfCollector || (this._perfCollector = new JA(this)), this._perfCollector }, u.prototype.runCoroutineAsync = function (e) { if (!this._coroutineScheduler) { var t = function (e) { var t = new Array, i = new Array, r = new Array, n = e.add((function () { for (var e = t.length, n = 0; n < e; n++)$r(t.shift(), i.shift(), r.shift()) })); return { scheduler: function (e, n, o) { t.push(e), i.push(n), r.push(o) }, dispose: function () { e.remove(n) } } }(this); this._coroutineScheduler = t.scheduler, this._coroutineSchedulerDispose = t.dispose } return nn(e, this._coroutineScheduler) }, u.prototype.cancelAllCoroutines = function () { this._coroutineSchedulerDispose && this._coroutineSchedulerDispose(), this._coroutineScheduler = void 0, this._coroutineSchedulerDispose = void 0 }; var tR = function (e) { function t(i, r) { void 0 === r && (r = {}); var n = e.call(this, i) || this; return n.options = r, n._direction = new R(0, 0, -1), n._mat = new I, n._onSelectEnabled = !1, n._origin = new R(0, 0, 0), n.lastNativeXRHitResults = [], n.onHitTestResultObservable = new u, n._onHitTestResults = function (e) { var t = e.map((function (e) { var t = I.FromArray(e.hitMatrix); return n._xrSessionManager.scene.useRightHandedSystem || t.toggleModelMatrixHandInPlace(), n.options.worldParentNode && t.multiplyToRef(n.options.worldParentNode.getWorldMatrix(), t), { xrHitResult: e, transformationMatrix: t } })); n.lastNativeXRHitResults = e, n.onHitTestResultObservable.notifyObservers(t) }, n._onSelect = function (e) { n._onSelectEnabled && t.XRHitTestWithSelectEvent(e, n._xrSessionManager.referenceSpace) }, n.xrNativeFeatureName = "hit-test", xi.Warn("A newer version of this plugin is available"), n } return W(t, e), t.XRHitTestWithRay = function (e, t, i, r) { return e.requestHitTest(t, i).then((function (e) { var t = r || function (e) { return !!e.hitMatrix }; return e.filter(t) })) }, t.XRHitTestWithSelectEvent = function (e, t) { var i = e.frame.getPose(e.inputSource.targetRaySpace, t); if (!i) return Promise.resolve([]); var r = new XRRay(i.transform); return this.XRHitTestWithRay(e.frame.session, r, t) }, t.prototype.attach = function () { return !!e.prototype.attach.call(this) && (this.options.testOnPointerDownOnly && this._xrSessionManager.session.addEventListener("select", this._onSelect, !1), !0) }, t.prototype.detach = function () { return !!e.prototype.detach.call(this) && (this._onSelectEnabled = !1, this._xrSessionManager.session.removeEventListener("select", this._onSelect), !0) }, t.prototype.dispose = function () { e.prototype.dispose.call(this), this.onHitTestResultObservable.clear() }, t.prototype._onXRFrame = function (e) { if (this.attached && !this.options.testOnPointerDownOnly) { var i = e.getViewerPose(this._xrSessionManager.referenceSpace); if (i) { I.FromArrayToRef(i.transform.matrix, 0, this._mat), R.TransformCoordinatesFromFloatsToRef(0, 0, 0, this._mat, this._origin), R.TransformCoordinatesFromFloatsToRef(0, 0, -1, this._mat, this._direction), this._direction.subtractInPlace(this._origin), this._direction.normalize(); var r = new XRRay({ x: this._origin.x, y: this._origin.y, z: this._origin.z, w: 0 }, { x: this._direction.x, y: this._direction.y, z: this._direction.z, w: 0 }); t.XRHitTestWithRay(this._xrSessionManager.session, r, this._xrSessionManager.referenceSpace).then(this._onHitTestResults) } } }, t.Name = zo.HIT_TEST, t.Version = 1, t }(Ho); Wo.AddWebXRFeature(tR.Name, (function (e, t) { return function () { return new tR(e, t) } }), tR.Version, !1); var iR = 0, rR = function (e) { function t(t, i) { void 0 === i && (i = {}); var r = e.call(this, t) || this; return r._options = i, r._lastFrameDetected = new Set, r._trackedAnchors = [], r._futureAnchors = [], r.onAnchorAddedObservable = new u, r.onAnchorRemovedObservable = new u, r.onAnchorUpdatedObservable = new u, r._tmpVector = new R, r._tmpQuaternion = new P, r.xrNativeFeatureName = "anchors", r } return W(t, e), Object.defineProperty(t.prototype, "referenceSpaceForFrameAnchors", { set: function (e) { this._referenceSpaceForFrameAnchors = e }, enumerable: !1, configurable: !0 }), t.prototype._populateTmpTransformation = function (e, t) { return this._tmpVector.copyFrom(e), this._tmpQuaternion.copyFrom(t), this._xrSessionManager.scene.useRightHandedSystem || (this._tmpVector.z *= -1, this._tmpQuaternion.z *= -1, this._tmpQuaternion.w *= -1), { position: this._tmpVector, rotationQuaternion: this._tmpQuaternion } }, t.prototype.addAnchorPointUsingHitTestResultAsync = function (e, t, i) { return void 0 === t && (t = new R), void 0 === i && (i = new P), j(this, void 0, void 0, (function () { var r, n, o, a = this; return Y(this, (function (s) { switch (s.label) { case 0: if (this._populateTmpTransformation(t, i), r = new XRRigidTransform({ x: this._tmpVector.x, y: this._tmpVector.y, z: this._tmpVector.z }, { x: this._tmpQuaternion.x, y: this._tmpQuaternion.y, z: this._tmpQuaternion.z, w: this._tmpQuaternion.w }), e.xrHitResult.createAnchor) return [3, 1]; throw this.detach(), new Error("Anchors not enabled in this environment/browser"); case 1: return s.trys.push([1, 3, , 4]), [4, e.xrHitResult.createAnchor(r)]; case 2: return n = s.sent(), [2, new Promise((function (e, t) { a._futureAnchors.push({ nativeAnchor: n, resolved: !1, submitted: !0, xrTransformation: r, resolve: e, reject: t }) }))]; case 3: throw o = s.sent(), new Error(o); case 4: return [2] } })) })) }, t.prototype.addAnchorAtPositionAndRotationAsync = function (e, t, i) { return void 0 === t && (t = new P), void 0 === i && (i = !1), j(this, void 0, void 0, (function () { var r, n, o, a = this; return Y(this, (function (s) { switch (s.label) { case 0: return this._populateTmpTransformation(e, t), r = new XRRigidTransform({ x: this._tmpVector.x, y: this._tmpVector.y, z: this._tmpVector.z }, { x: this._tmpQuaternion.x, y: this._tmpQuaternion.y, z: this._tmpQuaternion.z, w: this._tmpQuaternion.w }), i && this.attached && this._xrSessionManager.currentFrame ? [4, this._createAnchorAtTransformation(r, this._xrSessionManager.currentFrame)] : [3, 2]; case 1: return o = s.sent(), [3, 3]; case 2: o = void 0, s.label = 3; case 3: return n = o, [2, new Promise((function (e, t) { a._futureAnchors.push({ nativeAnchor: n, resolved: !1, submitted: !1, xrTransformation: r, resolve: e, reject: t }) }))] } })) })) }, Object.defineProperty(t.prototype, "anchors", { get: function () { return this._trackedAnchors }, enumerable: !1, configurable: !0 }), t.prototype.detach = function () { if (!e.prototype.detach.call(this)) return !1; if (!this._options.doNotRemoveAnchorsOnSessionEnded) for (; this._trackedAnchors.length;) { var t = this._trackedAnchors.pop(); if (t) { try { t.remove() } catch (e) { } this.onAnchorRemovedObservable.notifyObservers(t) } } return !0 }, t.prototype.dispose = function () { this._futureAnchors.length = 0, e.prototype.dispose.call(this), this.onAnchorAddedObservable.clear(), this.onAnchorRemovedObservable.clear(), this.onAnchorUpdatedObservable.clear() }, t.prototype._onXRFrame = function (e) { var t = this; if (this.attached && e) { var i = e.trackedAnchors; if (i) { var r = this._trackedAnchors.filter((function (e) { return !i.has(e.xrAnchor) })).map((function (e) { return t._trackedAnchors.indexOf(e) })), n = 0; r.forEach((function (e) { var i = t._trackedAnchors.splice(e - n, 1)[0]; t.onAnchorRemovedObservable.notifyObservers(i), n++ })), i.forEach((function (i) { if (t._lastFrameDetected.has(i)) { var r = t._findIndexInAnchorArray(i); o = t._trackedAnchors[r]; try { t._updateAnchorWithXRFrame(i, o, e), o.attachedNode && (o.attachedNode.rotationQuaternion = o.attachedNode.rotationQuaternion || new P, o.transformationMatrix.decompose(o.attachedNode.scaling, o.attachedNode.rotationQuaternion, o.attachedNode.position)), t.onAnchorUpdatedObservable.notifyObservers(o) } catch (e) { xi.Warn("Anchor could not be updated") } } else { var n = { id: iR++, xrAnchor: i, remove: function () { return i.delete() } }, o = t._updateAnchorWithXRFrame(i, n, e); t._trackedAnchors.push(o), t.onAnchorAddedObservable.notifyObservers(o); var a = t._futureAnchors.filter((function (e) { return e.nativeAnchor === i }))[0]; a && (a.resolve(o), a.resolved = !0) } })), this._lastFrameDetected = i } this._futureAnchors.forEach((function (i) { i.resolved || i.submitted || (t._createAnchorAtTransformation(i.xrTransformation, e).then((function (e) { i.nativeAnchor = e }), (function (e) { i.resolved = !0, i.reject(e) })), i.submitted = !0) })) } }, t.prototype._findIndexInAnchorArray = function (e) { for (var t = 0; t < this._trackedAnchors.length; ++t)if (this._trackedAnchors[t].xrAnchor === e) return t; return -1 }, t.prototype._updateAnchorWithXRFrame = function (e, t, i) { var r = i.getPose(e.anchorSpace, this._xrSessionManager.referenceSpace); if (r) { var n = t.transformationMatrix || new I; I.FromArrayToRef(r.transform.matrix, 0, n), this._xrSessionManager.scene.useRightHandedSystem || n.toggleModelMatrixHandInPlace(), t.transformationMatrix = n, this._options.worldParentNode && n.multiplyToRef(this._options.worldParentNode.getWorldMatrix(), n) } return t }, t.prototype._createAnchorAtTransformation = function (e, t) { var i; return j(this, void 0, void 0, (function () { return Y(this, (function (r) { if (!t.createAnchor) throw this.detach(), new Error("Anchors are not enabled in your browser"); try { return [2, t.createAnchor(e, null !== (i = this._referenceSpaceForFrameAnchors) && void 0 !== i ? i : this._xrSessionManager.referenceSpace)] } catch (e) { throw new Error(e) } return [2] })) })) }, t.Name = zo.ANCHOR_SYSTEM, t.Version = 1, t }(Ho); Wo.AddWebXRFeature(rR.Name, (function (e, t) { return function () { return new rR(e, t) } }), rR.Version); var nR = 0, oR = function (e) { function t(t, i) { void 0 === i && (i = {}); var r = e.call(this, t) || this; return r._options = i, r._detectedPlanes = [], r._enabled = !1, r._lastFrameDetected = new Set, r.onPlaneAddedObservable = new u, r.onPlaneRemovedObservable = new u, r.onPlaneUpdatedObservable = new u, r.xrNativeFeatureName = "plane-detection", r._xrSessionManager.session ? r._init() : r._xrSessionManager.onXRSessionInit.addOnce((function () { r._init() })), r } return W(t, e), t.prototype.detach = function () { if (!e.prototype.detach.call(this)) return !1; if (!this._options.doNotRemovePlanesOnSessionEnded) for (; this._detectedPlanes.length;) { var t = this._detectedPlanes.pop(); t && this.onPlaneRemovedObservable.notifyObservers(t) } return !0 }, t.prototype.dispose = function () { e.prototype.dispose.call(this), this.onPlaneAddedObservable.clear(), this.onPlaneRemovedObservable.clear(), this.onPlaneUpdatedObservable.clear() }, t.prototype.isCompatible = function () { return "undefined" != typeof XRPlane }, t.prototype._onXRFrame = function (e) { var t, i = this; if (this.attached && this._enabled && e) { var r = e.detectedPlanes || (null === (t = e.worldInformation) || void 0 === t ? void 0 : t.detectedPlanes); if (r) { for (var n = 0; n < this._detectedPlanes.length; n++) { var o = this._detectedPlanes[n]; r.has(o.xrPlane) || (this._detectedPlanes.splice(n--, 1), this.onPlaneRemovedObservable.notifyObservers(o)) } r.forEach((function (t) { if (i._lastFrameDetected.has(t)) { if (t.lastChangedTime === i._xrSessionManager.currentTimestamp) { var r = i._findIndexInPlaneArray(t); o = i._detectedPlanes[r], i._updatePlaneWithXRPlane(t, o, e), i.onPlaneUpdatedObservable.notifyObservers(o) } } else { var n = { id: nR++, xrPlane: t, polygonDefinition: [] }, o = i._updatePlaneWithXRPlane(t, n, e); i._detectedPlanes.push(o), i.onPlaneAddedObservable.notifyObservers(o) } })), this._lastFrameDetected = r } } }, t.prototype._init = function () { var e = this, t = function () { e._enabled = !0, e._detectedPlanes.length && (e._detectedPlanes.length = 0) }; this._xrSessionManager.isNative && this._options.preferredDetectorOptions && this._xrSessionManager.session.trySetPreferredPlaneDetectorOptions && this._xrSessionManager.session.trySetPreferredPlaneDetectorOptions(this._options.preferredDetectorOptions), this._xrSessionManager.session.updateWorldTrackingState ? (this._xrSessionManager.session.updateWorldTrackingState({ planeDetectionState: { enabled: !0 } }), t()) : t() }, t.prototype._updatePlaneWithXRPlane = function (e, t, i) { var r = this; t.polygonDefinition = e.polygon.map((function (e) { var t = r._xrSessionManager.scene.useRightHandedSystem ? 1 : -1; return new R(e.x, e.y, e.z * t) })); var n = i.getPose(e.planeSpace, this._xrSessionManager.referenceSpace); if (n) { var o = t.transformationMatrix || new I; I.FromArrayToRef(n.transform.matrix, 0, o), this._xrSessionManager.scene.useRightHandedSystem || o.toggleModelMatrixHandInPlace(), t.transformationMatrix = o, this._options.worldParentNode && o.multiplyToRef(this._options.worldParentNode.getWorldMatrix(), o) } return t }, t.prototype._findIndexInPlaneArray = function (e) { for (var t = 0; t < this._detectedPlanes.length; ++t)if (this._detectedPlanes[t].xrPlane === e) return t; return -1 }, t.Name = zo.PLANE_DETECTION, t.Version = 1, t }(Ho); Wo.AddWebXRFeature(oR.Name, (function (e, t) { return function () { return new oR(e, t) } }), oR.Version); var aR = function (e) { function t(t, i) { void 0 === i && (i = {}); var r = e.call(this, t) || this; return r.options = i, r.onBackgroundStateChangedObservable = new u, r } return W(t, e), t.prototype.attach = function () { return this._setBackgroundState(!1), e.prototype.attach.call(this) }, t.prototype.detach = function () { return this._setBackgroundState(!0), e.prototype.detach.call(this) }, t.prototype.dispose = function () { e.prototype.dispose.call(this), this.onBackgroundStateChangedObservable.clear() }, t.prototype._onXRFrame = function (e) { }, t.prototype._setBackgroundState = function (e) { var t = this._xrSessionManager.scene; if (!this.options.ignoreEnvironmentHelper) if (this.options.environmentHelperRemovalFlags) { if (this.options.environmentHelperRemovalFlags.skyBox) { var i = t.getMeshByName("BackgroundSkybox"); i && i.setEnabled(e) } if (this.options.environmentHelperRemovalFlags.ground) { var r = t.getMeshByName("BackgroundPlane"); r && r.setEnabled(e) } } else { var n = t.getMeshByName("BackgroundHelper"); n && n.setEnabled(e) } this.options.backgroundMeshes && this.options.backgroundMeshes.forEach((function (t) { return t.setEnabled(e) })), this.onBackgroundStateChangedObservable.notifyObservers(e) }, t.Name = zo.BACKGROUND_REMOVER, t.Version = 1, t }(Ho); Wo.AddWebXRFeature(aR.Name, (function (e, t) { return function () { return new aR(e, t) } }), aR.Version, !0); var sR = function () { }, lR = function (e) { function t(t, i) { var r = e.call(this, t) || this; return r._options = i, r._attachController = function (e) { r._controllers[e.uniqueId] || (r._xrSessionManager.scene.isPhysicsEnabled() || $.Warn("physics engine not enabled, skipped. Please add this controller manually."), r._options.physicsProperties.useControllerMesh && e.inputSource.gamepad ? e.onMotionControllerInitObservable.addOnce((function (t) { t._doNotLoadControllerMesh ? r._createPhysicsImpostor(e) : t.onModelLoadedObservable.addOnce((function () { var i = new Zo(t.rootMesh, Zo.MeshImpostor, H({ mass: 0 }, r._options.physicsProperties)), n = e.grip || e.pointer; r._controllers[e.uniqueId] = { xrController: e, impostor: i, oldPos: n.position.clone(), oldRotation: n.rotationQuaternion.clone() } })) })) : r._createPhysicsImpostor(e)) }, r._controllers = {}, r._debugMode = !1, r._delta = 0, r._lastTimestamp = 0, r._tmpQuaternion = new P, r._tmpVector = new R, r._options.physicsProperties || (r._options.physicsProperties = {}), r } return W(t, e), t.prototype._createPhysicsImpostor = function (e) { var t = this._options.physicsProperties.impostorType || Zo.SphereImpostor, i = this._options.physicsProperties.impostorSize || .1, r = bu("impostor-mesh-" + e.uniqueId, { diameterX: "number" == typeof i ? i : i.width, diameterY: "number" == typeof i ? i : i.height, diameterZ: "number" == typeof i ? i : i.depth }); r.isVisible = this._debugMode, r.isPickable = !1, r.rotationQuaternion = new P; var n = e.grip || e.pointer; r.position.copyFrom(n.position), r.rotationQuaternion.copyFrom(n.rotationQuaternion); var o = new Zo(r, t, H({ mass: 0 }, this._options.physicsProperties)); this._controllers[e.uniqueId] = { xrController: e, impostor: o, impostorMesh: r } }, t.prototype._enablePhysicsDebug = function () { var e = this; this._debugMode = !0, Object.keys(this._controllers).forEach((function (t) { var i = e._controllers[t]; i.impostorMesh && (i.impostorMesh.isVisible = !0) })) }, t.prototype.addController = function (e) { this._attachController(e) }, t.prototype.attach = function () { var t = this; if (!e.prototype.attach.call(this)) return !1; if (!this._options.xrInput) return !0; if (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) })), this._options.enableHeadsetImpostor) { var i = this._options.headsetImpostorParams || { impostorType: Zo.SphereImpostor, restitution: .8, impostorSize: .3 }, r = i.impostorSize || .3; this._headsetMesh = bu("headset-mesh", { diameterX: "number" == typeof r ? r : r.width, diameterY: "number" == typeof r ? r : r.height, diameterZ: "number" == typeof r ? r : r.depth }), this._headsetMesh.rotationQuaternion = new P, this._headsetMesh.isVisible = !1, this._headsetImpostor = new Zo(this._headsetMesh, i.impostorType, H({ mass: 0 }, i)) } return !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._headsetMesh && this._headsetMesh.dispose(), !0) }, t.prototype.getHeadsetImpostor = function () { return this._headsetImpostor }, t.prototype.getImpostorForController = function (e) { var t = "string" == typeof e ? e : e.uniqueId; return this._controllers[t] ? this._controllers[t].impostor : null }, t.prototype.setPhysicsProperties = function (e) { this._options.physicsProperties = H(H({}, this._options.physicsProperties), e) }, t.prototype._onXRFrame = function (e) { var t, i, r = this; if (this._delta = this._xrSessionManager.currentTimestamp - this._lastTimestamp, this._lastTimestamp = this._xrSessionManager.currentTimestamp, this._headsetMesh && this._headsetImpostor) { if (this._headsetMesh.position.copyFrom(this._options.xrInput.xrCamera.globalPosition), this._headsetMesh.rotationQuaternion.copyFrom(this._options.xrInput.xrCamera.absoluteRotation), null === (t = this._options.xrInput.xrCamera._lastXRViewerPose) || void 0 === t ? void 0 : t.linearVelocity) { var n = this._options.xrInput.xrCamera._lastXRViewerPose.linearVelocity; this._tmpVector.set(n.x, n.y, n.z), this._headsetImpostor.setLinearVelocity(this._tmpVector) } if (null === (i = this._options.xrInput.xrCamera._lastXRViewerPose) || void 0 === i ? void 0 : i.angularVelocity) { var o = this._options.xrInput.xrCamera._lastXRViewerPose.angularVelocity; this._tmpVector.set(o.x, o.y, o.z), this._headsetImpostor.setAngularVelocity(this._tmpVector) } } Object.keys(this._controllers).forEach((function (e) { var t, i, n = r._controllers[e], o = n.xrController.grip || n.xrController.pointer, a = n.oldPos || n.impostorMesh.position; if (null === (t = n.xrController._lastXRPose) || void 0 === t ? void 0 : t.linearVelocity) { var s = n.xrController._lastXRPose.linearVelocity; r._tmpVector.set(s.x, s.y, s.z), n.impostor.setLinearVelocity(r._tmpVector) } else o.position.subtractToRef(a, r._tmpVector), r._tmpVector.scaleInPlace(1e3 / r._delta), n.impostor.setLinearVelocity(r._tmpVector); a.copyFrom(o.position), r._debugMode && console.log(r._tmpVector, "linear"); var l = n.oldRotation || n.impostorMesh.rotationQuaternion; if (null === (i = n.xrController._lastXRPose) || void 0 === i ? void 0 : i.angularVelocity) { var c = n.xrController._lastXRPose.angularVelocity; r._tmpVector.set(c.x, c.y, c.z), n.impostor.setAngularVelocity(r._tmpVector) } else if (!l.equalsWithEpsilon(o.rotationQuaternion)) { l.conjugateInPlace().multiplyToRef(o.rotationQuaternion, r._tmpQuaternion); var u = Math.sqrt(r._tmpQuaternion.x * r._tmpQuaternion.x + r._tmpQuaternion.y * r._tmpQuaternion.y + r._tmpQuaternion.z * r._tmpQuaternion.z); if (r._tmpVector.set(r._tmpQuaternion.x, r._tmpQuaternion.y, r._tmpQuaternion.z), u < .001) r._tmpVector.scaleInPlace(2); else { var h = 2 * Math.atan2(u, r._tmpQuaternion.w); r._tmpVector.scaleInPlace(h / (u * (r._delta / 1e3))) } n.impostor.setAngularVelocity(r._tmpVector) } l.copyFrom(o.rotationQuaternion), r._debugMode && console.log(r._tmpVector, r._tmpQuaternion, "angular") })) }, t.prototype._detachController = function (e) { var t = this._controllers[e]; t && (t.impostorMesh && t.impostorMesh.dispose(), delete this._controllers[e]) }, t.Name = zo.PHYSICS_CONTROLLERS, t.Version = 1, t }(Ho); Wo.AddWebXRFeature(lR.Name, (function (e, t) { return function () { return new lR(e, t) } }), lR.Version, !0); var cR = function (e) { function t(t, i) { void 0 === i && (i = {}); var r = e.call(this, t) || this; return r.options = i, r._tmpMat = new I, r._tmpPos = new R, r._tmpQuat = new P, r._initHitTestSource = function (e) { if (e) { var t = new XRRay(r.options.offsetRay || {}), i = { space: r.options.useReferenceSpace ? e : r._xrSessionManager.viewerReferenceSpace, offsetRay: t }; r.options.entityTypes && (i.entityTypes = r.options.entityTypes), i.space ? r._xrSessionManager.session.requestHitTestSource(i).then((function (e) { r._xrHitTestSource && r._xrHitTestSource.cancel(), r._xrHitTestSource = e })) : xi.Warn("waiting for viewer reference space to initialize") } }, r.autoCloneTransformation = !1, r.onHitTestResultObservable = new u, r.paused = !1, r.xrNativeFeatureName = "hit-test", xi.Warn("Hit test is an experimental and unstable feature."), r } return W(t, e), t.prototype.attach = function () { var t = this; if (!e.prototype.attach.call(this)) return !1; if (!this._xrSessionManager.session.requestHitTestSource) return !1; if (this.options.disablePermanentHitTest || (this._xrSessionManager.referenceSpace && this._initHitTestSource(this._xrSessionManager.referenceSpace), this._xrSessionManager.onXRReferenceSpaceChanged.add(this._initHitTestSource)), this.options.enableTransientHitTest) { var i = new XRRay(this.options.transientOffsetRay || {}); this._xrSessionManager.session.requestHitTestSourceForTransientInput({ profile: this.options.transientHitTestProfile || "generic-touchscreen", offsetRay: i, entityTypes: this.options.entityTypes }).then((function (e) { t._transientXrHitTestSource = e })) } return !0 }, t.prototype.detach = function () { return !!e.prototype.detach.call(this) && (this._xrHitTestSource && (this._xrHitTestSource.cancel(), this._xrHitTestSource = null), this._xrSessionManager.onXRReferenceSpaceChanged.removeCallback(this._initHitTestSource), this._transientXrHitTestSource && (this._transientXrHitTestSource.cancel(), this._transientXrHitTestSource = null), !0) }, t.prototype.dispose = function () { e.prototype.dispose.call(this), this.onHitTestResultObservable.clear() }, t.prototype._onXRFrame = function (e) { var t = this; if (this.attached && !this.paused) { if (this._xrHitTestSource) { var i = e.getHitTestResults(this._xrHitTestSource); this._processWebXRHitTestResult(i) } this._transientXrHitTestSource && e.getHitTestResultsForTransientInput(this._transientXrHitTestSource).forEach((function (e) { t._processWebXRHitTestResult(e.results, e.inputSource) })) } }, t.prototype._processWebXRHitTestResult = function (e, t) { var i = this, r = []; e.forEach((function (e) { var n = e.getPose(i._xrSessionManager.referenceSpace); if (n) { var o = n.transform.position, a = n.transform.orientation; i._tmpPos.set(o.x, o.y, o.z), i._tmpQuat.set(a.x, a.y, a.z, a.w), I.FromFloat32ArrayToRefScaled(n.transform.matrix, 0, 1, i._tmpMat), i._xrSessionManager.scene.useRightHandedSystem || (i._tmpPos.z *= -1, i._tmpQuat.z *= -1, i._tmpQuat.w *= -1, i._tmpMat.toggleModelMatrixHandInPlace()); var s = { position: i.autoCloneTransformation ? i._tmpPos.clone() : i._tmpPos, rotationQuaternion: i.autoCloneTransformation ? i._tmpQuat.clone() : i._tmpQuat, transformationMatrix: i.autoCloneTransformation ? i._tmpMat.clone() : i._tmpMat, inputSource: t, isTransient: !!t, xrHitResult: e }; r.push(s) } })), this.onHitTestResultObservable.notifyObservers(r) }, t.Name = zo.HIT_TEST, t.Version = 2, t }(Ho); Wo.AddWebXRFeature(cR.Name, (function (e, t) { return function () { return new cR(e, t) } }), cR.Version, !1); var uR = function (e) { function t(t) { var i = e.call(this, t) || this; return i._enabled = !1, i._featurePointCloud = [], i.onFeaturePointsAddedObservable = new u, i.onFeaturePointsUpdatedObservable = new u, i.xrNativeFeatureName = "bjsfeature-points", i._xrSessionManager.session ? i._init() : i._xrSessionManager.onXRSessionInit.addOnce((function () { i._init() })), i } return W(t, e), Object.defineProperty(t.prototype, "featurePointCloud", { get: function () { return this._featurePointCloud }, enumerable: !1, configurable: !0 }), t.prototype.detach = function () { return !!e.prototype.detach.call(this) && (this.featurePointCloud.length = 0, !0) }, t.prototype.dispose = function () { e.prototype.dispose.call(this), this._featurePointCloud.length = 0, this.onFeaturePointsUpdatedObservable.clear(), this.onFeaturePointsAddedObservable.clear() }, t.prototype._onXRFrame = function (e) { if (this.attached && this._enabled && e) { var t = e.featurePointCloud; if (t && 0 !== t.length) { if (t.length % 5 != 0) throw new Error("Received malformed feature point cloud of length: " + t.length); for (var i = t.length / 5, r = new Array, n = new Array, o = 0; o < i; o++) { var a = 5 * o, s = t[a + 4]; this._featurePointCloud[s] ? r.push(s) : (this._featurePointCloud[s] = { position: new R, confidenceValue: 0 }, n.push(s)), this._featurePointCloud[s].position.x = t[a], this._featurePointCloud[s].position.y = t[a + 1], this._featurePointCloud[s].position.z = t[a + 2], this._featurePointCloud[s].confidenceValue = t[a + 3] } n.length > 0 && 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 = zo.FEATURE_POINTS, t.Version = 1, t }(Ho); Wo.AddWebXRFeature(uR.Name, (function (e) { return function () { return new uR(e) } }), uR.Version); var hR, dR = 0, pR = 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: dR++, 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; r < e.positions.length; r += 3)t.positions[r] = e.positions[r], t.positions[r + 1] = e.positions[r + 1], t.positions[r + 2] = -1 * e.positions[r + 2]; if (e.normals) for (t.normals = new Float32Array(e.normals.length), r = 0; r < e.normals.length; r += 3)t.normals[r] = e.normals[r], t.normals[r + 1] = e.normals[r + 1], t.normals[r + 2] = -1 * e.normals[r + 2] } t.indices = e.indices; var n = i.getPose(e.meshSpace, this._xrSessionManager.referenceSpace); if (n) { var o = t.transformationMatrix || new I; I.FromArrayToRef(n.transform.matrix, 0, o), this._xrSessionManager.scene.useRightHandedSystem || o.toggleModelMatrixHandInPlace(), t.transformationMatrix = o, this._options.worldParentNode && o.multiplyToRef(this._options.worldParentNode.getWorldMatrix(), o) } } return t }, t.Name = zo.MESH_DETECTION, t.Version = 1, t }(Ho); Wo.AddWebXRFeature(pR.Name, (function (e, t) { return function () { return new pR(e, t) } }), pR.Version, !1), function (e) { e[e.NotReceived = 0] = "NotReceived", e[e.Waiting = 1] = "Waiting", e[e.Received = 2] = "Received" }(hR || (hR = {})); var fR = function (e) { function t(t, i) { var r = e.call(this, t) || this; return r.options = i, r.onUntrackableImageFoundObservable = new u, r.onTrackableImageFoundObservable = new u, r.onTrackedImageUpdatedObservable = new u, r._trackableScoreStatus = hR.NotReceived, r._trackedImages = [], r.xrNativeFeatureName = "image-tracking", r } return W(t, e), t.prototype.attach = function () { return e.prototype.attach.call(this) }, t.prototype.detach = function () { return e.prototype.detach.call(this) }, t.prototype.getTrackedImageById = function (e) { return this._trackedImages[e] || null }, t.prototype.dispose = function () { e.prototype.dispose.call(this), this._trackedImages.forEach((function (e) { e.originalBitmap.close() })), this._trackedImages.length = 0, this.onTrackableImageFoundObservable.clear(), this.onUntrackableImageFoundObservable.clear(), this.onTrackedImageUpdatedObservable.clear() }, t.prototype.getXRSessionInitExtension = function () { return j(this, void 0, void 0, (function () { var e, t, i = this; return Y(this, (function (r) { switch (r.label) { case 0: if (!this.options.images || !this.options.images.length) return [2, {}]; e = this.options.images.map((function (e) { return "string" == typeof e.src ? i._xrSessionManager.scene.getEngine()._createImageBitmapFromSource(e.src) : Promise.resolve(e.src) })), r.label = 1; case 1: return r.trys.push([1, 3, , 4]), [4, Promise.all(e)]; case 2: return t = r.sent(), this._originalTrackingRequest = t.map((function (e, t) { return { image: e, widthInMeters: i.options.images[t].estimatedRealWorldWidth } })), [2, { trackedImages: this._originalTrackingRequest }]; case 3: return r.sent(), xi.Error("Error loading images for tracking, WebXRImageTracking disabled for this session."), [2, {}]; case 4: return [2] } })) })) }, t.prototype._onXRFrame = function (e) { if (e.getImageTrackingResults && this._trackableScoreStatus !== hR.Waiting) if (this._trackableScoreStatus !== hR.NotReceived) for (var t = 0, i = e.getImageTrackingResults(); t < i.length; t++) { var r = i[t], n = !1, o = r.index, a = this._trackedImages[o]; if (a) { a.xrTrackingResult = r, a.realWorldWidth !== r.measuredWidthInMeters && (a.realWorldWidth = r.measuredWidthInMeters, n = !0); var s = e.getPose(r.imageSpace, this._xrSessionManager.referenceSpace); if (s) { var l = a.transformationMatrix; I.FromArrayToRef(s.transform.matrix, 0, l), this._xrSessionManager.scene.useRightHandedSystem || l.toggleModelMatrixHandInPlace(), n = !0 } var c = "emulated" === r.trackingState; a.emulated !== c && (a.emulated = c, n = !0), n && this.onTrackedImageUpdatedObservable.notifyObservers(a) } } else this._checkScoresAsync() }, t.prototype._checkScoresAsync = function () { return j(this, void 0, void 0, (function () { var e, t, i, r; return Y(this, (function (n) { switch (n.label) { case 0: return this._xrSessionManager.session.getTrackedImageScores && this._trackableScoreStatus === hR.NotReceived ? (this._trackableScoreStatus = hR.Waiting, [4, this._xrSessionManager.session.getTrackedImageScores()]) : [2]; case 1: if (!(e = n.sent()) || 0 === e.length) return this._trackableScoreStatus = hR.NotReceived, [2]; for (t = 0; t < e.length; ++t)"untrackable" == e[t] ? this.onUntrackableImageFoundObservable.notifyObservers(t) : (i = this._originalTrackingRequest[t].image, r = { id: t, originalBitmap: i, transformationMatrix: new I, ratio: i.width / i.height }, this._trackedImages[t] = r, this.onTrackableImageFoundObservable.notifyObservers(r)); return this._trackableScoreStatus = e.length > 0 ? hR.Received : hR.NotReceived, [2] } })) })) }, t.Name = zo.IMAGE_TRACKING, t.Version = 1, t }(Ho); Wo.AddWebXRFeature(fR.Name, (function (e, t) { return function () { return new fR(e, t) } }), fR.Version, !1); var _R = 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", xi.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 xi.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 xi.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 = zo.DOM_OVERLAY, t.Version = 1, t }(Ho); Wo.AddWebXRFeature(_R.Name, (function (e, t) { return function () { return new _R(e, t) } }), _R.Version, !1); var mR = 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; n < o.length; n++) { var a = o[n], s = e.motionController.getComponentOfType(a); if (null !== s) { r = s; break } } if (i.mainComponentOnly) { var l = e.motionController.getMainComponent(); if (null === l) return "continue"; r = l } if ("function" == typeof i.componentSelectionPredicate && (r = i.componentSelectionPredicate(e)), r && i.forceHandedness && e.inputSource.handedness !== i.forceHandedness) return "continue"; if (null === r) return "continue"; var c = { registrationConfiguration: i, component: r }; t.registeredComponents.push(c), "axisChangedHandler" in i && (c.onAxisChangedObserver = r.onAxisValueChangedObservable.add((function (e) { i.axisChangedHandler(e, u._movementState, u._featureContext, u._xrInput) }))), "buttonChangedhandler" in i && (c.onButtonChangedObserver = r.onButtonStateChangedObservable.add((function () { r.changes.pressed && i.buttonChangedhandler(r.changes.pressed, u._movementState, u._featureContext, u._xrInput) }))) }, r = 0, n = u._currentRegistrationConfigurations; r < n.length; r++)i(n[r]) }; e.motionController ? i() : e.onMotionControllerInitObservable.addOnce((function () { i() })) } } }, r && void 0 !== r.xrInput ? (Array.isArray(r.customRegistrationConfigurations) ? u._currentRegistrationConfigurations = r.customRegistrationConfigurations : u._currentRegistrationConfigurations = t.REGISTRATIONS.default, u._featureContext = { movementEnabled: r.movementEnabled || !0, movementOrientationFollowsViewerPose: null === (n = r.movementOrientationFollowsViewerPose) || void 0 === n || n, movementSpeed: null !== (o = r.movementSpeed) && void 0 !== o ? o : 1, movementThreshold: null !== (a = r.movementThreshold) && void 0 !== a ? a : .25, rotationEnabled: null === (s = r.rotationEnabled) || void 0 === s || s, rotationSpeed: null !== (l = r.rotationSpeed) && void 0 !== l ? l : 1, rotationThreshold: null !== (c = r.rotationThreshold) && void 0 !== c ? c : .25 }, u._movementState = { moveX: 0, moveY: 0, rotateX: 0, rotateY: 0 }, u._xrInput = r.xrInput, u) : (xi.Error('WebXRControllerMovement feature requires "xrInput" option.'), u) } return W(t, e), Object.defineProperty(t.prototype, "movementDirection", { get: function () { return this._movementDirection }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "movementEnabled", { get: function () { return this._featureContext.movementEnabled }, set: function (e) { this._featureContext.movementEnabled = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "movementOrientationFollowsViewerPose", { get: function () { return this._featureContext.movementOrientationFollowsViewerPose }, set: function (e) { this._featureContext.movementOrientationFollowsViewerPose = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "movementSpeed", { get: function () { return this._featureContext.movementSpeed }, set: function (e) { this._featureContext.movementSpeed = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "movementThreshold", { get: function () { return this._featureContext.movementThreshold }, set: function (e) { this._featureContext.movementThreshold = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rotationEnabled", { get: function () { return this._featureContext.rotationEnabled }, set: function (e) { this._featureContext.rotationEnabled = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rotationSpeed", { get: function () { return this._featureContext.rotationSpeed }, set: function (e) { this._featureContext.rotationSpeed = e }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rotationThreshold", { get: function () { return this._featureContext.rotationThreshold }, set: function (e) { this._featureContext.rotationThreshold = e }, enumerable: !1, configurable: !0 }), t.prototype.attach = function () { var t = this; return !!e.prototype.attach.call(this) && (this._xrInput.controllers.forEach(this._attachController), this._addNewAttachObserver(this._xrInput.onControllerAddedObservable, this._attachController), this._addNewAttachObserver(this._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._controllers = {}, !0) }, t.prototype._onXRFrame = function (e) { if (this.attached) { if (0 !== this._movementState.rotateX && this._featureContext.rotationEnabled) { var t = .001 * this._xrSessionManager.scene.getEngine().getDeltaTime() * this._featureContext.rotationSpeed * this._movementState.rotateX * (this._xrSessionManager.scene.useRightHandedSystem ? -1 : 1); this._featureContext.movementOrientationFollowsViewerPose ? (this._xrInput.xrCamera.cameraRotation.y += t, P.RotationYawPitchRollToRef(t, 0, 0, this._tempCacheQuaternion), this._xrInput.xrCamera.rotationQuaternion.multiplyToRef(this._tempCacheQuaternion, this._movementDirection)) : (P.RotationYawPitchRollToRef(3 * t, 0, 0, this._tempCacheQuaternion), this._movementDirection.multiplyInPlace(this._tempCacheQuaternion)) } else this._featureContext.movementOrientationFollowsViewerPose && this._movementDirection.copyFrom(this._xrInput.xrCamera.rotationQuaternion); (this._movementState.moveX || this._movementState.moveY) && this._featureContext.movementEnabled && (I.FromQuaternionToRef(this._movementDirection, this._tmpRotationMatrix), this._tmpTranslationDirection.set(this._movementState.moveX, 0, this._movementState.moveY * (this._xrSessionManager.scene.useRightHandedSystem ? 1 : -1)), R.TransformCoordinatesToRef(this._tmpTranslationDirection, this._tmpRotationMatrix, this._tmpMovementTranslation), this._tmpMovementTranslation.scaleInPlace(this._xrInput.xrCamera._computeLocalCameraSpeed() * this._featureContext.movementSpeed), this._xrInput.xrCamera.cameraDirection.addInPlace(this._tmpMovementTranslation)) } }, t.prototype._detachController = function (e) { var t = this._controllers[e]; if (t) { for (var i = 0, r = t.registeredComponents; i < r.length; i++) { var n = r[i]; n.onAxisChangedObserver && n.component.onAxisValueChangedObservable.remove(n.onAxisChangedObserver), n.onButtonChangedObserver && n.component.onButtonStateChangedObservable.remove(n.onButtonChangedObserver) } delete this._controllers[e] } }, t.Name = zo.MOVEMENT, t.REGISTRATIONS = { default: [{ allowedComponentTypes: [am.THUMBSTICK_TYPE, am.TOUCHPAD_TYPE], forceHandedness: "left", axisChangedHandler: function (e, t, i) { t.rotateX = Math.abs(e.x) > i.rotationThreshold ? e.x : 0, t.rotateY = Math.abs(e.y) > i.rotationThreshold ? e.y : 0 } }, { allowedComponentTypes: [am.THUMBSTICK_TYPE, am.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 }(Ho); Wo.AddWebXRFeature(mR.Name, (function (e, t) { return function () { return new mR(e, t) } }), mR.Version, !0); var gR = 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 rd, 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 < r.options.cubeMapPollInterval) return; r._cubeMapPollTime = t } var i = r._getXRGLBinding().getReflectionCubeMap(r._xrLightProbe); if (i && r._reflectionCubeMap) { if (r._reflectionCubeMap._texture) null === (e = r._reflectionCubeMap._texture._hardwareTexture) || void 0 === e || e.set(i), r._reflectionCubeMap._texture.getEngine().resetTextureCache(); else { var n = new Ht(r._xrSessionManager.scene.getEngine(), It.Unknown); n.isCube = !0, n.invertY = !1, n._useSRGBBuffer = "srgba8" === r.options.reflectionFormat, n.format = a.TEXTUREFORMAT_RGBA, n.generateMipMaps = !0, n.type = "srgba8" !== r.options.reflectionFormat ? a.TEXTURETYPE_HALF_FLOAT : a.TEXTURETYPE_UNSIGNED_BYTE, n.samplingMode = a.TEXTURE_LINEAR_LINEAR_MIPLINEAR, n.width = r._reflectionCubeMapTextureSize, n.height = r._reflectionCubeMapTextureSize, n._cachedWrapU = a.TEXTURE_WRAP_ADDRESSMODE, n._cachedWrapV = a.TEXTURE_WRAP_ADDRESSMODE, n._hardwareTexture = new Zt(i, r._getCanvasContext()), r._reflectionCubeMap._texture = n } r._reflectionCubeMap._texture.isReady = !0, r._xrSessionManager.scene.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag), r.onReflectionCubeMapUpdatedObservable.notifyObservers(r._reflectionCubeMap) } } }, r.xrNativeFeatureName = "light-estimation", r.options.createDirectionalLightSource && (r.directionalLight = new r_("light estimation directional", r._lightDirection, r._xrSessionManager.scene), r.directionalLight.position = new R(0, 8, 0), r.directionalLight.intensity = 0, r.directionalLight.falloffType = br.FALLOFF_GLTF), xi.Warn("light-estimation is an experimental and unstable feature."), r } return W(t, e), Object.defineProperty(t.prototype, "reflectionCubeMapTexture", { get: function () { return this._reflectionCubeMap }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xrLightingEstimate", { get: function () { return this._xrLightEstimate ? { lightColor: this._lightColor, lightDirection: this._lightDirection, lightIntensity: this._intensity, sphericalHarmonics: this._sphericalHarmonics } : this._xrLightEstimate }, enumerable: !1, configurable: !0 }), t.prototype._getCanvasContext = function () { return null === this._canvasContext && (this._canvasContext = this._xrSessionManager.scene.getEngine()._gl), this._canvasContext }, t.prototype._getXRGLBinding = function () { if (null === this._xrWebGLBinding) { var e = this._getCanvasContext(); this._xrWebGLBinding = new XRWebGLBinding(this._xrSessionManager.session, e) } return this._xrWebGLBinding }, t.prototype.attach = function () { var t, i = this; if (!e.prototype.attach.call(this)) return !1; var r = null !== (t = this.options.reflectionFormat) && void 0 !== t ? t : this._xrSessionManager.session.preferredReflectionFormat || "srgba8"; return this.options.reflectionFormat = r, this._xrSessionManager.session.requestLightProbe({ reflectionFormat: r }).then((function (e) { i._xrLightProbe = e, i.options.disableCubeMapReflection || (i._reflectionCubeMap || (i._reflectionCubeMap = new po(i._xrSessionManager.scene), i._reflectionCubeMap._isCube = !0, i._reflectionCubeMap.coordinatesMode = a.TEXTURE_CUBIC_MODE, i.options.setSceneEnvironmentTexture && (i._xrSessionManager.scene.environmentTexture = i._reflectionCubeMap)), i._xrLightProbe.addEventListener("reflectionchange", i._updateReflectionCubeMap)) })), !0 }, t.prototype.detach = function () { var t = e.prototype.detach.call(this); return null === this._xrLightProbe || this.options.disableCubeMapReflection || (this._xrLightProbe.removeEventListener("reflectionchange", this._updateReflectionCubeMap), this._xrLightProbe = null), this._canvasContext = null, this._xrLightEstimate = null, this._xrWebGLBinding = null, t }, t.prototype.dispose = function () { e.prototype.dispose.call(this), this.onReflectionCubeMapUpdatedObservable.clear(), this.directionalLight && (this.directionalLight.dispose(), this.directionalLight = null), null !== this._reflectionCubeMap && (this._reflectionCubeMap._texture && this._reflectionCubeMap._texture.dispose(), this._reflectionCubeMap.dispose(), this._reflectionCubeMap = null) }, t.prototype._onXRFrame = function (e) { var t; if (null !== this._xrLightProbe) { if (this.options.lightEstimationPollInterval) { var i = Date.now(); if (i - this._lightEstimationPollTime < this.options.lightEstimationPollInterval) return; this._lightEstimationPollTime = i } if (this._xrLightEstimate = e.getLightEstimate(this._xrLightProbe), this._xrLightEstimate) { this._intensity = Math.max(1, this._xrLightEstimate.primaryLightIntensity.x, this._xrLightEstimate.primaryLightIntensity.y, this._xrLightEstimate.primaryLightIntensity.z); var r = this._xrSessionManager.scene.useRightHandedSystem ? 1 : -1; this.options.disableVectorReuse && (this._lightDirection = new R, this._lightColor = new B, this.directionalLight && (this.directionalLight.direction = this._lightDirection, this.directionalLight.diffuse = this._lightColor)), this._lightDirection.copyFromFloats(this._xrLightEstimate.primaryLightDirection.x, this._xrLightEstimate.primaryLightDirection.y, this._xrLightEstimate.primaryLightDirection.z * r), this._lightColor.copyFromFloats(this._xrLightEstimate.primaryLightIntensity.x / this._intensity, this._xrLightEstimate.primaryLightIntensity.y / this._intensity, this._xrLightEstimate.primaryLightIntensity.z / this._intensity), this._sphericalHarmonics.updateFromFloatsArray(this._xrLightEstimate.sphericalHarmonicsCoefficients), this._reflectionCubeMap && !this.options.disableSphericalPolynomial && (this._reflectionCubeMap.sphericalPolynomial = this._reflectionCubeMap.sphericalPolynomial || new nd, null === (t = this._reflectionCubeMap.sphericalPolynomial) || void 0 === t || t.updateFromHarmonics(this._sphericalHarmonics)), this._lightDirection.negateInPlace(), this.directionalLight && (this.directionalLight.direction.copyFrom(this._lightDirection), this.directionalLight.intensity = Math.min(this._intensity, 1), this.directionalLight.diffuse.copyFrom(this._lightColor)) } } }, t.Name = zo.LIGHT_ESTIMATION, t.Version = 1, t }(Ho); Wo.AddWebXRFeature(gR.Name, (function (e, t) { return function () { return new gR(e, t) } }), gR.Version, !1); var vR = function (e) { function t(t) { var i = e.call(this, t) || this; return i.onEyeTrackingStartedObservable = new u, i.onEyeTrackingEndedObservable = new u, i.onEyeTrackingFrameUpdateObservable = new u, i._eyeTrackingStartListener = function (e) { i._latestEyeSpace = e.gazeSpace, i._gazeRay = new Mo(R.Zero(), R.Forward()), i.onEyeTrackingStartedObservable.notifyObservers(i._gazeRay) }, i._eyeTrackingEndListener = function () { i._latestEyeSpace = null, i._gazeRay = null, i.onEyeTrackingEndedObservable.notifyObservers() }, i.xrNativeFeatureName = "eye-tracking", i._xrSessionManager.session ? i._init() : i._xrSessionManager.onXRSessionInit.addOnce((function () { i._init() })), i } return W(t, e), t.prototype.dispose = function () { e.prototype.dispose.call(this), this._xrSessionManager.session.removeEventListener("eyetrackingstart", this._eyeTrackingStartListener), this._xrSessionManager.session.removeEventListener("eyetrackingend", this._eyeTrackingEndListener), this.onEyeTrackingStartedObservable.clear(), this.onEyeTrackingEndedObservable.clear(), this.onEyeTrackingFrameUpdateObservable.clear() }, Object.defineProperty(t.prototype, "isEyeGazeValid", { get: function () { return !!this._gazeRay }, enumerable: !1, configurable: !0 }), t.prototype.getEyeGaze = function () { return this._gazeRay }, t.prototype._onXRFrame = function (e) { if (this.attached && e && this._latestEyeSpace && this._gazeRay) { var t = e.getPose(this._latestEyeSpace, this._xrSessionManager.referenceSpace); if (t) { this._gazeRay.origin.set(t.transform.position.x, t.transform.position.y, t.transform.position.z); var i = t.transform.orientation; O.Quaternion[0].set(i.x, i.y, i.z, i.w), this._xrSessionManager.scene.useRightHandedSystem ? R.RightHandedForwardReadOnly.rotateByQuaternionToRef(O.Quaternion[0], this._gazeRay.direction) : (this._gazeRay.origin.z *= -1, O.Quaternion[0].z *= -1, O.Quaternion[0].w *= -1, R.LeftHandedForwardReadOnly.rotateByQuaternionToRef(O.Quaternion[0], this._gazeRay.direction)), this.onEyeTrackingFrameUpdateObservable.notifyObservers(this._gazeRay) } } }, t.prototype._init = function () { this._xrSessionManager.isNative && (this._xrSessionManager.session.addEventListener("eyetrackingstart", this._eyeTrackingStartListener), this._xrSessionManager.session.addEventListener("eyetrackingend", this._eyeTrackingEndListener)) }, t.Name = zo.EYE_TRACKING, t.Version = 1, t }(Ho); Wo.AddWebXRFeature(vR.Name, (function (e) { return function () { return new vR(e) } }), vR.Version, !1); var yR = function () { function e(e, t) { this._samples = [], this._idx = 0; for (var i = 0; i < e; ++i)this._samples.push(t ? t() : A.Zero()) } return Object.defineProperty(e.prototype, "length", { get: function () { return this._samples.length }, enumerable: !1, configurable: !0 }), e.prototype.push = function (e, t) { this._idx = (this._idx + this._samples.length - 1) % this._samples.length, this.at(0).copyFromFloats(e, t) }, e.prototype.at = function (e) { if (e >= this._samples.length) throw new Error("Index out of bounds"); return this._samples[(this._idx + e) % this._samples.length] }, e }(), bR = function () { function e() { this._samples = new yR(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; o < this._samples.length && !(A.DistanceSquared(n, this._samples.at(o)) < this._samePointSquaredDistanceThreshold); ++o); if (o !== this._samples.length) { for (var a = -1, s = 0, l = void 0, c = 1; c < o; ++c)(l = A.DistanceSquared(n, this._samples.at(c))) > a && (s = c, a = l); if (!(a < this._apexSquaredDistanceThreshold)) { var u = this._samples.at(s), h = u.subtract(n); h.normalize(); var d, p = O.Vector2[0], f = 0; for (c = 1; c < o; ++c)this._samples.at(c).subtractToRef(n, p), d = A.Dot(h, p), f += p.lengthSquared() - d * d; if (!(f > o * 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; e < this._samples.length; ++e)this._samples.at(e).copyFromFloats(0, 0) }, Object.defineProperty(e.prototype, "_samePointCheckStartIdx", { get: function () { return Math.floor(this._samples.length / 3) }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "_samePointSquaredDistanceThreshold", { get: function () { return 9e-4 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "_apexSquaredDistanceThreshold", { get: function () { return .0081 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "_squaredProjectionDistanceThreshold", { get: function () { return 9e-4 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "_axisToApexShrinkFactor", { get: function () { return .8 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "_axisToApexExtendFactor", { get: function () { return -1.6 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "_entropyDecayFactor", { get: function () { return .93 }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "_entropyThreshold", { get: function () { return .4 }, enumerable: !1, configurable: !0 }), e }(), TR = function () { function e(e, t, i, r) { this._leftApex = new A, this._rightApex = new A, this._currentPosition = new A, this._axis = new A, this._axisLength = -1, this._forward = new A, this._steppingLeft = !1, this._t = -1, this._maxT = -1, this._maxTPosition = new A, this._vitality = 0, this.onMovement = new u, this.onFootfall = new u, this._reset(e, t, i, "left" === r) } return e.prototype._reset = function (e, t, i, r) { this._leftApex.copyFrom(e), this._rightApex.copyFrom(t), this._steppingLeft = r, this._steppingLeft ? (this._leftApex.subtractToRef(this._rightApex, this._axis), this._forward.copyFromFloats(-this._axis.y, this._axis.x)) : (this._rightApex.subtractToRef(this._leftApex, this._axis), this._forward.copyFromFloats(this._axis.y, -this._axis.x)), this._axisLength = this._axis.length(), this._forward.scaleInPlace(1 / this._axisLength), this._updateTAndVitality(i.x, i.y), this._maxT = this._t, this._maxTPosition.copyFrom(i), this._vitality = 1 }, e.prototype._updateTAndVitality = function (e, t) { this._currentPosition.copyFromFloats(e, t), this._steppingLeft ? this._currentPosition.subtractInPlace(this._rightApex) : this._currentPosition.subtractInPlace(this._leftApex); var i = this._t, r = A.Dot(this._currentPosition, this._axis); this._t = r / (this._axisLength * this._axisLength); var n = this._currentPosition.lengthSquared() - r / this._axisLength * (r / this._axisLength); this._vitality *= .92 - 100 * Math.max(n - .0016, 0) + Math.max(this._t - i, 0) }, e.prototype.update = function (e, t) { if (this._vitality < this._vitalityThreshold) return !1; var i = this._t; return this._updateTAndVitality(e, t), this._t > this._maxT && (this._maxT = this._t, this._maxTPosition.copyFromFloats(e, t)), !(this._vitality < this._vitalityThreshold || (this._t > i && (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 }(), ER = function () { function e(t) { var i = this; this._detector = new bR, 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 TR(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 }(), SR = 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 zo.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 ER(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 }(Ho); Wo.AddWebXRFeature(SR.Name, (function (e, t) { return function () { return new SR(e, t) } }), SR.Version, !1); var xR = 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 }(Tc), AR = 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 }(Ec), RR = 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 CR(e, r, n) })) || this; return n.layer = t, n } return W(t, e), t }(xR), CR = 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 }(AR), PR = {}, IR = { textureType: "texture", colorFormat: 6408, depthFormat: 35056, scaleFactor: 1 }, MR = 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({}, IR), 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 = PR); var t = new XRWebGLLayer(this._xrSessionManager.session, this._glContext, e); return new Sc(t) }, t.prototype.createProjectionLayer = function (e, t) { if (void 0 === e && (e = IR), 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 RR(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 = zo.LAYERS, t.Version = 1, t }(Ho); Wo.AddWebXRFeature(MR.Name, (function (e, t) { return function () { return new MR(e, t) } }), MR.Version, !1); var OR = 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", xi.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 Ht(i, It.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 Zt(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; r < n.length; r++) { var o = n[r]; switch (this.depthUsage) { case "cpu": this._updateDepthInformationAndTextureCPUDepthUsage(e, o, this.depthDataFormat); break; case "gpu": if (!this._glBinding) break; this._updateDepthInformationAndTextureWebGLDepthUsage(this._glBinding, o, this.depthDataFormat); break; default: xi.Error("Unknown depth usage"), this.detach() } } }, t.prototype._updateDepthInformationAndTextureCPUDepthUsage = function (e, t, i) { var r, n = e.getDepthInformation(t); if (null !== n) { var o = (r = n).data, a = r.width, s = r.height, l = r.rawValueToMeters, c = r.getDepthInMeters; switch (this._width = a, this._height = s, this._rawValueToMeters = l, this._cachedDepthBuffer = o, this.onGetDepthInMetersAvailable.notifyObservers(c.bind(n)), this._cachedDepthImageTexture || (this._cachedDepthImageTexture = Eo.CreateRTexture(null, a, s, this._xrSessionManager.scene, !1, !0, vo.NEAREST_SAMPLINGMODE, In.TEXTURETYPE_FLOAT)), i) { case "ushort": this._cachedDepthImageTexture.update(Float32Array.from(new Uint16Array(o)).map((function (e) { return e * l }))); break; case "float": this._cachedDepthImageTexture.update(new Float32Array(o).map((function (e) { return e * l }))) } } }, t.prototype._updateDepthInformationAndTextureWebGLDepthUsage = function (e, t, i) { var r, n = e.getDepthInformation(t); if (null !== n) { var o = (r = n).texture, a = r.width, s = r.height; this._width = a, this._height = s, this._cachedWebGLTexture = o; var l = this._xrSessionManager.scene, c = l.getEngine().wrapWebGLTexture(o); this._cachedDepthImageTexture || (this._cachedDepthImageTexture = Eo.CreateRTexture(null, a, s, l, !1, !0, vo.NEAREST_SAMPLINGMODE, "ushort" === i ? In.TEXTURETYPE_UNSIGNED_BYTE : In.TEXTURETYPE_FLOAT)), this._cachedDepthImageTexture._texture = c } }, t.prototype.getXRSessionInitExtension = function () { var e = this, t = null != this.options.usagePreference && 0 !== this.options.usagePreference.length, i = null != this.options.dataFormatPreference && 0 !== this.options.dataFormatPreference.length; return new Promise((function (r) { r(t && i ? { depthSensing: { usagePreference: e.options.usagePreference.map((function (e) { switch (e) { case "cpu": return "cpu-optimized"; case "gpu": return "gpu-optimized" } })), dataFormatPreference: e.options.dataFormatPreference.map((function (e) { switch (e) { case "ushort": return "luminance-alpha"; case "float": return "float32" } })) } } : {}) })) }, t.Name = zo.DEPTH_SENSING, t.Version = 1, t }(Ho); Wo.AddWebXRFeature(OR.Name, (function (e, t) { return function () { return new OR(e, t) } }), OR.Version, !1); Ut.ShadersStore.velocityPixelShader = "precision highp float;\n#define CUSTOM_FRAGMENT_BEGIN\nvarying vec4 clipPos;varying vec4 previousClipPos;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nhighp vec4 motionVector=( clipPos/clipPos.w-previousClipPos/previousClipPos.w );gl_FragColor=motionVector;\n#define CUSTOM_FRAGMENT_MAIN_END\n}"; Ut.ShadersStore.velocityVertexShader = "#define CUSTOM_VERTEX_BEGIN\n#define VELOCITY\nattribute vec3 position;\n#include\nuniform mat4 viewProjection;uniform mat4 previousViewProjection;\n#ifdef MULTIVIEW\nuniform mat4 viewProjectionR;uniform mat4 previousViewProjectionR;\n#endif\nvarying vec4 clipPos;varying vec4 previousClipPos;\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec3 positionUpdated=position;\n#include\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);vec4 previousWorldPos=finalPreviousWorld*vec4(positionUpdated,1.0);\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR==0u) {clipPos=viewProjection*worldPos;previousClipPos=previousViewProjection*previousWorldPos;gl_Position=clipPos;} else {clipPos=viewProjectionR*worldPos;previousClipPos=previousViewProjectionR*previousWorldPos;gl_Position=clipPos;}\n#elif\nclipPos=viewProjection*worldPos;previousClipPos=previousViewProjection*previousWorldPos;gl_Position=clipPos;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}"; var DR = function (e) { function t(t, i, r, n) { void 0 === n && (n = 512); var o = e.call(this, "spacewarp rtt", n, r, !1, !0, a.TEXTURETYPE_HALF_FLOAT, !1, void 0, !1, !1, !0, void 0, !0) || this; return o._originalPairing = [], o._previousWorldMatrices = [], o._previousTransforms = [I.Identity(), I.Identity()], o._renderTarget = o.getScene().getEngine().createMultiviewRenderTargetTexture(o.getRenderWidth(), o.getRenderHeight(), t, i), o._renderTarget._disposeOnlyFramebuffers = !0, o._texture = o._renderTarget.texture, o._texture.isMultiview = !0, o._texture.format = a.TEXTUREFORMAT_RGBA, r && (o._velocityMaterial = new Gu("velocity shader material", r, { vertex: "velocity", fragment: "velocity" }, { uniforms: ["world", "previousWorld", "viewProjection", "viewProjectionR", "previousViewProjection", "previousViewProjectionR"] }), o._velocityMaterial._materialHelperNeedsPreviousMatrices = !0, o._velocityMaterial.onBindObservable.add((function (e) { o._previousWorldMatrices[e.uniqueId] = o._previousWorldMatrices[e.uniqueId] || e.getWorldMatrix(), o._velocityMaterial.getEffect().setMatrix("previousWorld", o._previousWorldMatrices[e.uniqueId]), o._previousWorldMatrices[e.uniqueId] = e.getWorldMatrix(), o._velocityMaterial.getEffect().setMatrix("previousViewProjection", o._previousTransforms[0]), o._velocityMaterial.getEffect().setMatrix("previousViewProjectionR", o._previousTransforms[1]), o._previousTransforms[0].copyFrom(r.getTransformMatrix()), o._previousTransforms[1].copyFrom(r._transformMatrixR) })), o._velocityMaterial.freeze()), o } return W(t, e), t.prototype.render = function (t, i) { var r = this; void 0 === t && (t = !1), void 0 === i && (i = !1), this._originalPairing.length = 0; var n = this.getScene(); n && this._velocityMaterial && n.getActiveMeshes().forEach((function (e) { r._originalPairing.push([e, e.material]), e.material = r._velocityMaterial })), e.prototype.render.call(this, t, i), this._originalPairing.forEach((function (e) { e[0].material = e[1] })) }, t.prototype._bindFrameBuffer = function () { this._renderTarget && this.getScene().getEngine().bindSpaceWarpFramebuffer(this._renderTarget) }, t.prototype.getViewCount = function () { return 2 }, t.prototype.dispose = function () { e.prototype.dispose.call(this), this._velocityMaterial.dispose(), this._previousTransforms.length = 0, this._previousWorldMatrices.length = 0, this._originalPairing.length = 0 }, t }(es), NR = function () { function e(e, t, i) { this._scene = e, this._xrSessionManager = t, this._xrWebGLBinding = i, this._lastSubImages = new Map, this._renderTargetTextures = new Map, this._engine = e.getEngine() } return e.prototype._getSubImageForView = function (e) { var t = this._xrSessionManager._getBaseLayerWrapper(); if (!t) throw new Error("For Space Warp, the base layer should be a WebXR Projection Layer."); if ("XRProjectionLayer" !== t.layerType) throw new Error('For Space Warp, the base layer type should "XRProjectionLayer".'); var i = t.layer; return this._xrWebGLBinding.getViewSubImage(i, e) }, e.prototype._setViewportForSubImage = function (e, t) { e.x = 0, e.y = 0, e.width = t.motionVectorTextureWidth, e.height = t.motionVectorTextureHeight }, e.prototype._createRenderTargetTexture = function (e, t, i, r, n) { if (!this._engine) throw new Error("Engine is disposed"); var o = { width: e, height: t }, a = new DR(r, n, this._scene, o), s = a.renderTarget; return i && (s._framebuffer = i), s._colorTextureArray = r, s._depthStencilTextureArray = n, a.disableRescaling(), a.renderListPredicate = function () { return !0 }, a }, e.prototype._getRenderTargetForSubImage = function (e, t) { var i = this._lastSubImages.get(t), r = this._renderTargetTextures.get(t.eye), n = e.motionVectorTextureWidth, o = e.motionVectorTextureHeight; return r && (null == i ? void 0 : i.textureWidth) === n && (null == i ? void 0 : i.textureHeight) == o || (r = this._createRenderTargetTexture(n, o, null, e.motionVectorTexture, e.depthStencilTexture), this._renderTargetTextures.set(t.eye, r), this._framebufferDimensions = { framebufferWidth: n, framebufferHeight: o }), this._lastSubImages.set(t, e), r }, e.prototype.trySetViewportForView = function (e, t) { var i = this._lastSubImages.get(t) || this._getSubImageForView(t); return !!i && (this._setViewportForSubImage(e, i), !0) }, e.prototype.accessMotionVector = function (e) { var t = this._getSubImageForView(e); t && (t.motionVectorTexture, t.depthStencilTexture) }, e.prototype.getRenderTargetTextureForEye = function (e) { return null }, e.prototype.getRenderTargetTextureForView = function (e) { var t = this._getSubImageForView(e); return t ? this._getRenderTargetForSubImage(t, e) : null }, e.prototype.dispose = function () { this._renderTargetTextures.forEach((function (e) { return e.dispose() })), this._renderTargetTextures.clear() }, e }(), FR = function (e) { function t(t) { var i = e.call(this, t) || this; return i.dependsOn = [zo.LAYERS], i.xrNativeFeatureName = "space-warp", i._xrSessionManager.scene.needsPreviousWorldMatrices = !0, i } return W(t, e), t.prototype.attach = function () { if (!e.prototype.attach.call(this)) return !1; var t = this._xrSessionManager.scene.getEngine(); return this._glContext = t._gl, this._xrWebGLBinding = new XRWebGLBinding(this._xrSessionManager.session, this._glContext), this.spaceWarpRTTProvider = new NR(this._xrSessionManager.scene, this._xrSessionManager, this._xrWebGLBinding), this._xrSessionManager.scene.onAfterRenderObservable.add(this._onAfterRender.bind(this)), !0 }, t.prototype._onAfterRender = function () { this.attached && this._renderTargetTexture && this._renderTargetTexture.render(!1, !1) }, t.prototype.isCompatible = function () { return this._xrSessionManager.scene.getEngine().getCaps().colorBufferHalfFloat || !1 }, t.prototype.dispose = function () { e.prototype.dispose.call(this) }, t.prototype._onXRFrame = function (e) { var t = e.getViewerPose(this._xrSessionManager.referenceSpace); if (t) { var i = t.views[0]; this._renderTargetTexture = this._renderTargetTexture || this.spaceWarpRTTProvider.getRenderTargetTextureForView(i), this.spaceWarpRTTProvider.accessMotionVector(i) } }, t.Name = zo.SPACE_WARP, t.Version = 1, t }(Ho); Wo.AddWebXRFeature(FR.Name, (function (e) { return function () { return new FR(e) } }), FR.Version, !1); var LR = function (e) { function t(t, i, r) { var n = e.call(this, t, wR[r], i, r, !0) || this; return n.profileId = "generic-hand-select-grasp", n } 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) { }, t.prototype._updateModel = function () { }, t }(sm); dm.RegisterController("generic-hand-select-grasp", (function (e, t) { return new LR(t, e.gamepad, e.handedness) })); var wR = { left: { selectComponentId: "xr-standard-trigger", components: { "xr-standard-trigger": { type: "trigger", gamepadIndices: { button: 0 }, rootNodeName: "xr-standard-trigger", visualResponses: {} }, grasp: { type: "trigger", gamepadIndices: { button: 4 }, rootNodeName: "grasp", visualResponses: {} } }, gamepadMapping: "xr-standard", rootNodeName: "generic-hand-select-grasp-left", assetPath: "left.glb" }, right: { selectComponentId: "xr-standard-trigger", components: { "xr-standard-trigger": { type: "trigger", gamepadIndices: { button: 0 }, rootNodeName: "xr-standard-trigger", visualResponses: {} }, grasp: { type: "trigger", gamepadIndices: { button: 4 }, rootNodeName: "grasp", visualResponses: {} } }, gamepadMapping: "xr-standard", rootNodeName: "generic-hand-select-grasp-right", assetPath: "right.glb" }, none: { selectComponentId: "xr-standard-trigger", components: { "xr-standard-trigger": { type: "trigger", gamepadIndices: { button: 0 }, rootNodeName: "xr-standard-trigger", visualResponses: {} }, grasp: { type: "trigger", gamepadIndices: { button: 4 }, rootNodeName: "grasp", visualResponses: {} } }, gamepadMapping: "xr-standard", rootNodeName: "generic-hand-select-grasp-none", assetPath: "none.glb" } }, BR = function (e) { function t(t, i, r) { var n = e.call(this, t, UR["left-right"], i, r) || this; return n._mapping = { defaultButton: { valueNodeName: "VALUE", unpressedNodeName: "UNPRESSED", pressedNodeName: "PRESSED" }, defaultAxis: { valueNodeName: "VALUE", minNodeName: "MIN", maxNodeName: "MAX" }, buttons: { "xr-standard-trigger": { rootNodeName: "SELECT", componentProperty: "button", states: ["default", "touched", "pressed"] }, "xr-standard-squeeze": { rootNodeName: "GRASP", componentProperty: "state", states: ["pressed"] }, "xr-standard-touchpad": { rootNodeName: "TOUCHPAD_PRESS", labelAnchorNodeName: "squeeze-label", touchPointNodeName: "TOUCH" }, "xr-standard-thumbstick": { rootNodeName: "THUMBSTICK_PRESS", componentProperty: "state", states: ["pressed"] } }, axes: { "xr-standard-touchpad": { "x-axis": { rootNodeName: "TOUCHPAD_TOUCH_X" }, "y-axis": { rootNodeName: "TOUCHPAD_TOUCH_Y" } }, "xr-standard-thumbstick": { "x-axis": { rootNodeName: "THUMBSTICK_X" }, "y-axis": { rootNodeName: "THUMBSTICK_Y" } } } }, n.profileId = "microsoft-mixed-reality", n } return W(t, e), t.prototype._getFilenameAndPath = function () { return { filename: "left" === this.handedness ? t.MODEL_LEFT_FILENAME : t.MODEL_RIGHT_FILENAME, path: t.MODEL_BASE_URL + "default/" } }, t.prototype._getModelLoadingConstraints = function () { var e = ea.IsPluginForExtensionAvailable(".glb"); return e || $.Warn("glTF / glb loaded was not registered, using generic controller instead"), e }, t.prototype._processLoadedModel = function (e) { var t = this; this.rootMesh && (this.getComponentIds().forEach((function (e, i) { if (!t.disableAnimation && e && t.rootMesh) { var r = t._mapping.buttons[e], n = r.rootNodeName; if (!n) return void $.Log("Skipping unknown button at index: " + i + " with mapped name: " + e); var o = t._getChildByName(t.rootMesh, n); if (!o) return void $.Warn("Missing button mesh with name: " + n); if (r.valueMesh = t._getImmediateChildByName(o, t._mapping.defaultButton.valueNodeName), r.pressedMesh = t._getImmediateChildByName(o, t._mapping.defaultButton.pressedNodeName), r.unpressedMesh = t._getImmediateChildByName(o, t._mapping.defaultButton.unpressedNodeName), r.valueMesh && r.pressedMesh && r.unpressedMesh) { var a = t.getComponent(e); a && a.onButtonStateChangedObservable.add((function (e) { t._lerpTransform(r, e.value) }), void 0, !0) } else $.Warn("Missing button submesh under mesh with name: " + n) } })), this.getComponentIds().forEach((function (e) { var i = t.getComponent(e); i.isAxes() && ["x-axis", "y-axis"].forEach((function (r) { if (t.rootMesh) { var n = t._mapping.axes[e][r], o = t._getChildByName(t.rootMesh, n.rootNodeName); o ? (n.valueMesh = t._getImmediateChildByName(o, t._mapping.defaultAxis.valueNodeName), n.minMesh = t._getImmediateChildByName(o, t._mapping.defaultAxis.minNodeName), n.maxMesh = t._getImmediateChildByName(o, t._mapping.defaultAxis.maxNodeName), n.valueMesh && n.minMesh && n.maxMesh ? i && i.onAxisValueChangedObservable.add((function (e) { var i = "x-axis" === r ? e.x : e.y; t._lerpTransform(n, i, !0) }), void 0, !0) : $.Warn("Missing axis submesh under mesh with name: " + n.rootNodeName)) : $.Warn("Missing axis mesh with name: " + n.rootNodeName) } })) }))) }, t.prototype._setRootMesh = function (e) { var t; this.rootMesh = new Jn(this.profileId + " " + this.handedness, this.scene), this.rootMesh.isPickable = !1; for (var i = 0; i < e.length; i++) { var r = e[i]; r.isPickable = !1, r.parent || (t = r) } t && t.setParent(this.rootMesh), this.scene.useRightHandedSystem || (this.rootMesh.rotationQuaternion = P.FromEulerAngles(0, Math.PI, 0)) }, t.prototype._updateModel = function () { }, t.MODEL_BASE_URL = "https://controllers.babylonjs.com/microsoft/", t.MODEL_LEFT_FILENAME = "left.glb", t.MODEL_RIGHT_FILENAME = "right.glb", t }(sm); dm.RegisterController("windows-mixed-reality", (function (e, t) { return new BR(t, e.gamepad, e.handedness) })); var UR = { left: { selectComponentId: "xr-standard-trigger", components: { "xr-standard-trigger": { type: "trigger", gamepadIndices: { button: 0 }, rootNodeName: "xr_standard_trigger", visualResponses: { xr_standard_trigger_pressed: { componentProperty: "button", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_trigger_pressed_value", minNodeName: "xr_standard_trigger_pressed_min", maxNodeName: "xr_standard_trigger_pressed_max" } } }, "xr-standard-squeeze": { type: "squeeze", gamepadIndices: { button: 1 }, rootNodeName: "xr_standard_squeeze", visualResponses: { xr_standard_squeeze_pressed: { componentProperty: "button", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_squeeze_pressed_value", minNodeName: "xr_standard_squeeze_pressed_min", maxNodeName: "xr_standard_squeeze_pressed_max" } } }, "xr-standard-touchpad": { type: "touchpad", gamepadIndices: { button: 2, xAxis: 0, yAxis: 1 }, rootNodeName: "xr_standard_touchpad", visualResponses: { xr_standard_touchpad_pressed: { componentProperty: "button", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_touchpad_pressed_value", minNodeName: "xr_standard_touchpad_pressed_min", maxNodeName: "xr_standard_touchpad_pressed_max" }, xr_standard_touchpad_xaxis_pressed: { componentProperty: "xAxis", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_touchpad_xaxis_pressed_value", minNodeName: "xr_standard_touchpad_xaxis_pressed_min", maxNodeName: "xr_standard_touchpad_xaxis_pressed_max" }, xr_standard_touchpad_yaxis_pressed: { componentProperty: "yAxis", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_touchpad_yaxis_pressed_value", minNodeName: "xr_standard_touchpad_yaxis_pressed_min", maxNodeName: "xr_standard_touchpad_yaxis_pressed_max" }, xr_standard_touchpad_xaxis_touched: { componentProperty: "xAxis", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_touchpad_xaxis_touched_value", minNodeName: "xr_standard_touchpad_xaxis_touched_min", maxNodeName: "xr_standard_touchpad_xaxis_touched_max" }, xr_standard_touchpad_yaxis_touched: { componentProperty: "yAxis", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_touchpad_yaxis_touched_value", minNodeName: "xr_standard_touchpad_yaxis_touched_min", maxNodeName: "xr_standard_touchpad_yaxis_touched_max" }, xr_standard_touchpad_axes_touched: { componentProperty: "state", states: ["touched", "pressed"], valueNodeProperty: "visibility", valueNodeName: "xr_standard_touchpad_axes_touched_value" } }, touchPointNodeName: "xr_standard_touchpad_axes_touched_value" }, "xr-standard-thumbstick": { type: "thumbstick", gamepadIndices: { button: 3, xAxis: 2, yAxis: 3 }, rootNodeName: "xr_standard_thumbstick", visualResponses: { xr_standard_thumbstick_pressed: { componentProperty: "button", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_thumbstick_pressed_value", minNodeName: "xr_standard_thumbstick_pressed_min", maxNodeName: "xr_standard_thumbstick_pressed_max" }, xr_standard_thumbstick_xaxis_pressed: { componentProperty: "xAxis", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_thumbstick_xaxis_pressed_value", minNodeName: "xr_standard_thumbstick_xaxis_pressed_min", maxNodeName: "xr_standard_thumbstick_xaxis_pressed_max" }, xr_standard_thumbstick_yaxis_pressed: { componentProperty: "yAxis", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_thumbstick_yaxis_pressed_value", minNodeName: "xr_standard_thumbstick_yaxis_pressed_min", maxNodeName: "xr_standard_thumbstick_yaxis_pressed_max" } } } }, gamepadMapping: "xr-standard", rootNodeName: "microsoft-mixed-reality-left", assetPath: "left.glb" }, right: { selectComponentId: "xr-standard-trigger", components: { "xr-standard-trigger": { type: "trigger", gamepadIndices: { button: 0 }, rootNodeName: "xr_standard_trigger", visualResponses: { xr_standard_trigger_pressed: { componentProperty: "button", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_trigger_pressed_value", minNodeName: "xr_standard_trigger_pressed_min", maxNodeName: "xr_standard_trigger_pressed_max" } } }, "xr-standard-squeeze": { type: "squeeze", gamepadIndices: { button: 1 }, rootNodeName: "xr_standard_squeeze", visualResponses: { xr_standard_squeeze_pressed: { componentProperty: "button", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_squeeze_pressed_value", minNodeName: "xr_standard_squeeze_pressed_min", maxNodeName: "xr_standard_squeeze_pressed_max" } } }, "xr-standard-touchpad": { type: "touchpad", gamepadIndices: { button: 2, xAxis: 0, yAxis: 1 }, rootNodeName: "xr_standard_touchpad", visualResponses: { xr_standard_touchpad_pressed: { componentProperty: "button", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_touchpad_pressed_value", minNodeName: "xr_standard_touchpad_pressed_min", maxNodeName: "xr_standard_touchpad_pressed_max" }, xr_standard_touchpad_xaxis_pressed: { componentProperty: "xAxis", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_touchpad_xaxis_pressed_value", minNodeName: "xr_standard_touchpad_xaxis_pressed_min", maxNodeName: "xr_standard_touchpad_xaxis_pressed_max" }, xr_standard_touchpad_yaxis_pressed: { componentProperty: "yAxis", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_touchpad_yaxis_pressed_value", minNodeName: "xr_standard_touchpad_yaxis_pressed_min", maxNodeName: "xr_standard_touchpad_yaxis_pressed_max" }, xr_standard_touchpad_xaxis_touched: { componentProperty: "xAxis", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_touchpad_xaxis_touched_value", minNodeName: "xr_standard_touchpad_xaxis_touched_min", maxNodeName: "xr_standard_touchpad_xaxis_touched_max" }, xr_standard_touchpad_yaxis_touched: { componentProperty: "yAxis", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_touchpad_yaxis_touched_value", minNodeName: "xr_standard_touchpad_yaxis_touched_min", maxNodeName: "xr_standard_touchpad_yaxis_touched_max" }, xr_standard_touchpad_axes_touched: { componentProperty: "state", states: ["touched", "pressed"], valueNodeProperty: "visibility", valueNodeName: "xr_standard_touchpad_axes_touched_value" } }, touchPointNodeName: "xr_standard_touchpad_axes_touched_value" }, "xr-standard-thumbstick": { type: "thumbstick", gamepadIndices: { button: 3, xAxis: 2, yAxis: 3 }, rootNodeName: "xr_standard_thumbstick", visualResponses: { xr_standard_thumbstick_pressed: { componentProperty: "button", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_thumbstick_pressed_value", minNodeName: "xr_standard_thumbstick_pressed_min", maxNodeName: "xr_standard_thumbstick_pressed_max" }, xr_standard_thumbstick_xaxis_pressed: { componentProperty: "xAxis", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_thumbstick_xaxis_pressed_value", minNodeName: "xr_standard_thumbstick_xaxis_pressed_min", maxNodeName: "xr_standard_thumbstick_xaxis_pressed_max" }, xr_standard_thumbstick_yaxis_pressed: { componentProperty: "yAxis", states: ["default", "touched", "pressed"], valueNodeProperty: "transform", valueNodeName: "xr_standard_thumbstick_yaxis_pressed_value", minNodeName: "xr_standard_thumbstick_yaxis_pressed_min", maxNodeName: "xr_standard_thumbstick_yaxis_pressed_max" } } } }, gamepadMapping: "xr-standard", rootNodeName: "microsoft-mixed-reality-right", assetPath: "right.glb" } }, VR = function (e) { function t(t, i, r, n, o) { void 0 === n && (n = !1), void 0 === o && (o = !1); var a = e.call(this, t, kR[r], i, r) || this; return a._forceLegacyControllers = o, a.profileId = "oculus-touch", a } return W(t, e), t.prototype._getFilenameAndPath = function () { return { filename: "left" === this.handedness ? t.MODEL_LEFT_FILENAME : t.MODEL_RIGHT_FILENAME, path: this._isQuest() ? t.QUEST_MODEL_BASE_URL : t.MODEL_BASE_URL } }, t.prototype._getModelLoadingConstraints = function () { return !0 }, t.prototype._processLoadedModel = function (e) { var t = this, i = this._isQuest(), r = "right" === this.handedness ? -1 : 1; this.getComponentIds().forEach((function (e) { var n = e && t.getComponent(e); n && n.onButtonStateChangedObservable.add((function (n) { if (t.rootMesh && !t.disableAnimation) switch (e) { case "xr-standard-trigger": return void (i || (t._modelRootNode.getChildren()[3].rotation.x = .2 * -n.value, t._modelRootNode.getChildren()[3].position.y = .005 * -n.value, t._modelRootNode.getChildren()[3].position.z = .005 * -n.value)); case "xr-standard-squeeze": return void (i || (t._modelRootNode.getChildren()[4].position.x = r * n.value * .0035)); case "xr-standard-thumbstick": return; case "a-button": case "x-button": return void (i || (n.pressed ? t._modelRootNode.getChildren()[1].position.y = -.001 : t._modelRootNode.getChildren()[1].position.y = 0)); case "b-button": case "y-button": return void (i || (n.pressed ? t._modelRootNode.getChildren()[2].position.y = -.001 : t._modelRootNode.getChildren()[2].position.y = 0)) } }), void 0, !0) })) }, t.prototype._setRootMesh = function (e) { this.rootMesh = new Jn(this.profileId + " " + this.handedness, this.scene), this.scene.useRightHandedSystem || (this.rootMesh.rotationQuaternion = P.FromEulerAngles(0, Math.PI, 0)), e.forEach((function (e) { e.isPickable = !1 })), this._isQuest() ? this._modelRootNode = e[0] : (this._modelRootNode = e[1], this.rootMesh.position.y = .034, this.rootMesh.position.z = .052), this._modelRootNode.parent = this.rootMesh }, t.prototype._updateModel = function () { }, t.prototype._isQuest = function () { return !!navigator.userAgent.match(/Quest/gi) && !this._forceLegacyControllers }, t.MODEL_BASE_URL = "https://controllers.babylonjs.com/oculus/", t.MODEL_LEFT_FILENAME = "left.babylon", t.MODEL_RIGHT_FILENAME = "right.babylon", t.QUEST_MODEL_BASE_URL = "https://controllers.babylonjs.com/oculusQuest/", t }(sm); dm.RegisterController("oculus-touch", (function (e, t) { return new VR(t, e.gamepad, e.handedness) })), dm.RegisterController("oculus-touch-legacy", (function (e, t) { return new VR(t, e.gamepad, e.handedness, !0) })); var kR = { left: { selectComponentId: "xr-standard-trigger", components: { "xr-standard-trigger": { type: "trigger", gamepadIndices: { button: 0 }, rootNodeName: "xr_standard_trigger", visualResponses: {} }, "xr-standard-squeeze": { type: "squeeze", gamepadIndices: { button: 1 }, rootNodeName: "xr_standard_squeeze", visualResponses: {} }, "xr-standard-thumbstick": { type: "thumbstick", gamepadIndices: { button: 3, xAxis: 2, yAxis: 3 }, rootNodeName: "xr_standard_thumbstick", visualResponses: {} }, "x-button": { type: "button", gamepadIndices: { button: 4 }, rootNodeName: "x_button", visualResponses: {} }, "y-button": { type: "button", gamepadIndices: { button: 5 }, rootNodeName: "y_button", visualResponses: {} }, thumbrest: { type: "button", gamepadIndices: { button: 6 }, rootNodeName: "thumbrest", visualResponses: {} } }, gamepadMapping: "xr-standard", rootNodeName: "oculus-touch-v2-left", assetPath: "left.glb" }, right: { selectComponentId: "xr-standard-trigger", components: { "xr-standard-trigger": { type: "trigger", gamepadIndices: { button: 0 }, rootNodeName: "xr_standard_trigger", visualResponses: {} }, "xr-standard-squeeze": { type: "squeeze", gamepadIndices: { button: 1 }, rootNodeName: "xr_standard_squeeze", visualResponses: {} }, "xr-standard-thumbstick": { type: "thumbstick", gamepadIndices: { button: 3, xAxis: 2, yAxis: 3 }, rootNodeName: "xr_standard_thumbstick", visualResponses: {} }, "a-button": { type: "button", gamepadIndices: { button: 4 }, rootNodeName: "a_button", visualResponses: {} }, "b-button": { type: "button", gamepadIndices: { button: 5 }, rootNodeName: "b_button", visualResponses: {} }, thumbrest: { type: "button", gamepadIndices: { button: 6 }, rootNodeName: "thumbrest", visualResponses: {} } }, gamepadMapping: "xr-standard", rootNodeName: "oculus-touch-v2-right", assetPath: "right.glb" } }, GR = function (e) { function t(t, i, r) { var n = e.call(this, t, WR[r], i, r) || this; return n.profileId = "htc-vive", n } return W(t, e), t.prototype._getFilenameAndPath = function () { return { filename: t.MODEL_FILENAME, path: t.MODEL_BASE_URL } }, t.prototype._getModelLoadingConstraints = function () { return !0 }, t.prototype._processLoadedModel = function (e) { var t = this; this.getComponentIds().forEach((function (e) { var i = e && t.getComponent(e); i && i.onButtonStateChangedObservable.add((function (i) { if (t.rootMesh && !t.disableAnimation) switch (e) { case "xr-standard-trigger": return void (t._modelRootNode.getChildren()[6].rotation.x = .15 * -i.value); case "xr-standard-touchpad": case "xr-standard-squeeze": return } }), void 0, !0) })) }, t.prototype._setRootMesh = function (e) { this.rootMesh = new Jn(this.profileId + " " + this.handedness, this.scene), e.forEach((function (e) { e.isPickable = !1 })), this._modelRootNode = e[1], this._modelRootNode.parent = this.rootMesh, this.scene.useRightHandedSystem || (this.rootMesh.rotationQuaternion = P.FromEulerAngles(0, Math.PI, 0)) }, t.prototype._updateModel = function () { }, t.MODEL_BASE_URL = "https://controllers.babylonjs.com/vive/", t.MODEL_FILENAME = "wand.babylon", t }(sm); dm.RegisterController("htc-vive", (function (e, t) { return new GR(t, e.gamepad, e.handedness) })); var zR, WR = { left: { selectComponentId: "xr-standard-trigger", components: { "xr-standard-trigger": { type: "trigger", gamepadIndices: { button: 0 }, rootNodeName: "xr_standard_trigger", visualResponses: {} }, "xr-standard-squeeze": { type: "squeeze", gamepadIndices: { button: 1 }, rootNodeName: "xr_standard_squeeze", visualResponses: {} }, "xr-standard-touchpad": { type: "touchpad", gamepadIndices: { button: 2, xAxis: 0, yAxis: 1 }, rootNodeName: "xr_standard_touchpad", visualResponses: {} }, menu: { type: "button", gamepadIndices: { button: 4 }, rootNodeName: "menu", visualResponses: {} } }, gamepadMapping: "xr-standard", rootNodeName: "htc_vive_none", assetPath: "none.glb" }, right: { selectComponentId: "xr-standard-trigger", components: { "xr-standard-trigger": { type: "trigger", gamepadIndices: { button: 0 }, rootNodeName: "xr_standard_trigger", visualResponses: {} }, "xr-standard-squeeze": { type: "squeeze", gamepadIndices: { button: 1 }, rootNodeName: "xr_standard_squeeze", visualResponses: {} }, "xr-standard-touchpad": { type: "touchpad", gamepadIndices: { button: 2, xAxis: 0, yAxis: 1 }, rootNodeName: "xr_standard_touchpad", visualResponses: {} }, menu: { type: "button", gamepadIndices: { button: 4 }, rootNodeName: "menu", visualResponses: {} } }, gamepadMapping: "xr-standard", rootNodeName: "htc_vive_none", assetPath: "none.glb" }, none: { selectComponentId: "xr-standard-trigger", components: { "xr-standard-trigger": { type: "trigger", gamepadIndices: { button: 0 }, rootNodeName: "xr_standard_trigger", visualResponses: {} }, "xr-standard-squeeze": { type: "squeeze", gamepadIndices: { button: 1 }, rootNodeName: "xr_standard_squeeze", visualResponses: {} }, "xr-standard-touchpad": { type: "touchpad", gamepadIndices: { button: 2, xAxis: 0, yAxis: 1 }, rootNodeName: "xr_standard_touchpad", visualResponses: {} }, menu: { type: "button", gamepadIndices: { button: 4 }, rootNodeName: "menu", visualResponses: {} } }, gamepadMapping: "xr-standard", rootNodeName: "htc-vive-none", assetPath: "none.glb" } }, HR = function () { function e(e) { var t = this; this._nativeImpl = e, this._xrTransform = new XRRigidTransform, this._xrPose = { transform: this._xrTransform, emulatedPosition: !1 }, this._xrPoseVectorData = new Float32Array(8), this.fillPoses = this._nativeImpl.fillPoses.bind(this._nativeImpl), this.getViewerPose = this._nativeImpl.getViewerPose.bind(this._nativeImpl), this.getHitTestResults = this._nativeImpl.getHitTestResults.bind(this._nativeImpl), this.getHitTestResultsForTransientInput = function () { throw new Error("XRFrame.getHitTestResultsForTransientInput not supported on native.") }, this.createAnchor = this._nativeImpl.createAnchor.bind(this._nativeImpl), this.getJointPose = this._nativeImpl.getJointPose.bind(this._nativeImpl), this.fillJointRadii = this._nativeImpl.fillJointRadii.bind(this._nativeImpl), this.getLightEstimate = function () { throw new Error("XRFrame.getLightEstimate not supported on native.") }, this.getImageTrackingResults = function () { var e; return null !== (e = t._nativeImpl._imageTrackingResults) && void 0 !== e ? e : [] } } return Object.defineProperty(e.prototype, "session", { get: function () { return this._nativeImpl.session }, enumerable: !1, configurable: !0 }), e.prototype.getPose = function (e, t) { if (this._nativeImpl.getPoseData(e, t, this._xrPoseVectorData.buffer, this._xrTransform.matrix.buffer)) { var i = this._xrTransform.position; i.x = this._xrPoseVectorData[0], i.y = this._xrPoseVectorData[1], i.z = this._xrPoseVectorData[2], i.w = this._xrPoseVectorData[3]; var r = this._xrTransform.orientation; return r.x = this._xrPoseVectorData[4], r.y = this._xrPoseVectorData[5], r.z = this._xrPoseVectorData[6], r.w = this._xrPoseVectorData[7], this._xrPose } }, Object.defineProperty(e.prototype, "trackedAnchors", { get: function () { return this._nativeImpl.trackedAnchors }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "worldInformation", { get: function () { return this._nativeImpl.worldInformation }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "detectedPlanes", { get: function () { return this._nativeImpl.detectedPlanes }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "featurePointCloud", { get: function () { return this._nativeImpl.featurePointCloud }, enumerable: !1, configurable: !0 }), e.prototype.getDepthInformation = function (e) { throw new Error("This function is not available in Babylon Native") }, e }(); Vd("NativeXRFrame", HR), function (e) { e[e.Input = 0] = "Input", e[e.Output = 1] = "Output" }(zR || (zR = {})); var XR = function () { function e(e, t, i) { this.name = e, this._type = t, this._ownerBlock = i, this._connectedPoint = null } return Object.defineProperty(e.prototype, "type", { get: function () { return this._type }, enumerable: !1, configurable: !0 }), e.prototype.connectTo = function (e) { if (this._type === e._type) throw new Error("Cannot connect two points of type ".concat(this.type)); this._connectedPoint = e, e._connectedPoint = this }, e }(), jR = function (e) { function t(t, i, r, n) { var o = e.call(this, t, i, r) || this; return o._value = n, o } return W(t, e), Object.defineProperty(t.prototype, "value", { get: function () { return this.type === zR.Output ? (this._ownerBlock._updateOutputs(), this._value) : this._connectedPoint ? this._connectedPoint.value : this._value }, set: function (e) { this._value = e }, enumerable: !1, configurable: !0 }), t }(XR), YR = function () { function e(e) { this.dataInputs = [], this.dataOutputs = [], this._graph = e, this._graph._addBlock(this) } return e.prototype._updateOutputs = function () { }, e.prototype._registerDataInput = function (e, t) { var i = new jR(e, zR.Input, this, t); return this.dataInputs.push(i), i }, e.prototype._registerDataOutput = function (e, t) { var i = new jR(e, zR.Output, this, t); return this.dataOutputs.push(i), i }, e }(), KR = function (e) { function t() { return null !== e && e.apply(this, arguments) || this } return W(t, e), t.prototype._activateSignal = function () { var e; this.type === zR.Input ? this._ownerBlock._execute() : null === (e = this._connectedPoint) || void 0 === e || e._activateSignal() }, t }(XR), QR = function (e) { function t(t) { var i = e.call(this, t) || this; return i._signalInputs = [], i._signalOutputs = [], i.onStart = i._registerSignalInput("onStart"), i } return W(t, e), t.prototype._registerSignalInput = function (e) { var t = new KR(e, zR.Input, this); return this._signalInputs.push(t), t }, t.prototype._registerSignalOutput = function (e) { var t = new KR(e, zR.Output, this); return this._signalOutputs.push(t), t }, t }(YR), qR = function (e) { function t(t) { var i = e.call(this, t) || this; return i.onDone = i._registerSignalOutput("onDone"), i } return W(t, e), t }(QR), ZR = function (e) { function t() { return null !== e && e.apply(this, arguments) || this } return W(t, e), t.prototype._execute = function () { this.onDone._activateSignal() }, t }(qR), JR = function () { function e(e) { this._scene = e, this._blocks = [], this._sceneDisposeObserver = this._scene.onDisposeObservable.add(this.dispose.bind(this)) } return e.prototype._addBlock = function (e) { this._blocks.push(e) }, e.prototype.findBlockByName = function (e) { return this._blocks.find((function (t) { return t.name === e })) }, e.prototype.start = function () { for (var e = 0, t = this._blocks; e < t.length; e++) { var i = t[e]; i instanceof ZR && i._startListening() } }, e.prototype.dispose = function () { for (var e = 0, t = this._blocks; e < t.length; e++) { var i = t[e]; i instanceof ZR && i._stopListening() } this._blocks.length = 0, this._scene.onDisposeObservable.remove(this._sceneDisposeObserver), this._sceneDisposeObserver = null }, e }(), $R = function (e) { function t(t) { var i = e.call(this, t) || this; return i._currentIndex = 0, i._cachedEndIndex = 0, i._cachedStep = 0, i.startIndex = i._registerDataInput("startIndex", 0), i.endIndex = i._registerDataInput("endIndex", 0), i.step = i._registerDataInput("step", 1), i.index = i._registerDataOutput("index", 0), i.onLoop = i._registerSignalOutput("onLoop"), i.onDone = i._registerSignalOutput("onDone"), i } return W(t, e), t.prototype._executeLoop = function () { this._currentIndex < this._cachedEndIndex ? (this.index.value = this._currentIndex, this.onLoop._activateSignal(), this._currentIndex += this._cachedStep, this._executeLoop()) : this.onDone._activateSignal() }, t.prototype._execute = function () { this._currentIndex = this.startIndex.value, this._cachedEndIndex = this.endIndex.value, this._cachedStep = this.step.value, this._executeLoop() }, t }(qR), eC = function (e) { function t(t) { var i = e.call(this, t) || this; return i.message = i._registerDataInput("message", "Hello world"), i } return W(t, e), t.prototype._execute = function () { var e = this.message.value; console.log(e), this.onDone._activateSignal() }, t }(qR), tC = function (e) { function t(t) { return e.call(this, t, 0, 0, (function (e, t) { return e + t })) || this } return W(t, e), t }(function (e) { function t(t, i, r, n) { var o = e.call(this, t) || this; return o._binOp = n, o.left = o._registerDataInput("left", i), o.right = o._registerDataInput("right", r), o.output = o._registerDataOutput("output", n(i, r)), o } return W(t, e), t.prototype._updateOutputs = function () { this.output.value = this._binOp(this.left.value, this.right.value) }, t }(YR)), iC = function (e) { function t(t, i) { var r = e.call(this, t) || this; return r._meshToPick = i, r } return W(t, e), Object.defineProperty(t.prototype, "meshToPick", { get: function () { return this._meshToPick }, set: function (e) { if (this._meshToPick !== e) { var t = !!this._meshPickObserver; t && this._stopListening(), this._meshToPick = e, t && this._startListening() } }, enumerable: !1, configurable: !0 }), t.prototype._startListening = function () { var e = this; this._meshPickObserver || (this._meshPickObserver = this._meshToPick.getScene().onPointerObservable.add((function (t) { var i; t.type === Ji.POINTERPICK && (null === (i = t.pickInfo) || void 0 === i ? void 0 : i.pickedMesh) === e._meshToPick && e._execute() })), this._meshDisposeObserver = this._meshToPick.onDisposeObservable.add((function () { return e._stopListening() }))) }, t.prototype._stopListening = function () { this._meshToPick.getScene().onPointerObservable.remove(this._meshPickObserver), this._meshPickObserver = null, this._meshToPick.onDisposeObservable.remove(this._meshDisposeObserver), this._meshDisposeObserver = null }, t }(ZR), rC = function (e) { function t(t, i) { var r = e.call(this, t) || this; return r._scene = i, r } return W(t, e), t.prototype._startListening = function () { var e = this; this._sceneReadyObserver || (this._sceneReadyObserver = this._scene.onReadyObservable.add((function () { e._execute() }))) }, t.prototype._stopListening = function () { this._scene.onReadyObservable.remove(this._sceneReadyObserver), this._sceneReadyObserver = null }, t }(ZR), nC = void 0 !== e.g ? e.g : "undefined" != typeof window ? window : void 0; if (void 0 !== nC) { nC.BABYLON = nC.BABYLON || {}; var oC = nC.BABYLON; if (!oC.Debug) for (var aC in oC.Debug = oC.Debug || {}, i) oC.Debug[aC] || (oC.Debug[aC] = i[aC]); for (var aC in r) oC[aC] || (oC[aC] = r[aC]) } var sC = { AxesViewer: du, BoneAxesViewer: pu, PhysicsViewer: Bh, SkeletonViewer: Vh }; const lC = n; return t.default })())); +//# sourceMappingURL=babylon.js.map \ No newline at end of file diff --git a/COMETwebapp/wwwroot/Scripts/BabylonJS/babylonjs.loaders.min.js b/COMETwebapp/wwwroot/Scripts/BabylonJS/babylonjs.loaders.min.js new file mode 100644 index 00000000..2f03614c --- /dev/null +++ b/COMETwebapp/wwwroot/Scripts/BabylonJS/babylonjs.loaders.min.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-loaders",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-loaders"]=t(require("babylonjs")):e.LOADERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(e=>(()=>{"use strict";var t={520:t=>{t.exports=e}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,r),a.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{r.d(o,{default:()=>Wt});var e={};r.r(e),r.d(e,{GLTFValidation:()=>y});var t={};r.r(t),r.d(t,{GLTFFileLoader:()=>v,GLTFLoaderAnimationStartMode:()=>_,GLTFLoaderCoordinateSystemMode:()=>p,GLTFLoaderState:()=>m});var n={};r.r(n),r.d(n,{EBlendingFunction:()=>C,EComponentType:()=>T,ECullingType:()=>w,EParameterType:()=>E,EShaderType:()=>x,ETextureFilterType:()=>M,ETextureFormat:()=>L,ETextureWrapMode:()=>O,GLTFBinaryExtension:()=>ne,GLTFLoader:()=>ee,GLTFLoaderBase:()=>$,GLTFLoaderExtension:()=>te,GLTFMaterialsCommonExtension:()=>re,GLTFUtils:()=>P});var a={};r.r(a);var i={};r.r(i),r.d(i,{EXT_lights_image_based:()=>fe,EXT_mesh_gpu_instancing:()=>_e,EXT_meshopt_compression:()=>ye,EXT_texture_webp:()=>ve,ExtrasAsMetadata:()=>wt,KHR_animation_pointer:()=>gt,KHR_draco_mesh_compression:()=>Ae,KHR_lights:()=>xe,KHR_materials_anisotropy:()=>Re,KHR_materials_clearcoat:()=>Ce,KHR_materials_emissive_strength:()=>Fe,KHR_materials_ior:()=>Ue,KHR_materials_iridescence:()=>Ne,KHR_materials_pbrSpecularGlossiness:()=>Oe,KHR_materials_sheen:()=>De,KHR_materials_specular:()=>ke,KHR_materials_translucency:()=>Xe,KHR_materials_transmission:()=>Ye,KHR_materials_unlit:()=>Le,KHR_materials_variants:()=>He,KHR_materials_volume:()=>Ze,KHR_mesh_quantization:()=>Je,KHR_texture_basisu:()=>et,KHR_texture_transform:()=>nt,KHR_xmp_json_ld:()=>ot,MSFT_audio_emitter:()=>bt,MSFT_lod:()=>Tt,MSFT_minecraftMesh:()=>Et,MSFT_sRGBFactors:()=>Mt});var s={};r.r(s),r.d(s,{ArrayItem:()=>ue,EXT_lights_image_based:()=>fe,EXT_mesh_gpu_instancing:()=>_e,EXT_meshopt_compression:()=>ye,EXT_texture_webp:()=>ve,ExtrasAsMetadata:()=>wt,GLTFLoader:()=>de,KHR_animation_pointer:()=>gt,KHR_draco_mesh_compression:()=>Ae,KHR_lights:()=>xe,KHR_materials_anisotropy:()=>Re,KHR_materials_clearcoat:()=>Ce,KHR_materials_emissive_strength:()=>Fe,KHR_materials_ior:()=>Ue,KHR_materials_iridescence:()=>Ne,KHR_materials_pbrSpecularGlossiness:()=>Oe,KHR_materials_sheen:()=>De,KHR_materials_specular:()=>ke,KHR_materials_translucency:()=>Xe,KHR_materials_transmission:()=>Ye,KHR_materials_unlit:()=>Le,KHR_materials_variants:()=>He,KHR_materials_volume:()=>Ze,KHR_mesh_quantization:()=>Je,KHR_texture_basisu:()=>et,KHR_texture_transform:()=>nt,KHR_xmp_json_ld:()=>ot,MSFT_audio_emitter:()=>bt,MSFT_lod:()=>Tt,MSFT_minecraftMesh:()=>Et,MSFT_sRGBFactors:()=>Mt});var l={};r.r(l),r.d(l,{MTLFileLoader:()=>Ct,OBJFileLoader:()=>Nt,SolidParser:()=>St});var c={};r.r(c),r.d(c,{STLFileLoader:()=>Pt});var u={};r.r(u),r.d(u,{GLTF1:()=>n,GLTF2:()=>s,GLTFFileLoader:()=>v,GLTFLoaderAnimationStartMode:()=>_,GLTFLoaderCoordinateSystemMode:()=>p,GLTFLoaderState:()=>m,GLTFValidation:()=>y,MTLFileLoader:()=>Ct,OBJFileLoader:()=>Nt,STLFileLoader:()=>Pt,SolidParser:()=>St});var d=r(520);function h(e,t,n,r){var o={externalResourceFunction:function(e){return r(e).then((function(e){return new Uint8Array(e)}))}};return n&&(o.uri="file:"===t?n:t+n),e instanceof ArrayBuffer?GLTFValidator.validateBytes(new Uint8Array(e),o):GLTFValidator.validateString(e,o)}function f(){var e=[];onmessage=function(t){var n=t.data;switch(n.id){case"init":importScripts(n.url);break;case"validate":h(n.data,n.rootUrl,n.fileName,(function(t){return new Promise((function(n,r){var o=e.length;e.push({resolve:n,reject:r}),postMessage({id:"getExternalResource",index:o,uri:t})}))})).then((function(e){postMessage({id:"validate.resolve",value:e})}),(function(e){postMessage({id:"validate.reject",reason:e})}));break;case"getExternalResource.resolve":e[n.index].resolve(n.value);break;case"getExternalResource.reject":e[n.index].reject(n.reason)}}}var p,_,m,y=function(){function e(){}return e.ValidateAsync=function(e,t,n,r){var o=this,a=ArrayBuffer.isView(e)?e.slice().buffer:e;return"function"==typeof Worker?new Promise((function(e,i){var s="".concat(h,"(").concat(f,")()"),l=URL.createObjectURL(new Blob([s],{type:"application/javascript"})),c=new Worker(l),u=function(e){c.removeEventListener("error",u),c.removeEventListener("message",d),i(e)},d=function(t){var n=t.data;switch(n.id){case"getExternalResource":r(n.uri).then((function(e){c.postMessage({id:"getExternalResource.resolve",index:n.index,value:e},[e])}),(function(e){c.postMessage({id:"getExternalResource.reject",index:n.index,reason:e})}));break;case"validate.resolve":c.removeEventListener("error",u),c.removeEventListener("message",d),e(n.value),c.terminate();break;case"validate.reject":c.removeEventListener("error",u),c.removeEventListener("message",d),i(n.reason),c.terminate()}};c.addEventListener("error",u),c.addEventListener("message",d),c.postMessage({id:"init",url:o.Configuration.url}),c.postMessage({id:"validate",data:a,rootUrl:t,fileName:n})})):(this._LoadScriptPromise||(this._LoadScriptPromise=d.Tools.LoadScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then((function(){return h(a,t,n,r)})))},e.Configuration={url:"https://preview.babylonjs.com/gltf_validator.js"},e}();function g(e,t,n){try{return Promise.resolve(new Uint8Array(e,t,n))}catch(e){return Promise.reject(e)}}!function(e){e[e.AUTO=0]="AUTO",e[e.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED"}(p||(p={})),function(e){e[e.NONE=0]="NONE",e[e.FIRST=1]="FIRST",e[e.ALL=2]="ALL"}(_||(_={})),function(e){e[e.LOADING=0]="LOADING",e[e.READY=1]="READY",e[e.COMPLETE=2]="COMPLETE"}(m||(m={}));var v=function(){function e(){this.onParsedObservable=new d.Observable,this.coordinateSystemMode=p.AUTO,this.animationStartMode=_.FIRST,this.compileMaterials=!1,this.useClipPlane=!1,this.compileShadowGenerators=!1,this.transparencyAsCoverage=!1,this.useRangeRequests=!1,this.createInstances=!0,this.alwaysComputeBoundingBox=!1,this.loadAllMaterials=!1,this.loadOnlyMaterials=!1,this.skipMaterials=!1,this.useSRGBBuffers=!0,this.targetFps=60,this.alwaysComputeSkeletonRootNode=!1,this.preprocessUrlAsync=function(e){return Promise.resolve(e)},this.onMeshLoadedObservable=new d.Observable,this.onSkinLoadedObservable=new d.Observable,this.onTextureLoadedObservable=new d.Observable,this.onMaterialLoadedObservable=new d.Observable,this.onCameraLoadedObservable=new d.Observable,this.onCompleteObservable=new d.Observable,this.onErrorObservable=new d.Observable,this.onDisposeObservable=new d.Observable,this.onExtensionLoadedObservable=new d.Observable,this.validate=!1,this.onValidatedObservable=new d.Observable,this._loader=null,this._state=null,this._requests=new Array,this.name="gltf",this.extensions={".gltf":{isBinary:!1},".glb":{isBinary:!0}},this.onLoaderStateChangedObservable=new d.Observable,this._logIndentLevel=0,this._loggingEnabled=!1,this._log=this._logDisabled,this._capturePerformanceCounters=!1,this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled}return Object.defineProperty(e.prototype,"onParsed",{set:function(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),this._onParsedObserver=this.onParsedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMeshLoaded",{set:function(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onTextureLoaded",{set:function(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMaterialLoaded",{set:function(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onCameraLoaded",{set:function(e){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{set:function(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{set:function(e){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(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,"onExtensionLoaded",{set:function(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loggingEnabled",{get:function(){return this._loggingEnabled},set:function(e){this._loggingEnabled!==e&&(this._loggingEnabled=e,this._loggingEnabled?this._log=this._logEnabled:this._log=this._logDisabled)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"capturePerformanceCounters",{get:function(){return this._capturePerformanceCounters},set:function(e){this._capturePerformanceCounters!==e&&(this._capturePerformanceCounters=e,this._capturePerformanceCounters?(this._startPerformanceCounter=this._startPerformanceCounterEnabled,this._endPerformanceCounter=this._endPerformanceCounterEnabled):(this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onValidated",{set:function(e){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(e)},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this._loader&&(this._loader.dispose(),this._loader=null);for(var e=0,t=this._requests;ee.byteLength)throw new Error("Array length out of bounds.");return Promise.resolve(new Uint8Array(e.buffer,e.byteOffset+t,n))}catch(e){return Promise.reject(e)}}(t,e,n)},byteLength:t.byteLength})).then((function(e){r(e)}),o?function(e){return o(void 0,e)}:void 0)},e.prototype.importMeshAsync=function(e,t,n,r,o,a){var i=this;return Promise.resolve().then((function(){return i.onParsedObservable.notifyObservers(n),i.onParsedObservable.clear(),i._log("Loading ".concat(a||"")),i._loader=i._getLoader(n),i._loader.importMeshAsync(e,t,null,n,r,o,a)}))},e.prototype.loadAsync=function(e,t,n,r,o){var a=this;return Promise.resolve().then((function(){return a.onParsedObservable.notifyObservers(t),a.onParsedObservable.clear(),a._log("Loading ".concat(o||"")),a._loader=a._getLoader(t),a._loader.loadAsync(e,t,n,r,o)}))},e.prototype.loadAssetContainerAsync=function(e,t,n,r,o){var a=this;return Promise.resolve().then((function(){a.onParsedObservable.notifyObservers(t),a.onParsedObservable.clear(),a._log("Loading ".concat(o||"")),a._loader=a._getLoader(t);var i=new d.AssetContainer(e),s=[];a.onMaterialLoadedObservable.add((function(e){s.push(e)}));var l=[];a.onTextureLoadedObservable.add((function(e){l.push(e)}));var c=[];a.onCameraLoadedObservable.add((function(e){c.push(e)}));var u=[];return a.onMeshLoadedObservable.add((function(e){e.morphTargetManager&&u.push(e.morphTargetManager)})),a._loader.importMeshAsync(null,e,i,t,n,r,o).then((function(e){return Array.prototype.push.apply(i.geometries,e.geometries),Array.prototype.push.apply(i.meshes,e.meshes),Array.prototype.push.apply(i.particleSystems,e.particleSystems),Array.prototype.push.apply(i.skeletons,e.skeletons),Array.prototype.push.apply(i.animationGroups,e.animationGroups),Array.prototype.push.apply(i.materials,s),Array.prototype.push.apply(i.textures,l),Array.prototype.push.apply(i.lights,e.lights),Array.prototype.push.apply(i.transformNodes,e.transformNodes),Array.prototype.push.apply(i.cameras,c),Array.prototype.push.apply(i.morphTargetManagers,u),i}))}))},e.prototype.canDirectLoad=function(t){return-1!==t.indexOf("asset")&&-1!==t.indexOf("version")||t.startsWith("data:base64,"+e._MagicBase64Encoded)||t.startsWith("data:;base64,"+e._MagicBase64Encoded)||t.startsWith("data:application/octet-stream;base64,"+e._MagicBase64Encoded)||t.startsWith("data:model/gltf-binary;base64,"+e._MagicBase64Encoded)},e.prototype.directLoad=function(t,n){if(n.startsWith("base64,"+e._MagicBase64Encoded)||n.startsWith(";base64,"+e._MagicBase64Encoded)||n.startsWith("application/octet-stream;base64,"+e._MagicBase64Encoded)||n.startsWith("model/gltf-binary;base64,"+e._MagicBase64Encoded)){var r=(0,d.DecodeBase64UrlToBinary)(n);return this._validate(t,new Uint8Array(r)),this._unpackBinaryAsync(new d.DataReader({readAsync:function(e,t){return g(r,e,t)},byteLength:r.byteLength}))}return this._validate(t,n),Promise.resolve({json:this._parseJson(n)})},e.prototype.createPlugin=function(){return new e},Object.defineProperty(e.prototype,"loaderState",{get:function(){return this._state},enumerable:!1,configurable:!0}),e.prototype.whenCompleteAsync=function(){var e=this;return new Promise((function(t,n){e.onCompleteObservable.addOnce((function(){t()})),e.onErrorObservable.addOnce((function(e){n(e)}))}))},e.prototype._setState=function(e){this._state!==e&&(this._state=e,this.onLoaderStateChangedObservable.notifyObservers(this._state),this._log(m[this._state]))},e.prototype._loadFile=function(e,t,n,r,o,a){var i=this,s=e._loadFile(t,n,(function(e){i._onProgress(e,s)}),!0,r,o,a);return s.onCompleteObservable.add((function(e){i._requests.splice(i._requests.indexOf(e),1)})),this._requests.push(s),s},e.prototype._onProgress=function(e,t){if(this._progressCallback){t._lengthComputable=e.lengthComputable,t._loaded=e.loaded,t._total=e.total;for(var n=!0,r=0,o=0,a=0,i=this._requests;a0)throw new Error("Incompatible minimum version: "+n.minVersion)}var a={1:e._CreateGLTF1Loader,2:e._CreateGLTF2Loader}[r.major];if(!a)throw new Error("Unsupported version: "+n.version);return a(this)},e.prototype._parseJson=function(e){this._startPerformanceCounter("Parse JSON"),this._log("JSON length: ".concat(e.length));var t=JSON.parse(e);return this._endPerformanceCounter("Parse JSON"),t},e.prototype._unpackBinaryAsync=function(e){var t=this;return this._startPerformanceCounter("Unpack Binary"),e.loadAsync(20).then((function(){var n=e.readUint32();if(1179937895!==n)throw new d.RuntimeError("Unexpected magic: "+n,d.ErrorCodes.GLTFLoaderUnexpectedMagicError);var r=e.readUint32();t.loggingEnabled&&t._log("Binary version: ".concat(r));var o,a=e.readUint32();switch(t.useRangeRequests||a===e.buffer.byteLength||d.Logger.Warn("Length in header does not match actual data length: ".concat(a," != ").concat(e.buffer.byteLength)),r){case 1:o=t._unpackBinaryV1Async(e,a);break;case 2:o=t._unpackBinaryV2Async(e,a);break;default:throw new Error("Unsupported version: "+r)}return t._endPerformanceCounter("Unpack Binary"),o}))},e.prototype._unpackBinaryV1Async=function(e,t){var n=e.readUint32(),r=e.readUint32();if(0!==r)throw new Error("Unexpected content format: ".concat(r));var o=t-e.byteOffset,a={json:this._parseJson(e.readString(n)),bin:null};if(0!==o){var i=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(i+t,n)},byteLength:o}}return Promise.resolve(a)},e.prototype._unpackBinaryV2Async=function(e,t){var n=this,r=1313821514,o=e.readUint32();if(e.readUint32()!==r)throw new Error("First chunk format is not JSON");return e.byteOffset+o===t?e.loadAsync(o).then((function(){return{json:n._parseJson(e.readString(o)),bin:null}})):e.loadAsync(o+8).then((function(){var a={json:n._parseJson(e.readString(o)),bin:null},i=function(){var n=e.readUint32();switch(e.readUint32()){case r:throw new Error("Unexpected JSON chunk");case 5130562:var o=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(o+t,n)},byteLength:n},e.skipBytes(n);break;default:e.skipBytes(n)}return e.byteOffset!==t?e.loadAsync(8).then(i):Promise.resolve(a)};return i()}))},e._parseVersion=function(e){if("1.0"===e||"1.0.1"===e)return{major:1,minor:0};var t=(e+"").match(/^(\d+)\.(\d+)/);return t?{major:parseInt(t[1]),minor:parseInt(t[2])}:null},e._compareVersion=function(e,t){return e.major>t.major?1:e.majort.minor?1:e.minora.byteLength)throw new Error("Buffer access is out of range");var i=a.buffer;switch(n+=a.byteOffset,o){case T.BYTE:return new Int8Array(i,n,r);case T.UNSIGNED_BYTE:return new Uint8Array(i,n,r);case T.SHORT:return new Int16Array(i,n,r);case T.UNSIGNED_SHORT:return new Uint16Array(i,n,r);default:return new Float32Array(i,n,r)}},e.GetBufferFromAccessor=function(t,n){var r=t.bufferViews[n.bufferView],o=n.count*e.GetByteStrideFromType(n);return e.GetBufferFromBufferView(t,r,n.byteOffset,o,n.componentType)},e.DecodeBufferToText=function(e){for(var t="",n=e.byteLength,r=0;r=this._maxPos},e}(),I=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],F=["world","view","projection","worldView","worldViewProjection","mBones"],B=["translation","rotation","scale"],D=["position","rotationQuaternion","scaling"],V=function(e,t,n){for(var r in e){var o=e[r];n[t][r]=o}},k=function(e){if(e)for(var t=0;t1?(a=new d.MultiMaterial("multimat"+r,e.scene)).subMaterials=i:a=new d.StandardMaterial("multimat"+r,e.scene),1===i.length&&(a=i[0]),a._parentContainer=e.assetContainer,o.material||(o.material=a),new d.Geometry(r,e.scene,s,!1,o),o.computeWorldMatrix(!0),e.scene._blockEntityCollection=!1,o.subMeshes=[];var C=0;for(f=0;f0&&-1===e.importMeshesNames.indexOf(t.name||""))return null;if(t.skin){if(t.meshes){var o=e.skins[t.skin];(a=Y(e,t,t.meshes,n,t.babylonNode)).skeleton=e.scene.getLastSkeletonById(t.skin),null===a.skeleton&&(a.skeleton=function(e,t,n,r){if(r||(r=new d.Skeleton(t.name||"","",e.scene)),!t.babylonSkeleton)return r;var o=[],a=[];!function(e,t,n,r){for(var o in e.nodes){var a=e.nodes[o],i=o;if(a.jointName&&!W(n,a.jointName)){var s=U(a),l=new d.Bone(a.name||"",t,null,s);l.id=i,r.push({bone:l,node:a,id:i})}}for(var c=0;c0&&(h=H(o,l))&&-1===a.indexOf(h)&&a.push(h),new d.Bone(s.jointName||"",r,h,g).id=l}}else d.Tools.Warn("Joint named "+t.jointNames[i]+" does not exist")}var v=r.bones;for(r.bones=[],i=0;i ").concat(m[m.READY]),i="".concat(m[m.LOADING]," => ").concat(m[m.COMPLETE]);o._parent._startPerformanceCounter(a),o._parent._startPerformanceCounter(i),o._parent._setState(m.LOADING),o._extensionsOnLoading();var s=new Array,l=o._babylonScene.blockMaterialDirtyMechanism;if(o._babylonScene.blockMaterialDirtyMechanism=!0,!o.parent.loadOnlyMaterials)if(n)s.push(o.loadSceneAsync("/nodes",{nodes:n,index:-1}));else if(null!=o._gltf.scene||o._gltf.scenes&&o._gltf.scenes[0]){var c=ue.Get("/scene",o._gltf.scenes,o._gltf.scene||0);s.push(o.loadSceneAsync("/scenes/".concat(c.index),c))}if(!o.parent.skipMaterials&&o.parent.loadAllMaterials&&o._gltf.materials)for(var u=0;ue.bin.byteLength)&&d.Logger.Warn("Binary buffer length (".concat(n.byteLength,") from JSON does not match chunk length (").concat(e.bin.byteLength,")")),this._bin=e.bin}else d.Logger.Warn("Unexpected BIN chunk")}},e.prototype._setupData=function(){if(ue.Assign(this._gltf.accessors),ue.Assign(this._gltf.animations),ue.Assign(this._gltf.buffers),ue.Assign(this._gltf.bufferViews),ue.Assign(this._gltf.cameras),ue.Assign(this._gltf.images),ue.Assign(this._gltf.materials),ue.Assign(this._gltf.meshes),ue.Assign(this._gltf.nodes),ue.Assign(this._gltf.samplers),ue.Assign(this._gltf.scenes),ue.Assign(this._gltf.skins),ue.Assign(this._gltf.textures),this._gltf.nodes){for(var e={},t=0,n=this._gltf.nodes;t=(i=n[t[0]]).length)return l;s=i[c];for(var u=1;u=(i=n[t[u]]).length||s!==i[c])return l;l=s}},e.prototype._loadBone=function(e,t,n,r){var o=r[e.index];if(o)return o;var a=null;e.index!==t.skeleton&&(e.parent&&-1!==e.parent.index?a=this._loadBone(e.parent,t,n,r):void 0!==t.skeleton&&d.Logger.Warn("/skins/".concat(t.index,"/skeleton: Skeleton node is not a common root")));var i=t.joints.indexOf(e.index);return o=new d.Bone(e.name||"joint".concat(e.index),n,a,this._getNodeMatrix(e),null,null,i),r[e.index]=o,this._postSceneLoadActions.push((function(){o.linkTransformNode(e._babylonTransformNode)})),o},e.prototype._loadSkinInverseBindMatricesDataAsync=function(e,t){if(null==t.inverseBindMatrices)return Promise.resolve(null);var n=ue.Get("".concat(e,"/inverseBindMatrices"),this._gltf.accessors,t.inverseBindMatrices);return this._loadFloatAccessorAsync("/accessors/".concat(n.index),n)},e.prototype._updateBoneMatrices=function(e,t){for(var n=0,r=e.bones;n0){var A="".concat(n.name||"animation".concat(n.index),"_channel").concat(r.index,"_").concat(t);u.buildAnimations(o.target,A,i,_,(function(e,n){++t,a(e,n)}))}}}))},e.prototype._loadAnimationSamplerAsync=function(e,t){if(t._data)return t._data;var n=t.interpolation||"LINEAR";switch(n){case"STEP":case"LINEAR":case"CUBICSPLINE":break;default:throw new Error("".concat(e,"/interpolation: Invalid value (").concat(t.interpolation,")"))}var r=ue.Get("".concat(e,"/input"),this._gltf.accessors,t.input),o=ue.Get("".concat(e,"/output"),this._gltf.accessors,t.output);return t._data=Promise.all([this._loadFloatAccessorAsync("/accessors/".concat(r.index),r),this._loadFloatAccessorAsync("/accessors/".concat(o.index),o)]).then((function(e){var t=e[0],r=e[1];return{input:t,interpolation:n,output:r}})),t._data},e.prototype.loadBufferAsync=function(e,t,n,r){var o=this._extensionsLoadBufferAsync(e,t,n,r);if(o)return o;if(!t._data)if(t.uri)t._data=this.loadUriAsync("".concat(e,"/uri"),t,t.uri);else{if(!this._bin)throw new Error("".concat(e,": Uri is missing or the binary glTF is missing its binary chunk"));t._data=this._bin.readAsync(0,t.byteLength)}return t._data.then((function(t){try{return new Uint8Array(t.buffer,t.byteOffset+n,r)}catch(t){throw new Error("".concat(e,": ").concat(t.message))}}))},e.prototype.loadBufferViewAsync=function(e,t){var n=this._extensionsLoadBufferViewAsync(e,t);if(n)return n;if(t._data)return t._data;var r=ue.Get("".concat(e,"/buffer"),this._gltf.buffers,t.buffer);return t._data=this.loadBufferAsync("/buffers/".concat(r.index),r,t.byteOffset||0,t.byteLength),t._data},e.prototype._loadAccessorAsync=function(t,n,r){var o=this;if(n._data)return n._data;var a=e._GetNumComponents(t,n.type),i=a*d.VertexBuffer.GetTypeByteLength(n.componentType),s=a*n.count;if(null==n.bufferView)n._data=Promise.resolve(new r(s));else{var l=ue.Get("".concat(t,"/bufferView"),this._gltf.bufferViews,n.bufferView);n._data=this.loadBufferViewAsync("/bufferViews/".concat(l.index),l).then((function(o){if(5126!==n.componentType||n.normalized||l.byteStride&&l.byteStride!==i){var c=new r(s);return d.VertexBuffer.ForEach(o,n.byteOffset||0,l.byteStride||i,a,n.componentType,c.length,n.normalized||!1,(function(e,t){c[t]=e})),c}return e._GetTypedArray(t,n.componentType,o,n.byteOffset,s)}))}if(n.sparse){var c=n.sparse;n._data=n._data.then((function(s){var l=s,u=ue.Get("".concat(t,"/sparse/indices/bufferView"),o._gltf.bufferViews,c.indices.bufferView),h=ue.Get("".concat(t,"/sparse/values/bufferView"),o._gltf.bufferViews,c.values.bufferView);return Promise.all([o.loadBufferViewAsync("/bufferViews/".concat(u.index),u),o.loadBufferViewAsync("/bufferViews/".concat(h.index),h)]).then((function(o){var s,u=o[0],h=o[1],f=e._GetTypedArray("".concat(t,"/sparse/indices"),c.indices.componentType,u,c.indices.byteOffset,c.count),p=a*c.count;if(5126!==n.componentType||n.normalized){var _=e._GetTypedArray("".concat(t,"/sparse/values"),n.componentType,h,c.values.byteOffset,p);s=new r(p),d.VertexBuffer.ForEach(_,0,i,a,n.componentType,s.length,n.normalized||!1,(function(e,t){s[t]=e}))}else s=e._GetTypedArray("".concat(t,"/sparse/values"),n.componentType,h,c.values.byteOffset,p);for(var m=0,y=0;y=6)throw new Error("".concat(t,"/texCoord: Invalid value (").concat(n.texCoord,")"));var i=ue.Get("".concat(t,"/index"),this._gltf.textures,n.index);i._textureInfo=n;var s=this._loadTextureAsync("/textures/".concat(n.index),i,(function(a){a.coordinatesIndex=n.texCoord||0,e.AddPointerMetadata(a,t),o._parent.onTextureLoadedObservable.notifyObservers(a),r(a)}));return this.logClose(),s},e.prototype._loadTextureAsync=function(t,n,r){void 0===r&&(r=function(){});var o=this._extensionsLoadTextureAsync(t,n,r);if(o)return o;this.logOpen("".concat(t," ").concat(n.name||""));var a=null==n.sampler?e.DefaultSampler:ue.Get("".concat(t,"/sampler"),this._gltf.samplers,n.sampler),i=ue.Get("".concat(t,"/source"),this._gltf.images,n.source),s=this._createTextureAsync(t,a,i,r,void 0,!n._textureInfo.nonColorData);return this.logClose(),s},e.prototype._createTextureAsync=function(e,t,n,r,o,a){var i=this;void 0===r&&(r=function(){});var s=this._loadSampler("/samplers/".concat(t.index),t),l=new Array,c=new d.Deferred;this._babylonScene._blockEntityCollection=!!this._assetContainer;var u={noMipmap:s.noMipMaps,invertY:!1,samplingMode:s.samplingMode,onLoad:function(){i._disposed||c.resolve()},onError:function(t,n){i._disposed||c.reject(new Error("".concat(e,": ").concat(n&&n.message?n.message:t||"Failed to load texture")))},mimeType:n.mimeType,loaderOptions:o,useSRGBBuffer:!!a&&this._parent.useSRGBBuffers},h=new d.Texture(null,this._babylonScene,u);return h._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,l.push(c.promise),l.push(this.loadImageAsync("/images/".concat(n.index),n).then((function(e){var t=n.uri||"".concat(i._fileName,"#image").concat(n.index),r="data:".concat(i._uniqueRootUrl).concat(t);h.updateURL(r,e)}))),h.wrapU=s.wrapU,h.wrapV=s.wrapV,r(h),Promise.all(l).then((function(){return h}))},e.prototype._loadSampler=function(t,n){return n._data||(n._data={noMipMaps:9728===n.minFilter||9729===n.minFilter,samplingMode:e._GetTextureSamplingMode(t,n),wrapU:e._GetTextureWrapMode("".concat(t,"/wrapS"),n.wrapS),wrapV:e._GetTextureWrapMode("".concat(t,"/wrapT"),n.wrapT)}),n._data},e.prototype.loadImageAsync=function(e,t){if(!t._data){if(this.logOpen("".concat(e," ").concat(t.name||"")),t.uri)t._data=this.loadUriAsync("".concat(e,"/uri"),t,t.uri);else{var n=ue.Get("".concat(e,"/bufferView"),this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync("/bufferViews/".concat(n.index),n)}this.logClose()}return t._data},e.prototype.loadUriAsync=function(t,n,r){var o=this,a=this._extensionsLoadUriAsync(t,n,r);if(a)return a;if(!e._ValidateUri(r))throw new Error("".concat(t,": '").concat(r,"' is invalid"));if((0,d.IsBase64DataUrl)(r)){var i=new Uint8Array((0,d.DecodeBase64UrlToBinary)(r));return this.log("".concat(t,": Decoded ").concat(r.substr(0,64),"... (").concat(i.length," bytes)")),Promise.resolve(i)}return this.log("".concat(t,": Loading ").concat(r)),this._parent.preprocessUrlAsync(this._rootUrl+r).then((function(e){return new Promise((function(n,a){o._parent._loadFile(o._babylonScene,e,(function(e){o._disposed||(o.log("".concat(t,": Loaded ").concat(r," (").concat(e.byteLength," bytes)")),n(new Uint8Array(e)))}),!0,(function(e){a(new d.LoadFileError("".concat(t,": Failed to load '").concat(r,"'").concat(e?": "+e.status+" "+e.statusText:""),e))}))}))}))},e.AddPointerMetadata=function(e,t){e.metadata=e.metadata||{};var n=e._internalMetadata=e._internalMetadata||{},r=n.gltf=n.gltf||{};(r.pointers=r.pointers||[]).push(t)},e._GetTextureWrapMode=function(e,t){switch(t=null==t?10497:t){case 33071:return d.Texture.CLAMP_ADDRESSMODE;case 33648:return d.Texture.MIRROR_ADDRESSMODE;case 10497:return d.Texture.WRAP_ADDRESSMODE;default:return d.Logger.Warn("".concat(e,": Invalid value (").concat(t,")")),d.Texture.WRAP_ADDRESSMODE}},e._GetTextureSamplingMode=function(e,t){var n=null==t.magFilter?9729:t.magFilter,r=null==t.minFilter?9987:t.minFilter;if(9729===n)switch(r){case 9728:return d.Texture.LINEAR_NEAREST;case 9729:return d.Texture.LINEAR_LINEAR;case 9984:return d.Texture.LINEAR_NEAREST_MIPNEAREST;case 9985:return d.Texture.LINEAR_LINEAR_MIPNEAREST;case 9986:return d.Texture.LINEAR_NEAREST_MIPLINEAR;case 9987:return d.Texture.LINEAR_LINEAR_MIPLINEAR;default:return d.Logger.Warn("".concat(e,"/minFilter: Invalid value (").concat(r,")")),d.Texture.LINEAR_LINEAR_MIPLINEAR}else switch(9728!==n&&d.Logger.Warn("".concat(e,"/magFilter: Invalid value (").concat(n,")")),r){case 9728:return d.Texture.NEAREST_NEAREST;case 9729:return d.Texture.NEAREST_LINEAR;case 9984:return d.Texture.NEAREST_NEAREST_MIPNEAREST;case 9985:return d.Texture.NEAREST_LINEAR_MIPNEAREST;case 9986:return d.Texture.NEAREST_NEAREST_MIPLINEAR;case 9987:return d.Texture.NEAREST_LINEAR_MIPLINEAR;default:return d.Logger.Warn("".concat(e,"/minFilter: Invalid value (").concat(r,")")),d.Texture.NEAREST_NEAREST_MIPNEAREST}},e._GetTypedArrayConstructor=function(e,t){switch(t){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5125:return Uint32Array;case 5126:return Float32Array;default:throw new Error("".concat(e,": Invalid component type ").concat(t))}},e._GetTypedArray=function(t,n,r,o,a){var i=r.buffer;o=r.byteOffset+(o||0);var s=e._GetTypedArrayConstructor("".concat(t,"/componentType"),n),l=d.VertexBuffer.GetTypeByteLength(n);return o%l!=0?(d.Logger.Warn("".concat(t,": Copying buffer as byte offset (").concat(o,") is not a multiple of component type byte length (").concat(l,")")),new s(i.slice(o,o+a*l),0)):new s(i,o,a)},e._GetNumComponents=function(e,t){switch(t){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16}throw new Error("".concat(e,": Invalid type (").concat(t,")"))},e._ValidateUri=function(e){return d.Tools.IsBase64(e)||-1===e.indexOf("..")},e._GetDrawMode=function(e,t){switch(null==t&&(t=4),t){case 0:return d.Material.PointListDrawMode;case 1:return d.Material.LineListDrawMode;case 2:return d.Material.LineLoopDrawMode;case 3:return d.Material.LineStripDrawMode;case 4:return d.Material.TriangleFillMode;case 5:return d.Material.TriangleStripDrawMode;case 6:return d.Material.TriangleFanDrawMode}throw new Error("".concat(e,": Invalid mesh primitive mode (").concat(t,")"))},e.prototype._compileMaterialsAsync=function(){var e=this;this._parent._startPerformanceCounter("Compile materials");var t=new Array;if(this._gltf.materials)for(var n=0,r=this._gltf.materials;n=0;a--)if(o.push(ue.Get("".concat(e,"/ids/").concat(r[a]),n,r[a])),o.length===this.maxLODsToLoad)return o;return o.push(t),o},e.prototype._disposeTransformNode=function(e){var t=this,n=new Array,r=e.material;r&&n.push(r);for(var o=0,a=e.getChildMeshes();o0){var n=e.metadata=e.metadata||{};(n.gltf=n.gltf||{}).extras=t.extras}},e.prototype.dispose=function(){this._loader=null},e.prototype.loadNodeAsync=function(e,t,n){var r=this;return this._loader.loadNodeAsync(e,t,(function(e){r._assignExtras(e,t),n(e)}))},e.prototype.loadCameraAsync=function(e,t,n){var r=this;return this._loader.loadCameraAsync(e,t,(function(e){r._assignExtras(e,t),n(e)}))},e.prototype.createMaterial=function(e,t,n){var r=this._loader.createMaterial(e,t,n);return this._assignExtras(r,t),r},e}();de.RegisterExtension(Lt,(function(e){return new wt(e)}));var Ct=function(){function e(){this.materials=[]}return e.prototype.parseMTL=function(t,n,r,o){if(!(n instanceof ArrayBuffer)){for(var a,i=n.split("\n"),s=/\s+/,l=null,c=0;c=0?u.substring(0,h):u;f=f.toLowerCase();var p=h>=0?u.substring(h+1).trim():"";if("newmtl"===f)l&&this.materials.push(l),t._blockEntityCollection=!!o,(l=new d.StandardMaterial(p,t))._parentContainer=o,t._blockEntityCollection=!1;else if("kd"===f&&l)a=p.split(s,3).map(parseFloat),l.diffuseColor=d.Color3.FromArray(a);else if("ka"===f&&l)a=p.split(s,3).map(parseFloat),l.ambientColor=d.Color3.FromArray(a);else if("ks"===f&&l)a=p.split(s,3).map(parseFloat),l.specularColor=d.Color3.FromArray(a);else if("ke"===f&&l)a=p.split(s,3).map(parseFloat),l.emissiveColor=d.Color3.FromArray(a);else if("ns"===f&&l)l.specularPower=parseFloat(p);else if("d"===f&&l)l.alpha=parseFloat(p);else if("map_ka"===f&&l)l.ambientTexture=e._GetTexture(r,p,t);else if("map_kd"===f&&l)l.diffuseTexture=e._GetTexture(r,p,t);else if("map_ks"===f&&l)l.specularTexture=e._GetTexture(r,p,t);else if("map_ns"===f);else if("map_bump"===f&&l){var _=p.split(s),m=_.indexOf("-bm"),y=null;m>=0&&(y=_[m+1],_.splice(m,2)),l.bumpTexture=e._GetTexture(r,_.join(" "),t),l.bumpTexture&&null!==y&&(l.bumpTexture.level=parseFloat(y))}else"map_d"===f&&l&&(l.opacityTexture=e._GetTexture(r,p,t))}}l&&this.materials.push(l)}},e._GetTexture=function(t,n,r){if(!n)return null;var o=t;if("file:"===t){var a=n.lastIndexOf("\\");-1===a&&(a=n.lastIndexOf("/")),o+=a>-1?n.substr(a+1):n}else o+=n;return new d.Texture(o,r,!1,e.INVERT_TEXTURE_Y)},e.INVERT_TEXTURE_Y=!0,e}(),St=function(){function e(e,t,n){this._positions=[],this._normals=[],this._uvs=[],this._colors=[],this._meshesFromObj=[],this._indicesForBabylon=[],this._wrappedPositionForBabylon=[],this._wrappedUvsForBabylon=[],this._wrappedColorsForBabylon=[],this._wrappedNormalsForBabylon=[],this._tuplePosNorm=[],this._curPositionInIndices=0,this._hasMeshes=!1,this._unwrappedPositionsForBabylon=[],this._unwrappedColorsForBabylon=[],this._unwrappedNormalsForBabylon=[],this._unwrappedUVForBabylon=[],this._triangles=[],this._materialNameFromObj="",this._objMeshName="",this._increment=1,this._isFirstMaterial=!0,this._grayColor=new d.Color4(.5,.5,.5,1),this._materialToUse=e,this._babylonMeshesArray=t,this._loadingOptions=n}return e.prototype._isInArray=function(e,t){e[t[0]]||(e[t[0]]={normals:[],idx:[]});var n=e[t[0]].normals.indexOf(t[1]);return-1===n?-1:e[t[0]].idx[n]},e.prototype._isInArrayUV=function(e,t){e[t[0]]||(e[t[0]]={normals:[],idx:[],uv:[]});var n=e[t[0]].normals.indexOf(t[1]);return 1!=n&&t[2]===e[t[0]].uv[n]?e[t[0]].idx[n]:-1},e.prototype._setData=function(e,t,n,r,o,a,i){var s;-1===(s=this._loadingOptions.optimizeWithUV?this._isInArrayUV(this._tuplePosNorm,[e,n,t]):this._isInArray(this._tuplePosNorm,[e,n]))?(this._indicesForBabylon.push(this._wrappedPositionForBabylon.length),this._wrappedPositionForBabylon.push(r),this._wrappedUvsForBabylon.push(o),this._wrappedNormalsForBabylon.push(a),void 0!==i&&this._wrappedColorsForBabylon.push(i),this._tuplePosNorm[e].normals.push(n),this._tuplePosNorm[e].idx.push(this._curPositionInIndices++),this._loadingOptions.optimizeWithUV&&this._tuplePosNorm[e].uv.push(t)):this._indicesForBabylon.push(s)},e.prototype._unwrapData=function(){for(var e=0;e0&&(this._handledMesh=this._meshesFromObj[this._meshesFromObj.length-1],this._unwrapData(),this._indicesForBabylon.reverse(),this._handledMesh.indices=this._indicesForBabylon.slice(),this._handledMesh.positions=this._unwrappedPositionsForBabylon.slice(),this._handledMesh.normals=this._unwrappedNormalsForBabylon.slice(),this._handledMesh.uvs=this._unwrappedUVForBabylon.slice(),this._loadingOptions.importVertexColors&&(this._handledMesh.colors=this._unwrappedColorsForBabylon.slice()),this._indicesForBabylon.length=0,this._unwrappedPositionsForBabylon.length=0,this._unwrappedColorsForBabylon.length=0,this._unwrappedNormalsForBabylon.length=0,this._unwrappedUVForBabylon.length=0)},e.prototype._optimizeNormals=function(e){var t=e.getVerticesData(d.VertexBuffer.PositionKind),n=e.getVerticesData(d.VertexBuffer.NormalKind),r={};if(t&&n){for(var o=0;o=7){var h=parseFloat(u[4]),f=parseFloat(u[5]),p=parseFloat(u[6]);this._colors.push(new d.Color4(h>1?h/255:h,f>1?f/255:f,p>1?p/255:p,7===u.length||void 0===u[7]?1:parseFloat(u[7])))}else this._colors.push(this._grayColor)}else if(null!==(u=e.NormalPattern.exec(c)))this._normals.push(new d.Vector3(parseFloat(u[1]),parseFloat(u[2]),parseFloat(u[3])));else if(null!==(u=e.UVPattern.exec(c)))this._uvs.push(new d.Vector2(parseFloat(u[1])*this._loadingOptions.UVScaling.x,parseFloat(u[2])*this._loadingOptions.UVScaling.y));else if(null!==(u=e.FacePattern3.exec(c)))this._setDataForCurrentFaceWithPattern3(u[1].trim().split(" "),1);else if(null!==(u=e.FacePattern4.exec(c)))this._setDataForCurrentFaceWithPattern4(u[1].trim().split(" "),1);else if(null!==(u=e.FacePattern5.exec(c)))this._setDataForCurrentFaceWithPattern5(u[1].trim().split(" "),1);else if(null!==(u=e.FacePattern2.exec(c)))this._setDataForCurrentFaceWithPattern2(u[1].trim().split(" "),1);else if(null!==(u=e.FacePattern1.exec(c)))this._setDataForCurrentFaceWithPattern1(u[1].trim().split(" "),1);else if(null!==(u=e.LinePattern1.exec(c)))this._setDataForCurrentFaceWithPattern1(u[1].trim().split(" "),0);else if(null!==(u=e.LinePattern2.exec(c)))this._setDataForCurrentFaceWithPattern2(u[1].trim().split(" "),0);else if(null!==(u=e.LinePattern3.exec(c)))this._setDataForCurrentFaceWithPattern3(u[1].trim().split(" "),0);else if(e.GroupDescriptor.test(c)||e.ObjectDescriptor.test(c)){var _={name:c.substring(2).trim(),indices:void 0,positions:void 0,normals:void 0,uvs:void 0,colors:void 0,materialName:this._materialNameFromObj};this._addPreviousObjMesh(),this._meshesFromObj.push(_),this._hasMeshes=!0,this._isFirstMaterial=!0,this._increment=1}else e.UseMtlDescriptor.test(c)?(this._materialNameFromObj=c.substring(7).trim(),this._isFirstMaterial&&this._hasMeshes||(this._addPreviousObjMesh(),_={name:(this._objMeshName||"mesh")+"_mm"+this._increment.toString(),indices:void 0,positions:void 0,normals:void 0,uvs:void 0,colors:void 0,materialName:this._materialNameFromObj},this._increment++,this._meshesFromObj.push(_),this._hasMeshes=!0),this._hasMeshes&&this._isFirstMaterial&&(this._meshesFromObj[this._meshesFromObj.length-1].materialName=this._materialNameFromObj,this._isFirstMaterial=!1)):e.MtlLibGroupDescriptor.test(c)?a(c.substring(7).trim()):e.SmoothDescriptor.test(c)||console.log("Unhandled expression at line : "+c)}if(this._hasMeshes&&(this._handledMesh=this._meshesFromObj[this._meshesFromObj.length-1],this._indicesForBabylon.reverse(),this._unwrapData(),this._handledMesh.indices=this._indicesForBabylon,this._handledMesh.positions=this._unwrappedPositionsForBabylon,this._handledMesh.normals=this._unwrappedNormalsForBabylon,this._handledMesh.uvs=this._unwrappedUVForBabylon,this._loadingOptions.importVertexColors&&(this._handledMesh.colors=this._unwrappedColorsForBabylon)),!this._hasMeshes){var m=null;if(this._indicesForBabylon.length)this._indicesForBabylon.reverse(),this._unwrapData();else{for(var y=0,g=this._positions;y-1;)f.push(p),h=p+1;if(-1===p&&0===f.length)i.materials[u].dispose();else for(var _=0;_-1||(Vt.GLTF2[Gt]=s[Gt])}var Ut=void 0!==r.g?r.g:"undefined"!=typeof window?window:void 0;if(void 0!==Ut)for(var jt in l)Ut.BABYLON[jt]||(Ut.BABYLON[jt]=l[jt]);var Ht=void 0!==r.g?r.g:"undefined"!=typeof window?window:void 0;if(void 0!==Ht)for(var Kt in c)Ht.BABYLON[Kt]||(Ht.BABYLON[Kt]=c[Kt]);const Wt=u})(),o.default})())); +//# sourceMappingURL=babylonjs.loaders.min.js.map \ No newline at end of file diff --git a/COMETwebapp/wwwroot/index.html b/COMETwebapp/wwwroot/index.html index 85f363a4..edd9c5cf 100644 --- a/COMETwebapp/wwwroot/index.html +++ b/COMETwebapp/wwwroot/index.html @@ -66,8 +66,8 @@ - - + +