!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, (function() {
return (()=>{
"use strict";
var e = {
d: (t,i)=>{
for (var n in i)
e.o(i, n) && !e.o(t, n) && Object.defineProperty(t, n, {
enumerable: !0,
get: i[n]
})
}
};
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: ()=>XE
});
var i = {};
e.r(i),
e.d(i, {
AxesViewer: ()=>xl,
BoneAxesViewer: ()=>Rl,
DebugLayer: ()=>Cl,
DebugLayerTab: ()=>bl,
DirectionalLightFrustumViewer: ()=>uc,
PhysicsViewer: ()=>Wl,
RayHelper: ()=>tc,
SkeletonViewer: ()=>cc
});
var n = {};
e.r(n),
e.d(n, {
AbstractActionManager: ()=>s,
AbstractAssetTask: ()=>jb,
AbstractMesh: ()=>Sr,
AbstractScene: ()=>o,
AcquireNativeObjectAsync: ()=>ru,
Action: ()=>F,
ActionEvent: ()=>w,
ActionManager: ()=>_e,
AddBlock: ()=>Hm,
AddressMode: ()=>Tu,
AdvancedTimer: ()=>Uf,
AlphaState: ()=>Dt,
AmmoJSPlugin: ()=>I_,
AnaglyphArcRotateCamera: ()=>za,
AnaglyphFreeCamera: ()=>Wa,
AnaglyphGamepadCamera: ()=>Ha,
AnaglyphPostProcess: ()=>ka,
AnaglyphUniversalCamera: ()=>Xa,
Analyser: ()=>Wr,
AndOrNotEvaluator: ()=>ve,
Angle: ()=>An,
Animatable: ()=>bn,
AnimatedInputBlockTypes: ()=>qp,
Animation: ()=>Qe,
AnimationEvent: ()=>zn,
AnimationGroup: ()=>Hn,
AnimationKeyInterpolation: ()=>ke,
AnimationPropertiesOverride: ()=>En,
AnimationRange: ()=>We,
AnisotropyBlock: ()=>Og,
ApplyPostProcess: ()=>Ic,
Arc2: ()=>xn,
ArcFollowCamera: ()=>Ea,
ArcRotateCamera: ()=>_a,
ArcRotateCameraGamepadInput: ()=>Ho,
ArcRotateCameraInputsManager: ()=>Ko,
ArcRotateCameraKeyboardMoveInput: ()=>Xo,
ArcRotateCameraMouseWheelInput: ()=>jo,
ArcRotateCameraPointersInput: ()=>Yo,
ArcRotateCameraVRDeviceOrientationInput: ()=>Qo,
ArcTan2Block: ()=>pg,
AssetContainer: ()=>zr,
AssetTaskState: ()=>Wb,
AssetsManager: ()=>nT,
AssetsProgressEvent: ()=>Yb,
AsyncLoop: ()=>yi,
AttachToBoxBehavior: ()=>po,
AudioEngine: ()=>Hr,
AudioSceneComponent: ()=>Yr,
AutoReleaseWorkerPool: ()=>vp,
AutoRotationBehavior: ()=>lo,
AxesViewer: ()=>xl,
Axis: ()=>vn,
AxisDragGizmo: ()=>Al,
AxisScaleGizmo: ()=>fd,
BRDFTextureTools: ()=>Xd,
BabylonFileLoaderConfiguration: ()=>N_,
BackEase: ()=>On,
BackgroundMaterial: ()=>Vd,
BakedVertexAnimationManager: ()=>Qr,
BaseCameraMouseWheelInput: ()=>Bo,
BaseCameraPointersInput: ()=>Uo,
BaseError: ()=>dt,
BaseParticleSystem: ()=>Tf,
BaseSixDofDragBehavior: ()=>Ro,
BaseTexture: ()=>Zr,
BasisTools: ()=>um,
BasisToolsOptions: ()=>nm,
BasisTranscodeConfiguration: ()=>im,
BezierCurve: ()=>Sn,
BezierCurveEase: ()=>Gn,
BinaryFileAssetTask: ()=>Zb,
BlackAndWhitePostProcess: ()=>Uy,
BlendFactor: ()=>Lu,
BlendOperation: ()=>Fu,
BloomEffect: ()=>zy,
BloomMergePostProcess: ()=>Gy,
BlurPostProcess: ()=>Fd,
Bone: ()=>yn,
BoneAxesViewer: ()=>Rl,
BoneIKController: ()=>No,
BoneLookController: ()=>Lo,
BonesBlock: ()=>Em,
BounceEase: ()=>Dn,
BouncingBehavior: ()=>co,
BoundingBox: ()=>tr,
BoundingBoxGizmo: ()=>_d,
BoundingBoxRenderer: ()=>Ab,
BoundingInfo: ()=>sr,
BoundingSphere: ()=>ir,
BoxBuilder: ()=>Il,
BoxParticleEmitter: ()=>hf,
Buffer: ()=>wi,
BufferBindingType: ()=>xu,
BufferUsage: ()=>fu,
CSG: ()=>cv,
Camera: ()=>Rr,
CameraGizmo: ()=>Ld,
CameraInputTypes: ()=>Vo,
CameraInputsManager: ()=>ko,
CannonJSPlugin: ()=>P_,
CanvasCompositingAlphaMode: ()=>Xu,
CapsuleBuilder: ()=>zl,
CascadedShadowGenerator: ()=>p_,
ChromaticAberrationPostProcess: ()=>Wy,
CircleEase: ()=>In,
CircleOfConfusionPostProcess: ()=>Hy,
ClampBlock: ()=>jm,
ClearCoatBlock: ()=>Ng,
ClipPlanesBlock: ()=>Wm,
ClipboardEventTypes: ()=>nd,
ClipboardInfo: ()=>rd,
CloudBlock: ()=>zg,
CloudPoint: ()=>Ay,
Collider: ()=>pl,
Color3: ()=>D,
Color3Gradient: ()=>cy,
Color4: ()=>N,
ColorCorrectionPostProcess: ()=>Xy,
ColorCurves: ()=>Ai,
ColorGradient: ()=>ly,
ColorGradingTexture: ()=>Y_,
ColorMergerBlock: ()=>Zm,
ColorSplitterBlock: ()=>Ef,
ColorWrite: ()=>Nu,
CombineAction: ()=>ie,
CompareFunction: ()=>Su,
CompatibilityOptions: ()=>pr,
CompilationMessageType: ()=>Mu,
ComputeBindingType: ()=>_l,
ComputeEffect: ()=>ml,
ComputePassTimestampLocation: ()=>ku,
ComputePressureObserverWrapper: ()=>_n,
ComputeShader: ()=>gl,
ComputeShaderParticleSystem: ()=>ay,
Condition: ()=>H,
ConditionalBlock: ()=>Gg,
ConditionalBlockConditions: ()=>Vg,
ConeParticleEmitter: ()=>df,
Constants: ()=>a,
ContainerAssetTask: ()=>Kb,
ConvolutionPostProcess: ()=>jy,
Coordinate: ()=>gn,
CopyTools: ()=>to,
CreateBox: ()=>Ml,
CreateBoxVertexData: ()=>Pl,
CreateCapsule: ()=>Gl,
CreateCapsuleVertexData: ()=>kl,
CreateCylinder: ()=>Ys,
CreateCylinderVertexData: ()=>js,
CreateDashedLines: ()=>$l,
CreateDashedLinesVertexData: ()=>ql,
CreateDecal: ()=>wv,
CreateDisc: ()=>Pd,
CreateEnvTextureAsync: ()=>Gc,
CreateGeodesic: ()=>zv,
CreateGoldberg: ()=>Hv,
CreateGoldbergVertexData: ()=>Wv,
CreateGround: ()=>il,
CreateGroundFromHeightMap: ()=>rl,
CreateGroundFromHeightMapVertexData: ()=>tl,
CreateGroundVertexData: ()=>$s,
CreateHemisphere: ()=>Id,
CreateIcoSphere: ()=>Lv,
CreateIcoSphereVertexData: ()=>Nv,
CreateImageDataArrayBufferViews: ()=>Wc,
CreateLathe: ()=>Mv,
CreateLineSystem: ()=>Zl,
CreateLineSystemVertexData: ()=>Ql,
CreateLines: ()=>Jl,
CreatePlane: ()=>vo,
CreatePlaneVertexData: ()=>go,
CreatePolygon: ()=>Rv,
CreatePolygonVertexData: ()=>xv,
CreatePolyhedron: ()=>Td,
CreatePolyhedronVertexData: ()=>bd,
CreateResizedCopy: ()=>Mc,
CreateRibbon: ()=>nc,
CreateRibbonVertexData: ()=>ic,
CreateScreenshot: ()=>AT,
CreateScreenshotAsync: ()=>xT,
CreateScreenshotUsingRenderTarget: ()=>CT,
CreateScreenshotUsingRenderTargetAsync: ()=>PT,
CreateScreenshotWithResizeAsync: ()=>RT,
CreateSphere: ()=>Dl,
CreateSphereVertexData: ()=>Ol,
CreateTiledBox: ()=>mv,
CreateTiledBoxVertexData: ()=>_v,
CreateTiledGround: ()=>nl,
CreateTiledGroundVertexData: ()=>el,
CreateTiledPlane: ()=>pv,
CreateTiledPlaneVertexData: ()=>dv,
CreateTorus: ()=>qs,
CreateTorusKnot: ()=>yv,
CreateTorusKnotVertexData: ()=>vv,
CreateTorusVertexData: ()=>Qs,
CreateTube: ()=>Ov,
CrossBlock: ()=>Ym,
CubeMapToSphericalPolynomialTools: ()=>wc,
CubeTexture: ()=>Bd,
CubeTextureAssetTask: ()=>eT,
CubicEase: ()=>Nn,
CullMode: ()=>Du,
CurrentScreenBlock: ()=>nf,
Curve3: ()=>Pn,
CustomBlock: ()=>Km,
CustomOptimization: ()=>pT,
CustomParticleEmitter: ()=>yf,
CustomProceduralTexture: ()=>mm,
CylinderBuilder: ()=>Ks,
CylinderDirectedParticleEmitter: ()=>ff,
CylinderParticleEmitter: ()=>pf,
DDSTools: ()=>pp,
DataBuffer: ()=>Bt,
DataReader: ()=>NT,
DataStorage: ()=>LT,
Database: ()=>ny,
DaydreamController: ()=>ad,
DebugLayer: ()=>Cl,
DebugLayerTab: ()=>bl,
DecalBuilder: ()=>Bv,
Decode: ()=>se,
DecodeBase64ToBinary: ()=>ue,
DecodeBase64ToString: ()=>ce,
DecodeBase64UrlToBinary: ()=>oi,
DecodeBase64UrlToString: ()=>si,
DeepCopier: ()=>fe,
DefaultCollisionCoordinator: ()=>fl,
DefaultLoadingScreen: ()=>m_,
DefaultRenderingPipeline: ()=>db,
Deferred: ()=>rT,
DepthCullingState: ()=>It,
DepthOfFieldBlurPostProcess: ()=>Yy,
DepthOfFieldEffect: ()=>Zy,
DepthOfFieldEffectBlurLevel: ()=>Ky,
DepthOfFieldMergePostProcess: ()=>qy,
DepthOfFieldMergePostProcessOptions: ()=>Qy,
DepthPeelingRenderer: ()=>Cb,
DepthPeelingSceneComponent: ()=>Pb,
DepthReducer: ()=>s_,
DepthRenderer: ()=>o_,
DepthRendererSceneComponent: ()=>xb,
DepthSortedParticle: ()=>Ty,
DerivativeBlock: ()=>Im,
DesaturateBlock: ()=>Mg,
DetailMapConfiguration: ()=>Ps,
DeviceInputEventType: ()=>Li,
DeviceLostReason: ()=>ju,
DeviceOrientationCamera: ()=>ma,
DeviceSource: ()=>on,
DeviceSourceManager: ()=>sn,
DeviceType: ()=>Ci,
DirectionalLight: ()=>Rd,
DirectionalLightFrustumViewer: ()=>uc,
DiscBuilder: ()=>Md,
DiscardBlock: ()=>Pm,
DisplayPassPostProcess: ()=>Jy,
DistanceBlock: ()=>lg,
DistanceJoint: ()=>Fl,
DivideBlock: ()=>eg,
DoNothingAction: ()=>te,
DomManagement: ()=>lt,
DotBlock: ()=>Qm,
DracoCompression: ()=>iv,
DrawWrapper: ()=>Gt,
DualSenseInput: ()=>Oi,
DualShockButton: ()=>Ca,
DualShockDpad: ()=>Pa,
DualShockInput: ()=>Ii,
DualShockPad: ()=>Ia,
DynamicFloat32Array: ()=>zT,
DynamicTexture: ()=>Ds,
EasingFunction: ()=>Mn,
EdgesRenderer: ()=>Ib,
Effect: ()=>Mt,
EffectFallbacks: ()=>ys,
EffectLayer: ()=>Kf,
EffectLayerSceneComponent: ()=>Qf,
EffectRenderer: ()=>y_,
EffectWrapper: ()=>b_,
ElasticEase: ()=>Ln,
ElbowBlock: ()=>Hg,
EncodeArrayBufferToBase64: ()=>le,
EndsWith: ()=>oe,
Engine: ()=>vr,
EngineFactory: ()=>id,
EngineInstrumentation: ()=>jf,
EngineStore: ()=>E,
EngineView: ()=>mc,
EnvironmentHelper: ()=>kd,
EnvironmentTextureTools: ()=>Qc,
Epsilon: ()=>m,
EquiRectangularCubeTexture: ()=>K_,
EquiRectangularCubeTextureAssetTask: ()=>iT,
ErrorCodes: ()=>pt,
ErrorFilter: ()=>Yu,
EventConstants: ()=>$i,
EventState: ()=>l,
ExecuteCodeAction: ()=>ne,
ExponentialEase: ()=>Fn,
ExternalTexture: ()=>Mh,
ExtractHighlightsPostProcess: ()=>ky,
ExtrudePolygon: ()=>Cv,
ExtrudeShape: ()=>oc,
ExtrudeShapeCustom: ()=>ac,
FactorGradient: ()=>uy,
FadeInOutBehavior: ()=>fo,
FeatureName: ()=>pu,
FileTools: ()=>ai,
FileToolsOptions: ()=>qt,
FilesInput: ()=>aT,
FilesInputStore: ()=>ut,
FilterMode: ()=>Eu,
FilterPostProcess: ()=>$y,
FlyCamera: ()=>va,
FlyCameraInputsManager: ()=>ga,
FlyCameraKeyboardInput: ()=>qo,
FlyCameraMouseInput: ()=>Zo,
FogBlock: ()=>Fm,
FollowBehavior: ()=>Mo,
FollowCamera: ()=>Ta,
FollowCameraInputsManager: ()=>ya,
FollowCameraKeyboardMoveInput: ()=>Jo,
FollowCameraMouseWheelInput: ()=>$o,
FollowCameraPointersInput: ()=>ea,
FragCoordBlock: ()=>Om,
FragmentOutputBlock: ()=>Zp,
FramingBehavior: ()=>uo,
FreeCamera: ()=>pa,
FreeCameraDeviceOrientationInput: ()=>sa,
FreeCameraGamepadInput: ()=>ca,
FreeCameraInputsManager: ()=>aa,
FreeCameraKeyboardMoveInput: ()=>ta,
FreeCameraMouseInput: ()=>na,
FreeCameraMouseWheelInput: ()=>ra,
FreeCameraTouchInput: ()=>oa,
FreeCameraVirtualJoystickInput: ()=>ha,
FresnelBlock: ()=>og,
FresnelParameters: ()=>z_,
FromHalfFloat: ()=>Dc,
FrontFace: ()=>Ou,
FrontFacingBlock: ()=>Mm,
Frustum: ()=>dn,
FxaaPostProcess: ()=>eb,
GPUParticleSystem: ()=>_y,
GUID: ()=>_i,
Gamepad: ()=>zo,
GamepadCamera: ()=>La,
GamepadManager: ()=>Oa,
GamepadSystemSceneComponent: ()=>Da,
GearVRController: ()=>sd,
GenerateBase64StringFromPixelData: ()=>Jr,
GenerateBase64StringFromTexture: ()=>$r,
GenerateBase64StringFromTextureAsync: ()=>eo,
GenericController: ()=>ld,
GenericPad: ()=>Wo,
GeodesicData: ()=>Gv,
Geometry: ()=>fr,
GeometryBufferRenderer: ()=>nb,
GeometryBufferRendererSceneComponent: ()=>ob,
GetClass: ()=>b,
GetDOMTextContent: ()=>at,
GetEnvInfo: ()=>Vc,
GetEnvironmentBRDFTexture: ()=>Hd,
GetInternalFormatFromBasisFormat: ()=>rm,
GetTGAHeader: ()=>q_,
Gizmo: ()=>Sl,
GizmoManager: ()=>Ad,
GlowLayer: ()=>qf,
GoldbergMesh: ()=>uv,
GradientBlock: ()=>Tg,
GradientBlockColorStep: ()=>bg,
GradientHelper: ()=>hy,
GrainPostProcess: ()=>tb,
GroundBuilder: ()=>ol,
GroundMesh: ()=>Js,
HDRCubeTexture: ()=>E_,
HDRCubeTextureAssetTask: ()=>tT,
HDRFiltering: ()=>T_,
HDRTools: ()=>v_,
HandConstraintBehavior: ()=>Do,
HandConstraintOrientation: ()=>Eo,
HandConstraintVisibility: ()=>So,
HandConstraintZone: ()=>To,
HardwareScalingOptimization: ()=>cT,
HemisphereBuilder: ()=>Od,
HemisphericLight: ()=>ds,
HemisphericParticleEmitter: ()=>_f,
HighlightLayer: ()=>Jf,
HighlightsPostProcess: ()=>ib,
Hinge2Joint: ()=>Ul,
HingeJoint: ()=>Bl,
HtmlElementTexture: ()=>Q_,
IWebXRControllerPhysicsOptions: ()=>nE,
IcoSphereBuilder: ()=>Fv,
ImageAssetTask: ()=>Jb,
ImageProcessingBlock: ()=>Rm,
ImageProcessingConfiguration: ()=>Ri,
ImageProcessingConfigurationDefines: ()=>xi,
ImageProcessingPostProcess: ()=>Fs,
ImageSourceBlock: ()=>Um,
IncrementValueAction: ()=>J,
IndexFormat: ()=>Bu,
InputBlock: ()=>tf,
InputStepMode: ()=>Vu,
InspectableType: ()=>IT,
InstancedLinesMesh: ()=>Kl,
InstancedMesh: ()=>Hl,
InstancesBlock: ()=>Sm,
InstantiatedEntries: ()=>Gr,
InternalTexture: ()=>Lt,
InternalTextureSource: ()=>At,
InterpolateValueAction: ()=>qe,
IntersectionInfo: ()=>er,
IsBase64DataUrl: ()=>ri,
IsDocumentAvailable: ()=>ot,
IsFileURL: ()=>ni,
IsNavigatorAvailable: ()=>rt,
IsWindowObjectExist: ()=>nt,
JoystickAxis: ()=>la,
KeepAssets: ()=>kr,
KeyboardEventTypes: ()=>Qi,
KeyboardInfo: ()=>qi,
KeyboardInfoPre: ()=>Zi,
KhronosTextureContainer: ()=>mp,
KhronosTextureContainer2: ()=>yp,
LatheBuilder: ()=>Iv,
Layer: ()=>e_,
LayerSceneComponent: ()=>$f,
LengthBlock: ()=>cg,
LensFlare: ()=>t_,
LensFlareSystem: ()=>i_,
LensFlareSystemSceneComponent: ()=>n_,
LensFlaresOptimization: ()=>dT,
LensRenderingPipeline: ()=>pb,
LerpBlock: ()=>$m,
Light: ()=>Cr,
LightBlock: ()=>wm,
LightGizmo: ()=>Nd,
LightInformationBlock: ()=>xm,
LineEdgesRenderer: ()=>Ob,
LinesBuilder: ()=>ec,
LinesMesh: ()=>Yl,
LoadFile: ()=>ti,
LoadFileError: ()=>Yt,
LoadImage: ()=>$t,
LoadOp: ()=>zu,
LoadTextureFromTranscodeResult: ()=>cm,
Logger: ()=>K,
MapMode: ()=>_u,
Material: ()=>Or,
MaterialAnisotropicDefines: ()=>qd,
MaterialClearCoatDefines: ()=>Kd,
MaterialDefines: ()=>Si,
MaterialDetailMapDefines: ()=>Cs,
MaterialFlags: ()=>vs,
MaterialHelper: ()=>Mr,
MaterialPluginBase: ()=>Rs,
MaterialPluginManager: ()=>bs,
MaterialSheenDefines: ()=>Jd,
MaterialSubSurfaceDefines: ()=>ep,
Matrix: ()=>P,
MatrixBuilderBlock: ()=>kg,
MaxBlock: ()=>ag,
MergeMeshesOptimization: ()=>mT,
Mesh: ()=>Vr,
MeshAssetTask: ()=>Qb,
MeshBuilder: ()=>jv,
MeshExploder: ()=>oT,
MeshLODLevel: ()=>Nr,
MeshParticleEmitter: ()=>bf,
MeshoptCompression: ()=>nv,
MinBlock: ()=>sg,
MinMaxReducer: ()=>a_,
MirrorTexture: ()=>wd,
ModBlock: ()=>Ug,
ModelShape: ()=>by,
MorphTarget: ()=>S_,
MorphTargetManager: ()=>x_,
MorphTargetsBlock: ()=>Am,
MotionBlurPostProcess: ()=>ab,
MotorEnabledJoint: ()=>wl,
MultiMaterial: ()=>Dr,
MultiObserver: ()=>u,
MultiPointerScaleBehavior: ()=>xo,
MultiRenderTarget: ()=>pm,
MultiplyBlock: ()=>uf,
NLerpBlock: ()=>Eg,
NativeDataStream: ()=>bc,
NativeEngine: ()=>uu,
NativePointerInput: ()=>Mi,
NativeXRFrame: ()=>VE,
NativeXRLayerRenderTargetTextureProvider: ()=>Ws,
NativeXRLayerWrapper: ()=>zs,
NativeXRRenderTarget: ()=>Hs,
NegateBlock: ()=>ug,
Node: ()=>Xe,
NodeMaterial: ()=>Of,
NodeMaterialBlock: ()=>Wp,
NodeMaterialBlockConnectionPointMode: ()=>Kp,
NodeMaterialBlockConnectionPointTypes: ()=>Op,
NodeMaterialBlockTargets: ()=>Dp,
NodeMaterialConnectionPoint: ()=>zp,
NodeMaterialConnectionPointCompatibilityStates: ()=>Up,
NodeMaterialConnectionPointDirection: ()=>Vp,
NodeMaterialDefines: ()=>If,
NodeMaterialModes: ()=>cf,
NodeMaterialOptimizer: ()=>Xg,
NodeMaterialSystemValues: ()=>Qp,
NoiseProceduralTexture: ()=>gm,
NormalBlendBlock: ()=>xg,
NormalizeBlock: ()=>qm,
NullEngine: ()=>dc,
NullEngineOptions: ()=>hc,
Observable: ()=>h,
Observer: ()=>c,
OcclusionMaterial: ()=>W_,
Octree: ()=>yl,
OctreeBlock: ()=>vl,
OctreeSceneComponent: ()=>Tl,
OculusTouchController: ()=>cd,
OimoJSPlugin: ()=>M_,
OnAfterEnteringVRObservableEvent: ()=>ul,
OneMinusBlock: ()=>ng,
Orientation: ()=>Tn,
OutlineRenderer: ()=>Ub,
PBRAnisotropicConfiguration: ()=>Zd,
PBRBaseMaterial: ()=>rp,
PBRBaseSimpleMaterial: ()=>H_,
PBRClearCoatConfiguration: ()=>Qd,
PBRMaterial: ()=>op,
PBRMaterialDefines: ()=>np,
PBRMetallicRoughnessBlock: ()=>Bg,
PBRMetallicRoughnessMaterial: ()=>X_,
PBRSheenConfiguration: ()=>$d,
PBRSpecularGlossinessMaterial: ()=>j_,
PBRSubSurfaceConfiguration: ()=>tp,
PHI: ()=>_,
PadNumber: ()=>he,
PanoramaToCubeMapTools: ()=>g_,
Particle: ()=>dy,
ParticleBlendMultiplyBlock: ()=>af,
ParticleHelper: ()=>gy,
ParticleRampGradientBlock: ()=>of,
ParticleSystem: ()=>fy,
ParticleSystemSet: ()=>my,
ParticleTextureBlock: ()=>rf,
ParticlesOptimization: ()=>fT,
PassCubePostProcess: ()=>Va,
PassPostProcess: ()=>Ua,
Path2: ()=>Rn,
Path3D: ()=>Cn,
PathCursor: ()=>Xn,
PerfCollectionStrategy: ()=>qT,
PerfCounter: ()=>un,
PerformanceConfigurator: ()=>T,
PerformanceMonitor: ()=>_r,
PerformanceViewerCollector: ()=>KT,
PerturbNormalBlock: ()=>Cm,
PhotoDome: ()=>zd,
PhysicsEngine: ()=>R_,
PhysicsEngineSceneComponent: ()=>My,
PhysicsHelper: ()=>Iy,
PhysicsImpostor: ()=>Vl,
PhysicsJoint: ()=>Ll,
PhysicsRadialExplosionEventOptions: ()=>Fy,
PhysicsRadialImpulseFalloff: ()=>Cy,
PhysicsUpdraftEventOptions: ()=>wy,
PhysicsUpdraftMode: ()=>Py,
PhysicsViewer: ()=>Wl,
PhysicsVortexEventOptions: ()=>By,
PickingInfo: ()=>Ui,
PivotTools: ()=>mo,
Plane: ()=>hn,
PlaneBuilder: ()=>yo,
PlaneDragGizmo: ()=>vd,
PlaneRotationGizmo: ()=>md,
PlayAnimationAction: ()=>$,
PlaySoundAction: ()=>me,
PointColor: ()=>vy,
PointLight: ()=>__,
PointParticleEmitter: ()=>mf,
PointerDragBehavior: ()=>Ao,
PointerEventTypes: ()=>Xi,
PointerInfo: ()=>Ki,
PointerInfoBase: ()=>ji,
PointerInfoPre: ()=>Yi,
PointerInput: ()=>Pi,
PointsCloudSystem: ()=>Ry,
PointsGroup: ()=>xy,
Polygon: ()=>Sv,
PolygonBuilder: ()=>Pv,
PolygonMeshBuilder: ()=>Av,
PolyhedronBuilder: ()=>Ed,
PolyhedronData: ()=>kv,
PoseEnabledController: ()=>Ra,
PoseEnabledControllerHelper: ()=>xa,
PoseEnabledControllerType: ()=>ba,
PositionGizmo: ()=>yd,
PositionNormalTextureVertex: ()=>Ec,
PositionNormalVertex: ()=>Tc,
PostProcess: ()=>Ba,
PostProcessManager: ()=>Vi,
PostProcessRenderEffect: ()=>Vy,
PostProcessRenderPipeline: ()=>cb,
PostProcessRenderPipelineManager: ()=>ub,
PostProcessRenderPipelineManagerSceneComponent: ()=>hb,
PostProcessesOptimization: ()=>hT,
PosterizeBlock: ()=>vg,
PowBlock: ()=>hg,
PowerEase: ()=>wn,
PowerPreference: ()=>du,
PrePassRenderer: ()=>Nb,
PrePassRendererSceneComponent: ()=>Lb,
PrecisionDate: ()=>ct,
PredefinedColorSpace: ()=>hu,
PredicateCondition: ()=>j,
PrimitiveTopology: ()=>Iu,
ProceduralTexture: ()=>xf,
ProceduralTextureSceneComponent: ()=>Sf,
PromisePolyfill: ()=>di,
PropertyTypeForEdition: ()=>Xp,
PushMaterial: ()=>gs,
QuadraticEase: ()=>Bn,
QuadraticErrorSimplification: ()=>$v,
QuarticEase: ()=>Un,
Quaternion: ()=>C,
QueryType: ()=>Hu,
QuinticEase: ()=>Vn,
RGBDTextureTools: ()=>Lc,
RandomGUID: ()=>fi,
RandomNumberBlock: ()=>dg,
RawCubeTexture: ()=>vm,
RawTexture: ()=>ao,
RawTexture2DArray: ()=>A_,
RawTexture3D: ()=>ym,
Ray: ()=>_o,
RayHelper: ()=>tc,
ReadFile: ()=>ei,
ReadFileError: ()=>Qt,
RecastJSCrowd: ()=>iy,
RecastJSPlugin: ()=>ty,
ReciprocalBlock: ()=>_g,
ReflectBlock: ()=>Cg,
ReflectionBlock: ()=>Dg,
ReflectionProbe: ()=>O_,
ReflectionTextureBlock: ()=>Gm,
Reflector: ()=>GT,
RefractBlock: ()=>Pg,
RefractionBlock: ()=>Lg,
RefractionPostProcess: ()=>sb,
RefractionTexture: ()=>bm,
RegisterClass: ()=>y,
RegisterMaterialPlugin: ()=>Ss,
RegisterNativeTypeAsync: ()=>ou,
RemapBlock: ()=>lf,
RenderPassTimestampLocation: ()=>Gu,
RenderTargetTexture: ()=>ns,
RenderTargetWrapper: ()=>Fa,
RenderTargetsOptimization: ()=>_T,
RenderingGroup: ()=>ki,
RenderingGroupInfo: ()=>Gi,
RenderingManager: ()=>zi,
ReplaceColorBlock: ()=>mg,
RequestFile: ()=>ii,
RequestFileError: ()=>Kt,
RetryStrategy: ()=>ht,
RibbonBuilder: ()=>rc,
RollingAverage: ()=>mr,
Rotate2dBlock: ()=>Rg,
RotationGizmo: ()=>gd,
RuntimeAnimation: ()=>it,
RuntimeError: ()=>ft,
SSAO2RenderingPipeline: ()=>_b,
SSAORenderingPipeline: ()=>mb,
SamplerBindingType: ()=>Ru,
Scalar: ()=>d,
ScaleBlock: ()=>Xm,
ScaleGizmo: ()=>Sd,
Scene: ()=>mn,
SceneComponentConstants: ()=>Wi,
SceneDepthBlock: ()=>zm,
SceneInstrumentation: ()=>Yf,
SceneLoader: ()=>od,
SceneLoaderAnimationGroupLoadingMode: ()=>td,
SceneLoaderFlags: ()=>dr,
SceneOptimization: ()=>sT,
SceneOptimizer: ()=>vT,
SceneOptimizerOptions: ()=>gT,
SceneRecorder: ()=>FT,
SceneSerializer: ()=>ET,
ScreenSizeBlock: ()=>Dm,
ScreenSpaceBlock: ()=>Nm,
ScreenSpaceCurvaturePostProcess: ()=>Sb,
ScreenSpaceReflectionPostProcess: ()=>vb,
ScreenshotTools: ()=>OT,
SerializationHelper: ()=>Ge,
SetCorsBehavior: ()=>Jt,
SetParentAction: ()=>re,
SetStateAction: ()=>q,
SetValueAction: ()=>Z,
ShaderCodeInliner: ()=>iu,
ShaderLanguage: ()=>st,
ShaderMaterial: ()=>jl,
ShaderStage: ()=>Au,
ShaderStore: ()=>Pt,
ShadowDepthWrapper: ()=>Yg,
ShadowGenerator: ()=>r_,
ShadowGeneratorSceneComponent: ()=>f_,
ShadowLight: ()=>xd,
ShadowsOptimization: ()=>uT,
ShapeBuilder: ()=>lc,
SharpenPostProcess: ()=>lb,
SheenBlock: ()=>Ig,
SimplexPerlin3DBlock: ()=>Ag,
SimplicationQueueSceneComponent: ()=>ey,
SimplificationQueue: ()=>Kv,
SimplificationSettings: ()=>Yv,
SimplificationType: ()=>Xv,
SineEase: ()=>kn,
SixDofDragBehavior: ()=>Co,
Size: ()=>je,
Skeleton: ()=>Fo,
SkeletonViewer: ()=>cc,
SmartArray: ()=>bi,
SmartArrayNoDuplicate: ()=>Ti,
SmoothStepBlock: ()=>fg,
SolidParticle: ()=>yy,
SolidParticleSystem: ()=>Sy,
SolidParticleVertex: ()=>Ey,
Sound: ()=>Xr,
SoundTrack: ()=>jr,
Space: ()=>Ji,
SphereBuilder: ()=>Nl,
SphereDirectedParticleEmitter: ()=>vf,
SphereParticleEmitter: ()=>gf,
SphericalHarmonics: ()=>Cc,
SphericalPolynomial: ()=>Pc,
SpotLight: ()=>Dd,
Sprite: ()=>Vb,
SpriteManager: ()=>zb,
SpriteMap: ()=>Hb,
SpritePackedManager: ()=>Xb,
SpriteSceneComponent: ()=>kb,
Stage: ()=>Hi,
StandardMaterial: ()=>Os,
StandardMaterialDefines: ()=>Is,
StandardRenderingPipeline: ()=>yb,
StartsWith: ()=>ae,
StateCondition: ()=>Y,
StencilOperation: ()=>wu,
StencilState: ()=>Ot,
StencilStateComposer: ()=>zt,
StepBlock: ()=>ig,
StereoscopicArcRotateCamera: ()=>Qa,
StereoscopicFreeCamera: ()=>qa,
StereoscopicGamepadCamera: ()=>Za,
StereoscopicInterlacePostProcess: ()=>Ya,
StereoscopicInterlacePostProcessI: ()=>ja,
StereoscopicScreenUniversalCamera: ()=>$a,
StereoscopicUniversalCamera: ()=>Ja,
StickValues: ()=>Go,
StopAnimationAction: ()=>ee,
StopSoundAction: ()=>ge,
StorageBuffer: ()=>wo,
StorageTextureAccess: ()=>Pu,
StoreOp: ()=>Wu,
StringDictionary: ()=>Ei,
StringTools: ()=>de,
SubEmitter: ()=>py,
SubEmitterType: ()=>sy,
SubMesh: ()=>hr,
SubSurfaceBlock: ()=>Fg,
SubSurfaceSceneComponent: ()=>Bb,
SubtractBlock: ()=>tg,
SurfaceMagnetismBehavior: ()=>Po,
SwitchBooleanAction: ()=>Q,
SwitchInput: ()=>Ni,
TGATools: ()=>J_,
Tags: ()=>ye,
TargetCamera: ()=>da,
TargetedAnimation: ()=>Wn,
TextFileAssetTask: ()=>qb,
Texture: ()=>io,
TextureAspect: ()=>yu,
TextureAssetTask: ()=>$b,
TextureBlock: ()=>Vm,
TextureDimension: ()=>mu,
TextureFormat: ()=>bu,
TextureOptimization: ()=>lT,
TexturePacker: ()=>_m,
TexturePackerFrame: ()=>fm,
TextureSampleType: ()=>Cu,
TextureSampler: ()=>Nt,
TextureTools: ()=>Nc,
TextureUsage: ()=>gu,
TextureViewDimension: ()=>vu,
ThinEngine: ()=>Ht,
ThinMaterialHelper: ()=>Pr,
ThinRenderTargetTexture: ()=>Tm,
ThinTexture: ()=>qr,
TiledBoxBuilder: ()=>gv,
TiledPlaneBuilder: ()=>fv,
TimerState: ()=>Nf,
TmpColors: ()=>L,
TmpVectors: ()=>I,
ToGammaSpace: ()=>p,
ToHalfFloat: ()=>Oc,
ToLinearSpace: ()=>f,
TonemapPostProcess: ()=>Tb,
TonemappingOperator: ()=>bb,
Tools: ()=>gi,
TorusBuilder: ()=>Zs,
TorusKnotBuilder: ()=>bv,
TouchCamera: ()=>fa,
TrailMesh: ()=>hv,
Trajectory: ()=>wT,
TrajectoryClassifier: ()=>kT,
TranscodeAsync: ()=>lm,
TransformBlock: ()=>Hp,
TransformNode: ()=>yr,
TrigonometryBlock: ()=>Rf,
TrigonometryBlockOperations: ()=>Af,
TubeBuilder: ()=>Dv,
TwirlBlock: ()=>Lm,
UniformBuffer: ()=>Fi,
UniversalCamera: ()=>Na,
UnregisterAllMaterialPlugins: ()=>xs,
UnregisterMaterialPlugin: ()=>As,
UploadContent: ()=>Z_,
UploadEnvLevelsAsync: ()=>Hc,
UploadEnvSpherical: ()=>Yc,
UploadLevelsAsync: ()=>jc,
UtilityLayerRenderer: ()=>El,
VRCameraMetrics: ()=>ts,
VRDeviceOrientationArcRotateCamera: ()=>cs,
VRDeviceOrientationFreeCamera: ()=>us,
VRDeviceOrientationGamepadCamera: ()=>hs,
VRDistortionCorrectionPostProcess: ()=>is,
VRExperienceHelper: ()=>hl,
VRMultiviewToSingleviewPostProcess: ()=>ss,
ValidatedNativeDataStream: ()=>Ku,
ValueCondition: ()=>X,
Vector2: ()=>A,
Vector3: ()=>x,
Vector4: ()=>R,
VectorMergerBlock: ()=>sf,
VectorSplitterBlock: ()=>Jm,
VertexAnimationBaker: ()=>so,
VertexBuffer: ()=>Bi,
VertexData: ()=>$n,
VertexFormat: ()=>Uu,
VertexOutputBlock: ()=>jp,
VideoDome: ()=>Xf,
VideoRecorder: ()=>ST,
VideoTexture: ()=>Hf,
ViewDirectionBlock: ()=>rg,
Viewport: ()=>xr,
VirtualJoystick: ()=>ua,
VirtualJoysticksCamera: ()=>es,
ViveController: ()=>ud,
VolumetricLightScatteringPostProcess: ()=>Eb,
VoronoiNoiseBlock: ()=>Wg,
WaveBlock: ()=>yg,
WaveBlockKind: ()=>gg,
WebGL2ParticleSystem: ()=>oy,
WebGL2ShaderProcessor: ()=>wt,
WebGLDataBuffer: ()=>Ut,
WebGLHardwareTexture: ()=>kt,
WebGLPipelineContext: ()=>Vt,
WebGPUCacheBindGroups: ()=>Nh,
WebGPUCacheRenderPipeline: ()=>Ah,
WebGPUCacheRenderPipelineTree: ()=>Rh,
WebGPUCacheSampler: ()=>Th,
WebGPUDataBuffer: ()=>_h,
WebGPUDrawContext: ()=>Oh,
WebGPUEngine: ()=>Qh,
WebGPUTintWASM: ()=>Yh,
WebRequest: ()=>Ye,
WebVRController: ()=>_s,
WebVRFreeCamera: ()=>fs,
WebXRAbstractFeature: ()=>wp,
WebXRAbstractMotionController: ()=>xp,
WebXRAnchorSystem: ()=>$T,
WebXRBackgroundRemover: ()=>iE,
WebXRCamera: ()=>Ep,
WebXRCompositionLayerWrapper: ()=>AE,
WebXRControllerComponent: ()=>Ap,
WebXRControllerMovement: ()=>mE,
WebXRControllerPhysics: ()=>rE,
WebXRControllerPointerSelection: ()=>Bp,
WebXRDefaultExperience: ()=>Gf,
WebXRDefaultExperienceOptions: ()=>kf,
WebXRDomOverlay: ()=>_E,
WebXREnterExitUI: ()=>wf,
WebXREnterExitUIButton: ()=>Lf,
WebXREnterExitUIOptions: ()=>Ff,
WebXRExperienceHelper: ()=>Sp,
WebXREyeTracking: ()=>vE,
WebXRFeatureName: ()=>Io,
WebXRFeaturePointSystem: ()=>sE,
WebXRFeaturesManager: ()=>Oo,
WebXRGenericHandController: ()=>OE,
WebXRGenericTriggerMotionController: ()=>Rp,
WebXRHTCViveMotionController: ()=>BE,
WebXRHand: ()=>uE,
WebXRHandTracking: ()=>hE,
WebXRHitTest: ()=>oE,
WebXRHitTestLegacy: ()=>ZT,
WebXRImageTracking: ()=>fE,
WebXRInput: ()=>Fp,
WebXRInputSource: ()=>Lp,
WebXRLayers: ()=>IE,
WebXRLightEstimation: ()=>gE,
WebXRManagedOutputCanvas: ()=>Gs,
WebXRManagedOutputCanvasOptions: ()=>ks,
WebXRMeshDetector: ()=>pE,
WebXRMicrosoftMixedRealityController: ()=>NE,
WebXRMotionControllerManager: ()=>Ip,
WebXRMotionControllerTeleportation: ()=>Vf,
WebXRNearControllerMode: ()=>Pf,
WebXRNearInteraction: ()=>Df,
WebXROculusTouchMotionController: ()=>FE,
WebXRPlaneDetector: ()=>tE,
WebXRProfiledMotionController: ()=>Pp,
WebXRProjectionLayerWrapper: ()=>RE,
WebXRSessionManager: ()=>Xs,
WebXRState: ()=>Ns,
WebXRTrackingState: ()=>Ls,
WebXRWalkingLocomotion: ()=>SE,
WeightedSound: ()=>Kr,
WindowsMotionController: ()=>dd,
WorkerPool: ()=>gp,
WorleyNoise3DBlock: ()=>Sg,
XRWindowsMotionController: ()=>pd,
Xbox360Button: ()=>Sa,
Xbox360Dpad: ()=>Aa,
Xbox360Pad: ()=>Ma,
XboxInput: ()=>Di,
_BabylonLoaderRegistered: ()=>D_,
_BasisTextureLoader: ()=>dm,
_CreationDataStorage: ()=>Lr,
_DDSTextureLoader: ()=>fp,
_ENVTextureLoader: ()=>_p,
_HDRTextureLoader: ()=>em,
_IAnimationState: ()=>Ke,
_InstancesBatch: ()=>wr,
_KTXTextureLoader: ()=>Tp,
_MeshCollisionData: ()=>br,
_OcclusionDataStorage: ()=>fc,
_PrimaryIsoTriangle: ()=>Vv,
_TGATextureLoader: ()=>$_,
_TimeToken: ()=>pc,
_UpdateRGBDAsync: ()=>Kc,
_forceSceneHelpersToBundle: ()=>zf,
_forceTransformFeedbackToBundle: ()=>_c,
_injectLTSFileTools: ()=>ci,
allocateAndCopyTypedBuffer: ()=>gr,
className: ()=>vi,
createDetailMapPlugin: ()=>$g,
createPBRAnisotropicPlugin: ()=>Kg,
createPBRBRDFPlugin: ()=>Qg,
createPBRClearCoatPlugin: ()=>qg,
createPBRSheenPlugin: ()=>Zg,
createPBRSubSurfacePlugin: ()=>Jg,
createYieldingScheduler: ()=>Yn,
editableInPropertyPage: ()=>Yp,
expandToProperty: ()=>Re,
extractMinAndMax: ()=>ur,
extractMinAndMaxIndexed: ()=>cr,
inlineScheduler: ()=>jn,
makeAsyncFunction: ()=>Jn,
makeSyncFunction: ()=>Zn,
nativeOverride: ()=>ze,
normalizeEnvInfo: ()=>kc,
runCoroutine: ()=>Kn,
runCoroutineAsync: ()=>qn,
runCoroutineSync: ()=>Qn,
serialize: ()=>Ce,
serializeAsCameraReference: ()=>Ve,
serializeAsColor3: ()=>Me,
serializeAsColor4: ()=>Fe,
serializeAsColorCurves: ()=>Le,
serializeAsFresnelParameters: ()=>Ie,
serializeAsImageProcessingConfiguration: ()=>we,
serializeAsMatrix: ()=>Ue,
serializeAsMeshReference: ()=>Ne,
serializeAsQuaternion: ()=>Be,
serializeAsTexture: ()=>Pe,
serializeAsVector2: ()=>Oe,
serializeAsVector3: ()=>De,
setAndStartTimer: ()=>Bf,
setStereoscopicAnaglyphRigMode: ()=>Ga,
setStereoscopicRigMode: ()=>Ka,
setVRRigMode: ()=>ls,
setWebVRRigMode: ()=>ps
});
var r = {};
e.r(r),
e.d(r, {
AbstractActionManager: ()=>s,
AbstractAssetTask: ()=>jb,
AbstractMesh: ()=>Sr,
AbstractScene: ()=>o,
AcquireNativeObjectAsync: ()=>ru,
Action: ()=>F,
ActionEvent: ()=>w,
ActionManager: ()=>_e,
AddBlock: ()=>Hm,
AddressMode: ()=>Tu,
AdvancedTimer: ()=>Uf,
AlphaState: ()=>Dt,
AmmoJSPlugin: ()=>I_,
AnaglyphArcRotateCamera: ()=>za,
AnaglyphFreeCamera: ()=>Wa,
AnaglyphGamepadCamera: ()=>Ha,
AnaglyphPostProcess: ()=>ka,
AnaglyphUniversalCamera: ()=>Xa,
Analyser: ()=>Wr,
AndOrNotEvaluator: ()=>ve,
Angle: ()=>An,
Animatable: ()=>bn,
AnimatedInputBlockTypes: ()=>qp,
Animation: ()=>Qe,
AnimationEvent: ()=>zn,
AnimationGroup: ()=>Hn,
AnimationKeyInterpolation: ()=>ke,
AnimationPropertiesOverride: ()=>En,
AnimationRange: ()=>We,
AnisotropyBlock: ()=>Og,
ApplyPostProcess: ()=>Ic,
Arc2: ()=>xn,
ArcFollowCamera: ()=>Ea,
ArcRotateCamera: ()=>_a,
ArcRotateCameraGamepadInput: ()=>Ho,
ArcRotateCameraInputsManager: ()=>Ko,
ArcRotateCameraKeyboardMoveInput: ()=>Xo,
ArcRotateCameraMouseWheelInput: ()=>jo,
ArcRotateCameraPointersInput: ()=>Yo,
ArcRotateCameraVRDeviceOrientationInput: ()=>Qo,
ArcTan2Block: ()=>pg,
AssetContainer: ()=>zr,
AssetTaskState: ()=>Wb,
AssetsManager: ()=>nT,
AssetsProgressEvent: ()=>Yb,
AsyncLoop: ()=>yi,
AttachToBoxBehavior: ()=>po,
AudioEngine: ()=>Hr,
AudioSceneComponent: ()=>Yr,
AutoReleaseWorkerPool: ()=>vp,
AutoRotationBehavior: ()=>lo,
AxesViewer: ()=>xl,
Axis: ()=>vn,
AxisDragGizmo: ()=>Al,
AxisScaleGizmo: ()=>fd,
BRDFTextureTools: ()=>Xd,
BabylonFileLoaderConfiguration: ()=>N_,
BackEase: ()=>On,
BackgroundMaterial: ()=>Vd,
BakedVertexAnimationManager: ()=>Qr,
BaseCameraMouseWheelInput: ()=>Bo,
BaseCameraPointersInput: ()=>Uo,
BaseError: ()=>dt,
BaseParticleSystem: ()=>Tf,
BaseSixDofDragBehavior: ()=>Ro,
BaseTexture: ()=>Zr,
BasisTools: ()=>um,
BasisToolsOptions: ()=>nm,
BasisTranscodeConfiguration: ()=>im,
BezierCurve: ()=>Sn,
BezierCurveEase: ()=>Gn,
BinaryFileAssetTask: ()=>Zb,
BlackAndWhitePostProcess: ()=>Uy,
BlendFactor: ()=>Lu,
BlendOperation: ()=>Fu,
BloomEffect: ()=>zy,
BloomMergePostProcess: ()=>Gy,
BlurPostProcess: ()=>Fd,
Bone: ()=>yn,
BoneAxesViewer: ()=>Rl,
BoneIKController: ()=>No,
BoneLookController: ()=>Lo,
BonesBlock: ()=>Em,
BounceEase: ()=>Dn,
BouncingBehavior: ()=>co,
BoundingBox: ()=>tr,
BoundingBoxGizmo: ()=>_d,
BoundingBoxRenderer: ()=>Ab,
BoundingInfo: ()=>sr,
BoundingSphere: ()=>ir,
BoxBuilder: ()=>Il,
BoxParticleEmitter: ()=>hf,
Buffer: ()=>wi,
BufferBindingType: ()=>xu,
BufferUsage: ()=>fu,
CSG: ()=>cv,
Camera: ()=>Rr,
CameraGizmo: ()=>Ld,
CameraInputTypes: ()=>Vo,
CameraInputsManager: ()=>ko,
CannonJSPlugin: ()=>P_,
CanvasCompositingAlphaMode: ()=>Xu,
CapsuleBuilder: ()=>zl,
CascadedShadowGenerator: ()=>p_,
ChromaticAberrationPostProcess: ()=>Wy,
CircleEase: ()=>In,
CircleOfConfusionPostProcess: ()=>Hy,
ClampBlock: ()=>jm,
ClearCoatBlock: ()=>Ng,
ClipPlanesBlock: ()=>Wm,
ClipboardEventTypes: ()=>nd,
ClipboardInfo: ()=>rd,
CloudBlock: ()=>zg,
CloudPoint: ()=>Ay,
Collider: ()=>pl,
Color3: ()=>D,
Color3Gradient: ()=>cy,
Color4: ()=>N,
ColorCorrectionPostProcess: ()=>Xy,
ColorCurves: ()=>Ai,
ColorGradient: ()=>ly,
ColorGradingTexture: ()=>Y_,
ColorMergerBlock: ()=>Zm,
ColorSplitterBlock: ()=>Ef,
ColorWrite: ()=>Nu,
CombineAction: ()=>ie,
CompareFunction: ()=>Su,
CompatibilityOptions: ()=>pr,
CompilationMessageType: ()=>Mu,
ComputeBindingType: ()=>_l,
ComputeEffect: ()=>ml,
ComputePassTimestampLocation: ()=>ku,
ComputePressureObserverWrapper: ()=>_n,
ComputeShader: ()=>gl,
ComputeShaderParticleSystem: ()=>ay,
Condition: ()=>H,
ConditionalBlock: ()=>Gg,
ConditionalBlockConditions: ()=>Vg,
ConeParticleEmitter: ()=>df,
Constants: ()=>a,
ContainerAssetTask: ()=>Kb,
ConvolutionPostProcess: ()=>jy,
Coordinate: ()=>gn,
CopyTools: ()=>to,
CreateBox: ()=>Ml,
CreateBoxVertexData: ()=>Pl,
CreateCapsule: ()=>Gl,
CreateCapsuleVertexData: ()=>kl,
CreateCylinder: ()=>Ys,
CreateCylinderVertexData: ()=>js,
CreateDashedLines: ()=>$l,
CreateDashedLinesVertexData: ()=>ql,
CreateDecal: ()=>wv,
CreateDisc: ()=>Pd,
CreateEnvTextureAsync: ()=>Gc,
CreateGeodesic: ()=>zv,
CreateGoldberg: ()=>Hv,
CreateGoldbergVertexData: ()=>Wv,
CreateGround: ()=>il,
CreateGroundFromHeightMap: ()=>rl,
CreateGroundFromHeightMapVertexData: ()=>tl,
CreateGroundVertexData: ()=>$s,
CreateHemisphere: ()=>Id,
CreateIcoSphere: ()=>Lv,
CreateIcoSphereVertexData: ()=>Nv,
CreateImageDataArrayBufferViews: ()=>Wc,
CreateLathe: ()=>Mv,
CreateLineSystem: ()=>Zl,
CreateLineSystemVertexData: ()=>Ql,
CreateLines: ()=>Jl,
CreatePlane: ()=>vo,
CreatePlaneVertexData: ()=>go,
CreatePolygon: ()=>Rv,
CreatePolygonVertexData: ()=>xv,
CreatePolyhedron: ()=>Td,
CreatePolyhedronVertexData: ()=>bd,
CreateResizedCopy: ()=>Mc,
CreateRibbon: ()=>nc,
CreateRibbonVertexData: ()=>ic,
CreateScreenshot: ()=>AT,
CreateScreenshotAsync: ()=>xT,
CreateScreenshotUsingRenderTarget: ()=>CT,
CreateScreenshotUsingRenderTargetAsync: ()=>PT,
CreateScreenshotWithResizeAsync: ()=>RT,
CreateSphere: ()=>Dl,
CreateSphereVertexData: ()=>Ol,
CreateTiledBox: ()=>mv,
CreateTiledBoxVertexData: ()=>_v,
CreateTiledGround: ()=>nl,
CreateTiledGroundVertexData: ()=>el,
CreateTiledPlane: ()=>pv,
CreateTiledPlaneVertexData: ()=>dv,
CreateTorus: ()=>qs,
CreateTorusKnot: ()=>yv,
CreateTorusKnotVertexData: ()=>vv,
CreateTorusVertexData: ()=>Qs,
CreateTube: ()=>Ov,
CrossBlock: ()=>Ym,
CubeMapToSphericalPolynomialTools: ()=>wc,
CubeTexture: ()=>Bd,
CubeTextureAssetTask: ()=>eT,
CubicEase: ()=>Nn,
CullMode: ()=>Du,
CurrentScreenBlock: ()=>nf,
Curve3: ()=>Pn,
CustomBlock: ()=>Km,
CustomOptimization: ()=>pT,
CustomParticleEmitter: ()=>yf,
CustomProceduralTexture: ()=>mm,
CylinderBuilder: ()=>Ks,
CylinderDirectedParticleEmitter: ()=>ff,
CylinderParticleEmitter: ()=>pf,
DDSTools: ()=>pp,
DataBuffer: ()=>Bt,
DataReader: ()=>NT,
DataStorage: ()=>LT,
Database: ()=>ny,
DaydreamController: ()=>ad,
Debug: ()=>HE,
DebugLayer: ()=>Cl,
DebugLayerTab: ()=>bl,
DecalBuilder: ()=>Bv,
Decode: ()=>se,
DecodeBase64ToBinary: ()=>ue,
DecodeBase64ToString: ()=>ce,
DecodeBase64UrlToBinary: ()=>oi,
DecodeBase64UrlToString: ()=>si,
DeepCopier: ()=>fe,
DefaultCollisionCoordinator: ()=>fl,
DefaultLoadingScreen: ()=>m_,
DefaultRenderingPipeline: ()=>db,
Deferred: ()=>rT,
DepthCullingState: ()=>It,
DepthOfFieldBlurPostProcess: ()=>Yy,
DepthOfFieldEffect: ()=>Zy,
DepthOfFieldEffectBlurLevel: ()=>Ky,
DepthOfFieldMergePostProcess: ()=>qy,
DepthOfFieldMergePostProcessOptions: ()=>Qy,
DepthPeelingRenderer: ()=>Cb,
DepthPeelingSceneComponent: ()=>Pb,
DepthReducer: ()=>s_,
DepthRenderer: ()=>o_,
DepthRendererSceneComponent: ()=>xb,
DepthSortedParticle: ()=>Ty,
DerivativeBlock: ()=>Im,
DesaturateBlock: ()=>Mg,
DetailMapConfiguration: ()=>Ps,
DeviceInputEventType: ()=>Li,
DeviceLostReason: ()=>ju,
DeviceOrientationCamera: ()=>ma,
DeviceSource: ()=>on,
DeviceSourceManager: ()=>sn,
DeviceType: ()=>Ci,
DirectionalLight: ()=>Rd,
DirectionalLightFrustumViewer: ()=>uc,
DiscBuilder: ()=>Md,
DiscardBlock: ()=>Pm,
DisplayPassPostProcess: ()=>Jy,
DistanceBlock: ()=>lg,
DistanceJoint: ()=>Fl,
DivideBlock: ()=>eg,
DoNothingAction: ()=>te,
DomManagement: ()=>lt,
DotBlock: ()=>Qm,
DracoCompression: ()=>iv,
DrawWrapper: ()=>Gt,
DualSenseInput: ()=>Oi,
DualShockButton: ()=>Ca,
DualShockDpad: ()=>Pa,
DualShockInput: ()=>Ii,
DualShockPad: ()=>Ia,
DynamicFloat32Array: ()=>zT,
DynamicTexture: ()=>Ds,
EasingFunction: ()=>Mn,
EdgesRenderer: ()=>Ib,
Effect: ()=>Mt,
EffectFallbacks: ()=>ys,
EffectLayer: ()=>Kf,
EffectLayerSceneComponent: ()=>Qf,
EffectRenderer: ()=>y_,
EffectWrapper: ()=>b_,
ElasticEase: ()=>Ln,
ElbowBlock: ()=>Hg,
EncodeArrayBufferToBase64: ()=>le,
EndsWith: ()=>oe,
Engine: ()=>vr,
EngineFactory: ()=>id,
EngineInstrumentation: ()=>jf,
EngineStore: ()=>E,
EngineView: ()=>mc,
EnvironmentHelper: ()=>kd,
EnvironmentTextureTools: ()=>Qc,
Epsilon: ()=>m,
EquiRectangularCubeTexture: ()=>K_,
EquiRectangularCubeTextureAssetTask: ()=>iT,
ErrorCodes: ()=>pt,
ErrorFilter: ()=>Yu,
EventConstants: ()=>$i,
EventState: ()=>l,
ExecuteCodeAction: ()=>ne,
ExponentialEase: ()=>Fn,
ExternalTexture: ()=>Mh,
ExtractHighlightsPostProcess: ()=>ky,
ExtrudePolygon: ()=>Cv,
ExtrudeShape: ()=>oc,
ExtrudeShapeCustom: ()=>ac,
FactorGradient: ()=>uy,
FadeInOutBehavior: ()=>fo,
FeatureName: ()=>pu,
FileTools: ()=>ai,
FileToolsOptions: ()=>qt,
FilesInput: ()=>aT,
FilesInputStore: ()=>ut,
FilterMode: ()=>Eu,
FilterPostProcess: ()=>$y,
FlyCamera: ()=>va,
FlyCameraInputsManager: ()=>ga,
FlyCameraKeyboardInput: ()=>qo,
FlyCameraMouseInput: ()=>Zo,
FogBlock: ()=>Fm,
FollowBehavior: ()=>Mo,
FollowCamera: ()=>Ta,
FollowCameraInputsManager: ()=>ya,
FollowCameraKeyboardMoveInput: ()=>Jo,
FollowCameraMouseWheelInput: ()=>$o,
FollowCameraPointersInput: ()=>ea,
FragCoordBlock: ()=>Om,
FragmentOutputBlock: ()=>Zp,
FramingBehavior: ()=>uo,
FreeCamera: ()=>pa,
FreeCameraDeviceOrientationInput: ()=>sa,
FreeCameraGamepadInput: ()=>ca,
FreeCameraInputsManager: ()=>aa,
FreeCameraKeyboardMoveInput: ()=>ta,
FreeCameraMouseInput: ()=>na,
FreeCameraMouseWheelInput: ()=>ra,
FreeCameraTouchInput: ()=>oa,
FreeCameraVirtualJoystickInput: ()=>ha,
FresnelBlock: ()=>og,
FresnelParameters: ()=>z_,
FromHalfFloat: ()=>Dc,
FrontFace: ()=>Ou,
FrontFacingBlock: ()=>Mm,
Frustum: ()=>dn,
FxaaPostProcess: ()=>eb,
GPUParticleSystem: ()=>_y,
GUID: ()=>_i,
Gamepad: ()=>zo,
GamepadCamera: ()=>La,
GamepadManager: ()=>Oa,
GamepadSystemSceneComponent: ()=>Da,
GearVRController: ()=>sd,
GenerateBase64StringFromPixelData: ()=>Jr,
GenerateBase64StringFromTexture: ()=>$r,
GenerateBase64StringFromTextureAsync: ()=>eo,
GenericController: ()=>ld,
GenericPad: ()=>Wo,
GeodesicData: ()=>Gv,
Geometry: ()=>fr,
GeometryBufferRenderer: ()=>nb,
GeometryBufferRendererSceneComponent: ()=>ob,
GetClass: ()=>b,
GetDOMTextContent: ()=>at,
GetEnvInfo: ()=>Vc,
GetEnvironmentBRDFTexture: ()=>Hd,
GetInternalFormatFromBasisFormat: ()=>rm,
GetTGAHeader: ()=>q_,
Gizmo: ()=>Sl,
GizmoManager: ()=>Ad,
GlowLayer: ()=>qf,
GoldbergMesh: ()=>uv,
GradientBlock: ()=>Tg,
GradientBlockColorStep: ()=>bg,
GradientHelper: ()=>hy,
GrainPostProcess: ()=>tb,
GroundBuilder: ()=>ol,
GroundMesh: ()=>Js,
HDRCubeTexture: ()=>E_,
HDRCubeTextureAssetTask: ()=>tT,
HDRFiltering: ()=>T_,
HDRTools: ()=>v_,
HandConstraintBehavior: ()=>Do,
HandConstraintOrientation: ()=>Eo,
HandConstraintVisibility: ()=>So,
HandConstraintZone: ()=>To,
HardwareScalingOptimization: ()=>cT,
HemisphereBuilder: ()=>Od,
HemisphericLight: ()=>ds,
HemisphericParticleEmitter: ()=>_f,
HighlightLayer: ()=>Jf,
HighlightsPostProcess: ()=>ib,
Hinge2Joint: ()=>Ul,
HingeJoint: ()=>Bl,
HtmlElementTexture: ()=>Q_,
IWebXRControllerPhysicsOptions: ()=>nE,
IcoSphereBuilder: ()=>Fv,
ImageAssetTask: ()=>Jb,
ImageProcessingBlock: ()=>Rm,
ImageProcessingConfiguration: ()=>Ri,
ImageProcessingConfigurationDefines: ()=>xi,
ImageProcessingPostProcess: ()=>Fs,
ImageSourceBlock: ()=>Um,
IncrementValueAction: ()=>J,
IndexFormat: ()=>Bu,
InputBlock: ()=>tf,
InputStepMode: ()=>Vu,
InspectableType: ()=>IT,
InstancedLinesMesh: ()=>Kl,
InstancedMesh: ()=>Hl,
InstancesBlock: ()=>Sm,
InstantiatedEntries: ()=>Gr,
InternalTexture: ()=>Lt,
InternalTextureSource: ()=>At,
InterpolateValueAction: ()=>qe,
IntersectionInfo: ()=>er,
IsBase64DataUrl: ()=>ri,
IsDocumentAvailable: ()=>ot,
IsFileURL: ()=>ni,
IsNavigatorAvailable: ()=>rt,
IsWindowObjectExist: ()=>nt,
JoystickAxis: ()=>la,
KeepAssets: ()=>kr,
KeyboardEventTypes: ()=>Qi,
KeyboardInfo: ()=>qi,
KeyboardInfoPre: ()=>Zi,
KhronosTextureContainer: ()=>mp,
KhronosTextureContainer2: ()=>yp,
LatheBuilder: ()=>Iv,
Layer: ()=>e_,
LayerSceneComponent: ()=>$f,
LengthBlock: ()=>cg,
LensFlare: ()=>t_,
LensFlareSystem: ()=>i_,
LensFlareSystemSceneComponent: ()=>n_,
LensFlaresOptimization: ()=>dT,
LensRenderingPipeline: ()=>pb,
LerpBlock: ()=>$m,
Light: ()=>Cr,
LightBlock: ()=>wm,
LightGizmo: ()=>Nd,
LightInformationBlock: ()=>xm,
LineEdgesRenderer: ()=>Ob,
LinesBuilder: ()=>ec,
LinesMesh: ()=>Yl,
LoadFile: ()=>ti,
LoadFileError: ()=>Yt,
LoadImage: ()=>$t,
LoadOp: ()=>zu,
LoadTextureFromTranscodeResult: ()=>cm,
Logger: ()=>K,
MapMode: ()=>_u,
Material: ()=>Or,
MaterialAnisotropicDefines: ()=>qd,
MaterialClearCoatDefines: ()=>Kd,
MaterialDefines: ()=>Si,
MaterialDetailMapDefines: ()=>Cs,
MaterialFlags: ()=>vs,
MaterialHelper: ()=>Mr,
MaterialPluginBase: ()=>Rs,
MaterialPluginManager: ()=>bs,
MaterialSheenDefines: ()=>Jd,
MaterialSubSurfaceDefines: ()=>ep,
Matrix: ()=>P,
MatrixBuilderBlock: ()=>kg,
MaxBlock: ()=>ag,
MergeMeshesOptimization: ()=>mT,
Mesh: ()=>Vr,
MeshAssetTask: ()=>Qb,
MeshBuilder: ()=>jv,
MeshExploder: ()=>oT,
MeshLODLevel: ()=>Nr,
MeshParticleEmitter: ()=>bf,
MeshoptCompression: ()=>nv,
MinBlock: ()=>sg,
MinMaxReducer: ()=>a_,
MirrorTexture: ()=>wd,
ModBlock: ()=>Ug,
ModelShape: ()=>by,
MorphTarget: ()=>S_,
MorphTargetManager: ()=>x_,
MorphTargetsBlock: ()=>Am,
MotionBlurPostProcess: ()=>ab,
MotorEnabledJoint: ()=>wl,
MultiMaterial: ()=>Dr,
MultiObserver: ()=>u,
MultiPointerScaleBehavior: ()=>xo,
MultiRenderTarget: ()=>pm,
MultiplyBlock: ()=>uf,
NLerpBlock: ()=>Eg,
NativeDataStream: ()=>bc,
NativeEngine: ()=>uu,
NativePointerInput: ()=>Mi,
NativeXRFrame: ()=>VE,
NativeXRLayerRenderTargetTextureProvider: ()=>Ws,
NativeXRLayerWrapper: ()=>zs,
NativeXRRenderTarget: ()=>Hs,
NegateBlock: ()=>ug,
Node: ()=>Xe,
NodeMaterial: ()=>Of,
NodeMaterialBlock: ()=>Wp,
NodeMaterialBlockConnectionPointMode: ()=>Kp,
NodeMaterialBlockConnectionPointTypes: ()=>Op,
NodeMaterialBlockTargets: ()=>Dp,
NodeMaterialConnectionPoint: ()=>zp,
NodeMaterialConnectionPointCompatibilityStates: ()=>Up,
NodeMaterialConnectionPointDirection: ()=>Vp,
NodeMaterialDefines: ()=>If,
NodeMaterialModes: ()=>cf,
NodeMaterialOptimizer: ()=>Xg,
NodeMaterialSystemValues: ()=>Qp,
NoiseProceduralTexture: ()=>gm,
NormalBlendBlock: ()=>xg,
NormalizeBlock: ()=>qm,
NullEngine: ()=>dc,
NullEngineOptions: ()=>hc,
Observable: ()=>h,
Observer: ()=>c,
OcclusionMaterial: ()=>W_,
Octree: ()=>yl,
OctreeBlock: ()=>vl,
OctreeSceneComponent: ()=>Tl,
OculusTouchController: ()=>cd,
OimoJSPlugin: ()=>M_,
OnAfterEnteringVRObservableEvent: ()=>ul,
OneMinusBlock: ()=>ng,
Orientation: ()=>Tn,
OutlineRenderer: ()=>Ub,
PBRAnisotropicConfiguration: ()=>Zd,
PBRBaseMaterial: ()=>rp,
PBRBaseSimpleMaterial: ()=>H_,
PBRClearCoatConfiguration: ()=>Qd,
PBRMaterial: ()=>op,
PBRMaterialDefines: ()=>np,
PBRMetallicRoughnessBlock: ()=>Bg,
PBRMetallicRoughnessMaterial: ()=>X_,
PBRSheenConfiguration: ()=>$d,
PBRSpecularGlossinessMaterial: ()=>j_,
PBRSubSurfaceConfiguration: ()=>tp,
PHI: ()=>_,
PadNumber: ()=>he,
PanoramaToCubeMapTools: ()=>g_,
Particle: ()=>dy,
ParticleBlendMultiplyBlock: ()=>af,
ParticleHelper: ()=>gy,
ParticleRampGradientBlock: ()=>of,
ParticleSystem: ()=>fy,
ParticleSystemSet: ()=>my,
ParticleTextureBlock: ()=>rf,
ParticlesOptimization: ()=>fT,
PassCubePostProcess: ()=>Va,
PassPostProcess: ()=>Ua,
Path2: ()=>Rn,
Path3D: ()=>Cn,
PathCursor: ()=>Xn,
PerfCollectionStrategy: ()=>qT,
PerfCounter: ()=>un,
PerformanceConfigurator: ()=>T,
PerformanceMonitor: ()=>_r,
PerformanceViewerCollector: ()=>KT,
PerturbNormalBlock: ()=>Cm,
PhotoDome: ()=>zd,
PhysicsEngine: ()=>R_,
PhysicsEngineSceneComponent: ()=>My,
PhysicsHelper: ()=>Iy,
PhysicsImpostor: ()=>Vl,
PhysicsJoint: ()=>Ll,
PhysicsRadialExplosionEventOptions: ()=>Fy,
PhysicsRadialImpulseFalloff: ()=>Cy,
PhysicsUpdraftEventOptions: ()=>wy,
PhysicsUpdraftMode: ()=>Py,
PhysicsViewer: ()=>Wl,
PhysicsVortexEventOptions: ()=>By,
PickingInfo: ()=>Ui,
PivotTools: ()=>mo,
Plane: ()=>hn,
PlaneBuilder: ()=>yo,
PlaneDragGizmo: ()=>vd,
PlaneRotationGizmo: ()=>md,
PlayAnimationAction: ()=>$,
PlaySoundAction: ()=>me,
PointColor: ()=>vy,
PointLight: ()=>__,
PointParticleEmitter: ()=>mf,
PointerDragBehavior: ()=>Ao,
PointerEventTypes: ()=>Xi,
PointerInfo: ()=>Ki,
PointerInfoBase: ()=>ji,
PointerInfoPre: ()=>Yi,
PointerInput: ()=>Pi,
PointsCloudSystem: ()=>Ry,
PointsGroup: ()=>xy,
Polygon: ()=>Sv,
PolygonBuilder: ()=>Pv,
PolygonMeshBuilder: ()=>Av,
PolyhedronBuilder: ()=>Ed,
PolyhedronData: ()=>kv,
PoseEnabledController: ()=>Ra,
PoseEnabledControllerHelper: ()=>xa,
PoseEnabledControllerType: ()=>ba,
PositionGizmo: ()=>yd,
PositionNormalTextureVertex: ()=>Ec,
PositionNormalVertex: ()=>Tc,
PostProcess: ()=>Ba,
PostProcessManager: ()=>Vi,
PostProcessRenderEffect: ()=>Vy,
PostProcessRenderPipeline: ()=>cb,
PostProcessRenderPipelineManager: ()=>ub,
PostProcessRenderPipelineManagerSceneComponent: ()=>hb,
PostProcessesOptimization: ()=>hT,
PosterizeBlock: ()=>vg,
PowBlock: ()=>hg,
PowerEase: ()=>wn,
PowerPreference: ()=>du,
PrePassRenderer: ()=>Nb,
PrePassRendererSceneComponent: ()=>Lb,
PrecisionDate: ()=>ct,
PredefinedColorSpace: ()=>hu,
PredicateCondition: ()=>j,
PrimitiveTopology: ()=>Iu,
ProceduralTexture: ()=>xf,
ProceduralTextureSceneComponent: ()=>Sf,
PromisePolyfill: ()=>di,
PropertyTypeForEdition: ()=>Xp,
PushMaterial: ()=>gs,
QuadraticEase: ()=>Bn,
QuadraticErrorSimplification: ()=>$v,
QuarticEase: ()=>Un,
Quaternion: ()=>C,
QueryType: ()=>Hu,
QuinticEase: ()=>Vn,
RGBDTextureTools: ()=>Lc,
RandomGUID: ()=>fi,
RandomNumberBlock: ()=>dg,
RawCubeTexture: ()=>vm,
RawTexture: ()=>ao,
RawTexture2DArray: ()=>A_,
RawTexture3D: ()=>ym,
Ray: ()=>_o,
RayHelper: ()=>tc,
ReadFile: ()=>ei,
ReadFileError: ()=>Qt,
RecastJSCrowd: ()=>iy,
RecastJSPlugin: ()=>ty,
ReciprocalBlock: ()=>_g,
ReflectBlock: ()=>Cg,
ReflectionBlock: ()=>Dg,
ReflectionProbe: ()=>O_,
ReflectionTextureBlock: ()=>Gm,
Reflector: ()=>GT,
RefractBlock: ()=>Pg,
RefractionBlock: ()=>Lg,
RefractionPostProcess: ()=>sb,
RefractionTexture: ()=>bm,
RegisterClass: ()=>y,
RegisterMaterialPlugin: ()=>Ss,
RegisterNativeTypeAsync: ()=>ou,
RemapBlock: ()=>lf,
RenderPassTimestampLocation: ()=>Gu,
RenderTargetTexture: ()=>ns,
RenderTargetWrapper: ()=>Fa,
RenderTargetsOptimization: ()=>_T,
RenderingGroup: ()=>ki,
RenderingGroupInfo: ()=>Gi,
RenderingManager: ()=>zi,
ReplaceColorBlock: ()=>mg,
RequestFile: ()=>ii,
RequestFileError: ()=>Kt,
RetryStrategy: ()=>ht,
RibbonBuilder: ()=>rc,
RollingAverage: ()=>mr,
Rotate2dBlock: ()=>Rg,
RotationGizmo: ()=>gd,
RuntimeAnimation: ()=>it,
RuntimeError: ()=>ft,
SSAO2RenderingPipeline: ()=>_b,
SSAORenderingPipeline: ()=>mb,
SamplerBindingType: ()=>Ru,
Scalar: ()=>d,
ScaleBlock: ()=>Xm,
ScaleGizmo: ()=>Sd,
Scene: ()=>mn,
SceneComponentConstants: ()=>Wi,
SceneDepthBlock: ()=>zm,
SceneInstrumentation: ()=>Yf,
SceneLoader: ()=>od,
SceneLoaderAnimationGroupLoadingMode: ()=>td,
SceneLoaderFlags: ()=>dr,
SceneOptimization: ()=>sT,
SceneOptimizer: ()=>vT,
SceneOptimizerOptions: ()=>gT,
SceneRecorder: ()=>FT,
SceneSerializer: ()=>ET,
ScreenSizeBlock: ()=>Dm,
ScreenSpaceBlock: ()=>Nm,
ScreenSpaceCurvaturePostProcess: ()=>Sb,
ScreenSpaceReflectionPostProcess: ()=>vb,
ScreenshotTools: ()=>OT,
SerializationHelper: ()=>Ge,
SetCorsBehavior: ()=>Jt,
SetParentAction: ()=>re,
SetStateAction: ()=>q,
SetValueAction: ()=>Z,
ShaderCodeInliner: ()=>iu,
ShaderLanguage: ()=>st,
ShaderMaterial: ()=>jl,
ShaderStage: ()=>Au,
ShaderStore: ()=>Pt,
ShadowDepthWrapper: ()=>Yg,
ShadowGenerator: ()=>r_,
ShadowGeneratorSceneComponent: ()=>f_,
ShadowLight: ()=>xd,
ShadowsOptimization: ()=>uT,
ShapeBuilder: ()=>lc,
SharpenPostProcess: ()=>lb,
SheenBlock: ()=>Ig,
SimplexPerlin3DBlock: ()=>Ag,
SimplicationQueueSceneComponent: ()=>ey,
SimplificationQueue: ()=>Kv,
SimplificationSettings: ()=>Yv,
SimplificationType: ()=>Xv,
SineEase: ()=>kn,
SixDofDragBehavior: ()=>Co,
Size: ()=>je,
Skeleton: ()=>Fo,
SkeletonViewer: ()=>cc,
SmartArray: ()=>bi,
SmartArrayNoDuplicate: ()=>Ti,
SmoothStepBlock: ()=>fg,
SolidParticle: ()=>yy,
SolidParticleSystem: ()=>Sy,
SolidParticleVertex: ()=>Ey,
Sound: ()=>Xr,
SoundTrack: ()=>jr,
Space: ()=>Ji,
SphereBuilder: ()=>Nl,
SphereDirectedParticleEmitter: ()=>vf,
SphereParticleEmitter: ()=>gf,
SphericalHarmonics: ()=>Cc,
SphericalPolynomial: ()=>Pc,
SpotLight: ()=>Dd,
Sprite: ()=>Vb,
SpriteManager: ()=>zb,
SpriteMap: ()=>Hb,
SpritePackedManager: ()=>Xb,
SpriteSceneComponent: ()=>kb,
Stage: ()=>Hi,
StandardMaterial: ()=>Os,
StandardMaterialDefines: ()=>Is,
StandardRenderingPipeline: ()=>yb,
StartsWith: ()=>ae,
StateCondition: ()=>Y,
StencilOperation: ()=>wu,
StencilState: ()=>Ot,
StencilStateComposer: ()=>zt,
StepBlock: ()=>ig,
StereoscopicArcRotateCamera: ()=>Qa,
StereoscopicFreeCamera: ()=>qa,
StereoscopicGamepadCamera: ()=>Za,
StereoscopicInterlacePostProcess: ()=>Ya,
StereoscopicInterlacePostProcessI: ()=>ja,
StereoscopicScreenUniversalCamera: ()=>$a,
StereoscopicUniversalCamera: ()=>Ja,
StickValues: ()=>Go,
StopAnimationAction: ()=>ee,
StopSoundAction: ()=>ge,
StorageBuffer: ()=>wo,
StorageTextureAccess: ()=>Pu,
StoreOp: ()=>Wu,
StringDictionary: ()=>Ei,
StringTools: ()=>de,
SubEmitter: ()=>py,
SubEmitterType: ()=>sy,
SubMesh: ()=>hr,
SubSurfaceBlock: ()=>Fg,
SubSurfaceSceneComponent: ()=>Bb,
SubtractBlock: ()=>tg,
SurfaceMagnetismBehavior: ()=>Po,
SwitchBooleanAction: ()=>Q,
SwitchInput: ()=>Ni,
TGATools: ()=>J_,
Tags: ()=>ye,
TargetCamera: ()=>da,
TargetedAnimation: ()=>Wn,
TextFileAssetTask: ()=>qb,
Texture: ()=>io,
TextureAspect: ()=>yu,
TextureAssetTask: ()=>$b,
TextureBlock: ()=>Vm,
TextureDimension: ()=>mu,
TextureFormat: ()=>bu,
TextureOptimization: ()=>lT,
TexturePacker: ()=>_m,
TexturePackerFrame: ()=>fm,
TextureSampleType: ()=>Cu,
TextureSampler: ()=>Nt,
TextureTools: ()=>Nc,
TextureUsage: ()=>gu,
TextureViewDimension: ()=>vu,
ThinEngine: ()=>Ht,
ThinMaterialHelper: ()=>Pr,
ThinRenderTargetTexture: ()=>Tm,
ThinTexture: ()=>qr,
TiledBoxBuilder: ()=>gv,
TiledPlaneBuilder: ()=>fv,
TimerState: ()=>Nf,
TmpColors: ()=>L,
TmpVectors: ()=>I,
ToGammaSpace: ()=>p,
ToHalfFloat: ()=>Oc,
ToLinearSpace: ()=>f,
TonemapPostProcess: ()=>Tb,
TonemappingOperator: ()=>bb,
Tools: ()=>gi,
TorusBuilder: ()=>Zs,
TorusKnotBuilder: ()=>bv,
TouchCamera: ()=>fa,
TrailMesh: ()=>hv,
Trajectory: ()=>wT,
TrajectoryClassifier: ()=>kT,
TranscodeAsync: ()=>lm,
TransformBlock: ()=>Hp,
TransformNode: ()=>yr,
TrigonometryBlock: ()=>Rf,
TrigonometryBlockOperations: ()=>Af,
TubeBuilder: ()=>Dv,
TwirlBlock: ()=>Lm,
UniformBuffer: ()=>Fi,
UniversalCamera: ()=>Na,
UnregisterAllMaterialPlugins: ()=>xs,
UnregisterMaterialPlugin: ()=>As,
UploadContent: ()=>Z_,
UploadEnvLevelsAsync: ()=>Hc,
UploadEnvSpherical: ()=>Yc,
UploadLevelsAsync: ()=>jc,
UtilityLayerRenderer: ()=>El,
VRCameraMetrics: ()=>ts,
VRDeviceOrientationArcRotateCamera: ()=>cs,
VRDeviceOrientationFreeCamera: ()=>us,
VRDeviceOrientationGamepadCamera: ()=>hs,
VRDistortionCorrectionPostProcess: ()=>is,
VRExperienceHelper: ()=>hl,
VRMultiviewToSingleviewPostProcess: ()=>ss,
ValidatedNativeDataStream: ()=>Ku,
ValueCondition: ()=>X,
Vector2: ()=>A,
Vector3: ()=>x,
Vector4: ()=>R,
VectorMergerBlock: ()=>sf,
VectorSplitterBlock: ()=>Jm,
VertexAnimationBaker: ()=>so,
VertexBuffer: ()=>Bi,
VertexData: ()=>$n,
VertexFormat: ()=>Uu,
VertexOutputBlock: ()=>jp,
VideoDome: ()=>Xf,
VideoRecorder: ()=>ST,
VideoTexture: ()=>Hf,
ViewDirectionBlock: ()=>rg,
Viewport: ()=>xr,
VirtualJoystick: ()=>ua,
VirtualJoysticksCamera: ()=>es,
ViveController: ()=>ud,
VolumetricLightScatteringPostProcess: ()=>Eb,
VoronoiNoiseBlock: ()=>Wg,
WaveBlock: ()=>yg,
WaveBlockKind: ()=>gg,
WebGL2ParticleSystem: ()=>oy,
WebGL2ShaderProcessor: ()=>wt,
WebGLDataBuffer: ()=>Ut,
WebGLHardwareTexture: ()=>kt,
WebGLPipelineContext: ()=>Vt,
WebGPUCacheBindGroups: ()=>Nh,
WebGPUCacheRenderPipeline: ()=>Ah,
WebGPUCacheRenderPipelineTree: ()=>Rh,
WebGPUCacheSampler: ()=>Th,
WebGPUDataBuffer: ()=>_h,
WebGPUDrawContext: ()=>Oh,
WebGPUEngine: ()=>Qh,
WebGPUTintWASM: ()=>Yh,
WebRequest: ()=>Ye,
WebVRController: ()=>_s,
WebVRFreeCamera: ()=>fs,
WebXRAbstractFeature: ()=>wp,
WebXRAbstractMotionController: ()=>xp,
WebXRAnchorSystem: ()=>$T,
WebXRBackgroundRemover: ()=>iE,
WebXRCamera: ()=>Ep,
WebXRCompositionLayerWrapper: ()=>AE,
WebXRControllerComponent: ()=>Ap,
WebXRControllerMovement: ()=>mE,
WebXRControllerPhysics: ()=>rE,
WebXRControllerPointerSelection: ()=>Bp,
WebXRDefaultExperience: ()=>Gf,
WebXRDefaultExperienceOptions: ()=>kf,
WebXRDomOverlay: ()=>_E,
WebXREnterExitUI: ()=>wf,
WebXREnterExitUIButton: ()=>Lf,
WebXREnterExitUIOptions: ()=>Ff,
WebXRExperienceHelper: ()=>Sp,
WebXREyeTracking: ()=>vE,
WebXRFeatureName: ()=>Io,
WebXRFeaturePointSystem: ()=>sE,
WebXRFeaturesManager: ()=>Oo,
WebXRGenericHandController: ()=>OE,
WebXRGenericTriggerMotionController: ()=>Rp,
WebXRHTCViveMotionController: ()=>BE,
WebXRHand: ()=>uE,
WebXRHandTracking: ()=>hE,
WebXRHitTest: ()=>oE,
WebXRHitTestLegacy: ()=>ZT,
WebXRImageTracking: ()=>fE,
WebXRInput: ()=>Fp,
WebXRInputSource: ()=>Lp,
WebXRLayers: ()=>IE,
WebXRLightEstimation: ()=>gE,
WebXRManagedOutputCanvas: ()=>Gs,
WebXRManagedOutputCanvasOptions: ()=>ks,
WebXRMeshDetector: ()=>pE,
WebXRMicrosoftMixedRealityController: ()=>NE,
WebXRMotionControllerManager: ()=>Ip,
WebXRMotionControllerTeleportation: ()=>Vf,
WebXRNearControllerMode: ()=>Pf,
WebXRNearInteraction: ()=>Df,
WebXROculusTouchMotionController: ()=>FE,
WebXRPlaneDetector: ()=>tE,
WebXRProfiledMotionController: ()=>Pp,
WebXRProjectionLayerWrapper: ()=>RE,
WebXRSessionManager: ()=>Xs,
WebXRState: ()=>Ns,
WebXRTrackingState: ()=>Ls,
WebXRWalkingLocomotion: ()=>SE,
WeightedSound: ()=>Kr,
WindowsMotionController: ()=>dd,
WorkerPool: ()=>gp,
WorleyNoise3DBlock: ()=>Sg,
XRWindowsMotionController: ()=>pd,
Xbox360Button: ()=>Sa,
Xbox360Dpad: ()=>Aa,
Xbox360Pad: ()=>Ma,
XboxInput: ()=>Di,
_BabylonLoaderRegistered: ()=>D_,
_BasisTextureLoader: ()=>dm,
_CreationDataStorage: ()=>Lr,
_DDSTextureLoader: ()=>fp,
_ENVTextureLoader: ()=>_p,
_HDRTextureLoader: ()=>em,
_IAnimationState: ()=>Ke,
_InstancesBatch: ()=>wr,
_KTXTextureLoader: ()=>Tp,
_MeshCollisionData: ()=>br,
_OcclusionDataStorage: ()=>fc,
_PrimaryIsoTriangle: ()=>Vv,
_TGATextureLoader: ()=>$_,
_TimeToken: ()=>pc,
_UpdateRGBDAsync: ()=>Kc,
_forceSceneHelpersToBundle: ()=>zf,
_forceTransformFeedbackToBundle: ()=>_c,
_injectLTSFileTools: ()=>ci,
allocateAndCopyTypedBuffer: ()=>gr,
className: ()=>vi,
createDetailMapPlugin: ()=>$g,
createPBRAnisotropicPlugin: ()=>Kg,
createPBRBRDFPlugin: ()=>Qg,
createPBRClearCoatPlugin: ()=>qg,
createPBRSheenPlugin: ()=>Zg,
createPBRSubSurfacePlugin: ()=>Jg,
createYieldingScheduler: ()=>Yn,
editableInPropertyPage: ()=>Yp,
expandToProperty: ()=>Re,
extractMinAndMax: ()=>ur,
extractMinAndMaxIndexed: ()=>cr,
inlineScheduler: ()=>jn,
makeAsyncFunction: ()=>Jn,
makeSyncFunction: ()=>Zn,
nativeOverride: ()=>ze,
normalizeEnvInfo: ()=>kc,
runCoroutine: ()=>Kn,
runCoroutineAsync: ()=>qn,
runCoroutineSync: ()=>Qn,
serialize: ()=>Ce,
serializeAsCameraReference: ()=>Ve,
serializeAsColor3: ()=>Me,
serializeAsColor4: ()=>Fe,
serializeAsColorCurves: ()=>Le,
serializeAsFresnelParameters: ()=>Ie,
serializeAsImageProcessingConfiguration: ()=>we,
serializeAsMatrix: ()=>Ue,
serializeAsMeshReference: ()=>Ne,
serializeAsQuaternion: ()=>Be,
serializeAsTexture: ()=>Pe,
serializeAsVector2: ()=>Oe,
serializeAsVector3: ()=>De,
setAndStartTimer: ()=>Bf,
setStereoscopicAnaglyphRigMode: ()=>Ga,
setStereoscopicRigMode: ()=>Ka,
setVRRigMode: ()=>ls,
setWebVRRigMode: ()=>ps
});
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, n) {
for (var r in this._BabylonFileParsers)
Object.prototype.hasOwnProperty.call(this._BabylonFileParsers, r) && this._BabylonFileParsers[r](e, t, i, n)
}
,
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_COMPRESSED_RGBA_BPTC_UNORM = 36492,
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_RGBA_S3TC_DXT3 = 33778,
e.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1 = 33777,
e.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1 = 33776,
e.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4 = 37808,
e.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL = 36196,
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_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.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
}()
, 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, n) {
void 0 === t && (t = !1),
this.initialize(e, t, i, n)
}
return e.prototype.initialize = function(e, t, i, n) {
return void 0 === t && (t = !1),
this.mask = e,
this.skipNextObservers = t,
this.target = i,
this.currentTarget = n,
this
}
,
e
}()
, c = function(e, t, i) {
void 0 === i && (i = null),
this.callback = e,
this.mask = t,
this.scope = i,
this._willBeUnregistered = !1,
this.unregisterOnNextCall = !1
}
, u = 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, n, r) {
void 0 === n && (n = -1),
void 0 === r && (r = 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, n, !1, r);
l && o._observers.push(l)
}
return o
}
,
e
}()
, h = function() {
function e(e) {
this._observers = new Array,
this._eventState = new l(0),
e && (this._onObserverAdded = e)
}
return e.FromPromise = function(t, i) {
var n = new e;
return t.then((function(e) {
n.notifyObservers(e)
}
)).catch((function(e) {
if (!i)
throw e;
i.notifyObservers(e)
}
)),
n
}
,
Object.defineProperty(e.prototype, "observers", {
get: function() {
return this._observers
},
enumerable: !1,
configurable: !0
}),
e.prototype.add = function(e, t, i, n, r) {
if (void 0 === t && (t = -1),
void 0 === i && (i = !1),
void 0 === n && (n = null),
void 0 === r && (r = !1),
!e)
return null;
var o = new c(e,t,n);
return o.unregisterOnNextCall = r,
i ? this._observers.unshift(o) : this._observers.push(o),
this._onObserverAdded && this._onObserverAdded(o),
o
}
,
e.prototype.addOnce = function(e) {
return this.add(e, void 0, void 0, void 0, !0)
}
,
e.prototype.remove = function(e) {
return !!e && -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 n = this._observers[i];
if (!(n._willBeUnregistered || n.callback !== e || t && t !== n.scope))
return this._deferUnregister(n),
!0
}
return !1
}
,
e.prototype._deferUnregister = function(e) {
var t = this;
e.unregisterOnNextCall = !1,
e._willBeUnregistered = !0,
setTimeout((function() {
t._remove(e)
}
), 0)
}
,
e.prototype._remove = function(e) {
if (!e)
return !1;
var t = this._observers.indexOf(e);
return -1 !== t && (this._observers.splice(t, 1),
!0)
}
,
e.prototype.makeObserverTopPriority = function(e) {
this._remove(e),
this._observers.unshift(e)
}
,
e.prototype.makeObserverBottomPriority = function(e) {
this._remove(e),
this._observers.push(e)
}
,
e.prototype.notifyObservers = function(e, t, i, n, r) {
if (void 0 === t && (t = -1),
!this._observers.length)
return !0;
var o = this._eventState;
o.mask = t,
o.target = i,
o.currentTarget = n,
o.skipNextObservers = !1,
o.lastReturnValue = e,
o.userInfo = r;
for (var a = 0, s = this._observers; a < s.length; a++) {
var l = s[a];
if (!l._willBeUnregistered && (l.mask & t && (l.scope ? o.lastReturnValue = l.callback.apply(l.scope, [e, o]) : o.lastReturnValue = l.callback(e, o),
l.unregisterOnNextCall && this._deferUnregister(l)),
o.skipNextObservers))
return !1
}
return !0
}
,
e.prototype.notifyObserversWithPromise = function(e, t, i, n, r) {
var o = this;
void 0 === t && (t = -1);
var a = Promise.resolve(e);
if (!this._observers.length)
return a;
var s = this._eventState;
return s.mask = t,
s.target = i,
s.currentTarget = n,
s.skipNextObservers = !1,
s.userInfo = r,
this._observers.forEach((function(i) {
s.skipNextObservers || i._willBeUnregistered || i.mask & t && (a = i.scope ? a.then((function(t) {
return s.lastReturnValue = t,
i.callback.apply(i.scope, [e, s])
}
)) : a.then((function(t) {
return s.lastReturnValue = t,
i.callback(e, s)
}
)),
i.unregisterOnNextCall && o._deferUnregister(i))
}
)),
a.then((function() {
return e
}
))
}
,
e.prototype.notifyObserver = function(e, t, i) {
if (void 0 === i && (i = -1),
!e._willBeUnregistered) {
var n = this._eventState;
n.mask = i,
n.skipNextObservers = !1,
e.callback(t, n),
e.unregisterOnNextCall && this._deferUnregister(e)
}
}
,
e.prototype.hasObservers = function() {
return this._observers.length > 0
}
,
e.prototype.clear = function() {
this._observers = new Array,
this._onObserverAdded = null
}
,
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 n = i[t];
if (n.mask & e || n.mask === e)
return !0
}
return !1
}
,
e
}()
, d = 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 n = e.Repeat(i - t, 360);
return n > 180 && (n -= 360),
n
}
,
e.PingPong = function(t, i) {
var n = e.Repeat(t, 2 * i);
return i - Math.abs(n - i)
}
,
e.SmoothStep = function(t, i, n) {
var r = e.Clamp(n);
return i * (r = -2 * r * r * r + 3 * r * r) + t * (1 - r)
}
,
e.MoveTowards = function(t, i, n) {
return Math.abs(i - t) <= n ? i : t + e.Sign(i - t) * n
}
,
e.MoveTowardsAngle = function(t, i, n) {
var r = e.DeltaAngle(t, i)
, o = 0;
return -n < r && r < n ? o = i : (i = t + r,
o = e.MoveTowards(t, i, n)),
o
}
,
e.Lerp = function(e, t, i) {
return e + (t - e) * i
}
,
e.LerpAngle = function(t, i, n) {
var r = e.Repeat(i - t, 360);
return r > 180 && (r -= 360),
t + r * e.Clamp(n)
}
,
e.InverseLerp = function(t, i, n) {
return t != i ? e.Clamp((n - t) / (i - t)) : 0
}
,
e.Hermite = function(e, t, i, n, r) {
var o = r * r
, a = r * o;
return e * (2 * a - 3 * o + 1) + i * (-2 * a + 3 * o) + t * (a - 2 * o + r) + n * (a - o)
}
,
e.Hermite1stDerivative = function(e, t, i, n, r) {
var o = r * r;
return 6 * (o - r) * e + (3 * o - 4 * r + 1) * t + 6 * (-o + r) * i + (3 * o - 2 * r) * n
}
,
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 n = t % i;
return 0 === n ? i : e.HCF(i, n)
}
,
e.TwoPi = 2 * Math.PI,
e
}()
, p = 1 / 2.2
, f = 2.2
, _ = (1 + Math.sqrt(5)) / 2
, m = .001
, g = function() {
function e() {}
return e.BuildArray = function(e, t) {
for (var i = [], n = 0; n < e; ++n)
i.push(t());
return i
}
,
e.BuildTuple = function(t, i) {
return e.BuildArray(t, i)
}
,
e
}()
, v = {};
function y(e, t) {
v[e] = t
}
function b(e) {
return v[e]
}
var T = 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 n = e.MatrixTrackedMatrices[i]
, r = n._m;
n._m = new Array(16);
for (var o = 0; o < 16; ++o)
n._m[o] = r[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
}()
, E = 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._LastCreatedScene = null,
e.UseFallbackTexture = !0,
e.FallbackTexture = "",
e
}()
, S = 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 = S(this.x);
return 397 * e ^ S(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(t) {
return new e(this.x + t.x,this.y + t.y)
}
,
e.prototype.addToRef = function(e, t) {
return t.x = this.x + e.x,
t.y = this.y + e.y,
this
}
,
e.prototype.addInPlace = function(e) {
return this.x += e.x,
this.y += e.y,
this
}
,
e.prototype.addVector3 = function(t) {
return new e(this.x + t.x,this.y + t.y)
}
,
e.prototype.subtract = function(t) {
return new e(this.x - t.x,this.y - t.y)
}
,
e.prototype.subtractToRef = function(e, t) {
return t.x = this.x - e.x,
t.y = this.y - e.y,
this
}
,
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(t) {
return new e(this.x * t.x,this.y * t.y)
}
,
e.prototype.multiplyToRef = function(e, t) {
return t.x = this.x * e.x,
t.y = this.y * e.y,
this
}
,
e.prototype.multiplyByFloats = function(t, i) {
return new e(this.x * t,this.y * i)
}
,
e.prototype.divide = function(t) {
return new e(this.x / t.x,this.y / t.y)
}
,
e.prototype.divideToRef = function(e, t) {
return t.x = this.x / e.x,
t.y = this.y / e.y,
this
}
,
e.prototype.divideInPlace = function(e) {
return this.divideToRef(e, this)
}
,
e.prototype.negate = function() {
return new e(-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(t) {
var i = new e(0,0);
return this.scaleToRef(t, i),
i
}
,
e.prototype.scaleToRef = function(e, t) {
return t.x = this.x * e,
t.y = this.y * e,
this
}
,
e.prototype.scaleAndAddToRef = function(e, t) {
return t.x += this.x * e,
t.y += this.y * e,
this
}
,
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 = m),
e && d.WithinEpsilon(this.x, e.x, t) && d.WithinEpsilon(this.y, e.y, t)
}
,
e.prototype.floor = function() {
return new e(Math.floor(this.x),Math.floor(this.y))
}
,
e.prototype.fract = function() {
return new e(this.x - Math.floor(this.x),this.y - Math.floor(this.y))
}
,
e.prototype.rotateToRef = function(e, t) {
var i = Math.cos(e)
, n = Math.sin(e);
return t.x = i * this.x - n * this.y,
t.y = n * this.x + i * this.y,
this
}
,
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 e(this.x,this.y)
}
,
e.Zero = function() {
return new e(0,0)
}
,
e.One = function() {
return new e(1,1)
}
,
e.FromArray = function(t, i) {
return void 0 === i && (i = 0),
new e(t[i],t[i + 1])
}
,
e.FromArrayToRef = function(e, t, i) {
i.x = e[t],
i.y = e[t + 1]
}
,
e.CatmullRom = function(t, i, n, r, o) {
var a = o * o
, s = o * a;
return new e(.5 * (2 * i.x + (-t.x + n.x) * o + (2 * t.x - 5 * i.x + 4 * n.x - r.x) * a + (-t.x + 3 * i.x - 3 * n.x + r.x) * s),.5 * (2 * i.y + (-t.y + n.y) * o + (2 * t.y - 5 * i.y + 4 * n.y - r.y) * a + (-t.y + 3 * i.y - 3 * n.y + r.y) * s))
}
,
e.Clamp = function(t, i, n) {
var r = t.x;
r = (r = r > n.x ? n.x : r) < i.x ? i.x : r;
var o = t.y;
return new e(r,o = (o = o > n.y ? n.y : o) < i.y ? i.y : o)
}
,
e.Hermite = function(t, i, n, r, o) {
var a = o * o
, s = o * a
, l = 2 * s - 3 * a + 1
, c = -2 * s + 3 * a
, u = s - 2 * a + o
, h = s - a;
return new e(t.x * l + n.x * c + i.x * u + r.x * h,t.y * l + n.y * c + i.y * u + r.y * h)
}
,
e.Hermite1stDerivative = function(t, i, n, r, o) {
var a = e.Zero();
return this.Hermite1stDerivativeToRef(t, i, n, r, o, a),
a
}
,
e.Hermite1stDerivativeToRef = function(e, t, i, n, r, o) {
var a = r * r;
o.x = 6 * (a - r) * e.x + (3 * a - 4 * r + 1) * t.x + 6 * (-a + r) * i.x + (3 * a - 2 * r) * n.x,
o.y = 6 * (a - r) * e.y + (3 * a - 4 * r + 1) * t.y + 6 * (-a + r) * i.y + (3 * a - 2 * r) * n.y
}
,
e.Lerp = function(t, i, n) {
return new e(t.x + (i.x - t.x) * n,t.y + (i.y - t.y) * n)
}
,
e.Dot = function(e, t) {
return e.x * t.x + e.y * t.y
}
,
e.Normalize = function(t) {
var i = e.Zero();
return this.NormalizeToRef(t, i),
i
}
,
e.NormalizeToRef = function(e, t) {
var i = e.length();
0 !== i && (t.x = e.x / i,
t.y = e.y / i)
}
,
e.Minimize = function(t, i) {
return new e(t.x < i.x ? t.x : i.x,t.y < i.y ? t.y : i.y)
}
,
e.Maximize = function(t, i) {
return new e(t.x > i.x ? t.x : i.x,t.y > i.y ? t.y : i.y)
}
,
e.Transform = function(t, i) {
var n = e.Zero();
return e.TransformToRef(t, i, n),
n
}
,
e.TransformToRef = function(e, t, i) {
var n = t.m
, r = e.x * n[0] + e.y * n[4] + n[12]
, o = e.x * n[1] + e.y * n[5] + n[13];
i.x = r,
i.y = o
}
,
e.PointInTriangle = function(e, t, i, n) {
var r = .5 * (-i.y * n.x + t.y * (-i.x + n.x) + t.x * (i.y - n.y) + i.x * n.y)
, o = r < 0 ? -1 : 1
, a = (t.y * n.x - t.x * n.y + (n.y - t.y) * e.x + (t.x - n.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 * r * o
}
,
e.Distance = function(t, i) {
return Math.sqrt(e.DistanceSquared(t, i))
}
,
e.DistanceSquared = function(e, t) {
var i = e.x - t.x
, n = e.y - t.y;
return i * i + n * n
}
,
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.DistanceOfPointFromSegment = function(t, i, n) {
var r = e.DistanceSquared(i, n);
if (0 === r)
return e.Distance(t, i);
var o = n.subtract(i)
, a = Math.max(0, Math.min(1, e.Dot(t.subtract(i), o) / r))
, s = i.add(o.multiplyByFloats(a, a));
return e.Distance(t, s)
}
,
e
}()
, x = 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 = S(this._x);
return 397 * (e = 397 * e ^ S(this._y)) ^ S(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 C.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
}
,
e.prototype.add = function(t) {
return new e(this._x + t._x,this._y + t._y,this._z + t._z)
}
,
e.prototype.addToRef = function(e, t) {
return t.copyFromFloats(this._x + e._x, this._y + e._y, this._z + e._z)
}
,
e.prototype.subtractInPlace = function(e) {
return this.x -= e._x,
this.y -= e._y,
this.z -= e._z,
this
}
,
e.prototype.subtract = function(t) {
return new e(this._x - t._x,this._y - t._y,this._z - t._z)
}
,
e.prototype.subtractToRef = function(e, t) {
return this.subtractFromFloatsToRef(e._x, e._y, e._z, t)
}
,
e.prototype.subtractFromFloats = function(t, i, n) {
return new e(this._x - t,this._y - i,this._z - n)
}
,
e.prototype.subtractFromFloatsToRef = function(e, t, i, n) {
return n.copyFromFloats(this._x - e, this._y - t, this._z - i)
}
,
e.prototype.negate = function() {
return new e(-this._x,-this._y,-this._z)
}
,
e.prototype.negateInPlace = function() {
return this.x *= -1,
this.y *= -1,
this.z *= -1,
this
}
,
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
}
,
e.prototype.scale = function(t) {
return new e(this._x * t,this._y * t,this._z * t)
}
,
e.prototype.scaleToRef = function(e, t) {
return t.copyFromFloats(this._x * e, this._y * e, this._z * e)
}
,
e.prototype.scaleAndAddToRef = function(e, t) {
return t.addInPlaceFromFloats(this._x * e, this._y * e, this._z * e)
}
,
e.prototype.projectOnPlane = function(t, i) {
var n = e.Zero();
return this.projectOnPlaneToRef(t, i, n),
n
}
,
e.prototype.projectOnPlaneToRef = function(t, i, n) {
var r = t.normal
, o = t.d
, a = M.Vector3[0];
this.subtractToRef(i, a),
a.normalize();
var s = e.Dot(a, r)
, l = -(e.Dot(i, r) + o) / s
, c = a.scaleInPlace(l);
i.addToRef(c, n)
}
,
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 = m),
e && d.WithinEpsilon(this._x, e._x, t) && d.WithinEpsilon(this._y, e._y, t) && d.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
}
,
e.prototype.multiply = function(e) {
return this.multiplyByFloats(e._x, e._y, e._z)
}
,
e.prototype.multiplyToRef = function(e, t) {
return t.copyFromFloats(this._x * e._x, this._y * e._y, this._z * e._z)
}
,
e.prototype.multiplyByFloats = function(t, i, n) {
return new e(this._x * t,this._y * i,this._z * n)
}
,
e.prototype.divide = function(t) {
return new e(this._x / t._x,this._y / t._y,this._z / t._z)
}
,
e.prototype.divideToRef = function(e, t) {
return t.copyFromFloats(this._x / e._x, this._y / e._y, this._z / e._z)
}
,
e.prototype.divideInPlace = function(e) {
return this.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 (!d.WithinEpsilon(t, i, e))
return !0;
var n = Math.abs(this._z);
return !d.WithinEpsilon(t, n, e) || !d.WithinEpsilon(i, n, 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 e(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z))
}
,
e.prototype.fract = function() {
return new e(this._x - Math.floor(this._x),this._y - Math.floor(this._y),this._z - Math.floor(this._z))
}
,
e.prototype.length = function() {
return Math.sqrt(this._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
}
,
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, n) {
t[i] = M.Vector3[0][e[n]]
}
))),
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) {
return e.Cross(this, t)
}
,
e.prototype.normalizeFromLength = function(e) {
return 0 === e || 1 === e ? this : this.scaleInPlace(1 / e)
}
,
e.prototype.normalizeToNew = function() {
var t = new e(0,0,0);
return this.normalizeToRef(t),
t
}
,
e.prototype.normalizeToRef = function(e) {
var t = this.length();
return 0 === t || 1 === t ? e.copyFromFloats(this._x, this._y, this._z) : this.scaleToRef(1 / t, e)
}
,
e.prototype.clone = function() {
return new e(this._x,this._y,this._z)
}
,
e.prototype.copyFrom = function(e) {
return this.copyFromFloats(e._x, e._y, e._z)
}
,
e.prototype.copyFromFloats = function(e, t, i) {
return this.x = e,
this.y = t,
this.z = i,
this
}
,
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
}
,
e.GetClipFactor = function(t, i, n, r) {
var o = e.Dot(t, n) - r;
return o / (o - (e.Dot(i, n) - r))
}
,
e.GetAngleBetweenVectors = function(t, i, n) {
var r = t.normalizeToRef(M.Vector3[1])
, o = i.normalizeToRef(M.Vector3[2])
, a = e.Dot(r, o)
, s = Math.acos(a)
, l = M.Vector3[3];
return e.CrossToRef(r, o, l),
e.Dot(l, n) > 0 ? isNaN(s) ? 0 : s : isNaN(s) ? -Math.PI : -Math.acos(a)
}
,
e.GetAngleBetweenVectorsOnPlane = function(t, i, n) {
M.Vector3[0].copyFrom(t);
var r = M.Vector3[0];
M.Vector3[1].copyFrom(i);
var o = M.Vector3[1];
M.Vector3[2].copyFrom(n);
var a = M.Vector3[2]
, s = M.Vector3[3]
, l = M.Vector3[4];
r.normalize(),
o.normalize(),
a.normalize(),
e.CrossToRef(a, r, s),
e.CrossToRef(s, a, l);
var c = Math.atan2(e.Dot(o, s), e.Dot(o, l));
return d.NormalizeRadians(c)
}
,
e.SlerpToRef = function(t, i, n, r) {
n = d.Clamp(n, 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, h = e.Dot(o, a);
if (h < 1 - m) {
var p = Math.acos(h)
, f = 1 / Math.sin(p);
c = Math.sin((1 - n) * p) * f,
u = Math.sin(n * p) * f
} else
c = 1 - n,
u = n;
o.scaleInPlace(c),
a.scaleInPlace(u),
r.copyFrom(o).addInPlace(a),
r.scaleInPlace(d.Lerp(s, l, n))
}
,
e.SmoothToRef = function(t, i, n, r, o) {
e.SlerpToRef(t, i, 0 === r ? 1 : n / r, 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) {
i.x = e[t],
i.y = e[t + 1],
i.z = e[t + 2]
}
,
e.FromFloatArrayToRef = function(t, i, n) {
return e.FromArrayToRef(t, i, n)
}
,
e.FromFloatsToRef = function(e, t, i, n) {
n.copyFromFloats(e, t, i)
}
,
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, "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, "ZeroReadOnly", {
get: function() {
return e._ZeroReadOnly
},
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.TransformCoordinates = function(t, i) {
var n = e.Zero();
return e.TransformCoordinatesToRef(t, i, n),
n
}
,
e.TransformCoordinatesToRef = function(t, i, n) {
e.TransformCoordinatesFromFloatsToRef(t._x, t._y, t._z, i, n)
}
,
e.TransformCoordinatesFromFloatsToRef = function(e, t, i, n, r) {
var o = n.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]);
r.x = a * c,
r.y = s * c,
r.z = l * c
}
,
e.TransformNormal = function(t, i) {
var n = e.Zero();
return e.TransformNormalToRef(t, i, n),
n
}
,
e.TransformNormalToRef = function(e, t, i) {
this.TransformNormalFromFloatsToRef(e._x, e._y, e._z, t, i)
}
,
e.TransformNormalFromFloatsToRef = function(e, t, i, n, r) {
var o = n.m;
r.x = e * o[0] + t * o[4] + i * o[8],
r.y = e * o[1] + t * o[5] + i * o[9],
r.z = e * o[2] + t * o[6] + i * o[10]
}
,
e.CatmullRom = function(t, i, n, r, o) {
var a = o * o
, s = o * a;
return new e(.5 * (2 * i._x + (-t._x + n._x) * o + (2 * t._x - 5 * i._x + 4 * n._x - r._x) * a + (-t._x + 3 * i._x - 3 * n._x + r._x) * s),.5 * (2 * i._y + (-t._y + n._y) * o + (2 * t._y - 5 * i._y + 4 * n._y - r._y) * a + (-t._y + 3 * i._y - 3 * n._y + r._y) * s),.5 * (2 * i._z + (-t._z + n._z) * o + (2 * t._z - 5 * i._z + 4 * n._z - r._z) * a + (-t._z + 3 * i._z - 3 * n._z + r._z) * s))
}
,
e.Clamp = function(t, i, n) {
var r = new e;
return e.ClampToRef(t, i, n, r),
r
}
,
e.ClampToRef = function(e, t, i, n) {
var r = e._x;
r = (r = r > i._x ? i._x : r) < t._x ? t._x : r;
var o = e._y;
o = (o = o > i._y ? i._y : o) < t._y ? t._y : o;
var a = e._z;
a = (a = a > i._z ? i._z : a) < t._z ? t._z : a,
n.copyFromFloats(r, o, a)
}
,
e.CheckExtends = function(e, t, i) {
t.minimizeInPlace(e),
i.maximizeInPlace(e)
}
,
e.Hermite = function(t, i, n, r, o) {
var a = o * o
, s = o * a
, l = 2 * s - 3 * a + 1
, c = -2 * s + 3 * a
, u = s - 2 * a + o
, h = s - a;
return new e(t._x * l + n._x * c + i._x * u + r._x * h,t._y * l + n._y * c + i._y * u + r._y * h,t._z * l + n._z * c + i._z * u + r._z * h)
}
,
e.Hermite1stDerivative = function(t, i, n, r, o) {
var a = e.Zero();
return this.Hermite1stDerivativeToRef(t, i, n, r, o, a),
a
}
,
e.Hermite1stDerivativeToRef = function(e, t, i, n, r, o) {
var a = r * r;
o.x = 6 * (a - r) * e.x + (3 * a - 4 * r + 1) * t.x + 6 * (-a + r) * i.x + (3 * a - 2 * r) * n.x,
o.y = 6 * (a - r) * e.y + (3 * a - 4 * r + 1) * t.y + 6 * (-a + r) * i.y + (3 * a - 2 * r) * n.y,
o.z = 6 * (a - r) * e.z + (3 * a - 4 * r + 1) * t.z + 6 * (-a + r) * i.z + (3 * a - 2 * r) * n.z
}
,
e.Lerp = function(t, i, n) {
var r = new e(0,0,0);
return e.LerpToRef(t, i, n, r),
r
}
,
e.LerpToRef = function(e, t, i, n) {
n.x = e._x + (t._x - e._x) * i,
n.y = e._y + (t._y - e._y) * i,
n.z = e._z + (t._z - e._z) * i
}
,
e.Dot = function(e, t) {
return e._x * t._x + e._y * t._y + e._z * t._z
}
,
e.Cross = function(t, i) {
var n = e.Zero();
return e.CrossToRef(t, i, n),
n
}
,
e.CrossToRef = function(e, t, i) {
var n = e._y * t._z - e._z * t._y
, r = e._z * t._x - e._x * t._z
, o = e._x * t._y - e._y * t._x;
i.copyFromFloats(n, r, o)
}
,
e.Normalize = function(t) {
var i = e.Zero();
return e.NormalizeToRef(t, i),
i
}
,
e.NormalizeToRef = function(e, t) {
e.normalizeToRef(t)
}
,
e.Project = function(t, i, n, r) {
var o = new e;
return e.ProjectToRef(t, i, n, r, o),
o
}
,
e.ProjectToRef = function(t, i, n, r, o) {
var a = r.width
, s = r.height
, l = r.x
, c = r.y
, u = M.Matrix[1];
P.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(n, h),
h.multiplyToRef(u, h),
e.TransformCoordinatesToRef(t, h, o),
o
}
,
e._UnprojectFromInvertedMatrixToRef = function(t, i, n) {
e.TransformCoordinatesToRef(t, i, n);
var r = i.m
, o = t._x * r[3] + t._y * r[7] + t._z * r[11] + r[15];
d.WithinEpsilon(o, 1) && n.scaleInPlace(1 / o)
}
,
e.UnprojectFromTransform = function(e, t, i, n, r) {
return this.Unproject(e, t, i, n, r, P.IdentityReadOnly)
}
,
e.Unproject = function(t, i, n, r, o, a) {
var s = e.Zero();
return e.UnprojectToRef(t, i, n, r, o, a, s),
s
}
,
e.UnprojectToRef = function(t, i, n, r, o, a, s) {
e.UnprojectFloatsToRef(t._x, t._y, t._z, i, n, r, o, a, s)
}
,
e.UnprojectFloatsToRef = function(t, i, n, r, 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];
d.x = t / r * 2 - 1,
d.y = -(i / o * 2 - 1),
(null === (u = E.LastCreatedEngine) || void 0 === u ? void 0 : u.isNDCHalfZRange) ? d.z = n : d.z = 2 * n - 1,
e._UnprojectFromInvertedMatrixToRef(d, h, c)
}
,
e.Minimize = function(e, t) {
var i = e.clone();
return i.minimizeInPlace(t),
i
}
,
e.Maximize = function(e, t) {
var i = e.clone();
return 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
, n = e._y - t._y
, r = e._z - t._z;
return i * i + n * n + r * r
}
,
e.ProjectOnTriangleToRef = function(t, i, n, r, o) {
var a = M.Vector3[0]
, s = M.Vector3[1]
, l = M.Vector3[2]
, c = M.Vector3[3]
, u = M.Vector3[4];
n.subtractToRef(i, a),
r.subtractToRef(i, s),
r.subtractToRef(n, l);
var h = a.length()
, p = s.length()
, f = l.length();
if (h < m || p < m || f < m)
return o.copyFrom(i),
e.Distance(t, i);
t.subtractToRef(i, u),
e.CrossToRef(a, s, c);
var _ = c.length();
if (_ < m)
return o.copyFrom(i),
e.Distance(t, i);
c.normalizeFromLength(_);
var g = u.length();
if (g < m)
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]
, A = M.Vector3[8];
T.copyFrom(a).scaleInPlace(1 / h),
A.copyFrom(s).scaleInPlace(1 / p),
T.addInPlace(A).scaleInPlace(-1),
E.copyFrom(a).scaleInPlace(-1 / h),
A.copyFrom(l).scaleInPlace(1 / f),
E.addInPlace(A).scaleInPlace(-1),
S.copyFrom(l).scaleInPlace(-1 / f),
A.copyFrom(s).scaleInPlace(-1 / p),
S.addInPlace(A).scaleInPlace(-1);
var x = M.Vector3[9];
x.copyFrom(b).subtractInPlace(i),
e.CrossToRef(T, x, A);
var R = e.Dot(A, c);
x.copyFrom(b).subtractInPlace(n),
e.CrossToRef(E, x, A);
var C = e.Dot(A, c);
x.copyFrom(b).subtractInPlace(r),
e.CrossToRef(S, x, A);
var P, I, O = e.Dot(A, c), D = M.Vector3[10];
R > 0 && C < 0 ? (D.copyFrom(a),
P = i,
I = n) : C > 0 && O < 0 ? (D.copyFrom(l),
P = n,
I = r) : (D.copyFrom(s).scaleInPlace(-1),
P = r,
I = i);
var N = M.Vector3[9]
, L = M.Vector3[4];
if (P.subtractToRef(b, A),
I.subtractToRef(b, N),
e.CrossToRef(A, N, L),
!(e.Dot(L, c) < 0))
return o.copyFrom(b),
Math.abs(g * v);
var F = M.Vector3[5];
e.CrossToRef(D, L, F),
F.normalize();
var w = M.Vector3[9];
w.copyFrom(P).subtractInPlace(b);
var B = w.length();
if (B < m)
return o.copyFrom(P),
e.Distance(t, P);
w.normalizeFromLength(B);
var U = e.Dot(F, w)
, V = M.Vector3[7];
V.copyFrom(b).addInPlace(F.scaleInPlace(B * U)),
A.copyFrom(V).subtractInPlace(P),
g = D.length(),
D.normalizeFromLength(g);
var k = e.Dot(A, D) / Math.max(g, m);
return k = d.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, n) {
var r = e.Zero();
return e.RotationFromAxisToRef(t, i, n, r),
r
}
,
e.RotationFromAxisToRef = function(e, t, i, n) {
var r = M.Quaternion[0];
C.RotationQuaternionFromAxisToRef(e, t, i, r),
r.toEulerAnglesToRef(n)
}
,
e._UpReadOnly = e.Up(),
e._LeftHandedForwardReadOnly = e.Forward(!1),
e._RightHandedForwardReadOnly = e.Forward(!0),
e._RightReadOnly = e.Right(),
e._LeftReadOnly = e.Left(),
e._ZeroReadOnly = e.Zero(),
e
}()
, R = function() {
function e(e, t, i, n) {
this.x = e,
this.y = t,
this.z = i,
this.w = n
}
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 = S(this.x);
return 397 * (e = 397 * (e = 397 * e ^ S(this.y)) ^ S(this.z)) ^ S(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(t) {
return new e(this.x + t.x,this.y + t.y,this.z + t.z,this.w + t.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,
this
}
,
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(t) {
return new e(this.x - t.x,this.y - t.y,this.z - t.z,this.w - t.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,
this
}
,
e.prototype.subtractFromFloats = function(t, i, n, r) {
return new e(this.x - t,this.y - i,this.z - n,this.w - r)
}
,
e.prototype.subtractFromFloatsToRef = function(e, t, i, n, r) {
return r.x = this.x - e,
r.y = this.y - t,
r.z = this.z - i,
r.w = this.w - n,
this
}
,
e.prototype.negate = function() {
return new e(-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(t) {
return new e(this.x * t,this.y * t,this.z * t,this.w * t)
}
,
e.prototype.scaleToRef = function(e, t) {
return t.x = this.x * e,
t.y = this.y * e,
t.z = this.z * e,
t.w = this.w * e,
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,
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 = m),
e && d.WithinEpsilon(this.x, e.x, t) && d.WithinEpsilon(this.y, e.y, t) && d.WithinEpsilon(this.z, e.z, t) && d.WithinEpsilon(this.w, e.w, t)
}
,
e.prototype.equalsToFloats = function(e, t, i, n) {
return this.x === e && this.y === t && this.z === i && this.w === n
}
,
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(t) {
return new e(this.x * t.x,this.y * t.y,this.z * t.z,this.w * t.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,
this
}
,
e.prototype.multiplyByFloats = function(t, i, n, r) {
return new e(this.x * t,this.y * i,this.z * n,this.w * r)
}
,
e.prototype.divide = function(t) {
return new e(this.x / t.x,this.y / t.y,this.z / t.z,this.w / t.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,
this
}
,
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 e(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z),Math.floor(this.w))
}
,
e.prototype.fract = function() {
return new e(this.x - Math.floor(this.x),this.y - Math.floor(this.y),this.z - Math.floor(this.z),this.w - Math.floor(this.w))
}
,
e.prototype.length = function() {
return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w)
}
,
e.prototype.lengthSquared = function() {
return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w
}
,
e.prototype.normalize = function() {
var e = this.length();
return 0 === e ? this : this.scaleInPlace(1 / e)
}
,
e.prototype.toVector3 = function() {
return new x(this.x,this.y,this.z)
}
,
e.prototype.clone = function() {
return new e(this.x,this.y,this.z,this.w)
}
,
e.prototype.copyFrom = function(e) {
return this.x = e.x,
this.y = e.y,
this.z = e.z,
this.w = e.w,
this
}
,
e.prototype.copyFromFloats = function(e, t, i, n) {
return this.x = e,
this.y = t,
this.z = i,
this.w = n,
this
}
,
e.prototype.set = function(e, t, i, n) {
return this.copyFromFloats(e, t, i, n)
}
,
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) {
i.x = e[t],
i.y = e[t + 1],
i.z = e[t + 2],
i.w = e[t + 3]
}
,
e.FromFloatArrayToRef = function(t, i, n) {
e.FromArrayToRef(t, i, n)
}
,
e.FromFloatsToRef = function(e, t, i, n, r) {
r.x = e,
r.y = t,
r.z = i,
r.w = n
}
,
e.Zero = function() {
return new e(0,0,0,0)
}
,
e.One = function() {
return new e(1,1,1,1)
}
,
e.Normalize = function(t) {
var i = e.Zero();
return e.NormalizeToRef(t, i),
i
}
,
e.NormalizeToRef = function(e, t) {
t.copyFrom(e),
t.normalize()
}
,
e.Minimize = function(e, t) {
var i = e.clone();
return i.minimizeInPlace(t),
i
}
,
e.Maximize = function(e, t) {
var i = e.clone();
return 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
, n = e.y - t.y
, r = e.z - t.z
, o = e.w - t.w;
return i * i + n * n + r * r + 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 n = e.Zero();
return e.TransformCoordinatesToRef(t, i, n),
n
}
,
e.TransformCoordinatesToRef = function(t, i, n) {
e.TransformCoordinatesFromFloatsToRef(t._x, t._y, t._z, i, n)
}
,
e.TransformCoordinatesFromFloatsToRef = function(e, t, i, n, r) {
var o = n.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];
r.x = a,
r.y = s,
r.z = l,
r.w = c
}
,
e.TransformNormal = function(t, i) {
var n = e.Zero();
return e.TransformNormalToRef(t, i, n),
n
}
,
e.TransformNormalToRef = function(e, t, i) {
var n = t.m
, r = e.x * n[0] + e.y * n[4] + e.z * n[8]
, o = e.x * n[1] + e.y * n[5] + e.z * n[9]
, a = e.x * n[2] + e.y * n[6] + e.z * n[10];
i.x = r,
i.y = o,
i.z = a,
i.w = e.w
}
,
e.TransformNormalFromFloatsToRef = function(e, t, i, n, r, o) {
var a = r.m;
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 = n
}
,
e.FromVector3 = function(t, i) {
return void 0 === i && (i = 0),
new e(t._x,t._y,t._z,i)
}
,
e
}()
, C = function() {
function e(e, t, i, n) {
void 0 === e && (e = 0),
void 0 === t && (t = 0),
void 0 === i && (i = 0),
void 0 === n && (n = 1),
this._isDirty = !0,
this._x = e,
this._y = t,
this._z = i,
this._w = n
}
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 = S(this._x);
return 397 * (e = 397 * (e = 397 * e ^ S(this._y)) ^ S(this._z)) ^ S(this._w)
}
,
e.prototype.asArray = function() {
return [this._x, this._y, this._z, this._w]
}
,
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 = m),
e && d.WithinEpsilon(this._x, e._x, t) && d.WithinEpsilon(this._y, e._y, t) && d.WithinEpsilon(this._z, e._z, t) && d.WithinEpsilon(this._w, e._w, t)
}
,
e.prototype.clone = function() {
return new e(this._x,this._y,this._z,this._w)
}
,
e.prototype.copyFrom = function(e) {
return this.x = e._x,
this.y = e._y,
this.z = e._z,
this.w = e._w,
this
}
,
e.prototype.copyFromFloats = function(e, t, i, n) {
return this.x = e,
this.y = t,
this.z = i,
this.w = n,
this
}
,
e.prototype.set = function(e, t, i, n) {
return this.copyFromFloats(e, t, i, n)
}
,
e.prototype.add = function(t) {
return new e(this._x + t._x,this._y + t._y,this._z + t._z,this._w + t._w)
}
,
e.prototype.addInPlace = function(e) {
return this._x += e._x,
this._y += e._y,
this._z += e._z,
this._w += e._w,
this
}
,
e.prototype.subtract = function(t) {
return new e(this._x - t._x,this._y - t._y,this._z - t._z,this._w - t._w)
}
,
e.prototype.scale = function(t) {
return new e(this._x * t,this._y * t,this._z * t,this._w * t)
}
,
e.prototype.scaleToRef = function(e, t) {
return t.x = this._x * e,
t.y = this._y * e,
t.z = this._z * e,
t.w = this._w * e,
this
}
,
e.prototype.scaleInPlace = function(e) {
return this.x *= e,
this.y *= e,
this.z *= e,
this.w *= e,
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,
this
}
,
e.prototype.multiply = function(t) {
var i = new e(0,0,0,1);
return this.multiplyToRef(t, i),
i
}
,
e.prototype.multiplyToRef = function(e, t) {
var i = this._x * e._w + this._y * e._z - this._z * e._y + this._w * e._x
, n = -this._x * e._z + this._y * e._w + this._z * e._x + this._w * e._y
, r = 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, n, r, o),
this
}
,
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),
this
}
,
e.prototype.conjugateInPlace = function() {
return this.x *= -1,
this.y *= -1,
this.z *= -1,
this
}
,
e.prototype.conjugate = function() {
return new e(-this._x,-this._y,-this._z,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.normalize = function() {
var e = this.length();
if (0 === e)
return this;
var t = 1 / e;
return this.x *= t,
this.y *= t,
this.z *= t,
this.w *= t,
this
}
,
e.prototype.toEulerAngles = function() {
var e = x.Zero();
return this.toEulerAnglesToRef(e),
e
}
,
e.prototype.toEulerAnglesToRef = function(e) {
var t = this._z
, i = this._x
, n = this._y
, r = this._w
, o = r * r
, a = t * t
, s = i * i
, l = n * n
, c = n * t - i * r
, u = .4999999;
return c < -u ? (e.y = 2 * Math.atan2(n, r),
e.x = Math.PI / 2,
e.z = 0) : c > u ? (e.y = 2 * Math.atan2(n, r),
e.x = -Math.PI / 2,
e.z = 0) : (e.z = Math.atan2(2 * (i * n + t * r), -a - s + l + o),
e.x = Math.asin(-2 * (t * n - i * r)),
e.y = Math.atan2(2 * (t * i + n * r), a - s - l + o)),
this
}
,
e.prototype.toRotationMatrix = function(e) {
return P.FromQuaternionToRef(this, e),
this
}
,
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, n = e.m, r = n[0], o = n[4], a = n[8], s = n[1], l = n[5], c = n[9], u = n[2], h = n[6], d = n[10], p = r + l + d;
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) : r > l && r > d ? (i = 2 * Math.sqrt(1 + r - l - d),
t.w = (h - c) / i,
t.x = .25 * i,
t.y = (o + s) / i,
t.z = (a + u) / i) : l > d ? (i = 2 * Math.sqrt(1 + l - r - d),
t.w = (a - u) / i,
t.x = (o + s) / i,
t.y = .25 * i,
t.z = (c + h) / i) : (i = 2 * Math.sqrt(1 + d - r - l),
t.w = (s - o) / i,
t.x = (a + u) / i,
t.y = (c + h) / i,
t.z = .25 * i)
}
,
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) {
return e.Dot(t, i) >= 0
}
,
e.SmoothToRef = function(t, i, n, r, o) {
var a = 0 === r ? 1 : n / r;
a = d.Clamp(a, 0, 1),
e.SlerpToRef(t, i, a, o)
}
,
e.Zero = function() {
return new e(0,0,0,0)
}
,
e.Inverse = function(t) {
return new e(-t._x,-t._y,-t._z,t._w)
}
,
e.InverseToRef = function(e, t) {
return t.set(-e._x, -e._y, -e._z, e._w),
t
}
,
e.Identity = function() {
return new e(0,0,0,1)
}
,
e.IsIdentity = function(e) {
return e && 0 === e._x && 0 === e._y && 0 === e._z && 1 === e._w
}
,
e.RotationAxis = function(t, i) {
return e.RotationAxisToRef(t, i, new e)
}
,
e.RotationAxisToRef = function(e, t, i) {
var n = Math.sin(t / 2);
return e.normalize(),
i.w = Math.cos(t / 2),
i.x = e._x * n,
i.y = e._y * n,
i.z = e._z * n,
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) {
i.x = e[t],
i.y = e[t + 1],
i.z = e[t + 2],
i.w = e[t + 3]
}
,
e.FromEulerAngles = function(t, i, n) {
var r = new e;
return e.RotationYawPitchRollToRef(i, t, n, r),
r
}
,
e.FromEulerAnglesToRef = function(t, i, n, r) {
return e.RotationYawPitchRollToRef(i, t, n, r),
r
}
,
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) {
var n = x.Dot(e, t) + 1;
return n < m ? Math.abs(e.x) > Math.abs(e.z) ? i.set(-e.y, e.x, 0, 0) : i.set(0, -e.z, e.y, 0) : (x.CrossToRef(e, t, I.Vector3[0]),
i.set(I.Vector3[0].x, I.Vector3[0].y, I.Vector3[0].z, n)),
i.normalize()
}
,
e.RotationYawPitchRoll = function(t, i, n) {
var r = new e;
return e.RotationYawPitchRollToRef(t, i, n, r),
r
}
,
e.RotationYawPitchRollToRef = function(e, t, i, n) {
var r = .5 * i
, o = .5 * t
, a = .5 * e
, s = Math.sin(r)
, l = Math.cos(r)
, c = Math.sin(o)
, u = Math.cos(o)
, h = Math.sin(a)
, d = Math.cos(a);
n.x = d * c * l + h * u * s,
n.y = h * u * l - d * c * s,
n.z = d * u * s - h * c * l,
n.w = d * u * l + h * c * s
}
,
e.RotationAlphaBetaGamma = function(t, i, n) {
var r = new e;
return e.RotationAlphaBetaGammaToRef(t, i, n, r),
r
}
,
e.RotationAlphaBetaGammaToRef = function(e, t, i, n) {
var r = .5 * (i + e)
, o = .5 * (i - e)
, a = .5 * t;
n.x = Math.cos(o) * Math.sin(a),
n.y = Math.sin(o) * Math.sin(a),
n.z = Math.sin(r) * Math.cos(a),
n.w = Math.cos(r) * Math.cos(a)
}
,
e.RotationQuaternionFromAxis = function(t, i, n) {
var r = new e(0,0,0,0);
return e.RotationQuaternionFromAxisToRef(t, i, n, r),
r
}
,
e.RotationQuaternionFromAxisToRef = function(t, i, n, r) {
var o = M.Matrix[0];
P.FromXYZAxesToRef(t.normalize(), i.normalize(), n.normalize(), o),
e.FromRotationMatrixToRef(o, r)
}
,
e.FromLookDirectionLH = function(t, i) {
var n = new e;
return e.FromLookDirectionLHToRef(t, i, n),
n
}
,
e.FromLookDirectionLHToRef = function(t, i, n) {
var r = M.Matrix[0];
P.LookDirectionLHToRef(t, i, r),
e.FromRotationMatrixToRef(r, n)
}
,
e.FromLookDirectionRH = function(t, i) {
var n = new e;
return e.FromLookDirectionRHToRef(t, i, n),
n
}
,
e.FromLookDirectionRHToRef = function(t, i, n) {
var r = M.Matrix[0];
return P.LookDirectionRHToRef(t, i, r),
e.FromRotationMatrixToRef(r, n)
}
,
e.Slerp = function(t, i, n) {
var r = e.Identity();
return e.SlerpToRef(t, i, n, r),
r
}
,
e.SlerpToRef = function(e, t, i, n) {
var r, 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,
r = s ? -i : i;
else {
var l = Math.acos(a)
, c = 1 / Math.sin(l);
o = Math.sin((1 - i) * l) * c,
r = s ? -Math.sin(i * l) * c : Math.sin(i * l) * c
}
n.x = o * e._x + r * t._x,
n.y = o * e._y + r * t._y,
n.z = o * e._z + r * t._z,
n.w = o * e._w + r * t._w
}
,
e.Hermite = function(t, i, n, r, o) {
var a = o * o
, s = o * a
, l = 2 * s - 3 * a + 1
, c = -2 * s + 3 * a
, u = s - 2 * a + o
, h = s - a;
return new e(t._x * l + n._x * c + i._x * u + r._x * h,t._y * l + n._y * c + i._y * u + r._y * h,t._z * l + n._z * c + i._z * u + r._z * h,t._w * l + n._w * c + i._w * u + r._w * h)
}
,
e.Hermite1stDerivative = function(t, i, n, r, o) {
var a = e.Zero();
return this.Hermite1stDerivativeToRef(t, i, n, r, o, a),
a
}
,
e.Hermite1stDerivativeToRef = function(e, t, i, n, r, o) {
var a = r * r;
o.x = 6 * (a - r) * e.x + (3 * a - 4 * r + 1) * t.x + 6 * (-a + r) * i.x + (3 * a - 2 * r) * n.x,
o.y = 6 * (a - r) * e.y + (3 * a - 4 * r + 1) * t.y + 6 * (-a + r) * i.y + (3 * a - 2 * r) * n.y,
o.z = 6 * (a - r) * e.z + (3 * a - 4 * r + 1) * t.z + 6 * (-a + r) * i.z + (3 * a - 2 * r) * n.z,
o.w = 6 * (a - r) * e.w + (3 * a - 4 * r + 1) * t.w + 6 * (-a + r) * i.w + (3 * a - 2 * r) * n.w
}
,
e
}()
, P = function() {
function e() {
this._isIdentity = !1,
this._isIdentityDirty = !0,
this._isIdentity3x2 = !0,
this._isIdentity3x2Dirty = !0,
this.updateFlag = -1,
T.MatrixTrackPrecisionChange && T.MatrixTrackedMatrices.push(this),
this._m = new T.MatrixCurrentType(16),
this.markAsUpdated()
}
return Object.defineProperty(e, "Use64Bits", {
get: function() {
return T.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, n) {
void 0 === t && (t = !1),
void 0 === i && (i = !1),
void 0 === n && (n = !0),
this._isIdentity = e,
this._isIdentity3x2 = e || i,
this._isIdentityDirty = !this._isIdentity && t,
this._isIdentity3x2Dirty = !this._isIdentity3x2 && n
}
,
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]
, n = e[2]
, r = 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) + n * +(o * v - a * b + l * E) + r * -(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(t) {
var i = new e;
return this.addToRef(t, i),
i
}
,
e.prototype.addToRef = function(e, t) {
for (var i = this._m, n = t._m, r = e.m, o = 0; o < 16; o++)
n[o] = i[o] + r[o];
return t.markAsUpdated(),
this
}
,
e.prototype.addToSelf = function(e) {
for (var t = this._m, i = e.m, n = 0; n < 16; n++)
t[n] += i[n];
return this.markAsUpdated(),
this
}
,
e.prototype.invertToRef = function(t) {
if (!0 === this._isIdentity)
return e.IdentityToRef(t),
this;
var i = this._m
, n = i[0]
, r = 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 * _
, A = h * m - _ * d
, x = +(l * y - c * b + u * T)
, R = -(s * y - c * E + u * S)
, C = +(s * b - l * E + u * A)
, P = -(s * T - l * S + c * A)
, M = n * x + r * R + o * C + a * P;
if (0 === M)
return t.copyFrom(this),
this;
var I = 1 / M
, O = c * v - g * u
, D = l * v - m * u
, N = l * g - m * c
, L = s * v - _ * u
, F = 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 = -(r * y - o * b + a * T)
, H = +(n * y - o * E + a * S)
, X = -(n * b - r * E + a * A)
, j = +(n * T - r * S + o * A)
, Y = +(r * O - o * D + a * N)
, K = -(n * O - o * L + a * F)
, Q = +(n * D - r * L + a * w)
, q = -(n * N - r * F + o * w)
, Z = -(r * B - o * U + a * V)
, J = +(n * B - o * k + a * G)
, $ = -(n * U - r * k + a * z)
, ee = +(n * V - r * G + o * z);
return e.FromValuesToRef(x * I, W * I, Y * I, Z * I, R * I, H * I, K * I, J * I, C * I, X * I, Q * I, $ * I, P * I, j * I, q * I, ee * I, t),
this
}
,
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 x(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],
this
}
,
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(t) {
var i = new e;
return this.multiplyToRef(t, i),
i
}
,
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),
this) : e._isIdentity ? (t.copyFrom(this),
this) : (this.multiplyToArray(e, t._m, 0),
t.markAsUpdated(),
this)
}
,
e.prototype.multiplyToArray = function(e, t, i) {
var n = this._m
, r = e.m
, o = n[0]
, a = n[1]
, s = n[2]
, l = n[3]
, c = n[4]
, u = n[5]
, h = n[6]
, d = n[7]
, p = n[8]
, f = n[9]
, _ = n[10]
, m = n[11]
, g = n[12]
, v = n[13]
, y = n[14]
, b = n[15]
, T = r[0]
, E = r[1]
, S = r[2]
, A = r[3]
, x = r[4]
, R = r[5]
, C = r[6]
, P = r[7]
, M = r[8]
, I = r[9]
, O = r[10]
, D = r[11]
, N = r[12]
, L = r[13]
, F = r[14]
, w = r[15];
return t[i] = o * T + a * x + s * M + l * N,
t[i + 1] = o * E + a * R + s * I + l * L,
t[i + 2] = o * S + a * C + s * O + l * F,
t[i + 3] = o * A + a * P + s * D + l * w,
t[i + 4] = c * T + u * x + h * M + d * N,
t[i + 5] = c * E + u * R + h * I + d * L,
t[i + 6] = c * S + u * C + h * O + d * F,
t[i + 7] = c * A + u * P + h * D + d * w,
t[i + 8] = p * T + f * x + _ * M + m * N,
t[i + 9] = p * E + f * R + _ * I + m * L,
t[i + 10] = p * S + f * C + _ * O + m * F,
t[i + 11] = p * A + f * P + _ * D + m * w,
t[i + 12] = g * T + v * x + y * M + b * N,
t[i + 13] = g * E + v * R + y * I + b * L,
t[i + 14] = g * S + v * C + y * O + b * F,
t[i + 15] = g * A + 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
, n = t.m;
return i[0] === n[0] && i[1] === n[1] && i[2] === n[2] && i[3] === n[3] && i[4] === n[4] && i[5] === n[5] && i[6] === n[6] && i[7] === n[7] && i[8] === n[8] && i[9] === n[9] && i[10] === n[10] && i[11] === n[11] && i[12] === n[12] && i[13] === n[13] && i[14] === n[14] && i[15] === n[15]
}
,
e.prototype.clone = function() {
var t = new e;
return t.copyFrom(this),
t
}
,
e.prototype.getClassName = function() {
return "Matrix"
}
,
e.prototype.getHashCode = function() {
for (var e = S(this._m[0]), t = 1; t < 16; t++)
e = 397 * e ^ S(this._m[t]);
return e
}
,
e.prototype.decomposeToTransformNode = function(e) {
return e.rotationQuaternion = e.rotationQuaternion || new C,
this.decompose(e.scaling, e.rotationQuaternion, e.position)
}
,
e.prototype.decompose = function(t, i, n, r) {
if (this._isIdentity)
return n && n.setAll(0),
t && t.setAll(1),
i && i.copyFromFloats(0, 0, 0, 1),
!0;
var o = this._m;
if (n && n.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]),
r) {
var a = r.scaling.x < 0 ? -1 : 1
, s = r.scaling.y < 0 ? -1 : 1
, l = r.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]),
C.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 R(this._m[t + 0],this._m[t + 1],this._m[t + 2],this._m[t + 3])
}
,
e.prototype.setRow = function(e, t) {
return this.setRowFromFloats(e, t.x, t.y, t.z, t.w)
}
,
e.prototype.transpose = function() {
return e.Transpose(this)
}
,
e.prototype.transposeToRef = function(t) {
return e.TransposeToRef(this, t),
this
}
,
e.prototype.setRowFromFloats = function(e, t, i, n, r) {
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] = n,
this._m[o + 3] = r,
this.markAsUpdated(),
this
}
,
e.prototype.scale = function(t) {
var i = new e;
return this.scaleToRef(t, i),
i
}
,
e.prototype.scaleToRef = function(e, t) {
for (var i = 0; i < 16; i++)
t._m[i] = this._m[i] * e;
return t.markAsUpdated(),
this
}
,
e.prototype.scaleAndAddToRef = function(e, t) {
for (var i = 0; i < 16; i++)
t._m[i] += this._m[i] * e;
return t.markAsUpdated(),
this
}
,
e.prototype.toNormalMatrix = function(t) {
var i = M.Matrix[0];
this.invertToRef(i),
i.transposeToRef(t);
var n = t._m;
e.FromValuesToRef(n[0], n[1], n[2], 0, n[4], n[5], n[6], 0, n[8], n[9], n[10], 0, 0, 0, 0, 1, t)
}
,
e.prototype.getRotationMatrix = function() {
var t = new e;
return this.getRotationMatrixToRef(t),
t
}
,
e.prototype.getRotationMatrixToRef = function(t) {
var i = M.Vector3[0];
if (!this.decompose(i))
return e.IdentityToRef(t),
this;
var n = this._m
, r = 1 / i._x
, o = 1 / i._y
, a = 1 / i._z;
return e.FromValuesToRef(n[0] * r, n[1] * r, n[2] * r, 0, n[4] * o, n[5] * o, n[6] * o, 0, n[8] * a, n[9] * a, n[10] * a, 0, 0, 0, 0, 1, t),
this
}
,
e.prototype.toggleModelMatrixHandInPlace = function() {
var e = this._m;
e[2] *= -1,
e[6] *= -1,
e[8] *= -1,
e[9] *= -1,
e[14] *= -1,
this.markAsUpdated()
}
,
e.prototype.toggleProjectionMatrixHandInPlace = function() {
var e = this._m;
e[8] *= -1,
e[9] *= -1,
e[10] *= -1,
e[11] *= -1,
this.markAsUpdated()
}
,
e.FromArray = function(t, i) {
void 0 === i && (i = 0);
var n = new e;
return e.FromArrayToRef(t, i, n),
n
}
,
e.FromArrayToRef = function(e, t, i) {
for (var n = 0; n < 16; n++)
i._m[n] = e[n + t];
i.markAsUpdated()
}
,
e.FromFloat32ArrayToRefScaled = function(e, t, i, n) {
for (var r = 0; r < 16; r++)
n._m[r] = e[r + t] * i;
n.markAsUpdated()
}
,
Object.defineProperty(e, "IdentityReadOnly", {
get: function() {
return e._IdentityReadOnly
},
enumerable: !1,
configurable: !0
}),
e.FromValuesToRef = function(e, t, i, n, r, 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] = n,
g[4] = r,
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, n, r, 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] = n,
v[3] = r,
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, n) {
var r = new e;
return e.ComposeToRef(t, i, n, r),
r
}
,
e.ComposeToRef = function(e, t, i, n) {
var r = n._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;
r[0] = (1 - (_ + g)) * T,
r[1] = (p + b) * T,
r[2] = (f - y) * T,
r[3] = 0,
r[4] = (p - b) * E,
r[5] = (1 - (d + g)) * E,
r[6] = (m + v) * E,
r[7] = 0,
r[8] = (f + y) * S,
r[9] = (m - v) * S,
r[10] = (1 - (d + _)) * S,
r[11] = 0,
r[12] = i._x,
r[13] = i._y,
r[14] = i._z,
r[15] = 1,
n.markAsUpdated()
}
,
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) {
e.FromValuesToRef(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, t),
t._updateIdentityStatus(!0)
}
,
e.Zero = function() {
var t = e.FromValues(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
return t._updateIdentityStatus(!1),
t
}
,
e.RotationX = function(t) {
var i = new e;
return e.RotationXToRef(t, i),
i
}
,
e.Invert = function(t) {
var i = new e;
return t.invertToRef(i),
i
}
,
e.RotationXToRef = function(t, i) {
var n = Math.sin(t)
, r = Math.cos(t);
e.FromValuesToRef(1, 0, 0, 0, 0, r, n, 0, 0, -n, r, 0, 0, 0, 0, 1, i),
i._updateIdentityStatus(1 === r && 0 === n)
}
,
e.RotationY = function(t) {
var i = new e;
return e.RotationYToRef(t, i),
i
}
,
e.RotationYToRef = function(t, i) {
var n = Math.sin(t)
, r = Math.cos(t);
e.FromValuesToRef(r, 0, -n, 0, 0, 1, 0, 0, n, 0, r, 0, 0, 0, 0, 1, i),
i._updateIdentityStatus(1 === r && 0 === n)
}
,
e.RotationZ = function(t) {
var i = new e;
return e.RotationZToRef(t, i),
i
}
,
e.RotationZToRef = function(t, i) {
var n = Math.sin(t)
, r = Math.cos(t);
e.FromValuesToRef(r, n, 0, 0, -n, r, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, i),
i._updateIdentityStatus(1 === r && 0 === n)
}
,
e.RotationAxis = function(t, i) {
var n = new e;
return e.RotationAxisToRef(t, i, n),
n
}
,
e.RotationAxisToRef = function(e, t, i) {
var n = Math.sin(-t)
, r = Math.cos(-t)
, o = 1 - r;
e.normalize();
var a = i._m;
a[0] = e._x * e._x * o + r,
a[1] = e._x * e._y * o - e._z * n,
a[2] = e._x * e._z * o + e._y * n,
a[3] = 0,
a[4] = e._y * e._x * o + e._z * n,
a[5] = e._y * e._y * o + r,
a[6] = e._y * e._z * o - e._x * n,
a[7] = 0,
a[8] = e._z * e._x * o - e._y * n,
a[9] = e._z * e._y * o + e._x * n,
a[10] = e._z * e._z * o + r,
a[11] = 0,
a[12] = 0,
a[13] = 0,
a[14] = 0,
a[15] = 1,
i.markAsUpdated()
}
,
e.RotationAlignToRef = function(e, t, i) {
var n = x.Dot(t, e)
, r = i._m;
if (n < -1 + m)
r[0] = -1,
r[1] = 0,
r[2] = 0,
r[3] = 0,
r[4] = 0,
r[5] = -1,
r[6] = 0,
r[7] = 0,
r[8] = 0,
r[9] = 0,
r[10] = 1,
r[11] = 0;
else {
var o = x.Cross(t, e)
, a = 1 / (1 + n);
r[0] = o._x * o._x * a + n,
r[1] = o._y * o._x * a - o._z,
r[2] = o._z * o._x * a + o._y,
r[3] = 0,
r[4] = o._x * o._y * a + o._z,
r[5] = o._y * o._y * a + n,
r[6] = o._z * o._y * a - o._x,
r[7] = 0,
r[8] = o._x * o._z * a - o._y,
r[9] = o._y * o._z * a + o._x,
r[10] = o._z * o._z * a + n,
r[11] = 0
}
r[12] = 0,
r[13] = 0,
r[14] = 0,
r[15] = 1,
i.markAsUpdated()
}
,
e.RotationYawPitchRoll = function(t, i, n) {
var r = new e;
return e.RotationYawPitchRollToRef(t, i, n, r),
r
}
,
e.RotationYawPitchRollToRef = function(e, t, i, n) {
C.RotationYawPitchRollToRef(e, t, i, M.Quaternion[0]),
M.Quaternion[0].toRotationMatrix(n)
}
,
e.Scaling = function(t, i, n) {
var r = new e;
return e.ScalingToRef(t, i, n, r),
r
}
,
e.ScalingToRef = function(t, i, n, r) {
e.FromValuesToRef(t, 0, 0, 0, 0, i, 0, 0, 0, 0, n, 0, 0, 0, 0, 1, r),
r._updateIdentityStatus(1 === t && 1 === i && 1 === n)
}
,
e.Translation = function(t, i, n) {
var r = new e;
return e.TranslationToRef(t, i, n, r),
r
}
,
e.TranslationToRef = function(t, i, n, r) {
e.FromValuesToRef(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, t, i, n, 1, r),
r._updateIdentityStatus(0 === t && 0 === i && 0 === n)
}
,
e.Lerp = function(t, i, n) {
var r = new e;
return e.LerpToRef(t, i, n, r),
r
}
,
e.LerpToRef = function(e, t, i, n) {
for (var r = n._m, o = e.m, a = t.m, s = 0; s < 16; s++)
r[s] = o[s] * (1 - i) + a[s] * i;
n.markAsUpdated()
}
,
e.DecomposeLerp = function(t, i, n) {
var r = new e;
return e.DecomposeLerpToRef(t, i, n, r),
r
}
,
e.DecomposeLerpToRef = function(t, i, n, r) {
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];
x.LerpToRef(o, l, n, h);
var d = M.Quaternion[2];
C.SlerpToRef(a, c, n, d);
var p = M.Vector3[5];
x.LerpToRef(s, u, n, p),
e.ComposeToRef(h, d, p, r)
}
,
e.LookAtLH = function(t, i, n) {
var r = new e;
return e.LookAtLHToRef(t, i, n, r),
r
}
,
e.LookAtLHToRef = function(t, i, n, r) {
var o = M.Vector3[0]
, a = M.Vector3[1]
, s = M.Vector3[2];
i.subtractToRef(t, s),
s.normalize(),
x.CrossToRef(n, s, o);
var l = o.lengthSquared();
0 === l ? o.x = 1 : o.normalizeFromLength(Math.sqrt(l)),
x.CrossToRef(s, o, a),
a.normalize();
var c = -x.Dot(o, t)
, u = -x.Dot(a, t)
, h = -x.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, r)
}
,
e.LookAtRH = function(t, i, n) {
var r = new e;
return e.LookAtRHToRef(t, i, n, r),
r
}
,
e.LookAtRHToRef = function(t, i, n, r) {
var o = M.Vector3[0]
, a = M.Vector3[1]
, s = M.Vector3[2];
t.subtractToRef(i, s),
s.normalize(),
x.CrossToRef(n, s, o);
var l = o.lengthSquared();
0 === l ? o.x = 1 : o.normalizeFromLength(Math.sqrt(l)),
x.CrossToRef(s, o, a),
a.normalize();
var c = -x.Dot(o, t)
, u = -x.Dot(a, t)
, h = -x.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, r)
}
,
e.LookDirectionLH = function(t, i) {
var n = new e;
return e.LookDirectionLHToRef(t, i, n),
n
}
,
e.LookDirectionLHToRef = function(t, i, n) {
var r = M.Vector3[0];
r.copyFrom(t),
r.scaleInPlace(-1);
var o = M.Vector3[1];
x.CrossToRef(i, r, o),
e.FromValuesToRef(o._x, o._y, o._z, 0, i._x, i._y, i._z, 0, r._x, r._y, r._z, 0, 0, 0, 0, 1, n)
}
,
e.LookDirectionRH = function(t, i) {
var n = new e;
return e.LookDirectionRHToRef(t, i, n),
n
}
,
e.LookDirectionRHToRef = function(t, i, n) {
var r = M.Vector3[2];
x.CrossToRef(i, t, r),
e.FromValuesToRef(r._x, r._y, r._z, 0, i._x, i._y, i._z, 0, t._x, t._y, t._z, 0, 0, 0, 0, 1, n)
}
,
e.OrthoLH = function(t, i, n, r, o) {
var a = new e;
return e.OrthoLHToRef(t, i, n, r, a, o),
a
}
,
e.OrthoLHToRef = function(t, i, n, r, o, a) {
var s = 2 / t
, l = 2 / i
, c = 2 / (r - n)
, u = -(r + n) / (r - n);
e.FromValuesToRef(s, 0, 0, 0, 0, l, 0, 0, 0, 0, c, 0, 0, 0, u, 1, o),
a && o.multiplyToRef(O, o),
o._updateIdentityStatus(1 === s && 1 === l && 1 === c && 0 === u)
}
,
e.OrthoOffCenterLH = function(t, i, n, r, o, a, s) {
var l = new e;
return e.OrthoOffCenterLHToRef(t, i, n, r, o, a, l, s),
l
}
,
e.OrthoOffCenterLHToRef = function(t, i, n, r, o, a, s, l) {
var c = 2 / (i - t)
, u = 2 / (r - n)
, h = 2 / (a - o)
, d = -(a + o) / (a - o)
, p = (t + i) / (t - i)
, f = (r + n) / (n - r);
e.FromValuesToRef(c, 0, 0, 0, 0, u, 0, 0, 0, 0, h, 0, p, f, d, 1, s),
l && s.multiplyToRef(O, s),
s.markAsUpdated()
}
,
e.OrthoOffCenterRH = function(t, i, n, r, o, a, s) {
var l = new e;
return e.OrthoOffCenterRHToRef(t, i, n, r, o, a, l, s),
l
}
,
e.OrthoOffCenterRHToRef = function(t, i, n, r, o, a, s, l) {
e.OrthoOffCenterLHToRef(t, i, n, r, o, a, s, l),
s._m[10] *= -1
}
,
e.PerspectiveLH = function(t, i, n, r, o, a) {
void 0 === a && (a = 0);
var s = new e
, l = 2 * n / t
, c = 2 * n / i
, u = (r + n) / (r - n)
, h = -2 * r * n / (r - n)
, 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(O, s),
s._updateIdentityStatus(!1),
s
}
,
e.PerspectiveFovLH = function(t, i, n, r, o, a, s) {
void 0 === a && (a = 0),
void 0 === s && (s = !1);
var l = new e;
return e.PerspectiveFovLHToRef(t, i, n, r, l, !0, o, a, s),
l
}
,
e.PerspectiveFovLHToRef = function(t, i, n, r, o, a, s, l, c) {
void 0 === a && (a = !0),
void 0 === l && (l = 0),
void 0 === c && (c = !1);
var u = n
, h = r
, 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);
e.FromValuesToRef(p, 0, 0, 0, 0, f, 0, g, 0, 0, _, 1, 0, 0, m, 0, o),
s && o.multiplyToRef(O, o),
o._updateIdentityStatus(!1)
}
,
e.PerspectiveFovReverseLHToRef = function(t, i, n, r, 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);
e.FromValuesToRef(u, 0, 0, 0, 0, h, 0, d, 0, 0, -n, 1, 0, 0, 1, 0, o),
s && o.multiplyToRef(O, o),
o._updateIdentityStatus(!1)
}
,
e.PerspectiveFovRH = function(t, i, n, r, o, a, s) {
void 0 === a && (a = 0),
void 0 === s && (s = !1);
var l = new e;
return e.PerspectiveFovRHToRef(t, i, n, r, l, !0, o, a, s),
l
}
,
e.PerspectiveFovRHToRef = function(t, i, n, r, o, a, s, l, c) {
void 0 === a && (a = !0),
void 0 === l && (l = 0),
void 0 === c && (c = !1);
var u = n
, h = r
, 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);
e.FromValuesToRef(p, 0, 0, 0, 0, f, 0, g, 0, 0, _, -1, 0, 0, m, 0, o),
s && o.multiplyToRef(O, o),
o._updateIdentityStatus(!1)
}
,
e.PerspectiveFovReverseRHToRef = function(t, i, n, r, 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);
e.FromValuesToRef(u, 0, 0, 0, 0, h, 0, d, 0, 0, -n, -1, 0, 0, -1, 0, o),
s && o.multiplyToRef(O, o),
o._updateIdentityStatus(!1)
}
,
e.PerspectiveFovWebVRToRef = function(e, t, i, n, r, o, a) {
void 0 === r && (r = !1),
void 0 === a && (a = 0);
var s = r ? -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)
, _ = n._m;
_[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 && n.multiplyToRef(O, n),
n.markAsUpdated()
}
,
e.GetFinalMatrix = function(t, i, n, r, 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 = M.Matrix[0];
return i.multiplyToRef(n, d),
d.multiplyToRef(r, d),
d.multiply(h)
}
,
e.GetAsMatrix2x2 = function(e) {
var t = e.m
, i = [t[0], t[1], t[4], t[5]];
return T.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 T.MatrixUse64Bits ? i : new Float32Array(i)
}
,
e.Transpose = function(t) {
var i = new e;
return e.TransposeToRef(t, i),
i
}
,
e.TransposeToRef = function(e, t) {
var i = t._m
, n = e.m;
i[0] = n[0],
i[1] = n[4],
i[2] = n[8],
i[3] = n[12],
i[4] = n[1],
i[5] = n[5],
i[6] = n[9],
i[7] = n[13],
i[8] = n[2],
i[9] = n[6],
i[10] = n[10],
i[11] = n[14],
i[12] = n[3],
i[13] = n[7],
i[14] = n[11],
i[15] = n[15],
t.markAsUpdated(),
t._updateIdentityStatus(e._isIdentity, e._isIdentityDirty)
}
,
e.Reflection = function(t) {
var i = new e;
return e.ReflectionToRef(t, i),
i
}
,
e.ReflectionToRef = function(t, i) {
t.normalize();
var n = t.normal.x
, r = t.normal.y
, o = t.normal.z
, a = -2 * n
, s = -2 * r
, l = -2 * o;
e.FromValuesToRef(a * n + 1, s * n, l * n, 0, a * r, s * r + 1, l * r, 0, a * o, s * o, l * o + 1, 0, a * t.d, s * t.d, l * t.d, 1, i)
}
,
e.FromXYZAxesToRef = function(t, i, n, r) {
e.FromValuesToRef(t._x, t._y, t._z, 0, i._x, i._y, i._z, 0, n._x, n._y, n._z, 0, 0, 0, 0, 1, r)
}
,
e.FromQuaternionToRef = function(e, t) {
var i = e._x * e._x
, n = e._y * e._y
, r = 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;
t._m[0] = 1 - 2 * (n + r),
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 * (r + 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 * (n + i),
t._m[11] = 0,
t._m[12] = 0,
t._m[13] = 0,
t._m[14] = 0,
t._m[15] = 1,
t.markAsUpdated()
}
,
e._UpdateFlagSeed = 0,
e._IdentityReadOnly = e.Identity(),
e
}()
, M = function() {
function e() {}
return e.Vector3 = g.BuildTuple(11, x.Zero),
e.Matrix = g.BuildTuple(2, P.Identity),
e.Quaternion = g.BuildTuple(3, C.Zero),
e
}()
, I = function() {
function e() {}
return e.Vector2 = g.BuildTuple(3, A.Zero),
e.Vector3 = g.BuildTuple(13, x.Zero),
e.Vector4 = g.BuildTuple(3, R.Zero),
e.Quaternion = g.BuildTuple(2, C.Zero),
e.Matrix = g.BuildTuple(8, P.Identity),
e
}();
y("BABYLON.Vector2", A),
y("BABYLON.Vector3", x),
y("BABYLON.Vector4", R),
y("BABYLON.Matrix", P);
var O = P.FromValues(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, .5, 0, 0, 0, .5, 1)
, D = 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 N(this.r,this.g,this.b,e)
}
,
e.prototype.asArray = function() {
var e = new Array;
return this.toArray(e, 0),
e
}
,
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.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 = d.Clamp(this.r, e, t),
i.g = d.Clamp(this.g, e, t),
i.b = d.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 "#" + d.ToHex(e) + d.ToHex(t) + d.ToHex(i)
}
,
e.prototype.toLinearSpace = function() {
var t = new e;
return this.toLinearSpaceToRef(t),
t
}
,
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
, n = this.b
, r = Math.max(t, i, n)
, o = Math.min(t, i, n)
, a = 0
, s = 0
, l = r
, c = r - o;
0 !== r && (s = c / r),
r != o && (r == t ? (a = (i - n) / c,
i < n && (a += 6)) : r == i ? a = (n - t) / c + 2 : r == n && (a = (t - i) / c + 4),
a *= 60),
e.r = a,
e.g = s,
e.b = l
}
,
e.prototype.toLinearSpaceToRef = function(e) {
return e.r = Math.pow(this.r, f),
e.g = Math.pow(this.g, f),
e.b = Math.pow(this.b, f),
this
}
,
e.prototype.toGammaSpace = function() {
var t = new e;
return this.toGammaSpaceToRef(t),
t
}
,
e.prototype.toGammaSpaceToRef = function(e) {
return e.r = Math.pow(this.r, p),
e.g = Math.pow(this.g, p),
e.b = Math.pow(this.b, p),
this
}
,
e.HSVtoRGBToRef = function(e, t, i, n) {
var r = i * t
, o = e / 60
, a = r * (1 - Math.abs(o % 2 - 1))
, s = 0
, l = 0
, c = 0;
o >= 0 && o <= 1 ? (s = r,
l = a) : o >= 1 && o <= 2 ? (s = a,
l = r) : o >= 2 && o <= 3 ? (l = r,
c = a) : o >= 3 && o <= 4 ? (l = a,
c = r) : o >= 4 && o <= 5 ? (s = a,
c = r) : o >= 5 && o <= 6 && (s = r,
c = a);
var u = i - r;
n.set(s + u, l + u, c + u)
}
,
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)
, n = parseInt(t.substring(3, 5), 16)
, r = parseInt(t.substring(5, 7), 16);
return e.FromInts(i, n, r)
}
,
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, n) {
return new e(t / 255,i / 255,n / 255)
}
,
e.Lerp = function(t, i, n) {
var r = new e(0,0,0);
return e.LerpToRef(t, i, n, r),
r
}
,
e.LerpToRef = function(e, t, i, n) {
n.r = e.r + (t.r - e.r) * i,
n.g = e.g + (t.g - e.g) * i,
n.b = e.b + (t.b - e.b) * i
}
,
e.Hermite = function(t, i, n, r, 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 + n.r * c + i.r * u + r.r * h,t.g * l + n.g * c + i.g * u + r.g * h,t.b * l + n.b * c + i.b * u + r.b * h)
}
,
e.Hermite1stDerivative = function(t, i, n, r, o) {
var a = e.Black();
return this.Hermite1stDerivativeToRef(t, i, n, r, o, a),
a
}
,
e.Hermite1stDerivativeToRef = function(e, t, i, n, r, o) {
var a = r * r;
o.r = 6 * (a - r) * e.r + (3 * a - 4 * r + 1) * t.r + 6 * (-a + r) * i.r + (3 * a - 2 * r) * n.r,
o.g = 6 * (a - r) * e.g + (3 * a - 4 * r + 1) * t.g + 6 * (-a + r) * i.g + (3 * a - 2 * r) * n.g,
o.b = 6 * (a - r) * e.b + (3 * a - 4 * r + 1) * t.b + 6 * (-a + r) * i.b + (3 * a - 2 * r) * n.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
}()
, N = function() {
function e(e, t, i, n) {
void 0 === e && (e = 0),
void 0 === t && (t = 0),
void 0 === i && (i = 0),
void 0 === n && (n = 1),
this.r = e,
this.g = t,
this.b = i,
this.a = n
}
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() {
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.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.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 = d.Clamp(this.r, e, t),
i.g = d.Clamp(this.g, e, t),
i.b = d.Clamp(this.b, e, t),
i.a = d.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, n) {
return this.r = e,
this.g = t,
this.b = i,
this.a = n,
this
}
,
e.prototype.set = function(e, t, i, n) {
return this.copyFromFloats(e, t, i, n)
}
,
e.prototype.toHexString = function(e) {
void 0 === e && (e = !1);
var t = Math.round(255 * this.r)
, i = Math.round(255 * this.g)
, n = Math.round(255 * this.b);
if (e)
return "#" + d.ToHex(t) + d.ToHex(i) + d.ToHex(n);
var r = Math.round(255 * this.a);
return "#" + d.ToHex(t) + d.ToHex(i) + d.ToHex(n) + d.ToHex(r)
}
,
e.prototype.toLinearSpace = function() {
var t = new e;
return this.toLinearSpaceToRef(t),
t
}
,
e.prototype.toLinearSpaceToRef = function(e) {
return e.r = Math.pow(this.r, f),
e.g = Math.pow(this.g, f),
e.b = Math.pow(this.b, f),
e.a = this.a,
this
}
,
e.prototype.toGammaSpace = function() {
var t = new e;
return this.toGammaSpaceToRef(t),
t
}
,
e.prototype.toGammaSpaceToRef = function(e) {
return e.r = Math.pow(this.r, p),
e.g = Math.pow(this.g, p),
e.b = Math.pow(this.b, p),
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)
, n = parseInt(t.substring(3, 5), 16)
, r = parseInt(t.substring(5, 7), 16)
, o = 9 === t.length ? parseInt(t.substring(7, 9), 16) : 255;
return e.FromInts(i, n, r, o)
}
,
e.Lerp = function(t, i, n) {
var r = new e(0,0,0,0);
return e.LerpToRef(t, i, n, r),
r
}
,
e.LerpToRef = function(e, t, i, n) {
n.r = e.r + (t.r - e.r) * i,
n.g = e.g + (t.g - e.g) * i,
n.b = e.b + (t.b - e.b) * i,
n.a = e.a + (t.a - e.a) * i
}
,
e.Hermite = function(t, i, n, r, 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 + n.r * c + i.r * u + r.r * h,t.g * l + n.g * c + i.g * u + r.g * h,t.b * l + n.b * c + i.b * u + r.b * h,t.a * l + n.a * c + i.a * u + r.a * h)
}
,
e.Hermite1stDerivative = function(t, i, n, r, o) {
var a = new e;
return this.Hermite1stDerivativeToRef(t, i, n, r, o, a),
a
}
,
e.Hermite1stDerivativeToRef = function(e, t, i, n, r, o) {
var a = r * r;
o.r = 6 * (a - r) * e.r + (3 * a - 4 * r + 1) * t.r + 6 * (-a + r) * i.r + (3 * a - 2 * r) * n.r,
o.g = 6 * (a - r) * e.g + (3 * a - 4 * r + 1) * t.g + 6 * (-a + r) * i.g + (3 * a - 2 * r) * n.g,
o.b = 6 * (a - r) * e.b + (3 * a - 4 * r + 1) * t.b + 6 * (-a + r) * i.b + (3 * a - 2 * r) * n.b,
o.a = 6 * (a - r) * e.a + (3 * a - 4 * r + 1) * t.a + 6 * (-a + r) * i.a + (3 * a - 2 * r) * n.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, n, r) {
return new e(t / 255,i / 255,n / 255,r / 255)
}
,
e.CheckColors4 = function(e, t) {
if (e.length === 3 * t) {
for (var i = [], n = 0; n < e.length; n += 3) {
var r = n / 3 * 4;
i[r] = e[n],
i[r + 1] = e[n + 1],
i[r + 2] = e[n + 2],
i[r + 3] = 1
}
return i
}
return e
}
,
e
}()
, L = function() {
function e() {}
return e.Color3 = g.BuildArray(3, D.Black),
e.Color4 = g.BuildArray(3, (function() {
return new N(0,0,0,0)
}
)),
e
}();
y("BABYLON.Color3", D),
y("BABYLON.Color4", N);
var F = function() {
function e(e, t) {
this.triggerOptions = e,
this.onBeforeExecuteObservable = new h,
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 n = this._condition.serialize();
return n.children.push(i),
t && t.children.push(n),
n
}
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 x ? e.x + ", " + e.y + ", " + e.z : e instanceof D ? e.r + ", " + e.g + ", " + e.b : e instanceof N ? 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" : "SceneProperties",
value: e._isScene ? "Scene" : e.name
}
}
,
e
}();
y("BABYLON.Action", F);
var w = function() {
function e(e, t, i, n, r, o) {
this.source = e,
this.pointerX = t,
this.pointerY = i,
this.meshUnderPointer = n,
this.sourceEvent = r,
this.additionalData = o
}
return e.CreateNew = function(t, i, n) {
var r = t.getScene();
return new e(t,r.pointerX,r.pointerY,r.meshUnderPointer || t,i,n)
}
,
e.CreateNewFromSprite = function(t, i, n, r) {
return new e(t,i.pointerX,i.pointerY,i.meshUnderPointer,n,r)
}
,
e.CreateNewFromScene = function(t, i) {
return new e(null,t.pointerX,t.pointerY,t.meshUnderPointer,i)
}
,
e.CreateNewFromPrimitive = function(t, i, n, r) {
return new e(t,i.x,i.y,null,n,r)
}
,
e
}()
, B = function(e, t) {
return B = 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])
}
,
B(e, t)
};
function U(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
}
B(e, t),
e.prototype = null === t ? Object.create(t) : (i.prototype = t.prototype,
new i)
}
var V = function() {
return V = Object.assign || function(e) {
for (var t, i = 1, n = arguments.length; i < n; i++)
for (var r in t = arguments[i])
Object.prototype.hasOwnProperty.call(t, r) && (e[r] = t[r]);
return e
}
,
V.apply(this, arguments)
};
function k(e, t, i, n) {
var r, o = arguments.length, a = o < 3 ? t : null === n ? n = Object.getOwnPropertyDescriptor(t, i) : n;
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate)
a = Reflect.decorate(e, t, i, n);
else
for (var s = e.length - 1; s >= 0; s--)
(r = e[s]) && (a = (o < 3 ? r(a) : o > 3 ? r(t, i, a) : r(t, i)) || a);
return o > 3 && a && Object.defineProperty(t, i, a),
a
}
function G(e, t, i, n) {
return new (i || (i = Promise))((function(r, o) {
function a(e) {
try {
l(n.next(e))
} catch (e) {
o(e)
}
}
function s(e) {
try {
l(n.throw(e))
} catch (e) {
o(e)
}
}
function l(e) {
var t;
e.done ? r(e.value) : (t = e.value,
t instanceof i ? t : new i((function(e) {
e(t)
}
))).then(a, s)
}
l((n = n.apply(e, t || [])).next())
}
))
}
function z(e, t) {
var i, n, r, o, a = {
label: 0,
sent: function() {
if (1 & r[0])
throw r[1];
return r[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(o) {
return function(s) {
return function(o) {
if (i)
throw new TypeError("Generator is already executing.");
for (; a; )
try {
if (i = 1,
n && (r = 2 & o[0] ? n.return : o[0] ? n.throw || ((r = n.return) && r.call(n),
0) : n.next) && !(r = r.call(n, o[1])).done)
return r;
switch (n = 0,
r && (o = [2 & o[0], r.value]),
o[0]) {
case 0:
case 1:
r = o;
break;
case 4:
return a.label++,
{
value: o[1],
done: !1
};
case 5:
a.label++,
n = o[1],
o = [0];
continue;
case 7:
o = a.ops.pop(),
a.trys.pop();
continue;
default:
if (!((r = (r = a.trys).length > 0 && r[r.length - 1]) || 6 !== o[0] && 2 !== o[0])) {
a = 0;
continue
}
if (3 === o[0] && (!r || o[1] > r[0] && o[1] < r[3])) {
a.label = o[1];
break
}
if (6 === o[0] && a.label < r[1]) {
a.label = r[1],
r = o;
break
}
if (r && a.label < r[2]) {
a.label = r[2],
a.ops.push(o);
break
}
r[2] && a.ops.pop(),
a.trys.pop();
continue
}
o = t.call(e, a)
} catch (e) {
o = [6, e],
n = 0
} finally {
i = r = 0
}
if (5 & o[0])
throw o[1];
return {
value: o[0] ? o[1] : void 0,
done: !0
}
}([o, s])
}
}
}
function W(e, t, i) {
if (i || 2 === arguments.length)
for (var n, r = 0, o = t.length; r < o; r++)
!n && r in t || (n || (n = Array.prototype.slice.call(t, 0, r)),
n[r] = t[r]);
return e.concat(n || Array.prototype.slice.call(t))
}
Object.create,
Object.create;
var H = 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
}()
, X = function(e) {
function t(i, n, r, o, a) {
void 0 === a && (a = t.IsEqual);
var s = e.call(this, i) || this;
return s.propertyPath = r,
s.value = o,
s.operator = a,
s._target = n,
s._effectiveTarget = s._getEffectiveTarget(n, s.propertyPath),
s._property = s._getProperty(s.propertyPath),
s
}
return U(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: [F._GetTargetProperty(this._target), {
name: "propertyPath",
value: this.propertyPath
}, {
name: "value",
value: F._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
}(H)
, j = function(e) {
function t(t, i) {
var n = e.call(this, t) || this;
return n.predicate = i,
n
}
return U(t, e),
t.prototype.isValid = function() {
return this.predicate()
}
,
t
}(H)
, Y = function(e) {
function t(t, i, n) {
var r = e.call(this, t) || this;
return r.value = n,
r._target = i,
r
}
return U(t, e),
t.prototype.isValid = function() {
return this._target.state === this.value
}
,
t.prototype.serialize = function() {
return this._serialize({
name: "StateCondition",
properties: [F._GetTargetProperty(this._target), {
name: "value",
value: this.value
}]
})
}
,
t
}(H);
y("BABYLON.ValueCondition", X),
y("BABYLON.PredicateCondition", j),
y("BABYLON.StateCondition", Y);
var K = function() {
function e() {}
return e._CheckLimit = function(t, i) {
var n = e._LogLimitOutputs[t];
return n ? n.current++ : (n = {
limit: i,
current: 1
},
e._LogLimitOutputs[t] = n),
n.current <= n.limit
}
,
e._GenerateLimitMessage = function(t, i) {
var n = e._LogLimitOutputs[t];
if (n && e.MessageLimitReached && n.current === n.limit)
switch (i) {
case 0:
e.Log(e.MessageLimitReached.replace(/%LIMIT%/g, "" + n.limit).replace(/%TYPE%/g, "log"));
break;
case 1:
e.Warn(e.MessageLimitReached.replace(/%LIMIT%/g, "" + n.limit).replace(/%TYPE%/g, "warning"));
break;
case 2:
e.Error(e.MessageLimitReached.replace(/%LIMIT%/g, "" + n.limit).replace(/%TYPE%/g, "error"))
}
}
,
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) {
if (void 0 === i || e._CheckLimit(t, i)) {
var n = e._FormatMessage(t);
console.log("BJS - " + n);
var r = "
" + n + "
";
e._AddLogEntry(r),
e._GenerateLimitMessage(t, 0)
}
}
,
e._WarnDisabled = function(e, t) {}
,
e._WarnEnabled = function(t, i) {
if (void 0 === i || e._CheckLimit(t, i)) {
var n = e._FormatMessage(t);
console.warn("BJS - " + n);
var r = "" + t + "
";
e._AddLogEntry(r),
e._GenerateLimitMessage(t, 1)
}
}
,
e._ErrorDisabled = function(e, t) {}
,
e._ErrorEnabled = function(t, i) {
if (void 0 === i || e._CheckLimit(t, i)) {
var n = e._FormatMessage(t);
e.errorsCount++,
console.error("BJS - " + n);
var r = "" + n + "
";
e._AddLogEntry(r),
e._GenerateLimitMessage(t, 2)
}
}
,
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) {
(t & e.MessageLogLevel) === e.MessageLogLevel ? e.Log = e._LogEnabled : e.Log = e._LogDisabled,
(t & e.WarningLogLevel) === e.WarningLogLevel ? e.Warn = e._WarnEnabled : e.Warn = e._WarnDisabled,
(t & e.ErrorLogLevel) === e.ErrorLogLevel ? e.Error = e._ErrorEnabled : e.Error = e._ErrorDisabled
},
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.errorsCount = 0,
e.Log = e._LogEnabled,
e.Warn = e._WarnEnabled,
e.Error = e._ErrorEnabled,
e
}()
, Q = function(e) {
function t(t, i, n, r) {
var o = e.call(this, t, r) || this;
return o.propertyPath = n,
o._target = o._effectiveTarget = i,
o
}
return U(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: [F._GetTargetProperty(this._target), {
name: "propertyPath",
value: this.propertyPath
}]
}, t)
}
,
t
}(F)
, q = function(e) {
function t(t, i, n, r) {
var o = e.call(this, t, r) || this;
return o.value = n,
o._target = i,
o
}
return U(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: [F._GetTargetProperty(this._target), {
name: "value",
value: this.value
}]
}, t)
}
,
t
}(F)
, Z = function(e) {
function t(t, i, n, r, o) {
var a = e.call(this, t, o) || this;
return a.propertyPath = n,
a.value = r,
a._target = a._effectiveTarget = i,
a
}
return U(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: [F._GetTargetProperty(this._target), {
name: "propertyPath",
value: this.propertyPath
}, {
name: "value",
value: F._SerializeValueAsString(this.value)
}]
}, t)
}
,
t
}(F)
, J = function(e) {
function t(t, i, n, r, o) {
var a = e.call(this, t, o) || this;
return a.propertyPath = n,
a.value = r,
a._target = a._effectiveTarget = i,
a
}
return U(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] && K.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: [F._GetTargetProperty(this._target), {
name: "propertyPath",
value: this.propertyPath
}, {
name: "value",
value: F._SerializeValueAsString(this.value)
}]
}, t)
}
,
t
}(F)
, $ = function(e) {
function t(t, i, n, r, o, a) {
var s = e.call(this, t, a) || this;
return s.from = n,
s.to = r,
s.loop = o,
s._target = i,
s
}
return U(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: [F._GetTargetProperty(this._target), {
name: "from",
value: String(this.from)
}, {
name: "to",
value: String(this.to)
}, {
name: "loop",
value: F._SerializeValueAsString(this.loop) || !1
}]
}, t)
}
,
t
}(F)
, ee = function(e) {
function t(t, i, n) {
var r = e.call(this, t, n) || this;
return r._target = i,
r
}
return U(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: [F._GetTargetProperty(this._target)]
}, t)
}
,
t
}(F)
, te = function(e) {
function t(t, i) {
return void 0 === t && (t = a.ACTION_NothingTrigger),
e.call(this, t, i) || this
}
return U(t, e),
t.prototype.execute = function() {}
,
t.prototype.serialize = function(t) {
return e.prototype._serialize.call(this, {
name: "DoNothingAction",
properties: []
}, t)
}
,
t
}(F)
, ie = function(e) {
function t(t, i, n, r) {
void 0 === r && (r = !0);
var o = e.call(this, t, n) || this;
return o.children = i,
o.enableChildrenConditions = r,
o
}
return U(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 n = i[t];
this.enableChildrenConditions && !n._evaluateConditionForCurrentFrame() || n.execute(e)
}
}
,
t.prototype.serialize = function(t) {
for (var i = e.prototype._serialize.call(this, {
name: "CombineAction",
properties: [],
combine: []
}, t), n = 0; n < this.children.length; n++)
i.combine.push(this.children[n].serialize(null));
return i
}
,
t
}(F)
, ne = function(e) {
function t(t, i, n) {
var r = e.call(this, t, n) || this;
return r.func = i,
r
}
return U(t, e),
t.prototype.execute = function(e) {
this.func(e)
}
,
t
}(F)
, re = function(e) {
function t(t, i, n, r) {
var o = e.call(this, t, r) || this;
return o._target = i,
o._parent = n,
o
}
return U(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 = x.TransformCoordinates(this._target.position, e),
this._target.parent = this._parent
}
}
,
t.prototype.serialize = function(t) {
return e.prototype._serialize.call(this, {
name: "SetParentAction",
properties: [F._GetTargetProperty(this._target), F._GetTargetProperty(this._parent)]
}, t)
}
,
t
}(F);
y("BABYLON.SetParentAction", re),
y("BABYLON.ExecuteCodeAction", ne),
y("BABYLON.DoNothingAction", te),
y("BABYLON.StopAnimationAction", ee),
y("BABYLON.PlayAnimationAction", $),
y("BABYLON.IncrementValueAction", J),
y("BABYLON.SetValueAction", Z),
y("BABYLON.SetStateAction", q),
y("BABYLON.SetParentAction", re);
var oe = function(e, t) {
return -1 !== e.indexOf(t, e.length - t.length)
}
, ae = function(e, t) {
return !!e && 0 === e.indexOf(t)
}
, se = 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
}
, le = function(e) {
for (var t, i, n, r, 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; )
r = (t = h[u++]) >> 2,
o = (3 & t) << 4 | (i = u < h.length ? h[u++] : Number.NaN) >> 4,
a = (15 & i) << 2 | (n = u < h.length ? h[u++] : Number.NaN) >> 6,
s = 63 & n,
isNaN(i) ? a = s = 64 : isNaN(n) && (s = 64),
c += l.charAt(r) + l.charAt(o) + l.charAt(a) + l.charAt(s);
return c
}
, ce = function(e) {
return atob(e)
}
, ue = function(e) {
for (var t = ce(e), i = t.length, n = new Uint8Array(new ArrayBuffer(i)), r = 0; r < i; r++)
n[r] = t.charCodeAt(r);
return n.buffer
}
, he = function(e, t) {
for (var i = String(e); i.length < t; )
i = "0" + i;
return i
}
, de = {
EndsWith: oe,
StartsWith: ae,
Decode: se,
EncodeArrayBufferToBase64: le,
DecodeBase64ToString: ce,
DecodeBase64ToBinary: ue,
PadNumber: he
}
, pe = function(e, t) {
return e ? e.getClassName && "Mesh" === e.getClassName() ? null : e.getClassName && "SubMesh" === e.getClassName() ? e.clone(t) : e.clone ? e.clone() : null : null
}
, fe = function() {
function e() {}
return e.DeepCopy = function(e, t, i, n) {
for (var r = 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 = r; o < a.length; o++) {
var s = a[o];
if (("_" !== s[0] || n && -1 !== n.indexOf(s)) && !(oe(s, "Observable") || i && -1 !== i.indexOf(s))) {
var l = e[s]
, c = typeof l;
if ("function" !== c)
try {
if ("object" === c)
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 = pe(l[u], t);
-1 === t[s].indexOf(h) && t[s].push(h)
}
else
t[s] = l.slice(0)
} else
t[s] = pe(l, t);
else
t[s] = l
} catch (e) {
K.Warn(e.message)
}
}
}
}
,
e
}()
, _e = function(e) {
function t(t) {
var i = e.call(this) || this;
return (t = t || E.LastCreatedScene) ? (i._scene = t,
t.actionManagers.push(i),
i) : i
}
return U(t, e),
t.prototype.dispose = function() {
for (var e = this._scene.actionManagers.indexOf(this), i = 0; i < this.actions.length; i++) {
var n = this.actions[i];
t.Triggers[n.trigger]--,
0 === t.Triggers[n.trigger] && delete t.Triggers[n.trigger]
}
e > -1 && this._scene.actionManagers.splice(e, 1)
}
,
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 n = this.actions[i];
if (e == n.trigger || t == n.trigger)
return !0
}
return !1
}
,
t.prototype.hasSpecificTrigger = function(e, t) {
for (var i = 0; i < this.actions.length; i++) {
var n = this.actions[i];
if (n.trigger === e) {
if (!t)
return !0;
if (t(n.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 ? (K.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),
null) : (this.actions.push(e),
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,
!0)
}
,
t.prototype.processTrigger = function(e, i) {
for (var n = 0; n < this.actions.length; n++) {
var r = this.actions[n];
if (r.trigger === e) {
if (i && (e === t.OnKeyUpTrigger || e === t.OnKeyDownTrigger)) {
var o = r.getTriggerParameter();
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
}
}
}
r._executeCurrent(i)
}
}
}
,
t.prototype._getEffectiveTarget = function(e, t) {
for (var i = t.split("."), n = 0; n < i.length - 1; n++)
e = e[i[n]];
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
}, n = 0; n < this.actions.length; n++) {
var r = {
type: 0,
children: new Array,
name: t.GetTriggerName(this.actions[n].trigger),
properties: new Array
}
, o = this.actions[n].triggerOptions;
if (o && "number" != typeof o)
if (o.parameter instanceof Node)
r.properties.push(F._GetTargetProperty(o.parameter));
else {
var a = {};
fe.DeepCopy(o.parameter, a, ["mesh"]),
o.parameter && o.parameter.mesh && (a._meshId = o.parameter.mesh.id),
r.properties.push({
name: "parameter",
targetType: null,
value: a
})
}
this.actions[n].serialize(r),
i.children.push(r)
}
return i
}
,
t.Parse = function(e, i, n) {
var r = new t(n);
null === i ? n.actionManager = r : i.actionManager = r;
for (var o = function(e, t, i, n) {
if (null === n) {
var r = parseFloat(t);
return "true" === t || "false" === t ? "true" === t : isNaN(r) ? t : r
}
for (var o = n.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 x ? x.FromArray(l) : i instanceof R ? R.FromArray(l) : i instanceof D ? D.FromArray(l) : i instanceof N ? N.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(r) : 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 = null !== y && "SceneProperties" === y ? n : n.getNodeByName(g) : "parent" === v ? g = n.getNodeByName(g) : "sound" === v ? n.getSoundByName && (g = n.getSoundByName(g)) : "propertyPath" !== v ? g = 2 === e.type && "operator" === v ? X[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 T = u[u.length - 2];
u[u.length - 1] = T,
u[u.length - 2] = s
}
var E = function(e, t) {
var i = b("BABYLON." + e);
if (i) {
var n = Object.create(i.prototype);
return n.constructor.apply(n, t),
n
}
}(e.name, u);
if (E instanceof H && null !== s) {
var S = new te(i,s);
l ? l.then(S) : r.registerAction(S),
l = S
}
for (null === c ? E instanceof H ? (s = E,
E = l) : (s = null,
l ? l.then(E) : r.registerAction(E)) : c.push(E),
m = 0; m < e.children.length; m++)
a(e.children[m], i, s, E, 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 : n.getMeshByName(u);
h._meshId && (h.mesh = n.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 0:
return "NothingTrigger";
case 1:
return "OnPickTrigger";
case 2:
return "OnLeftPickTrigger";
case 3:
return "OnRightPickTrigger";
case 4:
return "OnCenterPickTrigger";
case 5:
return "OnPickDownTrigger";
case 6:
return "OnPickUpTrigger";
case 7:
return "OnLongPressTrigger";
case 8:
return "OnPointerOverTrigger";
case 9:
return "OnPointerOutTrigger";
case 10:
return "OnEveryFrameTrigger";
case 11:
return "OnIntersectionEnterTrigger";
case 12:
return "OnIntersectionExitTrigger";
case 13:
return "OnKeyDownTrigger";
case 14:
return "OnKeyUpTrigger";
case 15:
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 = 15,
t
}(s)
, me = function(e) {
function t(t, i, n) {
var r = e.call(this, t, n) || this;
return r._sound = i,
r
}
return U(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
}(F)
, ge = function(e) {
function t(t, i, n) {
var r = e.call(this, t, n) || this;
return r._sound = i,
r
}
return U(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
}(F);
y("BABYLON.PlaySoundAction", me),
y("BABYLON.StopSoundAction", ge);
var ve = 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 n;
i = i || function(e) {
return "true" === e
}
;
var r = t.split("||");
for (var o in r)
if (Object.prototype.hasOwnProperty.call(r, o)) {
var a = e._SimplifyNegation(r[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 (!(n = "true" !== c && "false" !== c ? "!" === c[0] ? !i(c.substring(1)) : i(c) : "true" === c)) {
a = "false";
break
}
}
if (n || "true" === a) {
n = !0;
break
}
n = "true" !== a && "false" !== a ? "!" === a[0] ? !i(a.substring(1)) : i(a) : "true" === a
}
return n ? "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
}()
, ye = 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 n in e._tags)
Object.prototype.hasOwnProperty.call(e._tags, n) && !0 === e._tags[n] && i.push(n);
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 n = i.split(" ");
for (var r in n)
e._RemoveTagFrom(t, n[r])
}
}
,
e._RemoveTagFrom = function(e, t) {
delete e._tags[t]
}
,
e.MatchesQuery = function(t, i) {
return void 0 === i || ("" === i ? e.HasTags(t) : ve.Eval(i, (function(i) {
return e.HasTags(t) && t._tags[i]
}
)))
}
,
e
}();
function be(e) {
return "".concat(e, " needs to be imported before as it contains a side-effect required by your code.")
}
var Te = {}
, Ee = {}
, Se = function(e, t, i) {
var n = e();
ye && ye.AddTagsTo(n, t.tags);
var r = Ae(n);
for (var o in r) {
var a = r[o]
, s = t[o]
, l = a.type;
if (null != s && ("uniqueId" !== o || Ge.AllowLoadingUniqueId))
switch (l) {
case 0:
case 6:
case 11:
n[o] = s;
break;
case 1:
n[o] = i || s.isRenderTarget ? s : s.clone();
break;
case 2:
case 3:
case 4:
case 5:
case 7:
case 10:
case 12:
n[o] = i ? s : s.clone()
}
}
return n
};
function Ae(e) {
var t = e.getClassName();
if (Ee[t])
return Ee[t];
Ee[t] = {};
for (var i = Ee[t], n = e, r = t; r; ) {
var o = Te[r];
for (var a in o)
i[a] = o[a];
var s = void 0
, l = !1;
do {
if (!(s = Object.getPrototypeOf(n)).getClassName) {
l = !0;
break
}
if (s.getClassName() !== r)
break;
n = s
} while (s);
if (l)
break;
r = s.getClassName(),
n = s
}
return i
}
function xe(e, t) {
return function(i, n) {
var r = function(e) {
var t = e.getClassName();
return Te[t] || (Te[t] = {}),
Te[t]
}(i);
r[n] || (r[n] = {
type: e,
sourceName: t
})
}
}
function Re(e, t) {
return void 0 === t && (t = null),
function(e, t) {
return void 0 === t && (t = null),
function(i, n) {
var r = t || "_" + n;
Object.defineProperty(i, n, {
get: function() {
return this[r]
},
set: function(t) {
"function" == typeof this.equals && this.equals(t) || this[r] !== t && (this[r] = t,
i[e].apply(this))
},
enumerable: !0,
configurable: !0
})
}
}(e, t)
}
function Ce(e) {
return xe(0, e)
}
function Pe(e) {
return xe(1, e)
}
function Me(e) {
return xe(2, e)
}
function Ie(e) {
return xe(3, e)
}
function Oe(e) {
return xe(4, e)
}
function De(e) {
return xe(5, e)
}
function Ne(e) {
return xe(6, e)
}
function Le(e) {
return xe(7, e)
}
function Fe(e) {
return xe(8, e)
}
function we(e) {
return xe(9, e)
}
function Be(e) {
return xe(10, e)
}
function Ue(e) {
return xe(12, e)
}
function Ve(e) {
return xe(11, e)
}
var ke, Ge = function() {
function e() {}
return e.AppendSerializedAnimations = function(e, t) {
if (e.animations) {
t.animations = [];
for (var i = 0; i < e.animations.length; i++) {
var n = e.animations[i];
t.animations.push(n.serialize())
}
}
}
,
e.Serialize = function(t, i) {
i || (i = {}),
ye && (i.tags = ye.GetTags(t));
var n = Ae(t);
for (var r in n) {
var o = n[r]
, a = o.sourceName || r
, s = o.type
, l = t[r];
if (null != l && ("uniqueId" !== r || 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.Parse = function(t, i, n, r) {
void 0 === r && (r = null);
var o = t();
r || (r = ""),
ye && ye.AddTagsTo(o, i.tags);
var a = Ae(o);
for (var s in a) {
var l = a[s]
, c = i[l.sourceName || s]
, u = l.type;
if (null != c && ("uniqueId" !== s || e.AllowLoadingUniqueId)) {
var h = o;
switch (u) {
case 0:
h[s] = c;
break;
case 1:
n && (h[s] = e._TextureParser(c, n, r));
break;
case 2:
h[s] = D.FromArray(c);
break;
case 3:
h[s] = e._FresnelParametersParser(c);
break;
case 4:
h[s] = A.FromArray(c);
break;
case 5:
h[s] = x.FromArray(c);
break;
case 6:
n && (h[s] = n.getLastMeshById(c));
break;
case 7:
h[s] = e._ColorCurvesParser(c);
break;
case 8:
h[s] = N.FromArray(c);
break;
case 9:
h[s] = e._ImageProcessingConfigurationParser(c);
break;
case 10:
h[s] = C.FromArray(c);
break;
case 11:
n && (h[s] = n.getCameraById(c));
break;
case 12:
h[s] = P.FromArray(c)
}
}
}
return o
}
,
e.Clone = function(e, t) {
return Se(e, t, !1)
}
,
e.Instanciate = function(e, t) {
return Se(e, t, !0)
}
,
e.AllowLoadingUniqueId = !1,
e._ImageProcessingConfigurationParser = function(e) {
throw be("ImageProcessingConfiguration")
}
,
e._FresnelParametersParser = function(e) {
throw be("FresnelParameters")
}
,
e._ColorCurvesParser = function(e) {
throw be("ColorCurves")
}
,
e._TextureParser = function(e, t, i) {
throw be("Texture")
}
,
e
}();
function ze(e, t, i, n) {
var r = i.value;
i.value = function() {
for (var i = [], o = 0; o < arguments.length; o++)
i[o] = arguments[o];
var a = r;
if ("undefined" != typeof _native && _native[t]) {
var s = _native[t];
a = n ? function() {
for (var e = [], t = 0; t < arguments.length; t++)
e[t] = arguments[t];
return n.apply(void 0, e) ? s.apply(void 0, e) : r.apply(void 0, e)
}
: s
}
return e[t] = a,
a.apply(void 0, i)
}
}
ze.filter = function(e) {
return function(t, i, n) {
return ze(t, i, n, e)
}
}
,
function(e) {
e[e.NONE = 0] = "NONE",
e[e.STEP = 1] = "STEP"
}(ke || (ke = {}));
var We = 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
}()
, He = function() {
this._doNotSerialize = !1,
this._isDisposed = !1,
this._sceneRootNodesIndex = -1,
this._isEnabled = !0,
this._isParentEnabled = !0,
this._isReady = !0,
this._onEnabledStateChangedObservable = new h,
this._onClonedObservable = new h
}
, Xe = function() {
function e(e, t) {
void 0 === t && (t = null),
this._isDirty = !1,
this._nodeDataStorage = new He,
this.state = "",
this.metadata = null,
this.reservedDataStore = null,
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._cache = {},
this._parentNode = null,
this._children = null,
this._worldMatrix = P.Identity(),
this._worldMatrixDeterminant = 0,
this._worldMatrixDeterminantIsDirty = !0,
this._animationPropertiesOverride = null,
this._isNode = !0,
this.onDisposeObservable = new h,
this._onDisposeObserver = null,
this._behaviors = new Array,
this.name = e,
this.id = e,
this._scene = t || E.LastCreatedScene,
this.uniqueId = this._scene.getUniqueId(),
this._initCache()
}
return e.AddNodeConstructor = function(e, t) {
this._NodeConstructors[e] = t
}
,
e.Construct = function(e, t, i, n) {
var r = this._NodeConstructors[e];
return r ? r(t, i, n) : null
}
,
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._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 n = i[t];
if (n.name === e)
return n
}
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._nodeDataStorage._onEnabledStateChangedObservable.notifyObservers(e),
this._syncParentEnabledState())
}
,
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 n = 0; n < this._children.length; n++) {
var r = this._children[n];
i && !i(r) || e.push(r),
t || r._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, n) {
if (!this._ranges[t]) {
this._ranges[t] = e._AnimationRangeFactory(t, i, n);
for (var r = 0, o = this.animations.length; r < o; r++)
this.animations[r] && this.animations[r].createRange(t, i, n)
}
}
,
e.prototype.deleteAnimationRange = function(e, t) {
void 0 === t && (t = !0);
for (var i = 0, n = this.animations.length; i < n; 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.getAnimationRanges = function() {
var e, t = [];
for (e in this._ranges)
t.push(this._ranges[e]);
return t
}
,
e.prototype.beginAnimation = function(e, t, i, n) {
var r = this.getAnimationRange(e);
return r ? this._scene.beginAnimation(this, r.from, r.to, t, i, n) : null
}
,
e.prototype.serializeAnimationRanges = function() {
var e = [];
for (var t in this._ranges) {
var i = this._ranges[t];
if (i) {
var n = {};
n.name = t,
n.from = i.from,
n.to = i.to,
e.push(n)
}
}
return e
}
,
e.prototype.computeWorldMatrix = function(e) {
return this._worldMatrix || (this._worldMatrix = P.Identity()),
this._worldMatrix
}
,
e.prototype.dispose = function(e, t) {
if (void 0 === t && (t = !1),
this._nodeDataStorage._isDisposed = !0,
!e)
for (var i = 0, n = this.getDescendants(!0); i < n.length; i++)
n[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 r = 0, o = this._behaviors; r < o.length; r++)
o[r].detach();
this._behaviors = [],
this.metadata = null
}
,
e.ParseAnimationRanges = function(e, t, i) {
if (t.ranges)
for (var n = 0; n < t.ranges.length; n++) {
var r = t.ranges[n];
e.createAnimationRange(r.name, r.from, r.to)
}
}
,
e.prototype.getHierarchyBoundingVectors = function(e, t) {
var i, n;
void 0 === e && (e = !0),
void 0 === t && (t = null),
this.getScene().incrementRenderId(),
this.computeWorldMatrix(!0);
var r = this;
if (r.getBoundingInfo && r.subMeshes) {
var o = r.getBoundingInfo();
i = o.boundingBox.minimumWorld.clone(),
n = o.boundingBox.maximumWorld.clone()
} else
i = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
n = new x(-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;
x.CheckExtends(u, i, n),
x.CheckExtends(h, i, n)
}
}
return {
min: i,
max: n
}
}
,
e._AnimationRangeFactory = function(e, t, i) {
throw be("AnimationRange")
}
,
e._NodeConstructors = {},
k([Ce()], e.prototype, "name", void 0),
k([Ce()], e.prototype, "id", void 0),
k([Ce()], e.prototype, "uniqueId", void 0),
k([Ce()], e.prototype, "state", void 0),
k([Ce()], e.prototype, "metadata", void 0),
e
}()
, je = 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, n) {
return new e(t.width + (i.width - t.width) * n,t.height + (i.height - t.height) * n)
}
,
e
}()
, Ye = function() {
function e() {
this._xhr = "undefined" != typeof _native && _native.XMLHttpRequest ? new _native.XMLHttpRequest : new XMLHttpRequest
}
return e.prototype._injectCustomRequestHeaders = function() {
for (var t in e.CustomRequestHeaders) {
var i = e.CustomRequestHeaders[t];
i && this._xhr.setRequestHeader(t, i)
}
}
,
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 n = 0, r = e.CustomRequestModifiers; n < r.length; n++)
(0,
r[n])(this._xhr, i);
return i = (i = i.replace("file:http:", "http:")).replace("file:https:", "https:"),
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
}()
, Ke = function() {}
, Qe = function() {
function e(t, i, n, r, o, a) {
this.name = t,
this.targetProperty = i,
this.framePerSecond = n,
this.dataType = r,
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 = r,
this.loopMode = void 0 === o ? e.ANIMATIONLOOPMODE_CYCLE : o,
this.uniqueId = e._UniqueIdGenerator++
}
return e._PrepareAnimation = function(t, i, n, r, o, a, s, l) {
var c = void 0;
if (!isNaN(parseFloat(o)) && isFinite(o) ? c = e.ANIMATIONTYPE_FLOAT : o instanceof C ? c = e.ANIMATIONTYPE_QUATERNION : o instanceof x ? c = e.ANIMATIONTYPE_VECTOR3 : o instanceof A ? c = e.ANIMATIONTYPE_VECTOR2 : o instanceof D ? c = e.ANIMATIONTYPE_COLOR3 : o instanceof N ? c = e.ANIMATIONTYPE_COLOR4 : o instanceof je && (c = e.ANIMATIONTYPE_SIZE),
null == c)
return null;
var u = new e(t,i,n,c,s)
, h = [{
frame: 0,
value: o
}, {
frame: r,
value: a
}];
return u.setKeys(h),
void 0 !== l && u.setEasingFunction(l),
u
}
,
e.CreateAnimation = function(t, i, n, r) {
var o = new e(t + "Animation",t,n,i,e.ANIMATIONLOOPMODE_CONSTANT);
return o.setEasingFunction(r),
o
}
,
e.CreateAndStartAnimation = function(t, i, n, r, o, a, s, l, c, u, h) {
var d = e._PrepareAnimation(t, n, r, 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, n, r, o, a, s, l, c, u, h) {
var d = e._PrepareAnimation(t, r, o, a, s, l, c, u);
return d ? i.getScene().beginDirectHierarchyAnimation(i, n, [d], 0, a, 1 === d.loopMode, 1, h) : null
}
,
e.CreateMergeAndStartAnimation = function(t, i, n, r, o, a, s, l, c, u) {
var h = e._PrepareAnimation(t, n, r, 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, n, r, o) {
void 0 === i && (i = 0),
void 0 === r && (r = !1);
var a = t;
if (r && ((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: I.Vector3[0],
referenceQuaternion: I.Quaternion[0],
referenceScaling: I.Vector3[1],
keyPosition: I.Vector3[2],
keyQuaternion: I.Quaternion[1],
keyScaling: I.Vector3[3]
}
, d = !1
, p = l.frame
, f = u.frame;
if (n) {
var _ = a.getRange(n);
_ && (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),
P.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, n, r, o, a, s) {
if (void 0 === s && (s = null),
a <= 0)
return i[e] = t,
s && s(),
null;
var l = r * (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 = n.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 n in this._ranges)
i && (t += ", ",
i = !1),
t += n;
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 We(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 n = i.from, r = i.to, o = this._keys.length - 1; o >= 0; o--)
this._keys[o].frame >= n && this._keys[o].frame <= r && 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 d.Lerp(e, t, i)
}
,
e.prototype.floatInterpolateFunctionWithTangents = function(e, t, i, n, r) {
return d.Hermite(e, t, i, n, r)
}
,
e.prototype.quaternionInterpolateFunction = function(e, t, i) {
return C.Slerp(e, t, i)
}
,
e.prototype.quaternionInterpolateFunctionWithTangents = function(e, t, i, n, r) {
return C.Hermite(e, t, i, n, r).normalize()
}
,
e.prototype.vector3InterpolateFunction = function(e, t, i) {
return x.Lerp(e, t, i)
}
,
e.prototype.vector3InterpolateFunctionWithTangents = function(e, t, i, n, r) {
return x.Hermite(e, t, i, n, r)
}
,
e.prototype.vector2InterpolateFunction = function(e, t, i) {
return A.Lerp(e, t, i)
}
,
e.prototype.vector2InterpolateFunctionWithTangents = function(e, t, i, n, r) {
return A.Hermite(e, t, i, n, r)
}
,
e.prototype.sizeInterpolateFunction = function(e, t, i) {
return je.Lerp(e, t, i)
}
,
e.prototype.color3InterpolateFunction = function(e, t, i) {
return D.Lerp(e, t, i)
}
,
e.prototype.color3InterpolateFunctionWithTangents = function(e, t, i, n, r) {
return D.Hermite(e, t, i, n, r)
}
,
e.prototype.color4InterpolateFunction = function(e, t, i) {
return N.Lerp(e, t, i)
}
,
e.prototype.color4InterpolateFunctionWithTangents = function(e, t, i, n, r) {
return N.Hermite(e, t, i, n, r)
}
,
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;
var n = this._keys;
if (1 === n.length)
return this._getKeyValue(n[0].value);
var r = i.key;
if (n[r].frame >= t)
for (; r - 1 >= 0 && n[r].frame >= t; )
r--;
for (var o = r; o < n.length - 1; o++) {
var a = n[o + 1];
if (a.frame >= t) {
i.key = o;
var s = n[o]
, l = this._getKeyValue(s.value)
, c = this._getKeyValue(a.value);
if (s.interpolation === ke.STEP)
return a.frame > t ? l : c;
var u = void 0 !== s.outTangent && void 0 !== a.inTangent
, h = a.frame - s.frame
, d = (t - s.frame) / h
, p = this.getEasingFunction();
switch (null !== p && (d = p.ease(d)),
this.dataType) {
case e.ANIMATIONTYPE_FLOAT:
var f = u ? this.floatInterpolateFunctionWithTangents(l, s.outTangent * h, c, a.inTangent * h, d) : this.floatInterpolateFunction(l, c, d);
switch (i.loopMode) {
case e.ANIMATIONLOOPMODE_CYCLE:
case e.ANIMATIONLOOPMODE_CONSTANT:
return f;
case e.ANIMATIONLOOPMODE_RELATIVE:
return i.offsetValue * i.repeatCount + f
}
break;
case e.ANIMATIONTYPE_QUATERNION:
var _ = u ? this.quaternionInterpolateFunctionWithTangents(l, s.outTangent.scale(h), c, a.inTangent.scale(h), d) : this.quaternionInterpolateFunction(l, c, d);
switch (i.loopMode) {
case e.ANIMATIONLOOPMODE_CYCLE:
case e.ANIMATIONLOOPMODE_CONSTANT:
return _;
case e.ANIMATIONLOOPMODE_RELATIVE:
return _.addInPlace(i.offsetValue.scale(i.repeatCount))
}
return _;
case e.ANIMATIONTYPE_VECTOR3:
var m = u ? this.vector3InterpolateFunctionWithTangents(l, s.outTangent.scale(h), c, a.inTangent.scale(h), d) : this.vector3InterpolateFunction(l, c, d);
switch (i.loopMode) {
case e.ANIMATIONLOOPMODE_CYCLE:
case e.ANIMATIONLOOPMODE_CONSTANT:
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, s.outTangent.scale(h), c, a.inTangent.scale(h), d) : this.vector2InterpolateFunction(l, c, d);
switch (i.loopMode) {
case e.ANIMATIONLOOPMODE_CYCLE:
case e.ANIMATIONLOOPMODE_CONSTANT:
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:
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, s.outTangent.scale(h), c, a.inTangent.scale(h), d) : this.color3InterpolateFunction(l, c, d);
switch (i.loopMode) {
case e.ANIMATIONLOOPMODE_CYCLE:
case e.ANIMATIONLOOPMODE_CONSTANT:
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, s.outTangent.scale(h), c, a.inTangent.scale(h), d) : this.color4InterpolateFunction(l, c, d);
switch (i.loopMode) {
case e.ANIMATIONLOOPMODE_CYCLE:
case e.ANIMATIONLOOPMODE_CONSTANT:
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:
return e.AllowMatricesInterpolation ? this.matrixInterpolateFunction(l, c, d, i.workValue) : l;
case e.ANIMATIONLOOPMODE_RELATIVE:
return l
}
}
break
}
}
return this._getKeyValue(n[n.length - 1].value)
}
,
e.prototype.matrixInterpolateFunction = function(t, i, n, r) {
return e.AllowMatrixDecomposeForInterpolation ? r ? (P.DecomposeLerpToRef(t, i, n, r),
r) : P.DecomposeLerp(t, i, n) : r ? (P.LerpToRef(t, i, n, r),
r) : P.Lerp(t, i, n)
}
,
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 n = this._ranges[i];
n && (t._ranges[i] = n.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 n = this.getKeys(), r = 0; r < n.length; r++) {
var o = n[r]
, 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 n = e.constructor;
return n.Lerp ? n.Lerp(e, t, i) : n.Slerp ? n.Slerp(e, t, i) : e.toFixed ? e * (1 - i) + i * t : t
}
,
e.Parse = function(t) {
var i, n, r = new e(t.name,t.property,t.framePerSecond,t.dataType,t.loopBehavior), o = t.dataType, a = [];
for (t.enableBlending && (r.enableBlending = t.enableBlending),
t.blendingSpeed && (r.blendingSpeed = t.blendingSpeed),
n = 0; n < t.keys.length; n++) {
var s = t.keys[n]
, 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 = C.FromArray(s.values),
s.values.length >= 8) {
var h = C.FromArray(s.values.slice(4, 8));
h.equals(C.Zero()) || (l = h)
}
if (s.values.length >= 12) {
var d = C.FromArray(s.values.slice(8, 12));
d.equals(C.Zero()) || (c = d)
}
s.values.length >= 13 && (u = s.values[12]);
break;
case e.ANIMATIONTYPE_MATRIX:
i = P.FromArray(s.values),
s.values.length >= 17 && (u = s.values[16]);
break;
case e.ANIMATIONTYPE_COLOR3:
i = D.FromArray(s.values),
s.values[3] && (l = D.FromArray(s.values[3])),
s.values[4] && (c = D.FromArray(s.values[4])),
s.values[5] && (u = s.values[5]);
break;
case e.ANIMATIONTYPE_COLOR4:
i = N.FromArray(s.values),
s.values[4] && (l = N.FromArray(s.values[4])),
s.values[5] && (c = N.FromArray(s.values[5])),
s.values[6] && (u = N.FromArray(s.values[6]));
break;
case e.ANIMATIONTYPE_VECTOR3:
default:
i = x.FromArray(s.values),
s.values[3] && (l = x.FromArray(s.values[3])),
s.values[4] && (c = x.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 (r.setKeys(a),
t.ranges)
for (n = 0; n < t.ranges.length; n++)
i = t.ranges[n],
r.createRange(i.name, i.from, i.to);
return r
}
,
e.AppendSerializedAnimations = function(e, t) {
Ge.AppendSerializedAnimations(e, t)
}
,
e.ParseFromFileAsync = function(e, t) {
var i = this;
return new Promise((function(n, r) {
var o = new Ye;
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))
}
n(a)
} else
a = i.Parse(t),
e && (a.name = e),
n(a)
} else
r("Unable to load the animation")
}
)),
o.open("GET", t),
o.send()
}
))
}
,
e.CreateFromSnippetAsync = function(e) {
var t = this;
return new Promise((function(i, n) {
var r = new Ye;
r.addEventListener("readystatechange", (function() {
if (4 == r.readyState)
if (200 == r.status) {
var o = JSON.parse(JSON.parse(r.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
n("Unable to load the snippet " + e)
}
)),
r.open("GET", t.SnippetUrl + "/" + e.replace(/#/g, "/")),
r.send()
}
))
}
,
e._UniqueIdGenerator = 0,
e.AllowMatricesInterpolation = !1,
e.AllowMatrixDecomposeForInterpolation = !0,
e.SnippetUrl = "https://snippet.babylonjs.com",
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
}();
y("BABYLON.Animation", Qe),
Xe._AnimationRangeFactory = function(e, t, i) {
return new We(e,t,i)
}
;
var qe = function(e) {
function t(t, i, n, r, o, a, s, l) {
void 0 === o && (o = 1e3);
var c = e.call(this, t, a) || this;
return c.duration = 1e3,
c.onInterpolationDoneObservable = new h,
c.propertyPath = n,
c.value = r,
c.duration = o,
c.stopOtherAnimations = s,
c.onInterpolationDone = l,
c._target = c._effectiveTarget = i,
c
}
return U(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(), n = [{
frame: 0,
value: this._effectiveTarget[this._property]
}, {
frame: 100,
value: this.value
}];
if ("number" == typeof this.value)
e = Qe.ANIMATIONTYPE_FLOAT;
else if (this.value instanceof D)
e = Qe.ANIMATIONTYPE_COLOR3;
else if (this.value instanceof x)
e = Qe.ANIMATIONTYPE_VECTOR3;
else if (this.value instanceof P)
e = Qe.ANIMATIONTYPE_MATRIX;
else {
if (!(this.value instanceof C))
return void K.Warn("InterpolateValueAction: Unsupported type (" + typeof this.value + ")");
e = Qe.ANIMATIONTYPE_QUATERNION
}
var r = new Qe("InterpolateValueAction",this._property,1e3 / this.duration * 100,e,Qe.ANIMATIONLOOPMODE_CONSTANT);
r.setKeys(n),
this.stopOtherAnimations && i.stopAnimation(this._effectiveTarget),
i.beginDirectAnimation(this._effectiveTarget, [r], 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: [F._GetTargetProperty(this._target), {
name: "propertyPath",
value: this.propertyPath
}, {
name: "value",
value: F._SerializeValueAsString(this.value)
}, {
name: "duration",
value: F._SerializeValueAsString(this.duration)
}, {
name: "stopOtherAnimations",
value: F._SerializeValueAsString(this.stopOtherAnimations) || !1
}]
}, t)
}
,
t
}(F);
y("BABYLON.InterpolateValueAction", qe);
var Ze = Object.freeze(new C(0,0,0,0))
, Je = Object.freeze(x.Zero())
, $e = Object.freeze(A.Zero())
, et = Object.freeze(je.Zero())
, tt = Object.freeze(D.Black())
, it = function() {
function e(e, t, i, n) {
var r = 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._ratioOffset = 0,
this._previousDelay = 0,
this._previousRatio = 0,
this._targetIsArray = !1,
this._animation = t,
this._target = e,
this._scene = i,
this._host = n,
this._activeTargets = [],
t._runtimeAnimations.push(this),
this._animationState = {
key: 0,
repeatCount: 0,
loopMode: this._getCorrectLoopMode()
},
this._animation.dataType === Qe.ANIMATIONTYPE_MATRIX && (this._animationState.workValue = P.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) {
r._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 n = e[i[0]], r = 1; r < i.length - 1; r++)
n = n[i[r]];
this._targetPath = i[i.length - 1],
this._activeTargets[t] = n
} 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, n = this._target; i < n.length; i++) {
var r = n[i];
void 0 !== this._originalValue[t] && this._setValue(r, 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 n = this._target[i];
this._setValue(n, 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, n, r) {
if (this._currentActiveTarget = t,
this._weight = n,
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 ? Qe.AllowMatrixDecomposeForInterpolation ? this._currentValue ? P.DecomposeLerpToRef(this._originalBlendValue, i, this._blendingFactor, this._currentValue) : this._currentValue = P.DecomposeLerp(this._originalBlendValue, i, this._blendingFactor) : this._currentValue ? P.LerpToRef(this._originalBlendValue, i, this._blendingFactor, this._currentValue) : this._currentValue = P.Lerp(this._originalBlendValue, i, this._blendingFactor) : this._currentValue = Qe._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 !== n ? this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[r]) : 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 n = 0; n < i.length; n++)
i[n].onlyOnce || (i[n].isDone = i[n].frame < e);
this._currentFrame = e;
var r = this._animation._interpolate(e, this._animationState);
this.setValue(r, -1)
}
,
e.prototype._prepareForSpeedRatioChange = function(e) {
var t = this._previousDelay * (this._animation.framePerSecond * e) / 1e3;
this._ratioOffset = this._previousRatio - t
}
,
e.prototype.animate = function(e, t, i, n, r, 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 * r) / 1e3 + this._ratioOffset, p = 0;
if (this._previousDelay = e,
this._previousRatio = d,
!n && i >= t && d >= h)
l = !1,
p = a._getKeyValue(this._maxValue);
else if (!n && t >= i && d <= h)
l = !1,
p = a._getKeyValue(this._minValue);
else if (this._animationState.loopMode !== Qe.ANIMATIONLOOPMODE_CYCLE) {
var f = i.toString() + t.toString();
if (!this._offsetsCache[f]) {
this._animationState.repeatCount = 0,
this._animationState.loopMode = Qe.ANIMATIONLOOPMODE_CYCLE;
var _ = a._interpolate(t, this._animationState)
, m = a._interpolate(i, this._animationState);
switch (this._animationState.loopMode = this._getCorrectLoopMode(),
a.dataType) {
case Qe.ANIMATIONTYPE_FLOAT:
this._offsetsCache[f] = m - _;
break;
case Qe.ANIMATIONTYPE_QUATERNION:
case Qe.ANIMATIONTYPE_VECTOR3:
case Qe.ANIMATIONTYPE_VECTOR2:
case Qe.ANIMATIONTYPE_SIZE:
case Qe.ANIMATIONTYPE_COLOR3:
this._offsetsCache[f] = m.subtract(_)
}
this._highLimitsCache[f] = m
}
p = this._highLimitsCache[f],
c = this._offsetsCache[f]
}
if (void 0 === c)
switch (a.dataType) {
case Qe.ANIMATIONTYPE_FLOAT:
c = 0;
break;
case Qe.ANIMATIONTYPE_QUATERNION:
c = Ze;
break;
case Qe.ANIMATIONTYPE_VECTOR3:
c = Je;
break;
case Qe.ANIMATIONTYPE_VECTOR2:
c = $e;
break;
case Qe.ANIMATIONTYPE_SIZE:
c = et;
break;
case Qe.ANIMATIONTYPE_COLOR3:
c = tt
}
if (this._host && this._host.syncRoot) {
var g = this._host.syncRoot;
u = t + (i - t) * ((g.masterFrame - g.fromFrame) / (g.toFrame - g.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 v = this._events;
if ((r > 0 && this.currentFrame > u || r < 0 && this.currentFrame < u) && (this._onLoop(),
v.length))
for (var y = 0; y < v.length; y++)
v[y].onlyOnce || (v[y].isDone = !1);
this._currentFrame = u,
this._animationState.repeatCount = 0 === h ? 0 : d / h >> 0,
this._animationState.highLimitValue = p,
this._animationState.offsetValue = c;
var b = a._interpolate(u, this._animationState);
if (this.setValue(b, o),
v.length)
for (y = 0; y < v.length; y++)
if (h > 0 && u >= v[y].frame && v[y].frame >= t || h < 0 && u <= v[y].frame && v[y].frame <= t) {
var T = v[y];
T.isDone || (T.onlyOnce && (v.splice(y, 1),
y--),
T.isDone = !0,
T.action(u))
}
return l || (this._stopped = !0),
l
}
,
e
}();
function nt() {
return "undefined" != typeof window
}
function rt() {
return "undefined" != typeof navigator
}
function ot() {
return "undefined" != typeof document
}
function at(e) {
for (var t = "", i = e.firstChild; i; )
3 === i.nodeType && (t += i.textContent),
i = i.nextSibling;
return t
}
var st, lt = {
IsWindowObjectExist: nt,
IsNavigatorAvailable: rt,
IsDocumentAvailable: ot,
GetDOMTextContent: at
}, ct = function() {
function e() {}
return Object.defineProperty(e, "Now", {
get: function() {
return lt.IsWindowObjectExist() && window.performance && window.performance.now ? window.performance.now() : Date.now()
},
enumerable: !1,
configurable: !0
}),
e
}(), ut = function() {
function e() {}
return e.FilesToLoad = {},
e
}(), ht = function() {
function e() {}
return e.ExponentialBackoff = function(e, t) {
return void 0 === e && (e = 3),
void 0 === t && (t = 500),
function(i, n, r) {
return 0 !== n.status || r >= e || -1 !== i.indexOf("file:") ? -1 : Math.pow(2, r) * t
}
}
,
e
}(), dt = function(e) {
function t() {
return null !== e && e.apply(this, arguments) || this
}
return U(t, e),
t._setPrototypeOf = Object.setPrototypeOf || function(e, t) {
return e.__proto__ = t,
e
}
,
t
}(Error), pt = {
MeshInvalidPositionsError: 0,
UnsupportedTextureError: 1e3,
GLTFLoaderUnexpectedMagicError: 2e3,
SceneLoaderError: 3e3,
LoadFileError: 4e3,
RequestFileError: 4001,
ReadFileError: 4002
}, ft = function(e) {
function t(i, n, r) {
var o = e.call(this, i) || this;
return o.errorCode = n,
o.innerError = r,
o.name = "RuntimeError",
dt._setPrototypeOf(o, t.prototype),
o
}
return U(t, e),
t
}(dt), _t = function() {
function e() {
this.children = []
}
return e.prototype.isValid = function(e) {
return !0
}
,
e.prototype.process = function(e, t) {
var i = "";
if (this.line) {
var n = this.line
, r = t.processor;
r && (r.lineProcessor && (n = r.lineProcessor(n, t.isFragment, t.processingContext)),
r.attributeProcessor && ae(this.line, "attribute") ? n = r.attributeProcessor(this.line, e, t.processingContext) : r.varyingProcessor && ae(this.line, "varying") ? n = r.varyingProcessor(this.line, t.isFragment, e, t.processingContext) : r.uniformProcessor && r.uniformRegexp && r.uniformRegexp.test(this.line) ? t.lookForClosingBracketForUniformBuffer || (n = r.uniformProcessor(this.line, t.isFragment, e, t.processingContext)) : r.uniformBufferProcessor && r.uniformBufferRegexp && r.uniformBufferRegexp.test(this.line) ? t.lookForClosingBracketForUniformBuffer || (n = r.uniformBufferProcessor(this.line, t.isFragment, t.processingContext),
t.lookForClosingBracketForUniformBuffer = !0) : r.textureProcessor && r.textureRegexp && r.textureRegexp.test(this.line) ? n = r.textureProcessor(this.line, t.isFragment, e, t.processingContext) : (r.uniformProcessor || r.uniformBufferProcessor) && ae(this.line, "uniform") && !t.lookForClosingBracketForUniformBuffer && (/uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/.test(this.line) ? r.uniformProcessor && (n = r.uniformProcessor(this.line, t.isFragment, e, t.processingContext)) : r.uniformBufferProcessor && (n = r.uniformBufferProcessor(this.line, t.isFragment, t.processingContext),
t.lookForClosingBracketForUniformBuffer = !0)),
t.lookForClosingBracketForUniformBuffer && -1 !== this.line.indexOf("}") && (t.lookForClosingBracketForUniformBuffer = !1,
r.endOfUniformBufferProcessor && (n = r.endOfUniformBufferProcessor(this.line, t.isFragment, t.processingContext)))),
i += n + "\r\n"
}
return this.children.forEach((function(n) {
i += n.process(e, t)
}
)),
this.additionalDefineKey && (e[this.additionalDefineKey] = this.additionalDefineValue || "true"),
i
}
,
e
}(), mt = function() {
function e() {}
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 = [];
for (var t = 0, i = e; t < i.length; t++) {
var n = i[t];
if ("#" !== n[0])
for (var r = n.split(";"), o = 0; o < r.length; o++) {
var a = r[o];
(a = a.trim()) && this._lines.push(a + (o !== r.length - 1 ? ";" : ""))
}
else
this._lines.push(n)
}
},
enumerable: !1,
configurable: !0
}),
e
}(), gt = function(e) {
function t() {
return null !== e && e.apply(this, arguments) || this
}
return U(t, e),
t.prototype.process = function(e, t) {
for (var i = 0; i < this.children.length; i++) {
var n = this.children[i];
if (n.isValid(e))
return n.process(e, t)
}
return ""
}
,
t
}(_t), vt = function(e) {
function t() {
return null !== e && e.apply(this, arguments) || this
}
return U(t, e),
t.prototype.isValid = function(e) {
return this.testExpression.isTrue(e)
}
,
t
}(_t), yt = function() {
function e() {}
return e.prototype.isTrue = function(e) {
return !0
}
,
e.postfixToInfix = function(t) {
for (var i = [], n = 0, r = t; n < r.length; n++) {
var o = r[n];
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) {
for (var i = [], n = -1, r = function() {
"" !== (c = c.trim()) && (i.push(c),
c = "")
}, o = function(t) {
n < e._Stack.length - 1 && (e._Stack[++n] = t)
}, a = function() {
return e._Stack[n]
}, s = function() {
return -1 === n ? "!!INVALID EXPRESSION!!" : e._Stack[n--]
}, l = 0, c = ""; l < t.length; ) {
var u = t.charAt(l)
, h = l < t.length - 1 ? t.substr(l, 2) : "";
if ("(" === u)
c = "",
o(u);
else if (")" === u) {
for (r(); -1 !== n && "(" !== a(); )
i.push(s());
s()
} else if (e._OperatorPriority[h] > 1) {
for (r(); -1 !== n && e._OperatorPriority[a()] >= e._OperatorPriority[h]; )
i.push(s());
o(h),
l++
} else
c += u;
l++
}
for (r(); -1 !== n; )
"(" === a() ? s() : i.push(s());
return i
}
,
e._OperatorPriority = {
")": 0,
"(": 1,
"||": 2,
"&&": 3
},
e._Stack = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
e
}(), bt = function(e) {
function t(t, i) {
void 0 === i && (i = !1);
var n = e.call(this) || this;
return n.define = t,
n.not = i,
n
}
return U(t, e),
t.prototype.isTrue = function(e) {
var t = void 0 !== e[this.define];
return this.not && (t = !t),
t
}
,
t
}(yt), Tt = function(e) {
function t() {
return null !== e && e.apply(this, arguments) || this
}
return U(t, e),
t.prototype.isTrue = function(e) {
return this.leftOperand.isTrue(e) || this.rightOperand.isTrue(e)
}
,
t
}(yt), Et = function(e) {
function t() {
return null !== e && e.apply(this, arguments) || this
}
return U(t, e),
t.prototype.isTrue = function(e) {
return this.leftOperand.isTrue(e) && this.rightOperand.isTrue(e)
}
,
t
}(yt), St = function(e) {
function t(t, i, n) {
var r = e.call(this) || this;
return r.define = t,
r.operand = i,
r.testValue = n,
r
}
return U(t, e),
t.prototype.isTrue = function(e) {
var t = e[this.define];
void 0 === t && (t = this.define);
var i = !1
, n = parseInt(t)
, r = parseInt(this.testValue);
switch (this.operand) {
case ">":
i = n > r;
break;
case "<":
i = n < r;
break;
case "<=":
i = n <= r;
break;
case ">=":
i = n >= r;
break;
case "==":
i = n === r
}
return i
}
,
t
}(yt);
!function(e) {
e[e.GLSL = 0] = "GLSL",
e[e.WGSL = 1] = "WGSL"
}(st || (st = {}));
var At, xt = /defined\s*?\((.+?)\)/g, Rt = /defined\s*?\[(.+?)\]/g, Ct = function() {
function e() {}
return e.Initialize = function(e) {
e.processor && e.processor.initializeShaders && e.processor.initializeShaders(e.processingContext)
}
,
e.Process = function(e, t, i, n) {
var r, o = this;
(null === (r = t.processor) || void 0 === r ? void 0 : r.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 r = o._ProcessShaderConversion(e, t, n);
i(r)
}
))
}
,
e.PreProcess = function(e, t, i, n) {
var r, o = this;
(null === (r = t.processor) || void 0 === r ? void 0 : r.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 r = o._ApplyPreProcessing(e, t, n);
i(r)
}
))
}
,
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 n = t.shouldUseHighPrecisionShader;
return -1 === e.indexOf("precision highp float") ? e = n ? "precision highp float;\n" + e : "precision mediump float;\n" + e : n || (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 bt(t[1].trim(),"!" === e[0]);
for (var i = "", n = 0, r = 0, o = ["==", ">=", "<=", "<", ">"]; r < o.length && (i = o[r],
!((n = e.indexOf(i)) > -1)); r++)
;
if (-1 === n)
return new bt(e);
var a = e.substring(0, n).trim()
, s = e.substring(n + i.length).trim();
return new St(a,i,s)
}
,
e._BuildSubExpression = function(e) {
e = e.replace(xt, "defined[$1]");
for (var t = [], i = 0, n = yt.infixToPostfix(e); i < n.length; i++) {
var r = n[i];
if ("||" !== r && "&&" !== r)
t.push(r);
else if (t.length >= 2) {
var o = t[t.length - 1]
, a = t[t.length - 2];
t.length -= 2;
var s = "&&" == r ? new Et : new Tt;
"string" == typeof o && (o = o.replace(Rt, "defined($1)")),
"string" == typeof a && (a = a.replace(Rt, "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(Rt, "defined($1)")),
"string" == typeof l ? this._ExtractOperation(l) : l
}
,
e._BuildExpression = function(e, t) {
var i = new vt
, n = e.substring(0, t)
, r = e.substring(t);
return r = r.substring(0, (r.indexOf("//") + 1 || r.length + 1) - 1).trim(),
i.testExpression = "#ifdef" === n ? new bt(r) : "#ifndef" === n ? new bt(r,!0) : this._BuildSubExpression(r),
i
}
,
e._MoveCursorWithinIf = function(e, t, i) {
for (var n = e.currentLine; this._MoveCursor(e, i); ) {
var r = (n = e.currentLine).substring(0, 5).toLowerCase();
if ("#else" === r) {
var o = new _t;
return t.children.push(o),
void this._MoveCursor(e, o)
}
if ("#elif" === r) {
var a = this._BuildExpression(n, 5);
t.children.push(a),
i = a
}
}
}
,
e._MoveCursor = function(e, t) {
for (; e.canRead; ) {
e.lineIndex++;
var i = e.currentLine
, n = /(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/.exec(i);
if (n && n.length)
switch (n[0]) {
case "#ifdef":
var r = new gt;
t.children.push(r);
var o = this._BuildExpression(i, 6);
r.children.push(o),
this._MoveCursorWithinIf(e, r, o);
break;
case "#else":
case "#elif":
return !0;
case "#endif":
return !1;
case "#ifndef":
r = new gt,
t.children.push(r),
o = this._BuildExpression(i, 7),
r.children.push(o),
this._MoveCursorWithinIf(e, r, o);
break;
case "#if":
r = new gt,
o = this._BuildExpression(i, 3),
t.children.push(r),
r.children.push(o),
this._MoveCursorWithinIf(e, r, o)
}
else {
var a = new _t;
if (a.line = i,
t.children.push(a),
"#" === i[0] && "d" === i[1]) {
var s = i.replace(";", "").split(" ");
a.additionalDefineKey = s[1],
3 === s.length && (a.additionalDefineValue = s[2])
}
}
}
return !1
}
,
e._EvaluatePreProcessors = function(e, t, i) {
var n = new _t
, r = new mt;
return r.lineIndex = -1,
r.lines = e.split("\n"),
this._MoveCursor(r, n),
n.process(t, i)
}
,
e._PreparePreProcessors = function(e, t) {
for (var i, n = {}, r = 0, o = e.defines; r < o.length; r++) {
var a = o[r].replace("#define", "").replace(";", "").trim().split(" ");
n[a[0]] = a.length > 1 ? a[1] : ""
}
return (null === (i = e.processor) || void 0 === i ? void 0 : i.shaderLanguage) === st.GLSL && (n.GL_ES = "true"),
n.__VERSION__ = e.version,
n[e.platformName] = "true",
t._getGlobalDefines(n),
n
}
,
e._ProcessShaderConversion = function(e, t, i) {
var n = this._ProcessPrecision(e, t);
if (!t.processor)
return n;
if (t.processor.shaderLanguage === st.GLSL && -1 !== n.indexOf("#version 3"))
return n.replace("#version 300 es", "");
var r = t.defines
, o = this._PreparePreProcessors(t, i);
return t.processor.preProcessor && (n = t.processor.preProcessor(n, r, t.isFragment, t.processingContext)),
n = this._EvaluatePreProcessors(n, o, t),
t.processor.postProcessor && (n = t.processor.postProcessor(n, r, t.isFragment, t.processingContext, i)),
i._features.needShaderCodeInlining && (n = i.inlineShaderCode(n)),
n
}
,
e._ApplyPreProcessing = function(e, t, i) {
var n, r, o = e, a = t.defines, s = this._PreparePreProcessors(t, i);
return (null === (n = t.processor) || void 0 === n ? void 0 : n.preProcessor) && (o = t.processor.preProcessor(o, a, t.isFragment, t.processingContext)),
o = this._EvaluatePreProcessors(o, s, t),
(null === (r = t.processor) || void 0 === r ? void 0 : r.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, n) {
for (var r = this, o = /#include\s?<(.+)>(\((.*)\))*(\[(.*)\])*/g, a = o.exec(t), s = new String(t), l = !1, c = function() {
var c = a[1];
if (-1 !== c.indexOf("__decl__") && (c = c.replace(/__decl__/, ""),
i.supportsUniformBuffers && (c = (c = c.replace(/Vertex/, "Ubo")).replace(/Fragment/, "Ubo")),
c += "Declaration"),
!i.includesShadersStore[c]) {
var u = i.shadersRepository + "ShadersInclude/" + c + ".fx";
return e._FileToolsLoadFile(u, (function(e) {
i.includesShadersStore[c] = e,
r._ProcessIncludes(s, i, n)
}
)),
{
value: void 0
}
}
var h = i.includesShadersStore[c];
if (a[2])
for (var d = a[3].split(","), p = 0; p < d.length; p += 2) {
var f = new RegExp(d[p],"g")
, _ = d[p + 1];
h = h.replace(f, _)
}
if (a[4]) {
var m = a[5];
if (-1 !== m.indexOf("..")) {
var g = m.split("..")
, v = parseInt(g[0])
, y = parseInt(g[1])
, b = h.slice(0);
h = "",
isNaN(y) && (y = i.indexParameters[g[1]]);
for (var T = v; T < y; T++)
i.supportsUniformBuffers || (b = b.replace(/light\{X\}.(\w*)/g, (function(e, t) {
return t + "{X}"
}
))),
h += b.replace(/\{X\}/g, T.toString()) + "\n"
} else
i.supportsUniformBuffers || (h = h.replace(/light\{X\}.(\w*)/g, (function(e, t) {
return t + "{X}"
}
))),
h = h.replace(/\{X\}/g, m)
}
s = s.replace(a[0], h),
l = l || h.indexOf("#include<") >= 0 || h.indexOf("#include <") >= 0,
a = o.exec(t)
}; null != a; ) {
var u = c();
if ("object" == typeof u)
return u.value
}
l ? this._ProcessIncludes(s.toString(), i, n) : n(s)
}
,
e._FileToolsLoadFile = function(e, t, i, n, r, o) {
throw be("FileTools")
}
,
e
}(), Pt = function() {
function e() {}
return e.GetShadersRepository = function(t) {
return void 0 === t && (t = st.GLSL),
t === st.GLSL ? e.ShadersRepository : e.ShadersRepositoryWGSL
}
,
e.GetShadersStore = function(t) {
return void 0 === t && (t = st.GLSL),
t === st.GLSL ? e.ShadersStore : e.ShadersStoreWGSL
}
,
e.GetIncludesShadersStore = function(t) {
return void 0 === t && (t = st.GLSL),
t === st.GLSL ? e.IncludesShadersStore : e.IncludesShadersStoreWGSL
}
,
e.ShadersRepository = "src/Shaders/",
e.ShadersStore = {},
e.IncludesShadersStore = {},
e.ShadersRepositoryWGSL = "src/ShadersWGSL/",
e.ShadersStoreWGSL = {},
e.IncludesShadersStoreWGSL = {},
e
}(), Mt = function() {
function e(t, i, n, r, o, a, s, l, c, u, d, p) {
void 0 === r && (r = 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 = st.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 h,
this.onErrorObservable = new h,
this._onBindObservable = null,
this._wasPreviouslyReady = !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._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 = n,
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 : st.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 = n.concat(r),
this._samplerList = r ? r.slice() : [],
this._attributesNames = i,
this._uniformBuffersNamesList = [],
this._shaderLanguage = p,
this.onError = c,
this.onCompiled = l,
this._indexParameters = u,
this._fallbacks = s;
this._attributeLocationByName = {},
this.uniqueId = e._UniqueIdSeed++;
var A = nt() ? this._engine.getHostDocument() : null;
t.vertexSource ? v = "source:" + t.vertexSource : t.vertexElement ? (v = A ? A.getElementById(t.vertexElement) : null) || (v = t.vertexElement) : v = t.vertex || t,
t.fragmentSource ? y = "source:" + t.fragmentSource : t.fragmentElement ? (y = A ? A.getElementById(t.fragmentElement) : null) || (y = t.fragmentElement) : y = t.fragment || t,
this._processingContext = this._engine._getShaderProcessingContext(this._shaderLanguage);
var x = {
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: Pt.GetShadersRepository(this._shaderLanguage),
includesShadersStore: Pt.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]) {
x.isFragment = !0;
var e = R[0]
, i = R[1];
Ct.Process(i, x, (function(i) {
T && (i = T("fragment", i));
var n = Ct.Finalize(e, i, x);
g._useFinalCode(n.vertexCode, n.fragmentCode, t)
}
), g._engine)
}
};
this._loadShader(v, "Vertex", "", (function(e) {
Ct.Initialize(x),
Ct.Process(e, x, (function(t) {
g._rawVertexSourceCode = e,
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 Pt.ShadersRepository
},
set: function(e) {
Pt.ShadersRepository = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "onBindObservable", {
get: function() {
return this._onBindObservable || (this._onBindObservable = new h),
this._onBindObservable
},
enumerable: !1,
configurable: !0
}),
e.prototype._useFinalCode = function(e, t, i) {
if (i) {
var n = i.vertexElement || i.vertex || i.spectorName || i
, r = i.fragmentElement || i.fragment || i.spectorName || i;
this._vertexSourceCode = (this._shaderLanguage === st.WGSL ? "//" : "") + "#define SHADER_NAME vertex:" + n + "\n" + e,
this._fragmentSourceCode = (this._shaderLanguage === st.WGSL ? "//" : "") + "#define SHADER_NAME fragment:" + r + "\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)
}
setTimeout((function() {
t._checkIsReady(e)
}
), 16)
}
,
e.prototype._loadShader = function(e, t, i, n) {
if ("undefined" != typeof HTMLElement && e instanceof HTMLElement)
n(at(e));
else if ("source:" !== e.substr(0, 7))
if ("base64:" !== e.substr(0, 7)) {
var r, o = Pt.GetShadersStore(this._shaderLanguage);
o[e + t + "Shader"] ? n(o[e + t + "Shader"]) : i && o[e + i + "Shader"] ? n(o[e + i + "Shader"]) : (r = "." === e[0] || "/" === e[0] || e.indexOf("http") > -1 ? e : Pt.GetShadersRepository(this._shaderLanguage) + e,
this._engine._loadFile(r + "." + t.toLowerCase() + ".fx", n))
} else
n(window.atob(e.substr(7)));
else
n(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, "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, n) {
var r = this;
this._isReady = !1,
this._vertexSourceCodeOverride = e,
this._fragmentSourceCodeOverride = t,
this.onError = function(e, t) {
n && n(t)
}
,
this.onCompiled = function() {
var e = r.getEngine().scenes;
if (e)
for (var t = 0; t < e.length; t++)
e[t].markAllMaterialsAsDirty(a.MATERIAL_AllDirtyFlag);
r._pipelineContext._handlesSpectorRebuildCallback(i)
}
,
this._fallbacks = null,
this._prepareEffect()
}
,
e.prototype._prepareEffect = function() {
var e = this
, t = this._attributesNames
, i = this.defines
, n = this._pipelineContext;
this._isReady = !1;
try {
var r = this._engine;
this._pipelineContext = r.createPipelineContext(this._processingContext),
this._pipelineContext._name = this._key;
var o = this._rebuildProgram.bind(this);
this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride ? r._preparePipelineContext(this._pipelineContext, this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, !0, this._rawVertexSourceCode, this._rawFragmentSourceCode, o, null, this._transformFeedbackVaryings, this._key) : r._preparePipelineContext(this._pipelineContext, this._vertexSourceCode, this._fragmentSourceCode, !1, this._rawVertexSourceCode, this._rawFragmentSourceCode, o, i, this._transformFeedbackVaryings, this._key),
r._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]
}
r.bindSamplers(e),
e._compilationError = "",
e._isReady = !0,
e.onCompiled && e.onCompiled(e),
e.onCompileObservable.notifyObservers(e),
e.onCompileObservable.clear(),
e._fallbacks && e._fallbacks.unBindMesh(),
n && e.getEngine()._deletePipelineContext(n)
}
)),
this._pipelineContext.isAsync && this._checkIsReady(n)
} catch (e) {
this._processCompilationErrors(e, n)
}
}
,
e.prototype._getShaderCodeAndErrorLine = function(e, t, i) {
var n = i ? /FRAGMENT SHADER ERROR: 0:(\d+?):/ : /VERTEX SHADER ERROR: 0:(\d+?):/
, r = null;
if (t && e) {
var o = t.match(n);
if (o && 2 === o.length) {
var a = parseInt(o[1])
, s = e.split("\n", -1);
s.length >= a && (r = "Offending line [".concat(a, "] in ").concat(i ? "fragment" : "vertex", " code: ").concat(s[a - 1]))
}
}
return [e, r]
}
,
e.prototype._processCompilationErrors = function(t, i) {
var n, r, o, a, s;
void 0 === i && (i = null),
this._compilationError = t.message;
var l = this._attributesNames
, c = this._fallbacks;
if (K.Error("Unable to compile effect:"),
K.Error("Uniforms: " + this._uniformsNames.map((function(e) {
return " " + e
}
))),
K.Error("Attributes: " + l.map((function(e) {
return " " + e
}
))),
K.Error("Defines:\r\n" + this.defines),
e.LogShaderCodeOnCompilationError) {
var u = null
, h = null
, d = null;
(null === (o = this._pipelineContext) || void 0 === o ? void 0 : o._getVertexShaderCode()) && (d = (n = this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(), this._compilationError, !1))[0],
u = n[1],
d && (K.Error("Vertex code:"),
K.Error(d))),
(null === (a = this._pipelineContext) || void 0 === a ? void 0 : a._getFragmentShaderCode()) && (d = (r = this._getShaderCodeAndErrorLine(null === (s = this._pipelineContext) || void 0 === s ? void 0 : s._getFragmentShaderCode(), this._compilationError, !0))[0],
h = r[1],
d && (K.Error("Fragment code:"),
K.Error(d))),
u && K.Error(u),
h && K.Error(h)
}
K.Error("Error: " + this._compilationError),
i && (this._pipelineContext = i,
this._isReady = !0,
this.onError && this.onError(this, this._compilationError),
this.onErrorObservable.notifyObservers(this)),
c ? (this._pipelineContext = null,
c.hasMoreFallbacks ? (this._allFallbacksProcessed = !1,
K.Error("Trying next fallback."),
this.defines = c.reduce(this.defines, this),
this._prepareEffect()) : (this._allFallbacksProcessed = !0,
this.onError && this.onError(this, this._compilationError),
this.onErrorObservable.notifyObservers(this),
this.onErrorObservable.clear(),
this._fallbacks && this._fallbacks.unBindMesh())) : this._allFallbacksProcessed = !0
}
,
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 n = this._samplerList.indexOf(e), r = 1; r < t.length; r++) {
var o = i + (r - 1).toString();
this._samplerList.splice(n + r, 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 n = this._uniformBuffersNames[i];
void 0 === n || e._BaseCache[n] === t && this._engine._features.useUBOBindingCache || (e._BaseCache[n] = t,
this._engine.bindUniformBufferBase(t, n, 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, n) {
return this._pipelineContext.setInt3(e, t, i, n),
this
}
,
e.prototype.setInt4 = function(e, t, i, n, r) {
return this._pipelineContext.setInt4(e, t, i, n, r),
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.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, n) {
return this._pipelineContext.setFloat3(e, t, i, n),
this
}
,
e.prototype.setVector4 = function(e, t) {
return this._pipelineContext.setVector4(e, t),
this
}
,
e.prototype.setFloat4 = function(e, t, i, n, r) {
return this._pipelineContext.setFloat4(e, t, i, n, r),
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)
}
,
e.RegisterShader = function(e, t, i, n) {
void 0 === n && (n = st.GLSL),
t && (Pt.GetShadersStore(n)["".concat(e, "PixelShader")] = t),
i && (Pt.GetShadersStore(n)["".concat(e, "VertexShader")] = i)
}
,
e.ResetCache = function() {
e._BaseCache = {}
}
,
e.LogShaderCodeOnCompilationError = !0,
e._UniqueIdSeed = 0,
e._BaseCache = {},
e.ShadersStore = Pt.ShadersStore,
e.IncludesShadersStore = Pt.IncludesShadersStore,
e
}(), It = 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
}(), Ot = 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
}(), Dt = 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, n) {
this._blendConstants[0] === e && this._blendConstants[1] === t && this._blendConstants[2] === i && this._blendConstants[3] === n || (this._blendConstants[0] = e,
this._blendConstants[1] = t,
this._blendConstants[2] = i,
this._blendConstants[3] = n,
this._isBlendConstantsDirty = !0)
}
,
e.prototype.setAlphaBlendFunctionParameters = function(e, t, i, n) {
this._blendFunctionParameters[0] === e && this._blendFunctionParameters[1] === t && this._blendFunctionParameters[2] === i && this._blendFunctionParameters[3] === n || (this._blendFunctionParameters[0] = e,
this._blendFunctionParameters[1] = t,
this._blendFunctionParameters[2] = i,
this._blendFunctionParameters[3] = n,
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
}(), Nt = 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, n, r, 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 === n && (n = 1),
void 0 === r && (r = a.TEXTURE_BILINEAR_SAMPLINGMODE),
void 0 === o && (o = 0),
this._cachedWrapU = e,
this._cachedWrapV = t,
this._cachedWrapR = i,
this._cachedAnisotropicFilteringLevel = n,
this.samplingMode = r,
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"
}(At || (At = {}));
var Lt = function(e) {
function t(i, n, r) {
void 0 === r && (r = !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 h,
o.onErrorObservable = new h,
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 = At.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 = n,
o._uniqueId = t._Counter++,
r || (o._hardwareTexture = i._createHardwareTexture()),
o
}
return U(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.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)
, n = function(e) {
e._swapAndDie(t, !1),
t.isReady = i.isReady
};
i.isAsync ? i.proxy.then(n) : n(i.proxy)
} else {
var r;
switch (this.source) {
case At.Temp:
break;
case At.Url:
return void (r = this._engine.createTexture(null !== (e = this._originalUrl) && void 0 !== e ? e : this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, (function() {
r._swapAndDie(t, !1),
t.isReady = !0
}
), null, this._buffer, void 0, this.format, this._extension, void 0, void 0, void 0, this._useSRGBBuffer));
case At.Raw:
(r = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type))._swapAndDie(this, !1),
this.isReady = !0;
break;
case At.Raw3D:
(r = 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 At.Raw2DArray:
(r = 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 At.Dynamic:
(r = 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 At.Cube:
return void (r = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, (function() {
r._swapAndDie(t, !1),
t.isReady = !0
}
), null, this.format, this._extension, !1, 0, 0, null, void 0, this._useSRGBBuffer));
case At.CubeRaw:
(r = 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 At.CubeRawRGBD:
return;
case At.CubePrefiltered:
return void ((r = 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 n = this._engine.getLoadedTexturesCache()
, r = n.indexOf(this);
-1 !== r && n.splice(r, 1),
-1 === (r = n.indexOf(e)) && n.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
}(Nt)
, Ft = function() {
function e() {
this.shaderLanguage = st.GLSL
}
return e.prototype.postProcessor = function(e, t, i, n, r) {
return r.getCaps().drawBuffersExtension || (e = e.replace(/#extension.+GL_EXT_draw_buffers.+(enable|require)/g, "")),
e
}
,
e
}()
, wt = function() {
function e() {
this.shaderLanguage = st.GLSL
}
return e.prototype.attributeProcessor = function(e) {
return e.replace("attribute", "in")
}
,
e.prototype.varyingProcessor = function(e, t) {
return e.replace("varying", t ? "in" : "out")
}
,
e.prototype.postProcessor = function(e, t, i) {
var n = -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)
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, (n ? "" : "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
}()
, Bt = 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
}()
, Ut = function(e) {
function t(t) {
var i = e.call(this) || this;
return i._buffer = t,
i
}
return U(t, e),
Object.defineProperty(t.prototype, "underlyingResource", {
get: function() {
return this._buffer
},
enumerable: !1,
configurable: !0
}),
t
}(Bt)
, Vt = function() {
function e() {
this._valueCache = {},
this.vertexCompilationError = null,
this.fragmentCompilationError = null,
this.programLinkError = null,
this.programValidationError = null
}
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, n, r, 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) {
n[i[t]] = e
}
)),
this._uniforms = n,
l = 0; l < r.length; l++)
null == e.getUniform(r[l]) && (r.splice(l, 1),
l--);
r.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 = {}
}
,
e.prototype._cacheMatrix = function(e, t) {
var i = this._valueCache[e]
, n = t.updateFlag;
return (void 0 === i || i !== n) && (this._valueCache[e] = n,
!0)
}
,
e.prototype._cacheFloat2 = function(e, t, i) {
var n = this._valueCache[e];
if (!n || 2 !== n.length)
return n = [t, i],
this._valueCache[e] = n,
!0;
var r = !1;
return n[0] !== t && (n[0] = t,
r = !0),
n[1] !== i && (n[1] = i,
r = !0),
r
}
,
e.prototype._cacheFloat3 = function(e, t, i, n) {
var r = this._valueCache[e];
if (!r || 3 !== r.length)
return r = [t, i, n],
this._valueCache[e] = r,
!0;
var o = !1;
return r[0] !== t && (r[0] = t,
o = !0),
r[1] !== i && (r[1] = i,
o = !0),
r[2] !== n && (r[2] = n,
o = !0),
o
}
,
e.prototype._cacheFloat4 = function(e, t, i, n, r) {
var o = this._valueCache[e];
if (!o || 4 !== o.length)
return o = [t, i, n, r],
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] !== n && (o[2] = n,
a = !0),
o[3] !== r && (o[3] = r,
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, n) {
this._cacheFloat3(e, t, i, n) && (this.engine.setInt3(this._uniforms[e], t, i, n) || (this._valueCache[e] = null))
}
,
e.prototype.setInt4 = function(e, t, i, n, r) {
this._cacheFloat4(e, t, i, n, r) && (this.engine.setInt4(this._uniforms[e], t, i, n, r) || (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.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, n) {
this._cacheFloat3(e, t, i, n) && (this.engine.setFloat3(this._uniforms[e], t, i, n) || (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.setFloat4 = function(e, t, i, n, r) {
this._cacheFloat4(e, t, i, n, r) && (this.engine.setFloat4(this._uniforms[e], t, i, n, r) || (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
}()
, kt = function() {
function e(e, t) {
if (void 0 === e && (e = null),
this._MSAARenderBuffer = 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._MSAARenderBuffer = null
}
,
e.prototype.release = function() {
this._MSAARenderBuffer && (this._context.deleteRenderbuffer(this._MSAARenderBuffer),
this._MSAARenderBuffer = null),
this._webGLTexture && this._context.deleteTexture(this._webGLTexture),
this.reset()
}
,
e
}()
, Gt = 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 n;
void 0 === i && (i = !0),
this.effect = e,
void 0 !== t && (this.defines = t),
i && (null === (n = this.drawContext) || void 0 === n || n.reset())
}
,
e.prototype.dispose = function() {
var e;
null === (e = this.drawContext) || void 0 === e || e.dispose()
}
,
e
}()
, zt = 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
}()
, Wt = function() {}
, Ht = function() {
function e(t, i, n, r) {
var o = this;
this._name = "WebGL",
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 h,
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 h,
this.onContextRestoredObservable = new h,
this._contextWasLost = !1,
this._doNotHandleContextLost = !1,
this.disableVertexArrayObjects = !1,
this._colorWrite = !0,
this._colorWriteChanged = !0,
this._depthCullingState = new It,
this._stencilStateComposer = new zt,
this._stencilState = new Ot,
this._alphaState = new Dt,
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._activeRequests = new Array,
this._adaptToDeviceRatio = !1,
this._transformTextureUrl = null,
this.hostInformation = {
isMobile: !1
},
this.premultipliedAlpha = !0,
this.onBeforeTextureInitObservable = new h,
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 = {};
var s = null;
if (n = n || {},
this._creationOptions = n,
this._adaptToDeviceRatio = null != r && r,
this._stencilStateComposer.stencilGlobal = this._stencilState,
T.SetMatrixPrecision(!!n.useHighPrecisionMatrix),
t) {
if (r = r || n.adaptToDeviceRatio || !1,
t.getContext) {
if (s = t,
this._renderingCanvas = s,
void 0 !== i && (n.antialias = i),
void 0 === n.deterministicLockstep && (n.deterministicLockstep = !1),
void 0 === n.lockstepMaxSteps && (n.lockstepMaxSteps = 4),
void 0 === n.timeStep && (n.timeStep = 1 / 60),
void 0 === n.preserveDrawingBuffer && (n.preserveDrawingBuffer = !1),
void 0 === n.audioEngine && (n.audioEngine = !0),
void 0 !== n.audioEngineOptions && void 0 !== n.audioEngineOptions.audioContext && (this._audioContext = n.audioEngineOptions.audioContext),
void 0 !== n.audioEngineOptions && void 0 !== n.audioEngineOptions.audioDestination && (this._audioDestination = n.audioEngineOptions.audioDestination),
void 0 === n.stencil && (n.stencil = !0),
!1 === n.premultipliedAlpha && (this.premultipliedAlpha = !1),
void 0 === n.xrCompatible && (n.xrCompatible = !0),
this._doNotHandleContextLost = !!n.doNotHandleContextLost,
navigator && navigator.userAgent) {
this._checkForMobile = function() {
var e = navigator.userAgent;
o.hostInformation.isMobile = -1 !== e.indexOf("Mobile") || -1 !== e.indexOf("Mac") && ot() && "ontouchend"in document
}
,
this._checkForMobile(),
nt() && window.addEventListener("resize", this._checkForMobile);
for (var l = navigator.userAgent, c = 0, u = e.ExceptionList; c < u.length; c++) {
var d = u[c]
, p = d.key
, f = d.targets;
if (new RegExp(p).test(l)) {
if (d.capture && d.captureConstraint) {
var _ = d.capture
, m = d.captureConstraint
, g = new RegExp(_).exec(l);
if (g && g.length > 0 && parseInt(g[g.length - 1]) >= m)
continue
}
for (var v = 0, y = f; v < y.length; v++)
switch (y[v]) {
case "uniformBuffer":
this.disableUniformBuffers = !0;
break;
case "vao":
this.disableVertexArrayObjects = !0
}
}
}
}
if (this._doNotHandleContextLost || (this._onContextLost = function(e) {
e.preventDefault(),
o._contextWasLost = !0,
K.Warn("WebGL context lost."),
o.onContextLostObservable.notifyObservers(o)
}
,
this._onContextRestored = function() {
o._restoreEngineAfterContextLost(o._initGLContext.bind(o))
}
,
s.addEventListener("webglcontextlost", this._onContextLost, !1),
s.addEventListener("webglcontextrestored", this._onContextRestored, !1),
n.powerPreference = "high-performance"),
this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent),
this._badDesktopOS && (n.xrCompatible = !1),
!n.disableWebGL2Support)
try {
this._gl = s.getContext("webgl2", n) || s.getContext("experimental-webgl2", n),
this._gl && (this._webGLVersion = 2,
this._shaderPlatformName = "WEBGL2",
this._gl.deleteQuery || (this._webGLVersion = 1,
this._shaderPlatformName = "WEBGL1"))
} catch (e) {}
if (!this._gl) {
if (!s)
throw new Error("The provided canvas is null or undefined.");
try {
this._gl = s.getContext("webgl", n) || s.getContext("experimental-webgl", n)
} 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 b = this._gl.getContextAttributes();
b && (n.stencil = b.stencil)
}
this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE),
void 0 !== n.useHighPrecisionFloats && (this._highPrecisionShadersAllowed = n.useHighPrecisionFloats);
var E = nt() && window.devicePixelRatio || 1
, S = n.limitDeviceRatio || E;
this._hardwareScalingLevel = r ? 1 / Math.min(S, E) : 1,
this.resize(),
this._isStencilEnable = !!n.stencil,
this._initGLContext(),
this._initFeatures();
for (var A = 0; A < this._caps.maxVertexAttribs; A++)
this._currentBufferPointers[A] = new Wt;
this._shaderProcessor = this.webGLVersion > 1 ? new wt : new Ft,
this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
var x = "Babylon.js v".concat(e.Version);
console.log(x + " - ".concat(this.description)),
this._renderingCanvas && this._renderingCanvas.setAttribute && this._renderingCanvas.setAttribute("data-engine", x)
}
}
return Object.defineProperty(e, "NpmPackage", {
get: function() {
return "babylonjs@5.0.0-rc.4"
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "Version", {
get: function() {
return "5.0.0-rc.4"
},
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, "ShadersRepository", {
get: function() {
return Mt.ShadersRepository
},
set: function(e) {
Mt.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._restoreEngineAfterContextLost = function(e) {
var t = this;
setTimeout((function() {
return G(t, void 0, void 0, (function() {
var t, i, n, r, o;
return z(this, (function(a) {
switch (a.label) {
case 0:
return this._dummyFramebuffer = null,
t = this._depthCullingState.depthTest,
i = this._depthCullingState.depthFunc,
n = this._depthCullingState.depthMask,
r = this._stencilState.stencilTest,
[4, e()];
case 1:
return a.sent(),
this._rebuildEffects(),
null === (o = this._rebuildComputeEffects) || void 0 === o || o.call(this),
this._rebuildInternalTextures(),
this._rebuildRenderTargetWrappers(),
this._rebuildBuffers(),
this.wipeCaches(!0),
this._depthCullingState.depthTest = t,
this._depthCullingState.depthFunc = i,
this._depthCullingState.depthMask = n,
this._stencilState.stencilTest = r,
K.Warn(this.name + " context successfully restored."),
this.onContextRestoredObservable.notifyObservers(this),
this._contextWasLost = !1,
[2]
}
}
))
}
))
}
), 0)
}
,
e.prototype._sharedInit = function(e, t, i) {
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()
}
Mt.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, n = this._storageBuffers; i < n.length; i++)
n[i]._rebuild()
}
,
e.prototype._initGLContext = function() {
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")),
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")),
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
},
this._glVersion = this._gl.getParameter(this._gl.VERSION);
var e = this._gl.getExtension("WEBGL_debug_renderer_info");
if (null != e && (this._glRenderer = this._gl.getParameter(e.UNMASKED_RENDERER_WEBGL),
this._glVendor = this._gl.getParameter(e.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 = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) > 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_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._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 = this._gl.getParameter(this._gl.MAX_SAMPLES);
else {
var t = this._gl.getExtension("WEBGL_draw_buffers");
if (null !== t) {
this._caps.drawBuffersExtension = !0,
this._gl.drawBuffers = t.drawBuffersWEBGL.bind(t),
this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
for (var i = 0; i < 16; i++)
this._gl["COLOR_ATTACHMENT" + i + "_WEBGL"] = t["COLOR_ATTACHMENT" + i + "_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 r = this._gl.getExtension("OES_vertex_array_object");
null != r && (this._caps.vertexArrayObject = !0,
this._gl.createVertexArray = r.createVertexArrayOES.bind(r),
this._gl.bindVertexArray = r.bindVertexArrayOES.bind(r),
this._gl.deleteVertexArray = r.deleteVertexArrayOES.bind(r))
}
if (this._webGLVersion > 1)
this._caps.instancedArrays = !0;
else {
var o = this._gl.getExtension("ANGLE_instanced_arrays");
null != o ? (this._caps.instancedArrays = !0,
this._gl.drawArraysInstanced = o.drawArraysInstancedANGLE.bind(o),
this._gl.drawElementsInstanced = o.drawElementsInstancedANGLE.bind(o),
this._gl.vertexAttribDivisor = o.vertexAttribDivisorANGLE.bind(o)) : this._caps.instancedArrays = !1
}
if (this._gl.getShaderPrecisionFormat) {
var a = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT)
, s = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
a && s && (this._caps.highPrecisionShaderSupported = 0 !== a.precision && 0 !== s.precision)
}
if (this._webGLVersion > 1)
this._caps.blendMinMax = !0;
else {
var l = this._gl.getExtension("EXT_blend_minmax");
null != l && (this._caps.blendMinMax = !0,
this._gl.MAX = l.MAX_EXT,
this._gl.MIN = l.MIN_EXT)
}
if (!this._caps.supportSRGBBuffers) {
if (this._webGLVersion > 1)
this._caps.supportSRGBBuffers = !0;
else {
var c = this._gl.getExtension("EXT_sRGB");
null != c && (this._caps.supportSRGBBuffers = !0,
this._gl.SRGB = c.SRGB_EXT,
this._gl.SRGB8 = c.SRGB_ALPHA_EXT,
this._gl.SRGB8_ALPHA8 = c.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 u = 0; u < this._maxSimultaneousTextures; u++)
this._nextFreeTextureSlots.push(u)
}
,
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,
_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) {
var t = this._activeRenderLoops.indexOf(e);
t >= 0 && this._activeRenderLoops.splice(t, 1)
} else
this._activeRenderLoops = []
}
,
e.prototype._renderLoop = function() {
if (!this._contextWasLost) {
var e = !0;
if (!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 nt() ? 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(e, t, i, n) {
void 0 === n && (n = !1);
var r = this.stencilStateComposer.useStencilGlobalOnly;
this.stencilStateComposer.useStencilGlobalOnly = !0,
this.applyStates(),
this.stencilStateComposer.useStencilGlobalOnly = r;
var o = 0;
t && e && (this._gl.clearColor(e.r, e.g, e.b, void 0 !== e.a ? e.a : 1),
o |= this._gl.COLOR_BUFFER_BIT),
i && (this.useReverseDepthBuffer ? (this._depthCullingState.depthFunc = this._gl.GEQUAL,
this._gl.clearDepth(0)) : this._gl.clearDepth(1),
o |= this._gl.DEPTH_BUFFER_BIT),
n && (this._gl.clearStencil(0),
o |= this._gl.STENCIL_BUFFER_BIT),
this._gl.clear(o)
}
,
e.prototype._viewport = function(e, t, i, n) {
e === this._viewportCached.x && t === this._viewportCached.y && i === this._viewportCached.z && n === this._viewportCached.w || (this._viewportCached.x = e,
this._viewportCached.y = t,
this._viewportCached.z = i,
this._viewportCached.w = n,
this._gl.viewport(e, t, i, n))
}
,
e.prototype.setViewport = function(e, t, i) {
var n = t || this.getRenderWidth()
, r = i || this.getRenderHeight()
, o = e.x || 0
, a = e.y || 0;
this._cachedViewport = e,
this._viewport(o * n, a * r, n * e.width, r * 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 n = nt() && window.devicePixelRatio || 1
, r = this._creationOptions.limitDeviceRatio || n;
this._hardwareScalingLevel = this._adaptToDeviceRatio ? 1 / Math.min(r, n) : 1
}
nt() ? (t = this._renderingCanvas ? this._renderingCanvas.clientWidth || this._renderingCanvas.width : window.innerWidth,
i = this._renderingCanvas ? this._renderingCanvas.clientHeight || this._renderingCanvas.height : window.innerHeight) : (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, n, r, 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.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 && !r ? this.setViewport(this._cachedViewport, i, n) : (i || (i = e.width,
o && (i /= Math.pow(2, o))),
n || (n = e.height,
o && (n /= Math.pow(2, o))),
this._viewport(0, 0, i, n)),
this.wipeCaches()
}
,
e.prototype.setState = function(e, t, i, n, r, o, a) {
var s, l;
void 0 === t && (t = 0),
void 0 === n && (n = !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 : r) || 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 = n ? this._gl.CW : this._gl.CCW;
(this._depthCullingState.frontFace !== u || i) && (this._depthCullingState.frontFace = u),
this._stencilStateComposer.stencilMaterial = o
}
,
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 n;
void 0 === t && (t = !1);
var r = e;
this._currentRenderTarget = null;
var o = this._gl;
if (r._MSAAFramebuffer) {
if (e.isMulti)
return void this.unBindMultiColorAttachmentFramebuffer(e, t, i);
o.bindFramebuffer(o.READ_FRAMEBUFFER, r._MSAAFramebuffer),
o.bindFramebuffer(o.DRAW_FRAMEBUFFER, r._framebuffer),
o.blitFramebuffer(0, 0, e.width, e.height, 0, 0, e.width, e.height, o.COLOR_BUFFER_BIT, o.NEAREST)
}
!(null === (n = e.texture) || void 0 === n ? void 0 : n.generateMipMaps) || t || e.isCube || this.generateMipmaps(e.texture),
i && (r._MSAAFramebuffer && this._bindUnboundFramebuffer(r._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 n = new Ut(i);
return this.bindArrayBuffer(n),
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(),
n.references = 1,
n
}
,
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()
, n = new Ut(i);
if (!i)
throw new Error("Unable to create index buffer");
this.bindIndexBuffer(n);
var r = this._normalizeIndexData(e);
return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, r, t ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW),
this._resetIndexBufferBinding(),
n.references = 1,
n.is32Bits = 4 === r.BYTES_PER_ELEMENT,
n
}
,
e.prototype._normalizeIndexData = function(e) {
if (2 === e.BYTES_PER_ELEMENT)
return e;
if (this._caps.uintIndices) {
if (e instanceof Uint32Array)
return e;
for (var t = 0; t < 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 n = e.program
, r = this._gl.getUniformBlockIndex(n, t);
this._gl.uniformBlockBinding(n, r, 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, n, r, 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 !== n && (s.type = n,
l = !0),
s.normalized !== r && (s.normalized = r,
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 = n,
s.normalized = r,
s.stride = o,
s.offset = a,
s.buffer = e),
(l || this._vaoRecordInProgress) && (this.bindArrayBuffer(e),
this._gl.vertexAttribPointer(t, i, n, r, 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 n = t.getAttributesNames();
this._vaoRecordInProgress || this._unbindVertexArrayObject(),
this.unbindAllAttributes();
for (var r = 0; r < n.length; r++) {
var o = t.getAttributeLocation(r);
if (o >= 0) {
var a = n[r]
, 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, n) {
var r = this._gl.createVertexArray();
return this._vaoRecordInProgress = !0,
this._gl.bindVertexArray(r),
this._mustWipeVertexAttributes = !0,
this._bindVertexBuffersAttributes(e, i, n),
this.bindIndexBuffer(t),
this._vaoRecordInProgress = !1,
this._gl.bindVertexArray(null),
r
}
,
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, n, r) {
if (this._cachedVertexBuffers !== e || this._cachedEffectForVertexBuffers !== r) {
this._cachedVertexBuffers = e,
this._cachedEffectForVertexBuffers = r;
var o = r.getAttributesCount();
this._unbindVertexArrayObject(),
this.unbindAllAttributes();
for (var a = 0, s = 0; s < o; s++)
if (s < i.length) {
var l = r.getAttributeLocation(s);
l >= 0 && (this._gl.enableVertexAttribArray(l),
this._vertexAttribArraysEnabled[l] = !0,
this._vertexAttribPointer(e, l, i[s], this._gl.FLOAT, !1, n, 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, n) {
this._cachedVertexBuffers === e && this._cachedEffectForVertexBuffers === i || (this._cachedVertexBuffers = e,
this._cachedEffectForVertexBuffers = i,
this._bindVertexBuffersAttributes(e, i, n)),
this._bindIndexBufferWithCache(t)
}
,
e.prototype.unbindInstanceAttributes = function() {
for (var e, t = 0, i = this._currentInstanceLocations.length; t < i; t++) {
var n = this._currentInstanceBuffers[t];
e != n && n.references && (e = n,
this.bindArrayBuffer(n));
var r = this._currentInstanceLocations[t];
this._gl.vertexAttribDivisor(r, 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 n = 0; n < 4; n++) {
var r = i[n];
this._vertexAttribArraysEnabled[r] || (this._gl.enableVertexAttribArray(r),
this._vertexAttribArraysEnabled[r] = !0),
this._vertexAttribPointer(e, r, 4, this._gl.FLOAT, !1, 64, 16 * n),
this._gl.vertexAttribDivisor(r, 1),
this._currentInstanceLocations.push(r),
this._currentInstanceBuffers.push(e)
}
}
,
e.prototype.bindInstancesBuffer = function(e, t, i) {
void 0 === i && (i = !0),
this.bindArrayBuffer(e);
var n = 0;
if (i)
for (var r = 0; r < t.length; r++)
n += 4 * (o = t[r]).attributeSize;
for (r = 0; r < t.length; r++) {
var o;
void 0 === (o = t[r]).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, n, 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, n) {
this.drawElementsType(e ? a.MATERIAL_TriangleFillMode : a.MATERIAL_WireFrameFillMode, t, i, n)
}
,
e.prototype.drawPointClouds = function(e, t, i) {
this.drawArraysType(a.MATERIAL_PointFillMode, e, t, i)
}
,
e.prototype.drawUnIndexed = function(e, t, i, n) {
this.drawArraysType(e ? a.MATERIAL_TriangleFillMode : a.MATERIAL_WireFrameFillMode, t, i, n)
}
,
e.prototype.drawElementsType = function(e, t, i, n) {
this.applyStates(),
this._reportDrawCall();
var r = this._drawMode(e)
, o = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT
, a = this._uintIndicesCurrentlySet ? 4 : 2;
n ? this._gl.drawElementsInstanced(r, i, o, t * a, n) : this._gl.drawElements(r, i, o, t * a)
}
,
e.prototype.drawArraysType = function(e, t, i, n) {
this.applyStates(),
this._reportDrawCall();
var r = this._drawMode(e);
n ? this._gl.drawArraysInstanced(r, t, i, n) : this._gl.drawArrays(r, 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) {
if (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,
void (this.useReverseDepthBuffer ? e.USE_REVERSE_DEPTHBUFFER = "" : delete e.USE_REVERSE_DEPTHBUFFER);
var t = "";
return this.isNDCHalfZRange && (t += "#define IS_NDC_HALF_ZRANGE"),
this.useReverseDepthBuffer && (t && (t += "\n"),
t += "#define USE_REVERSE_DEPTHBUFFER"),
t
}
,
e.prototype.createEffect = function(e, t, i, n, r, o, a, s, l, c) {
var u;
void 0 === c && (c = st.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 != r ? r : 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 Mt(e,t,i,n,this,r,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, n, r) {
return this._compileRawShader(e._ConcatenateShader(t, n, r), i)
}
,
e.prototype._compileRawShader = function(e, t) {
for (var i = this._gl; i.getError() != i.NO_ERROR; )
;
var n = i.createShader("vertex" === t ? i.VERTEX_SHADER : i.FRAGMENT_SHADER);
if (!n)
throw new Error("Something went wrong while creating a gl ".concat(t, " shader object. gl error=").concat(i.getError(), ", gl isContextLost=").concat(i.isContextLost(), ", _contextWasLost=").concat(this._contextWasLost));
return i.shaderSource(n, e),
i.compileShader(n),
n
}
,
e.prototype._getShaderSource = function(e) {
return this._gl.getShaderSource(e)
}
,
e.prototype.createRawShaderProgram = function(e, t, i, n, r) {
void 0 === r && (r = null),
n = n || this._gl;
var o = this._compileRawShader(t, "vertex")
, a = this._compileRawShader(i, "fragment");
return this._createShaderProgram(e, o, a, n, r)
}
,
e.prototype.createShaderProgram = function(e, t, i, n, r, o) {
void 0 === o && (o = null),
r = r || this._gl;
var a = this._webGLVersion > 1 ? "#version 300 es\n#define WEBGL2 \n" : ""
, s = this._compileShader(t, "vertex", n, a)
, l = this._compileShader(i, "fragment", n, a);
return this._createShaderProgram(e, s, l, r, o)
}
,
e.prototype.inlineShaderCode = function(e) {
return e
}
,
e.prototype.createPipelineContext = function(e) {
var t = new Vt;
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, n, r) {
void 0 === r && (r = null);
var o = n.createProgram();
if (e.program = o,
!o)
throw new Error("Unable to create program");
return n.attachShader(o, t),
n.attachShader(o, i),
n.linkProgram(o),
e.context = n,
e.vertexShader = t,
e.fragmentShader = i,
e.isParallelCompiled || this._finalizePipelineContext(e),
o
}
,
e.prototype._finalizePipelineContext = function(e) {
var t = e.context
, i = e.vertexShader
, n = e.fragmentShader
, r = e.program;
if (!t.getProgramParameter(r, 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(n, this._gl.COMPILE_STATUS) && (o = this._gl.getShaderInfoLog(n)))
throw e.fragmentCompilationError = o,
new Error("FRAGMENT SHADER " + o);
if (a = t.getProgramInfoLog(r))
throw e.programLinkError = a,
new Error(a)
}
if (this.validateShaderPrograms && (t.validateProgram(r),
!t.getProgramParameter(r, t.VALIDATE_STATUS) && (a = t.getProgramInfoLog(r))))
throw e.programValidationError = a,
new Error(a);
t.deleteShader(i),
t.deleteShader(n),
e.vertexShader = void 0,
e.fragmentShader = void 0,
e.onCompiled && (e.onCompiled(),
e.onCompiled = void 0)
}
,
e.prototype._preparePipelineContext = function(e, t, i, n, r, o, a, s, l, c) {
var u = e;
u.program = n ? 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._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 n = i.onCompiled;
i.onCompiled = n ? function() {
n(),
t()
}
: t
} else
t()
}
,
e.prototype.getUniforms = function(e, t) {
for (var i = new Array, n = e, r = 0; r < t.length; r++)
i.push(this._gl.getUniformLocation(n.program, t[r]));
return i
}
,
e.prototype.getAttributes = function(e, t) {
for (var i = [], n = e, r = 0; r < t.length; r++)
try {
i.push(this._gl.getAttribLocation(n.program, t[r]))
} catch (e) {
i.push(-1)
}
return i
}
,
e.prototype.enableEffect = function(e) {
(e = null !== e && Gt.IsWrapper(e) ? e.effect : e) && e !== this._currentEffect && (this._stencilStateComposer.stencilMaterial = void 0,
e = e,
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, n) {
return !!e && (this._gl.uniform3i(e, t, i, n),
!0)
}
,
e.prototype.setInt4 = function(e, t, i, n, r) {
return !!e && (this._gl.uniform4i(e, t, i, n, r),
!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.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, n) {
return !!e && (this._gl.uniform3f(e, t, i, n),
!0)
}
,
e.prototype.setFloat4 = function(e, t, i, n, r) {
return !!e && (this._gl.uniform4f(e, t, i, n, r),
!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 = []
}
,
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
, n = i.NEAREST
, r = i.NEAREST;
switch (e) {
case a.TEXTURE_LINEAR_LINEAR_MIPNEAREST:
n = i.LINEAR,
r = t ? i.LINEAR_MIPMAP_NEAREST : i.LINEAR;
break;
case a.TEXTURE_LINEAR_LINEAR_MIPLINEAR:
n = i.LINEAR,
r = t ? i.LINEAR_MIPMAP_LINEAR : i.LINEAR;
break;
case a.TEXTURE_NEAREST_NEAREST_MIPLINEAR:
n = i.NEAREST,
r = t ? i.NEAREST_MIPMAP_LINEAR : i.NEAREST;
break;
case a.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
n = i.NEAREST,
r = t ? i.NEAREST_MIPMAP_NEAREST : i.NEAREST;
break;
case a.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
n = i.NEAREST,
r = t ? i.LINEAR_MIPMAP_NEAREST : i.LINEAR;
break;
case a.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
n = i.NEAREST,
r = t ? i.LINEAR_MIPMAP_LINEAR : i.LINEAR;
break;
case a.TEXTURE_NEAREST_LINEAR:
n = i.NEAREST,
r = i.LINEAR;
break;
case a.TEXTURE_NEAREST_NEAREST:
n = i.NEAREST,
r = i.NEAREST;
break;
case a.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
n = i.LINEAR,
r = t ? i.NEAREST_MIPMAP_NEAREST : i.NEAREST;
break;
case a.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
n = i.LINEAR,
r = t ? i.NEAREST_MIPMAP_LINEAR : i.NEAREST;
break;
case a.TEXTURE_LINEAR_LINEAR:
n = i.LINEAR,
r = i.LINEAR;
break;
case a.TEXTURE_LINEAR_NEAREST:
n = i.LINEAR,
r = i.NEAREST
}
return {
min: r,
mag: n
}
}
,
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 kt(this._createTexture(),this._gl)
}
,
e.prototype._createInternalTexture = function(e, t, i, n) {
void 0 === i && (i = !0),
void 0 === n && (n = At.Unknown);
var r = {};
void 0 !== t && "object" == typeof t ? (r.generateMipMaps = t.generateMipMaps,
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.format = void 0 === t.format ? a.TEXTUREFORMAT_RGBA : t.format) : (r.generateMipMaps = t,
r.type = a.TEXTURETYPE_UNSIGNED_INT,
r.samplingMode = a.TEXTURE_TRILINEAR_SAMPLINGMODE,
r.format = a.TEXTUREFORMAT_RGBA),
(r.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (r.type !== a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (r.samplingMode = a.TEXTURE_NEAREST_SAMPLINGMODE),
r.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloat || (r.type = a.TEXTURETYPE_UNSIGNED_INT,
K.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));
var o = this._gl
, s = new Lt(this,n)
, l = e.width || e
, c = e.height || e
, u = e.layers || 0
, h = this._getSamplingParameters(r.samplingMode, !!r.generateMipMaps)
, d = 0 !== u ? o.TEXTURE_2D_ARRAY : o.TEXTURE_2D
, p = this._getRGBABufferInternalSizedFormat(r.type, r.format)
, f = this._getInternalFormat(r.format)
, _ = this._getWebGLTextureType(r.type);
return this._bindTextureDirectly(d, s),
0 !== u ? (s.is2DArray = !0,
o.texImage3D(d, 0, p, l, c, u, 0, f, _, null)) : o.texImage2D(d, 0, p, l, c, 0, f, _, null),
o.texParameteri(d, o.TEXTURE_MAG_FILTER, h.mag),
o.texParameteri(d, o.TEXTURE_MIN_FILTER, h.min),
o.texParameteri(d, o.TEXTURE_WRAP_S, o.CLAMP_TO_EDGE),
o.texParameteri(d, o.TEXTURE_WRAP_T, o.CLAMP_TO_EDGE),
r.generateMipMaps && this._gl.generateMipmap(d),
this._bindTextureDirectly(d, null),
s.baseWidth = l,
s.baseHeight = c,
s.width = l,
s.height = c,
s.depth = u,
s.isReady = !0,
s.samples = 1,
s.generateMipMaps = !!r.generateMipMaps,
s.samplingMode = r.samplingMode,
s.type = r.type,
s.format = r.format,
this._internalTexturesCache.push(s),
s
}
,
e.prototype._getUseSRGBBuffer = function(e, t) {
return e && this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || this.isWebGPU || t)
}
,
e.prototype._createTextureBase = function(t, i, n, r, 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,")
, S = d || new Lt(this,At.Url)
, A = t;
!this._transformTextureUrl || T || d || h || (t = this._transformTextureUrl(t)),
A !== t && (S._originalUrl = A);
var x = t.lastIndexOf(".")
, R = f || (x > -1 ? t.substring(x).toLowerCase() : "")
, C = null;
R.indexOf("?") > -1 && (R = R.split("?")[0]);
for (var P = 0, M = e._TextureLoaders; P < M.length; P++) {
var I = M[P];
if (I.canLoad(R, _)) {
C = I;
break
}
}
r && r._addPendingData(S),
S.url = t,
S.generateMipMaps = !i,
S.samplingMode = o,
S.invertY = n,
S._useSRGBBuffer = this._getUseSRGBBuffer(!!g, i),
this._doNotHandleContextLost || (S._buffer = h);
var O = null;
s && !d && (O = S.onLoadedObservable.add(s)),
d || this._internalTexturesCache.push(S);
var D = function(e, n) {
r && r._removePendingData(S),
t === A ? (O && S.onLoadedObservable.remove(O),
E.UseFallbackTexture && v._createTextureBase(E.FallbackTexture, i, S.invertY, r, o, null, l, c, u, h, S),
e = (e || "Unknown error") + (E.UseFallbackTexture ? " - Fallback texture was used" : ""),
S.onErrorObservable.notifyObservers({
message: e,
exception: n
}),
l && l(e, n)) : (K.Warn("Failed to load ".concat(t, ", falling back to ").concat(A)),
v._createTextureBase(A, i, S.invertY, r, o, s, l, c, u, h, S, p, f, _, m, g))
};
if (C) {
var N = function(e) {
C.loadData(e, S, (function(e, t, i, n, a, s) {
s ? D("TextureLoader failed to load data") : c(S, R, r, {
width: e,
height: t
}, S.invertY, !i, n, (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, r ? r.offlineProvider : void 0, !0, (function(e, t) {
D("Unable to load " + (e && e.responseURL,
t))
}
))
} else {
var L = function(e) {
b && !v._doNotHandleContextLost && (S._buffer = e),
c(S, R, r, e, S.invertY, i, !1, u, o)
};
!y || T ? h && ("string" == typeof h.decoding || h.close) ? L(h) : e._FileToolsLoadImage(t, L, D, r ? r.offlineProvider : null, _, S.invertY && this._features.needsInvertingBitmap ? {
imageOrientation: "flipY"
} : void 0) : "string" == typeof h || h instanceof ArrayBuffer || ArrayBuffer.isView(h) || h instanceof Blob ? e._FileToolsLoadImage(h, L, D, r ? r.offlineProvider : null, _, S.invertY && this._features.needsInvertingBitmap ? {
imageOrientation: "flipY"
} : void 0) : h && L(h)
}
return S
}
,
e.prototype.createTexture = function(e, t, i, n, r, o, s, l, c, u, h, d, p, f, _) {
var m = this;
return void 0 === r && (r = 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, n, r, o, s, this._prepareWebGLTexture.bind(this), (function(e, t, i, r, o, a) {
var s = m._gl
, l = i.width === e && i.height === t
, c = u ? m._getInternalFormat(u, o._useSRGBBuffer) : ".jpg" !== r || o._useSRGBBuffer ? o._useSRGBBuffer ? s.SRGB8_ALPHA8 : s.RGBA : s.RGB
, h = u ? m._getInternalFormat(u) : ".jpg" !== r || 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 Lt(m,At.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, n, 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, n, r, o) {
throw be("FileTools")
}
,
e.prototype._rescaleTexture = function(e, t, i, n, r) {}
,
e.prototype.createRawTexture = function(e, t, i, n, r, o, s, l, c) {
throw void 0 === l && (l = null),
void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT),
be("Engine.RawTexture")
}
,
e.prototype.createRawCubeTexture = function(e, t, i, n, r, o, a, s) {
throw void 0 === s && (s = null),
be("Engine.RawTexture")
}
,
e.prototype.createRawTexture3D = function(e, t, i, n, r, o, s, l, c, u) {
throw void 0 === c && (c = null),
void 0 === u && (u = a.TEXTURETYPE_UNSIGNED_INT),
be("Engine.RawTexture")
}
,
e.prototype.createRawTexture2DArray = function(e, t, i, n, r, o, s, l, c, u) {
throw void 0 === c && (c = null),
void 0 === u && (u = a.TEXTURETYPE_UNSIGNED_INT),
be("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 n = this._getTextureTarget(t)
, r = this._getSamplingParameters(e, t.generateMipMaps || i);
this._setTextureParameterInteger(n, this._gl.TEXTURE_MAG_FILTER, r.mag, t),
this._setTextureParameterInteger(n, this._gl.TEXTURE_MIN_FILTER, r.min),
i && (t.generateMipMaps = !0,
this._gl.generateMipmap(n)),
this._bindTextureDirectly(n, null),
t.samplingMode = e
}
,
e.prototype.updateTextureDimensions = function(e, t, i, n) {
void 0 === n && (n = 1)
}
,
e.prototype.updateTextureWrappingMode = function(e, t, i, n) {
void 0 === i && (i = null),
void 0 === n && (n = null);
var r = this._getTextureTarget(e);
null !== t && (this._setTextureParameterInteger(r, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(t), e),
e._cachedWrapU = t),
null !== i && (this._setTextureParameterInteger(r, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(i), e),
e._cachedWrapV = i),
(e.is2DArray || e.is3D) && null !== n && (this._setTextureParameterInteger(r, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(n), e),
e._cachedWrapR = n),
this._bindTextureDirectly(r, null)
}
,
e.prototype._setupDepthStencilTexture = function(e, t, i, n, r, 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 = n ? a.TEXTURE_BILINEAR_SAMPLINGMODE : a.TEXTURE_NEAREST_SAMPLINGMODE,
e.type = a.TEXTURETYPE_UNSIGNED_INT,
e._comparisonFunction = r;
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),
0 === r ? (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, r),
u.texParameteri(h, u.TEXTURE_COMPARE_MODE, u.COMPARE_REF_TO_TEXTURE))
}
,
e.prototype._uploadCompressedDataToTextureDirectly = function(e, t, i, n, r, 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_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_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, n, 0, r)
}
,
e.prototype._uploadDataToTextureDirectly = function(e, t, i, n, r, o) {
void 0 === i && (i = 0),
void 0 === n && (n = 0),
void 0 === o && (o = !1);
var a = this._gl
, s = this._getWebGLTextureType(e.type)
, l = this._getInternalFormat(e.format)
, c = void 0 === r ? this._getRGBABufferInternalSizedFormat(e.type, e.format, e._useSRGBBuffer) : this._getInternalFormat(r, 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 - n, 0))
, f = o ? e.height : Math.pow(2, Math.max(d - n, 0));
a.texImage2D(u, n, c, p, f, 0, l, s, t)
}
,
e.prototype.updateTextureData = function(e, t, i, n, r, o, a, s) {
void 0 === a && (a = 0),
void 0 === s && (s = 0);
var l = this._gl
, c = this._getWebGLTextureType(e.type)
, u = this._getInternalFormat(e.format);
this._unpackFlipY(e.invertY);
var h = l.TEXTURE_2D;
e.isCube && (h = l.TEXTURE_CUBE_MAP_POSITIVE_X + a),
l.texSubImage2D(h, s, i, n, r, o, u, c, t)
}
,
e.prototype._uploadArrayBufferViewToTexture = function(e, t, i, n) {
void 0 === i && (i = 0),
void 0 === n && (n = 0);
var r = this._gl
, o = e.isCube ? r.TEXTURE_CUBE_MAP : r.TEXTURE_2D;
this._bindTextureDirectly(o, e, !0),
this._uploadDataToTextureDirectly(e, t, i, n),
this._bindTextureDirectly(o, null, !0)
}
,
e.prototype._prepareWebGLTextureContinuation = function(e, t, i, n, r) {
var o = this._gl;
if (o) {
var a = this._getSamplingParameters(r, !i);
o.texParameteri(o.TEXTURE_2D, o.TEXTURE_MAG_FILTER, a.mag),
o.texParameteri(o.TEXTURE_2D, o.TEXTURE_MIN_FILTER, a.min),
i || n || 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, n, r, 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(r.width, d) : r.width)
, f = Math.min(d, this.needPOTTextures ? e.GetExponentOfTwo(r.height, d) : r.height)
, _ = this._gl;
_ && (t._hardwareTexture ? (this._bindTextureDirectly(_.TEXTURE_2D, t, !0),
this._unpackFlipY(void 0 === o || !!o),
t.baseWidth = r.width,
t.baseHeight = r.height,
t.width = p,
t.height = f,
t.isReady = !0,
c(p, f, r, i, t, (function() {
h._prepareWebGLTextureContinuation(t, n, s, l, u)
}
)) || this._prepareWebGLTextureContinuation(t, n, s, l, u)) : n && n._removePendingData(t))
}
,
e.prototype._setupFramebufferDepthAttachments = function(e, t, i, n, r) {
void 0 === r && (r = 1);
var o = this._gl;
if (e && t)
return this._createRenderBuffer(i, n, r, 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, n, r, a, a, o.DEPTH_ATTACHMENT)
}
return e ? this._createRenderBuffer(i, n, r, o.STENCIL_INDEX8, o.STENCIL_INDEX8, o.STENCIL_ATTACHMENT) : null
}
,
e.prototype._createRenderBuffer = function(e, t, i, n, r, o, a) {
void 0 === a && (a = !0);
var s = this._gl
, l = s.createRenderbuffer();
return s.bindRenderbuffer(s.RENDERBUFFER, l),
i > 1 && s.renderbufferStorageMultisample ? s.renderbufferStorageMultisample(s.RENDERBUFFER, i, r, e, t) : s.renderbufferStorage(s.RENDERBUFFER, n, e, t),
s.framebufferRenderbuffer(s.FRAMEBUFFER, o, s.RENDERBUFFER, l),
a && s.bindRenderbuffer(s.RENDERBUFFER, null),
l
}
,
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(), n = 0; n < i.length; n++) {
var r = e.getUniform(i[n]);
r && (this._boundUniforms[n] = r)
}
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, n) {
var r, o;
void 0 === i && (i = !1),
void 0 === n && (n = !1);
var a = !1
, s = t && t._associatedChannel > -1;
if (i && s && (this._activeChannel = t._associatedChannel),
this._boundTexturesCache[this._activeChannel] !== t || n) {
if (this._activateCurrentTexture(),
t && t.isMultiview)
throw console.error(e, t),
"_bindTextureDirectly called with a multiview texture!";
this._gl.bindTexture(e, null !== (o = null === (r = null == t ? void 0 : t._hardwareTexture) || void 0 === r ? void 0 : r.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 n = t ? this._getTextureTarget(t) : this._gl.TEXTURE_2D;
this._bindTextureDirectly(n, 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, n) {
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, n, r) {
if (void 0 === i && (i = !1),
void 0 === n && (n = !1),
void 0 === r && (r = ""),
!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,
t.update();
else if (t.delayLoadState === a.DELAYLOADSTATE_NOTLOADED)
return t.delayLoad(),
!1;
var o;
o = n ? t.depthStencilTexture : t.isReady() ? t.getInternalTexture() : t.isCube ? this.emptyCubeTexture : t.is3D ? this.emptyTexture3D : t.is2DArray ? this.emptyTexture2DArray : this.emptyTexture,
!i && o && (o._associatedChannel = e);
var s = !0;
this._boundTexturesCache[e] === o && (i || this._bindSamplerUniformToChannel(o._associatedChannel, e),
s = !1),
this._activeChannel = e;
var l = this._getTextureTarget(o);
if (s && this._bindTextureDirectly(l, o, i),
o && !o.isMultiview) {
if (o.isCube && o._cachedCoordinatesMode !== t.coordinatesMode) {
o._cachedCoordinatesMode = t.coordinatesMode;
var c = t.coordinatesMode !== a.TEXTURE_CUBIC_MODE && t.coordinatesMode !== a.TEXTURE_SKYBOX_MODE ? a.TEXTURE_WRAP_ADDRESSMODE : a.TEXTURE_CLAMP_ADDRESSMODE;
t.wrapU = c,
t.wrapV = c
}
o._cachedWrapU !== t.wrapU && (o._cachedWrapU = t.wrapU,
this._setTextureParameterInteger(l, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(t.wrapU), o)),
o._cachedWrapV !== t.wrapV && (o._cachedWrapV = t.wrapV,
this._setTextureParameterInteger(l, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(t.wrapV), o)),
o.is3D && o._cachedWrapR !== t.wrapR && (o._cachedWrapR = t.wrapR,
this._setTextureParameterInteger(l, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(t.wrapR), o)),
this._setAnisotropicLevel(l, o, t.anisotropicFilteringLevel)
}
return !0
}
,
e.prototype.setTextureArray = function(e, t, i, n) {
if (void 0 !== e && t) {
this._textureUnits && this._textureUnits.length === i.length || (this._textureUnits = new Int32Array(i.length));
for (var r = 0; r < i.length; r++) {
var o = i[r].getInternalTexture();
o ? (this._textureUnits[r] = e + r,
o._associatedChannel = e + r) : this._textureUnits[r] = -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 n = 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),
n && t._cachedAnisotropicFilteringLevel !== i && (this._setTextureParameterFloat(e, n.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(i, this._caps.maxAnisotropy), t),
t._cachedAnisotropicFilteringLevel = i)
}
,
e.prototype._setTextureParameterFloat = function(e, t, i, n) {
this._bindTextureDirectly(e, n, !0, !0),
this._gl.texParameterf(e, t, i)
}
,
e.prototype._setTextureParameterInteger = function(e, t, i, n) {
n && this._bindTextureDirectly(e, n, !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.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 = [],
nt() && 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 = [],
this._renderingCanvas = null,
this._currentProgram = null,
this._boundRenderFunction = null,
Mt.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
, n = t.createTexture();
t.bindTexture(t.TEXTURE_2D, n),
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 r = t.createFramebuffer();
t.bindFramebuffer(t.FRAMEBUFFER, r),
t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, n, 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(n),
t.deleteFramebuffer(r),
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._gl.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._gl.SRGB : this._gl.RGB;
break;
case a.TEXTUREFORMAT_RGBA:
i = t ? this._gl.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._gl.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._gl.SRGB8 : this._gl.RGB8;
case a.TEXTUREFORMAT_RGBA:
return i ? this._gl.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._gl.SRGB8_ALPHA8 : this._gl.RGBA8
}
,
e.prototype._getRGBAMultiSampleBufferFormat = function(e) {
return e === a.TEXTURETYPE_FLOAT ? this._gl.RGBA32F : e === a.TEXTURETYPE_HALF_FLOAT ? this._gl.RGBA16F : this._gl.RGBA8
}
,
e.prototype._loadFile = function(t, i, n, r, o, a) {
var s = this
, l = e._FileToolsLoadFile(t, i, n, r, 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, n, r, o) {
throw be("FileTools")
}
,
e.prototype.readPixels = function(e, t, i, n, r, o) {
void 0 === r && (r = !0),
void 0 === o && (o = !0);
var a = r ? 4 : 3
, s = r ? this._gl.RGBA : this._gl.RGB
, l = new Uint8Array(n * i * a);
return o && this.flushFramebuffer(),
this._gl.readPixels(e, t, i, n, 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)
, n = e.FloorPOT(t);
return i - t > t - n ? n : i
}
,
e.GetExponentOfTwo = function(t, i, n) {
var r;
switch (void 0 === n && (n = a.SCALEMODE_NEAREST),
n) {
case a.SCALEMODE_FLOOR:
r = e.FloorPOT(t);
break;
case a.SCALEMODE_NEAREST:
r = e.NearestPOT(t);
break;
case a.SCALEMODE_CEILING:
default:
r = e.CeilingPOT(t)
}
return Math.min(r, i)
}
,
e.QueueNewFrame = function(e, t) {
return nt() ? (t || (t = window),
t.requestPostAnimationFrame ? t.requestPostAnimationFrame(e) : t.requestAnimationFrame ? t.requestAnimationFrame(e) : t.msRequestAnimationFrame ? t.msRequestAnimationFrame(e) : t.webkitRequestAnimationFrame ? t.webkitRequestAnimationFrame(e) : t.mozRequestAnimationFrame ? t.mozRequestAnimationFrame(e) : t.oRequestAnimationFrame ? t.oRequestAnimationFrame(e) : window.setTimeout(e, 16)) : "undefined" != typeof requestAnimationFrame ? requestAnimationFrame(e) : setTimeout(e, 16)
}
,
e.prototype.getHostDocument = function() {
return this._renderingCanvas && this._renderingCanvas.ownerDocument ? this._renderingCanvas.ownerDocument : document
}
,
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"]
}],
e._TextureLoaders = [],
e.CollisionsEpsilon = .001,
e._IsSupported = null,
e._HasMajorPerformanceCaveat = null,
e
}()
, Xt = function() {
function e() {}
return e.SetImmediate = function(e) {
nt() && window.setImmediate ? window.setImmediate(e) : setTimeout(e, 1)
}
,
e
}()
, jt = new RegExp(/^data:([^,]+\/[^,]+)?;base64,/i)
, Yt = function(e) {
function t(i, n) {
var r = e.call(this, i, pt.LoadFileError) || this;
return r.name = "LoadFileError",
dt._setPrototypeOf(r, t.prototype),
n instanceof Ye ? r.request = n : r.file = n,
r
}
return U(t, e),
t
}(ft)
, Kt = function(e) {
function t(i, n) {
var r = e.call(this, i, pt.RequestFileError) || this;
return r.request = n,
r.name = "RequestFileError",
dt._setPrototypeOf(r, t.prototype),
r
}
return U(t, e),
t
}(ft)
, Qt = function(e) {
function t(i, n) {
var r = e.call(this, i, pt.ReadFileError) || this;
return r.file = n,
r.name = "ReadFileError",
dt._setPrototypeOf(r, t.prototype),
r
}
return U(t, e),
t
}(ft)
, qt = {
DefaultRetryStrategy: ht.ExponentialBackoff(),
BaseUrl: "",
CorsBehavior: "anonymous",
PreprocessUrl: function(e) {
return e
}
}
, Zt = function(e) {
return e.replace(/#/gm, "%23")
}
, Jt = function(e, t) {
if ((!e || 0 !== e.indexOf("data:")) && qt.CorsBehavior)
if ("string" == typeof qt.CorsBehavior || qt.CorsBehavior instanceof String)
t.crossOrigin = qt.CorsBehavior;
else {
var i = qt.CorsBehavior(e);
i && (t.crossOrigin = i)
}
}
, $t = function(e, t, i, n, r, o) {
var a, s;
void 0 === r && (r = "");
var l = !1;
e instanceof ArrayBuffer || ArrayBuffer.isView(e) ? "undefined" != typeof Blob ? (s = URL.createObjectURL(new Blob([e],{
type: r
})),
l = !0) : s = "data:".concat(r, ";base64,") + le(e) : e instanceof Blob ? (s = URL.createObjectURL(e),
l = !0) : (s = Zt(e),
s = qt.PreprocessUrl(e));
var c = E.LastCreatedEngine
, u = function(t) {
if (i) {
var n = s || e.toString();
i("Error while trying to load image: ".concat(0 === n.indexOf("http") || n.length <= 128 ? n : n.slice(0, 128) + "..."), t)
}
};
if ("undefined" == typeof Image || null !== (a = null == c ? void 0 : c._features.forceBitmapOverHTMLImageElement) && void 0 !== a && a)
return ti(s, (function(n) {
c.createImageBitmap(new Blob([n],{
type: r
}), V({
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, n || void 0, !0, (function(e, t) {
u(t)
}
)),
null;
var h = new Image;
Jt(s, h);
var d = function() {
h.removeEventListener("load", d),
h.removeEventListener("error", p),
t(h),
l && h.src && URL.revokeObjectURL(h.src)
}
, p = function(e) {
h.removeEventListener("load", d),
h.removeEventListener("error", p),
u(e),
l && h.src && URL.revokeObjectURL(h.src)
};
h.addEventListener("load", d),
h.addEventListener("error", p);
var f = function() {
h.src = s
};
if ("blob:" !== s.substr(0, 5) && "data:" !== s.substr(0, 5) && n && n.enableTexturesOffline)
n.open((function() {
n && n.loadImage(s, h)
}
), f);
else {
if (-1 !== s.indexOf("file:")) {
var _ = decodeURIComponent(s.substring(5).toLowerCase());
if (ut.FilesToLoad[_]) {
try {
var m = void 0;
try {
m = URL.createObjectURL(ut.FilesToLoad[_])
} catch (e) {
m = URL.createObjectURL(ut.FilesToLoad[_])
}
h.src = m,
l = !0
} catch (e) {
h.src = ""
}
return h
}
}
f()
}
return h
}
, ei = function(e, t, i, n, r) {
var o = new FileReader
, a = {
onCompleteObservable: new h,
abort: function() {
return o.abort()
}
};
return o.onloadend = function() {
return a.onCompleteObservable.notifyObservers(a)
}
,
r && (o.onerror = function() {
r(new Qt("Unable to read ".concat(e.name),e))
}
),
o.onload = function(e) {
t(e.target.result)
}
,
i && (o.onprogress = i),
n ? o.readAsArrayBuffer(e) : o.readAsText(e),
a
}
, ti = function(e, t, i, n, r, o, a) {
if (e.name)
return ei(e, t, i, r, 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 = ut.FilesToLoad[l];
if (c)
return ei(c, t, i, r, o ? function(e) {
return o(void 0, new Yt(e.message,e.file))
}
: void 0)
}
if (ri(s)) {
var u = {
onCompleteObservable: new h,
abort: function() {
return function() {}
}
};
try {
t(r ? oi(s) : si(s))
} catch (e) {
o ? o(void 0, e) : K.Error(e.message || "Failed to parse the Data URL")
}
return Xt.SetImmediate((function() {
u.onCompleteObservable.notifyObservers(u)
}
)),
u
}
return ii(s, (function(e, i) {
t(e, i ? i.responseURL : void 0)
}
), i, n, r, o ? function(e) {
o(e.request, new Yt(e.message,e.request))
}
: void 0, a)
}
, ii = function(e, t, i, n, r, o, a) {
e = Zt(e),
e = qt.PreprocessUrl(e);
var s = qt.BaseUrl + e
, l = !1
, c = {
onCompleteObservable: new h,
abort: function() {
return l = !0
}
}
, u = function() {
var e, n = new Ye, u = null, h = function() {
n && (i && n.removeEventListener("progress", i),
e && n.removeEventListener("readystatechange", e),
n.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(),
n && n.readyState !== (XMLHttpRequest.DONE || 4) && n.abort(),
null !== u && (clearTimeout(u),
u = null),
n = null
}
;
var p = function(e) {
var t = e.message || "Unknown error";
o && n ? o(new Kt(t,n)) : K.Error(t)
}
, f = function(c) {
if (n) {
if (n.open("GET", s),
a)
try {
a(n)
} catch (e) {
return void p(e)
}
r && (n.responseType = "arraybuffer"),
i && n.addEventListener("progress", i),
d && n.addEventListener("loadend", d),
e = function() {
if (!l && n && n.readyState === (XMLHttpRequest.DONE || 4)) {
if (e && n.removeEventListener("readystatechange", e),
n.status >= 200 && n.status < 300 || 0 === n.status && (!nt() || ni())) {
try {
t && t(r ? n.response : n.responseText, n)
} catch (e) {
p(e)
}
return
}
var i = qt.DefaultRetryStrategy;
if (i) {
var a = i(s, n, c);
if (-1 !== a)
return h(),
n = new Ye,
void (u = setTimeout((function() {
return f(c + 1)
}
), a))
}
var d = new Kt("Error status: " + n.status + " " + n.statusText + " - Unable to load " + s,n);
o && o(d)
}
}
,
n.addEventListener("readystatechange", e),
n.send()
}
};
f(0)
};
if (n && n.enableSceneOffline) {
var d = function(e) {
e && e.status > 400 ? o && o(e) : u()
};
n.open((function() {
n && n.loadFile(qt.BaseUrl + e, (function(e) {
!l && t && t(e),
c.onCompleteObservable.notifyObservers(c)
}
), i ? function(e) {
!l && i && i(e)
}
: void 0, d, r)
}
), d)
} else
u();
return c
}
, ni = function() {
return "undefined" != typeof location && "file:" === location.protocol
}
, ri = function(e) {
return jt.test(e)
};
function oi(e) {
return ue(e.split(",")[1])
}
var ai, si = function(e) {
return ce(e.split(",")[1])
};
Ht._FileToolsLoadImage = $t,
Ht._FileToolsLoadFile = ti,
Ct._FileToolsLoadFile = ti;
var li, ci = function(e, t, i, n, r, o, a, s, l, c) {
ai = {
DecodeBase64UrlToBinary: e,
DecodeBase64UrlToString: t,
DefaultRetryStrategy: i.DefaultRetryStrategy,
BaseUrl: i.BaseUrl,
CorsBehavior: i.CorsBehavior,
PreprocessUrl: i.PreprocessUrl,
IsBase64DataUrl: n,
IsFileURL: r,
LoadFile: o,
LoadImage: a,
ReadFile: s,
RequestFile: l,
SetCorsBehavior: c
},
Object.defineProperty(ai, "DefaultRetryStrategy", {
get: function() {
return i.DefaultRetryStrategy
},
set: function(e) {
i.DefaultRetryStrategy = e
}
}),
Object.defineProperty(ai, "BaseUrl", {
get: function() {
return i.BaseUrl
},
set: function(e) {
i.BaseUrl = e
}
}),
Object.defineProperty(ai, "PreprocessUrl", {
get: function() {
return i.PreprocessUrl
},
set: function(e) {
i.PreprocessUrl = e
}
}),
Object.defineProperty(ai, "CorsBehavior", {
get: function() {
return i.CorsBehavior
},
set: function(e) {
i.CorsBehavior = e
}
})
};
ci(oi, si, qt, ri, ni, ti, $t, ei, ii, Jt),
function(e) {
e[e.Pending = 0] = "Pending",
e[e.Fulfilled = 1] = "Fulfilled",
e[e.Rejected = 2] = "Rejected"
}(li || (li = {}));
var ui = function() {
this.count = 0,
this.target = 0,
this.results = []
}
, hi = function() {
function e(e) {
var t = this;
if (this._state = li.Pending,
this._children = new Array,
this._rejectWasConsumed = !1,
e)
try {
e((function(e) {
t._resolve(e)
}
), (function(e) {
t._reject(e)
}
))
} catch (e) {
this._reject(e)
}
}
return Object.defineProperty(e.prototype, "_result", {
get: function() {
return this._resultValue
},
set: function(e) {
this._resultValue = e,
this._parent && void 0 === this._parent._result && (this._parent._result = e)
},
enumerable: !1,
configurable: !0
}),
e.prototype.catch = function(e) {
return this.then(void 0, e)
}
,
e.prototype.then = function(t, i) {
var n = this
, r = new e;
return r._onFulfilled = t,
r._onRejected = i,
this._children.push(r),
r._parent = this,
this._state !== li.Pending && setTimeout((function() {
n._state === li.Fulfilled || n._rejectWasConsumed ? r._resolve(n._result) : r._reject(n._reason)
}
)),
r
}
,
e.prototype._moveChildren = function(e) {
var t, i = this;
if ((t = this._children).push.apply(t, e.splice(0, e.length)),
this._children.forEach((function(e) {
e._parent = i
}
)),
this._state === li.Fulfilled)
for (var n = 0, r = this._children; n < r.length; n++)
r[n]._resolve(this._result);
else if (this._state === li.Rejected)
for (var o = 0, a = this._children; o < a.length; o++)
a[o]._reject(this._reason)
}
,
e.prototype._resolve = function(e) {
try {
this._state = li.Fulfilled;
var t = null;
if (this._onFulfilled && (t = this._onFulfilled(e)),
null != t)
if (void 0 !== t._state) {
var i = t;
i._parent = this,
i._moveChildren(this._children),
e = i._result
} else
e = t;
this._result = e;
for (var n = 0, r = this._children; n < r.length; n++)
r[n]._resolve(e);
this._children.length = 0,
delete this._onFulfilled,
delete this._onRejected
} catch (e) {
this._reject(e, !0)
}
}
,
e.prototype._reject = function(e, t) {
if (void 0 === t && (t = !1),
this._state = li.Rejected,
this._reason = e,
this._onRejected && !t)
try {
this._onRejected(e),
this._rejectWasConsumed = !0
} catch (t) {
e = t
}
for (var i = 0, n = this._children; i < n.length; i++) {
var r = n[i];
this._rejectWasConsumed ? r._resolve(null) : r._reject(e)
}
this._children.length = 0,
delete this._onFulfilled,
delete this._onRejected
}
,
e.resolve = function(t) {
var i = new e;
return i._resolve(t),
i
}
,
e._RegisterForFulfillment = function(e, t, i) {
e.then((function(e) {
return t.results[i] = e,
t.count++,
t.count === t.target && t.rootPromise._resolve(t.results),
null
}
), (function(e) {
t.rootPromise._state !== li.Rejected && t.rootPromise._reject(e)
}
))
}
,
e.all = function(t) {
var i = new e
, n = new ui;
if (n.target = t.length,
n.rootPromise = i,
t.length)
for (var r = 0; r < t.length; r++)
e._RegisterForFulfillment(t[r], n, r);
else
i._resolve([]);
return i
}
,
e.race = function(t) {
var i = new e;
if (t.length)
for (var n = 0, r = t; n < r.length; n++)
r[n].then((function(e) {
return i && (i._resolve(e),
i = null),
null
}
), (function(e) {
i && (i._reject(e),
i = null)
}
));
return i
}
,
e
}()
, di = function() {
function e() {}
return e.Apply = function(e) {
void 0 === e && (e = !1),
(e || "undefined" == typeof Promise) && (window.Promise = hi)
}
,
e
}()
, pi = function() {
function e() {}
return e.Instantiate = function(e) {
if (this.RegisteredExternalClasses && this.RegisteredExternalClasses[e])
return this.RegisteredExternalClasses[e];
var t = b(e);
if (t)
return t;
K.Warn(e + " not found, you may have missed an import.");
for (var i = e.split("."), n = window || this, r = 0, o = i.length; r < o; r++)
n = n[i[r]];
return "function" != typeof n ? null : n
}
,
e.RegisteredExternalClasses = {},
e
}();
function fi() {
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 _i = {
RandomId: fi
}
, mi = function() {
function e() {}
return e.Slice = function(e, t, i) {
return e.slice ? e.slice(t, i) : Array.prototype.slice.call(e, t, i)
}
,
e.SliceToArray = function(e, t, i) {
return Array.isArray(e) ? e.slice(t, i) : Array.prototype.slice.call(e, t, i)
}
,
e
}()
, gi = function() {
function e() {}
return Object.defineProperty(e, "BaseUrl", {
get: function() {
return qt.BaseUrl
},
set: function(e) {
qt.BaseUrl = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "DefaultRetryStrategy", {
get: function() {
return qt.DefaultRetryStrategy
},
set: function(e) {
qt.DefaultRetryStrategy = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "CorsBehavior", {
get: function() {
return qt.CorsBehavior
},
set: function(e) {
qt.CorsBehavior = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "UseFallbackTexture", {
get: function() {
return E.UseFallbackTexture
},
set: function(e) {
E.UseFallbackTexture = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "RegisteredExternalClasses", {
get: function() {
return pi.RegisteredExternalClasses
},
set: function(e) {
pi.RegisteredExternalClasses = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "fallbackTexture", {
get: function() {
return E.FallbackTexture
},
set: function(e) {
E.FallbackTexture = e
},
enumerable: !1,
configurable: !0
}),
e.FetchToRef = function(e, t, i, n, r, o) {
var a = 4 * ((Math.abs(e) * i % i | 0) + (Math.abs(t) * n % n | 0) * i);
o.r = r[a] / 255,
o.g = r[a + 1] / 255,
o.b = r[a + 2] / 255,
o.a = r[a + 3] / 255
}
,
e.Mix = function(e, t, i) {
return e * (1 - i) + t * i
}
,
e.Instantiate = function(e) {
return pi.Instantiate(e)
}
,
e.Slice = function(e, t, i) {
return mi.Slice(e, t, i)
}
,
e.SliceToArray = function(e, t, i) {
return mi.SliceToArray(e, t, i)
}
,
e.SetImmediate = function(e) {
Xt.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.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 nt() && !window.PointerEvent && (t = "mouse"),
!e._badDesktopOS || e._badOS || document && "ontouchend"in document || (t = "mouse"),
t
}
,
e.SetCorsBehavior = function(e, t) {
Jt(e, t)
}
,
e.CleanUrl = function(e) {
return e.replace(/#/gm, "%23")
}
,
Object.defineProperty(e, "PreprocessUrl", {
get: function() {
return qt.PreprocessUrl
},
set: function(e) {
qt.PreprocessUrl = e
},
enumerable: !1,
configurable: !0
}),
e.LoadImage = function(e, t, i, n, r, o) {
return $t(e, t, i, n, r, o)
}
,
e.LoadFile = function(e, t, i, n, r, o) {
return ti(e, t, i, n, r, o)
}
,
e.LoadFileAsync = function(e, t) {
return void 0 === t && (t = !0),
new Promise((function(i, n) {
ti(e, (function(e) {
i(e)
}
), void 0, void 0, t, (function(e, t) {
n(t)
}
))
}
))
}
,
e.LoadScript = function(e, t, i, n) {
if (nt()) {
var r = document.getElementsByTagName("head")[0]
, o = document.createElement("script");
o.setAttribute("type", "text/javascript"),
o.setAttribute("src", e),
n && (o.id = n),
o.onload = function() {
t && t()
}
,
o.onerror = function(t) {
i && i("Unable to load script '".concat(e, "'"), t)
}
,
r.appendChild(o)
}
}
,
e.LoadScriptAsync = function(e) {
var t = this;
return new Promise((function(i, n) {
t.LoadScript(e, (function() {
i()
}
), (function(e, t) {
n(t)
}
))
}
))
}
,
e.ReadFileAsDataURL = function(e, t, i) {
var n = new FileReader
, r = {
onCompleteObservable: new h,
abort: function() {
return n.abort()
}
};
return n.onloadend = function() {
r.onCompleteObservable.notifyObservers(r)
}
,
n.onload = function(e) {
t(e.target.result)
}
,
n.onprogress = i,
n.readAsDataURL(e),
r
}
,
e.ReadFile = function(e, t, i, n, r) {
return ei(e, t, i, n, r)
}
,
e.FileAsURL = function(e) {
var t = new Blob([e]);
return (window.URL || window.webkitURL).createObjectURL(t)
}
,
e.Format = function(e, t) {
return void 0 === t && (t = 2),
e.toFixed(t)
}
,
e.DeepCopy = function(e, t, i, n) {
fe.DeepCopy(e, t, i, n)
}
,
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 n = t[i];
e.addEventListener(n.name, n.handler, !1);
try {
window.parent && window.parent.addEventListener(n.name, n.handler, !1)
} catch (e) {}
}
}
,
e.UnregisterTopRootEvents = function(e, t) {
for (var i = 0; i < t.length; i++) {
var n = t[i];
e.removeEventListener(n.name, n.handler);
try {
e.parent && e.parent.removeEventListener(n.name, n.handler)
} catch (e) {}
}
}
,
e.DumpFramebuffer = function(t, i, n, r, o, a) {
return void 0 === o && (o = "image/png"),
G(this, void 0, void 0, (function() {
var s, l;
return z(this, (function(c) {
switch (c.label) {
case 0:
return [4, n.readPixels(0, 0, t, i)];
case 1:
return s = c.sent(),
l = new Uint8Array(s.buffer),
e.DumpData(t, i, l, r, o, a, !0),
[2]
}
}
))
}
))
}
,
e.DumpData = function(t, i, n, r, o, a, s, l, c) {
void 0 === o && (o = "image/png"),
void 0 === s && (s = !1),
void 0 === l && (l = !1),
e._ScreenshotCanvas || (e._ScreenshotCanvas = document.createElement("canvas")),
e._ScreenshotCanvas.width = t,
e._ScreenshotCanvas.height = i;
var u = e._ScreenshotCanvas.getContext("2d");
if (u) {
if (n instanceof Float32Array) {
for (var h = new Uint8Array(n.length), d = n.length; d--; ) {
var p = n[d];
h[d] = p < 0 ? 0 : p > 1 ? 1 : Math.round(255 * p)
}
n = h
}
var f = u.createImageData(t, i);
f.data.set(n),
u.putImageData(f, 0, 0);
var _ = e._ScreenshotCanvas;
if (s) {
var m = document.createElement("canvas");
m.width = t,
m.height = i;
var g = m.getContext("2d");
if (!g)
return;
g.translate(0, i),
g.scale(1, -1),
g.drawImage(e._ScreenshotCanvas, 0, 0),
_ = m
}
l ? e.ToBlob(_, (function(e) {
var t = new FileReader;
t.onload = function(e) {
var t = e.target.result;
r && r(t)
}
,
t.readAsArrayBuffer(e)
}
), o, c) : e.EncodeScreenshotCanvasData(r, o, a, _, c)
}
}
,
e.DumpDataAsync = function(t, i, n, r, o, a, s, l) {
return void 0 === r && (r = "image/png"),
void 0 === a && (a = !1),
void 0 === s && (s = !1),
new Promise((function(c) {
e.DumpData(t, i, n, (function(e) {
return c(e)
}
), r, o, a, s, l)
}
))
}
,
e.ToBlob = function(e, t, i, n) {
void 0 === i && (i = "image/png"),
e.toBlob || (e.toBlob = function(e, t, i) {
var n = this;
setTimeout((function() {
for (var r = atob(n.toDataURL(t, i).split(",")[1]), o = r.length, a = new Uint8Array(o), s = 0; s < o; s++)
a[s] = r.charCodeAt(s);
e(new Blob([a]))
}
))
}
),
e.toBlob((function(e) {
t(e)
}
), i, n)
}
,
e.EncodeScreenshotCanvasData = function(t, i, n, r, o) {
void 0 === i && (i = "image/png"),
t ? t((null != r ? r : e._ScreenshotCanvas).toDataURL(i, o)) : this.ToBlob(null != r ? r : e._ScreenshotCanvas, (function(t) {
if ("download"in document.createElement("a")) {
if (!n) {
var i = new Date
, r = (i.getFullYear() + "-" + (i.getMonth() + 1)).slice(2) + "-" + i.getDate() + "_" + i.getHours() + "-" + ("0" + i.getMinutes()).slice(-2);
n = "screenshot_" + r + ".png"
}
e.Download(t, n)
} else if (t) {
var o = URL.createObjectURL(t)
, a = window.open("");
if (!a)
return;
var s = a.document.createElement("img");
s.onload = function() {
URL.revokeObjectURL(o)
}
,
s.src = o,
a.document.body.appendChild(s)
}
}
), i, o)
}
,
e.Download = function(e, t) {
if (navigator && navigator.msSaveBlob)
navigator.msSaveBlob(e, t);
else {
var i = window.URL.createObjectURL(e)
, n = document.createElement("a");
document.body.appendChild(n),
n.style.display = "none",
n.href = i,
n.download = t,
n.addEventListener("click", (function() {
n.parentElement && n.parentElement.removeChild(n)
}
)),
n.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, n, r) {
throw void 0 === r && (r = "image/png"),
be("ScreenshotTools")
}
,
e.CreateScreenshotAsync = function(e, t, i, n) {
throw void 0 === n && (n = "image/png"),
be("ScreenshotTools")
}
,
e.CreateScreenshotUsingRenderTarget = function(e, t, i, n, r, o, a, s) {
throw void 0 === r && (r = "image/png"),
void 0 === o && (o = 1),
void 0 === a && (a = !1),
be("ScreenshotTools")
}
,
e.CreateScreenshotUsingRenderTargetAsync = function(e, t, i, n, r, o, a) {
throw void 0 === n && (n = "image/png"),
void 0 === r && (r = 1),
void 0 === o && (o = !1),
be("ScreenshotTools")
}
,
e.RandomId = function() {
return fi()
}
,
e.IsBase64 = function(e) {
return ri(e)
}
,
e.DecodeBase64 = function(e) {
return oi(e)
}
,
Object.defineProperty(e, "errorsCount", {
get: function() {
return K.errorsCount
},
enumerable: !1,
configurable: !0
}),
e.Log = function(e) {
K.Log(e)
}
,
e.Warn = function(e) {
K.Warn(e)
}
,
e.Error = function(e) {
K.Error(e)
}
,
Object.defineProperty(e, "LogCache", {
get: function() {
return K.LogCache
},
enumerable: !1,
configurable: !0
}),
e.ClearLogCache = function() {
K.ClearLogCache()
}
,
Object.defineProperty(e, "LogLevels", {
set: function(e) {
K.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 (!nt())
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 ct.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, n = e; i < n.length; i++) {
var r = n[i];
if (t(r))
return r
}
return null
}
,
e.getFullClassName = function(e, t) {
void 0 === t && (t = !1);
var i = null
, n = null;
if (!t && e.getClassName)
i = e.getClassName();
else {
if (e instanceof Object) {
var r = t ? e : Object.getPrototypeOf(e);
i = r.constructor.__bjsclassName__,
n = r.constructor.__bjsmoduleName__
}
i || (i = typeof e)
}
return i ? (null != n ? n + "." : "") + i : null
}
,
e.DelayAsync = function(e) {
return new Promise((function(t) {
setTimeout((function() {
t()
}
), e)
}
))
}
,
e.IsSafari = function() {
return !!rt() && /^((?!chrome|android).)*safari/i.test(navigator.userAgent)
}
,
e.UseCustomRequestHeaders = !1,
e.CustomRequestHeaders = Ye.CustomRequestHeaders,
e._TmpFloatArray = new Float32Array(1),
e.GetDOMTextContent = at,
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 = K.NoneLogLevel,
e.MessageLogLevel = K.MessageLogLevel,
e.WarningLogLevel = K.WarningLogLevel,
e.ErrorLogLevel = K.ErrorLogLevel,
e.AllLogLevel = K.AllLogLevel,
e.IsWindowObjectExist = nt,
e.PerformanceNoneLogLevel = 0,
e.PerformanceUserMarkLogLevel = 1,
e.PerformanceConsoleLogLevel = 2,
e.StartPerformanceCounter = e._StartPerformanceCounterDisabled,
e.EndPerformanceCounter = e._EndPerformanceCounterDisabled,
e
}();
function vi(e, t) {
return function(i) {
i.__bjsclassName__ = e,
i.__bjsmoduleName__ = null != t ? t : null
}
}
var yi = function() {
function e(e, t, i, n) {
void 0 === n && (n = 0),
this.iterations = e,
this.index = n - 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, n, r) {
void 0 === r && (r = 0);
var o = new e(t,i,n,r);
return o.executeNext(),
o
}
,
e.SyncAsyncForLoop = function(t, i, n, r, o, a) {
return void 0 === a && (a = 0),
e.Run(Math.ceil(t / i), (function(e) {
o && o() ? e.breakLoop() : setTimeout((function() {
for (var r = 0; r < i; ++r) {
var a = e.index * i + r;
if (a >= t)
break;
if (n(a),
o && o()) {
e.breakLoop();
break
}
}
e.executeNext()
}
), a)
}
), r)
}
,
e
}();
E.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",
di.Apply();
var bi = 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,
this.data = [])
}
,
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
}()
, Ti = function(e) {
function t() {
var t = null !== e && e.apply(this, arguments) || this;
return t._duplicateId = 0,
t
}
return U(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
}(bi)
, Ei = 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
}()
, Si = function() {
function e(e) {
if (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._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 = [];
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 n in this._externalProperties)
this._keys.push(n)
}
,
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, n, r, o, a = null !== (n = null === (i = null === (t = this._externalProperties) || void 0 === t ? void 0 : t[e]) || void 0 === i ? void 0 : i.type) && void 0 !== n ? n : typeof this[e], s = null === (o = null === (r = this._externalProperties) || void 0 === r ? void 0 : r[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]
, n = this[i];
switch (typeof n) {
case "number":
case "string":
e += "#define " + i + " " + n + "\n";
break;
default:
n && (e += "#define " + i + "\n")
}
}
return e
}
,
e
}()
, Ai = function() {
function e() {
this._dirty = !0,
this._tempColor = new N(0,0,0,0),
this._globalCurve = new N(0,0,0,0),
this._highlightsCurve = new N(0,0,0,0),
this._midtonesCurve = new N(0,0,0,0),
this._shadowsCurve = new N(0,0,0,0),
this._positiveCurve = new N(0,0,0,0),
this._negativeCurve = new N(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, n, r) {
void 0 === i && (i = "vCameraColorCurvePositive"),
void 0 === n && (n = "vCameraColorCurveNeutral"),
void 0 === r && (r = "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(n, e._midtonesCurve.r, e._midtonesCurve.g, e._midtonesCurve.b, e._midtonesCurve.a),
t.setFloat4(r, 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, n, r, o) {
null != t && (t = e._Clamp(t, 0, 360),
i = e._Clamp(i, -100, 100),
n = e._Clamp(n, -100, 100),
r = e._Clamp(r, -100, 100),
i = e._ApplyColorGradingSliderNonlinear(i),
i *= .5,
r = e._ApplyColorGradingSliderNonlinear(r),
i < 0 && (i *= -1,
t = (t + 180) % 360),
e._FromHSBToRef(t, i, 50 + .25 * r, o),
o.scaleToRef(2, o),
o.a = 1 + .01 * n)
}
,
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, n, r) {
var o = e._Clamp(t, 0, 360)
, a = e._Clamp(i / 100, 0, 1)
, s = e._Clamp(n / 100, 0, 1);
if (0 === a)
r.r = s,
r.g = s,
r.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:
r.r = s,
r.g = d,
r.b = u;
break;
case 1:
r.r = h,
r.g = s,
r.b = u;
break;
case 2:
r.r = u,
r.g = s,
r.b = d;
break;
case 3:
r.r = u,
r.g = h,
r.b = s;
break;
case 4:
r.r = d,
r.g = u,
r.b = s;
break;
default:
r.r = s,
r.g = u,
r.b = h
}
}
r.a = 1
}
,
e._Clamp = function(e, t, i) {
return Math.min(Math.max(e, t), i)
}
,
e.prototype.clone = function() {
return Ge.Clone((function() {
return new e
}
), this)
}
,
e.prototype.serialize = function() {
return Ge.Serialize(this)
}
,
e.Parse = function(t) {
return Ge.Parse((function() {
return new e
}
), t, null, null)
}
,
k([Ce()], e.prototype, "_globalHue", void 0),
k([Ce()], e.prototype, "_globalDensity", void 0),
k([Ce()], e.prototype, "_globalSaturation", void 0),
k([Ce()], e.prototype, "_globalExposure", void 0),
k([Ce()], e.prototype, "_highlightsHue", void 0),
k([Ce()], e.prototype, "_highlightsDensity", void 0),
k([Ce()], e.prototype, "_highlightsSaturation", void 0),
k([Ce()], e.prototype, "_highlightsExposure", void 0),
k([Ce()], e.prototype, "_midtonesHue", void 0),
k([Ce()], e.prototype, "_midtonesDensity", void 0),
k([Ce()], e.prototype, "_midtonesSaturation", void 0),
k([Ce()], e.prototype, "_midtonesExposure", void 0),
e
}();
Ge._ColorCurvesParser = Ai.Parse;
var xi = 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.IMAGEPROCESSINGPOSTPROCESS = !1,
t.EXPOSURE = !1,
t.SKIPFINALCOLORCLAMP = !1,
t.rebuild(),
t
}
return U(t, e),
t
}(Si)
, Ri = function() {
function e() {
this.colorCurves = new Ai,
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.vignetteCentreX = 0,
this.vignetteCentreY = 0,
this.vignetteWeight = 1.5,
this.vignetteColor = new N(0,0,0,0),
this.vignetteCameraFov = .5,
this._vignetteBlendMode = e.VIGNETTEMODE_MULTIPLY,
this._vignetteEnabled = !1,
this._skipFinalColorClamp = !1,
this._applyByPostProcess = !1,
this._isEnabled = !0,
this.onUpdateParameters = new h
}
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, "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, "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 && (e.push("vInverseScreenSize"),
e.push("vignetteSettings1"),
e.push("vignetteSettings2")),
t.COLORCURVES && Ai.PrepareUniforms(e)
}
,
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.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.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess,
t.SKIPFINALCOLORCLAMP = this.skipFinalColorClamp,
t.IMAGEPROCESSING = t.VIGNETTE || t.TONEMAPPING || t.CONTRAST || t.EXPOSURE || t.COLORCURVES || t.COLORGRADING
}
,
e.prototype.isReady = function() {
return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady()
}
,
e.prototype.bind = function(e, t) {
if (this._colorCurvesEnabled && this.colorCurves && Ai.Bind(this.colorCurves, e),
this._vignetteEnabled) {
var i = 1 / e.getEngine().getRenderWidth()
, n = 1 / e.getEngine().getRenderHeight();
e.setFloat2("vInverseScreenSize", i, n);
var r = null != t ? t : n / i
, o = Math.tan(.5 * this.vignetteCameraFov)
, a = o * r
, s = Math.sqrt(a * o);
a = gi.Mix(a, s, this.vignetteStretch),
o = gi.Mix(o, s, this.vignetteStretch),
e.setFloat4("vignetteSettings1", a, o, -a * this.vignetteCentreX, -o * this.vignetteCentreY);
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 Ge.Clone((function() {
return new e
}
), this)
}
,
e.prototype.serialize = function() {
return Ge.Serialize(this)
}
,
e.Parse = function(t) {
return Ge.Parse((function() {
return new e
}
), t, null, null)
}
,
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,
k([Le()], e.prototype, "colorCurves", void 0),
k([Ce()], e.prototype, "_colorCurvesEnabled", void 0),
k([Pe("colorGradingTexture")], e.prototype, "_colorGradingTexture", void 0),
k([Ce()], e.prototype, "_colorGradingEnabled", void 0),
k([Ce()], e.prototype, "_colorGradingWithGreenDepth", void 0),
k([Ce()], e.prototype, "_colorGradingBGR", void 0),
k([Ce()], e.prototype, "_exposure", void 0),
k([Ce()], e.prototype, "_toneMappingEnabled", void 0),
k([Ce()], e.prototype, "_toneMappingType", void 0),
k([Ce()], e.prototype, "_contrast", void 0),
k([Ce()], e.prototype, "vignetteStretch", void 0),
k([Ce()], e.prototype, "vignetteCentreX", void 0),
k([Ce()], e.prototype, "vignetteCentreY", void 0),
k([Ce()], e.prototype, "vignetteWeight", void 0),
k([Fe()], e.prototype, "vignetteColor", void 0),
k([Ce()], e.prototype, "vignetteCameraFov", void 0),
k([Ce()], e.prototype, "_vignetteBlendMode", void 0),
k([Ce()], e.prototype, "_vignetteEnabled", void 0),
k([Ce()], e.prototype, "_skipFinalColorClamp", void 0),
k([Ce()], e.prototype, "_applyByPostProcess", void 0),
k([Ce()], e.prototype, "_isEnabled", void 0),
e
}();
Ge._ImageProcessingConfigurationParser = Ri.Parse,
Ht.prototype.createUniformBuffer = function(e) {
var t = this._gl.createBuffer();
if (!t)
throw new Error("Unable to create uniform buffer");
var i = new Ut(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
}
,
Ht.prototype.createDynamicUniformBuffer = function(e) {
var t = this._gl.createBuffer();
if (!t)
throw new Error("Unable to create dynamic uniform buffer");
var i = new Ut(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
}
,
Ht.prototype.updateUniformBuffer = function(e, t, i, n) {
this.bindUniformBuffer(e),
void 0 === i && (i = 0),
void 0 === n ? 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 + n)) : this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, new Float32Array(t).subarray(i, i + n)),
this.bindUniformBuffer(null)
}
,
Ht.prototype.bindUniformBuffer = function(e) {
this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, e ? e.underlyingResource : null)
}
,
Ht.prototype.bindUniformBufferBase = function(e, t, i) {
this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, t, e ? e.underlyingResource : null)
}
,
Ht.prototype.bindUniformBlock = function(e, t, i) {
var n = e.program
, r = this._gl.getUniformBlockIndex(n, t);
4294967295 !== r && this._gl.uniformBlockBinding(n, r, i)
}
;
var Ci, Pi, Mi, Ii, Oi, Di, Ni, Li, Fi = function() {
function e(e, t, i, n, r) {
void 0 === r && (r = !1),
this._valueCache = {},
this._engine = e,
this._noUBO = !e.supportsUniformBuffers || r,
this._dynamic = i,
this._name = null != n ? n : "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.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._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.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)
}
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 n = this._uniformLocationPointer - i, r = 0; r < n; r++)
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 n;
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,
n = [];
for (var r = 0; r < t; r++)
n.push(0)
} else {
if (t instanceof Array)
t = (n = t).length;
else
for (t = t,
n = [],
r = 0; r < t; r++)
n.push(0);
this._fillAlignment(t)
}
for (this._uniformSizes[e] = t,
this._uniformLocations[e] = this._uniformLocationPointer,
this._uniformLocationPointer += t,
r = 0; r < t; r++)
this._data.push(n[r]);
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 n = [t, i];
this.addUniform(e, n)
}
,
e.prototype.addFloat3 = function(e, t, i, n) {
var r = [t, i, n];
this.addUniform(e, r)
}
,
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 n = [t.r, t.g, t.b, i];
this.addUniform(e, n)
}
,
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
}),
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 n = this._uniformLocations[e];
if (void 0 === n) {
if (this._buffer)
return void K.Error("Cannot add an uniform after UBO has been created.");
this.addUniform(e, i),
n = this._uniformLocations[e]
}
if (this._buffer || this.create(),
this._dynamic)
for (o = 0; o < i; o++)
this._bufferData[n + o] = t[o];
else {
for (var r = !1, o = 0; o < i; o++)
(16 === i && !this._engine._features.uniformBufferHardCheckMatrix || this._bufferData[n + o] !== gi.FloatRound(t[o])) && (r = !0,
this._createBufferOnWrite && this._createNewBuffer(),
this._bufferData[n + o] = t[o]);
this._needSync = this._needSync || r
}
}
,
e.prototype.updateUniformArray = function(e, t, i) {
this._checkNewFrame();
var n = this._uniformLocations[e];
if (void 0 !== n) {
this._buffer || this.create();
var r = this._uniformArraySizes[e];
if (this._dynamic)
for (l = 0; l < i; l++)
this._bufferData[n + l] = t[l];
else {
for (var o = !1, a = 0, s = 0, l = 0; l < i; l++)
if (this._bufferData[n + 4 * s + a] !== gi.FloatRound(t[l]) && (o = !0,
this._createBufferOnWrite && this._createNewBuffer(),
this._bufferData[n + 4 * s + a] = t[l]),
++a === r.strideSize) {
for (; a < 4; a++)
this._bufferData[n + 4 * s + a] = 0;
a = 0,
s++
}
this._needSync = this._needSync || o
}
} else
K.Error("Cannot add an uniform Array dynamically. Please, add it using addUniform.")
}
,
e.prototype._cacheMatrix = function(e, t) {
this._checkNewFrame();
var i = this._valueCache[e]
, n = t.updateFlag;
return (void 0 === i || i !== n) && (this._valueCache[e] = n,
!0)
}
,
e.prototype._updateMatrix3x3ForUniform = function(t, i) {
for (var n = 0; n < 3; n++)
e._TempBuffer[4 * n] = i[3 * n],
e._TempBuffer[4 * n + 1] = i[3 * n + 1],
e._TempBuffer[4 * n + 2] = i[3 * n + 2],
e._TempBuffer[4 * n + 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 n = 0; n < 2; n++)
e._TempBuffer[4 * n] = i[2 * n],
e._TempBuffer[4 * n + 1] = i[2 * n + 1],
e._TempBuffer[4 * n + 2] = 0,
e._TempBuffer[4 * n + 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, n) {
void 0 === n && (n = ""),
this._currentEffect.setFloat2(e + n, t, i)
}
,
e.prototype._updateFloat2ForUniform = function(t, i, n) {
e._TempBuffer[0] = i,
e._TempBuffer[1] = n,
this.updateUniform(t, e._TempBuffer, 2)
}
,
e.prototype._updateFloat3ForEffect = function(e, t, i, n, r) {
void 0 === r && (r = ""),
this._currentEffect.setFloat3(e + r, t, i, n)
}
,
e.prototype._updateFloat3ForUniform = function(t, i, n, r) {
e._TempBuffer[0] = i,
e._TempBuffer[1] = n,
e._TempBuffer[2] = r,
this.updateUniform(t, e._TempBuffer, 3)
}
,
e.prototype._updateFloat4ForEffect = function(e, t, i, n, r, o) {
void 0 === o && (o = ""),
this._currentEffect.setFloat4(e + o, t, i, n, r)
}
,
e.prototype._updateFloat4ForUniform = function(t, i, n, r, o) {
e._TempBuffer[0] = i,
e._TempBuffer[1] = n,
e._TempBuffer[2] = r,
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._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, n) {
void 0 === n && (n = ""),
this._currentEffect.setColor4(e + n, 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, n) {
e._TempBuffer[0] = i.r,
e._TempBuffer[1] = i.g,
e._TempBuffer[2] = i.b,
e._TempBuffer[3] = n,
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, n) {
void 0 === n && (n = ""),
this._currentEffect.setInt2(e + n, t, i)
}
,
e.prototype._updateInt2ForUniform = function(t, i, n) {
e._TempBufferInt32View[0] = i,
e._TempBufferInt32View[1] = n,
this.updateUniform(t, e._TempBuffer, 2)
}
,
e.prototype._updateInt3ForEffect = function(e, t, i, n, r) {
void 0 === r && (r = ""),
this._currentEffect.setInt3(e + r, t, i, n)
}
,
e.prototype._updateInt3ForUniform = function(t, i, n, r) {
e._TempBufferInt32View[0] = i,
e._TempBufferInt32View[1] = n,
e._TempBufferInt32View[2] = r,
this.updateUniform(t, e._TempBuffer, 3)
}
,
e.prototype._updateInt4ForEffect = function(e, t, i, n, r, o) {
void 0 === o && (o = ""),
this._currentEffect.setInt4(e + o, t, i, n, r)
}
,
e.prototype._updateInt4ForUniform = function(t, i, n, r, o) {
e._TempBufferInt32View[0] = i,
e._TempBufferInt32View[1] = n,
e._TempBufferInt32View[2] = r,
e._TempBufferInt32View[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 n = this._buffers[i][0];
this._engine._releaseBuffer(n)
}
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 Uint32Array(e._TempBuffer.buffer),
e
}(), wi = function() {
function e(e, t, i, n, r, o, a, s) {
void 0 === n && (n = 0),
void 0 === r && (r = !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 Bt ? (this._data = null,
this._buffer = t) : (this._data = t,
this._buffer = null),
this.byteStride = a ? n : n * Float32Array.BYTES_PER_ELEMENT,
r || this.create()
}
return e.prototype.createVertexBuffer = function(e, t, i, n, r, o, a) {
void 0 === o && (o = !1);
var s = o ? t : t * Float32Array.BYTES_PER_ELEMENT
, l = n ? o ? n : n * Float32Array.BYTES_PER_ELEMENT : this.byteStride;
return new Bi(this._engine,this,e,this._updatable,!0,l,void 0 === r ? this._instanced : r,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, n) {
void 0 === n && (n = !1),
this._buffer && this._updatable && (this._engine.updateDynamicVertexBuffer(this._buffer, e, n ? 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
}(), Bi = function() {
function e(t, i, n, r, 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,r,a,o,s,d),
this._ownsBuffer = !0),
this.uniqueId = e._Counter++,
this._kind = n,
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(n)),
this.byteStride = a || this._buffer.byteStride || this._size * m,
this.byteOffset = l || 0) : (this._size = c || a || e.DeduceStride(n),
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) {
this._instanceDivisor = e,
this._instanced = 0 != e,
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 n = this.getData();
if (!n)
return null;
var r = this.getSize() * e.GetTypeByteLength(this.type)
, o = t * this.getSize();
if (this.type !== e.FLOAT || this.byteStride !== r) {
var a = new Float32Array(o);
return this.forEach(o, (function(e, t) {
return a[t] = e
}
)),
a
}
if (!(n instanceof Array || n instanceof Float32Array) || 0 !== this.byteOffset || n.length !== o) {
if (n instanceof Array) {
var s = this.byteOffset / 4;
return mi.Slice(n, s, s + o)
}
if (n instanceof ArrayBuffer)
return new Float32Array(n,this.byteOffset,o);
if (s = n.byteOffset + this.byteOffset,
i) {
var l = new Float32Array(o)
, c = new Float32Array(n.buffer,s,o);
return l.set(c),
l
}
var u = s % 4;
return u && (s = Math.max(0, s - u)),
new Float32Array(n.buffer,s,o)
}
return i ? mi.Slice(n) : n
}
,
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, n, r, o, a, s, l) {
if (t instanceof Array)
for (var c = i / 4, u = n / 4, h = 0; h < a; h += r) {
for (var d = 0; d < r; 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 += r) {
var _ = i;
for (d = 0; d < r; d++)
l(e._GetFloatValue(p, o, _, s), h + d),
_ += f;
i += n
}
}
}
,
e._GetFloatValue = function(t, i, n, r) {
switch (i) {
case e.BYTE:
var o = t.getInt8(n);
return r && (o = Math.max(o / 127, -1)),
o;
case e.UNSIGNED_BYTE:
return o = t.getUint8(n),
r && (o /= 255),
o;
case e.SHORT:
return o = t.getInt16(n, !0),
r && (o = Math.max(o / 32767, -1)),
o;
case e.UNSIGNED_SHORT:
return o = t.getUint16(n, !0),
r && (o /= 65535),
o;
case e.INT:
return t.getInt32(n, !0);
case e.UNSIGNED_INT:
return t.getUint32(n, !0);
case e.FLOAT:
return t.getFloat32(n, !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
}(), Ui = function() {
function e() {
this._pickingUnavailable = !1,
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 || !this.pickedMesh.isVerticesDataPresent(Bi.NormalKind))
return null;
var i, n = this.pickedMesh.getIndices();
if (!n)
return null;
if (t) {
var r = this.pickedMesh.getVerticesData(Bi.NormalKind)
, o = x.FromArray(r, 3 * n[3 * this.faceId])
, a = x.FromArray(r, 3 * n[3 * this.faceId + 1])
, s = x.FromArray(r, 3 * n[3 * this.faceId + 2]);
o = o.scale(this.bu),
a = a.scale(this.bv),
s = s.scale(1 - this.bu - this.bv),
i = new x(o.x + a.x + s.x,o.y + a.y + s.y,o.z + a.z + s.z)
} else {
var l = this.pickedMesh.getVerticesData(Bi.PositionKind)
, c = x.FromArray(l, 3 * n[3 * this.faceId])
, u = x.FromArray(l, 3 * n[3 * this.faceId + 1])
, h = x.FromArray(l, 3 * n[3 * this.faceId + 2])
, d = c.subtract(u)
, p = h.subtract(u);
i = x.Cross(d, p)
}
if (e) {
var f = this.pickedMesh.getWorldMatrix();
this.pickedMesh.nonUniformScaling && (I.Matrix[0].copyFrom(f),
(f = I.Matrix[0]).setTranslationFromFloats(0, 0, 0),
f.invert(),
f.transposeToRef(I.Matrix[1]),
f = I.Matrix[1]),
i = x.TransformNormal(i, f)
}
return i.normalize(),
i
}
,
e.prototype.getTextureCoordinates = function() {
if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(Bi.UVKind))
return null;
var e = this.pickedMesh.getIndices();
if (!e)
return null;
var t = this.pickedMesh.getVerticesData(Bi.UVKind);
if (!t)
return null;
var i = A.FromArray(t, 2 * e[3 * this.faceId])
, n = A.FromArray(t, 2 * e[3 * this.faceId + 1])
, r = A.FromArray(t, 2 * e[3 * this.faceId + 2]);
return i = i.scale(this.bu),
n = n.scale(this.bv),
r = r.scale(1 - this.bu - this.bv),
new A(i.x + n.x + r.x,i.y + n.y + r.y)
}
,
e
}(), Vi = function() {
function e(e) {
this._vertexBuffers = {},
this._scene = e
}
return e.prototype._prepareBuffers = function() {
if (!this._vertexBuffers[Bi.PositionKind]) {
var e = [];
e.push(1, 1),
e.push(-1, 1),
e.push(-1, -1),
e.push(1, -1),
this._vertexBuffers[Bi.PositionKind] = new Bi(this._scene.getEngine(),e,Bi.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[Bi.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, n, r, o) {
var s;
void 0 === t && (t = null),
void 0 === i && (i = !1),
void 0 === n && (n = 0),
void 0 === r && (r = 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, n, void 0, void 0, i, r) : 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, n, r) {
var o;
void 0 === r && (r = !1);
var s = this._scene.activeCamera;
if (s && (n = n || s._postProcesses.filter((function(e) {
return null != e
}
)),
0 !== n.length && this._scene.postProcessesEnabled)) {
for (var l = this._scene.getEngine(), c = 0, u = n.length; c < u; c++) {
var h = n[c];
if (c < u - 1 ? h._outputTexture = n[c + 1].activate(s, null == t ? void 0 : t.texture) : (t ? (l.bindFramebuffer(t, i, void 0, void 0, r),
h._outputTexture = t) : (l.restoreDefaultFramebuffer(),
h._outputTexture = null),
null === (o = l._debugInsertMarker) || void 0 === o || o.call(l, "post process ".concat(n[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[Bi.PositionKind];
e && (e.dispose(),
this._vertexBuffers[Bi.PositionKind] = null),
this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer),
this._indexBuffer = null)
}
,
e
}(), ki = function() {
function e(e, t, i, n, r) {
void 0 === i && (i = null),
void 0 === n && (n = null),
void 0 === r && (r = null),
this.index = e,
this._opaqueSubMeshes = new bi(256),
this._transparentSubMeshes = new bi(256),
this._alphaTestSubMeshes = new bi(256),
this._depthOnlySubMeshes = new bi(256),
this._particleSystems = new bi(256),
this._spriteManagers = new bi(256),
this._empty = !0,
this._edgesRenderers = new Ti(16),
this._scene = t,
this.opaqueSortCompareFn = i,
this.alphaTestSortCompareFn = n,
this.transparentSortCompareFn = r
}
return Object.defineProperty(e.prototype, "opaqueSortCompareFn", {
set: function(t) {
this._opaqueSortCompareFn = t,
this._renderOpaque = t ? this._renderOpaqueSorted : e._RenderUnsorted
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "alphaTestSortCompareFn", {
set: function(t) {
this._alphaTestSortCompareFn = t,
this._renderAlphaTest = t ? this._renderAlphaTestSorted : e._RenderUnsorted
},
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, n) {
if (e)
e(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes);
else {
var r = this._scene.getEngine();
0 !== this._depthOnlySubMeshes.length && (r.setColorWrite(!1),
this._renderAlphaTest(this._depthOnlySubMeshes),
r.setColorWrite(!0)),
0 !== this._opaqueSubMeshes.length && this._renderOpaque(this._opaqueSubMeshes),
0 !== this._alphaTestSubMeshes.length && this._renderAlphaTest(this._alphaTestSubMeshes);
var o = r.getStencilBuffer();
if (r.setStencilBuffer(!1),
t && this._renderSprites(),
i && this._renderParticles(n),
this.onBeforeTransparentRendering && this.onBeforeTransparentRendering(),
0 !== this._transparentSubMeshes.length || this._scene.useOrderIndependentTransparency) {
if (r.setStencilBuffer(o),
this._scene.useOrderIndependentTransparency) {
var s = this._scene.depthPeelingRenderer.render(this._transparentSubMeshes);
s.length && this._renderTransparent(s)
} else
this._renderTransparent(this._transparentSubMeshes);
r.setAlphaMode(a.ALPHA_DISABLE)
}
if (r.setStencilBuffer(!1),
this._edgesRenderers.length) {
for (var l = 0; l < this._edgesRenderers.length; l++)
this._edgesRenderers.data[l].render();
r.setAlphaMode(a.ALPHA_DISABLE)
}
r.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, n, r) {
for (var o, s = 0, l = n ? n.globalPosition : e._ZeroVector; s < t.length; s++)
(o = t.data[s])._alphaIndex = o.getMesh().alphaIndex,
o._distanceToCamera = x.Distance(o.getBoundingInfo().boundingSphere.centerWorld, l);
var c = t.data.slice(0, t.length);
for (i && c.sort(i),
s = 0; s < c.length; s++) {
if (o = c[s],
r) {
var u = o.getMaterial();
if (u && u.needDepthPrePass) {
var h = u.getScene().getEngine();
h.setColorWrite(!1),
h.setAlphaMode(a.ALPHA_DISABLE),
o.render(!1),
h.setColorWrite(!0)
}
}
o.render(r)
}
}
,
e._RenderUnsorted = function(e) {
for (var t = 0; t < e.length; t++)
e.data[t].render(!1)
}
,
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.prototype.prepare = function() {
this._opaqueSubMeshes.reset(),
this._transparentSubMeshes.reset(),
this._alphaTestSubMeshes.reset(),
this._depthOnlySubMeshes.reset(),
this._particleSystems.reset(),
this._spriteManagers.reset(),
this._edgesRenderers.reset(),
this._empty = !0
}
,
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 n = this._particleSystems.data[i];
if (0 !== (t && t.layerMask & n.layerMask)) {
var r = n.emitter;
r.position && e && -1 === e.indexOf(r) || this._scene._activeParticles.addCount(n.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 = x.Zero(),
e
}(), Gi = function() {}, zi = function() {
function e(t) {
this._useSceneAutoClearSetup = !1,
this._renderingGroups = new Array,
this._autoClearDepthStencil = {},
this._customOpaqueSortCompareFn = {},
this._customAlphaTestSortCompareFn = {},
this._customTransparentSortCompareFn = {},
this._renderingGroupInfo = new Gi,
this._scene = t;
for (var i = e.MIN_RENDERINGGROUPS; i < e.MAX_RENDERINGGROUPS; i++)
this._autoClearDepthStencil[i] = {
autoClear: !0,
depth: !0,
stencil: !0
}
}
return 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, n, r) {
var o = this._renderingGroupInfo;
if (o.scene = this._scene,
o.camera = this._scene.activeCamera,
this._scene.spriteManagers && r)
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, r, n, 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() {
for (var t = e.MIN_RENDERINGGROUPS; t < e.MAX_RENDERINGGROUPS; t++) {
var i = this._renderingGroups[t];
i && i.prepare()
}
}
,
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 ki(e,this._scene,this._customOpaqueSortCompareFn[e],this._customAlphaTestSortCompareFn[e],this._customTransparentSortCompareFn[e]))
}
,
e.prototype.dispatchSprites = function(e) {
var t = e.renderingGroupId || 0;
this._prepareRenderingGroup(t),
this._renderingGroups[t].dispatchSprites(e)
}
,
e.prototype.dispatchParticles = function(e) {
var t = e.renderingGroupId || 0;
this._prepareRenderingGroup(t),
this._renderingGroups[t].dispatchParticles(e)
}
,
e.prototype.dispatch = function(e, t, i) {
void 0 === t && (t = e.getMesh());
var n = t.renderingGroupId || 0;
this._prepareRenderingGroup(n),
this._renderingGroups[n].dispatch(e, t, i)
}
,
e.prototype.setRenderingOrder = function(e, t, i, n) {
if (void 0 === t && (t = null),
void 0 === i && (i = null),
void 0 === n && (n = null),
this._customOpaqueSortCompareFn[e] = t,
this._customAlphaTestSortCompareFn[e] = i,
this._customTransparentSortCompareFn[e] = n,
this._renderingGroups[e]) {
var r = this._renderingGroups[e];
r.opaqueSortCompareFn = this._customOpaqueSortCompareFn[e],
r.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[e],
r.transparentSortCompareFn = this._customTransparentSortCompareFn[e]
}
}
,
e.prototype.setRenderingAutoClearDepthStencil = function(e, t, i, n) {
void 0 === i && (i = !0),
void 0 === n && (n = !0),
this._autoClearDepthStencil[e] = {
autoClear: t,
depth: i,
stencil: n
}
}
,
e.prototype.getAutoClearDepthStencilSetup = function(e) {
return this._autoClearDepthStencil[e]
}
,
e.MAX_RENDERINGGROUPS = 4,
e.MIN_RENDERINGGROUPS = 0,
e.AUTOCLEAR = !0,
e
}(), Wi = 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.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_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_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_BEFORECLEARSTAGE_PREPASS = 0,
e.STEP_BEFORERENDERTARGETCLEARSTAGE_PREPASS = 0,
e.STEP_POINTERMOVE_SPRITE = 0,
e.STEP_POINTERDOWN_SPRITE = 0,
e.STEP_POINTERUP_SPRITE = 0,
e
}(), Hi = function(e) {
function t(t) {
return e.apply(this, t) || this
}
return U(t, e),
t.Create = function() {
return Object.create(t.prototype)
}
,
t.prototype.registerStep = function(e, t, i) {
var n = 0;
for (Number.MAX_VALUE; n < this.length && !(e < this[n].index); n++)
;
this.splice(n, 0, {
index: e,
component: t,
action: i.bind(t)
})
}
,
t.prototype.clear = function() {
this.length = 0
}
,
t
}(Array), Xi = 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
}(), ji = function(e, t) {
this.type = e,
this.event = t
}, Yi = function(e) {
function t(t, i, n, r) {
var o = e.call(this, t, i) || this;
return o.ray = null,
o.skipOnPointerObservable = !1,
o.localPosition = new A(n,r),
o
}
return U(t, e),
t
}(ji), Ki = function(e) {
function t(t, i, n) {
var r = e.call(this, t, i) || this;
return r.pickInfo = n,
r
}
return U(t, e),
t
}(ji), Qi = function() {
function e() {}
return e.KEYDOWN = 1,
e.KEYUP = 2,
e
}(), qi = function(e, t) {
this.type = e,
this.event = t
}, Zi = function(e) {
function t(t, i) {
var n = e.call(this, t, i) || this;
return n.type = t,
n.event = i,
n.skipOnKeyboardObservable = !1,
n
}
return U(t, e),
Object.defineProperty(t.prototype, "skipOnPointerObservable", {
get: function() {
return this.skipOnKeyboardObservable
},
set: function(e) {
this.skipOnKeyboardObservable = e
},
enumerable: !1,
configurable: !0
}),
t
}(qi);
!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"
}(Ci || (Ci = {})),
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"
}(Pi || (Pi = {})),
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"
}(Mi || (Mi = {})),
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"
}(Ii || (Ii = {})),
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"
}(Oi || (Oi = {})),
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"
}(Di || (Di = {})),
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"
}(Ni || (Ni = {})),
function(e) {
e[e.PointerMove = 0] = "PointerMove",
e[e.PointerDown = 1] = "PointerDown",
e[e.PointerUp = 2] = "PointerUp"
}(Li || (Li = {}));
var Ji, $i = function() {
function e() {}
return e.DOM_DELTA_PIXEL = 0,
e.DOM_DELTA_LINE = 1,
e.DOM_DELTA_PAGE = 2,
e
}(), en = function() {
function e() {}
return e.CreateDeviceEvent = function(e, t, i, n, r, o) {
switch (e) {
case Ci.Keyboard:
return this._CreateKeyboardEvent(i, n, r, o);
case Ci.Mouse:
if (i === Pi.MouseWheelX || i === Pi.MouseWheelY || i === Pi.MouseWheelZ)
return this._CreateWheelEvent(e, t, i, n, r, o);
case Ci.Touch:
return this._CreatePointerEvent(e, t, i, n, r, o);
default:
throw "Unable to generate event for device ".concat(Ci[e])
}
}
,
e._CreatePointerEvent = function(e, t, i, n, r, o) {
var a = this._CreateMouseEvent(e, t, i, n, r, o);
return e === Ci.Mouse ? (a.deviceType = Ci.Mouse,
a.pointerId = 1,
a.pointerType = "mouse") : (a.deviceType = Ci.Touch,
a.pointerId = t,
a.pointerType = "touch"),
i === Pi.Move ? a.type = "pointermove" : i >= Pi.LeftClick && i <= Pi.RightClick && (a.type = 1 === n ? "pointerdown" : "pointerup",
a.button = i - 2),
a
}
,
e._CreateWheelEvent = function(e, t, i, n, r, o) {
var a = this._CreateMouseEvent(e, t, i, n, r, o);
return a.type = "wheel",
a.deltaMode = $i.DOM_DELTA_PIXEL,
a.deltaX = i === Pi.MouseWheelX ? n : r.pollInput(e, t, Pi.MouseWheelX),
a.deltaY = i === Pi.MouseWheelY ? n : r.pollInput(e, t, Pi.MouseWheelY),
a.deltaZ = i === Pi.MouseWheelZ ? n : r.pollInput(e, t, Pi.MouseWheelZ),
a
}
,
e._CreateMouseEvent = function(e, t, i, n, r, o) {
var a = this._CreateEvent(o)
, s = r.pollInput(e, t, Pi.Horizontal)
, l = r.pollInput(e, t, Pi.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 = r.pollInput(e, t, Mi.DeltaHorizontal),
a.movementY = r.pollInput(e, t, Mi.DeltaVertical),
a.offsetX = 0,
a.offsetY = 0),
this._CheckNonCharacterKeys(a, r),
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, n) {
var r = this._CreateEvent(n);
return this._CheckNonCharacterKeys(r, i),
r.deviceType = Ci.Keyboard,
r.deviceSlot = 0,
r.inputIndex = e,
r.type = 1 === t ? "keydown" : "keyup",
r.key = String.fromCharCode(e),
r.keyCode = e,
r
}
,
e._CheckNonCharacterKeys = function(e, t) {
var i = t.isDeviceAvailable(Ci.Keyboard)
, n = i && 1 === t.pollInput(Ci.Keyboard, 0, a.INPUT_ALT_KEY)
, r = i && 1 === t.pollInput(Ci.Keyboard, 0, a.INPUT_CTRL_KEY)
, o = i && (1 === t.pollInput(Ci.Keyboard, 0, a.INPUT_META_KEY1) || 1 === t.pollInput(Ci.Keyboard, 0, a.INPUT_META_KEY2) || 1 === t.pollInput(Ci.Keyboard, 0, a.INPUT_META_KEY3))
, s = i && 1 === t.pollInput(Ci.Keyboard, 0, a.INPUT_SHIFT_KEY);
e.altKey = n,
e.ctrlKey = r,
e.metaKey = o,
e.shiftKey = s
}
,
e._CreateEvent = function(e) {
var t = {
preventDefault: function() {}
};
return t.target = e,
t
}
,
e
}(), tn = function() {
function e(e, t, i) {
var n = this;
this._nativeInput = _native.DeviceInputSystem ? new _native.DeviceInputSystem(e,t,(function(e, t, r, o) {
var a = r === Mi.Horizontal || r === Mi.Vertical || r === Mi.DeltaHorizontal || r === Mi.DeltaVertical ? Pi.Move : r
, s = en.CreateDeviceEvent(e, t, a, o, n);
i(e, t, s)
}
)) : this._createDummyNativeInput()
}
return e.prototype.pollInput = function(e, t, i) {
return this._nativeInput.pollInput(e, t, i)
}
,
e.prototype.isDeviceAvailable = function(e) {
return e === Ci.Mouse || e === Ci.Touch
}
,
e.prototype.dispose = function() {
this._nativeInput.dispose()
}
,
e.prototype._createDummyNativeInput = function() {
return {
pollInput: function() {
return 0
},
isDeviceAvailable: function() {
return !1
},
dispose: function() {}
}
}
,
e
}(), nn = Object.keys(Pi).length / 2, rn = function() {
function e(e, t, i, n) {
var r = this;
this._inputs = [],
this._keyboardActive = !1,
this._pointerActive = !1,
this._usingSafari = gi.IsSafari(),
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 = lt.IsNavigatorAvailable() && navigator.userAgent && -1 !== navigator.userAgent.indexOf("Firefox"),
this._maxTouchPoints = 0,
this._pointerInputClearObserver = null,
this._gamepadConnectedEvent = function(e) {}
,
this._gamepadDisconnectedEvent = function(e) {}
,
this._eventPrefix = gi.GetPointerPrefix(e),
this._engine = e,
this._onDeviceConnected = t,
this._onDeviceDisconnected = i,
this._onInputChanged = n,
this._enableEvents(),
this._engine._onEngineViewChanged || (this._engine._onEngineViewChanged = function() {
r._enableEvents()
}
)
}
return e.prototype.pollInput = function(e, t, i) {
var n = this._inputs[e][t];
if (!n)
throw "Unable to find device ".concat(Ci[e]);
e >= Ci.DualShock && e <= Ci.DualSense && navigator.getGamepads && this._updateDevice(e, t, i);
var r = n[i];
if (void 0 === r)
throw "Unable to find input ".concat(i, " for device ").concat(Ci[e], " in slot ").concat(t);
return i === Pi.Move && gi.Warn("Unable to provide information for PointerInput.Move. Try using PointerInput.Horizontal or PointerInput.Vertical for move data."),
r
}
,
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 n = i[t];
if (n)
for (var r in n) {
var o = n[+r];
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)
}
matchMedia("(pointer:fine)").matches && this._addPointerDevice(Ci.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, n) {
this._pointerActive || (this._pointerActive = !0),
this._registerDevice(e, t, nn);
var r = this._inputs[e][t];
r[0] = i,
r[1] = n
}
,
e.prototype._registerDevice = function(e, t, i) {
if (void 0 === t)
throw "Unable to register device ".concat(Ci[e], " to undefined slot.");
if (this._inputs[e] || (this._inputs[e] = {}),
!this._inputs[e][t]) {
for (var n = new Array(i), r = 0; r < i; r++)
n[r] = 0;
this._inputs[e][t] = n,
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(Ci.Keyboard, 0, 255));
var i = e._inputs[Ci.Keyboard][0];
if (i) {
i[t.keyCode] = 1;
var n = t;
n.inputIndex = t.keyCode,
e._onInputChanged(Ci.Keyboard, 0, n)
}
}
,
this._keyboardUpEvent = function(t) {
e._keyboardActive || (e._keyboardActive = !0,
e._registerDevice(Ci.Keyboard, 0, 255));
var i = e._inputs[Ci.Keyboard][0];
if (i) {
i[t.keyCode] = 0;
var n = t;
n.inputIndex = t.keyCode,
e._onInputChanged(Ci.Keyboard, 0, n)
}
}
,
this._keyboardBlurEvent = function() {
if (e._keyboardActive)
for (var t = e._inputs[Ci.Keyboard][0], i = 0; i < t.length; i++)
if (0 !== t[i]) {
t[i] = 0;
var n = en.CreateDeviceEvent(Ci.Keyboard, 0, i, 0, e, e._elementToAttachTo);
e._onInputChanged(Ci.Keyboard, 0, n)
}
}
,
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 = lt.IsNavigatorAvailable() && 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)
, n = i === Ci.Mouse ? 0 : e._activeTouchIds.indexOf(t.pointerId);
e._inputs[i] || (e._inputs[i] = {}),
e._inputs[i][n] || e._addPointerDevice(i, n, t.clientX, t.clientY);
var r = e._inputs[i][n];
if (r) {
r[Pi.Horizontal] = t.clientX,
r[Pi.Vertical] = t.clientY;
var o = t;
o.inputIndex = Pi.Move,
e._onInputChanged(i, n, o),
e._usingSafari || -1 === t.button || (o.inputIndex = t.button + 2,
r[t.button + 2] = r[t.button + 2] ? 0 : 1,
e._onInputChanged(i, n, o))
}
}
,
this._pointerDownEvent = function(t) {
var i = e._getPointerType(t)
, n = i === Ci.Mouse ? 0 : t.pointerId;
if (i === Ci.Touch) {
var r = e._activeTouchIds.indexOf(-1);
if (!(r >= 0))
return void gi.Warn("Max number of touches exceeded. Ignoring touches in excess of ".concat(e._maxTouchPoints));
n = r,
e._activeTouchIds[r] = t.pointerId
}
e._inputs[i] || (e._inputs[i] = {}),
e._inputs[i][n] ? i === Ci.Touch && e._onDeviceConnected(i, n) : e._addPointerDevice(i, n, t.clientX, t.clientY);
var o = e._inputs[i][n];
if (o) {
var a = o[Pi.Horizontal]
, s = o[Pi.Vertical];
if (i === Ci.Mouse) {
if (-1 === e._mouseId && (void 0 === t.pointerId ? e._mouseId = e._isUsingFirefox ? 0 : 1 : e._mouseId = t.pointerId),
!document.pointerLockElement && e._elementToAttachTo.hasPointerCapture)
try {
e._elementToAttachTo.setPointerCapture(e._mouseId)
} catch (e) {}
} else if (t.pointerId && !document.pointerLockElement && e._elementToAttachTo.hasPointerCapture)
try {
e._elementToAttachTo.setPointerCapture(t.pointerId)
} catch (e) {}
o[Pi.Horizontal] = t.clientX,
o[Pi.Vertical] = t.clientY,
o[t.button + 2] = 1;
var l = t;
l.inputIndex = t.button + 2,
e._onInputChanged(i, n, l),
a === t.clientX && s === t.clientY || (l.inputIndex = Pi.Move,
e._onInputChanged(i, n, l))
}
}
,
this._pointerUpEvent = function(t) {
var i, n, r, o, a, s = e._getPointerType(t), l = s === Ci.Mouse ? 0 : e._activeTouchIds.indexOf(t.pointerId);
if (s === Ci.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[Pi.Horizontal]
, h = c[Pi.Vertical];
c[Pi.Horizontal] = t.clientX,
c[Pi.Vertical] = t.clientY,
c[t.button + 2] = 0;
var d = t;
u === t.clientX && h === t.clientY || (d.inputIndex = Pi.Move,
e._onInputChanged(s, l, d)),
d.inputIndex = t.button + 2,
s === Ci.Mouse && e._mouseId >= 0 && (null === (r = (n = e._elementToAttachTo).hasPointerCapture) || void 0 === r ? void 0 : r.call(n, 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 === Ci.Touch && e._onDeviceDisconnected(s, l)
}
}
,
this._pointerCancelEvent = function(t) {
var i, n, r, o;
if ("mouse" === t.pointerType) {
var a = e._inputs[Ci.Mouse][0];
e._mouseId >= 0 && (null === (n = (i = e._elementToAttachTo).hasPointerCapture) || void 0 === n ? void 0 : n.call(i, e._mouseId)) && e._elementToAttachTo.releasePointerCapture(e._mouseId);
for (var s = Pi.LeftClick; s <= Pi.BrowserForward; s++)
if (1 === a[s]) {
a[s] = 0;
var l = en.CreateDeviceEvent(Ci.Mouse, 0, s, 0, e, e._elementToAttachTo);
e._onInputChanged(Ci.Mouse, 0, l)
}
} else {
var c = e._activeTouchIds.indexOf(t.pointerId);
(null === (o = (r = e._elementToAttachTo).hasPointerCapture) || void 0 === o ? void 0 : o.call(r, t.pointerId)) && e._elementToAttachTo.releasePointerCapture(t.pointerId),
e._inputs[Ci.Touch][c][Pi.LeftClick] = 0,
l = en.CreateDeviceEvent(Ci.Touch, c, Pi.LeftClick, 0, e, e._elementToAttachTo),
e._onInputChanged(Ci.Touch, c, l),
e._activeTouchIds[c] = -1,
e._onDeviceDisconnected(Ci.Touch, c)
}
}
,
this._wheelEventName = "onwheel"in document.createElement("div") ? "wheel" : void 0 !== document.onmousewheel ? "mousewheel" : "DOMMouseScroll";
var i = !1
, n = function() {};
try {
var r = {
passive: {
get: function() {
i = !0
}
}
};
this._elementToAttachTo.addEventListener("test", n, r),
this._elementToAttachTo.removeEventListener("test", n, r)
} catch (e) {}
this._pointerBlurEvent = function() {
var t, i, n, r, o;
if (e.isDeviceAvailable(Ci.Mouse)) {
var a = e._inputs[Ci.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 = Pi.LeftClick; s <= Pi.BrowserForward; s++)
if (1 === a[s]) {
a[s] = 0;
var l = en.CreateDeviceEvent(Ci.Mouse, 0, s, 0, e, e._elementToAttachTo);
e._onInputChanged(Ci.Mouse, 0, l)
}
}
if (e.isDeviceAvailable(Ci.Touch)) {
a = e._inputs[Ci.Touch];
for (var c = 0; c < e._activeTouchIds.length; c++) {
var u = e._activeTouchIds[c];
(null === (r = (n = e._elementToAttachTo).hasPointerCapture) || void 0 === r ? void 0 : r.call(n, u)) && e._elementToAttachTo.releasePointerCapture(u),
-1 !== u && 1 === (null === (o = a[c]) || void 0 === o ? void 0 : o[Pi.LeftClick]) && (a[c][Pi.LeftClick] = 0,
l = en.CreateDeviceEvent(Ci.Touch, c, Pi.LeftClick, 0, e, e._elementToAttachTo),
e._onInputChanged(Ci.Touch, c, l),
e._activeTouchIds[c] = -1,
e._onDeviceDisconnected(Ci.Touch, c))
}
}
}
,
this._pointerWheelEvent = function(t) {
var i = Ci.Mouse;
e._inputs[i] || (e._inputs[i] = []),
e._inputs[i][0] || (e._pointerActive = !0,
e._registerDevice(i, 0, nn));
var n = e._inputs[i][0];
if (n) {
n[Pi.MouseWheelX] = t.deltaX || 0,
n[Pi.MouseWheelY] = t.deltaY || t.wheelDelta || 0,
n[Pi.MouseWheelZ] = t.deltaZ || 0;
var r = t;
0 !== n[Pi.MouseWheelX] && (r.inputIndex = Pi.MouseWheelX,
e._onInputChanged(i, 0, r)),
0 !== n[Pi.MouseWheelY] && (r.inputIndex = Pi.MouseWheelY,
e._onInputChanged(i, 0, r)),
0 !== n[Pi.MouseWheelZ] && (r.inputIndex = Pi.MouseWheelZ,
e._onInputChanged(i, 0, r))
}
}
,
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(Ci.Mouse)) {
var t = e._inputs[Ci.Mouse][0];
t[Pi.MouseWheelX] = 0,
t[Pi.MouseWheelY] = 0,
t[Pi.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)
, n = t.gamepad.index;
e._unregisterDevice(i, n),
delete e._gamepads[n]
}
}
,
window.addEventListener("gamepadconnected", this._gamepadConnectedEvent),
window.addEventListener("gamepaddisconnected", this._gamepadDisconnectedEvent)
}
,
e.prototype._updateDevice = function(e, t, i) {
var n = navigator.getGamepads()[t];
if (n && e === this._gamepads[t]) {
var r = this._inputs[e][t];
i >= n.buttons.length ? r[i] = n.axes[i - n.buttons.length].valueOf() : r[i] = n.buttons[i].value
}
}
,
e.prototype._getGamepadDeviceType = function(e) {
return -1 !== e.indexOf("054c") ? -1 !== e.indexOf("0ce6") ? Ci.DualSense : Ci.DualShock : -1 !== e.indexOf("Xbox One") || -1 !== e.search("Xbox 360") || -1 !== e.search("xinput") ? Ci.Xbox : -1 !== e.indexOf("057e") ? Ci.Switch : Ci.Generic
}
,
e.prototype._getPointerType = function(e) {
var t = Ci.Mouse;
return ("touch" === e.pointerType || "pen" === e.pointerType || e.touches) && (t = Ci.Touch),
t
}
,
e
}(), on = function() {
function e(e, t, i) {
void 0 === i && (i = 0),
this.deviceType = t,
this.deviceSlot = i,
this.onInputChangedObservable = new h,
this._deviceInputSystem = e
}
return e.prototype.getInput = function(e) {
return this._deviceInputSystem.pollInput(this.deviceType, this.deviceSlot, e)
}
,
e
}(), an = 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 n = t._devices[i];
for (var r in n) {
var o = +r;
e._addDevice(new on(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(Ci).length / 2;
this._devices = new Array(i);
var n = function(e, i) {
t._devices[e] || (t._devices[e] = new Array),
t._devices[e][i] || (t._devices[e][i] = i);
for (var n = 0, r = t._registeredManagers; n < r.length; n++) {
var o = r[n]
, a = new on(t._deviceInputSystem,e,i);
o._addDevice(a)
}
}
, r = function(e, i) {
var n;
(null === (n = t._devices[e]) || void 0 === n ? void 0 : n[i]) && delete t._devices[e][i];
for (var r = 0, o = t._registeredManagers; r < o.length; r++)
o[r]._removeDevice(e, i)
}
, o = function(e, i, n) {
if (n)
for (var r = 0, o = t._registeredManagers; r < o.length; r++)
o[r]._onInputChanged(e, i, n)
};
"undefined" != typeof _native ? this._deviceInputSystem = new tn(n,r,o) : this._deviceInputSystem = new rn(e,n,r,o)
}
return e.prototype.dispose = function() {
this._deviceInputSystem.dispose()
}
,
e
}(), sn = function() {
function e(e) {
var t = this
, i = Object.keys(Ci).length / 2;
this._devices = new Array(i),
this._firstDevice = new Array(i),
this._engine = e,
this._engine._deviceSourceManager || (this._engine._deviceSourceManager = new an(e)),
this._engine._deviceSourceManager._refCount++,
this.onDeviceConnectedObservable = new h((function(e) {
t.getDevices().forEach((function(i) {
t.onDeviceConnectedObservable.notifyObserver(e, i)
}
))
}
)),
this.onDeviceDisconnectedObservable = new h,
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].filter((function(e) {
return !!e
}
))
}
,
e.prototype.getDevices = function() {
for (var e = new Array, t = 0, i = this._devices; t < i.length; t++) {
var n = i[t];
e.push.apply(e, n)
}
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, n, r = null === (i = this._devices[e]) || void 0 === i ? void 0 : i[t];
this.onDeviceDisconnectedObservable.notifyObservers(r),
(null === (n = this._devices[e]) || void 0 === n ? void 0 : n[t]) && delete this._devices[e][t],
this._updateFirstDevices(e)
}
,
e.prototype._onInputChanged = function(e, t, i) {
var n, r;
null === (r = null === (n = this._devices[e]) || void 0 === n ? void 0 : n[t]) || void 0 === r || r.onInputChangedObservable.notifyObservers(i)
}
,
e.prototype._updateFirstDevices = function(e) {
switch (e) {
case Ci.Keyboard:
case Ci.Mouse:
this._firstDevice[e] = 0;
break;
case Ci.Touch:
case Ci.DualSense:
case Ci.DualShock:
case Ci.Xbox:
case Ci.Switch:
case Ci.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
}(), ln = 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
}(), cn = function() {
function e(e) {
this._alreadyAttached = !1,
this._meshPickProceed = !1,
this._currentPickResult = null,
this._previousPickResult = null,
this._totalPointersPressed = 0,
this._doubleClickOccured = !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._deviceSourceManager = null,
this._scene = e || E.LastCreatedScene,
this._scene
}
return Object.defineProperty(e.prototype, "meshUnderPointer", {
get: function() {
return 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
, n = i.getEngine()
, r = n.getInputElement();
r && (r.tabIndex = n.canvasTabIndex,
i.doNotHandleCursors || (r.style.cursor = i.defaultCursor));
var o = !!(e && e.hit && e.pickedMesh);
o ? (i.setPointerOverMesh(e.pickedMesh, t.pointerId, e),
this._pointerOverMesh && this._pointerOverMesh.actionManager && this._pointerOverMesh.actionManager.hasPointerTriggers && !i.doNotHandleCursors && r && (this._pointerOverMesh.actionManager.hoverCursor ? r.style.cursor = this._pointerOverMesh.actionManager.hoverCursor : r.style.cursor = i.hoverCursor)) : i.setPointerOverMesh(null, t.pointerId, e);
for (var a = 0, s = i._pointerMoveStage; a < s.length; a++)
e = s[a].action(this._unTranslatedPointerX, this._unTranslatedPointerY, e, o, r);
if (e) {
var l = "wheel" === t.type || "mousewheel" === t.type || "DOMMouseScroll" === t.type ? Xi.POINTERWHEEL : Xi.POINTERMOVE;
if (i.onPointerMove && i.onPointerMove(t, e, l),
i.onPointerObservable.hasObservers()) {
var c = new Ki(l,t,e);
this._setRayOnPointerInfo(c),
i.onPointerObservable.notifyObservers(c, l)
}
}
}
,
e.prototype._setRayOnPointerInfo = function(e) {
var t = this._scene;
e.pickInfo && !e.pickInfo._pickingUnavailable && (e.pickInfo.ray || (e.pickInfo.ray = t.createPickingRay(e.event.offsetX, e.event.offsetY, P.Identity(), t.activeCamera)))
}
,
e.prototype._checkPrePointerObservable = function(e, t, i) {
var n = this._scene
, r = new Yi(i,t,this._unTranslatedPointerX,this._unTranslatedPointerY);
return e && (r.ray = e.ray,
e.originMesh && (r.nearInteractionPickingInfo = e)),
n.onPrePointerObservable.notifyObservers(r, i),
!!r.skipOnPointerObservable
}
,
e.prototype.simulatePointerMove = function(e, t) {
var i = new PointerEvent("pointermove",t);
i.inputIndex = Pi.Move,
this._checkPrePointerObservable(e, i, Xi.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, Xi.POINTERDOWN) || this._processPointerDown(e, i)
}
,
e.prototype._processPointerDown = function(t, i) {
var n = this
, r = this._scene;
if (t && t.hit && t.pickedMesh) {
this._pickedDownMesh = t.pickedMesh;
var o = t.pickedMesh._getActionManagerForTrigger();
if (o) {
if (o.hasPickTriggers)
switch (o.processTrigger(a.ACTION_OnPickDownTrigger, w.CreateNew(t.pickedMesh, i)),
i.button) {
case 0:
o.processTrigger(a.ACTION_OnLeftPickTrigger, w.CreateNew(t.pickedMesh, i));
break;
case 1:
o.processTrigger(a.ACTION_OnCenterPickTrigger, w.CreateNew(t.pickedMesh, i));
break;
case 2:
o.processTrigger(a.ACTION_OnRightPickTrigger, w.CreateNew(t.pickedMesh, i))
}
o.hasSpecificTrigger(a.ACTION_OnLongPressTrigger) && window.setTimeout((function() {
var t = r.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, r.cameraToUseForPointers);
t && t.hit && t.pickedMesh && o && 0 !== n._totalPointersPressed && Date.now() - n._startingPointerTime > e.LongPressDelay && !n._isPointerSwiping() && (n._startingPointerTime = 0,
o.processTrigger(a.ACTION_OnLongPressTrigger, w.CreateNew(t.pickedMesh, i)))
}
), e.LongPressDelay)
}
} else
for (var s = 0, l = r._pointerDownStage; s < l.length; s++)
t = l[s].action(this._unTranslatedPointerX, this._unTranslatedPointerY, t, i);
if (t) {
var c = Xi.POINTERDOWN;
if (r.onPointerDown && r.onPointerDown(i, t, c),
r.onPointerObservable.hasObservers()) {
var u = new Ki(c,i,t);
this._setRayOnPointerInfo(u),
r.onPointerObservable.notifyObservers(u, c)
}
}
}
,
e.prototype._isPointerSwiping = function() {
return Math.abs(this._startingPointerPosition.x - this._pointerX) > e.DragMovementThreshold || Math.abs(this._startingPointerPosition.y - this._pointerY) > e.DragMovementThreshold
}
,
e.prototype.simulatePointerUp = function(e, t, i) {
var n = new PointerEvent("pointerup",t);
n.inputIndex = Pi.Move;
var r = new ln;
i ? r.doubleClick = !0 : r.singleClick = !0,
this._checkPrePointerObservable(e, n, Xi.POINTERUP) || this._processPointerUp(e, n, r)
}
,
e.prototype._processPointerUp = function(e, t, i) {
var n = this._scene;
if (e && e && e.pickedMesh) {
if (this._pickedUpMesh = e.pickedMesh,
this._pickedDownMesh === this._pickedUpMesh && (n.onPointerPick && n.onPointerPick(t, e),
i.singleClick && !i.ignore && n.onPointerObservable.hasObservers())) {
var r = Xi.POINTERPICK
, o = new Ki(r,t,e);
this._setRayOnPointerInfo(o),
n.onPointerObservable.notifyObservers(o, r)
}
var s = e.pickedMesh._getActionManagerForTrigger();
if (s && !i.ignore) {
s.processTrigger(a.ACTION_OnPickUpTrigger, w.CreateNew(e.pickedMesh, t, e)),
!i.hasSwiped && i.singleClick && s.processTrigger(a.ACTION_OnPickTrigger, w.CreateNew(e.pickedMesh, t, e));
var l = e.pickedMesh._getActionManagerForTrigger(a.ACTION_OnDoublePickTrigger);
i.doubleClick && l && l.processTrigger(a.ACTION_OnDoublePickTrigger, w.CreateNew(e.pickedMesh, t, e))
}
} else if (!i.ignore)
for (var c = 0, u = n._pointerUpStage; c < u.length; c++)
e = u[c].action(this._unTranslatedPointerX, this._unTranslatedPointerY, e, t);
if (this._pickedDownMesh && this._pickedDownMesh !== this._pickedUpMesh) {
var h = this._pickedDownMesh._getActionManagerForTrigger(a.ACTION_OnPickOutTrigger);
h && h.processTrigger(a.ACTION_OnPickOutTrigger, w.CreateNew(this._pickedDownMesh, t))
}
var d = 0;
n.onPointerObservable.hasObservers() && (i.ignore || i.hasSwiped || (i.singleClick && n.onPointerObservable.hasSpecificMask(Xi.POINTERTAP) ? d = Xi.POINTERTAP : i.doubleClick && n.onPointerObservable.hasSpecificMask(Xi.POINTERDOUBLETAP) && (d = Xi.POINTERDOUBLETAP),
!d) || (o = new Ki(d,t,e),
this._setRayOnPointerInfo(o),
n.onPointerObservable.notifyObservers(o, d)),
i.ignore || (d = Xi.POINTERUP,
o = new Ki(d,t,e),
this._setRayOnPointerInfo(o),
n.onPointerObservable.notifyObservers(o, d))),
n.onPointerUp && !i.ignore && n.onPointerUp(t, e, d)
}
,
e.prototype.isPointerCaptured = function(e) {
return void 0 === e && (e = 0),
this._pointerCaptures[e]
}
,
e.prototype.attachControl = function(t, i, n, r) {
var o = this;
void 0 === t && (t = !0),
void 0 === i && (i = !0),
void 0 === n && (n = !0),
void 0 === r && (r = null);
var l = this._scene
, c = l.getEngine();
r || (r = c.getInputElement()),
this._alreadyAttached && this.detachControl(),
r && (this._alreadyAttachedTo = r),
this._deviceSourceManager = new sn(c),
this._initActionManager = function(e) {
if (!o._meshPickProceed) {
var t = l.pick(o._unTranslatedPointerX, o._unTranslatedPointerY, l.pointerDownPredicate, !1, 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, n) {
(Date.now() - o._previousStartingPointerTime > e.DoubleClickDelay && !o._doubleClickOccured || t !== o._previousButtonPressed) && (o._doubleClickOccured = !1,
i.singleClick = !0,
i.ignore = !1,
n(i, o._currentPickResult))
}
,
this._initClickEvent = function(t, i, n, r) {
var l = new ln;
o._currentPickResult = null;
var c = null
, u = t.hasSpecificMask(Xi.POINTERPICK) || i.hasSpecificMask(Xi.POINTERPICK) || t.hasSpecificMask(Xi.POINTERTAP) || i.hasSpecificMask(Xi.POINTERTAP) || t.hasSpecificMask(Xi.POINTERDOUBLETAP) || i.hasSpecificMask(Xi.POINTERDOUBLETAP);
!u && s && (c = o._initActionManager(c, l)) && (u = c.hasPickTriggers);
var h = !1;
if (u) {
var d = n.button;
if (l.hasSwiped = o._isPointerSwiping(),
!l.hasSwiped) {
var p = !e.ExclusiveDoubleClickMode;
p || (p = !t.hasSpecificMask(Xi.POINTERDOUBLETAP) && !i.hasSpecificMask(Xi.POINTERDOUBLETAP)) && !s.HasSpecificTrigger(a.ACTION_OnDoublePickTrigger) && (c = o._initActionManager(c, l)) && (p = !c.hasSpecificTrigger(a.ACTION_OnDoublePickTrigger)),
p ? (Date.now() - o._previousStartingPointerTime > e.DoubleClickDelay || d !== o._previousButtonPressed) && (l.singleClick = !0,
r(l, o._currentPickResult),
h = !0) : (o._previousDelayedSimpleClickTimeout = o._delayedSimpleClickTimeout,
o._delayedSimpleClickTimeout = window.setTimeout(o._delayedSimpleClick.bind(o, d, l, r), e.DoubleClickDelay));
var f = t.hasSpecificMask(Xi.POINTERDOUBLETAP) || i.hasSpecificMask(Xi.POINTERDOUBLETAP);
!f && s.HasSpecificTrigger(a.ACTION_OnDoublePickTrigger) && (c = o._initActionManager(c, l)) && (f = c.hasSpecificTrigger(a.ACTION_OnDoublePickTrigger)),
f && (d === o._previousButtonPressed && Date.now() - o._previousStartingPointerTime < e.DoubleClickDelay && !o._doubleClickOccured ? (l.hasSwiped || o._isPointerSwiping() ? (o._doubleClickOccured = !1,
o._previousStartingPointerTime = o._startingPointerTime,
o._previousStartingPointerPosition.x = o._startingPointerPosition.x,
o._previousStartingPointerPosition.y = o._startingPointerPosition.y,
o._previousButtonPressed = d,
e.ExclusiveDoubleClickMode ? (o._previousDelayedSimpleClickTimeout && clearTimeout(o._previousDelayedSimpleClickTimeout),
o._previousDelayedSimpleClickTimeout = o._delayedSimpleClickTimeout,
r(l, o._previousPickResult)) : r(l, o._currentPickResult)) : (o._previousStartingPointerTime = 0,
o._doubleClickOccured = !0,
l.doubleClick = !0,
l.ignore = !1,
e.ExclusiveDoubleClickMode && o._previousDelayedSimpleClickTimeout && clearTimeout(o._previousDelayedSimpleClickTimeout),
o._previousDelayedSimpleClickTimeout = o._delayedSimpleClickTimeout,
r(l, o._currentPickResult)),
h = !0) : (o._doubleClickOccured = !1,
o._previousStartingPointerTime = o._startingPointerTime,
o._previousStartingPointerPosition.x = o._startingPointerPosition.x,
o._previousStartingPointerPosition.y = o._startingPointerPosition.y,
o._previousButtonPressed = d))
}
}
h || r(l, o._currentPickResult)
}
,
this._onPointerMove = function(e) {
if (void 0 === e.pointerId && (e.pointerId = 0),
o._updatePointerPosition(e),
!o._checkPrePointerObservable(null, e, "wheel" === e.type || "mousewheel" === e.type || "DOMMouseScroll" === e.type ? Xi.POINTERWHEEL : Xi.POINTERMOVE) && (l.cameraToUseForPointers || l.activeCamera))
if (l.skipPointerMovePicking)
o._processPointerMove(new Ui, e);
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 t = l.pick(o._unTranslatedPointerX, o._unTranslatedPointerY, l.pointerMovePredicate, !1, l.cameraToUseForPointers, l.pointerMoveTrianglePredicate);
o._processPointerMove(t, e)
}
}
,
this._onPointerDown = function(e) {
if (o._totalPointersPressed++,
o._pickedDownMesh = null,
o._meshPickProceed = !1,
void 0 === e.pointerId && (e.pointerId = 0),
o._updatePointerPosition(e),
l.preventDefaultOnPointerDown && r && (e.preventDefault(),
r.focus()),
o._startingPointerPosition.x = o._pointerX,
o._startingPointerPosition.y = o._pointerY,
o._startingPointerTime = Date.now(),
!o._checkPrePointerObservable(null, e, Xi.POINTERDOWN) && (l.cameraToUseForPointers || l.activeCamera)) {
o._pointerCaptures[e.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;
var t = l.pick(o._unTranslatedPointerX, o._unTranslatedPointerY, l.pointerDownPredicate, !1, l.cameraToUseForPointers);
o._processPointerDown(t, e)
}
}
,
this._onPointerUp = function(e) {
0 !== o._totalPointersPressed && (o._totalPointersPressed--,
o._pickedUpMesh = null,
o._meshPickProceed = !1,
void 0 === e.pointerId && (e.pointerId = 0),
o._updatePointerPosition(e),
l.preventDefaultOnPointerUp && r && (e.preventDefault(),
r.focus()),
o._initClickEvent(l.onPrePointerObservable, l.onPointerObservable, e, (function(t, i) {
if (l.onPrePointerObservable.hasObservers() && !t.ignore) {
if (!t.hasSwiped) {
if (t.singleClick && l.onPrePointerObservable.hasSpecificMask(Xi.POINTERTAP) && o._checkPrePointerObservable(null, e, Xi.POINTERTAP))
return;
if (t.doubleClick && l.onPrePointerObservable.hasSpecificMask(Xi.POINTERDOUBLETAP) && o._checkPrePointerObservable(null, e, Xi.POINTERDOUBLETAP))
return
}
if (o._checkPrePointerObservable(null, e, Xi.POINTERUP))
return
}
!o._pointerCaptures[e.pointerId] && e.buttons > 0 || (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 || l.onPointerObservable.hasObservers()) && o._initActionManager(null, t),
i || (i = o._currentPickResult),
o._processPointerUp(i, e, t),
o._previousPickResult = o._currentPickResult))
}
)))
}
,
this._onKeyDown = function(e) {
var t = Qi.KEYDOWN;
if (l.onPreKeyboardObservable.hasObservers()) {
var i = new Zi(t,e);
if (l.onPreKeyboardObservable.notifyObservers(i, t),
i.skipOnKeyboardObservable)
return
}
l.onKeyboardObservable.hasObservers() && (i = new qi(t,e),
l.onKeyboardObservable.notifyObservers(i, t)),
l.actionManager && l.actionManager.processTrigger(a.ACTION_OnKeyDownTrigger, w.CreateNewFromScene(l, e))
}
,
this._onKeyUp = function(e) {
var t = Qi.KEYUP;
if (l.onPreKeyboardObservable.hasObservers()) {
var i = new Zi(t,e);
if (l.onPreKeyboardObservable.notifyObservers(i, t),
i.skipOnKeyboardObservable)
return
}
l.onKeyboardObservable.hasObservers() && (i = new qi(t,e),
l.onKeyboardObservable.notifyObservers(i, t)),
l.actionManager && l.actionManager.processTrigger(a.ACTION_OnKeyUpTrigger, w.CreateNewFromScene(l, e))
}
,
this._deviceSourceManager.onDeviceConnectedObservable.add((function(e) {
e.deviceType === Ci.Mouse ? e.onInputChangedObservable.add((function(r) {
if (r.inputIndex === Pi.LeftClick || r.inputIndex === Pi.MiddleClick || r.inputIndex === Pi.RightClick) {
var a = r;
i && 1 === e.getInput(a.inputIndex) ? o._onPointerDown(a) : t && 0 === e.getInput(a.inputIndex) && o._onPointerUp(a)
} else
n && (r.inputIndex === Pi.Move ? o._onPointerMove(r) : r.inputIndex !== Pi.MouseWheelX && r.inputIndex !== Pi.MouseWheelY && r.inputIndex !== Pi.MouseWheelZ || o._onPointerMove(r))
}
)) : e.deviceType === Ci.Touch ? e.onInputChangedObservable.add((function(r) {
var a = r;
r.inputIndex === Pi.LeftClick && (i && 1 === e.getInput(a.inputIndex) ? o._onPointerDown(r) : t && 0 === e.getInput(a.inputIndex) && o._onPointerUp(r)),
n && r.inputIndex === Pi.Move && o._onPointerMove(r)
}
)) : e.deviceType === Ci.Keyboard && e.onInputChangedObservable.add((function(e) {
var t = e;
"keydown" === t.type ? o._onKeyDown(t) : "keyup" === t.type && o._onKeyUp(t)
}
))
}
)),
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) {
if (void 0 === t && (t = 0),
this._meshUnderPointerId[t] !== e) {
var n, r = this._meshUnderPointerId[t];
r && (n = r._getActionManagerForTrigger(a.ACTION_OnPointerOutTrigger)) && n.processTrigger(a.ACTION_OnPointerOutTrigger, w.CreateNew(r, void 0, {
pointerId: t
})),
e ? (this._meshUnderPointerId[t] = e,
this._pointerOverMesh = e,
(n = e._getActionManagerForTrigger(a.ACTION_OnPointerOverTrigger)) && n.processTrigger(a.ACTION_OnPointerOverTrigger, w.CreateNew(e, void 0, {
pointerId: t,
pickResult: i
}))) : (delete this._meshUnderPointerId[t],
this._pointerOverMesh = null)
}
}
,
e.prototype.getPointerOverMesh = function() {
return this._pointerOverMesh
}
,
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
}(), un = 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 = ct.Now)
}
,
e.prototype.endMonitoring = function(t) {
if (void 0 === t && (t = !0),
e.Enabled) {
t && this.fetchNewFrame();
var i = ct.Now;
this._current = i - this._startMonitoringTime,
t && 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 = ct.Now;
e - this._lastSecTime > 1e3 && (this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount,
this._lastSecTime = e,
this._lastSecAccumulated = 0,
this._lastSecValueCount = 0)
}
,
e.Enabled = !0,
e
}(), hn = function() {
function e(e, t, i, n) {
this.normal = new x(e,t,i),
this.d = n
}
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 n = i.m
, r = this.normal.x
, o = this.normal.y
, a = this.normal.z
, s = this.d;
return new e(r * n[0] + o * n[1] + a * n[2] + s * n[3],r * n[4] + o * n[5] + a * n[6] + s * n[7],r * n[8] + o * n[9] + a * n[10] + s * n[11],r * n[12] + o * n[13] + a * n[14] + s * n[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 n, r = 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 - r * c, d = r * l - o * s, p = Math.sqrt(u * u + h * h + d * d);
return n = 0 !== p ? 1 / p : 0,
this.normal.x = u * n,
this.normal.y = h * n,
this.normal.z = d * n,
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 x.Dot(this.normal, e) <= t
}
,
e.prototype.signedDistanceTo = function(e) {
return x.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, n) {
var r = new e(0,0,0,0);
return r.copyFromPoints(t, i, n),
r
}
,
e.FromPositionAndNormal = function(t, i) {
var n = new e(0,0,0,0);
return i.normalize(),
n.normal = i,
n.d = -(i.x * t.x + i.y * t.y + i.z * t.z),
n
}
,
e.SignedDistanceToPlaneFromPositionAndNormal = function(e, t, i) {
var n = -(t.x * e.x + t.y * e.y + t.z * e.z);
return x.Dot(i, t) + n
}
,
e._TmpMatrix = P.Identity(),
e
}(), dn = function() {
function e() {}
return e.GetPlanes = function(t) {
for (var i = [], n = 0; n < 6; n++)
i.push(new hn(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
}(), pn = 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
}(), fn = 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
}(), _n = function() {
function e(t, i) {
e.IsAvailable && (this._observer = new window.ComputePressureObserver(t,i))
}
return Object.defineProperty(e, "IsAvailable", {
get: function() {
return nt() && "ComputePressureObserver"in window
},
enumerable: !1,
configurable: !0
}),
e.prototype.observe = function() {
var e, t;
(null === (e = this._observer) || void 0 === e ? void 0 : e.observe) && (null === (t = this._observer) || void 0 === t || t.observe())
}
,
e.prototype.unobserve = function() {
var e, t;
(null === (e = this._observer) || void 0 === e ? void 0 : e.unobserve) && (null === (t = this._observer) || void 0 === t || t.unobserve())
}
,
e
}(), mn = function(e) {
function t(i, n) {
var r = e.call(this) || this;
r._inputManager = new cn(r),
r.cameraToUseForPointers = null,
r._isScene = !0,
r._blockEntityCollection = !1,
r.autoClear = !0,
r.autoClearDepthAndStencil = !0,
r.clearColor = new N(.2,.2,.3,1),
r.ambientColor = new D(0,0,0),
r.environmentIntensity = 1,
r._forceWireframe = !1,
r._skipFrustumClipping = !1,
r._forcePointsCloud = !1,
r.animationsEnabled = !0,
r._animationPropertiesOverride = null,
r.useConstantAnimationDeltaTime = !1,
r.constantlyUpdateMeshUnderPointer = !1,
r.hoverCursor = "pointer",
r.defaultCursor = "",
r.doNotHandleCursors = !1,
r.preventDefaultOnPointerDown = !0,
r.preventDefaultOnPointerUp = !0,
r.metadata = null,
r.reservedDataStore = null,
r.disableOfflineSupportExceptionRules = new Array,
r.onDisposeObservable = new h,
r._onDisposeObserver = null,
r.onBeforeRenderObservable = new h,
r._onBeforeRenderObserver = null,
r.onAfterRenderObservable = new h,
r.onBeforeRunRegisterBeforeRenderObservable = new h,
r.onAfterRunRegisterBeforeRenderObservable = new h,
r.onBeforeRunRegisterAfterRenderObservable = new h,
r.onAfterRunRegisterAfterRenderObservable = new h,
r.onBeforeRTT1Observable = new h,
r.onAfterRTT1Observable = new h,
r.onAfterRenderCameraObservable = new h,
r._onAfterRenderObserver = null,
r.onBeforeAnimationsObservable = new h,
r.onAfterAnimationsObservable = new h,
r.onBeforeDrawPhaseObservable = new h,
r.onAfterDrawPhaseObservable = new h,
r.onReadyObservable = new h,
r.onBeforeCameraRenderObservable = new h,
r._onBeforeCameraRenderObserver = null,
r.onAfterCameraRenderObservable = new h,
r._onAfterCameraRenderObserver = null,
r.onBeforeActiveMeshesEvaluationObservable = new h,
r.onAfterActiveMeshesEvaluationObservable = new h,
r.onBeforeParticlesRenderingObservable = new h,
r.onAfterParticlesRenderingObservable = new h,
r.onDataLoadedObservable = new h,
r.onNewCameraAddedObservable = new h,
r.onCameraRemovedObservable = new h,
r.onNewLightAddedObservable = new h,
r.onLightRemovedObservable = new h,
r.onNewGeometryAddedObservable = new h,
r.onGeometryRemovedObservable = new h,
r.onNewTransformNodeAddedObservable = new h,
r.onTransformNodeRemovedObservable = new h,
r.onNewMeshAddedObservable = new h,
r.onMeshRemovedObservable = new h,
r.onNewSkeletonAddedObservable = new h,
r.onSkeletonRemovedObservable = new h,
r.onNewMaterialAddedObservable = new h,
r.onNewMultiMaterialAddedObservable = new h,
r.onMaterialRemovedObservable = new h,
r.onMultiMaterialRemovedObservable = new h,
r.onNewTextureAddedObservable = new h,
r.onTextureRemovedObservable = new h,
r.onBeforeRenderTargetsRenderObservable = new h,
r.onAfterRenderTargetsRenderObservable = new h,
r.onBeforeStepObservable = new h,
r.onAfterStepObservable = new h,
r.onActiveCameraChanged = new h,
r.onBeforeRenderingGroupObservable = new h,
r.onAfterRenderingGroupObservable = new h,
r.onMeshImportedObservable = new h,
r.onAnimationFileImportedObservable = new h,
r._registeredForLateAnimationBindings = new Ti(256),
r.skipPointerMovePicking = !1,
r.onPrePointerObservable = new h,
r.onPointerObservable = new h,
r.onPreKeyboardObservable = new h,
r.onKeyboardObservable = new h,
r._useRightHandedSystem = !1,
r._timeAccumulator = 0,
r._currentStepId = 0,
r._currentInternalStep = 0,
r._fogEnabled = !0,
r._fogMode = t.FOGMODE_NONE,
r.fogColor = new D(.2,.2,.3),
r.fogDensity = .1,
r.fogStart = 0,
r.fogEnd = 1e3,
r.needsPreviousWorldMatrices = !1,
r._shadowsEnabled = !0,
r._lightsEnabled = !0,
r.activeCameras = new Array,
r._texturesEnabled = !0,
r.physicsEnabled = !0,
r.particlesEnabled = !0,
r.spritesEnabled = !0,
r._skeletonsEnabled = !0,
r.lensFlaresEnabled = !0,
r.collisionsEnabled = !0,
r.gravity = new x(0,-9.807,0),
r.postProcessesEnabled = !0,
r.renderTargetsEnabled = !0,
r.dumpNextRenderTargets = !1,
r.customRenderTargets = new Array,
r.importedMeshesFiles = new Array,
r.probesEnabled = !0,
r._meshesForIntersections = new Ti(256),
r.proceduralTexturesEnabled = !0,
r._totalVertices = new un,
r._activeIndices = new un,
r._activeParticles = new un,
r._activeBones = new un,
r._animationTime = 0,
r.animationTimeScale = 1,
r._renderId = 0,
r._frameId = 0,
r._executeWhenReadyTimeoutId = null,
r._intermediateRendering = !1,
r._defaultFrameBufferCleared = !1,
r._viewUpdateFlag = -1,
r._projectionUpdateFlag = -1,
r._toBeDisposed = new Array(256),
r._activeRequests = new Array,
r._pendingData = new Array,
r._isDisposed = !1,
r.dispatchAllSubMeshesOfActiveMeshes = !1,
r._activeMeshes = new bi(256),
r._processedMaterials = new bi(256),
r._renderTargets = new Ti(256),
r._materialsRenderTargets = new Ti(256),
r._activeParticleSystems = new bi(256),
r._activeSkeletons = new Ti(32),
r._softwareSkinnedMeshes = new Ti(32),
r._activeAnimatables = new Array,
r._transformMatrix = P.Zero(),
r.requireLightSorting = !1,
r._components = [],
r._serializableComponents = [],
r._transientComponents = [],
r._beforeCameraUpdateStage = Hi.Create(),
r._beforeClearStage = Hi.Create(),
r._beforeRenderTargetClearStage = Hi.Create(),
r._gatherRenderTargetsStage = Hi.Create(),
r._gatherActiveCameraRenderTargetsStage = Hi.Create(),
r._isReadyForMeshStage = Hi.Create(),
r._beforeEvaluateActiveMeshStage = Hi.Create(),
r._evaluateSubMeshStage = Hi.Create(),
r._preActiveMeshStage = Hi.Create(),
r._cameraDrawRenderTargetStage = Hi.Create(),
r._beforeCameraDrawStage = Hi.Create(),
r._beforeRenderTargetDrawStage = Hi.Create(),
r._beforeRenderingGroupDrawStage = Hi.Create(),
r._beforeRenderingMeshStage = Hi.Create(),
r._afterRenderingMeshStage = Hi.Create(),
r._afterRenderingGroupDrawStage = Hi.Create(),
r._afterCameraDrawStage = Hi.Create(),
r._afterRenderTargetDrawStage = Hi.Create(),
r._afterRenderStage = Hi.Create(),
r._pointerMoveStage = Hi.Create(),
r._pointerDownStage = Hi.Create(),
r._pointerUpStage = Hi.Create(),
r._geometriesByUniqueId = null,
r._defaultMeshCandidates = {
data: [],
length: 0
},
r._defaultSubMeshCandidates = {
data: [],
length: 0
},
r._preventFreeActiveMeshesAndRenderingGroups = !1,
r._activeMeshesFrozen = !1,
r._skipEvaluateActiveMeshesCompletely = !1,
r._allowPostProcessClearColor = !0,
r.getDeterministicFrameTime = function() {
return r._engine.getTimeStep()
}
,
r._blockMaterialDirtyMechanism = !1,
r._perfCollector = null,
r.onComputePressureChanged = new h;
var o = V({
useGeometryUniqueIdsMap: !0,
useMaterialMeshMap: !0,
useClonedMeshMap: !0,
virtual: !1
}, n);
return r._engine = i || E.LastCreatedEngine,
o.virtual ? r._engine._virtualScenes.push(r) : (E._LastCreatedScene = r,
r._engine.scenes.push(r)),
r._uid = null,
r._renderingManager = new zi(r),
Vi && (r.postProcessManager = new Vi(r)),
nt() && r.attachControl(),
r._createUbo(),
Ri && (r._imageProcessingConfiguration = new Ri),
r.setDefaultCandidateProviders(),
o.useGeometryUniqueIdsMap && (r._geometriesByUniqueId = {}),
r.useMaterialMeshMap = o.useMaterialMeshMap,
r.useClonedMeshMap = o.useClonedMeshMap,
n && n.virtual || r._engine.onNewSceneAddedObservable.notifyObservers(r),
_n.IsAvailable && (r._computePressureObserver = new _n((function(e) {
r.onComputePressureChanged.notifyObservers(e)
}
),{
cpuUtilizationThresholds: [.25, .5, .75, .9],
cpuSpeedThresholds: [.5]
}),
r._computePressureObserver.observe()),
r
}
return U(t, e),
t.DefaultMaterialFactory = function(e) {
throw be("StandardMaterial")
}
,
t.CollisionCoordinatorFactory = function() {
throw be("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, "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, "unTranslatedPointer", {
get: function() {
return this._inputManager.unTranslatedPointer
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t, "DragMovementThreshold", {
get: function() {
return cn.DragMovementThreshold
},
set: function(e) {
cn.DragMovementThreshold = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t, "LongPressDelay", {
get: function() {
return cn.LongPressDelay
},
set: function(e) {
cn.LongPressDelay = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t, "DoubleClickDelay", {
get: function() {
return cn.DoubleClickDelay
},
set: function(e) {
cn.DoubleClickDelay = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t, "ExclusiveDoubleClickMode", {
get: function() {
return cn.ExclusiveDoubleClickMode
},
set: function(e) {
cn.ExclusiveDoubleClickMode = e
},
enumerable: !1,
configurable: !0
}),
t.prototype.bindEyePosition = function(e, t, i) {
var n;
void 0 === t && (t = "vEyePosition"),
void 0 === i && (i = !1);
var r = this._forcedViewPosition ? this._forcedViewPosition : this._mirroredCameraPosition ? this._mirroredCameraPosition : null !== (n = this.activeCamera.globalPosition) && void 0 !== n ? n : this.activeCamera.devicePosition
, o = this.useRightHandedSystem === (null != this._mirroredCameraPosition);
return I.Vector4[0].set(r.x, r.y, r.z, o ? -1 : 1),
e && (i ? e.setFloat3(t, I.Vector4[0].x, I.Vector4[0].y, I.Vector4[0].z) : e.setVector4(t, I.Vector4[0])),
I.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, "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, "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 = []
}
}
,
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 n = i[t];
if (n.name === e)
return n
}
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) {
if (void 0 === e && (e = !0),
this._isDisposed)
return !1;
var t, i = this.getEngine();
if (this._pendingData.length > 0)
return !1;
e && (this._processedMaterials.reset(),
this._materialsRenderTargets.reset());
var n = !0;
for (t = 0; t < this.meshes.length; t++) {
var r = this.meshes[t];
if (r.isEnabled() && r.subMeshes && 0 !== r.subMeshes.length)
if (r.isReady(!0)) {
for (var o = r.hasThinInstances || "InstancedMesh" === r.getClassName() || "InstancedLinesMesh" === r.getClassName() || i.getCaps().instancedArrays && r.instances.length > 0, s = 0, l = this._isReadyForMeshStage; s < l.length; s++)
l[s].action(r, o) || (n = !1);
if (e) {
var c = r.material || this.defaultMaterial;
if (c)
if (c._storeEffectOnSubMeshes)
for (var u = 0, h = r.subMeshes; u < h.length; u++) {
var d = h[u].getMaterial();
d && d.hasRenderTargetTextures && null != d.getRenderTargetTextures && -1 === this._processedMaterials.indexOf(d) && (this._processedMaterials.push(d),
this._materialsRenderTargets.concatWithNoDuplicate(d.getRenderTargetTextures()))
}
else
c.hasRenderTargetTextures && null != c.getRenderTargetTextures && -1 === this._processedMaterials.indexOf(c) && (this._processedMaterials.push(c),
this._materialsRenderTargets.concatWithNoDuplicate(c.getRenderTargetTextures()))
}
} else
n = !1
}
if (!n)
return !1;
if (!i.areAllEffectsReady())
return !1;
if (e)
for (t = 0; t < this._materialsRenderTargets.length; ++t)
if (!this._materialsRenderTargets.data[t].isReadyForRendering())
return !1;
for (t = 0; t < this.geometries.length; t++)
if (this.geometries[t].delayLoadState === a.DELAYLOADSTATE_LOADING)
return !1;
if (this.activeCameras && this.activeCameras.length > 0) {
for (var p = 0, f = this.activeCameras; p < f.length; p++)
if (!f[p].isReady(!0))
return !1
} else if (this.activeCamera && !this.activeCamera.isReady(!0))
return !1;
for (var _ = 0, m = this.particleSystems; _ < m.length; _++)
if (!m[_].isReady())
return !1;
return !0
}
,
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) {
var i = this;
void 0 === t && (t = !1),
this.onReadyObservable.add(e),
null === this._executeWhenReadyTimeoutId && (this._executeWhenReadyTimeoutId = setTimeout((function() {
i._checkIsReady(t)
}
), 150))
}
,
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._checkIsReady(e)
}
), 100))
}
,
Object.defineProperty(t.prototype, "animatables", {
get: function() {
return this._activeAnimatables
},
enumerable: !1,
configurable: !0
}),
t.prototype.resetLastAnimationTimeFrame = function() {
this._animationTimeLast = ct.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, n) {
i || n || !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 ? dn.GetPlanesToRef(this._transformMatrix, this._frustumPlanes) : this._frustumPlanes = dn.GetPlanes(this._transformMatrix),
this._multiviewSceneUbo && this._multiviewSceneUbo.useUbo ? this._updateMultiviewUbo(i, n) : 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 Fi(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 pn.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 n = this.meshes.indexOf(e);
return -1 !== n && (this.meshes[n] = 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)
}
)),
n
}
,
t.prototype.addTransformNode = function(e) {
this._blockEntityCollection || (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, n = this.meshes; i < n.length; i++)
n[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 n = i[t];
-1 === n.lightSources.indexOf(e) && (n.lightSources.push(e),
n._resyncLightSources())
}
this.onNewLightAddedObservable.notifyObservers(e)
}
}
,
t.prototype.sortLightsByPriority = function() {
this.requireLightSorting && this.lights.sort(fn.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._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.getMaterialByUniqueID = function(e) {
for (var t = 0; t < this.materials.length; t++)
if (this.materials[t].uniqueId === e)
return this.materials[t];
return null
}
,
t.prototype.getMaterialById = function(e) {
for (var t = 0; t < this.materials.length; t++)
if (this.materials[t].id === e)
return this.materials[t];
return null
}
,
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.getMaterialByName = function(e) {
for (var t = 0; t < this.materials.length; t++)
if (this.materials[t].name === e)
return this.materials[t];
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], n = 0; n < i.bones.length; n++)
if (i.bones[n].id === e)
return i.bones[n];
return null
}
,
t.prototype.getBoneByName = function(e) {
for (var t = 0; t < this.skeletons.length; t++)
for (var i = this.skeletons[t], n = 0; n < i.bones.length; n++)
if (i.bones[n].name === e)
return i.bones[n];
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,
this._geometriesByUniqueId[e.uniqueId] = void 0))
}
return 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.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 n = this.getLightById(e);
if (n)
return n;
var r = this.getCameraById(e);
return r || (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 n = this.getLightByName(e);
if (n)
return n;
var r = this.getCameraByName(e);
return r || (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], n = 0; n < i.numTargets; ++n) {
var r = i.getTarget(n);
if (r.id === e)
return r
}
return null
}
,
t.prototype.getMorphTargetByName = function(e) {
for (var t = 0; t < this.morphTargetManagers.length; ++t)
for (var i = this.morphTargetManagers[t], n = 0; n < i.numTargets; ++n) {
var r = i.getTarget(n);
if (r.name === e)
return r
}
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 = gi.RandomId()),
this._uid
},
enumerable: !1,
configurable: !0
}),
t.prototype.addExternalData = function(e, t) {
return this._externalData || (this._externalData = new Ei),
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 Ei),
this._externalData.getOrAddWithFactory(e, t)
}
,
t.prototype.removeExternalData = function(e) {
return this._externalData.remove(e)
}
,
t.prototype._evaluateSubMesh = function(e, t, i) {
if (i.hasInstances || i.isAnInstance || this.dispatchAllSubMeshesOfActiveMeshes || this._skipFrustumClipping || t.alwaysSelectAsActiveMesh || 1 === t.subMeshes.length || e.isInFrustum(this._frustumPlanes)) {
for (var n = 0, r = this._evaluateSubMeshStage; n < r.length; n++)
r[n].action(t, e);
var o = e.getMaterial();
null != o && (o.hasRenderTargetTextures && null != o.getRenderTargetTextures && -1 === this._processedMaterials.indexOf(o) && (this._processedMaterials.push(o),
this._materialsRenderTargets.concatWithNoDuplicate(o.getRenderTargetTextures())),
this._renderingManager.dispatch(e, t, o))
}
}
,
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, n) {
var r = this;
return void 0 === e && (e = !1),
void 0 === n && (n = !0),
this.executeWhenReady((function() {
if (r.activeCamera) {
if (r._frustumPlanes || r.updateTransformMatrix(),
r._evaluateActiveMeshes(),
r._activeMeshesFrozen = !0,
r._skipEvaluateActiveMeshesCompletely = e,
n)
for (var o = 0; o < r._activeMeshes.length; o++)
r._activeMeshes.data[o]._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 n = this._activeParticleSystems.length;
for (i = 0; i < n; i++)
this._activeParticleSystems.data[i].animate()
}
} 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 r = 0, o = this._beforeEvaluateActiveMeshStage; r < o.length; r++)
o[r].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() && 0 !== c.scaling.lengthSquared())) {
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) {
if (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)),
null != t && void 0 !== t.subMeshes && null !== t.subMeshes && t.subMeshes.length > 0)
for (var i = this.getActiveSubMeshCandidates(t), n = i.length, r = 0; r < n; r++) {
var o = i.data[r];
this._evaluateSubMesh(o, t, e)
}
}
,
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) {
var t = e.outputRenderTarget;
t.onClearObservable.hasObservers() ? t.onClearObservable.notifyObservers(this._engine) : t.skipInitialClear || (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 n, r, 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 && (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) {
gi.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
}
}
gi.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 !== (r = null === (n = e.outputRenderTarget) || void 0 === n ? void 0 : n.renderPassId) && void 0 !== r ? r : 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)
}
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 n = i.getTriggerParameter()
, r = n.mesh ? n.mesh : n
, o = r.intersectsMesh(t, n.usePreciseIntersection)
, s = t._intersectionsInProgress.indexOf(r);
o && -1 === s ? i.trigger === a.ACTION_OnIntersectionEnterTrigger ? (i._executeCurrent(w.CreateNew(t, void 0, r)),
t._intersectionsInProgress.push(r)) : i.trigger === a.ACTION_OnIntersectionExitTrigger && t._intersectionsInProgress.push(r) : !o && s > -1 && (i.trigger === a.ACTION_OnIntersectionExitTrigger && i._executeCurrent(w.CreateNew(t, void 0, r)),
t.actionManager.hasSpecificTrigger(a.ACTION_OnIntersectionExitTrigger, (function(e) {
var t = e.mesh ? e.mesh : e;
return r === t
}
)) && i.trigger !== a.ACTION_OnIntersectionExitTrigger || t._intersectionsInProgress.splice(s, 1))
}
}, n = 0; t.actionManager && n < t.actionManager.actions.length; n++)
i(n)
}
}
,
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()
, n = 1e3 / i / 1e3
, r = 0
, o = this._engine.getLockstepMaxSteps()
, a = Math.floor(e / i);
for (a = Math.min(a, o); e > 0 && r < a; )
this.onBeforeStepObservable.notifyObservers(this),
this._animationRatio = i * n,
this._animate(),
this.onAfterAnimationsObservable.notifyObservers(this),
this.physicsEnabled && this._advancePhysicsEngineStep(i),
this.onAfterStepObservable.notifyObservers(this),
this._currentStepId++,
r++,
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 n = e.rigCameras[i].outputRenderTarget;
n && (n._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, n, r;
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.onBeforeRunRegisterBeforeRenderObservable.notifyObservers(this),
this.onBeforeRenderObservable.notifyObservers(this),
this.onAfterRunRegisterBeforeRenderObservable.notifyObservers(this),
this.onBeforeRenderObservable.notifyObservers(this);
var h = this.getEngine();
this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
var d = (null === (n = this.activeCameras) || void 0 === n ? void 0 : n.length) ? this.activeCameras[0] : this.activeCamera;
if (this.renderTargetsEnabled) {
gi.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)
}
}
gi.EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0),
this._intermediateRendering = !1,
this._renderId++
}
this._engine.currentRenderPassId = null !== (r = null == d ? void 0 : d.renderPassId) && void 0 !== r ? r : 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 = []
}
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() {
var e;
if (!this.isDisposed) {
this.beforeRender = null,
this.afterRender = null,
this.metadata = null,
this.skeletons = [],
this.morphTargetManagers = [],
this._transientComponents = [],
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.stopAllAnimations(),
this.resetCachedMaterial(),
this.activeCamera && (this.activeCamera._activeMeshes.dispose(),
this.activeCamera = 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 = [];
for (var t = 0, i = this._activeRequests.slice(); t < i.length; t++)
i[t].abort();
this.onBeforeRunRegisterBeforeRenderObservable.clear(),
this.onAfterRunRegisterBeforeRenderObservable.clear(),
this.onBeforeRTT1Observable.clear(),
this.onAfterRTT1Observable.clear(),
this.onBeforeRunRegisterAfterRenderObservable.clear(),
this.onAfterRunRegisterAfterRenderObservable.clear()
if (this._activeRequests = [],
this.onDisposeObservable.notifyObservers(this),
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.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.onComputePressureChanged.clear(),
null === (e = this._computePressureObserver) || void 0 === e || e.unobserve(),
this._computePressureObserver = void 0,
this.detachControl(),
this._engine.getInputElement())
for (var n = 0; n < this.cameras.length; n++)
this.cameras[n].detachControl();
for (; this.animationGroups.length; )
this.animationGroups[0].dispose();
for (; this.lights.length; )
this.lights[0].dispose();
for (; this.meshes.length; )
this.meshes[0].dispose(!0);
for (; this.transformNodes.length; )
this.transformNodes[0].dispose(!0);
for (; this.cameras.length; )
this.cameras[0].dispose();
for (this._defaultMaterial && this._defaultMaterial.dispose(); this.multiMaterials.length; )
this.multiMaterials[0].dispose();
for (; this.materials.length; )
this.materials[0].dispose();
for (; this.particleSystems.length; )
this.particleSystems[0].dispose();
for (; this.postProcesses.length; )
this.postProcesses[0].dispose();
for (; this.textures.length; )
this.textures[0].dispose();
for (; this.morphTargetManagers.length; )
this.morphTargetManagers[0].dispose();
this._sceneUbo.dispose(),
this._multiviewSceneUbo && this._multiviewSceneUbo.dispose(),
this.postProcessManager.dispose();
for (var r = 0, o = this._components; r < o.length; r++)
o[r].dispose();
var a = this._engine.scenes.indexOf(this);
a > -1 && this._engine.scenes.splice(a, 1),
E._LastCreatedScene === this && (this._engine.scenes.length > 0 ? E._LastCreatedScene = this._engine.scenes[this._engine.scenes.length - 1] : E._LastCreatedScene = null),
(a = this._engine._virtualScenes.indexOf(this)) > -1 && this._engine._virtualScenes.splice(a, 1),
this._engine.wipeCaches(!0),
this._isDisposed = !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 x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)
, i = new x(-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 n = e.getBoundingInfo()
, r = n.boundingBox.minimumWorld
, o = n.boundingBox.maximumWorld;
x.CheckExtends(r, t, i),
x.CheckExtends(o, t, i)
}
}
)),
{
min: t,
max: i
}
}
,
t.prototype.createPickingRay = function(e, t, i, n, r) {
throw void 0 === r && (r = !1),
be("Ray")
}
,
t.prototype.createPickingRayToRef = function(e, t, i, n, r, o, a) {
throw void 0 === o && (o = !1),
void 0 === a && (a = !1),
be("Ray")
}
,
t.prototype.createPickingRayInCameraSpace = function(e, t, i) {
throw be("Ray")
}
,
t.prototype.createPickingRayInCameraSpaceToRef = function(e, t, i, n) {
throw be("Ray")
}
,
t.prototype.pick = function(e, t, i, n, r, o) {
var a = new Ui;
return a._pickingUnavailable = !0,
a
}
,
t.prototype.pickWithBoundingInfo = function(e, t, i, n, r) {
var o = new Ui;
return o._pickingUnavailable = !0,
o
}
,
t.prototype.pickWithRay = function(e, t, i, n) {
throw be("Ray")
}
,
t.prototype.multiPick = function(e, t, i, n, r) {
throw be("Ray")
}
,
t.prototype.multiPickWithRay = function(e, t, i) {
throw be("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, n = this.meshes; i < n.length; i++)
n[i]._rebuild();
this.postProcessManager && this.postProcessManager._rebuild();
for (var r = 0, o = this._components; r < o.length; r++)
o[r].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 n = [];
for (var r in i = i || function(e) {}
,
e) {
var o = e[r];
ye && ye.MatchesQuery(o, t) && (n.push(o),
i(o))
}
return n
}
,
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, n) {
void 0 === t && (t = null),
void 0 === i && (i = null),
void 0 === n && (n = null),
this._renderingManager.setRenderingOrder(e, t, i, n)
}
,
t.prototype.setRenderingAutoClearDepthStencil = function(e, t, i, n) {
void 0 === i && (i = !0),
void 0 === n && (n = !0),
this._renderingManager.setRenderingAutoClearDepthStencil(e, t, i, n)
}
,
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, n = this.materials; i < n.length; i++) {
var r = n[i];
t && !t(r) || r.markAsDirty(e)
}
}
,
t.prototype._loadFile = function(e, t, i, n, r, o, a) {
var s = this
, l = ti(e, t, i, n ? this.offlineProvider : void 0, r, 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, n, r) {
var o = this;
return new Promise((function(a, s) {
o._loadFile(e, (function(e) {
a(e)
}
), t, i, n, (function(e, t) {
s(t)
}
), r)
}
))
}
,
t.prototype._requestFile = function(e, t, i, n, r, o, a) {
var s = this
, l = ii(e, t, i, n ? this.offlineProvider : void 0, r, 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, n, r) {
var o = this;
return new Promise((function(a, s) {
o._requestFile(e, (function(e) {
a(e)
}
), t, i, n, (function(e) {
s(e)
}
), r)
}
))
}
,
t.prototype._readFile = function(e, t, i, n, r) {
var o = this
, a = ei(e, t, i, n, r);
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 n = this;
return new Promise((function(r, o) {
n._readFile(e, (function(e) {
r(e)
}
), t, i, (function(e) {
o(e)
}
))
}
))
}
,
t.prototype.getPerfCollector = function() {
throw be("performanceViewerSceneExtension")
}
,
t.FOGMODE_NONE = 0,
t.FOGMODE_EXP = 1,
t.FOGMODE_EXP2 = 2,
t.FOGMODE_LINEAR = 3,
t.MinDeltaTime = 1,
t.MaxDeltaTime = 1e3,
t
}(o);
mn.prototype.setActiveCameraByID = function(e) {
return this.setActiveCameraById(e)
}
,
mn.prototype.getLastMaterialByID = function(e) {
return this.getLastMaterialById(e)
}
,
mn.prototype.getMaterialByID = function(e) {
return this.getMaterialById(e)
}
,
mn.prototype.getTextureByUniqueID = function(e) {
return this.getTextureByUniqueId(e)
}
,
mn.prototype.getCameraByID = function(e) {
return this.getCameraById(e)
}
,
mn.prototype.getCameraByUniqueID = function(e) {
return this.getCameraByUniqueId(e)
}
,
mn.prototype.getBoneByID = function(e) {
return this.getBoneById(e)
}
,
mn.prototype.getLightByID = function(e) {
return this.getLightById(e)
}
,
mn.prototype.getLightByUniqueID = function(e) {
return this.getLightByUniqueId(e)
}
,
mn.prototype.getParticleSystemByID = function(e) {
return this.getParticleSystemById(e)
}
,
mn.prototype.getGeometryByID = function(e) {
return this.getGeometryById(e)
}
,
mn.prototype.getMeshByID = function(e) {
return this.getMeshById(e)
}
,
mn.prototype.getMeshesByID = function(e) {
return this.getMeshesById(e)
}
,
mn.prototype.getTransformNodeByID = function(e) {
return this.getTransformNodeById(e)
}
,
mn.prototype.getTransformNodeByUniqueID = function(e) {
return this.getTransformNodeByUniqueId(e)
}
,
mn.prototype.getTransformNodesByID = function(e) {
return this.getTransformNodesById(e)
}
,
mn.prototype.getMeshByUniqueID = function(e) {
return this.getMeshByUniqueId(e)
}
,
mn.prototype.getLastMeshByID = function(e) {
return this.getLastMeshById(e)
}
,
mn.prototype.getLastEntryByID = function(e) {
return this.getLastEntryById(e)
}
,
mn.prototype.getNodeByID = function(e) {
return this.getNodeById(e)
}
,
mn.prototype.getLastSkeletonByID = function(e) {
return this.getLastSkeletonById(e)
}
,
function(e) {
e[e.LOCAL = 0] = "LOCAL",
e[e.WORLD = 1] = "WORLD",
e[e.BONE = 2] = "BONE"
}(Ji || (Ji = {}));
var gn, vn = function() {
function e() {}
return e.X = new x(1,0,0),
e.Y = new x(0,1,0),
e.Z = new x(0,0,1),
e
}();
!function(e) {
e[e.X = 0] = "X",
e[e.Y = 1] = "Y",
e[e.Z = 2] = "Z"
}(gn || (gn = {}));
var yn = function(e) {
function t(t, i, n, r, o, a, s) {
void 0 === n && (n = null),
void 0 === r && (r = null),
void 0 === o && (o = null),
void 0 === a && (a = null),
void 0 === s && (s = null);
var l = e.call(this, t, i.getScene()) || this;
return l.name = t,
l.children = new Array,
l.animations = new Array,
l._index = null,
l._absoluteTransform = new P,
l._invertedAbsoluteTransform = new P,
l._scalingDeterminant = 1,
l._worldTransform = new P,
l._needToDecompose = !0,
l._needToCompose = !1,
l._linkedTransformNode = null,
l._waitingTransformNodeId = null,
l._skeleton = i,
l._localMatrix = r ? r.clone() : P.Identity(),
l._restPose = o || l._localMatrix.clone(),
l._baseMatrix = a || l._localMatrix.clone(),
l._index = s,
i.bones.push(l),
l.setParent(n, !1),
(a || r) && l._updateDifferenceMatrix(),
l
}
return U(t, e),
Object.defineProperty(t.prototype, "_matrix", {
get: function() {
return this._compose(),
this._localMatrix
},
set: function(e) {
this._needToCompose = !1,
e.updateFlag !== this._localMatrix.updateFlag && (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._updateDifferenceMatrix(),
this.markAsDirty()
}
}
,
t.prototype.getLocalMatrix = function() {
return this._compose(),
this._localMatrix
}
,
t.prototype.getBaseMatrix = function() {
return this._baseMatrix
}
,
t.prototype.getRestPose = function() {
return this._restPose
}
,
t.prototype.setRestPose = function(e) {
this._restPose.copyFrom(e)
}
,
t.prototype.getBindPose = function() {
return this._baseMatrix
}
,
t.prototype.setBindPose = function(e) {
this.updateMatrix(e)
}
,
t.prototype.getWorldMatrix = function() {
return this._worldTransform
}
,
t.prototype.returnToRest = function() {
var e;
if (this._linkedTransformNode) {
var t = I.Vector3[0]
, i = I.Quaternion[0]
, n = I.Vector3[1];
this.getRestPose().decompose(t, i, n),
this._linkedTransformNode.position.copyFrom(n),
this._linkedTransformNode.rotationQuaternion = null !== (e = this._linkedTransformNode.rotationQuaternion) && void 0 !== e ? e : C.Identity(),
this._linkedTransformNode.rotationQuaternion.copyFrom(i),
this._linkedTransformNode.scaling.copyFrom(t)
} else
this._matrix = this._restPose
}
,
t.prototype.getInvertedAbsoluteTransform = function() {
return this._invertedAbsoluteTransform
}
,
t.prototype.getAbsoluteTransform = function() {
return this._absoluteTransform
}
,
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 = x.Zero(),
this._localRotation = C.Zero(),
this._localPosition = x.Zero()),
this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition))
}
,
t.prototype._compose = function() {
this._needToCompose && (this._localScaling ? (this._needToCompose = !1,
P.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._baseMatrix.copyFrom(e),
t && this._updateDifferenceMatrix(),
i ? this._matrix = e : this.markAsDirty()
}
,
t.prototype._updateDifferenceMatrix = function(e, t) {
if (void 0 === t && (t = !0),
e || (e = this._baseMatrix),
this.parent ? e.multiplyToRef(this.parent._absoluteTransform, this._absoluteTransform) : this._absoluteTransform.copyFrom(e),
this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform),
t)
for (var i = 0; i < this.children.length; i++)
this.children[i]._updateDifferenceMatrix();
this._scalingDeterminant = this._absoluteTransform.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.translate = function(e, i, n) {
void 0 === i && (i = Ji.LOCAL);
var r = this.getLocalMatrix();
if (i == Ji.LOCAL)
r.addAtIndex(12, e.x),
r.addAtIndex(13, e.y),
r.addAtIndex(14, e.z);
else {
var o = null;
n && (o = n.getWorldMatrix()),
this._skeleton.computeAbsoluteTransforms();
var a = t._TmpMats[0]
, s = t._TmpVecs[0];
this.parent ? n && o ? (a.copyFrom(this.parent.getAbsoluteTransform()),
a.multiplyToRef(o, a)) : a.copyFrom(this.parent.getAbsoluteTransform()) : P.IdentityToRef(a),
a.setTranslationFromFloats(0, 0, 0),
a.invert(),
x.TransformCoordinatesToRef(e, a, s),
r.addAtIndex(12, s.x),
r.addAtIndex(13, s.y),
r.addAtIndex(14, s.z)
}
this._markAsDirtyAndDecompose()
}
,
t.prototype.setPosition = function(e, i, n) {
void 0 === i && (i = Ji.LOCAL);
var r = this.getLocalMatrix();
if (i == Ji.LOCAL)
r.setTranslationFromFloats(e.x, e.y, e.z);
else {
var o = null;
n && (o = n.getWorldMatrix()),
this._skeleton.computeAbsoluteTransforms();
var a = t._TmpMats[0]
, s = t._TmpVecs[0];
this.parent ? (n && o ? (a.copyFrom(this.parent.getAbsoluteTransform()),
a.multiplyToRef(o, a)) : a.copyFrom(this.parent.getAbsoluteTransform()),
a.invert()) : P.IdentityToRef(a),
x.TransformCoordinatesToRef(e, a, s),
r.setTranslationFromFloats(s.x, s.y, s.z)
}
this._markAsDirtyAndDecompose()
}
,
t.prototype.setAbsolutePosition = function(e, t) {
this.setPosition(e, Ji.WORLD, t)
}
,
t.prototype.scale = function(e, i, n, r) {
void 0 === r && (r = !1);
var o = this.getLocalMatrix()
, a = t._TmpMats[0];
P.ScalingToRef(e, i, n, 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, n),
d._markAsDirtyAndDecompose()
}
if (this._markAsDirtyAndDecompose(),
r)
for (var u = 0, h = this.children; u < h.length; u++) {
var d;
(d = h[u]).scale(e, i, n, r)
}
}
,
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, n, r, o) {
if (void 0 === r && (r = Ji.LOCAL),
r === Ji.LOCAL) {
var a = t._TmpQuat;
return C.RotationYawPitchRollToRef(e, i, n, a),
void this.setRotationQuaternion(a, r, o)
}
var s = t._TmpMats[0];
if (this._getNegativeRotationToRef(s, o)) {
var l = t._TmpMats[1];
P.RotationYawPitchRollToRef(e, i, n, l),
s.multiplyToRef(l, l),
this._rotateWithMatrix(l, r, o)
}
}
,
t.prototype.rotate = function(e, i, n, r) {
void 0 === n && (n = Ji.LOCAL);
var o = t._TmpMats[0];
o.setTranslationFromFloats(0, 0, 0),
P.RotationAxisToRef(e, i, o),
this._rotateWithMatrix(o, n, r)
}
,
t.prototype.setAxisAngle = function(e, i, n, r) {
if (void 0 === n && (n = Ji.LOCAL),
n === Ji.LOCAL) {
var o = t._TmpQuat;
return C.RotationAxisToRef(e, i, o),
void this.setRotationQuaternion(o, n, r)
}
var a = t._TmpMats[0];
if (this._getNegativeRotationToRef(a, r)) {
var s = t._TmpMats[1];
P.RotationAxisToRef(e, i, s),
a.multiplyToRef(s, s),
this._rotateWithMatrix(s, n, r)
}
}
,
t.prototype.setRotation = function(e, t, i) {
void 0 === t && (t = Ji.LOCAL),
this.setYawPitchRoll(e.y, e.x, e.z, t, i)
}
,
t.prototype.setRotationQuaternion = function(e, i, n) {
if (void 0 === i && (i = Ji.LOCAL),
i === Ji.LOCAL)
return this._decompose(),
this._localRotation.copyFrom(e),
void this._markAsDirtyAndCompose();
var r = t._TmpMats[0];
if (this._getNegativeRotationToRef(r, n)) {
var o = t._TmpMats[1];
P.FromQuaternionToRef(e, o),
r.multiplyToRef(o, o),
this._rotateWithMatrix(o, i, n)
}
}
,
t.prototype.setRotationMatrix = function(e, i, n) {
if (void 0 === i && (i = Ji.LOCAL),
i === Ji.LOCAL) {
var r = t._TmpQuat;
return C.FromRotationMatrixToRef(e, r),
void this.setRotationQuaternion(r, i, n)
}
var o = t._TmpMats[0];
if (this._getNegativeRotationToRef(o, n)) {
var a = t._TmpMats[1];
a.copyFrom(e),
o.multiplyToRef(e, a),
this._rotateWithMatrix(a, i, n)
}
}
,
t.prototype._rotateWithMatrix = function(e, i, n) {
void 0 === i && (i = Ji.LOCAL);
var r = this.getLocalMatrix()
, o = r.m[12]
, a = r.m[13]
, s = r.m[14]
, l = this.getParent()
, c = t._TmpMats[3]
, u = t._TmpMats[4];
l && i == Ji.WORLD ? (n ? (c.copyFrom(n.getWorldMatrix()),
l.getAbsoluteTransform().multiplyToRef(c, c)) : c.copyFrom(l.getAbsoluteTransform()),
u.copyFrom(c),
u.invert(),
r.multiplyToRef(c, r),
r.multiplyToRef(e, r),
r.multiplyToRef(u, r)) : i == Ji.WORLD && n ? (c.copyFrom(n.getWorldMatrix()),
u.copyFrom(c),
u.invert(),
r.multiplyToRef(c, r),
r.multiplyToRef(e, r),
r.multiplyToRef(u, r)) : r.multiplyToRef(e, r),
r.setTranslationFromFloats(o, a, s),
this.computeAbsoluteTransforms(),
this._markAsDirtyAndDecompose()
}
,
t.prototype._getNegativeRotationToRef = function(e, i) {
var n = t._TmpMats[2];
return e.copyFrom(this.getAbsoluteTransform()),
i ? (e.multiplyToRef(i.getWorldMatrix(), e),
P.ScalingToRef(i.scaling.x, i.scaling.y, i.scaling.z, n)) : P.IdentityToRef(n),
e.invert(),
!isNaN(e.m[0]) && (n.multiplyAtIndex(0, this._scalingDeterminant),
e.multiplyToRef(n, e),
!0)
}
,
t.prototype.getPosition = function(e, t) {
void 0 === e && (e = Ji.LOCAL),
void 0 === t && (t = null);
var i = x.Zero();
return this.getPositionToRef(e, t, i),
i
}
,
t.prototype.getPositionToRef = function(e, i, n) {
if (void 0 === e && (e = Ji.LOCAL),
e == Ji.LOCAL) {
var r = this.getLocalMatrix();
n.x = r.m[12],
n.y = r.m[13],
n.z = r.m[14]
} else {
var o = null;
i && (o = i.getWorldMatrix()),
this._skeleton.computeAbsoluteTransforms();
var a = t._TmpMats[0];
i && o ? (a.copyFrom(this.getAbsoluteTransform()),
a.multiplyToRef(o, a)) : a = this.getAbsoluteTransform(),
n.x = a.m[12],
n.y = a.m[13],
n.z = a.m[14]
}
}
,
t.prototype.getAbsolutePosition = function(e) {
void 0 === e && (e = null);
var t = x.Zero();
return this.getPositionToRef(Ji.WORLD, e, t),
t
}
,
t.prototype.getAbsolutePositionToRef = function(e, t) {
this.getPositionToRef(Ji.WORLD, e, t)
}
,
t.prototype.computeAbsoluteTransforms = function() {
if (this._compose(),
this.parent)
this._localMatrix.multiplyToRef(this.parent._absoluteTransform, this._absoluteTransform);
else {
this._absoluteTransform.copyFrom(this._localMatrix);
var e = this._skeleton.getPoseMatrix();
e && this._absoluteTransform.multiplyToRef(e, this._absoluteTransform)
}
for (var t = this.children, i = t.length, n = 0; n < i; n++)
t[n].computeAbsoluteTransforms()
}
,
t.prototype.getDirection = function(e, t) {
void 0 === t && (t = null);
var i = x.Zero();
return this.getDirectionToRef(e, t, i),
i
}
,
t.prototype.getDirectionToRef = function(e, i, n) {
void 0 === i && (i = null);
var r = null;
i && (r = i.getWorldMatrix()),
this._skeleton.computeAbsoluteTransforms();
var o = t._TmpMats[0];
o.copyFrom(this.getAbsoluteTransform()),
i && r && o.multiplyToRef(r, o),
x.TransformNormalToRef(e, o, n),
n.normalize()
}
,
t.prototype.getRotation = function(e, t) {
void 0 === e && (e = Ji.LOCAL),
void 0 === t && (t = null);
var i = x.Zero();
return this.getRotationToRef(e, t, i),
i
}
,
t.prototype.getRotationToRef = function(e, i, n) {
void 0 === e && (e = Ji.LOCAL),
void 0 === i && (i = null);
var r = t._TmpQuat;
this.getRotationQuaternionToRef(e, i, r),
r.toEulerAnglesToRef(n)
}
,
t.prototype.getRotationQuaternion = function(e, t) {
void 0 === e && (e = Ji.LOCAL),
void 0 === t && (t = null);
var i = C.Identity();
return this.getRotationQuaternionToRef(e, t, i),
i
}
,
t.prototype.getRotationQuaternionToRef = function(e, i, n) {
if (void 0 === e && (e = Ji.LOCAL),
void 0 === i && (i = null),
e == Ji.LOCAL)
this._decompose(),
n.copyFrom(this._localRotation);
else {
var r = t._TmpMats[0]
, o = this.getAbsoluteTransform();
i ? o.multiplyToRef(i.getWorldMatrix(), r) : r.copyFrom(o),
r.multiplyAtIndex(0, this._scalingDeterminant),
r.multiplyAtIndex(1, this._scalingDeterminant),
r.multiplyAtIndex(2, this._scalingDeterminant),
r.decompose(void 0, n, void 0)
}
}
,
t.prototype.getRotationMatrix = function(e, t) {
void 0 === e && (e = Ji.LOCAL);
var i = P.Identity();
return this.getRotationMatrixToRef(e, t, i),
i
}
,
t.prototype.getRotationMatrixToRef = function(e, i, n) {
if (void 0 === e && (e = Ji.LOCAL),
e == Ji.LOCAL)
this.getLocalMatrix().getRotationMatrixToRef(n);
else {
var r = t._TmpMats[0]
, o = this.getAbsoluteTransform();
i ? o.multiplyToRef(i.getWorldMatrix(), r) : r.copyFrom(o),
r.multiplyAtIndex(0, this._scalingDeterminant),
r.multiplyAtIndex(1, this._scalingDeterminant),
r.multiplyAtIndex(2, this._scalingDeterminant),
r.getRotationMatrixToRef(n)
}
}
,
t.prototype.getAbsolutePositionFromLocal = function(e, t) {
void 0 === t && (t = null);
var i = x.Zero();
return this.getAbsolutePositionFromLocalToRef(e, t, i),
i
}
,
t.prototype.getAbsolutePositionFromLocalToRef = function(e, i, n) {
void 0 === i && (i = null);
var r = null;
i && (r = i.getWorldMatrix()),
this._skeleton.computeAbsoluteTransforms();
var o = t._TmpMats[0];
i && r ? (o.copyFrom(this.getAbsoluteTransform()),
o.multiplyToRef(r, o)) : o = this.getAbsoluteTransform(),
x.TransformCoordinatesToRef(e, o, n)
}
,
t.prototype.getLocalPositionFromAbsolute = function(e, t) {
void 0 === t && (t = null);
var i = x.Zero();
return this.getLocalPositionFromAbsoluteToRef(e, t, i),
i
}
,
t.prototype.getLocalPositionFromAbsoluteToRef = function(e, i, n) {
void 0 === i && (i = null);
var r = null;
i && (r = i.getWorldMatrix()),
this._skeleton.computeAbsoluteTransforms();
var o = t._TmpMats[0];
o.copyFrom(this.getAbsoluteTransform()),
i && r && o.multiplyToRef(r, o),
o.invert(),
x.TransformCoordinatesToRef(e, o, n)
}
,
t.prototype.setCurrentPoseAsRest = function() {
this.setRestPose(this.getLocalMatrix())
}
,
t._TmpVecs = g.BuildArray(2, x.Zero),
t._TmpQuat = C.Identity(),
t._TmpMats = g.BuildArray(5, P.Identity),
t
}(Xe)
, bn = function() {
function e(e, t, i, n, r, o, a, s, l, c) {
void 0 === i && (i = 0),
void 0 === n && (n = 100),
void 0 === r && (r = !1),
void 0 === o && (o = 1),
void 0 === c && (c = !1),
this.target = t,
this.fromFrame = i,
this.toFrame = n,
this.loopAnimation = r,
this.onAnimationEnd = a,
this.onAnimationLoop = l,
this.isAdditive = c,
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 = 0,
this.disposeOnEnd = !0,
this.animationStarted = !1,
this.onAnimationEndObservable = new h,
this.onAnimationLoopObservable = new h,
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
},
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, n = 0; n < t.length; n++) {
var r = t[n]
, o = new it(e,r,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 n = i[0].animation.framePerSecond;
this._frameToSyncFromJump = null !== (t = this._frameToSyncFromJump) && void 0 !== t ? t : i[0].currentFrame;
var r = 0 === this.speedRatio ? 0 : (e - this._frameToSyncFromJump) / n * 1e3 / this.speedRatio;
this._manualJumpDelay = -r
}
for (var o = 0; o < i.length; o++)
i[o].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) {
if (e || t) {
var i = this._scene._activeAnimatables.indexOf(this);
if (i > -1) {
for (var n = (o = this._runtimeAnimations).length - 1; n >= 0; n--) {
var r = o[n];
e && r.animation.name != e || t && !t(r.target) || (r.dispose(),
o.splice(n, 1))
}
0 == o.length && (this._scene._activeAnimatables.splice(i, 1),
this._raiseOnAnimationEnd())
}
} else if ((n = this._scene._activeAnimatables.indexOf(this)) > -1) {
this._scene._activeAnimatables.splice(n, 1);
for (var o = this._runtimeAnimations, a = 0; a < o.length; a++)
o[a].dispose();
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),
0 === this._weight)
return !0;
var t, i = !1, n = this._runtimeAnimations;
for (t = 0; t < n.length; t++) {
var r = n[t].animate(e - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight);
i = i || r
}
if (this.animationStarted = i,
!i) {
if (this.disposeOnEnd)
for (t = this._scene._activeAnimatables.indexOf(this),
this._scene._activeAnimatables.splice(t, 1),
t = 0; t < n.length; t++)
n[t].dispose();
this._raiseOnAnimationEnd(),
this.disposeOnEnd && (this.onAnimationEnd = null,
this.onAnimationLoop = null,
this.onAnimationLoopObservable.clear(),
this.onAnimationEndObservable.clear())
}
return i
}
,
e
}();
mn.prototype._animate = function() {
if (this.animationsEnabled) {
var e = ct.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, n = 0; n < t.length; n++) {
var r = t[n];
!r._animate(i) && r.disposeOnEnd && n--
}
this._processLateAnimationBindings()
}
}
}
,
mn.prototype.beginWeightedAnimation = function(e, t, i, n, r, o, a, s, l, c, u) {
void 0 === n && (n = 1),
void 0 === o && (o = 1),
void 0 === u && (u = !1);
var h = this.beginAnimation(e, t, i, r, o, a, s, !1, l, c, u);
return h.weight = n,
h
}
,
mn.prototype.beginAnimation = function(e, t, i, n, r, o, a, s, l, c, u) {
void 0 === r && (r = 1),
void 0 === s && (s = !0),
void 0 === u && (u = !1),
t > i && r > 0 && (r *= -1),
s && this.stopAnimation(e, void 0, l),
a || (a = new bn(this,e,t,i,n,r,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, n, r, o, a, s, l, c);
return a.reset(),
a
}
,
mn.prototype.beginHierarchyAnimation = function(e, t, i, n, r, 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, n, r, 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, n, r, o, a, s, l, c, void 0, h))
}
return p
}
,
mn.prototype.beginDirectAnimation = function(e, t, i, n, r, o, a, s, l) {
if (void 0 === l && (l = !1),
void 0 === o && (o = 1),
i > n && o > 0)
o *= -1;
else if (n > i && o < 0) {
var c = n;
n = i,
i = c
}
return new bn(this,e,i,n,r,o,a,t,s,l)
}
,
mn.prototype.beginDirectHierarchyAnimation = function(e, t, i, n, r, o, a, s, l, c) {
void 0 === c && (c = !1);
var u = e.getDescendants(t)
, h = [];
h.push(this.beginDirectAnimation(e, i, n, r, 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, n, r, o, a, s, l, c))
}
return h
}
,
mn.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
}
,
mn.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
}
,
mn.prototype.stopAnimation = function(e, t, i) {
for (var n = 0, r = this.getAllAnimatablesByTarget(e); n < r.length; n++)
r[n].stop(t, i)
}
,
mn.prototype.stopAllAnimations = function() {
if (this._activeAnimatables) {
for (var e = 0; e < this._activeAnimatables.length; e++)
this._activeAnimatables[e].stop();
this._activeAnimatables = []
}
for (var t = 0, i = this.animationGroups; t < i.length; t++)
i[t].stop()
}
,
mn.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)
}
,
mn.prototype._processLateAnimationBindingsForMatrices = function(e) {
if (0 === e.totalWeight && 0 === e.totalAdditiveWeight)
return e.originalValue;
var t = 1
, i = I.Vector3[0]
, n = I.Vector3[1]
, r = I.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(n, r, i);
else {
if (o = 1,
t = e.totalWeight,
1 == (l = a.weight / t)) {
if (!e.totalAdditiveWeight)
return a.currentValue;
c = !0
}
a.currentValue.decompose(n, r, i)
}
if (!c) {
n.scaleInPlace(l),
i.scaleInPlace(l),
r.scaleInPlace(l);
for (var u = o; u < e.animations.length; u++)
if (0 !== (f = e.animations[u]).weight) {
l = f.weight / t;
var h = I.Vector3[2]
, d = I.Vector3[3]
, p = I.Quaternion[1];
f.currentValue.decompose(d, p, h),
d.scaleAndAddToRef(l, n),
p.scaleAndAddToRef(l, r),
h.scaleAndAddToRef(l, i)
}
}
for (u = 0; u < e.additiveAnimations.length; u++) {
var f;
0 !== (f = e.additiveAnimations[u]).weight && (h = I.Vector3[2],
d = I.Vector3[3],
p = I.Quaternion[1],
f.currentValue.decompose(d, p, h),
d.multiplyToRef(n, d),
x.LerpToRef(n, d, f.weight, n),
r.multiplyToRef(p, p),
C.SlerpToRef(r, p, f.weight, r),
h.scaleAndAddToRef(f.weight, i))
}
var _ = a ? a._animationState.workValue : I.Matrix[0].clone();
return P.ComposeToRef(n, r, i, _),
_
}
,
mn.prototype._processLateAnimationBindingsForQuaternions = function(e, t) {
if (0 === e.totalWeight && 0 === e.totalAdditiveWeight)
return t;
var i = e.animations[0]
, n = e.originalValue
, r = t;
if (0 === e.totalWeight && e.totalAdditiveWeight > 0)
r.copyFrom(n);
else if (1 === e.animations.length) {
if (C.SlerpToRef(n, i.currentValue, Math.min(1, e.totalWeight), r),
0 === e.totalAdditiveWeight)
return r
} 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(n),
s.push(l)
} else {
if (2 === e.animations.length && (C.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],
C.SlerpToRef(r, a[d], s[d] / h, r),
d++) : (C.SlerpToRef(a[d], a[d + 1], s[d + 1] / (s[d] + s[d + 1]), t),
r = t,
h = s[d] + s[d + 1],
d += 2)
}
for (c = 0; c < e.additiveAnimations.length; c++)
0 !== (u = e.additiveAnimations[c]).weight && (r.multiplyToRef(u.currentValue, I.Quaternion[0]),
C.SlerpToRef(r, I.Quaternion[0], u.weight, r));
return r
}
,
mn.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 n = t._lateAnimationHolders[i]
, r = n.animations[0]
, o = n.originalValue
, a = Qe.AllowMatrixDecomposeForInterpolation && o.m
, s = t[i];
if (a)
s = this._processLateAnimationBindingsForMatrices(n);
else if (void 0 !== o.w)
s = this._processLateAnimationBindingsForQuaternions(n, s || C.Identity());
else {
var l = 0
, c = 1;
n.totalWeight < 1 ? s = r && o.scale ? o.scale(1 - n.totalWeight) : r ? o * (1 - n.totalWeight) : o.clone ? o.clone() : o : r && (c = n.totalWeight,
s = 1 != (d = r.weight / c) ? r.currentValue.scale ? r.currentValue.scale(d) : r.currentValue * d : r.currentValue,
l = 1);
for (var u = l; u < n.animations.length; u++)
(d = (h = n.animations[u]).weight / c) && (h.currentValue.scaleAndAddToRef ? h.currentValue.scaleAndAddToRef(d, s) : s += h.currentValue * d);
for (u = 0; u < n.additiveAnimations.length; u++) {
var h, d;
(d = (h = n.additiveAnimations[u]).weight) && (h.currentValue.scaleAndAddToRef ? h.currentValue.scaleAndAddToRef(d, s) : s += h.currentValue * d)
}
}
t[i] = s
}
t._lateAnimationHolders = {}
}
this._registeredForLateAnimationBindings.reset()
}
}
,
yn.prototype.copyAnimationRange = function(e, t, i, n, r) {
void 0 === n && (n = !1),
void 0 === r && (r = null),
0 === this.animations.length && (this.animations.push(new Qe(this.name,"_matrix",e.animations[0].framePerSecond,Qe.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(), _ = n && p && d && this.length && d !== this.length, m = _ && f && p ? f.length / p.length : 1, g = n && !f && r && (1 !== r.x || 1 !== r.y || 1 !== r.z), v = this.animations[0].getKeys(), y = 0, b = h.length; y < b; y++)
(a = h[y]).frame >= c && a.frame <= u && (n ? (l = a.value.clone(),
_ ? (s = l.getTranslation(),
l.setTranslation(s.scaleInPlace(m))) : g && r ? (s = l.getTranslation(),
l.setTranslation(s.multiplyInPlace(r))) : 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 Tn, En = function() {
this.enableBlending = !1,
this.blendingSpeed = .01,
this.loopMode = Qe.ANIMATIONLOOPMODE_CYCLE
};
!function(e) {
e[e.CW = 0] = "CW",
e[e.CCW = 1] = "CCW"
}(Tn || (Tn = {}));
var Sn = function() {
function e() {}
return e.Interpolate = function(e, t, i, n, r) {
for (var o = 1 - 3 * n + 3 * t, a = 3 * n - 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) * r + Math.pow(l, 3)
}
,
e
}()
, An = 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 n = i.subtract(t);
return new e(Math.atan2(n.y, n.x))
}
,
e.FromRadians = function(t) {
return new e(t)
}
,
e.FromDegrees = function(t) {
return new e(t * Math.PI / 180)
}
,
e
}()
, xn = function(e, t, i) {
this.startPoint = e,
this.midPoint = t,
this.endPoint = i;
var n = Math.pow(t.x, 2) + Math.pow(t.y, 2)
, r = (Math.pow(e.x, 2) + Math.pow(e.y, 2) - n) / 2
, o = (n - 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((r * (t.y - i.y) - o * (e.y - t.y)) / a,((e.x - t.x) * o - (t.x - i.x) * r) / a),
this.radius = this.centerPoint.subtract(this.startPoint).length(),
this.startAngle = An.BetweenTwoPoints(this.centerPoint, this.startPoint);
var s = this.startAngle.degrees()
, l = An.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees()
, c = An.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 ? Tn.CW : Tn.CCW,
this.angle = An.FromDegrees(this.orientation === Tn.CW ? s - c : c - s)
}
, Rn = 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)
, n = this._points[this._points.length - 1];
return this._points.push(i),
this._length += i.subtract(n).length(),
this
}
,
e.prototype.addArcTo = function(e, t, i, n, r) {
if (void 0 === r && (r = 36),
this.closed)
return this;
var o = this._points[this._points.length - 1]
, a = new A(e,t)
, s = new A(i,n)
, l = new xn(o,a,s)
, c = l.angle.radians() / r;
l.orientation === Tn.CW && (c *= -1);
for (var u = l.startAngle.radians() + c, h = 0; h < r; 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.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.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, n = 0; n < this._points.length; n++) {
var r = (n + 1) % this._points.length
, o = this._points[n]
, a = this._points[r].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
}()
, Cn = function() {
function e(e, t, i, n) {
void 0 === t && (t = null),
void 0 === n && (n = !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: x.Zero(),
previousPointArrayIndex: 0,
position: 0,
subPosition: 0,
interpolateReady: !1,
interpolationMatrix: P.Identity()
};
for (var r = 0; r < e.length; r++)
this._curve[r] = e[r].clone();
this._raw = i || !1,
this._alignTangentsWithPath = n,
this._compute(t, n)
}
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 ? x.TransformCoordinates(x.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 ? x.TransformCoordinates(x.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 ? x.TransformCoordinates(x.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, n = 0; n < this._curve.length - 1; n++) {
var r = this._curve[n + 0]
, o = this._curve[n + 1].subtract(r).normalize()
, a = this._distances[n + 1] - this._distances[n + 0]
, s = Math.min(Math.max(x.Dot(o, e.subtract(r).normalize()), 0) * x.Distance(r, e) / a, 1)
, l = x.Distance(r.add(o.scale(s * a)), e);
l < t && (t = l,
i = (this._distances[n + 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 n = t;
t = i,
i = n
}
var r = 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, r.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 n = 0; n < e.length; n++)
this._curve[n].x = e[n].x,
this._curve[n].y = e[n].y,
this._curve[n].z = e[n].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 n, r, 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] = x.Cross(l, this._normals[0]),
this._raw || this._binormals[0].normalize(),
this._distances[0] = 0;
for (var u = 1; u < i; u++)
n = this._getLastNonNullVector(u),
u < i - 1 && (r = this._getFirstNonNullVector(u),
this._tangents[u] = t ? r : n.add(r),
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] = x.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] = x.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, n = e.length();
if (0 === n && (n = 1),
null == t) {
var r;
r = d.WithinEpsilon(Math.abs(e.y) / n, 1, m) ? d.WithinEpsilon(Math.abs(e.x) / n, 1, m) ? d.WithinEpsilon(Math.abs(e.z) / n, 1, m) ? x.Zero() : new x(0,0,1) : new x(1,0,0) : new x(0,-1,0),
i = x.Cross(e, r)
} else
i = x.Cross(e, t),
x.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 n, r = i[0], o = 0, a = e * this.length(), s = 1; s < i.length; s++) {
n = i[s];
var l = x.Distance(r, n);
if ((o += l) === a)
return this._setPointAtData(e, 1, n, s, t);
if (o > a) {
var c = (o - a) / l
, u = r.subtract(n)
, h = n.add(u.scaleInPlace(c));
return this._setPointAtData(e, 1 - c, h, s - 1, t)
}
r = n
}
return this._pointAtData
}
,
e.prototype._setPointAtData = function(e, t, i, n, r) {
return this._pointAtData.point = i,
this._pointAtData.position = e,
this._pointAtData.subPosition = t,
this._pointAtData.previousPointArrayIndex = n,
this._pointAtData.interpolateReady = r,
r && this._updateInterpolationMatrix(),
this._pointAtData
}
,
e.prototype._updateInterpolationMatrix = function() {
this._pointAtData.interpolationMatrix = P.Identity();
var e = this._pointAtData.previousPointArrayIndex;
if (e !== this._tangents.length - 1) {
var t = e + 1
, i = this._tangents[e].clone()
, n = this._normals[e].clone()
, r = this._binormals[e].clone()
, o = this._tangents[t].clone()
, a = this._normals[t].clone()
, s = this._binormals[t].clone()
, l = C.RotationQuaternionFromAxis(n, r, i)
, c = C.RotationQuaternionFromAxis(a, s, o);
C.Slerp(l, c, this._pointAtData.subPosition).toRotationMatrix(this._pointAtData.interpolationMatrix)
}
}
,
e
}()
, Pn = function() {
function e(e) {
this._length = 0,
this._points = e,
this._length = this._computeLength(e)
}
return e.CreateQuadraticBezier = function(t, i, n, r) {
r = r > 2 ? r : 3;
for (var o = new Array, a = function(e, t, i, n) {
return (1 - e) * (1 - e) * t + 2 * e * (1 - e) * i + e * e * n
}, s = 0; s <= r; s++)
o.push(new x(a(s / r, t.x, i.x, n.x),a(s / r, t.y, i.y, n.y),a(s / r, t.z, i.z, n.z)));
return new e(o)
}
,
e.CreateCubicBezier = function(t, i, n, r, o) {
o = o > 3 ? o : 4;
for (var a = new Array, s = function(e, t, i, n, r) {
return (1 - e) * (1 - e) * (1 - e) * t + 3 * e * (1 - e) * (1 - e) * i + 3 * e * e * (1 - e) * n + e * e * e * r
}, l = 0; l <= o; l++)
a.push(new x(s(l / o, t.x, i.x, n.x, r.x),s(l / o, t.y, i.y, n.y, r.y),s(l / o, t.z, i.z, n.z, r.z)));
return new e(a)
}
,
e.CreateHermiteSpline = function(t, i, n, r, o) {
for (var a = new Array, s = 1 / o, l = 0; l <= o; l++)
a.push(x.Hermite(t, i, n, r, l * s));
return new e(a)
}
,
e.CreateCatmullRomSpline = function(t, i, n) {
var r = new Array
, o = 1 / i
, a = 0;
if (n) {
for (var s = t.length, l = 0; l < s; l++) {
a = 0;
for (var c = 0; c < i; c++)
r.push(x.CatmullRom(t[l % s], t[(l + 1) % s], t[(l + 2) % s], t[(l + 3) % s], a)),
a += o
}
r.push(r[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++)
r.push(x.CatmullRom(u[l], u[l + 1], u[l + 2], u[l + 3], a)),
a += o;
l--,
r.push(x.CatmullRom(u[l], u[l + 1], u[l + 2], u[l + 3], a))
}
return new e(r)
}
,
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], n = this._points.slice(), r = t.getPoints(), o = 1; o < r.length; o++)
n.push(r[o].subtract(r[0]).add(i));
return new e(n)
}
,
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
}()
, Mn = 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
}()
, In = function(e) {
function t() {
return null !== e && e.apply(this, arguments) || this
}
return U(t, e),
t.prototype.easeInCore = function(e) {
return e = Math.max(0, Math.min(1, e)),
1 - Math.sqrt(1 - e * e)
}
,
t
}(Mn)
, On = function(e) {
function t(t) {
void 0 === t && (t = 1);
var i = e.call(this) || this;
return i.amplitude = t,
i
}
return U(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
}(Mn)
, Dn = function(e) {
function t(t, i) {
void 0 === t && (t = 3),
void 0 === i && (i = 2);
var n = e.call(this) || this;
return n.bounces = t,
n.bounciness = i,
n
}
return U(t, e),
t.prototype.easeInCore = function(e) {
var t = Math.max(0, this.bounces)
, i = this.bounciness;
i <= 1 && (i = 1.001);
var n = Math.pow(i, t)
, r = 1 - i
, o = (1 - n) / r + .5 * n
, 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)) / (r * o)
, h = .5 * (u + (1 - Math.pow(i, c)) / (r * o))
, d = e - h
, p = h - u;
return -Math.pow(1 / i, t - l) / (p * p) * (d - p) * (d + p)
}
,
t
}(Mn)
, Nn = function(e) {
function t() {
return null !== e && e.apply(this, arguments) || this
}
return U(t, e),
t.prototype.easeInCore = function(e) {
return e * e * e
}
,
t
}(Mn)
, Ln = function(e) {
function t(t, i) {
void 0 === t && (t = 3),
void 0 === i && (i = 3);
var n = e.call(this) || this;
return n.oscillations = t,
n.springiness = i,
n
}
return U(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
}(Mn)
, Fn = function(e) {
function t(t) {
void 0 === t && (t = 2);
var i = e.call(this) || this;
return i.exponent = t,
i
}
return U(t, e),
t.prototype.easeInCore = function(e) {
return this.exponent <= 0 ? e : (Math.exp(this.exponent * e) - 1) / (Math.exp(this.exponent) - 1)
}
,
t
}(Mn)
, wn = function(e) {
function t(t) {
void 0 === t && (t = 2);
var i = e.call(this) || this;
return i.power = t,
i
}
return U(t, e),
t.prototype.easeInCore = function(e) {
var t = Math.max(0, this.power);
return Math.pow(e, t)
}
,
t
}(Mn)
, Bn = function(e) {
function t() {
return null !== e && e.apply(this, arguments) || this
}
return U(t, e),
t.prototype.easeInCore = function(e) {
return e * e
}
,
t
}(Mn)
, Un = function(e) {
function t() {
return null !== e && e.apply(this, arguments) || this
}
return U(t, e),
t.prototype.easeInCore = function(e) {
return e * e * e * e
}
,
t
}(Mn)
, Vn = function(e) {
function t() {
return null !== e && e.apply(this, arguments) || this
}
return U(t, e),
t.prototype.easeInCore = function(e) {
return e * e * e * e * e
}
,
t
}(Mn)
, kn = function(e) {
function t() {
return null !== e && e.apply(this, arguments) || this
}
return U(t, e),
t.prototype.easeInCore = function(e) {
return 1 - Math.sin(1.5707963267948966 * (1 - e))
}
,
t
}(Mn)
, Gn = function(e) {
function t(t, i, n, r) {
void 0 === t && (t = 0),
void 0 === i && (i = 0),
void 0 === n && (n = 1),
void 0 === r && (r = 1);
var o = e.call(this) || this;
return o.x1 = t,
o.y1 = i,
o.x2 = n,
o.y2 = r,
o
}
return U(t, e),
t.prototype.easeInCore = function(e) {
return Sn.Interpolate(e, this.x1, this.y1, this.x2, this.y2)
}
,
t
}(Mn)
, zn = 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
}()
, Wn = 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
}()
, Hn = function() {
function e(e, t) {
void 0 === t && (t = null),
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._parentContainer = null,
this.onAnimationEndObservable = new h,
this.onAnimationLoopObservable = new h,
this.onAnimationGroupLoopObservable = new h,
this.onAnimationGroupEndObservable = new h,
this.onAnimationGroupPauseObservable = new h,
this.onAnimationGroupPlayObservable = new h,
this.metadata = null,
this._scene = t || E.LastCreatedScene,
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, "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
}),
e.prototype.addTargetedAnimation = function(e, t) {
var i = new Wn;
i.animation = e,
i.target = t;
var n = e.getKeys();
return this._from > n[0].frame && (this._from = n[0].frame),
this._to < n[n.length - 1].frame && (this._to = n[n.length - 1].frame),
this._targetedAnimations.push(i),
i
}
,
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 n = this._targetedAnimations[i].animation.getKeys()
, r = n[0]
, o = n[n.length - 1];
if (r.frame > e) {
var a = {
frame: e,
value: r.value,
inTangent: r.inTangent,
outTangent: r.outTangent,
interpolation: r.interpolation
};
n.splice(0, 0, a)
}
o.frame < t && (a = {
frame: t,
value: o.value,
inTangent: o.inTangent,
outTangent: o.outTangent,
interpolation: o.interpolation
},
n.push(a))
}
return this._from = e,
this._to = t,
this
}
,
e.prototype._processLoop = function(e, t, i) {
var n = this;
e.onAnimationLoop = function() {
n.onAnimationLoopObservable.notifyObservers(t),
n._animationLoopFlags[i] || (n._animationLoopFlags[i] = !0,
n._animationLoopCount++,
n._animationLoopCount === n._targetedAnimations.length && (n.onAnimationGroupLoopObservable.notifyObservers(n),
n._animationLoopCount = 0,
n._animationLoopFlags = []))
}
}
,
e.prototype.start = function(e, t, i, n, r) {
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 = [];
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 !== n ? n : s._to, e, t, void 0, void 0, void 0 !== r ? r : s._isAdditive);
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._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();
return 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 = [],
this._animatables = [];
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, n) {
void 0 === n && (n = !1);
for (var r = new e(t || this.name,this._scene), o = 0, a = this._targetedAnimations; o < a.length; o++) {
var s = a[o];
r.addTargetedAnimation(n ? s.animation.clone() : s.animation, i ? i(s.target) : s.target)
}
return r
}
,
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 ye && ye.HasTags(this) && (e.tags = ye.GetTags(this)),
this.metadata && (e.metadata = this.metadata),
e
}
,
e.Parse = function(t, i) {
for (var n = new e(t.name,i), r = 0; r < t.targetedAnimations.length; r++) {
var o = t.targetedAnimations[r]
, a = Qe.Parse(o.animation)
, s = o.targetId;
if ("influence" === o.animation.property) {
var l = i.getMorphTargetById(s);
l && n.addTargetedAnimation(a, l)
} else {
var c = i.getNodeById(s);
null != c && n.addTargetedAnimation(a, c)
}
}
return null !== t.from && null !== t.to && n.normalize(t.from, t.to),
ye && ye.AddTagsTo(n, t.tags),
void 0 !== t.metadata && (n.metadata = t.metadata),
n
}
,
e.MakeAnimationAdditive = function(e, t, i, n, r) {
void 0 === t && (t = 0),
void 0 === n && (n = !1);
var o = e;
n && (o = e.clone(r || o.name));
for (var a = o.targetedAnimations, s = 0; s < a.length; s++) {
var l = a[s];
Qe.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
}()
, Xn = 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 x(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 jn(e, t, i) {
try {
var n = e.next();
n.done ? t(n) : n.value ? n.value.then((function() {
n.value = void 0,
t(n)
}
), i) : t(n)
} catch (e) {
i(e)
}
}
function Yn(e) {
var t;
return void 0 === e && (e = 25),
function(i, n, r) {
var o = performance.now();
void 0 === t || o - t > e ? (t = o,
setTimeout((function() {
jn(i, n, r)
}
), 0)) : jn(i, n, r)
}
}
function Kn(e, t, i, n, r) {
var o = function() {
var a, s = function(e) {
e.done ? i(e.value) : void 0 === a ? a = !0 : o()
};
do {
a = void 0,
r && r.aborted ? n(new Error("Aborted")) : t(e, s, n),
void 0 === a && (a = !1)
} while (a)
};
o()
}
function Qn(e, t) {
var i;
return Kn(e, jn, (function(e) {
return i = e
}
), (function(e) {
throw e
}
), t),
i
}
function qn(e, t, i) {
return new Promise((function(n, r) {
Kn(e, t, n, r, i)
}
))
}
function Zn(e, t) {
return function() {
for (var i = [], n = 0; n < arguments.length; n++)
i[n] = arguments[n];
return Qn(e.apply(void 0, i), t)
}
}
function Jn(e, t, i) {
return function() {
for (var n = [], r = 0; r < arguments.length; r++)
n[r] = arguments[r];
return qn(e.apply(void 0, n), t, i)
}
}
var $n = function() {
function e() {
this._applyTo = Zn(this._applyToCoroutine.bind(this))
}
return e.prototype.set = function(e, t) {
switch (e.length || K.Warn("Setting vertex data kind '".concat(t, "' with an empty array")),
t) {
case Bi.PositionKind:
this.positions = e;
break;
case Bi.NormalKind:
this.normals = e;
break;
case Bi.TangentKind:
this.tangents = e;
break;
case Bi.UVKind:
this.uvs = e;
break;
case Bi.UV2Kind:
this.uvs2 = e;
break;
case Bi.UV3Kind:
this.uvs3 = e;
break;
case Bi.UV4Kind:
this.uvs4 = e;
break;
case Bi.UV5Kind:
this.uvs5 = e;
break;
case Bi.UV6Kind:
this.uvs6 = e;
break;
case Bi.ColorKind:
this.colors = e;
break;
case Bi.MatricesIndicesKind:
this.matricesIndices = e;
break;
case Bi.MatricesWeightsKind:
this.matricesWeights = e;
break;
case Bi.MatricesIndicesExtraKind:
this.matricesIndicesExtra = e;
break;
case Bi.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) {
return void 0 === t && (t = !1),
z(this, (function(n) {
switch (n.label) {
case 0:
return this.positions ? (e.setVerticesData(Bi.PositionKind, this.positions, t),
i ? [4] : [3, 2]) : [3, 2];
case 1:
n.sent(),
n.label = 2;
case 2:
return this.normals ? (e.setVerticesData(Bi.NormalKind, this.normals, t),
i ? [4] : [3, 4]) : [3, 4];
case 3:
n.sent(),
n.label = 4;
case 4:
return this.tangents ? (e.setVerticesData(Bi.TangentKind, this.tangents, t),
i ? [4] : [3, 6]) : [3, 6];
case 5:
n.sent(),
n.label = 6;
case 6:
return this.uvs ? (e.setVerticesData(Bi.UVKind, this.uvs, t),
i ? [4] : [3, 8]) : [3, 8];
case 7:
n.sent(),
n.label = 8;
case 8:
return this.uvs2 ? (e.setVerticesData(Bi.UV2Kind, this.uvs2, t),
i ? [4] : [3, 10]) : [3, 10];
case 9:
n.sent(),
n.label = 10;
case 10:
return this.uvs3 ? (e.setVerticesData(Bi.UV3Kind, this.uvs3, t),
i ? [4] : [3, 12]) : [3, 12];
case 11:
n.sent(),
n.label = 12;
case 12:
return this.uvs4 ? (e.setVerticesData(Bi.UV4Kind, this.uvs4, t),
i ? [4] : [3, 14]) : [3, 14];
case 13:
n.sent(),
n.label = 14;
case 14:
return this.uvs5 ? (e.setVerticesData(Bi.UV5Kind, this.uvs5, t),
i ? [4] : [3, 16]) : [3, 16];
case 15:
n.sent(),
n.label = 16;
case 16:
return this.uvs6 ? (e.setVerticesData(Bi.UV6Kind, this.uvs6, t),
i ? [4] : [3, 18]) : [3, 18];
case 17:
n.sent(),
n.label = 18;
case 18:
return this.colors ? (e.setVerticesData(Bi.ColorKind, this.colors, t),
i ? [4] : [3, 20]) : [3, 20];
case 19:
n.sent(),
n.label = 20;
case 20:
return this.matricesIndices ? (e.setVerticesData(Bi.MatricesIndicesKind, this.matricesIndices, t),
i ? [4] : [3, 22]) : [3, 22];
case 21:
n.sent(),
n.label = 22;
case 22:
return this.matricesWeights ? (e.setVerticesData(Bi.MatricesWeightsKind, this.matricesWeights, t),
i ? [4] : [3, 24]) : [3, 24];
case 23:
n.sent(),
n.label = 24;
case 24:
return this.matricesIndicesExtra ? (e.setVerticesData(Bi.MatricesIndicesExtraKind, this.matricesIndicesExtra, t),
i ? [4] : [3, 26]) : [3, 26];
case 25:
n.sent(),
n.label = 26;
case 26:
return this.matricesWeightsExtra ? (e.setVerticesData(Bi.MatricesWeightsExtraKind, this.matricesWeightsExtra, t),
i ? [4] : [3, 28]) : [3, 28];
case 27:
n.sent(),
n.label = 28;
case 28:
return this.indices ? (e.setIndices(this.indices, null, t),
i ? [4] : [3, 30]) : [3, 31];
case 29:
n.sent(),
n.label = 30;
case 30:
return [3, 32];
case 31:
e.setIndices([], null),
n.label = 32;
case 32:
return [2, this]
}
}
))
}
,
e.prototype._update = function(e, t, i) {
return this.positions && e.updateVerticesData(Bi.PositionKind, this.positions, t, i),
this.normals && e.updateVerticesData(Bi.NormalKind, this.normals, t, i),
this.tangents && e.updateVerticesData(Bi.TangentKind, this.tangents, t, i),
this.uvs && e.updateVerticesData(Bi.UVKind, this.uvs, t, i),
this.uvs2 && e.updateVerticesData(Bi.UV2Kind, this.uvs2, t, i),
this.uvs3 && e.updateVerticesData(Bi.UV3Kind, this.uvs3, t, i),
this.uvs4 && e.updateVerticesData(Bi.UV4Kind, this.uvs4, t, i),
this.uvs5 && e.updateVerticesData(Bi.UV5Kind, this.uvs5, t, i),
this.uvs6 && e.updateVerticesData(Bi.UV6Kind, this.uvs6, t, i),
this.colors && e.updateVerticesData(Bi.ColorKind, this.colors, t, i),
this.matricesIndices && e.updateVerticesData(Bi.MatricesIndicesKind, this.matricesIndices, t, i),
this.matricesWeights && e.updateVerticesData(Bi.MatricesWeightsKind, this.matricesWeights, t, i),
this.matricesIndicesExtra && e.updateVerticesData(Bi.MatricesIndicesExtraKind, this.matricesIndicesExtra, t, i),
this.matricesWeightsExtra && e.updateVerticesData(Bi.MatricesWeightsExtraKind, this.matricesWeightsExtra, t, i),
this.indices && e.setIndices(this.indices, null),
this
}
,
e._TransformVector3Coordinates = function(e, t, i, n) {
void 0 === i && (i = 0),
void 0 === n && (n = e.length);
for (var r = I.Vector3[0], o = I.Vector3[1], a = i; a < i + n; a += 3)
x.FromArrayToRef(e, a, r),
x.TransformCoordinatesToRef(r, t, o),
e[a] = o.x,
e[a + 1] = o.y,
e[a + 2] = o.z
}
,
e._TransformVector3Normals = function(e, t, i, n) {
void 0 === i && (i = 0),
void 0 === n && (n = e.length);
for (var r = I.Vector3[0], o = I.Vector3[1], a = i; a < i + n; a += 3)
x.FromArrayToRef(e, a, r),
x.TransformNormalToRef(r, t, o),
e[a] = o.x,
e[a + 1] = o.y,
e[a + 2] = o.z
}
,
e._TransformVector4Normals = function(e, t, i, n) {
void 0 === i && (i = 0),
void 0 === n && (n = e.length);
for (var r = I.Vector4[0], o = I.Vector4[1], a = i; a < i + n; a += 4)
R.FromArrayToRef(e, a, r),
R.TransformNormalToRef(r, 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 n = t; n < t + i; n += 3) {
var r = e[n + 1];
e[n + 1] = e[n + 2],
e[n + 2] = r
}
}
,
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.merge = function(e, t, i) {
void 0 === t && (t = !1),
void 0 === i && (i = !1);
var n = Array.isArray(e) ? e.map((function(e) {
return [e, void 0]
}
)) : [[e, void 0]];
return Qn(this._mergeCoroutine(void 0, n, t, !1, i))
}
,
e.prototype._mergeCoroutine = function(t, i, n, r, o) {
var a, s, l, c, u, h, d, p, f, _, m, g, v, y, b, T, E, S, A, x = this;
return void 0 === n && (n = !1),
z(this, (function(R) {
switch (R.label) {
case 0:
for (this._validate(),
a = i.map((function(e) {
return e[0]
}
)),
s = 0,
l = a; s < l.length; s++)
if ((v = l[s])._validate(),
!this.normals != !v.normals || !this.tangents != !v.tangents || !this.uvs != !v.uvs || !this.uvs2 != !v.uvs2 || !this.uvs3 != !v.uvs3 || !this.uvs4 != !v.uvs4 || !this.uvs5 != !v.uvs5 || !this.uvs6 != !v.uvs6 || !this.colors != !v.colors || !this.matricesIndices != !v.matricesIndices || !this.matricesWeights != !v.matricesWeights || !this.matricesIndicesExtra != !v.matricesIndicesExtra || !this.matricesWeightsExtra != !v.matricesWeightsExtra)
throw new Error("Cannot merge vertex data that do not have the same set of attributes");
if (c = a.reduce((function(e, t) {
var i, n;
return e + (null !== (n = null === (i = t.indices) || void 0 === i ? void 0 : i.length) && void 0 !== n ? n : 0)
}
), null !== (E = null === (T = this.indices) || void 0 === T ? void 0 : T.length) && void 0 !== E ? E : 0),
u = o || a.some((function(e) {
return e.indices === x.indices
}
)),
h = u ? null === (S = this.indices) || void 0 === S ? void 0 : S.slice() : this.indices,
!(c > 0))
return [3, 4];
d = null !== (A = null == h ? void 0 : h.length) && void 0 !== A ? A : 0,
h || (h = new Array(c)),
h.length !== c && (Array.isArray(h) ? h.length = c : ((p = n || h instanceof Uint32Array ? new Uint32Array(c) : new Uint16Array(c)).set(h),
h = p),
t && t.determinant() < 0 && e._FlipFaces(h, 0, d)),
f = this.positions ? this.positions.length / 3 : 0,
_ = 0,
m = i,
R.label = 1;
case 1:
if (!(_ < m.length))
return [3, 4];
if (g = m[_],
v = g[0],
y = g[1],
!v.indices)
return [3, 3];
for (b = 0; b < v.indices.length; b++)
h[d + b] = v.indices[b] + f;
return y && y.determinant() < 0 && e._FlipFaces(h, d, v.indices.length),
f += v.positions.length / 3,
d += v.indices.length,
r ? [4] : [3, 3];
case 2:
R.sent(),
R.label = 3;
case 3:
return _++,
[3, 1];
case 4:
return this.indices = h,
this.positions = e._MergeElement(Bi.PositionKind, this.positions, t, i.map((function(e) {
return [e[0].positions, e[1]]
}
))),
r ? [4] : [3, 6];
case 5:
R.sent(),
R.label = 6;
case 6:
return this.normals = e._MergeElement(Bi.NormalKind, this.normals, t, i.map((function(e) {
return [e[0].normals, e[1]]
}
))),
r ? [4] : [3, 8];
case 7:
R.sent(),
R.label = 8;
case 8:
return this.tangents = e._MergeElement(Bi.TangentKind, this.tangents, t, i.map((function(e) {
return [e[0].tangents, e[1]]
}
))),
r ? [4] : [3, 10];
case 9:
R.sent(),
R.label = 10;
case 10:
return this.uvs = e._MergeElement(Bi.UVKind, this.uvs, t, i.map((function(e) {
return [e[0].uvs, e[1]]
}
))),
r ? [4] : [3, 12];
case 11:
R.sent(),
R.label = 12;
case 12:
return this.uvs2 = e._MergeElement(Bi.UV2Kind, this.uvs2, t, i.map((function(e) {
return [e[0].uvs2, e[1]]
}
))),
r ? [4] : [3, 14];
case 13:
R.sent(),
R.label = 14;
case 14:
return this.uvs3 = e._MergeElement(Bi.UV3Kind, this.uvs3, t, i.map((function(e) {
return [e[0].uvs3, e[1]]
}
))),
r ? [4] : [3, 16];
case 15:
R.sent(),
R.label = 16;
case 16:
return this.uvs4 = e._MergeElement(Bi.UV4Kind, this.uvs4, t, i.map((function(e) {
return [e[0].uvs4, e[1]]
}
))),
r ? [4] : [3, 18];
case 17:
R.sent(),
R.label = 18;
case 18:
return this.uvs5 = e._MergeElement(Bi.UV5Kind, this.uvs5, t, i.map((function(e) {
return [e[0].uvs5, e[1]]
}
))),
r ? [4] : [3, 20];
case 19:
R.sent(),
R.label = 20;
case 20:
return this.uvs6 = e._MergeElement(Bi.UV6Kind, this.uvs6, t, i.map((function(e) {
return [e[0].uvs6, e[1]]
}
))),
r ? [4] : [3, 22];
case 21:
R.sent(),
R.label = 22;
case 22:
return this.colors = e._MergeElement(Bi.ColorKind, this.colors, t, i.map((function(e) {
return [e[0].colors, e[1]]
}
))),
r ? [4] : [3, 24];
case 23:
R.sent(),
R.label = 24;
case 24:
return this.matricesIndices = e._MergeElement(Bi.MatricesIndicesKind, this.matricesIndices, t, i.map((function(e) {
return [e[0].matricesIndices, e[1]]
}
))),
r ? [4] : [3, 26];
case 25:
R.sent(),
R.label = 26;
case 26:
return this.matricesWeights = e._MergeElement(Bi.MatricesWeightsKind, this.matricesWeights, t, i.map((function(e) {
return [e[0].matricesWeights, e[1]]
}
))),
r ? [4] : [3, 28];
case 27:
R.sent(),
R.label = 28;
case 28:
return this.matricesIndicesExtra = e._MergeElement(Bi.MatricesIndicesExtraKind, this.matricesIndicesExtra, t, i.map((function(e) {
return [e[0].matricesIndicesExtra, e[1]]
}
))),
r ? [4] : [3, 30];
case 29:
R.sent(),
R.label = 30;
case 30:
return this.matricesWeightsExtra = e._MergeElement(Bi.MatricesWeightsExtraKind, this.matricesWeightsExtra, t, i.map((function(e) {
return [e[0].matricesWeightsExtra, e[1]]
}
))),
[2, this]
}
}
))
}
,
e._MergeElement = function(t, i, n, r) {
var o = r.filter((function(e) {
return null !== e[0] && void 0 !== e[0]
}
));
if (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 === Bi.PositionKind ? e._TransformVector3Coordinates : t === Bi.NormalKind ? e._TransformVector3Normals : t === Bi.TangentKind ? e._TransformVector4Normals : function() {}
;
if (i instanceof Float32Array) {
var l = new Float32Array(a);
l.set(i),
n && s(l, n, 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];
n && s(_, n, 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 ft("Positions are required",pt.MeshInvalidPositionsError);
var e = function(e, t) {
var i = Bi.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(Bi.PositionKind, this.positions)
, i = function(i, n) {
var r = e(i, n);
if (r !== t)
throw new Error("The " + i + "s element count (" + r + ") does not match the positions count (" + t + ")")
};
this.normals && i(Bi.NormalKind, this.normals),
this.tangents && i(Bi.TangentKind, this.tangents),
this.uvs && i(Bi.UVKind, this.uvs),
this.uvs2 && i(Bi.UV2Kind, this.uvs2),
this.uvs3 && i(Bi.UV3Kind, this.uvs3),
this.uvs4 && i(Bi.UV4Kind, this.uvs4),
this.uvs5 && i(Bi.UV5Kind, this.uvs5),
this.uvs6 && i(Bi.UV6Kind, this.uvs6),
this.colors && i(Bi.ColorKind, this.colors),
this.matricesIndices && i(Bi.MatricesIndicesKind, this.matricesIndices),
this.matricesWeights && i(Bi.MatricesWeightsKind, this.matricesWeights),
this.matricesIndicesExtra && i(Bi.MatricesIndicesExtraKind, this.matricesIndicesExtra),
this.matricesWeightsExtra && i(Bi.MatricesWeightsExtraKind, this.matricesWeightsExtra)
}
,
e.prototype.serialize = function() {
var e = {};
return this.positions && (e.positions = this.positions),
this.normals && (e.normals = this.normals),
this.tangents && (e.tangents = this.tangents),
this.uvs && (e.uvs = this.uvs),
this.uvs2 && (e.uvs2 = this.uvs2),
this.uvs3 && (e.uvs3 = this.uvs3),
this.uvs4 && (e.uvs4 = this.uvs4),
this.uvs5 && (e.uvs5 = this.uvs5),
this.uvs6 && (e.uvs6 = this.uvs6),
this.colors && (e.colors = this.colors),
this.matricesIndices && (e.matricesIndices = this.matricesIndices,
e.matricesIndices._isExpanded = !0),
this.matricesWeights && (e.matricesWeights = this.matricesWeights),
this.matricesIndicesExtra && (e.matricesIndicesExtra = this.matricesIndicesExtra,
e.matricesIndicesExtra._isExpanded = !0),
this.matricesWeightsExtra && (e.matricesWeightsExtra = this.matricesWeightsExtra),
e.indices = this.indices,
e
}
,
e.ExtractFromMesh = function(t, i, n) {
return e._ExtractFrom(t, i, n)
}
,
e.ExtractFromGeometry = function(t, i, n) {
return e._ExtractFrom(t, i, n)
}
,
e._ExtractFrom = function(t, i, n) {
var r = new e;
return t.isVerticesDataPresent(Bi.PositionKind) && (r.positions = t.getVerticesData(Bi.PositionKind, i, n)),
t.isVerticesDataPresent(Bi.NormalKind) && (r.normals = t.getVerticesData(Bi.NormalKind, i, n)),
t.isVerticesDataPresent(Bi.TangentKind) && (r.tangents = t.getVerticesData(Bi.TangentKind, i, n)),
t.isVerticesDataPresent(Bi.UVKind) && (r.uvs = t.getVerticesData(Bi.UVKind, i, n)),
t.isVerticesDataPresent(Bi.UV2Kind) && (r.uvs2 = t.getVerticesData(Bi.UV2Kind, i, n)),
t.isVerticesDataPresent(Bi.UV3Kind) && (r.uvs3 = t.getVerticesData(Bi.UV3Kind, i, n)),
t.isVerticesDataPresent(Bi.UV4Kind) && (r.uvs4 = t.getVerticesData(Bi.UV4Kind, i, n)),
t.isVerticesDataPresent(Bi.UV5Kind) && (r.uvs5 = t.getVerticesData(Bi.UV5Kind, i, n)),
t.isVerticesDataPresent(Bi.UV6Kind) && (r.uvs6 = t.getVerticesData(Bi.UV6Kind, i, n)),
t.isVerticesDataPresent(Bi.ColorKind) && (r.colors = t.getVerticesData(Bi.ColorKind, i, n)),
t.isVerticesDataPresent(Bi.MatricesIndicesKind) && (r.matricesIndices = t.getVerticesData(Bi.MatricesIndicesKind, i, n)),
t.isVerticesDataPresent(Bi.MatricesWeightsKind) && (r.matricesWeights = t.getVerticesData(Bi.MatricesWeightsKind, i, n)),
t.isVerticesDataPresent(Bi.MatricesIndicesExtraKind) && (r.matricesIndicesExtra = t.getVerticesData(Bi.MatricesIndicesExtraKind, i, n)),
t.isVerticesDataPresent(Bi.MatricesWeightsExtraKind) && (r.matricesWeightsExtra = t.getVerticesData(Bi.MatricesWeightsExtraKind, i, n)),
r.indices = t.getIndices(i, n),
r
}
,
e.CreateRibbon = function(e) {
throw be("ribbonBuilder")
}
,
e.CreateBox = function(e) {
throw be("boxBuilder")
}
,
e.CreateTiledBox = function(e) {
throw be("tiledBoxBuilder")
}
,
e.CreateTiledPlane = function(e) {
throw be("tiledPlaneBuilder")
}
,
e.CreateSphere = function(e) {
throw be("sphereBuilder")
}
,
e.CreateCylinder = function(e) {
throw be("cylinderBuilder")
}
,
e.CreateTorus = function(e) {
throw be("torusBuilder")
}
,
e.CreateLineSystem = function(e) {
throw be("linesBuilder")
}
,
e.CreateDashedLines = function(e) {
throw be("linesBuilder")
}
,
e.CreateGround = function(e) {
throw be("groundBuilder")
}
,
e.CreateTiledGround = function(e) {
throw be("groundBuilder")
}
,
e.CreateGroundFromHeightMap = function(e) {
throw be("groundBuilder")
}
,
e.CreatePlane = function(e) {
throw be("planeBuilder")
}
,
e.CreateDisc = function(e) {
throw be("discBuilder")
}
,
e.CreatePolygon = function(e, t, i, n, r, o, a) {
throw be("polygonBuilder")
}
,
e.CreateIcoSphere = function(e) {
throw be("icoSphereBuilder")
}
,
e.CreatePolyhedron = function(e) {
throw be("polyhedronBuilder")
}
,
e.CreateCapsule = function(e) {
throw void 0 === e && (e = {
orientation: x.Up(),
subdivisions: 2,
tessellation: 16,
height: 1,
radius: .25,
capSubdivisions: 6
}),
be("capsuleBuilder")
}
,
e.CreateTorusKnot = function(e) {
throw be("torusKnotBuilder")
}
,
e.ComputeNormals = function(e, t, i, n) {
var r = 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
, A = !1
, R = !1
, C = !1
, P = !1
, M = 1
, I = 0
, O = null;
n && (A = !!n.facetNormals,
R = !!n.facetPositions,
C = !!n.facetPartitioning,
M = !0 === n.useRightHandedSystem ? -1 : 1,
I = n.ratio || 0,
P = !!n.depthSort,
O = n.distanceTo,
P && void 0 === O && (O = x.Zero()));
var D = 0
, N = 0
, L = 0
, F = 0;
for (C && n && n.bbSize && (D = n.subDiv.X * I / n.bbSize.x,
N = n.subDiv.Y * I / n.bbSize.y,
L = n.subDiv.Z * I / n.bbSize.z,
F = n.subDiv.max * n.subDiv.max,
n.facetPartitioning.length = 0),
r = 0; r < e.length; r++)
i[r] = 0;
var w = t.length / 3 | 0;
for (r = 0; r < w; r++) {
if (m = 1 + (_ = 3 * t[3 * r]),
g = _ + 2,
y = 1 + (v = 3 * t[3 * r + 1]),
b = v + 2,
E = 1 + (T = 3 * t[3 * r + 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 = M * (a * (u = e[S] - e[b]) - s * c),
d = M * (s * l - o * u),
p = M * (o * c - a * l),
h /= f = 0 === (f = Math.sqrt(h * h + d * d + p * p)) ? 1 : f,
d /= f,
p /= f,
A && n && (n.facetNormals[r].x = h,
n.facetNormals[r].y = d,
n.facetNormals[r].z = p),
R && n && (n.facetPositions[r].x = (e[_] + e[v] + e[T]) / 3,
n.facetPositions[r].y = (e[m] + e[y] + e[E]) / 3,
n.facetPositions[r].z = (e[g] + e[b] + e[S]) / 3),
C && n) {
var B = Math.floor((n.facetPositions[r].x - n.bInfo.minimum.x * I) * D)
, U = Math.floor((n.facetPositions[r].y - n.bInfo.minimum.y * I) * N)
, V = Math.floor((n.facetPositions[r].z - n.bInfo.minimum.z * I) * L)
, k = Math.floor((e[_] - n.bInfo.minimum.x * I) * D)
, G = Math.floor((e[m] - n.bInfo.minimum.y * I) * N)
, z = Math.floor((e[g] - n.bInfo.minimum.z * I) * L)
, W = Math.floor((e[v] - n.bInfo.minimum.x * I) * D)
, H = Math.floor((e[y] - n.bInfo.minimum.y * I) * N)
, X = Math.floor((e[b] - n.bInfo.minimum.z * I) * L)
, j = Math.floor((e[T] - n.bInfo.minimum.x * I) * D)
, Y = Math.floor((e[E] - n.bInfo.minimum.y * I) * N)
, K = Math.floor((e[S] - n.bInfo.minimum.z * I) * L)
, Q = k + n.subDiv.max * G + F * z
, q = W + n.subDiv.max * H + F * X
, Z = j + n.subDiv.max * Y + F * K
, J = B + n.subDiv.max * U + F * V;
n.facetPartitioning[J] = n.facetPartitioning[J] ? n.facetPartitioning[J] : new Array,
n.facetPartitioning[Q] = n.facetPartitioning[Q] ? n.facetPartitioning[Q] : new Array,
n.facetPartitioning[q] = n.facetPartitioning[q] ? n.facetPartitioning[q] : new Array,
n.facetPartitioning[Z] = n.facetPartitioning[Z] ? n.facetPartitioning[Z] : new Array,
n.facetPartitioning[Q].push(r),
q != Q && n.facetPartitioning[q].push(r),
Z != q && Z != Q && n.facetPartitioning[Z].push(r),
J != Q && J != q && J != Z && n.facetPartitioning[J].push(r)
}
if (P && n && n.facetPositions) {
var $ = n.depthSortedFacets[r];
$.ind = 3 * r,
$.sqDistance = x.DistanceSquared(n.facetPositions[r], 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 (r = 0; r < i.length / 3; r++)
h = i[3 * r],
d = i[3 * r + 1],
p = i[3 * r + 2],
h /= f = 0 === (f = Math.sqrt(h * h + d * d + p * p)) ? 1 : f,
d /= f,
p /= f,
i[3 * r] = h,
i[3 * r + 1] = d,
i[3 * r + 2] = p
}
,
e._ComputeSides = function(t, i, n, r, o, a, s) {
var l, c, u = n.length, h = r.length;
switch (t = t || e.DEFAULTSIDE) {
case e.FRONTSIDE:
break;
case e.BACKSIDE:
for (l = 0; l < u; l += 3) {
var d = n[l];
n[l] = n[l + 2],
n[l + 2] = d
}
for (c = 0; c < h; c++)
r[c] = -r[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)
n[l + u] = n[l + 2] + f,
n[l + 1 + u] = n[l + 1] + f,
n[l + 2 + u] = n[l] + f;
for (c = 0; c < h; c++)
r[h + c] = -r[c];
var m = o.length
, g = 0;
for (g = 0; g < m; g++)
o[g + m] = o[g];
for (a = a || new R(0,0,1,1),
s = s || new R(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.ImportVertexData = function(t, i) {
var n = new e
, r = t.positions;
r && n.set(r, Bi.PositionKind);
var o = t.normals;
o && n.set(o, Bi.NormalKind);
var a = t.tangents;
a && n.set(a, Bi.TangentKind);
var s = t.uvs;
s && n.set(s, Bi.UVKind);
var l = t.uv2s;
l && n.set(l, Bi.UV2Kind);
var c = t.uv3s;
c && n.set(c, Bi.UV3Kind);
var u = t.uv4s;
u && n.set(u, Bi.UV4Kind);
var h = t.uv5s;
h && n.set(h, Bi.UV5Kind);
var d = t.uv6s;
d && n.set(d, Bi.UV6Kind);
var p = t.colors;
p && n.set(N.CheckColors4(p, r.length / 3), Bi.ColorKind);
var f = t.matricesIndices;
f && n.set(f, Bi.MatricesIndicesKind);
var _ = t.matricesWeights;
_ && n.set(_, Bi.MatricesWeightsKind);
var m = t.indices;
m && (n.indices = m),
i.setAllVerticesData(n, t.updatable)
}
,
e.FRONTSIDE = 0,
e.BACKSIDE = 1,
e.DOUBLESIDE = 2,
e.DEFAULTSIDE = 0,
k([ze.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),
k([ze.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),
k([ze.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),
k([ze.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
}()
, er = function(e, t, i) {
this.bu = e,
this.bv = t,
this.distance = i,
this.faceId = 0,
this.subMeshId = 0
}
, tr = function() {
function e(e, t, i) {
this.vectors = g.BuildArray(8, x.Zero),
this.center = x.Zero(),
this.centerWorld = x.Zero(),
this.extendSize = x.Zero(),
this.extendSizeWorld = x.Zero(),
this.directions = g.BuildArray(3, x.Zero),
this.vectorsWorld = g.BuildArray(8, x.Zero),
this.minimumWorld = x.Zero(),
this.maximumWorld = x.Zero(),
this.minimum = x.Zero(),
this.maximum = x.Zero(),
this._drawWrapperFront = null,
this._drawWrapperBack = null,
this.reConstruct(e, t, i)
}
return e.prototype.reConstruct = function(e, t, i) {
var n = e.x
, r = e.y
, o = e.z
, a = t.x
, s = t.y
, l = t.z
, c = this.vectors;
this.minimum.copyFromFloats(n, r, o),
this.maximum.copyFromFloats(a, s, l),
c[0].copyFromFloats(n, r, o),
c[1].copyFromFloats(a, s, l),
c[2].copyFromFloats(a, r, o),
c[3].copyFromFloats(n, s, o),
c[4].copyFromFloats(n, r, l),
c[5].copyFromFloats(a, s, o),
c[6].copyFromFloats(n, s, l),
c[7].copyFromFloats(a, r, l),
t.addToRef(e, this.center).scaleInPlace(.5),
t.subtractToRef(e, this.extendSize).scaleInPlace(.5),
this._worldMatrix = i || P.IdentityReadOnly,
this._update(this._worldMatrix)
}
,
e.prototype.scale = function(t) {
var i = e._TmpVector3
, n = this.maximum.subtractToRef(this.minimum, i[0])
, r = n.length();
n.normalizeFromLength(r);
var o = r * t
, a = n.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
, n = this.directions
, r = this.vectorsWorld
, o = this.vectors;
if (e.isIdentity()) {
for (t.copyFrom(this.minimum),
i.copyFrom(this.maximum),
a = 0; a < 8; ++a)
r[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 = r[a];
x.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)
}
x.FromArrayToRef(e.m, 0, n[0]),
x.FromArrayToRef(e.m, 4, n[1]),
x.FromArrayToRef(e.m, 8, n[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
, n = t.x
, r = t.y
, o = t.z
, a = i.x
, s = i.y
, l = i.z
, c = e.x
, u = e.y
, h = e.z
, d = -m;
return !(a - c < d || d > c - n || s - u < d || d > u - r || 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
, n = this.maximumWorld
, r = i.x
, o = i.y
, a = i.z
, s = n.x
, l = n.y
, c = n.z
, u = e.x
, h = e.y
, d = e.z
, p = t.x
, f = t.y
, _ = t.z;
return !(s < u || r > 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, n, r) {
var o = e._TmpVector3[0];
return x.ClampToRef(n, t, i, o),
x.DistanceSquared(n, o) <= r * r
}
,
e.IsCompletelyInFrustum = function(e, t) {
for (var i = 0; i < 6; ++i)
for (var n = t[i], r = 0; r < 8; ++r)
if (n.dotCoordinate(e[r]) < 0)
return !1;
return !0
}
,
e.IsInFrustum = function(e, t) {
for (var i = 0; i < 6; ++i) {
for (var n = !0, r = t[i], o = 0; o < 8; ++o)
if (r.dotCoordinate(e[o]) >= 0) {
n = !1;
break
}
if (n)
return !1
}
return !0
}
,
e._TmpVector3 = g.BuildArray(3, x.Zero),
e
}()
, ir = function() {
function e(e, t, i) {
this.center = x.Zero(),
this.centerWorld = x.Zero(),
this.minimum = x.Zero(),
this.maximum = x.Zero(),
this.reConstruct(e, t, i)
}
return e.prototype.reConstruct = function(e, t, i) {
this.minimum.copyFrom(e),
this.maximum.copyFrom(t);
var n = x.Distance(e, t);
t.addToRef(e, this.center).scaleInPlace(.5),
this.radius = .5 * n,
this._update(i || P.IdentityReadOnly)
}
,
e.prototype.scale = function(t) {
var i = this.radius * t
, n = e._TmpVector3
, r = n[0].setAll(i)
, o = this.center.subtractToRef(r, n[1])
, a = this.center.addToRef(r, n[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 {
x.TransformCoordinatesToRef(this.center, t, this.centerWorld);
var i = e._TmpVector3[0];
x.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, n = 0; n < 6; n++)
if (e[n].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 = x.DistanceSquared(this.centerWorld, e);
return !(this.radiusWorld * this.radiusWorld < t)
}
,
e.Intersects = function(e, t) {
var i = x.DistanceSquared(e.centerWorld, t.centerWorld)
, n = e.radiusWorld + t.radiusWorld;
return !(n * n < i)
}
,
e.CreateFromCenterAndRadius = function(t, i, n) {
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 r = new e(this._TmpVector3[0],this._TmpVector3[2]);
return r._worldMatrix = n || P.Identity(),
r
}
,
e._TmpVector3 = g.BuildArray(3, x.Zero),
e
}()
, nr = {
min: 0,
max: 0
}
, rr = {
min: 0,
max: 0
}
, or = function(e, t, i) {
var n = x.Dot(t.centerWorld, e)
, r = Math.abs(x.Dot(t.directions[0], e)) * t.extendSize.x + Math.abs(x.Dot(t.directions[1], e)) * t.extendSize.y + Math.abs(x.Dot(t.directions[2], e)) * t.extendSize.z;
i.min = n - r,
i.max = n + r
}
, ar = function(e, t, i) {
return or(e, t, nr),
or(e, i, rr),
!(nr.min > rr.max || rr.min > nr.max)
}
, sr = function() {
function e(e, t, i) {
this._isLocked = !1,
this.boundingBox = new tr(e,t,i),
this.boundingSphere = new ir(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 n = e._TmpVector3[0].copyFrom(t).subtractInPlace(i)
, r = e._TmpVector3[1].copyFrom(t).addInPlace(i);
return this.boundingBox.reConstruct(n, r, this.boundingBox.getWorldMatrix()),
this.boundingSphere.reConstruct(n, r, this.boundingBox.getWorldMatrix()),
this
}
,
e.prototype.encapsulate = function(e) {
var t = x.Minimize(this.minimum, e)
, i = x.Maximize(this.maximum, e);
return this.reConstruct(t, i, this.boundingBox.getWorldMatrix()),
this
}
,
e.prototype.encapsulateBoundingInfo = function(e) {
return this.encapsulate(e.boundingBox.centerWorld.subtract(e.boundingBox.extendSizeWorld)),
this.encapsulate(e.boundingBox.centerWorld.add(e.boundingBox.extendSizeWorld)),
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 (!ir.Intersects(this.boundingSphere, e.boundingSphere))
return !1;
if (!tr.Intersects(this.boundingBox, e.boundingBox))
return !1;
if (!t)
return !0;
var i = this.boundingBox
, n = e.boundingBox;
return !!(ar(i.directions[0], i, n) && ar(i.directions[1], i, n) && ar(i.directions[2], i, n) && ar(n.directions[0], i, n) && ar(n.directions[1], i, n) && ar(n.directions[2], i, n) && ar(x.Cross(i.directions[0], n.directions[0]), i, n) && ar(x.Cross(i.directions[0], n.directions[1]), i, n) && ar(x.Cross(i.directions[0], n.directions[2]), i, n) && ar(x.Cross(i.directions[1], n.directions[0]), i, n) && ar(x.Cross(i.directions[1], n.directions[1]), i, n) && ar(x.Cross(i.directions[1], n.directions[2]), i, n) && ar(x.Cross(i.directions[2], n.directions[0]), i, n) && ar(x.Cross(i.directions[2], n.directions[1]), i, n) && ar(x.Cross(i.directions[2], n.directions[2]), i, n))
}
,
e._TmpVector3 = g.BuildArray(2, x.Zero),
e
}()
, lr = function() {
function e() {}
return e.extractMinAndMaxIndexed = function(e, t, i, n, r, o) {
for (var a = i; a < i + n; a++) {
var s = 3 * t[a]
, l = e[s]
, c = e[s + 1]
, u = e[s + 2];
r.minimizeInPlaceFromFloats(l, c, u),
o.maximizeInPlaceFromFloats(l, c, u)
}
}
,
e.extractMinAndMax = function(e, t, i, n, r, o) {
for (var a = t, s = t * n; a < t + i; a++,
s += n) {
var l = e[s]
, c = e[s + 1]
, u = e[s + 2];
r.minimizeInPlaceFromFloats(l, c, u),
o.maximizeInPlaceFromFloats(l, c, u)
}
}
,
k([ze.filter((function() {
for (var e = [], t = 0; t < arguments.length; t++)
e[t] = arguments[t];
var i = e[0]
, n = e[1];
return !Array.isArray(i) && !Array.isArray(n)
}
))], e, "extractMinAndMaxIndexed", null),
k([ze.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 cr(e, t, i, n, r) {
void 0 === r && (r = null);
var o = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)
, a = new x(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);
return lr.extractMinAndMaxIndexed(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
}
}
function ur(e, t, i, n, r) {
void 0 === n && (n = null);
var o = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)
, a = new x(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);
return r || (r = 3),
lr.extractMinAndMax(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
}
}
var hr = function() {
function e(e, t, i, n, r, 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 = n,
this.indexCount = r,
this._mainDrawWrapperOverride = null,
this._linesIndexCount = 0,
this._linesIndexBuffer = null,
this._lastColliderWorldVertices = null,
this._lastColliderTransformMatrix = null,
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 Gt(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, n) {
void 0 === t && (t = null),
void 0 === n && (n = !0);
var r = this._drawWrapper;
r.setEffect(e, t, n),
void 0 !== i && (r.materialContext = i),
e || (r.defines = null,
r.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 n = i[t];
null == n || n.dispose()
}
}
this._drawWrappers = []
}
,
e.AddToMesh = function(t, i, n, r, o, a, s, l) {
return void 0 === l && (l = !0),
new e(t,i,n,r,o,a,s,l)
}
,
Object.defineProperty(e.prototype, "IsGlobal", {
get: function() {
return 0 === this.verticesStart && this.verticesCount === this._mesh.getTotalVertices()
},
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() {
var e, t = null !== (e = this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId)) && void 0 !== e ? e : this._renderingMesh.material;
if (null == t)
return this._mesh.getScene().defaultMaterial;
if (this._isMultiMaterial(t)) {
var i = t.getSubMaterial(this.materialIndex);
return this._currentMaterial !== i && (this._currentMaterial = i,
this.resetDrawCache()),
i
}
return t
}
,
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(Bi.PositionKind)),
!e)
return this._boundingInfo = this._mesh.getBoundingInfo(),
this;
var t, i = this._renderingMesh.getIndices();
if (0 === this.indexStart && this.indexCount === i.length) {
var n = this._renderingMesh.getBoundingInfo();
t = {
minimum: n.minimum.clone(),
maximum: n.maximum.clone()
}
} else
t = cr(e, i, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
return this._boundingInfo ? this._boundingInfo.reConstruct(t.minimum, t.maximum) : this._boundingInfo = new sr(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 = [], n = this.indexStart; n < this.indexStart + this.indexCount; n += 3)
i.push(e[n], e[n + 1], e[n + 1], e[n + 2], e[n + 2], e[n]);
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, n, r) {
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, n) : this._intersectUnIndexedLines(e, t, i, this._mesh.intersectionThreshold, n) : !i.length && this._mesh._unIndexed ? this._intersectUnIndexedTriangles(e, t, i, n, r) : this._intersectTriangles(e, t, i, s, l, n, r)
}
,
e.prototype._intersectLines = function(e, t, i, n, r) {
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, n);
if (!(c < 0) && (r || !o || c < o.distance) && ((o = new er(null,null,c)).faceId = a / 2,
r))
break
}
return o
}
,
e.prototype._intersectUnIndexedLines = function(e, t, i, n, r) {
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, n);
if (!(c < 0) && (r || !o || c < o.distance) && ((o = new er(null,null,c)).faceId = a / 2,
r))
break
}
return o
}
,
e.prototype._intersectTriangles = function(e, t, i, n, r, o, a) {
for (var s = null, l = -1, c = this.indexStart; c < this.indexStart + this.indexCount - (3 - n); c += n) {
l++;
var u = i[c]
, h = i[c + 1]
, d = i[c + 2];
if (r && 4294967295 === d)
c += 2;
else {
var p = t[u]
, f = t[h]
, _ = t[d];
if (p && f && _ && (!a || a(p, f, _, e))) {
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, n, r) {
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 (!r || r(s, l, c, e)) {
var u = e.intersectsTriangle(s, l, c);
if (u) {
if (u.distance < 0)
continue;
if ((n || !o || u.distance < o.distance) && ((o = u).faceId = a / 3,
n))
break
}
}
}
return o
}
,
e.prototype._rebuild = function() {
this._linesIndexBuffer && (this._linesIndexBuffer = null)
}
,
e.prototype.clone = function(t, i) {
var n = new e(this.materialIndex,this.verticesStart,this.verticesCount,this.indexStart,this.indexCount,t,i,!1);
if (!this.IsGlobal) {
var r = this.getBoundingInfo();
if (!r)
return n;
n._boundingInfo = new sr(r.minimum,r.maximum)
}
return n
}
,
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, n, r, o, a) {
void 0 === a && (a = !0);
for (var s = Number.MAX_VALUE, l = -Number.MAX_VALUE, c = (o || r).getIndices(), u = i; u < i + n; u++) {
var h = c[u];
h < s && (s = h),
h > l && (l = h)
}
return new e(t,s,l - s + 1,i,n,r,o,a)
}
,
e
}()
, dr = 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
}()
, pr = function() {
function e() {}
return e.UseOpenGLOrientationForUV = !1,
e
}()
, fr = function() {
function e(e, t, i, n, r) {
void 0 === n && (n = !1),
void 0 === r && (r = 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 || E.LastCreatedScene,
this._scene && (this.id = e,
this.uniqueId = this._scene.getUniqueId(),
this._engine = this._scene.getEngine(),
this._meshes = [],
this._vertexBuffers = {},
this._indices = [],
this._updatable = n,
i ? this.setAllVerticesData(i, n) : (this._totalVertices = 0,
this._indices = []),
this._engine.getCaps().vertexArrayObject && (this._vertexArrayObjects = {}),
r && (this.applyToMesh(r),
r.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, n) {
void 0 === i && (i = !1),
i && Array.isArray(t) && (t = new Float32Array(t));
var r = new Bi(this._engine,t,e,i,0 === this._meshes.length,n);
this.setVerticesBuffer(r)
}
,
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 n = e.getKind();
this._vertexBuffers[n] && i && this._vertexBuffers[n].dispose(),
e._buffer && e._buffer._increaseReferences(),
this._vertexBuffers[n] = e;
var r = this._meshes
, o = r.length;
if (n === Bi.PositionKind) {
var a = e.getData();
null != t ? this._totalVertices = t : null != a && (this._totalVertices = a.length / (e.type === Bi.BYTE ? e.byteStride : e.byteStride / 4)),
this._updateExtend(a),
this._resetPointsArrayCache();
for (var s = 0; s < o; s++) {
var l = r[s];
l.buildBoundingInfo(this._extend.minimum, this._extend.maximum),
l._createGlobalSubMesh(!1),
l.computeWorldMatrix(!0),
l.synchronizeInstances()
}
}
this._notifyUpdate(n)
}
,
e.prototype.updateVerticesDataDirectly = function(e, t, i, n) {
void 0 === n && (n = !1);
var r = this.getVertexBuffer(e);
r && (r.updateDirectly(t, i, n),
this._notifyUpdate(e))
}
,
e.prototype.updateVerticesData = function(e, t, i) {
void 0 === i && (i = !1);
var n = this.getVertexBuffer(e);
n && (n.update(t),
e === Bi.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, n = this._meshes; i < n.length; i++) {
var r = n[i];
r.hasBoundingInfo ? r.getBoundingInfo().reConstruct(this._extend.minimum, this._extend.maximum) : r.buildBoundingInfo(this._extend.minimum, this._extend.maximum);
for (var o = 0, a = r.subMeshes; o < a.length; o++)
a[o].refreshBoundingInfo()
}
}
,
e.prototype._bind = function(e, t, i, n) {
if (e) {
void 0 === t && (t = this._indexBuffer);
var r = this.getVertexBuffers();
if (r)
if (t == this._indexBuffer && (this._vertexArrayObjects || n)) {
var o = n || this._vertexArrayObjects;
o[e.key] || (o[e.key] = this._engine.recordVertexArrayObject(r, t, e, i)),
this._engine.bindVertexArrayObject(o[e.key], t)
} else
this._engine.bindBuffers(r, t, e, i)
}
}
,
e.prototype.getTotalVertices = function() {
return this.isReady() ? this._totalVertices : 0
}
,
e.prototype.getVerticesData = function(e, t, i) {
var n = this.getVertexBuffer(e);
return n ? n.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 n = e.length !== this._indices.length;
if (i || (this._indices = e.slice()),
this._engine.updateDynamicIndexBuffer(this._indexBuffer, e, t),
n)
for (var r = 0, o = this._meshes; r < o.length; r++)
o[r]._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 n = 0, r = this._meshes; n < r.length; n++) {
var o = r[n];
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 ? gi.Slice(i) : 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
, n = i.indexOf(e);
-1 !== n && (i.splice(n, 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(Bi.PositionKind)))
return;
this._extend = ur(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 === Bi.PositionKind && (this._extend || this._updateExtend(),
e.buildBoundingInfo(this._extend.minimum, this._extend.maximum),
e._createGlobalSubMesh(!1),
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(n) {
if (i._delayLoadingFunction) {
i._delayLoadingFunction(JSON.parse(n), i),
i.delayLoadState = a.DELAYLOADSTATE_LOADED,
i._delayInfo = [],
e._removePendingData(i);
for (var r = i._meshes, o = r.length, s = 0; s < o; s++)
i._applyToMesh(r[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 n = this.getVerticesData(Bi.PositionKind, !1);
if (null != n && n.length > 0) {
for (t = 0; t < n.length; t += 3)
n[t + 2] = -n[t + 2];
this.setVerticesData(Bi.PositionKind, n, !1)
}
var r = this.getVerticesData(Bi.NormalKind, !1);
if (null != r && r.length > 0) {
for (t = 0; t < r.length; t += 3)
r[t + 2] = -r[t + 2];
this.setVerticesData(Bi.NormalKind, r, !1)
}
}
,
e.prototype._resetPointsArrayCache = function() {
this._positions = null
}
,
e.prototype._generatePointsArray = function() {
if (this._positions)
return !0;
var e = this.getVerticesData(Bi.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] = x.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, n = 0; n < i; n++)
t[n]._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 n in this._meshes = [],
this._disposeVertexArrayObjects(),
this._vertexBuffers)
this._vertexBuffers[n].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 r = this._parentContainer.geometries.indexOf(this);
r > -1 && this._parentContainer.geometries.splice(r, 1),
this._parentContainer = null
}
this._isDisposed = !0
}
,
e.prototype.copy = function(t) {
var i = new $n;
i.indices = [];
var n = this.getIndices();
if (n)
for (var r = 0; r < n.length; r++)
i.indices.push(n[r]);
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 sr(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,
ye && ye.HasTags(this) && (e.tags = ye.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(Bi.PositionKind) && (e.positions = this._toNumberArray(this.getVerticesData(Bi.PositionKind)),
this.isVertexBufferUpdatable(Bi.PositionKind) && (e.positions._updatable = !0)),
this.isVerticesDataPresent(Bi.NormalKind) && (e.normals = this._toNumberArray(this.getVerticesData(Bi.NormalKind)),
this.isVertexBufferUpdatable(Bi.NormalKind) && (e.normals._updatable = !0)),
this.isVerticesDataPresent(Bi.TangentKind) && (e.tangents = this._toNumberArray(this.getVerticesData(Bi.TangentKind)),
this.isVertexBufferUpdatable(Bi.TangentKind) && (e.tangents._updatable = !0)),
this.isVerticesDataPresent(Bi.UVKind) && (e.uvs = this._toNumberArray(this.getVerticesData(Bi.UVKind)),
this.isVertexBufferUpdatable(Bi.UVKind) && (e.uvs._updatable = !0)),
this.isVerticesDataPresent(Bi.UV2Kind) && (e.uv2s = this._toNumberArray(this.getVerticesData(Bi.UV2Kind)),
this.isVertexBufferUpdatable(Bi.UV2Kind) && (e.uv2s._updatable = !0)),
this.isVerticesDataPresent(Bi.UV3Kind) && (e.uv3s = this._toNumberArray(this.getVerticesData(Bi.UV3Kind)),
this.isVertexBufferUpdatable(Bi.UV3Kind) && (e.uv3s._updatable = !0)),
this.isVerticesDataPresent(Bi.UV4Kind) && (e.uv4s = this._toNumberArray(this.getVerticesData(Bi.UV4Kind)),
this.isVertexBufferUpdatable(Bi.UV4Kind) && (e.uv4s._updatable = !0)),
this.isVerticesDataPresent(Bi.UV5Kind) && (e.uv5s = this._toNumberArray(this.getVerticesData(Bi.UV5Kind)),
this.isVertexBufferUpdatable(Bi.UV5Kind) && (e.uv5s._updatable = !0)),
this.isVerticesDataPresent(Bi.UV6Kind) && (e.uv6s = this._toNumberArray(this.getVerticesData(Bi.UV6Kind)),
this.isVertexBufferUpdatable(Bi.UV6Kind) && (e.uv6s._updatable = !0)),
this.isVerticesDataPresent(Bi.ColorKind) && (e.colors = this._toNumberArray(this.getVerticesData(Bi.ColorKind)),
this.isVertexBufferUpdatable(Bi.ColorKind) && (e.colors._updatable = !0)),
this.isVerticesDataPresent(Bi.MatricesIndicesKind) && (e.matricesIndices = this._toNumberArray(this.getVerticesData(Bi.MatricesIndicesKind)),
e.matricesIndices._isExpanded = !0,
this.isVertexBufferUpdatable(Bi.MatricesIndicesKind) && (e.matricesIndices._updatable = !0)),
this.isVerticesDataPresent(Bi.MatricesWeightsKind) && (e.matricesWeights = this._toNumberArray(this.getVerticesData(Bi.MatricesWeightsKind)),
this.isVertexBufferUpdatable(Bi.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 gi.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 n = i.getScene()
, r = t.geometryUniqueId
, o = t.geometryId;
if (r || o) {
var a = r ? this._GetGeometryByLoadedUniqueId(r, n) : n.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(Bi.PositionKind, l, !1)
}
if (s.normalsAttrDesc && s.normalsAttrDesc.count > 0) {
var c = new Float32Array(t,s.normalsAttrDesc.offset,s.normalsAttrDesc.count);
i.setVerticesData(Bi.NormalKind, c, !1)
}
if (s.tangetsAttrDesc && s.tangetsAttrDesc.count > 0) {
var u = new Float32Array(t,s.tangetsAttrDesc.offset,s.tangetsAttrDesc.count);
i.setVerticesData(Bi.TangentKind, u, !1)
}
if (s.uvsAttrDesc && s.uvsAttrDesc.count > 0) {
var h = new Float32Array(t,s.uvsAttrDesc.offset,s.uvsAttrDesc.count);
if (pr.UseOpenGLOrientationForUV)
for (var d = 1; d < h.length; d += 2)
h[d] = 1 - h[d];
i.setVerticesData(Bi.UVKind, h, !1)
}
if (s.uvs2AttrDesc && s.uvs2AttrDesc.count > 0) {
var p = new Float32Array(t,s.uvs2AttrDesc.offset,s.uvs2AttrDesc.count);
if (pr.UseOpenGLOrientationForUV)
for (d = 1; d < p.length; d += 2)
p[d] = 1 - p[d];
i.setVerticesData(Bi.UV2Kind, p, !1)
}
if (s.uvs3AttrDesc && s.uvs3AttrDesc.count > 0) {
var f = new Float32Array(t,s.uvs3AttrDesc.offset,s.uvs3AttrDesc.count);
if (pr.UseOpenGLOrientationForUV)
for (d = 1; d < f.length; d += 2)
f[d] = 1 - f[d];
i.setVerticesData(Bi.UV3Kind, f, !1)
}
if (s.uvs4AttrDesc && s.uvs4AttrDesc.count > 0) {
var _ = new Float32Array(t,s.uvs4AttrDesc.offset,s.uvs4AttrDesc.count);
if (pr.UseOpenGLOrientationForUV)
for (d = 1; d < _.length; d += 2)
_[d] = 1 - _[d];
i.setVerticesData(Bi.UV4Kind, _, !1)
}
if (s.uvs5AttrDesc && s.uvs5AttrDesc.count > 0) {
var m = new Float32Array(t,s.uvs5AttrDesc.offset,s.uvs5AttrDesc.count);
if (pr.UseOpenGLOrientationForUV)
for (d = 1; d < m.length; d += 2)
m[d] = 1 - m[d];
i.setVerticesData(Bi.UV5Kind, m, !1)
}
if (s.uvs6AttrDesc && s.uvs6AttrDesc.count > 0) {
var g = new Float32Array(t,s.uvs6AttrDesc.offset,s.uvs6AttrDesc.count);
if (pr.UseOpenGLOrientationForUV)
for (d = 1; d < g.length; d += 2)
g[d] = 1 - g[d];
i.setVerticesData(Bi.UV6Kind, g, !1)
}
if (s.colorsAttrDesc && s.colorsAttrDesc.count > 0) {
var v = new Float32Array(t,s.colorsAttrDesc.offset,s.colorsAttrDesc.count);
i.setVerticesData(Bi.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(Bi.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(Bi.MatricesIndicesExtraKind, b, !1)
}
if (s.matricesWeightsAttrDesc && s.matricesWeightsAttrDesc.count > 0) {
var E = new Float32Array(t,s.matricesWeightsAttrDesc.offset,s.matricesWeightsAttrDesc.count);
i.setVerticesData(Bi.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 A = new Int32Array(t,s.subMeshesAttrDesc.offset,5 * s.subMeshesAttrDesc.count);
for (i.subMeshes = [],
T = 0; T < s.subMeshesAttrDesc.count; T++) {
var x = A[5 * T + 0]
, R = A[5 * T + 1]
, C = A[5 * T + 2]
, P = A[5 * T + 3]
, M = A[5 * T + 4];
hr.AddToMesh(x, R, C, P, M, i)
}
}
} else if (t.positions && t.normals && t.indices) {
if (i.setVerticesData(Bi.PositionKind, t.positions, t.positions._updatable),
i.setVerticesData(Bi.NormalKind, t.normals, t.normals._updatable),
t.tangents && i.setVerticesData(Bi.TangentKind, t.tangents, t.tangents._updatable),
t.uvs && i.setVerticesData(Bi.UVKind, t.uvs, t.uvs._updatable),
t.uvs2 && i.setVerticesData(Bi.UV2Kind, t.uvs2, t.uvs2._updatable),
t.uvs3 && i.setVerticesData(Bi.UV3Kind, t.uvs3, t.uvs3._updatable),
t.uvs4 && i.setVerticesData(Bi.UV4Kind, t.uvs4, t.uvs4._updatable),
t.uvs5 && i.setVerticesData(Bi.UV5Kind, t.uvs5, t.uvs5._updatable),
t.uvs6 && i.setVerticesData(Bi.UV6Kind, t.uvs6, t.uvs6._updatable),
t.colors && i.setVerticesData(Bi.ColorKind, N.CheckColors4(t.colors, t.positions.length / 3), t.colors._updatable),
t.matricesIndices)
if (t.matricesIndices._isExpanded)
delete t.matricesIndices._isExpanded,
i.setVerticesData(Bi.MatricesIndicesKind, t.matricesIndices, t.matricesIndices._updatable);
else {
for (b = [],
T = 0; T < t.matricesIndices.length; T++) {
var I = t.matricesIndices[T];
b.push(255 & I),
b.push((65280 & I) >> 8),
b.push((16711680 & I) >> 16),
b.push(I >> 24 & 255)
}
i.setVerticesData(Bi.MatricesIndicesKind, b, t.matricesIndices._updatable)
}
if (t.matricesIndicesExtra)
if (t.matricesIndicesExtra._isExpanded)
delete t.matricesIndices._isExpanded,
i.setVerticesData(Bi.MatricesIndicesExtraKind, t.matricesIndicesExtra, t.matricesIndicesExtra._updatable);
else {
for (b = [],
T = 0; T < t.matricesIndicesExtra.length; T++)
I = t.matricesIndicesExtra[T],
b.push(255 & I),
b.push((65280 & I) >> 8),
b.push((16711680 & I) >> 16),
b.push(I >> 24 & 255);
i.setVerticesData(Bi.MatricesIndicesExtraKind, b, t.matricesIndicesExtra._updatable)
}
t.matricesWeights && (e._CleanMatricesWeights(t, i),
i.setVerticesData(Bi.MatricesWeightsKind, t.matricesWeights, t.matricesWeights._updatable)),
t.matricesWeightsExtra && i.setVerticesData(Bi.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];
hr.AddToMesh(D.materialIndex, D.verticesStart, D.verticesCount, D.indexStart, D.indexCount, i)
}
}
i._shouldGenerateFlatShading && (i.convertToFlatShadedMesh(),
i._shouldGenerateFlatShading = !1),
i.computeWorldMatrix(!0),
n.onMeshImportedObservable.notifyObservers(i)
}
,
e._CleanMatricesWeights = function(e, t) {
var i = .001;
if (dr.CleanBoneMatrixWeights) {
var n = 0;
if (e.skeletonId > -1) {
var r = t.getScene().getLastSkeletonById(e.skeletonId);
if (r) {
n = r.bones.length;
for (var o = t.getVerticesData(Bi.MatricesIndicesKind), a = t.getVerticesData(Bi.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] = n) : (s[h + p] = 1 - d,
o[h + p] = n)
}
t.setVerticesData(Bi.MatricesIndicesKind, o),
e.matricesWeightsExtra && t.setVerticesData(Bi.MatricesIndicesExtraKind, a)
}
}
}
}
,
e.Parse = function(t, i, n) {
var r = new e(t.id,i,void 0,t.updatable);
return r._loadedUniqueId = t.uniqueId,
ye && ye.AddTagsTo(r, t.tags),
t.delayLoadingFile ? (r.delayLoadState = a.DELAYLOADSTATE_NOTLOADED,
r.delayLoadingFile = n + t.delayLoadingFile,
r._boundingInfo = new sr(x.FromArray(t.boundingBoxMinimum),x.FromArray(t.boundingBoxMaximum)),
r._delayInfo = [],
t.hasUVs && r._delayInfo.push(Bi.UVKind),
t.hasUVs2 && r._delayInfo.push(Bi.UV2Kind),
t.hasUVs3 && r._delayInfo.push(Bi.UV3Kind),
t.hasUVs4 && r._delayInfo.push(Bi.UV4Kind),
t.hasUVs5 && r._delayInfo.push(Bi.UV5Kind),
t.hasUVs6 && r._delayInfo.push(Bi.UV6Kind),
t.hasColors && r._delayInfo.push(Bi.ColorKind),
t.hasMatricesIndices && r._delayInfo.push(Bi.MatricesIndicesKind),
t.hasMatricesWeights && r._delayInfo.push(Bi.MatricesWeightsKind),
r._delayLoadingFunction = $n.ImportVertexData) : $n.ImportVertexData(t, r),
i.pushGeometry(r, !0),
r
}
,
e
}()
, _r = function() {
function e(e) {
void 0 === e && (e = 30),
this._enabled = !0,
this._rollingFrameTime = new mr(e)
}
return e.prototype.sampleFrame = function(e) {
if (void 0 === e && (e = ct.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
}()
, mr = 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 gr(e, t, i, n) {
switch (void 0 === i && (i = !1),
e) {
case a.TEXTURETYPE_BYTE:
var r = (ArrayBuffer,
new Int8Array(t));
return n && r.set(new Int8Array(n)),
r;
case a.TEXTURETYPE_UNSIGNED_BYTE:
var o = (ArrayBuffer,
new Uint8Array(t));
return n && o.set(new Uint8Array(n)),
o;
case a.TEXTURETYPE_SHORT:
var s = t instanceof ArrayBuffer ? new Int16Array(t) : new Int16Array(i ? t / 2 : t);
return n && s.set(new Int16Array(n)),
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 n && l.set(new Uint16Array(n)),
l;
case a.TEXTURETYPE_INT:
var c = t instanceof ArrayBuffer ? new Int32Array(t) : new Int32Array(i ? t / 4 : t);
return n && c.set(new Int32Array(n)),
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 n && u.set(new Uint32Array(n)),
u;
case a.TEXTURETYPE_FLOAT:
var h = t instanceof ArrayBuffer ? new Float32Array(t) : new Float32Array(i ? t / 4 : t);
return n && h.set(new Float32Array(n)),
h
}
var d = (ArrayBuffer,
new Uint8Array(t));
return n && d.set(new Uint8Array(n)),
d
}
Ht.prototype.setAlphaConstants = function(e, t, i, n) {
this._alphaState.setAlphaBlendConstants(e, t, i, n)
}
,
Ht.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
}
}
,
Ht.prototype.getAlphaMode = function() {
return this._alphaMode
}
,
Ht.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
}
}
,
Ht.prototype.getAlphaEquation = function() {
return this._alphaEquation
}
,
Ht.prototype._readTexturePixelsSync = function(e, t, i, n, r, o, a, s) {
var l, c;
void 0 === n && (n = -1),
void 0 === r && (r = 0),
void 0 === o && (o = null),
void 0 === a && (a = !0),
void 0 === s && (s = !1);
var u = this._gl;
if (!u)
throw new Error("Engine does not have gl rendering context.");
if (!this._dummyFramebuffer) {
var h = u.createFramebuffer();
if (!h)
throw new Error("Unable to create dummy framebuffer");
this._dummyFramebuffer = h
}
u.bindFramebuffer(u.FRAMEBUFFER, this._dummyFramebuffer),
n > -1 ? u.framebufferTexture2D(u.FRAMEBUFFER, u.COLOR_ATTACHMENT0, u.TEXTURE_CUBE_MAP_POSITIVE_X + n, null === (l = e._hardwareTexture) || void 0 === l ? void 0 : l.underlyingResource, r) : u.framebufferTexture2D(u.FRAMEBUFFER, u.COLOR_ATTACHMENT0, u.TEXTURE_2D, null === (c = e._hardwareTexture) || void 0 === c ? void 0 : c.underlyingResource, r);
var d = void 0 !== e.type ? this._getWebGLTextureType(e.type) : u.UNSIGNED_BYTE;
return s ? o || (o = gr(e.type, 4 * t * i)) : d === u.UNSIGNED_BYTE ? (o || (o = new Uint8Array(4 * t * i)),
d = u.UNSIGNED_BYTE) : (o || (o = new Float32Array(4 * t * i)),
d = u.FLOAT),
a && this.flushFramebuffer(),
u.readPixels(0, 0, t, i, u.RGBA, d, o),
u.bindFramebuffer(u.FRAMEBUFFER, this._currentFramebuffer),
o
}
,
Ht.prototype._readTexturePixels = function(e, t, i, n, r, o, a, s) {
return void 0 === n && (n = -1),
void 0 === r && (r = 0),
void 0 === o && (o = null),
void 0 === a && (a = !0),
void 0 === s && (s = !1),
Promise.resolve(this._readTexturePixelsSync(e, t, i, n, r, o, a, s))
}
,
Ht.prototype.updateDynamicIndexBuffer = function(e, t, i) {
var n;
void 0 === i && (i = 0),
this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null,
this.bindIndexBuffer(e),
n = t instanceof Uint16Array || t instanceof Uint32Array ? t : e.is32Bits ? new Uint32Array(t) : new Uint16Array(t),
this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, n, this._gl.DYNAMIC_DRAW),
this._resetIndexBufferBinding()
}
,
Ht.prototype.updateDynamicVertexBuffer = function(e, t, i, n) {
this.bindArrayBuffer(e),
void 0 === i && (i = 0);
var r = t.length || t.byteLength;
void 0 === n || n >= r && 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 + n)) : (t = t instanceof ArrayBuffer ? new Uint8Array(t,i,n) : new Uint8Array(t.buffer,t.byteOffset + i,n),
this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, t)),
this._resetVertexBufferBinding()
}
;
var vr = function(e) {
function t(i, n, r, o) {
void 0 === o && (o = !1);
var s = e.call(this, i, n, r, o) || this;
if (s.enableOfflineSupport = !1,
s.disableManifestCheck = !1,
s.scenes = new Array,
s._virtualScenes = new Array,
s.onNewSceneAddedObservable = new h,
s.postProcesses = new Array,
s.isPointerLock = !1,
s.onResizeObservable = new h,
s.onCanvasBlurObservable = new h,
s.onCanvasFocusObservable = new h,
s.onCanvasPointerOutObservable = new h,
s.onBeginFrameObservable = new h,
s.customAnimationFrameRequester = null,
s.onEndFrameObservable = new h,
s.onBeforeShaderCompilationObservable = new h,
s.onAfterShaderCompilationObservable = new h,
s._deterministicLockstep = !1,
s._lockstepMaxSteps = 4,
s._timeStep = 1 / 60,
s._fps = 60,
s._deltaTime = 0,
s._drawCalls = new un,
s.canvasTabIndex = 1,
s.disablePerformanceMonitorInBackground = !1,
s._performanceMonitor = new _r,
s._compatibilityMode = !0,
s.currentRenderPassId = a.RENDERPASS_MAIN,
s._renderPassNames = ["main"],
t.Instances.push(s),
!i)
return s;
if (s._features.supportRenderPasses = !0,
r = s._creationOptions,
i.getContext) {
var l = i;
if (s._sharedInit(l, !!r.doNotHandleTouchAction, r.audioEngine),
nt()) {
var c = document;
s._onFullscreenChange = function() {
void 0 !== c.fullscreen ? s.isFullscreen = c.fullscreen : void 0 !== c.mozFullScreen ? s.isFullscreen = c.mozFullScreen : void 0 !== c.webkitIsFullScreen ? s.isFullscreen = c.webkitIsFullScreen : void 0 !== c.msIsFullScreen && (s.isFullscreen = c.msIsFullScreen),
s.isFullscreen && s._pointerLockRequested && l && t._RequestPointerlock(l)
}
,
document.addEventListener("fullscreenchange", s._onFullscreenChange, !1),
document.addEventListener("mozfullscreenchange", s._onFullscreenChange, !1),
document.addEventListener("webkitfullscreenchange", s._onFullscreenChange, !1),
document.addEventListener("msfullscreenchange", s._onFullscreenChange, !1),
s._onPointerLockChange = function() {
s.isPointerLock = c.mozPointerLockElement === l || c.webkitPointerLockElement === l || c.msPointerLockElement === l || c.pointerLockElement === l
}
,
document.addEventListener("pointerlockchange", s._onPointerLockChange, !1),
document.addEventListener("mspointerlockchange", s._onPointerLockChange, !1),
document.addEventListener("mozpointerlockchange", s._onPointerLockChange, !1),
document.addEventListener("webkitpointerlockchange", s._onPointerLockChange, !1),
!t.audioEngine && r.audioEngine && t.AudioEngineFactory && (t.audioEngine = t.AudioEngineFactory(s.getRenderingCanvas(), s.getAudioContext(), s.getAudioDestination()))
}
s._connectVREvents(),
s.enableOfflineSupport = void 0 !== t.OfflineProviderFactory,
s._deterministicLockstep = !!r.deterministicLockstep,
s._lockstepMaxSteps = r.lockstepMaxSteps || 0,
s._timeStep = r.timeStep || 1 / 60
}
return s._prepareVRComponent(),
r.autoEnableWebVR && s.initWebVR(),
s
}
return U(t, e),
Object.defineProperty(t, "NpmPackage", {
get: function() {
return Ht.NpmPackage
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t, "Version", {
get: function() {
return Ht.Version
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t, "Instances", {
get: function() {
return E.Instances
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t, "LastCreatedEngine", {
get: function() {
return E.LastCreatedEngine
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t, "LastCreatedScene", {
get: function() {
return E.LastCreatedScene
},
enumerable: !1,
configurable: !0
}),
t.prototype.createImageBitmapFromSource = function(e, t) {
var i = this;
return new Promise((function(n, r) {
var o = new Image;
o.onload = function() {
o.decode().then((function() {
i.createImageBitmap(o, t).then((function(e) {
n(e)
}
))
}
))
}
,
o.onerror = function() {
r("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 n = this.createCanvas(t, i).getContext("2d");
if (!n)
throw new Error("Unable to get 2d context for resizeImageBitmap");
return n.drawImage(e, 0, 0),
n.getImageData(0, 0, t, i).data
}
,
t.MarkAllMaterialsAsDirty = function(e, i) {
for (var n = 0; n < t.Instances.length; n++)
for (var r = t.Instances[n], o = 0; o < r.scenes.length; o++)
r.scenes[o].markAllMaterialsAsDirty(e, i)
}
,
t.DefaultLoadingScreenFactory = function(e) {
throw be("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._sharedInit = function(i, n, r) {
var o = this;
if (e.prototype._sharedInit.call(this, i, n, r),
this._onCanvasFocus = function() {
o.onCanvasFocusObservable.notifyObservers(o)
}
,
this._onCanvasBlur = function() {
o.onCanvasBlurObservable.notifyObservers(o)
}
,
i.addEventListener("focus", this._onCanvasFocus),
i.addEventListener("blur", this._onCanvasBlur),
this._onBlur = function() {
o.disablePerformanceMonitorInBackground && o._performanceMonitor.disable(),
o._windowIsBackground = !0
}
,
this._onFocus = function() {
o.disablePerformanceMonitorInBackground && o._performanceMonitor.enable(),
o._windowIsBackground = !1
}
,
this._onCanvasPointerOut = function(e) {
document.elementFromPoint(e.clientX, e.clientY) !== i && o.onCanvasPointerOutObservable.notifyObservers(e)
}
,
nt()) {
var a = this.getHostWindow();
a && (a.addEventListener("blur", this._onBlur),
a.addEventListener("focus", this._onFocus))
}
i.addEventListener("pointerout", this._onCanvasPointerOut),
n || this._disableTouchAction(),
!t.audioEngine && r && t.AudioEngineFactory && (t.audioEngine = t.AudioEngineFactory(this.getRenderingCanvas(), this.getAudioContext(), this.getAudioDestination()))
}
,
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.getDepthBuffer = function() {
return this._depthCullingState.depthTest
}
,
t.prototype.setDepthBuffer = function(e) {
this._depthCullingState.depthTest = e
}
,
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, n) {
var r = this._cachedViewport;
return this._cachedViewport = null,
this._viewport(e, t, i, n),
r
}
,
t.prototype.scissorClear = function(e, t, i, n, r) {
this.enableScissor(e, t, i, n),
this.clear(r, !0, !0, !0),
this.disableScissor()
}
,
t.prototype.enableScissor = function(e, t, i, n) {
var r = this._gl;
r.enable(r.SCISSOR_TEST),
r.scissor(e, t, i, n)
}
,
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 be("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 n = this;
return new Promise((function(r, o) {
n._loadFile(e, (function(e) {
r(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, n) {
void 0 !== e && (t && (this._boundUniforms[e] = t),
i && i.depthStencilTexture ? this._setTexture(e, i, !1, !0, n) : this._setTexture(e, null, void 0, void 0, n))
}
,
t.prototype.setTextureFromPostProcess = function(e, t, i) {
var n, r = null;
t && (t._textures.data[t._currentRenderTextureInd] ? r = t._textures.data[t._currentRenderTextureInd] : t._forcedOutputTexture && (r = t._forcedOutputTexture)),
this._bindTexture(e, null !== (n = null == r ? void 0 : r.texture) && void 0 !== n ? n : null, i)
}
,
t.prototype.setTextureFromPostProcessOutput = function(e, t, i) {
var n, r;
this._bindTexture(e, null !== (r = null === (n = null == t ? void 0 : t._outputTexture) || void 0 === n ? void 0 : n.texture) && void 0 !== r ? r : 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 n = 0, r = this._virtualScenes; n < r.length; n++) {
var o;
(o = r[n]).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._renderLoop = function() {
if (!this._contextWasLost) {
var e = !0;
!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, n) {
if (void 0 === n && (n = !1),
!this._renderingCanvas)
return !1;
if (!e.prototype.setSize.call(this, t, i, n))
return !1;
if (this.scenes) {
for (var r = 0; r < this.scenes.length; r++)
for (var o = this.scenes[r], 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, n, r, o, a) {
void 0 === a && (a = null),
o = o || this._gl,
this.onBeforeShaderCompilationObservable.notifyObservers(this);
var s = e.prototype.createShaderProgram.call(this, t, i, n, r, o, a);
return this.onAfterShaderCompilationObservable.notifyObservers(this),
s
}
,
t.prototype._createShaderProgram = function(e, t, i, n, r) {
void 0 === r && (r = null);
var o = n.createProgram();
if (e.program = o,
!o)
throw new Error("Unable to create program");
if (n.attachShader(o, t),
n.attachShader(o, i),
this.webGLVersion > 1 && r) {
var a = this.createTransformFeedback();
this.bindTransformFeedback(a),
this.setTranformFeedbackVaryings(o, r),
e.transformFeedback = a
}
return n.linkProgram(o),
this.webGLVersion > 1 && r && this.bindTransformFeedback(null),
e.context = n,
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], n = 0; n < i.meshes.length; ++n) {
var r = i.meshes[n];
if (r.subMeshes)
for (var o = 0; o < r.subMeshes.length; ++o)
r.subMeshes[o]._removeDrawWrapper(e)
}
}
,
t.prototype._rescaleTexture = function(e, i, n, r, 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.externalTextureSamplerBinding = !0,
this._rescalePostProcess.getEffect().executeWhenCompiled((function() {
s._rescalePostProcess.onApply = function(t) {
t._bindTexture("textureSampler", e)
}
;
var t = n;
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, r, 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._uploadImageToTexture = function(e, t, i, n) {
void 0 === i && (i = 0),
void 0 === n && (n = 0);
var r = this._gl
, o = this._getWebGLTextureType(e.type)
, a = this._getInternalFormat(e.format)
, s = this._getRGBABufferInternalSizedFormat(e.type, a)
, l = e.isCube ? r.TEXTURE_CUBE_MAP : r.TEXTURE_2D;
this._bindTextureDirectly(l, e, !0),
this._unpackFlipY(e.invertY);
var c = r.TEXTURE_2D;
e.isCube && (c = r.TEXTURE_CUBE_MAP_POSITIVE_X + i),
r.texImage2D(c, n, 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
K.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 Ut(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 n = this._gl;
return new Promise((function(r, o) {
var a = function() {
var s = n.clientWaitSync(e, t, 0);
s != n.WAIT_FAILED ? s != n.TIMEOUT_EXPIRED ? r() : setTimeout(a, i) : o()
};
a()
}
))
}
,
t.prototype._readPixelsAsync = function(e, t, i, n, r, 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, n, r, 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 === t.Instances.length && t.audioEngine && (t.audioEngine.dispose(),
t.audioEngine = null),
this.disableVR(),
nt() && (window.removeEventListener("blur", this._onBlur),
window.removeEventListener("focus", this._onFocus),
this._renderingCanvas && (this._renderingCanvas.removeEventListener("focus", this._onCanvasFocus),
this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur),
this._renderingCanvas.removeEventListener("pointerout", this._onCanvasPointerOut)),
ot() && (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 i = t.Instances.indexOf(this);
i >= 0 && t.Instances.splice(i, 1),
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.msTouchAction = "none")
}
,
t.prototype.displayLoadingUI = function() {
if (nt()) {
var e = this.loadingScreen;
e && e.displayLoadingUI()
}
}
,
t.prototype.hideLoadingUI = function() {
if (nt()) {
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) {
e.requestPointerLock = e.requestPointerLock || e.msRequestPointerLock || e.mozRequestPointerLock || e.webkitRequestPointerLock,
e.requestPointerLock && e.requestPointerLock()
}
,
t._ExitPointerlock = function() {
var e = document;
document.exitPointerLock = document.exitPointerLock || e.msExitPointerLock || e.mozExitPointerLock || e.webkitExitPointerLock,
document.exitPointerLock && document.exitPointerLock()
}
,
t._RequestFullscreen = function(e) {
var t = e.requestFullscreen || e.msRequestFullscreen || e.webkitRequestFullscreen || e.mozRequestFullScreen;
t && t.call(e)
}
,
t._ExitFullscreen = function() {
var e = document;
document.exitFullscreen ? document.exitFullscreen() : e.mozCancelFullScreen ? e.mozCancelFullScreen() : e.webkitCancelFullScreen ? e.webkitCancelFullScreen() : e.msCancelFullScreen && e.msCancelFullScreen()
}
,
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 n = document.createElement("div");
n.style.whiteSpace = "nowrap",
n.appendChild(t),
n.appendChild(i),
document.body.appendChild(n);
var r = 0
, o = 0;
try {
o = i.getBoundingClientRect().top - t.getBoundingClientRect().top,
i.style.verticalAlign = "baseline",
r = i.getBoundingClientRect().top - t.getBoundingClientRect().top
} finally {
document.body.removeChild(n)
}
return {
ascent: r,
height: o,
descent: o - r
}
}
,
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
}(Ht)
, yr = function(e) {
function t(i, n, r) {
void 0 === n && (n = null),
void 0 === r && (r = !0);
var o = e.call(this, i, n) || this;
return o._forward = new x(0,0,1),
o._up = new x(0,1,0),
o._right = new x(1,0,0),
o._position = x.Zero(),
o._rotation = x.Zero(),
o._rotationQuaternion = null,
o._scaling = x.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 = P.Zero(),
o._usePivotMatrix = !1,
o._absolutePosition = x.Zero(),
o._absoluteScaling = x.Zero(),
o._absoluteRotationQuaternion = C.Identity(),
o._pivotMatrix = P.Identity(),
o._postMultiplyPivotMatrix = !1,
o._isWorldMatrixFrozen = !1,
o._indexInSceneTransformNodesArray = -1,
o.onAfterWorldMatrixUpdateObservable = new h,
o._nonUniformScaling = !1,
r && o.getScene().addTransformNode(o),
o
}
return U(t, e),
Object.defineProperty(t.prototype, "billboardMode", {
get: function() {
return this._billboardMode
},
set: function(e) {
this._billboardMode !== e && (this._billboardMode = e)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "preserveParentRotationForBillboard", {
get: function() {
return this._preserveParentRotationForBillboard
},
set: function(e) {
e !== this._preserveParentRotationForBillboard && (this._preserveParentRotationForBillboard = e)
},
enumerable: !1,
configurable: !0
}),
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 x.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 x.TransformNormalFromFloatsToRef(0, 1, 0, this.getWorldMatrix(), this._up),
this._up.normalize()
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "right", {
get: function() {
return x.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 = P.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
}
,
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 = P.Invert(this._pivotMatrix)),
this
}
,
t.prototype.getPivotMatrix = function() {
return this._pivotMatrix
}
,
t.prototype.instantiateHierarchy = function(e, t, i) {
void 0 === e && (e = null);
var n = this.clone("Clone of " + (this.name || this.id), e || this.parent, !0);
n && i && i(this, n);
for (var r = 0, o = this.getChildTransformNodes(!0); r < o.length; r++)
o[r].instantiateHierarchy(n, t, i);
return n
}
,
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 || C.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, n;
if (void 0 === e.x) {
if (arguments.length < 3)
return this;
t = arguments[0],
i = arguments[1],
n = arguments[2]
} else
t = e.x,
i = e.y,
n = e.z;
if (this.parent) {
var r = I.Matrix[0];
this.parent.getWorldMatrix().invertToRef(r),
x.TransformCoordinatesFromFloatsToRef(t, i, n, r, this.position)
} else
this.position.x = t,
this.position.y = i,
this.position.z = n;
return this._absolutePosition.copyFrom(e),
this
}
,
t.prototype.setPositionWithLocalVector = function(e) {
return this.computeWorldMatrix(),
this.position = x.TransformNormal(e, this._localMatrix),
this
}
,
t.prototype.getPositionExpressedInLocalSpace = function() {
this.computeWorldMatrix();
var e = I.Matrix[0];
return this._localMatrix.invertToRef(e),
x.TransformNormal(this.position, e)
}
,
t.prototype.locallyTranslate = function(e) {
return this.computeWorldMatrix(!0),
this.position = x.TransformCoordinates(e, this._localMatrix),
this
}
,
t.prototype.lookAt = function(e, i, n, r, o) {
void 0 === i && (i = 0),
void 0 === n && (n = 0),
void 0 === r && (r = 0),
void 0 === o && (o = Ji.LOCAL);
var a = t._LookAtVectorCache
, s = o === Ji.LOCAL ? this.position : this.getAbsolutePosition();
if (e.subtractToRef(s, a),
this.setDirection(a, i, n, r),
o === Ji.WORLD && this.parent)
if (this.rotationQuaternion) {
var l = I.Matrix[0];
this.rotationQuaternion.toRotationMatrix(l);
var c = I.Matrix[1];
this.parent.getWorldMatrix().getRotationMatrixToRef(c),
c.invert(),
l.multiplyToRef(c, l),
this.rotationQuaternion.fromRotationMatrix(l)
} else {
var u = I.Quaternion[0];
C.FromEulerVectorToRef(this.rotation, u),
l = I.Matrix[0],
u.toRotationMatrix(l),
c = I.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 = x.Zero();
return this.getDirectionToRef(e, t),
t
}
,
t.prototype.getDirectionToRef = function(e, t) {
return x.TransformNormalToRef(e, this.getWorldMatrix(), t),
this
}
,
t.prototype.setDirection = function(e, t, i, n) {
void 0 === t && (t = 0),
void 0 === i && (i = 0),
void 0 === n && (n = 0);
var r = -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 ? C.RotationYawPitchRollToRef(r + t, a + i, n, this.rotationQuaternion) : (this.rotation.x = a + i,
this.rotation.y = r + t,
this.rotation.z = n),
this
}
,
t.prototype.setPivotPoint = function(e, t) {
void 0 === t && (t = Ji.LOCAL),
0 == this.getScene().getRenderId() && this.computeWorldMatrix(!0);
var i = this.getWorldMatrix();
if (t == Ji.WORLD) {
var n = I.Matrix[0];
i.invertToRef(n),
e = x.TransformCoordinates(e, n)
}
return this.setPivotMatrix(P.Translation(-e.x, -e.y, -e.z), !0)
}
,
t.prototype.getPivotPoint = function() {
var e = x.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 = x.Zero();
return this.getAbsolutePivotPointToRef(e),
e
}
,
t.prototype.getAbsolutePivotPointToRef = function(e) {
return this.getPivotPointToRef(e),
x.TransformCoordinatesToRef(e, this.getWorldMatrix(), e),
this
}
,
t.prototype.markAsDirty = function(t) {
if (this._children)
for (var i = 0, n = this._children; i < n.length; i++)
n[i].markAsDirty(t);
return e.prototype.markAsDirty.call(this, t)
}
,
t.prototype.setParent = function(e, i) {
if (void 0 === i && (i = !1),
!e && !this.parent)
return this;
var n = I.Quaternion[0]
, r = I.Vector3[0]
, o = I.Vector3[1]
, a = I.Matrix[1];
P.IdentityToRef(a);
var s = I.Matrix[0];
this.computeWorldMatrix(!0);
var l = this.rotationQuaternion;
return l || (l = t._TmpRotation,
C.RotationYawPitchRollToRef(this._rotation.y, this._rotation.x, this._rotation.z, l)),
P.ComposeToRef(this.scaling, l, this.position, s),
this.parent && s.multiplyToRef(this.parent.computeWorldMatrix(!0), s),
e && (e.computeWorldMatrix(!0).invertToRef(a),
s.multiplyToRef(a, s)),
s.decompose(o, n, r, i ? this : void 0),
this.rotationQuaternion ? this.rotationQuaternion.copyFrom(n) : n.toEulerAnglesToRef(this.rotation),
this.scaling.copyFrom(o),
this.position.copyFrom(r),
this.parent = e,
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.getWorldMatrix().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, n) {
var r;
if (e.normalize(),
this.rotationQuaternion || (this.rotationQuaternion = this.rotation.toQuaternion(),
this.rotation.setAll(0)),
n && n !== Ji.LOCAL) {
if (this.parent) {
var o = I.Matrix[0];
this.parent.getWorldMatrix().invertToRef(o),
e = x.TransformNormal(e, o)
}
(r = C.RotationAxisToRef(e, i, t._RotationAxisCache)).multiplyToRef(this.rotationQuaternion, this.rotationQuaternion)
} else
r = C.RotationAxisToRef(e, i, t._RotationAxisCache),
this.rotationQuaternion.multiplyToRef(r, this.rotationQuaternion);
return this
}
,
t.prototype.rotateAround = function(e, t, i) {
t.normalize(),
this.rotationQuaternion || (this.rotationQuaternion = C.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z),
this.rotation.setAll(0));
var n = I.Vector3[0]
, r = I.Vector3[1]
, o = I.Vector3[2]
, a = I.Quaternion[0]
, s = I.Matrix[0]
, l = I.Matrix[1]
, c = I.Matrix[2]
, u = I.Matrix[3];
return e.subtractToRef(this.position, n),
P.TranslationToRef(n.x, n.y, n.z, s),
P.TranslationToRef(-n.x, -n.y, -n.z, l),
P.RotationAxisToRef(t, i, c),
l.multiplyToRef(c, u),
u.multiplyToRef(s, u),
u.decompose(r, a, o),
this.position.addInPlace(o),
a.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion),
this
}
,
t.prototype.translate = function(e, t, i) {
var n = e.scale(t);
if (i && i !== Ji.LOCAL)
this.setAbsolutePosition(this.getAbsolutePosition().add(n));
else {
var r = this.getPositionExpressedInLocalSpace().add(n);
this.setPositionWithLocalVector(r)
}
return this
}
,
t.prototype.addRotation = function(e, t, i) {
var n;
this.rotationQuaternion ? n = this.rotationQuaternion : (n = I.Quaternion[1],
C.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, n));
var r = I.Quaternion[0];
return C.RotationYawPitchRollToRef(t, e, i, r),
n.multiplyInPlace(r),
this.rotationQuaternion || n.toEulerAnglesToRef(this.rotation),
this
}
,
t.prototype._getEffectiveParent = function() {
return this.parent
}
,
t.prototype.computeWorldMatrix = function(e) {
if (this._isWorldMatrixFrozen && !this._isDirty)
return this._worldMatrix;
var i = this.getScene().getRenderId();
if (!this._isDirty && !e && this.isSynchronized())
return this._currentRenderId = i,
this._worldMatrix;
var n = this.getScene().activeCamera
, r = 0 != (this._billboardMode & t.BILLBOARDMODE_USE_POSITION)
, o = this._billboardMode !== t.BILLBOARDMODE_NONE && !this.preserveParentRotationForBillboard;
this._updateCache();
var a = this._cache;
a.pivotMatrixUpdated = !1,
a.billboardMode = this.billboardMode,
a.infiniteDistance = this.infiniteDistance,
this._currentRenderId = i,
this._childUpdateId += 1,
this._isDirty = !1,
this._position._isDirty = !1,
this._rotation._isDirty = !1,
this._scaling._isDirty = !1;
var s, l = this._getEffectiveParent(), c = t._TmpScaling, u = this._position;
if (this._infiniteDistance && !this.parent && n) {
var h = n.getWorldMatrix()
, d = new x(h.m[12],h.m[13],h.m[14]);
(u = t._TmpTranslation).copyFromFloats(this._position.x + d.x, this._position.y + d.y, this._position.z + d.z)
}
if (c.copyFromFloats(this._scaling.x * this.scalingDeterminant, this._scaling.y * this.scalingDeterminant, this._scaling.z * this.scalingDeterminant),
this._rotationQuaternion ? (this._rotationQuaternion._isDirty = !1,
s = this._rotationQuaternion,
this.reIntegrateRotationIntoRotationQuaternion && (E = this.rotation.lengthSquared()) && (this._rotationQuaternion.multiplyInPlace(C.RotationYawPitchRoll(this._rotation.y, this._rotation.x, this._rotation.z)),
this._rotation.copyFromFloats(0, 0, 0))) : (s = t._TmpRotation,
C.RotationYawPitchRollToRef(this._rotation.y, this._rotation.x, this._rotation.z, s)),
this._usePivotMatrix) {
var p = I.Matrix[1];
P.ScalingToRef(c.x, c.y, c.z, p);
var f = I.Matrix[0];
s.toRotationMatrix(f),
this._pivotMatrix.multiplyToRef(p, I.Matrix[4]),
I.Matrix[4].multiplyToRef(f, this._localMatrix),
this._postMultiplyPivotMatrix && this._localMatrix.multiplyToRef(this._pivotMatrixInverse, this._localMatrix),
this._localMatrix.addTranslationFromFloats(u.x, u.y, u.z)
} else
P.ComposeToRef(c, s, u, this._localMatrix);
if (l && l.getWorldMatrix) {
if (e && l.computeWorldMatrix(e),
o) {
this._transformToBoneReferal ? l.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), I.Matrix[7]) : I.Matrix[7].copyFrom(l.getWorldMatrix());
var _ = I.Vector3[5]
, m = I.Vector3[6];
I.Matrix[7].decompose(m, void 0, _),
P.ScalingToRef(m.x, m.y, m.z, I.Matrix[7]),
I.Matrix[7].setTranslation(_),
this._localMatrix.multiplyToRef(I.Matrix[7], this._worldMatrix)
} else
this._transformToBoneReferal ? (this._localMatrix.multiplyToRef(l.getWorldMatrix(), I.Matrix[6]),
I.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix)) : this._localMatrix.multiplyToRef(l.getWorldMatrix(), this._worldMatrix);
this._markSyncedWithParent()
} else
this._worldMatrix.copyFrom(this._localMatrix);
if (o && n && this.billboardMode && !r) {
var g = I.Vector3[0];
if (this._worldMatrix.getTranslationToRef(g),
I.Matrix[1].copyFrom(n.getViewMatrix()),
I.Matrix[1].setTranslationFromFloats(0, 0, 0),
I.Matrix[1].invertToRef(I.Matrix[0]),
(this.billboardMode & t.BILLBOARDMODE_ALL) !== t.BILLBOARDMODE_ALL) {
I.Matrix[0].decompose(void 0, I.Quaternion[0], void 0);
var v = I.Vector3[1];
I.Quaternion[0].toEulerAnglesToRef(v),
(this.billboardMode & t.BILLBOARDMODE_X) !== t.BILLBOARDMODE_X && (v.x = 0),
(this.billboardMode & t.BILLBOARDMODE_Y) !== t.BILLBOARDMODE_Y && (v.y = 0),
(this.billboardMode & t.BILLBOARDMODE_Z) !== t.BILLBOARDMODE_Z && (v.z = 0),
P.RotationYawPitchRollToRef(v.y, v.x, v.z, I.Matrix[0])
}
this._worldMatrix.setTranslationFromFloats(0, 0, 0),
this._worldMatrix.multiplyToRef(I.Matrix[0], this._worldMatrix),
this._worldMatrix.setTranslation(I.Vector3[0])
} else if (o && n && this.billboardMode && r) {
g = I.Vector3[0],
this._worldMatrix.getTranslationToRef(g);
var y = n.globalPosition;
this._worldMatrix.invertToRef(I.Matrix[1]);
var b = I.Vector3[1];
x.TransformCoordinatesToRef(y, I.Matrix[1], b),
b.normalize();
var T = -Math.atan2(b.z, b.x) + Math.PI / 2
, E = Math.sqrt(b.x * b.x + b.z * b.z)
, S = -Math.atan2(b.y, E);
C.RotationYawPitchRollToRef(T, S, 0, I.Quaternion[0]),
(this.billboardMode & t.BILLBOARDMODE_ALL) !== t.BILLBOARDMODE_ALL ? (v = I.Vector3[1],
I.Quaternion[0].toEulerAnglesToRef(v),
(this.billboardMode & t.BILLBOARDMODE_X) !== t.BILLBOARDMODE_X && (v.x = 0),
(this.billboardMode & t.BILLBOARDMODE_Y) !== t.BILLBOARDMODE_Y && (v.y = 0),
(this.billboardMode & t.BILLBOARDMODE_Z) !== t.BILLBOARDMODE_Z && (v.z = 0),
P.RotationYawPitchRollToRef(v.y, v.x, v.z, I.Matrix[0])) : P.FromQuaternionToRef(I.Quaternion[0], I.Matrix[0]),
this._worldMatrix.setTranslationFromFloats(0, 0, 0),
this._worldMatrix.multiplyToRef(I.Matrix[0], this._worldMatrix),
this._worldMatrix.setTranslation(I.Vector3[0])
}
return this.ignoreNonUniformScaling ? this._updateNonUniformScalingState(!1) : this._scaling.isNonUniformWithinEpsilon(1e-6) ? this._updateNonUniformScalingState(!0) : l && l._nonUniformScaling ? this._updateNonUniformScalingState(l._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 = P.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 n = t[i];
if (n) {
n.computeWorldMatrix();
var r = I.Matrix[0];
n._localMatrix.multiplyToRef(this._localMatrix, r);
var o = I.Quaternion[0];
r.decompose(n.scaling, o, n.position),
n.rotationQuaternion ? n.rotationQuaternion.copyFrom(o) : o.toEulerAnglesToRef(n.rotation)
}
}
this.scaling.copyFromFloats(1, 1, 1),
this.position.copyFromFloats(0, 0, 0),
this.rotation.copyFromFloats(0, 0, 0),
this.rotationQuaternion && (this.rotationQuaternion = C.Identity()),
this._worldMatrix = P.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),
x.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, n) {
var r = this
, o = Ge.Clone((function() {
return new t(e,r.getScene())
}
), this);
if (o.name = e,
o.id = e,
i && (o.parent = i),
!n)
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 = Ge.Serialize(this, e);
return t.type = this.getClassName(),
t.uniqueId = this.uniqueId,
this.parent && (t.parentId = this.parent.uniqueId),
t.localMatrix = this.getPivotMatrix().asArray(),
t.isEnabled = this.isEnabled(),
this.parent && (t.parentId = this.parent.uniqueId),
t
}
,
t.Parse = function(e, i, n) {
var r = Ge.Parse((function() {
return new t(e.name,i)
}
), e, i, n);
return e.localMatrix ? r.setPreTransformMatrix(P.FromArray(e.localMatrix)) : e.pivotMatrix && r.setPivotMatrix(P.FromArray(e.pivotMatrix)),
r.setEnabled(e.isEnabled),
void 0 !== e.parentId && (r._waitingParentId = e.parentId),
r
}
,
t.prototype.getChildTransformNodes = function(e, i) {
var n = [];
return this._getDescendants(n, e, (function(e) {
return (!i || i(e)) && e instanceof t
}
)),
n
}
,
t.prototype.dispose = function(t, i) {
if (void 0 === i && (i = !1),
this.getScene().stopAnimation(this),
this.getScene().removeTransformNode(this),
this._parentContainer) {
var n = this._parentContainer.transformNodes.indexOf(this);
n > -1 && this._parentContainer.transformNodes.splice(n, 1),
this._parentContainer = null
}
if (this.onAfterWorldMatrixUpdateObservable.clear(),
t)
for (var r = 0, o = this.getChildTransformNodes(!0); r < o.length; r++) {
var a = o[r];
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 n = null
, r = null;
t && (this.rotationQuaternion ? (r = this.rotationQuaternion.clone(),
this.rotationQuaternion.copyFromFloats(0, 0, 0, 1)) : this.rotation && (n = 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 && r ? this.rotationQuaternion.copyFrom(r) : this.rotation && n && this.rotation.copyFrom(n)),
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._TmpRotation = C.Zero(),
t._TmpScaling = x.Zero(),
t._TmpTranslation = x.Zero(),
t._LookAtVectorCache = new x(0,0,0),
t._RotationAxisCache = new C,
k([De("position")], t.prototype, "_position", void 0),
k([De("rotation")], t.prototype, "_rotation", void 0),
k([Be("rotationQuaternion")], t.prototype, "_rotationQuaternion", void 0),
k([De("scaling")], t.prototype, "_scaling", void 0),
k([Ce("billboardMode")], t.prototype, "_billboardMode", void 0),
k([Ce()], t.prototype, "scalingDeterminant", void 0),
k([Ce("infiniteDistance")], t.prototype, "_infiniteDistance", void 0),
k([Ce()], t.prototype, "ignoreNonUniformScaling", void 0),
k([Ce()], t.prototype, "reIntegrateRotationIntoRotationQuaternion", void 0),
t
}(Xe)
, br = function() {
this._checkCollisions = !1,
this._collisionMask = -1,
this._collisionGroup = -1,
this._surroundingMeshes = null,
this._collider = null,
this._oldPositionForCollisions = new x(0,0,0),
this._diffPositionForCollisions = new x(0,0,0),
this._collisionResponse = !0
}
, Tr = function() {
this.facetNb = 0,
this.partitioningSubdivisions = 10,
this.partitioningBBoxRatio = 1.01,
this.facetDataEnabled = !1,
this.facetParameters = {},
this.bbSize = x.Zero(),
this.subDiv = {
max: 1,
X: 1,
Y: 1,
Z: 1
},
this.facetDepthSort = !1,
this.facetDepthSortEnabled = !1
}
, Er = function() {
this._hasVertexAlpha = !1,
this._useVertexColors = !0,
this._numBoneInfluencers = 4,
this._applyFog = !0,
this._receiveShadows = !1,
this._facetData = new Tr,
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._meshCollisionData = new br,
this._enableDistantPicking = !1
}
, Sr = function(e) {
function t(i, n) {
void 0 === n && (n = null);
var r = e.call(this, i, n, !1) || this;
return r._internalAbstractMeshDataInfo = new Er,
r._waitingMaterialId = null,
r.cullingStrategy = t.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,
r.onCollideObservable = new h,
r.onCollisionPositionChangeObservable = new h,
r.onMaterialChangedObservable = new h,
r.definedFacingForward = !0,
r._occlusionQuery = null,
r._renderingGroup = null,
r.alphaIndex = Number.MAX_VALUE,
r.isVisible = !0,
r.isPickable = !0,
r.isNearPickable = !1,
r.isNearGrabbable = !1,
r.showSubMeshesBoundingBox = !1,
r.isBlocker = !1,
r.enablePointerMoveEvents = !1,
r.outlineColor = D.Red(),
r.outlineWidth = .02,
r.overlayColor = D.Red(),
r.overlayAlpha = .5,
r.useOctreeForRenderingSelection = !0,
r.useOctreeForPicking = !0,
r.useOctreeForCollisions = !0,
r.alwaysSelectAsActiveMesh = !1,
r.doNotSyncBoundingInfo = !1,
r.actionManager = null,
r.ellipsoid = new x(.5,1,.5),
r.ellipsoidOffset = new x(0,0,0),
r.edgesWidth = 1,
r.edgesColor = new N(1,0,0,1),
r._edgesRenderer = null,
r._masterMesh = null,
r._boundingInfo = null,
r._boundingInfoIsDirty = !0,
r._renderId = 0,
r._intersectionsInProgress = new Array,
r._unIndexed = !1,
r._lightSources = new Array,
r._waitingData = {
lods: null,
actions: null,
freezeWorldMatrix: null
},
r._bonesTransformMatrices = null,
r._transformMatrixTexture = null,
r.onRebuildObservable = new h,
r._onCollisionPositionChange = function(e, t, i) {
void 0 === i && (i = null),
t.subtractToRef(r._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions, r._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),
r._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions.length() > vr.CollisionsEpsilon && r.position.addInPlace(r._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),
i && r.onCollideObservable.notifyObservers(i),
r.onCollisionPositionChangeObservable.notifyObservers(r.position)
}
,
r.getScene().addMesh(r),
r._resyncLightSources(),
r._uniformBuffer = new Fi(r.getScene().getEngine(),void 0,void 0,i,!r.getScene().getEngine().isWebGPU),
r._buildUniformLayout(),
r
}
return U(t, e),
Object.defineProperty(t, "BILLBOARDMODE_NONE", {
get: function() {
return yr.BILLBOARDMODE_NONE
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t, "BILLBOARDMODE_X", {
get: function() {
return yr.BILLBOARDMODE_X
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t, "BILLBOARDMODE_Y", {
get: function() {
return yr.BILLBOARDMODE_Y
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t, "BILLBOARDMODE_Z", {
get: function() {
return yr.BILLBOARDMODE_Z
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t, "BILLBOARDMODE_ALL", {
get: function() {
return yr.BILLBOARDMODE_ALL
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t, "BILLBOARDMODE_USE_POSITION", {
get: function() {
return yr.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, "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._markSubMeshesAsMiscDirty()
}
},
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._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 !== yr.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)
, n = !1;
if (-1 === i) {
if (!t)
return;
this._lightSources.push(e)
} else {
if (t)
return;
n = !0,
this._lightSources.splice(i, 1)
}
this._markSubMeshesAsLightDirty(n)
}
,
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 n = i[t], r = 0; r < n._drawWrappers.length; ++r) {
var o = n._drawWrappers[r];
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, "scaling", {
get: function() {
return this._scaling
},
set: function(e) {
this._scaling = e
},
enumerable: !1,
configurable: !0
}),
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, n) {
return this
}
,
t.prototype.updateVerticesData = function(e, t, i, n) {
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.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 sr(e,t,i),
this._boundingInfo
}
,
t.prototype.normalizeToUnitCube = function(t, i, n) {
return void 0 === t && (t = !0),
void 0 === i && (i = !1),
e.prototype.normalizeToUnitCube.call(this, t, i, n)
}
,
Object.defineProperty(t.prototype, "useBones", {
get: function() {
return this.skeleton && this.getScene().skeletonsEnabled && this.isVerticesDataPresent(Bi.MatricesIndicesKind) && this.isVerticesDataPresent(Bi.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 === yr.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 n = new P;
(this.rotationQuaternion ? this.rotationQuaternion : C.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z)).toRotationMatrix(n);
var r = x.Zero()
, o = this.definedFacingForward ? -1 : 1;
return x.TransformCoordinatesFromFloatsToRef(e * o, t, i * o, n, r),
r
}
,
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 n = this.definedFacingForward ? 1 : -1;
return new x(e * n,t,i * n)
}
,
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 = ur(e, 0, this.getTotalVertices(), t);
this._boundingInfo ? this._boundingInfo.reConstruct(i.minimum, i.maximum) : this._boundingInfo = new sr(i.minimum,i.maximum)
}
if (this.subMeshes)
for (var n = 0; n < this.subMeshes.length; n++)
this.subMeshes[n].refreshBoundingInfo(e);
this._updateBoundingInfo()
}
,
t.prototype.getPositionData = function(e, t, i) {
if ((i = null != i ? i : this.getVerticesData(Bi.PositionKind)) && t && this.morphTargetManager)
for (var n = 0, r = 0, o = 0; o < i.length; o++) {
for (var a = 0; a < this.morphTargetManager.numTargets; a++) {
var s = this.morphTargetManager.getTarget(a)
, l = s.influence;
if (l > 0) {
var c = s.getPositions();
c && (i[o] += (c[o] - i[o]) * l)
}
}
if (n++,
this._positions && 3 === n) {
n = 0;
var u = 3 * r;
this._positions[r++].copyFromFloats(i[u], i[u + 1], i[u + 2])
}
}
if (i && e && this.skeleton) {
var h = this.getVerticesData(Bi.MatricesIndicesKind)
, d = this.getVerticesData(Bi.MatricesWeightsKind);
if (d && h) {
var p = this.numBoneInfluencers > 4
, f = p ? this.getVerticesData(Bi.MatricesIndicesExtraKind) : null
, _ = p ? this.getVerticesData(Bi.MatricesWeightsExtraKind) : null
, m = this.skeleton.getTransformMatrices(this)
, g = I.Vector3[0]
, v = I.Matrix[0]
, y = I.Matrix[1]
, b = 0;
for (u = 0; u < i.length; u += 3,
b += 4) {
v.reset();
var T = void 0
, E = void 0;
for (T = 0; T < 4; T++)
(E = d[b + T]) > 0 && (P.FromFloat32ArrayToRefScaled(m, Math.floor(16 * h[b + T]), E, y),
v.addToSelf(y));
if (p)
for (T = 0; T < 4; T++)
(E = _[b + T]) > 0 && (P.FromFloat32ArrayToRefScaled(m, Math.floor(16 * f[b + T]), E, y),
v.addToSelf(y));
x.TransformCoordinatesFromFloatsToRef(i[u], i[u + 1], i[u + 2], v, g),
g.toArray(i, u),
this._positions && this._positions[u / 3].copyFrom(g)
}
}
}
return i
}
,
t.prototype._getPositionData = function(e, t) {
var i, n = this.getVerticesData(Bi.PositionKind);
if (this._internalAbstractMeshDataInfo._positions && (this._internalAbstractMeshDataInfo._positions = null),
n && (e && this.skeleton || t && this.morphTargetManager) && (n = gi.Slice(n),
this._generatePointsArray(),
this._positions)) {
var r = this._positions;
this._internalAbstractMeshDataInfo._positions = new Array(r.length);
for (var o = 0; o < r.length; o++)
this._internalAbstractMeshDataInfo._positions[o] = (null === (i = r[o]) || void 0 === i ? void 0 : i.clone()) || new x
}
return this.getPositionData(e, t, n)
}
,
t.prototype._updateBoundingInfo = function() {
return this._boundingInfo ? this._boundingInfo.update(this.worldMatrixFromCache) : this._boundingInfo = new sr(this.position,this.position,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 n = this.subMeshes[i];
(t > 1 || !n.IsGlobal) && n.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 n = this.getBoundingInfo()
, r = e.getBoundingInfo();
if (n.intersects(r, 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 n;
if (this._generatePointsArray(),
!this._positions)
return this;
if (!e._lastColliderWorldVertices || !e._lastColliderTransformMatrix.equals(t)) {
e._lastColliderTransformMatrix = t.clone(),
e._lastColliderWorldVertices = [],
e._trianglePlanes = [];
for (var r = e.verticesStart, o = e.verticesStart + e.verticesCount, s = r; s < o; s++)
e._lastColliderWorldVertices.push(x.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 === (n = e.getMaterial()) || void 0 === n ? void 0 : n.fillMode) === a.MATERIAL_TriangleStripDrawMode),
this
}
,
t.prototype._processCollisionsForSubMeshes = function(e, t) {
for (var i = this._scene.getCollidingSubMeshCandidates(this, e), n = i.length, r = 0; r < n; r++) {
var o = i.data[r];
n > 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 = I.Matrix[0]
, i = I.Matrix[1];
return P.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, n, r, o) {
void 0 === n && (n = !1),
void 0 === o && (o = !1);
var s = new Ui
, l = "InstancedLinesMesh" === this.getClassName() || "LinesMesh" === this.getClassName() ? this.intersectionThreshold : 0
, c = this.getBoundingInfo();
if (!this.subMeshes)
return s;
if (!(o || e.intersectsSphere(c.boundingSphere, l) && e.intersectsBox(c.boundingBox, l)))
return s;
if (n)
return s.hit = !o,
s.pickedMesh = o ? null : this,
s.distance = o ? 0 : x.Distance(e.origin, c.boundingSphere.center),
s.subMeshId = 0,
s;
if (!this._generatePointsArray())
return s;
for (var u = null, h = this._scene.getIntersectingSubMeshCandidates(this, e), d = h.length, p = !1, f = 0; f < d; f++) {
var _ = (m = h.data[f]).getMaterial();
if (_ && (_.fillMode == a.MATERIAL_TriangleStripDrawMode || _.fillMode == a.MATERIAL_TriangleFillMode || _.fillMode == a.MATERIAL_WireFrameFillMode || _.fillMode == a.MATERIAL_PointFillMode || _.fillMode == a.MATERIAL_LineListDrawMode)) {
p = !0;
break
}
}
if (!p)
return s.hit = !0,
s.pickedMesh = this,
s.distance = x.Distance(e.origin, c.boundingSphere.center),
s.subMeshId = -1,
s;
for (f = 0; f < d; f++) {
var m = h.data[f];
if (!(d > 1) || m.canIntersects(e)) {
var g = m.intersects(e, this._positions, this.getIndices(), t, i);
if (g && (t || !u || g.distance < u.distance) && ((u = g).subMeshId = f,
t))
break
}
}
if (u) {
var v = null != r ? r : this.getWorldMatrix()
, y = I.Vector3[0]
, b = I.Vector3[1];
x.TransformCoordinatesToRef(e.origin, v, y),
e.direction.scaleToRef(u.distance, b);
var T = x.TransformNormal(b, v).addInPlace(y);
return s.hit = !0,
s.distance = x.Distance(y, T),
s.pickedPoint = T,
s.pickedMesh = this,
s.bu = u.bu || 0,
s.bv = u.bv || 0,
s.subMeshFaceId = u.faceId,
s.faceId = u.faceId + h.data[u.subMeshId].indexStart / (-1 !== this.getClassName().indexOf("LinesMesh") ? 2 : 3),
s.subMeshId = u.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 n, r = 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),
n = 0; n < this._intersectionsInProgress.length; n++) {
var o = this._intersectionsInProgress[n]
, a = o._intersectionsInProgress.indexOf(this);
o._intersectionsInProgress.splice(a, 1)
}
this._intersectionsInProgress = [],
this.getScene().lights.forEach((function(e) {
var t = e.includedOnlyMeshes.indexOf(r);
-1 !== t && e.includedOnlyMeshes.splice(t, 1),
-1 !== (t = e.excludedMeshes.indexOf(r)) && e.excludedMeshes.splice(t, 1);
var i = e.getShadowGenerator();
if (i) {
var n = i.getShadowMap();
n && n.renderList && -1 !== (t = n.renderList.indexOf(r)) && n.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 (n = 0; n < this.getScene().particleSystems.length; n++)
this.getScene().particleSystems[n].emitter === this && (this.getScene().particleSystems[n].dispose(),
n--);
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] = x.Zero(),
e.facetPositions[t] = x.Zero();
return e.facetDataEnabled = !0,
this
}
,
t.prototype.updateFacetData = function() {
var e = this._internalAbstractMeshDataInfo._facetData;
e.facetDataEnabled || this._initFacetData();
var t = this.getVerticesData(Bi.PositionKind)
, i = this.getIndices()
, n = this.getVerticesData(Bi.NormalKind)
, r = 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 : x.Zero()
}
e.depthSortedFacets = [];
for (var l = 0; l < e.facetNb; l++) {
var c = {
ind: 3 * l,
sqDistance: 0
};
e.depthSortedFacets.push(c)
}
e.invertedMatrix = P.Identity(),
e.facetDepthSortOrigin = x.Zero()
}
e.bbSize.x = r.maximum.x - r.minimum.x > m ? r.maximum.x - r.minimum.x : m,
e.bbSize.y = r.maximum.y - r.minimum.y > m ? r.maximum.y - r.minimum.y : m,
e.bbSize.z = r.maximum.z - r.minimum.z > m ? r.maximum.z - r.minimum.z : m;
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 = r,
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),
x.TransformCoordinatesToRef(e.facetDepthSortFrom, e.invertedMatrix, e.facetDepthSortOrigin),
e.facetParameters.distanceTo = e.facetDepthSortOrigin),
e.facetParameters.depthSortedFacets = e.depthSortedFacets,
n && $n.ComputeNormals(t, i, n, 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 = x.Zero();
return this.getFacetPositionToRef(e, t),
t
}
,
t.prototype.getFacetPositionToRef = function(e, t) {
var i = this.getFacetLocalPositions()[e]
, n = this.getWorldMatrix();
return x.TransformCoordinatesToRef(i, n, t),
this
}
,
t.prototype.getFacetNormal = function(e) {
var t = x.Zero();
return this.getFacetNormalToRef(e, t),
t
}
,
t.prototype.getFacetNormalToRef = function(e, t) {
var i = this.getFacetLocalNormals()[e];
return x.TransformNormalToRef(i, this.getWorldMatrix(), t),
this
}
,
t.prototype.getFacetsAtLocalCoordinates = function(e, t, i) {
var n = this.getBoundingInfo()
, r = this._internalAbstractMeshDataInfo._facetData
, o = Math.floor((e - n.minimum.x * r.partitioningBBoxRatio) * r.subDiv.X * r.partitioningBBoxRatio / r.bbSize.x)
, a = Math.floor((t - n.minimum.y * r.partitioningBBoxRatio) * r.subDiv.Y * r.partitioningBBoxRatio / r.bbSize.y)
, s = Math.floor((i - n.minimum.z * r.partitioningBBoxRatio) * r.subDiv.Z * r.partitioningBBoxRatio / r.bbSize.z);
return o < 0 || o > r.subDiv.max || a < 0 || a > r.subDiv.max || s < 0 || s > r.subDiv.max ? null : r.facetPartitioning[o + r.subDiv.max * a + r.subDiv.max * r.subDiv.max * s]
}
,
t.prototype.getClosestFacetAtCoordinates = function(e, t, i, n, r, o) {
void 0 === r && (r = !1),
void 0 === o && (o = !0);
var a = this.getWorldMatrix()
, s = I.Matrix[5];
a.invertToRef(s);
var l = I.Vector3[8];
x.TransformCoordinatesFromFloatsToRef(e, t, i, s, l);
var c = this.getClosestFacetAtLocalCoordinates(l.x, l.y, l.z, n, r, o);
return n && x.TransformCoordinatesFromFloatsToRef(n.x, n.y, n.z, a, n),
c
}
,
t.prototype.getClosestFacetAtLocalCoordinates = function(e, t, i, n, r, o) {
void 0 === r && (r = !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,
(!r || r && o && u >= 0 || r && !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,
n && (n.x = d,
n.y = p,
n.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(Bi.PositionKind), n = this.getIndices();
return t = this.isVerticesDataPresent(Bi.NormalKind) ? this.getVerticesData(Bi.NormalKind) : [],
$n.ComputeNormals(i, n, t, {
useRightHandedSystem: this.getScene().useRightHandedSystem
}),
this.setVerticesData(Bi.NormalKind, t, e),
this
}
,
t.prototype.alignWithNormal = function(e, t) {
t || (t = vn.Y);
var i = I.Vector3[0]
, n = I.Vector3[1];
return x.CrossToRef(t, e, n),
x.CrossToRef(e, n, i),
this.rotationQuaternion ? C.RotationQuaternionFromAxisToRef(i, e, n, this.rotationQuaternion) : x.RotationFromAxisToRef(i, e, n, this.rotation),
this
}
,
t.prototype._checkOcclusionQuery = function() {
return !1
}
,
t.prototype.disableEdgesRendering = function() {
throw be("EdgesRenderer")
}
,
t.prototype.enableEdgesRendering = function(e, t, i) {
throw be("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
}(yr);
y("BABYLON.AbstractMesh", Sr);
var Ar, xr = function() {
function e(e, t, i, n) {
this.x = e,
this.y = t,
this.width = i,
this.height = n
}
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
}(), Rr = function(e) {
function t(i, n, r, o) {
void 0 === o && (o = !0);
var a = e.call(this, i, r) || this;
return a._position = x.Zero(),
a._upVector = x.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 xr(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 h,
a.onProjectionMatrixChangedObservable = new h,
a.onAfterCheckInputsObservable = new h,
a.onRestoreStateObservable = new h,
a.isRigCamera = !1,
a._rigCameras = new Array,
a._webvrViewMatrix = P.Identity(),
a._skipRendering = !1,
a._projectionMatrix = new P,
a._postProcesses = new Array,
a._activeMeshes = new bi(256),
a._globalPosition = x.Zero(),
a._computedViewMatrix = P.Identity(),
a._doNotComputeProjectionMatrix = !1,
a._transformMatrix = P.Zero(),
a._refreshFrustumPlanes = !0,
a._absoluteRotation = C.Identity(),
a._isCamera = !0,
a._isLeftCamera = !1,
a._isRightCamera = !1,
a.getScene().addCamera(a),
o && !a.getScene().activeCamera && (a.getScene().activeCamera = a),
a.position = n,
a.renderPassId = a.getScene().getEngine().createRenderPassId("Camera ".concat(i)),
a
}
return U(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, n, r, 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 !== (n = this.orthoTop) && void 0 !== n ? n : l) - (null !== (r = this.orthoBottom) && void 0 !== r ? r : -l)
}
return o * a
},
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, n = this._postProcesses; i < n.length; i++) {
var r = n[i];
if (r && !r.isReady())
return !1
}
return e.prototype.isReady.call(this, t)
}
,
t.prototype._initCache = function() {
e.prototype._initCache.call(this),
this._cache.position = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
this._cache.upVector = new x(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()
}
,
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 n = this._rigCameras[t]
, r = n._rigPostProcess;
r ? ("pass" === r.getEffectName() && (n.isIntermediate = 0 === this._postProcesses.length),
n._postProcesses = this._postProcesses.slice(0).concat(r),
r.markTextureDirty()) : n._postProcesses = this._postProcesses.slice(0)
}
}
,
t.prototype.attachPostProcess = function(e, t) {
return void 0 === t && (t = null),
!e.isReusable() && this._postProcesses.indexOf(e) > -1 ? (K.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 P.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, n, r, 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();
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);
var d = u.useReverseDepthBuffer;
(h.useRightHandedSystem ? P.PerspectiveFovRHToRef : P.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, u.useReverseDepthBuffer)
} else {
var p = u.getRenderWidth() / 2
, f = u.getRenderHeight() / 2;
h.useRightHandedSystem ? P.OrthoOffCenterRHToRef(null !== (i = this.orthoLeft) && void 0 !== i ? i : -p, null !== (n = this.orthoRight) && void 0 !== n ? n : p, null !== (r = this.orthoBottom) && void 0 !== r ? r : -f, null !== (o = this.orthoTop) && void 0 !== o ? o : f, this.minZ, this.maxZ, this._projectionMatrix, u.isNDCHalfZRange) : P.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, 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 ? dn.GetPlanesToRef(this._transformMatrix, this._frustumPlanes) : this._frustumPlanes = dn.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),
be("Ray")
}
,
t.prototype.getForwardRayToRef = function(e, t, i, n) {
throw void 0 === t && (t = 100),
be("Ray")
}
,
t.prototype.dispose = function(i, n) {
for (void 0 === n && (n = !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 r = this._rigCameras.pop();
r && r.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 = [];
else if (this.cameraRigMode !== t.RIG_MODE_NONE)
this._rigPostProcess = null,
this._postProcesses = [];
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 = [],
this._activeMeshes.dispose(),
this.getScene().getEngine().releaseRenderPassId(this.renderPassId),
e.prototype.dispose.call(this, i, n)
}
,
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 n = this._rigCameras.pop();
n && n.dispose()
}
if (this.cameraRigMode = e,
this._cameraRigParams = {},
this._cameraRigParams.interaxialDistance = i.interaxialDistance || .0637,
this._cameraRigParams.stereoHalfAngle = gi.ToRadians(this._cameraRigParams.interaxialDistance / .0637),
this.cameraRigMode !== t.RIG_MODE_NONE) {
var r = this.createRigCamera(this.name + "_L", 0);
r && (r._isLeftCamera = !0);
var o = this.createRigCamera(this.name + "_R", 1);
o && (o._isRightCamera = !0),
r && o && (this._rigCameras.push(r),
this._rigCameras.push(o))
}
this._setRigMode(i),
this._cascadePostProcessesToRigCams(),
this.update()
}
}
,
t.prototype._setRigMode = function(e) {}
,
t.prototype._getVRProjectionMatrix = function() {
return P.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 P.Identity()
}
,
t.prototype._getWebVRViewMatrix = function() {
return P.Identity()
}
,
t.prototype.setCameraRigParameter = function(e, t) {
this._cameraRigParams || (this._cameraRigParams = {}),
this._cameraRigParams[e] = t,
"interaxialDistance" === e && (this._cameraRigParams.stereoHalfAngle = gi.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 = Ge.Serialize(this);
return e.uniqueId = this.uniqueId,
e.type = this.getClassName(),
this.parent && (e.parentId = this.parent.uniqueId),
this.inputs && this.inputs.serialize(e),
Ge.AppendSerializedAnimations(this, e),
e.ranges = this.serializeAnimationRanges(),
e.isEnabled = this.isEnabled(),
e
}
,
t.prototype.clone = function(e) {
var i = Ge.Clone(t.GetConstructorFromName(this.getClassName(), e, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
return i.name = e,
this.onClonedObservable.notifyObservers(i),
i
}
,
t.prototype.getDirection = function(e) {
var t = x.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) {
x.TransformNormalToRef(e, this.getWorldMatrix(), t)
}
,
t.GetConstructorFromName = function(e, i, n, r, o) {
return void 0 === r && (r = 0),
void 0 === o && (o = !0),
Xe.Construct(e, i, n, {
interaxial_distance: r,
isStereoscopicSideBySide: o
}) || function() {
return t._CreateDefaultParsedCamera(i, n)
}
}
,
t.prototype.computeWorldMatrix = function() {
return this.getWorldMatrix()
}
,
t.Parse = function(e, i) {
var n = e.type
, r = t.GetConstructorFromName(n, e.name, i, e.interaxial_distance, e.isStereoscopicSideBySide)
, o = Ge.Parse(r, e, i);
if (void 0 !== e.parentId && (o._waitingParentId = e.parentId),
o.inputs && (o.inputs.parse(e),
o._setupInputs()),
e.upVector && (o.upVector = x.FromArray(e.upVector)),
o.setPosition && (o.position.copyFromFloats(0, 0, 0),
o.setPosition(x.FromArray(e.position))),
e.target && o.setTarget && o.setTarget(x.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 = b("BABYLON.Animation");
c && o.animations.push(c.Parse(l))
}
Xe.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 be("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,
k([De("position")], t.prototype, "_position", void 0),
k([De("upVector")], t.prototype, "_upVector", void 0),
k([Ce()], t.prototype, "orthoLeft", void 0),
k([Ce()], t.prototype, "orthoRight", void 0),
k([Ce()], t.prototype, "orthoBottom", void 0),
k([Ce()], t.prototype, "orthoTop", void 0),
k([Ce()], t.prototype, "fov", void 0),
k([Ce()], t.prototype, "projectionPlaneTilt", void 0),
k([Ce()], t.prototype, "minZ", void 0),
k([Ce()], t.prototype, "maxZ", void 0),
k([Ce()], t.prototype, "inertia", void 0),
k([Ce()], t.prototype, "mode", void 0),
k([Ce()], t.prototype, "layerMask", void 0),
k([Ce()], t.prototype, "fovMode", void 0),
k([Ce()], t.prototype, "cameraRigMode", void 0),
k([Ce()], t.prototype, "interaxialDistance", void 0),
k([Ce()], t.prototype, "isStereoscopicSideBySide", void 0),
t
}(Xe), Cr = function(e) {
function t(i, n) {
var r = e.call(this, i, n) || this;
return r.diffuse = new D(1,1,1),
r.specular = new D(1,1,1),
r.falloffType = t.FALLOFF_DEFAULT,
r.intensity = 1,
r._range = Number.MAX_VALUE,
r._inverseSquaredRange = 0,
r._photometricScale = 1,
r._intensityMode = t.INTENSITYMODE_AUTOMATIC,
r._radius = 1e-5,
r.renderPriority = 0,
r._shadowEnabled = !0,
r._excludeWithLayerMask = 0,
r._includeOnlyWithLayerMask = 0,
r._lightmapMode = 0,
r._excludedMeshesIds = new Array,
r._includedOnlyMeshesIds = new Array,
r._isLight = !0,
r.getScene().addLight(r),
r._uniformBuffer = new Fi(r.getScene().getEngine(),void 0,void 0,i),
r._buildUniformLayout(),
r.includedOnlyMeshes = new Array,
r.excludedMeshes = new Array,
r._resyncMeshes(),
r
}
return U(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, n, r) {
void 0 === r && (r = !0);
var o = e.toString()
, a = !1;
if (this._uniformBuffer.bindToEffect(i, "Light" + o),
this._renderId !== t.getRenderId() || this._lastUseSpecular !== n || !this._uniformBuffer.useUbo) {
this._renderId = t.getRenderId(),
this._lastUseSpecular = n;
var s = this.getScaledIntensity();
this.transferToEffect(i, o),
this.diffuse.scaleToRef(s, L.Color3[0]),
this._uniformBuffer.updateColor4("vLightDiffuse", L.Color3[0], this.range, o),
n && (this.specular.scaleToRef(s, L.Color3[1]),
this._uniformBuffer.updateColor4("vLightSpecular", L.Color3[1], this.radius, o)),
a = !0
}
if (this.transferTexturesToEffect(i, o),
t.shadowsEnabled && this.shadowEnabled && r) {
var l = this.getShadowGenerator();
l && (l.bindShadowLight(o, i),
a = !0)
}
a ? 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() {
return this._shadowGenerator
}
,
t.prototype.getAbsolutePosition = function() {
return x.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._shadowGenerator && (this._shadowGenerator.dispose(),
this._shadowGenerator = null),
this.getScene().stopAnimation(this),
this._parentContainer) {
var n = this._parentContainer.lights.indexOf(this);
n > -1 && this._parentContainer.lights.splice(n, 1),
this._parentContainer = null
}
for (var r = 0, o = this.getScene().meshes; r < o.length; r++)
o[r]._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 n = t.GetConstructorFromName(this.getTypeID(), e, this.getScene());
if (!n)
return null;
var r = Ge.Clone(n, this);
return e && (r.name = e),
i && (r.parent = i),
r.setEnabled(this.isEnabled()),
this.onClonedObservable.notifyObservers(r),
r
}
,
t.prototype.serialize = function() {
var e = Ge.Serialize(this);
return e.uniqueId = this.uniqueId,
e.type = this.getTypeID(),
this.parent && (e.parentId = this.parent.uniqueId),
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)
}
))),
Ge.AppendSerializedAnimations(this, e),
e.ranges = this.serializeAnimationRanges(),
e.isEnabled = this.isEnabled(),
e
}
,
t.GetConstructorFromName = function(e, t, i) {
return Xe.Construct("Light_Type_" + e, t, i) || null
}
,
t.Parse = function(e, i) {
var n = t.GetConstructorFromName(e.type, e.name, i);
if (!n)
return null;
var r = Ge.Parse(n, e, i);
if (e.excludedMeshesIds && (r._excludedMeshesIds = e.excludedMeshesIds),
e.includedOnlyMeshesIds && (r._includedOnlyMeshesIds = e.includedOnlyMeshesIds),
void 0 !== e.parentId && (r._waitingParentId = e.parentId),
void 0 !== e.falloffType && (r.falloffType = e.falloffType),
void 0 !== e.lightmapMode && (r.lightmapMode = e.lightmapMode),
e.animations) {
for (var o = 0; o < e.animations.length; o++) {
var a = e.animations[o]
, s = b("BABYLON.Animation");
s && r.animations.push(s.Parse(a))
}
Xe.ParseAnimationRanges(r, e, i)
}
return e.autoAnimate && i.beginAnimation(r, e.autoAnimateFrom, e.autoAnimateTo, e.autoAnimateLoop, e.autoAnimateSpeed || 1),
void 0 !== e.isEnabled && r.setEnabled(e.isEnabled),
r
}
,
t.prototype._hookArrayForExcluded = function(e) {
var t = this
, i = e.push;
e.push = function() {
for (var n = [], r = 0; r < arguments.length; r++)
n[r] = arguments[r];
for (var o = i.apply(e, n), a = 0, s = n; a < s.length; a++) {
var l = s[a];
l._resyncLightSource(t)
}
return o
}
;
var n = e.splice;
e.splice = function(i, r) {
for (var o = n.apply(e, [i, r]), a = 0, s = o; a < s.length; a++)
s[a]._resyncLightSource(t);
return o
}
;
for (var r = 0, o = e; r < o.length; r++)
o[r]._resyncLightSource(this)
}
,
t.prototype._hookArrayForIncludedOnly = function(e) {
var t = this
, i = e.push;
e.push = function() {
for (var n = [], r = 0; r < arguments.length; r++)
n[r] = arguments[r];
var o = i.apply(e, n);
return t._resyncMeshes(),
o
}
;
var n = e.splice;
e.splice = function(i, r) {
var o = n.apply(e, [i, r]);
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()
, n = this.intensityMode;
switch (n === t.INTENSITYMODE_AUTOMATIC && (n = i === t.LIGHTTYPEID_DIRECTIONALLIGHT ? t.INTENSITYMODE_ILLUMINANCE : t.INTENSITYMODE_LUMINOUSINTENSITY),
i) {
case t.LIGHTTYPEID_POINTLIGHT:
case t.LIGHTTYPEID_SPOTLIGHT:
switch (n) {
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 (n) {
case t.INTENSITYMODE_ILLUMINANCE:
e = 1;
break;
case t.INTENSITYMODE_LUMINANCE:
var r = this.radius;
r = Math.max(r, .001),
e = 2 * Math.PI * (1 - Math.cos(r))
}
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 = fn.FALLOFF_DEFAULT,
t.FALLOFF_PHYSICAL = fn.FALLOFF_PHYSICAL,
t.FALLOFF_GLTF = fn.FALLOFF_GLTF,
t.FALLOFF_STANDARD = fn.FALLOFF_STANDARD,
t.LIGHTMAP_DEFAULT = fn.LIGHTMAP_DEFAULT,
t.LIGHTMAP_SPECULAR = fn.LIGHTMAP_SPECULAR,
t.LIGHTMAP_SHADOWSONLY = fn.LIGHTMAP_SHADOWSONLY,
t.INTENSITYMODE_AUTOMATIC = fn.INTENSITYMODE_AUTOMATIC,
t.INTENSITYMODE_LUMINOUSPOWER = fn.INTENSITYMODE_LUMINOUSPOWER,
t.INTENSITYMODE_LUMINOUSINTENSITY = fn.INTENSITYMODE_LUMINOUSINTENSITY,
t.INTENSITYMODE_ILLUMINANCE = fn.INTENSITYMODE_ILLUMINANCE,
t.INTENSITYMODE_LUMINANCE = fn.INTENSITYMODE_LUMINANCE,
t.LIGHTTYPEID_POINTLIGHT = fn.LIGHTTYPEID_POINTLIGHT,
t.LIGHTTYPEID_DIRECTIONALLIGHT = fn.LIGHTTYPEID_DIRECTIONALLIGHT,
t.LIGHTTYPEID_SPOTLIGHT = fn.LIGHTTYPEID_SPOTLIGHT,
t.LIGHTTYPEID_HEMISPHERICLIGHT = fn.LIGHTTYPEID_HEMISPHERICLIGHT,
k([Me()], t.prototype, "diffuse", void 0),
k([Me()], t.prototype, "specular", void 0),
k([Ce()], t.prototype, "falloffType", void 0),
k([Ce()], t.prototype, "intensity", void 0),
k([Ce()], t.prototype, "range", null),
k([Ce()], t.prototype, "intensityMode", null),
k([Ce()], t.prototype, "radius", null),
k([Ce()], t.prototype, "_renderPriority", void 0),
k([Re("_reorderLightsInScene")], t.prototype, "renderPriority", void 0),
k([Ce("shadowEnabled")], t.prototype, "_shadowEnabled", void 0),
k([Ce("excludeWithLayerMask")], t.prototype, "_excludeWithLayerMask", void 0),
k([Ce("includeOnlyWithLayerMask")], t.prototype, "_includeOnlyWithLayerMask", void 0),
k([Ce("lightmapMode")], t.prototype, "_lightmapMode", void 0),
t
}(Xe), Pr = function() {
function e() {}
return e.BindClipPlane = function(e, t) {
if (t.clipPlane) {
var i = t.clipPlane;
e.setFloat4("vClipPlane", i.normal.x, i.normal.y, i.normal.z, i.d)
}
t.clipPlane2 && (i = t.clipPlane2,
e.setFloat4("vClipPlane2", i.normal.x, i.normal.y, i.normal.z, i.d)),
t.clipPlane3 && (i = t.clipPlane3,
e.setFloat4("vClipPlane3", i.normal.x, i.normal.y, i.normal.z, i.d)),
t.clipPlane4 && (i = t.clipPlane4,
e.setFloat4("vClipPlane4", i.normal.x, i.normal.y, i.normal.z, i.d)),
t.clipPlane5 && (i = t.clipPlane5,
e.setFloat4("vClipPlane5", i.normal.x, i.normal.y, i.normal.z, i.d)),
t.clipPlane6 && (i = t.clipPlane6,
e.setFloat4("vClipPlane6", i.normal.x, i.normal.y, i.normal.z, i.d))
}
,
e
}(), Mr = 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.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 n = e.getTextureMatrix();
t.updateMatrix(i + "Matrix", n)
}
,
e.GetFogState = function(e, t) {
return t.fogEnabled && e.applyFog && t.fogMode !== mn.FOGMODE_NONE
}
,
e.PrepareDefinesForMisc = function(e, t, i, n, r, o, a) {
a._areMiscDirty && (a.LOGARITHMICDEPTH = i,
a.POINTSIZE = n,
a.FOG = r && this.GetFogState(e, t),
a.NONUNIFORMSCALING = e.nonUniformScaling,
a.ALPHATEST = o)
}
,
e.PrepareDefinesForFrameBoundValues = function(e, t, i, n, r, o) {
void 0 === r && (r = null),
void 0 === o && (o = !1);
var a, s, l, c, u, h, d = !1;
a = null == r ? void 0 !== e.clipPlane && null !== e.clipPlane : r,
s = null == r ? void 0 !== e.clipPlane2 && null !== e.clipPlane2 : r,
l = null == r ? void 0 !== e.clipPlane3 && null !== e.clipPlane3 : r,
c = null == r ? void 0 !== e.clipPlane4 && null !== e.clipPlane4 : r,
u = null == r ? void 0 !== e.clipPlane5 && null !== e.clipPlane5 : r,
h = null == r ? void 0 !== e.clipPlane6 && null !== e.clipPlane6 : r,
i.CLIPPLANE !== a && (i.CLIPPLANE = a,
d = !0),
i.CLIPPLANE2 !== s && (i.CLIPPLANE2 = s,
d = !0),
i.CLIPPLANE3 !== l && (i.CLIPPLANE3 = l,
d = !0),
i.CLIPPLANE4 !== c && (i.CLIPPLANE4 = c,
d = !0),
i.CLIPPLANE5 !== u && (i.CLIPPLANE5 = u,
d = !0),
i.CLIPPLANE6 !== h && (i.CLIPPLANE6 = h,
d = !0),
i.DEPTHPREPASS !== !t.getColorWrite() && (i.DEPTHPREPASS = !i.DEPTHPREPASS,
d = !0),
i.INSTANCES !== n && (i.INSTANCES = n,
d = !0),
i.INSTANCESCOLOR && !i.INSTANCES && (i.INSTANCESCOLOR = !1,
d = !0),
i.THIN_INSTANCES !== o && (i.THIN_INSTANCES = o,
d = !0),
d && i.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 n = e.getScene().prePassRenderer;
if (n && n.enabled) {
var r = -1 === n.excludedSkinnedMesh.indexOf(e);
t.BONES_VELOCITY_ENABLED = r
}
}
} else
t.NUM_BONE_INFLUENCERS = 0,
t.BonesPerMesh = 0
}
,
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, n, r, o, s) {
if (void 0 === r && (r = !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(Bi.NormalKind),
t._needNormals && e.isVerticesDataPresent(Bi.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(Bi.ColorKind);
t.VERTEXCOLOR = c,
t.VERTEXALPHA = e.hasVertexAlpha && c && o
}
return e.isVerticesDataPresent(Bi.ColorInstanceKind) && (t.INSTANCESCOLOR = !0),
n && this.PrepareDefinesForBones(e, t),
r && 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 n = t.ORDER_INDEPENDENT_TRANSPARENCY
, r = t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS;
t.ORDER_INDEPENDENT_TRANSPARENCY = e.useOrderIndependentTransparency && i,
t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS = !e.getEngine().getCaps().textureFloatLinearFiltering,
n === t.ORDER_INDEPENDENT_TRANSPARENCY && r === t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS || t.markAsUnprocessed()
}
,
e.PrepareDefinesForPrePass = function(e, t, i) {
var n = t.PREPASS;
if (t._arePrePassDirty) {
var r = [{
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 < r.length; o++) {
var s = e.prePassRenderer.getIndex(r[o].type);
-1 !== s ? (t[r[o].define] = !0,
t[r[o].index] = s) : t[r[o].define] = !1
}
} else
for (t.PREPASS = !1,
o = 0; o < r.length; o++)
t[r[o].define] = !1;
t.PREPASS != n && (t.markAsUnprocessed(),
t.markAsImageProcessingDirty())
}
}
,
e.PrepareDefinesForLight = function(e, t, i, n, r, o, a) {
switch (a.needNormals = !0,
void 0 === r["LIGHT" + n] && (a.needRebuild = !0),
r["LIGHT" + n] = !0,
r["SPOTLIGHT" + n] = !1,
r["HEMILIGHT" + n] = !1,
r["POINTLIGHT" + n] = !1,
r["DIRLIGHT" + n] = !1,
i.prepareLightSpecificDefines(r, n),
r["LIGHT_FALLOFF_PHYSICAL" + n] = !1,
r["LIGHT_FALLOFF_GLTF" + n] = !1,
r["LIGHT_FALLOFF_STANDARD" + n] = !1,
i.falloffType) {
case Cr.FALLOFF_GLTF:
r["LIGHT_FALLOFF_GLTF" + n] = !0;
break;
case Cr.FALLOFF_PHYSICAL:
r["LIGHT_FALLOFF_PHYSICAL" + n] = !0;
break;
case Cr.FALLOFF_STANDARD:
r["LIGHT_FALLOFF_STANDARD" + n] = !0
}
if (o && !i.specular.equalsFloats(0, 0, 0) && (a.specularEnabled = !0),
r["SHADOW" + n] = !1,
r["SHADOWCSM" + n] = !1,
r["SHADOWCSMDEBUG" + n] = !1,
r["SHADOWCSMNUM_CASCADES" + n] = !1,
r["SHADOWCSMUSESHADOWMAXZ" + n] = !1,
r["SHADOWCSMNOBLEND" + n] = !1,
r["SHADOWCSM_RIGHTHANDED" + n] = !1,
r["SHADOWPCF" + n] = !1,
r["SHADOWPCSS" + n] = !1,
r["SHADOWPOISSON" + n] = !1,
r["SHADOWESM" + n] = !1,
r["SHADOWCLOSEESM" + n] = !1,
r["SHADOWCUBE" + n] = !1,
r["SHADOWLOWQUALITY" + n] = !1,
r["SHADOWMEDIUMQUALITY" + n] = !1,
t && t.receiveShadows && e.shadowsEnabled && i.shadowEnabled) {
var s = i.getShadowGenerator();
if (s) {
var l = s.getShadowMap();
l && l.renderList && l.renderList.length > 0 && (a.shadowEnabled = !0,
s.prepareDefines(r, n))
}
}
i.lightmapMode != Cr.LIGHTMAP_DEFAULT ? (a.lightmapMode = !0,
r["LIGHTMAPEXCLUDED" + n] = !0,
r["LIGHTMAPNOSPECULAR" + n] = i.lightmapMode == Cr.LIGHTMAP_SHADOWSONLY) : (r["LIGHTMAPEXCLUDED" + n] = !1,
r["LIGHTMAPNOSPECULAR" + n] = !1)
}
,
e.PrepareDefinesForLights = function(e, t, i, n, r, o) {
if (void 0 === r && (r = 4),
void 0 === o && (o = !1),
!i._areLightsDirty)
return i._needNormals;
var a = 0
, s = {
needNormals: !1,
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, n, s),
++a === r)
break
}
i.SPECULARTERM = s.specularEnabled,
i.SHADOWS = s.shadowEnabled;
for (var h = a; h < r; 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, n, r, o) {
void 0 === r && (r = null),
void 0 === o && (o = !1),
r && r.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),
n && (i.push("projectionLightSampler" + e),
t.push("textureProjectionMatrix" + e)))
}
,
e.PrepareUniformsAndSamplersList = function(e, t, i, n) {
var r;
void 0 === n && (n = 4);
var o = null;
if (e.uniformsNames) {
var a = e;
r = a.uniformsNames,
o = a.uniformBuffersNames,
t = a.samplers,
i = a.defines,
n = a.maxSimultaneousLights || 0
} else
r = e,
t || (t = []);
for (var s = 0; s < n && i["LIGHT" + s]; s++)
this.PrepareUniformsAndSamplersForLight(s, r, t, i["PROJECTEDLIGHTTEXTURE" + s], o);
i.NUM_MORPH_INFLUENCERS && r.push("morphTargetInfluences"),
i.BAKED_VERTEX_ANIMATION_TEXTURE && (r.push("bakedVertexAnimationSettings"),
r.push("bakedVertexAnimationTextureSizeInverted"),
r.push("bakedVertexAnimationTime"),
t.push("bakedVertexAnimationTexture"))
}
,
e.HandleFallbacksForShadows = function(e, t, i, n) {
void 0 === i && (i = 4),
void 0 === n && (n = 0);
for (var r = 0, o = 0; o < i && e["LIGHT" + o]; o++)
o > 0 && (r = n + o,
t.addFallback(r, "LIGHT" + o)),
e.SHADOWS || (e["SHADOW" + o] && t.addFallback(n, "SHADOW" + o),
e["SHADOWPCF" + o] && t.addFallback(n, "SHADOWPCF" + o),
e["SHADOWPCSS" + o] && t.addFallback(n, "SHADOWPCSS" + o),
e["SHADOWPOISSON" + o] && t.addFallback(n, "SHADOWPOISSON" + o),
e["SHADOWESM" + o] && t.addFallback(n, "SHADOWESM" + o),
e["SHADOWCLOSEESM" + o] && t.addFallback(n, "SHADOWCLOSEESM" + o));
return r++
}
,
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 n = i.NUM_MORPH_INFLUENCERS;
if (n > 0 && E.LastCreatedEngine) {
var r = E.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 < n; c++)
e.push(Bi.PositionKind + c),
a && e.push(Bi.NormalKind + c),
s && e.push(Bi.TangentKind + c),
l && e.push(Bi.UVKind + "_" + c),
e.length > r && K.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, n) {
i.NUM_BONE_INFLUENCERS > 0 && (n.addCPUSkinningFallback(0, t),
e.push(Bi.MatricesIndicesKind),
e.push(Bi.MatricesWeightsKind),
i.NUM_BONE_INFLUENCERS > 4 && (e.push(Bi.MatricesIndicesExtraKind),
e.push(Bi.MatricesWeightsExtraKind)))
}
,
e.PrepareAttributesForInstances = function(e, t) {
(t.INSTANCES || t.THIN_INSTANCES) && this.PushAttributesForInstances(e, !!t.PREPASS_VELOCITY)
}
,
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, n, r, o) {
void 0 === o && (o = !0),
e._bindLight(t, i, n, r, o)
}
,
e.BindLights = function(e, t, i, n, r) {
void 0 === r && (r = 4);
for (var o = Math.min(t.lightSources.length, r), a = 0; a < o; a++) {
var s = t.lightSources[a];
this.BindLight(s, a, e, i, "boolean" == typeof n ? n : n.SPECULARTERM, t.receiveShadows)
}
}
,
e.BindFogParameters = function(e, t, i, n) {
void 0 === n && (n = !1),
e.fogEnabled && t.applyFog && e.fogMode !== mn.FOGMODE_NONE && (i.setFloat4("vFogInfos", e.fogMode, e.fogStart, e.fogEnd, e.fogDensity),
n ? (e.fogColor.toLinearSpaceToRef(this._TempFogColor),
i.setColor3("vFogColor", this._TempFogColor)) : i.setColor3("vFogColor", e.fogColor))
}
,
e.BindBonesParameters = function(t, i, n) {
if (i && t && (t.computeBonesUsingShaders && i._bonesComputationForcedToCPU && (t.computeBonesUsingShaders = !1),
t.useBones && t.computeBonesUsingShaders && t.skeleton)) {
var r = t.skeleton;
if (r.isUsingTextureForMatrices && i.getUniformIndex("boneTextureWidth") > -1) {
var o = r.getTransformMatrixTexture(t);
i.setTexture("boneSampler", o),
i.setFloat("boneTextureWidth", 4 * (r.bones.length + 1))
} else {
var s = r.getTransformMatrices(t);
s && (i.setMatrices("mBones", s),
n && t.getScene().prePassRenderer && t.getScene().prePassRenderer.getIndex(a.PREPASS_VELOCITY_TEXTURE_TYPE) && (n.previousBones[t.uniqueId] || (n.previousBones[t.uniqueId] = s.slice()),
i.setMatrices("mPreviousBones", n.previousBones[t.uniqueId]),
e._CopyBonesTransformationMatrices(s, n.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) {
var n = i.activeCamera;
n.mode === Rr.ORTHOGRAPHIC_CAMERA && K.Error("Logarithmic depth is not compatible with orthographic cameras!", 20),
t.setFloat("logarithmicDepthConstant", 2 / (Math.log(n.maxZ + 1) / Math.LN2))
}
}
,
e.BindClipPlane = function(e, t) {
Pr.BindClipPlane(e, t)
}
,
e._TmpMorphInfluencers = {
NUM_MORPH_INFLUENCERS: 0
},
e._TempFogColor = D.Black(),
e
}(), Ir = 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) {
Ge.Clone((function() {
return e
}
), this)
}
,
e.prototype.serialize = function() {
return Ge.Serialize(this)
}
,
e.prototype.parse = function(e, t, i) {
var n = this;
Ge.Parse((function() {
return n
}
), e, t, i)
}
,
k([Ce()], e.prototype, "func", null),
k([Ce()], e.prototype, "funcRef", null),
k([Ce()], e.prototype, "funcMask", null),
k([Ce()], e.prototype, "opStencilFail", null),
k([Ce()], e.prototype, "opDepthFail", null),
k([Ce()], e.prototype, "opStencilDepthPass", null),
k([Ce()], e.prototype, "mask", null),
k([Ce()], 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"
}(Ar || (Ar = {}));
var Or = function() {
function e(t, i, n) {
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.onCompiled = null,
this.onError = null,
this.getRenderTargetTextures = null,
this.doNotSerialize = !1,
this._storeEffectOnSubMeshes = !1,
this.animations = null,
this.onDisposeObservable = new h,
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 Ir,
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._callbackPluginEventHardBindForSubMesh = function() {}
,
this._callbackPluginEventBindForSubMesh = function() {}
,
this._callbackPluginEventHasRenderTargetTextures = function() {}
,
this._callbackPluginEventFillRenderTargetTextures = function() {}
,
this._forceAlphaTest = !1,
this._transparencyMode = null,
this.name = t;
var r = i || E.LastCreatedScene;
r && (this._scene = r,
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 || gi.RandomId(),
this.uniqueId = this._scene.getUniqueId(),
this._materialContext = this._scene.getEngine().createMaterialContext(),
this._drawWrapper = new Gt(this._scene.getEngine(),!1),
this._drawWrapper.materialContext = this._materialContext,
this._scene.useRightHandedSystem ? this.sideOrientation = e.ClockWiseSideOrientation : this.sideOrientation = e.CounterClockWiseSideOrientation,
this._uniformBuffer = new Fi(this._scene.getEngine(),void 0,void 0,t),
this._useUBO = this.getScene().getEngine().supportsUniformBuffers,
n || this._scene.addMaterial(this),
this._scene.useMaterialMeshMap && (this.meshMap = {}),
e.OnEventObservable.notifyObservers(this, Ar.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) {
this._alpha !== t && (this._alpha = t,
this.markAsDirty(e.MiscDirtyFlag))
},
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, "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 h),
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 h),
this._onUnBindObservable
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "onEffectCreatedObservable", {
get: function() {
return this._onEffectCreatedObservable || (this._onEffectCreatedObservable = new h),
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, "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 n = t.materialDefines;
return !!n && (this._eventInfo.isReadyForSubMesh = !0,
this._eventInfo.defines = n,
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 !(this._disableAlphaBlending && e.visibility >= 1) && (this.needAlphaBlending() || e.visibility < 1 || e.hasVertexAlpha)
}
,
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() {
for (var e = 0, t = this.getScene().meshes; e < t.length; e++) {
var i = t[e];
if (i.subMeshes)
for (var n = 0, r = i.subMeshes; n < r.length; n++) {
var o = r[n];
o.getMaterial() === this && o.effect && (o.effect._wasPreviouslyReady = !1)
}
}
}
,
e.prototype._preBind = function(t, i) {
void 0 === i && (i = null);
var n = this._scene.getEngine()
, r = (null == i ? this.sideOrientation : i) === e.ClockWiseSideOrientation;
return n.enableEffect(t || this._getDrawWrapper()),
n.setState(this.backFaceCulling, this.zOffset, !1, r, this.cullBackFaces, this.stencil, this.zOffsetUnits),
r
}
,
e.prototype.bind = function(e, t) {}
,
e.prototype.buildUniformLayout = function() {
var e = this._uniformBuffer;
this._eventInfo.ubo = e,
this._callbackPluginEventGeneric(Ar.PrepareUniformBuffer, this._eventInfo),
e.create(),
this._uniformBufferLayoutBuilt = !0
}
,
e.prototype.bindForSubMesh = function(e, t, i) {
i.effect && (this._eventInfo.subMesh = i,
this._callbackPluginEventBindForSubMesh(this._eventInfo))
}
,
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,
Mr.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(Ar.GetAnimatables, this._eventInfo),
this._eventInfo.animatables
}
,
e.prototype.getActiveTextures = function() {
return this._eventInfo.activeTextures = [],
this._callbackPluginEventGeneric(Ar.GetActiveTextures, this._eventInfo),
this._eventInfo.activeTextures
}
,
e.prototype.hasTexture = function(e) {
return this._eventInfo.hasTexture = !1,
this._eventInfo.texture = e,
this._callbackPluginEventGeneric(Ar.HasTexture, this._eventInfo),
this._eventInfo.hasTexture
}
,
e.prototype.clone = function(e) {
return null
}
,
e.prototype.getBindedMeshes = function() {
var e = this;
if (this.meshMap) {
var t = new Array;
for (var i in this.meshMap) {
var n = this.meshMap[i];
n && t.push(n)
}
return t
}
return this._scene.meshes.filter((function(t) {
return t.material === e
}
))
}
,
e.prototype.forceCompilation = function(e, t, i, n) {
var r = this
, o = V({
clipPlane: !1,
useInstances: !1
}, i)
, a = this.getScene()
, s = this.allowShaderHotSwapping;
this.allowShaderHotSwapping = !1;
var l = function() {
if (r._scene && r._scene.getEngine()) {
var i = a.clipPlane;
if (o.clipPlane && (a.clipPlane = new hn(0,0,0,1)),
r._storeEffectOnSubMeshes) {
var c = !0
, u = null;
if (e.subMeshes) {
var h = new hr(0,0,0,0,0,e,void 0,!1,!1);
h.materialDefines && (h.materialDefines._renderId = -1),
r.isReadyForSubMesh(e, h, o.useInstances) || (h.effect && h.effect.getCompilationError() && h.effect.allFallbacksProcessed() ? u = h.effect.getCompilationError() : (c = !1,
setTimeout(l, 16)))
}
c && (r.allowShaderHotSwapping = s,
u && n && n(u),
t && t(r))
} else
r.isReady() ? (r.allowShaderHotSwapping = s,
t && t(r)) : setTimeout(l, 16);
o.clipPlane && (a.clipPlane = i)
}
};
l()
}
,
e.prototype.forceCompilationAsync = function(e, t) {
var i = this;
return new Promise((function(n, r) {
i.forceCompilation(e, (function() {
n()
}
), t, (function(e) {
r(e)
}
))
}
))
}
,
e.prototype.markAsDirty = function(t) {
this.getScene().blockMaterialDirtyMechanism || (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 n = 0, r = i.subMeshes; n < r.length; n++) {
var o = r[n];
o.getMaterial() === this && o.resetDrawCache()
}
}
}
,
e.prototype._markAllSubMeshesAsDirty = function(e) {
if (!this.getScene().blockMaterialDirtyMechanism)
for (var t = 0, i = this.getScene().meshes; t < i.length; t++) {
var n = i[t];
if (n.subMeshes)
for (var r = 0, o = n.subMeshes; r < o.length; r++) {
var a = o[r];
if (0 !== n._renderId && a.getMaterial() === 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) {
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.setPrePassRenderer = function(e) {
return !1
}
,
e.prototype.dispose = function(e, t, i) {
var n = this.getScene();
if (n.stopAnimation(this),
n.freeProcessedMaterials(),
n.removeMaterial(this),
this._eventInfo.forceDisposeTextures = t,
this._callbackPluginEventGeneric(Ar.Disposed, this._eventInfo),
this._parentContainer) {
var r = this._parentContainer.materials.indexOf(this);
r > -1 && this._parentContainer.materials.splice(r, 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 = n.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()
}
,
e.prototype.releaseVertexArrayObject = function(e, t) {
if (e.geometry) {
var i = e.geometry;
if (this._storeEffectOnSubMeshes)
for (var n = 0, r = e.subMeshes; n < r.length; n++) {
var o = r[n];
i._releaseVertexArrayObject(o.effect),
t && o.effect && o.effect.dispose()
}
else
i._releaseVertexArrayObject(this._drawWrapper.effect)
}
}
,
e.prototype.serialize = function() {
var e = Ge.Serialize(this);
return e.stencil = this.stencil.serialize(),
e.uniqueId = this.uniqueId,
e
}
,
e.Parse = function(e, t, i) {
if (e.customType) {
if ("BABYLON.PBRMaterial" === e.customType && e.overloadedAlbedo && (e.customType = "BABYLON.LegacyPBRMaterial",
!BABYLON.LegacyPBRMaterial))
return K.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 n = gi.Instantiate(e.customType).Parse(e, t, i);
return n._loadedUniqueId = e.uniqueId,
n
}
,
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 h,
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, n = e._DirtyCallbackArray; i < n.length; i++)
(0,
n[i])(t)
}
,
k([Ce()], e.prototype, "id", void 0),
k([Ce()], e.prototype, "uniqueId", void 0),
k([Ce()], e.prototype, "name", void 0),
k([Ce()], e.prototype, "metadata", void 0),
k([Ce()], e.prototype, "checkReadyOnEveryCall", void 0),
k([Ce()], e.prototype, "checkReadyOnlyOnce", void 0),
k([Ce()], e.prototype, "state", void 0),
k([Ce("alpha")], e.prototype, "_alpha", void 0),
k([Ce("backFaceCulling")], e.prototype, "_backFaceCulling", void 0),
k([Ce("cullBackFaces")], e.prototype, "_cullBackFaces", void 0),
k([Ce()], e.prototype, "sideOrientation", void 0),
k([Ce("alphaMode")], e.prototype, "_alphaMode", void 0),
k([Ce()], e.prototype, "_needDepthPrePass", void 0),
k([Ce()], e.prototype, "disableDepthWrite", void 0),
k([Ce()], e.prototype, "disableColorWrite", void 0),
k([Ce()], e.prototype, "forceDepthWrite", void 0),
k([Ce()], e.prototype, "depthFunction", void 0),
k([Ce()], e.prototype, "separateCullingPass", void 0),
k([Ce("fogEnabled")], e.prototype, "_fogEnabled", void 0),
k([Ce()], e.prototype, "pointSize", void 0),
k([Ce()], e.prototype, "zOffset", void 0),
k([Ce()], e.prototype, "zOffsetUnits", void 0),
k([Ce()], e.prototype, "pointsCloud", null),
k([Ce()], e.prototype, "fillMode", null),
k([Ce()], e.prototype, "transparencyMode", null),
e
}()
, Dr = function(e) {
function t(t, i) {
var n = e.call(this, t, i, !0) || this;
return n._waitingSubMaterialsUniqueIds = [],
n.getScene().multiMaterials.push(n),
n.subMaterials = new Array,
n._storeEffectOnSubMeshes = !0,
n
}
return U(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 n = [], r = 0; r < arguments.length; r++)
n[r] = arguments[r];
var o = i.apply(e, n);
return t._markAllSubMeshesAsTexturesDirty(),
o
}
;
var n = e.splice;
e.splice = function(i, r) {
var o = n.apply(e, [i, r]);
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 n = 0; n < this.subMaterials.length; n++)
if (null === (i = this.subMaterials[n]) || 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 n = 0; n < this.subMaterials.length; n++) {
var r = this.subMaterials[n];
if (r) {
if (r._storeEffectOnSubMeshes) {
if (!r.isReadyForSubMesh(e, t, i))
return !1;
continue
}
if (!r.isReady(e))
return !1
}
}
return !0
}
,
t.prototype.clone = function(e, i) {
for (var n = new t(e,this.getScene()), r = 0; r < this.subMaterials.length; r++) {
var o, a = this.subMaterials[r];
o = i && a ? a.clone(e + "-" + a.name) : this.subMaterials[r],
n.subMaterials.push(o)
}
return n
}
,
t.prototype.serialize = function() {
var e = {};
e.name = this.name,
e.id = this.id,
e.uniqueId = this.uniqueId,
ye && (e.tags = ye.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, n) {
var r = this.getScene();
if (r) {
if (n)
for (var o = 0; o < this.subMaterials.length; o++) {
var a = this.subMaterials[o];
a && a.dispose(t, i)
}
var s = r.multiMaterials.indexOf(this);
s >= 0 && r.multiMaterials.splice(s, 1),
e.prototype.dispose.call(this, t, i)
}
}
,
t.ParseMultiMaterial = function(e, i) {
var n = new t(e.name,i);
return n.id = e.id,
n._loadedUniqueId = e.uniqueId,
ye && ye.AddTagsTo(n, e.tags),
e.materialsUniqueIds ? n._waitingSubMaterialsUniqueIds = e.materialsUniqueIds : e.materials.forEach((function(e) {
return n.subMaterials.push(i.getLastMaterialById(e))
}
)),
n
}
,
t
}(Or);
y("BABYLON.MultiMaterial", Dr);
var Nr = function(e, t) {
this.distanceOrScreenCoverage = e,
this.mesh = t
}
, Lr = function() {}
, Fr = function() {
this.visibleInstances = {},
this.batchCache = new wr,
this.batchCacheReplacementModeInFrozenMode = new wr,
this.instancesBufferSize = 2048
}
, wr = function() {
this.mustReturn = !1,
this.visibleInstances = new Array,
this.renderSelf = new Array,
this.hardwareInstancedRendering = new Array
}
, Br = function() {
this.instancesCount = 0,
this.matrixBuffer = null,
this.previousMatrixBuffer = null,
this.matrixBufferSize = 512,
this.matrixData = null,
this.boundingVectors = [],
this.worldMatrices = null
}
, Ur = 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
}
, Vr = function(e) {
function t(i, n, r, o, s, l) {
void 0 === n && (n = null),
void 0 === r && (r = null),
void 0 === o && (o = null),
void 0 === l && (l = !0);
var c = e.call(this, i, n) || this;
if (c._internalMeshDataInfo = new Ur,
c.delayLoadState = a.DELAYLOADSTATE_NONE,
c.instances = new Array,
c._creationDataStorage = null,
c._geometry = null,
c._instanceDataStorage = new Fr,
c._thinInstanceDataStorage = new Br,
c._shouldGenerateFlatShading = !1,
c._originalBuilderSideOrientation = t.DEFAULTSIDE,
c.overrideMaterialSideOrientation = null,
c.ignoreCameraMaxZ = !1,
n = 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),
fe.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"], ["_poseMatrix"]),
c._internalMeshDataInfo._source = o,
n.useClonedMeshMap && (o._internalMeshDataInfo.meshMap || (o._internalMeshDataInfo.meshMap = {}),
o._internalMeshDataInfo.meshMap[c.uniqueId] = c),
c._originalBuilderSideOrientation = o._originalBuilderSideOrientation,
c._creationDataStorage = o._creationDataStorage,
o._ranges) {
var u = o._ranges;
for (var d in u)
Object.prototype.hasOwnProperty.call(u, d) && u[d] && c.createAnimationRange(d, u[d].from, u[d].to)
}
if (o.metadata && o.metadata.clone ? c.metadata = o.metadata.clone() : c.metadata = o.metadata,
ye && ye.HasTags(o) && ye.AddTagsTo(c, ye.GetTags(o, !0)),
c.setEnabled(o.isEnabled()),
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),
n.getPhysicsEngine) {
var m = n.getPhysicsEngine();
if (l && m) {
var g = m.getImpostorForPhysicsObject(o);
g && (c.physicsImpostor = g.clone(c))
}
}
for (f = 0; f < n.particleSystems.length; f++) {
var v = n.particleSystems[f];
v.emitter === o && v.clone(v.name, c)
}
c.skeleton = o.skeleton,
c.refreshBoundingInfo(!0, !0),
c.computeWorldMatrix(!0)
}
return null !== r && (c.parent = r),
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 h(c._internalMeshDataInfo._onMeshReadyObserverAdded),
o && o.onClonedObservable.notifyObservers(c),
c
}
return U(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
},
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(Bi.PositionKind, this._internalMeshDataInfo._sourcePositions.slice(), !0),
this._internalMeshDataInfo._sourceNormals && this.setVerticesData(Bi.NormalKind, this._internalMeshDataInfo._sourceNormals.slice(), !0)),
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 h),
this._internalMeshDataInfo._onBeforeRenderObservable
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "onBeforeBindObservable", {
get: function() {
return this._internalMeshDataInfo._onBeforeBindObservable || (this._internalMeshDataInfo._onBeforeBindObservable = new h),
this._internalMeshDataInfo._onBeforeBindObservable
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "onAfterRenderObservable", {
get: function() {
return this._internalMeshDataInfo._onAfterRenderObservable || (this._internalMeshDataInfo._onAfterRenderObservable = new h),
this._internalMeshDataInfo._onAfterRenderObservable
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "onBetweenPassObservable", {
get: function() {
return this._internalMeshDataInfo._onBetweenPassObservable || (this._internalMeshDataInfo._onBetweenPassObservable = new h),
this._internalMeshDataInfo._onBetweenPassObservable
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "onBeforeDrawObservable", {
get: function() {
return this._internalMeshDataInfo._onBeforeDrawObservable || (this._internalMeshDataInfo._onBeforeDrawObservable = new h),
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, "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
}),
t.prototype.instantiateHierarchy = function(e, t, i) {
void 0 === e && (e = null);
var n = !(this.getTotalVertices() > 0) || t && t.doNotInstantiate ? this.clone("Clone of " + (this.name || this.id), e || this.parent, !0) : this.createInstance("instance of " + (this.name || this.id));
n.parent = e || this.parent,
n.position = this.position.clone(),
n.scaling = this.scaling.clone(),
this.rotationQuaternion ? n.rotationQuaternion = this.rotationQuaternion.clone() : n.rotation = this.rotation.clone(),
i && i(this, n);
for (var r = 0, o = this.getChildTransformNodes(!0); r < o.length; r++)
o[r].instantiateHierarchy(n, t, i);
return n
}
,
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 n = 0; n < this.animations.length; n++)
i += ", animation[0]: " + this.animations[n].toString(t);
if (t)
if (this._geometry) {
var r = this.getIndices()
, o = this.getVerticesData(Bi.PositionKind);
o && r && (i += ", flat shading: " + (o.length / 3 === r.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 K.Warn("You cannot use a mesh as LOD level twice"),
this;
var i = new Nr(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 n = t._LODLevels[i];
if (n.distanceOrScreenCoverage === e)
return n.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, n = this._internalMeshDataInfo;
if (!n._LODLevels || 0 === n._LODLevels.length)
return this;
var r = (i = t || this.getBoundingInfo().boundingSphere).centerWorld.subtract(e.globalPosition).length()
, o = r
, s = 1;
if (n._useLODScreenCoverage) {
var l = e.screenArea
, c = i.radiusWorld * e.minZ / r;
o = (c = c * c * Math.PI) / l,
s = -1
}
if (s * n._LODLevels[n._LODLevels.length - 1].distanceOrScreenCoverage > s * o)
return this.onLODLevelSelection && this.onLODLevelSelection(o, this, this),
this;
for (var u = 0; u < n._LODLevels.length; u++) {
var h = n._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) {
var n, r;
if (!this._geometry)
return null;
var o = null === (r = null === (n = this._userInstancedBuffersStorage) || void 0 === n ? void 0 : n.vertexBuffers[e]) || void 0 === r ? void 0 : r.getFloatData(this._geometry.getTotalVertices(), i || t && 1 !== this._geometry.meshes.length);
return o || (o = this._geometry.getVerticesData(e, t, i)),
o
}
,
t.prototype.getVertexBuffer = function(e) {
var t, i;
return this._geometry ? null !== (i = null === (t = this._userInstancedBuffersStorage) || void 0 === t ? void 0 : t.vertexBuffers[e]) && void 0 !== i ? i : this._geometry.getVertexBuffer(e) : null
}
,
t.prototype.isVerticesDataPresent = function(e) {
var t;
return this._geometry ? void 0 !== (null === (t = this._userInstancedBuffersStorage) || void 0 === t ? void 0 : t.vertexBuffers[e]) || this._geometry.isVerticesDataPresent(e) : !!this._delayInfo && -1 !== this._delayInfo.indexOf(e)
}
,
t.prototype.isVertexBufferUpdatable = function(e) {
var t, i;
return this._geometry ? (null === (i = null === (t = this._userInstancedBuffersStorage) || void 0 === t ? void 0 : t.vertexBuffers[e]) || void 0 === i ? void 0 : i.isUpdatable()) || this._geometry.isVertexBufferUpdatable(e) : !!this._delayInfo && -1 !== this._delayInfo.indexOf(e)
}
,
t.prototype.getVerticesDataKinds = function() {
if (!this._geometry) {
var e = new Array;
return this._delayInfo && this._delayInfo.forEach((function(t) {
e.push(t)
}
)),
e
}
var t = this._geometry.getVerticesDataKinds();
if (this._userInstancedBuffersStorage)
for (var i in this._userInstancedBuffersStorage.vertexBuffers)
t.push(i);
return t
}
,
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 n, r, o, s, l, c;
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 u = this.getEngine()
, h = this.getScene()
, d = i || u.getCaps().instancedArrays && (this.instances.length > 0 || this.hasThinInstances);
this.computeWorldMatrix();
var p = this.material || h.defaultMaterial;
if (p)
if (p._storeEffectOnSubMeshes)
for (var f = 0, _ = this.subMeshes; f < _.length; f++) {
var m = (S = _[f]).getMaterial();
if (m)
if (m._storeEffectOnSubMeshes) {
if (!m.isReadyForSubMesh(this, S, d))
return !1
} else if (!m.isReady(this, d))
return !1
}
else if (!p.isReady(this, d))
return !1;
for (var g = u.currentRenderPassId, v = 0, y = this.lightSources; v < y.length; v++) {
var b = y[v].getShadowGenerator();
if (b && (!(null === (n = b.getShadowMap()) || void 0 === n ? void 0 : n.renderList) || (null === (r = b.getShadowMap()) || void 0 === r ? void 0 : r.renderList) && -1 !== (null === (s = null === (o = b.getShadowMap()) || void 0 === o ? void 0 : o.renderList) || void 0 === s ? void 0 : s.indexOf(this)))) {
b.getShadowMap() && (u.currentRenderPassId = b.getShadowMap().renderPassId);
for (var T = 0, E = this.subMeshes; T < E.length; T++) {
var S = E[T];
if (!b.isReady(S, d, null !== (c = null === (l = S.getMaterial()) || void 0 === l ? void 0 : l.needAlphaBlendingForMesh(this)) && void 0 !== c && c))
return u.currentRenderPassId = g,
!1
}
u.currentRenderPassId = g
}
}
for (var A = 0, x = this._internalMeshDataInfo._LODLevels; A < x.length; A++) {
var R = x[A];
if (R.mesh && !R.mesh.isReady(d))
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 n = i.length
, r = !1;
if (e)
r = !0;
else
for (var o = 0, a = this.subMeshes; o < a.length; o++) {
var s = a[o];
if (s.indexStart + s.indexCount > n) {
r = !0;
break
}
if (s.verticesStart + s.verticesCount > t) {
r = !0;
break
}
}
if (!r)
return this.subMeshes[0]
}
return this.releaseSubMeshes(),
new hr(0,0,t,0,this.getTotalIndices(),this)
}
,
t.prototype.subdivide = function(e) {
if (!(e < 1)) {
for (var t = this.getTotalIndices(), i = t / e | 0, n = 0; i % 3 != 0; )
i++;
this.releaseSubMeshes();
for (var r = 0; r < e && !(n >= t); r++)
hr.CreateFromIndices(0, n, r === e - 1 ? t - n : i, this),
n += i;
this.synchronizeInstances()
}
}
,
t.prototype.setVerticesData = function(e, t, i, n) {
if (void 0 === i && (i = !1),
this._geometry)
this._geometry.setVerticesData(e, t, i, n);
else {
var r = new $n;
r.set(t, e);
var o = this.getScene();
new fr(fr.RandomId(),o,r,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 = fr.CreateGeometryForMesh(this)),
this._geometry.setVerticesBuffer(e, null, t),
this
}
,
t.prototype.updateVerticesData = function(e, t, i, n) {
return this._geometry ? (n ? (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(Bi.PositionKind);
if (!i)
return this;
if (e(i),
this.updateVerticesData(Bi.PositionKind, i, !1, !1),
t) {
var n = this.getIndices()
, r = this.getVerticesData(Bi.NormalKind);
if (!r)
return this;
$n.ComputeNormals(i, n, r),
this.updateVerticesData(Bi.NormalKind, r, !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(fr.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 n = new $n;
n.indices = e;
var r = this.getScene();
new fr(fr.RandomId(),r,n,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) {
if (!this._geometry)
return this;
var n, r = this.getScene().getEngine();
if (this.morphTargetManager && this.morphTargetManager.isUsingTextureForTargets && this.morphTargetManager._bind(t),
this._unIndexed)
n = null;
else
switch (i) {
case Or.PointFillMode:
n = null;
break;
case Or.WireFrameFillMode:
n = e._getLinesIndexBuffer(this.getIndices(), r);
break;
default:
case Or.TriangleFillMode:
n = this._geometry.getIndexBuffer()
}
return !this._userInstancedBuffersStorage || this.hasThinInstances ? this._geometry._bind(t, n) : this._geometry._bind(t, n, this._userInstancedBuffersStorage.vertexBuffers, this._userInstancedBuffersStorage.vertexArrayObjects),
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 n = this.getScene().getEngine();
return this._unIndexed || t == Or.PointFillMode ? n.drawArraysType(t, e.verticesStart, e.verticesCount, this.forcedInstanceCount || i) : t == Or.WireFrameFillMode ? n.drawElementsType(t, 0, e._linesIndexCount, this.forcedInstanceCount || i) : n.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()
, n = i._isInIntermediateRendering()
, r = n ? this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate : this._internalAbstractMeshDataInfo._onlyForInstances
, o = this._instanceDataStorage.batchCache;
if (o.mustReturn = !1,
o.renderSelf[e] = t || !r && this.isEnabled() && this.isVisible,
o.visibleInstances[e] = null,
this._instanceDataStorage.visibleInstances && !t) {
var a = this._instanceDataStorage.visibleInstances
, s = i.getRenderId()
, l = n ? 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, n, r, o) {
var a, s = n.visibleInstances[e._id];
if (!s)
return this;
for (var l = this._instanceDataStorage, c = l.instancesBufferSize, u = l.instancesBuffer, h = l.instancesPreviousBuffer, d = 16 * (s.length + 1) * 4; l.instancesBufferSize < d; )
l.instancesBufferSize *= 2;
l.instancesData && c == l.instancesBufferSize || (l.instancesData = new Float32Array(l.instancesBufferSize / 4)),
(this._scene.needsPreviousWorldMatrices && !l.instancesPreviousData || c != l.instancesBufferSize) && (l.instancesPreviousData = new Float32Array(l.instancesBufferSize / 4));
var p = 0
, f = 0
, _ = n.renderSelf[e._id]
, m = !u || c !== l.instancesBufferSize || this._scene.needsPreviousWorldMatrices && !l.instancesPreviousBuffer;
if (this._instanceDataStorage.manualUpdate || l.isFrozen && !m)
f = (_ ? 1 : 0) + s.length;
else {
var g = this.getWorldMatrix();
if (_ && (this._scene.needsPreviousWorldMatrices && (l.masterMeshPreviousWorldMatrix ? (l.masterMeshPreviousWorldMatrix.copyToArray(l.instancesPreviousData, p),
l.masterMeshPreviousWorldMatrix.copyFrom(g)) : (l.masterMeshPreviousWorldMatrix = g.clone(),
l.masterMeshPreviousWorldMatrix.copyToArray(l.instancesPreviousData, p))),
g.copyToArray(l.instancesData, p),
p += 16,
f++),
s) {
if (t.INSTANCEDMESH_SORT_TRANSPARENT && this._scene.activeCamera && (null === (a = e.getMaterial()) || void 0 === a ? void 0 : a.needAlphaBlendingForMesh(e.getRenderingMesh()))) {
for (var v = this._scene.activeCamera.globalPosition, y = 0; y < s.length; y++) {
var b = s[y];
b._distanceToCamera = x.Distance(b.getBoundingInfo().boundingSphere.centerWorld, v)
}
s.sort((function(e, t) {
return e._distanceToCamera > t._distanceToCamera ? -1 : e._distanceToCamera < t._distanceToCamera ? 1 : 0
}
))
}
for (y = 0; y < s.length; y++) {
var T = s[y]
, E = T.getWorldMatrix();
E.copyToArray(l.instancesData, p),
this._scene.needsPreviousWorldMatrices && (T._previousWorldMatrix ? (T._previousWorldMatrix.copyToArray(l.instancesPreviousData, p),
T._previousWorldMatrix.copyFrom(E)) : (T._previousWorldMatrix = E.clone(),
T._previousWorldMatrix.copyToArray(l.instancesPreviousData, p))),
p += 16,
f++
}
}
}
return m ? (u && u.dispose(),
h && h.dispose(),
u = new wi(o,l.instancesData,!0,16,!1,!0),
l.instancesBuffer = u,
this._userInstancedBuffersStorage || (this._userInstancedBuffersStorage = {
data: {},
vertexBuffers: {},
strides: {},
sizes: {},
vertexArrayObjects: this.getEngine().getCaps().vertexArrayObject ? {} : void 0
}),
this._userInstancedBuffersStorage.vertexBuffers.world0 = u.createVertexBuffer("world0", 0, 4),
this._userInstancedBuffersStorage.vertexBuffers.world1 = u.createVertexBuffer("world1", 4, 4),
this._userInstancedBuffersStorage.vertexBuffers.world2 = u.createVertexBuffer("world2", 8, 4),
this._userInstancedBuffersStorage.vertexBuffers.world3 = u.createVertexBuffer("world3", 12, 4),
this._scene.needsPreviousWorldMatrices && (h = new wi(o,l.instancesPreviousData,!0,16,!1,!0),
l.instancesPreviousBuffer = h,
this._userInstancedBuffersStorage.vertexBuffers.previousWorld0 = h.createVertexBuffer("previousWorld0", 0, 4),
this._userInstancedBuffersStorage.vertexBuffers.previousWorld1 = h.createVertexBuffer("previousWorld1", 4, 4),
this._userInstancedBuffersStorage.vertexBuffers.previousWorld2 = h.createVertexBuffer("previousWorld2", 8, 4),
this._userInstancedBuffersStorage.vertexBuffers.previousWorld3 = h.createVertexBuffer("previousWorld3", 12, 4)),
this._invalidateInstanceVertexArrayObject()) : this._instanceDataStorage.isFrozen || (u.updateDirectly(l.instancesData, 0, f),
!this._scene.needsPreviousWorldMatrices || this._instanceDataStorage.manualUpdate && !this._instanceDataStorage.previousManualUpdate || h.updateDirectly(l.instancesPreviousData, 0, f)),
this._processInstancedBuffers(s, _),
this.getScene()._activeIndices.addCount(e.indexCount * f, !1),
o._currentDrawContext && (o._currentDrawContext.useInstancing = !0),
this._bind(e, r, i),
this._draw(e, i, f),
!this._scene.needsPreviousWorldMatrices || m || !this._instanceDataStorage.manualUpdate || this._instanceDataStorage.isFrozen || this._instanceDataStorage.previousManualUpdate || h.updateDirectly(l.instancesData, 0, f),
o.unbindInstanceAttributes(),
this
}
,
t.prototype._renderWithThinInstances = function(e, t, i, n) {
var r, o, a = null !== (o = null === (r = this._thinInstanceDataStorage) || void 0 === r ? void 0 : r.instancesCount) && void 0 !== o ? o : 0;
this.getScene()._activeIndices.addCount(e.indexCount * a, !1),
n._currentDrawContext && (n._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)),
n.unbindInstanceAttributes()
}
,
t.prototype._processInstancedBuffers = function(e, t) {}
,
t.prototype._processRendering = function(e, t, i, n, r, o, a, s) {
var l = this.getScene()
, c = l.getEngine();
if (o && t.getRenderingMesh().hasThinInstances)
return this._renderWithThinInstances(t, n, i, c),
this;
if (o)
this._renderWithInstances(t, n, r, i, c);
else {
c._currentDrawContext && (c._currentDrawContext.useInstancing = !1);
var u = 0;
r.renderSelf[t._id] && (a && a(!1, e.getWorldMatrix(), s),
u++,
this._draw(t, n, this._instanceDataStorage.overridenInstanceCount));
var h = r.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, n)
}
}
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 n = this._userInstancedBuffersStorage.vertexBuffers[i];
n && (t && n.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 n, r, 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 = s.hardwareInstancedRendering[e._id] || e.getRenderingMesh().hasThinInstances, p = this._instanceDataStorage, f = e.getMaterial();
if (!f)
return u && (u.maxZ = c,
a.updateTransformMatrix(!0)),
this;
if (p.isFrozen && this._internalMeshDataInfo._effectiveMaterial && this._internalMeshDataInfo._effectiveMaterial === f) {
if (f._storeEffectOnSubMeshes && !(null === (n = e.effect) || void 0 === n ? void 0 : n._wasPreviouslyReady) || !f._storeEffectOnSubMeshes && !(null === (r = f.getEffect()) || void 0 === r ? void 0 : r._wasPreviouslyReady))
return u && (u.maxZ = c,
a.updateTransformMatrix(!0)),
this
} else {
if (f._storeEffectOnSubMeshes) {
if (!f.isReadyForSubMesh(this, e, d))
return u && (u.maxZ = c,
a.updateTransformMatrix(!0)),
this
} else if (!f.isReady(this, d))
return u && (u.maxZ = c,
a.updateTransformMatrix(!0)),
this;
this._internalMeshDataInfo._effectiveMaterial = f
}
t && l.setAlphaMode(this._internalMeshDataInfo._effectiveMaterial.alphaMode);
for (var _ = null !== (o = null == (h = this._internalMeshDataInfo._effectiveMaterial._storeEffectOnSubMeshes ? e._drawWrapper : this._internalMeshDataInfo._effectiveMaterial._getDrawWrapper()) ? void 0 : h.effect) && void 0 !== o ? o : null, m = 0, g = a._beforeRenderingMeshStage; m < g.length; m++)
g[m].action(this, e, s, _);
if (!h || !_)
return u && (u.maxZ = c,
a.updateTransformMatrix(!0)),
this;
var v, y = i || this;
if (p.isFrozen || !this._internalMeshDataInfo._effectiveMaterial.backFaceCulling && null === this.overrideMaterialSideOrientation)
v = p.sideOrientation;
else {
var b = y._getWorldMatrixDeterminant();
null == (v = this.overrideMaterialSideOrientation) && (v = this._internalMeshDataInfo._effectiveMaterial.sideOrientation),
b < 0 && (v = v === Or.ClockWiseSideOrientation ? Or.CounterClockWiseSideOrientation : Or.ClockWiseSideOrientation),
p.sideOrientation = v
}
var T = this._internalMeshDataInfo._effectiveMaterial._preBind(h, v);
this._internalMeshDataInfo._effectiveMaterial.forceDepthWrite && l.setDepthWrite(!0);
var E = a.forcePointsCloud ? Or.PointFillMode : a.forceWireframe ? Or.WireFrameFillMode : this._internalMeshDataInfo._effectiveMaterial.fillMode;
this._internalMeshDataInfo._onBeforeBindObservable && this._internalMeshDataInfo._onBeforeBindObservable.notifyObservers(this),
d || this._bind(e, _, E);
var S = this._internalMeshDataInfo._effectiveMaterial
, A = y.getWorldMatrix();
S._storeEffectOnSubMeshes ? S.bindForSubMesh(A, this, e) : S.bind(A, this),
!S.backFaceCulling && S.separateCullingPass && (l.setState(!0, S.zOffset, !1, !T, S.cullBackFaces, S.stencil, S.zOffsetUnits),
this._processRendering(this, e, _, E, s, d, this._onBeforeDraw, this._internalMeshDataInfo._effectiveMaterial),
l.setState(!0, S.zOffset, !1, T, S.cullBackFaces, S.stencil, S.zOffsetUnits),
this._internalMeshDataInfo._onBetweenPassObservable && this._internalMeshDataInfo._onBetweenPassObservable.notifyObservers(e)),
this._processRendering(this, e, _, E, s, d, this._onBeforeDraw, this._internalMeshDataInfo._effectiveMaterial),
this._internalMeshDataInfo._effectiveMaterial.unbind();
for (var x = 0, R = a._afterRenderingMeshStage; x < R.length; x++)
R[x].action(this, e, s, _);
return this._internalMeshDataInfo._onAfterRenderObservable && this._internalMeshDataInfo._onAfterRenderObservable.notifyObservers(this),
u && (u.maxZ = c,
a.updateTransformMatrix(!0)),
this
}
,
t.prototype.cleanMatrixWeights = function() {
this.isVerticesDataPresent(Bi.MatricesWeightsKind) && (this.isVerticesDataPresent(Bi.MatricesWeightsExtraKind) ? this._normalizeSkinWeightsAndExtra() : this._normalizeSkinFourWeights())
}
,
t.prototype._normalizeSkinFourWeights = function() {
for (var e = this.getVerticesData(Bi.MatricesWeightsKind), t = e.length, i = 0; i < t; i += 4) {
var n = e[i] + e[i + 1] + e[i + 2] + e[i + 3];
if (0 === n)
e[i] = 1;
else {
var r = 1 / n;
e[i] *= r,
e[i + 1] *= r,
e[i + 2] *= r,
e[i + 3] *= r
}
}
this.setVerticesData(Bi.MatricesWeightsKind, e)
}
,
t.prototype._normalizeSkinWeightsAndExtra = function() {
for (var e = this.getVerticesData(Bi.MatricesWeightsExtraKind), t = this.getVerticesData(Bi.MatricesWeightsKind), i = t.length, n = 0; n < i; n += 4) {
var r = t[n] + t[n + 1] + t[n + 2] + t[n + 3];
if (0 === (r += e[n] + e[n + 1] + e[n + 2] + e[n + 3]))
t[n] = 1;
else {
var o = 1 / r;
t[n] *= o,
t[n + 1] *= o,
t[n + 2] *= o,
t[n + 3] *= o,
e[n] *= o,
e[n + 1] *= o,
e[n + 2] *= o,
e[n + 3] *= o
}
}
this.setVerticesData(Bi.MatricesWeightsKind, t),
this.setVerticesData(Bi.MatricesWeightsKind, e)
}
,
t.prototype.validateSkinning = function() {
var e = this.getVerticesData(Bi.MatricesWeightsExtraKind)
, t = this.getVerticesData(Bi.MatricesWeightsKind);
if (null === t || null == this.skeleton)
return {
skinned: !1,
valid: !0,
report: "not skinned"
};
for (var i = t.length, n = 0, r = 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 && n++,
0 !== f && d++,
h += f,
u = f
}
if (l[d]++,
d > o && (o = d),
0 === h)
r++;
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(Bi.MatricesIndicesKind)
, y = this.getVerticesData(Bi.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 === r && 0 === a && 0 === b,
report: "Number of Weights = " + i / 4 + "\nMaximum influences = " + o + "\nMissing Weights = " + r + "\nNot Sorted = " + n + "\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 gi.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 n = this.getScene().multiMaterials;
for (t = n.length - 1; t > -1; t--)
if (n[t].id === e)
return this.material = n[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(Bi.PositionKind))
return this;
var t = this.subMeshes.splice(0);
this._resetPointsArrayCache();
var i, n = this.getVerticesData(Bi.PositionKind), r = new Array;
for (i = 0; i < n.length; i += 3)
x.TransformCoordinates(x.FromArray(n, i), e).toArray(r, i);
if (this.setVerticesData(Bi.PositionKind, r, this.getVertexBuffer(Bi.PositionKind).isUpdatable()),
this.isVerticesDataPresent(Bi.NormalKind)) {
for (n = this.getVerticesData(Bi.NormalKind),
r = [],
i = 0; i < n.length; i += 3)
x.TransformNormal(x.FromArray(n, i), e).normalize().toArray(r, i);
this.setVerticesData(Bi.NormalKind, r, this.getVertexBuffer(Bi.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, n, r) {
return void 0 === e && (e = ""),
void 0 === i && (i = null),
void 0 === r && (r = !0),
new t(e,this.getScene(),i,this,n,r)
}
,
t.prototype.dispose = function(t, i) {
void 0 === i && (i = !1),
this.morphTargetManager = null,
this._geometry && this._geometry.releaseForMesh(this, !0);
var n = this._internalMeshDataInfo;
if (n._onBeforeDrawObservable && n._onBeforeDrawObservable.clear(),
n._onBeforeBindObservable && n._onBeforeBindObservable.clear(),
n._onBeforeRenderObservable && n._onBeforeRenderObservable.clear(),
n._onAfterRenderObservable && n._onAfterRenderObservable.clear(),
n._onBetweenPassObservable && n._onBetweenPassObservable.clear(),
this._scene.useClonedMeshMap) {
if (n.meshMap)
for (var r in n.meshMap)
(s = n.meshMap[r]) && (s._internalMeshDataInfo._source = null,
n.meshMap[r] = void 0);
n._source && n._source._internalMeshDataInfo.meshMap && (n._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)
}
n._source = null,
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, n, r, o, a) {
var s = this;
void 0 === a && (a = !1);
var l = this.getScene();
return gi.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, r, o, a),
n && n(s)
}
), (function() {}
), l.offlineProvider),
this
}
,
t.prototype.applyDisplacementMapFromBuffer = function(e, t, i, n, r, o, a, s) {
if (void 0 === s && (s = !1),
!this.isVerticesDataPresent(Bi.PositionKind) || !this.isVerticesDataPresent(Bi.NormalKind) || !this.isVerticesDataPresent(Bi.UVKind))
return K.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"),
this;
var l = this.getVerticesData(Bi.PositionKind, !0, !0)
, c = this.getVerticesData(Bi.NormalKind)
, u = this.getVerticesData(Bi.UVKind)
, h = x.Zero()
, d = x.Zero()
, p = A.Zero();
o = o || A.Zero(),
a = a || new A(1,1);
for (var f = 0; f < l.length; f += 3) {
x.FromArrayToRef(l, f, h),
x.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(n + (r - n) * m),
(h = h.add(d)).toArray(l, f)
}
return $n.ComputeNormals(l, this.getIndices(), c),
s ? (this.setVerticesData(Bi.PositionKind, l),
this.setVerticesData(Bi.NormalKind, c),
this.setVerticesData(Bi.UVKind, u)) : (this.updateVerticesData(Bi.PositionKind, l),
this.updateVerticesData(Bi.NormalKind, c)),
this
}
,
t.prototype.convertToFlatShadedMesh = function() {
var e, t, i = this.getVerticesDataKinds(), n = {}, r = {}, o = {}, s = !1;
for (e = 0; e < i.length; e++) {
t = i[e];
var l = this.getVertexBuffer(t)
, c = l.getData();
(c instanceof Array || c instanceof Float32Array) && 0 === c.length || (t !== Bi.NormalKind ? (n[t] = l,
r[t] = this.getVerticesData(t),
o[t] = []) : (s = l.isUpdatable(),
i.splice(e, 1),
e--))
}
var u, h = this.subMeshes.slice(0), d = this.getIndices(), p = this.getTotalIndices();
for (u = 0; u < p; u++) {
var f = d[u];
for (e = 0; e < i.length; e++)
if (n[t = i[e]])
for (var _ = n[t].getStrideSize(), m = 0; m < _; m++)
o[t].push(r[t][f * _ + m])
}
var g, v = [], y = o[Bi.PositionKind];
for (g = this.getScene().useRightHandedSystem ? this.overrideMaterialSideOrientation === a.MATERIAL_CounterClockWiseSideOrientation : this.overrideMaterialSideOrientation === a.MATERIAL_ClockWiseSideOrientation,
u = 0; u < p; u += 3) {
d[u] = u,
d[u + 1] = u + 1,
d[u + 2] = u + 2;
var b = x.FromArray(y, 3 * u)
, T = x.FromArray(y, 3 * (u + 1))
, E = x.FromArray(y, 3 * (u + 2))
, S = b.subtract(T)
, A = E.subtract(T)
, R = x.Normalize(x.Cross(S, A));
g && R.scaleInPlace(-1);
for (var C = 0; C < 3; C++)
v.push(R.x),
v.push(R.y),
v.push(R.z)
}
for (this.setIndices(d),
this.setVerticesData(Bi.NormalKind, v, s),
e = 0; e < i.length; e++)
o[t = i[e]] && this.setVerticesData(t, o[t], n[t].isUpdatable());
this.releaseSubMeshes();
for (var P = 0; P < h.length; P++) {
var M = h[P];
hr.AddToMesh(M.materialIndex, M.indexStart, M.indexCount, M.indexStart, M.indexCount, this)
}
return this.synchronizeInstances(),
this
}
,
t.prototype.convertToUnIndexedMesh = function() {
var e, t, i = this.getVerticesDataKinds(), n = {}, r = {}, o = {};
for (e = 0; e < i.length; e++) {
t = i[e];
var a = this.getVertexBuffer(t);
n[t] = a,
r[t] = n[t].getData(),
o[t] = []
}
var s, l = this.subMeshes.slice(0), c = this.getIndices(), u = this.getTotalIndices();
for (s = 0; s < u; s++) {
var h = c[s];
for (e = 0; e < i.length; e++)
for (var d = n[t = i[e]].getStrideSize(), p = 0; p < d; p++)
o[t].push(r[t][h * d + p])
}
for (s = 0; s < u; s += 3)
c[s] = s,
c[s + 1] = s + 1,
c[s + 2] = s + 2;
for (this.setIndices(c),
e = 0; e < i.length; e++)
t = i[e],
this.setVerticesData(t, o[t], n[t].isUpdatable());
this.releaseSubMeshes();
for (var f = 0; f < l.length; f++) {
var _ = l[f];
hr.AddToMesh(_.materialIndex, _.indexStart, _.indexCount, _.indexStart, _.indexCount, this)
}
return this._unIndexed = !0,
this.synchronizeInstances(),
this
}
,
t.prototype.flipFaces = function(e) {
void 0 === e && (e = !1);
var t, i = $n.ExtractFromMesh(this);
if (e && this.isVerticesDataPresent(Bi.NormalKind) && i.normals)
for (t = 0; t < i.normals.length; t++)
i.normals[t] *= -1;
if (i.indices) {
var n = void 0;
for (t = 0; t < i.indices.length; t += 3)
n = i.indices[t + 1],
i.indices[t + 1] = i.indices[t + 2],
i.indices[t + 2] = n
}
return i.applyToMesh(this, this.isVertexBufferUpdatable(Bi.PositionKind)),
this
}
,
t.prototype.increaseVertices = function(e) {
var t = $n.ExtractFromMesh(this)
, i = t.uvs && !Array.isArray(t.uvs) && Array.from ? Array.from(t.uvs) : t.uvs
, n = 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
, o = t.normals && !Array.isArray(t.normals) && Array.from ? Array.from(t.normals) : t.normals;
if (n && r && o && i) {
t.indices = n,
t.positions = r,
t.normals = o,
t.uvs = i;
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 x(0,0,0)
, d = new x(0,0,0)
, p = new A(0,0)
, f = new Array
, _ = new Array
, m = new Array
, g = void 0
, v = r.length
, y = i.length;
for (l = 0; l < n.length; l += 3) {
_[0] = n[l],
_[1] = n[l + 1],
_[2] = n[l + 2];
for (var b = 0; b < 3; b++)
if (c = _[b],
u = _[(b + 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,
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,
p.x = (i[2 * u] - i[2 * c]) / a,
p.y = (i[2 * u + 1] - i[2 * c + 1]) / a,
m[c][u].push(c);
for (var T = 1; T < a; T++)
m[c][u].push(r.length / 3),
r[v] = r[3 * c] + T * h.x,
o[v++] = o[3 * c] + T * d.x,
r[v] = r[3 * c + 1] + T * h.y,
o[v++] = o[3 * c + 1] + T * d.y,
r[v] = r[3 * c + 2] + T * h.z,
o[v++] = o[3 * c + 2] + T * d.z,
i[y++] = i[2 * c] + T * p.x,
i[y++] = i[2 * c + 1] + T * p.y;
m[c][u].push(u),
m[u][c] = new Array,
g = m[c][u].length;
for (var E = 0; E < g; E++)
m[u][c][E] = m[c][u][g - 1 - E]
}
for (s[0][0] = n[l],
s[1][0] = m[n[l]][n[l + 1]][1],
s[1][1] = m[n[l]][n[l + 2]][1],
T = 2; T < a; T++)
for (s[T][0] = m[n[l]][n[l + 1]][T],
s[T][T] = m[n[l]][n[l + 2]][T],
h.x = (r[3 * s[T][T]] - r[3 * s[T][0]]) / T,
h.y = (r[3 * s[T][T] + 1] - r[3 * s[T][0] + 1]) / T,
h.z = (r[3 * s[T][T] + 2] - r[3 * s[T][0] + 2]) / T,
d.x = (o[3 * s[T][T]] - o[3 * s[T][0]]) / T,
d.y = (o[3 * s[T][T] + 1] - o[3 * s[T][0] + 1]) / T,
d.z = (o[3 * s[T][T] + 2] - o[3 * s[T][0] + 2]) / T,
p.x = (i[2 * s[T][T]] - i[2 * s[T][0]]) / T,
p.y = (i[2 * s[T][T] + 1] - i[2 * s[T][0] + 1]) / T,
b = 1; b < T; b++)
s[T][b] = r.length / 3,
r[v] = r[3 * s[T][0]] + b * h.x,
o[v++] = o[3 * s[T][0]] + b * d.x,
r[v] = r[3 * s[T][0] + 1] + b * h.y,
o[v++] = o[3 * s[T][0] + 1] + b * d.y,
r[v] = r[3 * s[T][0] + 2] + b * h.z,
o[v++] = o[3 * s[T][0] + 2] + b * d.z,
i[y++] = i[2 * s[T][0]] + b * p.x,
i[y++] = i[2 * s[T][0] + 1] + b * p.y;
for (s[a] = m[n[l + 1]][n[l + 2]],
f.push(s[0][0], s[1][0], s[1][1]),
T = 1; T < a; T++) {
for (b = void 0,
b = 0; b < T; b++)
f.push(s[T][b], s[T + 1][b], s[T + 1][b + 1]),
f.push(s[T][b], s[T + 1][b + 1], s[T][b + 1]);
f.push(s[T][b], s[T + 1][b], s[T + 1][b + 1])
}
}
t.indices = f,
t.applyToMesh(this, this.isVertexBufferUpdatable(Bi.PositionKind))
} else
K.Warn("VertexData contains null entries")
}
,
t.prototype.forceSharedVertices = function() {
var e = $n.ExtractFromMesh(this)
, t = e.uvs
, i = e.indices
, n = e.positions
, r = e.colors;
if (void 0 === i || void 0 === n || null === i || null === n)
K.Warn("VertexData contains empty entries");
else {
for (var o = new Array, a = new Array, s = new Array, l = new Array, c = new Array, u = 0, h = {}, d = void 0, p = void 0, f = 0; f < i.length; f += 3) {
p = [i[f], i[f + 1], i[f + 2]],
c = new Array;
for (var _ = 0; _ < 3; _++) {
c[_] = "";
for (var m = 0; m < 3; m++)
Math.abs(n[3 * p[_] + m]) < 1e-8 && (n[3 * p[_] + m] = 0),
c[_] += n[3 * p[_] + m] + "|"
}
if (c[0] != c[1] && c[0] != c[2] && c[1] != c[2])
for (_ = 0; _ < 3; _++) {
if (void 0 === (d = h[c[_]])) {
for (h[c[_]] = u,
d = u++,
m = 0; m < 3; m++)
o.push(n[3 * p[_] + m]);
if (null != r)
for (m = 0; m < 4; m++)
l.push(r[4 * p[_] + m]);
if (null != t)
for (m = 0; m < 2; m++)
s.push(t[2 * p[_] + m])
}
a.push(d)
}
}
var g = new Array;
$n.ComputeNormals(o, a, g),
e.positions = o,
e.indices = a,
e.normals = g,
null != t && (e.uvs = s),
null != r && (e.colors = l),
e.applyToMesh(this, this.isVertexBufferUpdatable(Bi.PositionKind))
}
}
,
t._instancedMeshFactory = function(e, t) {
throw be("InstancedMesh")
}
,
t._PhysicsImpostorParser = function(e, t, i) {
throw be("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()
, n = this.getVerticesData(Bi.PositionKind);
if (!n || !i)
return this;
for (var r = new Array, o = 0; o < n.length; o += 3)
r.push(x.FromArray(n, o));
var a = new Array;
return yi.SyncAsyncForLoop(r.length, 40, (function(e) {
for (var t = r.length - 1 - e, i = r[t], n = 0; n < t; ++n) {
var o = r[n];
if (i.equals(o)) {
a[t] = n;
break
}
}
}
), (function() {
for (var n = 0; n < i.length; ++n)
i[n] = a[i[n]] || i[n];
var r = t.subMeshes.slice(0);
t.setIndices(i),
t.subMeshes = r,
e && e(t)
}
)),
this
}
,
t.prototype.serialize = function(e) {
e.name = this.name,
e.id = this.id,
e.uniqueId = this.uniqueId,
e.type = this.getClassName(),
ye && ye.HasTags(this) && (e.tags = ye.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 && (e.parentId = this.parent.uniqueId),
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 n = this.subMeshes[i];
e.subMeshes.push({
materialIndex: n.materialIndex,
verticesStart: n.verticesStart,
verticesCount: n.verticesCount,
indexStart: n.indexStart,
indexCount: n.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(Wi.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 r = 0; r < this.instances.length; r++) {
var o = this.instances[r];
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 && (s.parentId = o.parent.uniqueId),
o.rotationQuaternion ? s.rotationQuaternion = o.rotationQuaternion.asArray() : o.rotation && (s.rotation = o.rotation.asArray()),
this.getScene()._getComponent(Wi.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),
e.instances.push(s),
Ge.AppendSerializedAnimations(o, s),
s.ranges = o.serializeAnimationRanges()
}
}
if (this._thinInstanceDataStorage.instancesCount && this._thinInstanceDataStorage.matrixData && (e.thinInstances = {
instancesCount: this._thinInstanceDataStorage.instancesCount,
matrixData: gi.SliceToArray(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] = gi.SliceToArray(this._userThinInstanceBuffersStorage.data[c]),
l.sizes[c] = this._userThinInstanceBuffersStorage.sizes[c],
l.strides[c] = this._userThinInstanceBuffersStorage.strides[c];
e.thinInstances.userThinInstance = l
}
Ge.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))
}
,
t.prototype._syncGeometryWithMorphTargetManager = function() {
if (this.geometry) {
this._markSubMeshesAsAttributesDirty();
var e = this._internalAbstractMeshDataInfo._morphTargetManager;
if (e && e.vertexCount) {
if (e.vertexCount !== this.getTotalVertices())
return K.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)
, n = i.getPositions();
if (!n)
return void K.Error("Invalid morph target. Target must have positions.");
this.geometry.setVerticesData(Bi.PositionKind + t, n, !1, 3);
var r = i.getNormals();
r && this.geometry.setVerticesData(Bi.NormalKind + t, r, !1, 3);
var o = i.getTangents();
o && this.geometry.setVerticesData(Bi.TangentKind + t, o, !1, 3);
var a = i.getUVs();
a && this.geometry.setVerticesData(Bi.UVKind + "_" + t, a, !1, 2)
}
} else
for (t = 0; this.geometry.isVerticesDataPresent(Bi.PositionKind + t); )
this.geometry.removeVerticesData(Bi.PositionKind + t),
this.geometry.isVerticesDataPresent(Bi.NormalKind + t) && this.geometry.removeVerticesData(Bi.NormalKind + t),
this.geometry.isVerticesDataPresent(Bi.TangentKind + t) && this.geometry.removeVerticesData(Bi.TangentKind + t),
this.geometry.isVerticesDataPresent(Bi.UVKind + t) && this.geometry.removeVerticesData(Bi.UVKind + "_" + t),
t++
}
}
,
t.Parse = function(e, i, n) {
var r;
if ((r = 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) : new t(e.name,i)).id = e.id,
ye && ye.AddTagsTo(r, e.tags),
r.position = x.FromArray(e.position),
void 0 !== e.metadata && (r.metadata = e.metadata),
e.rotationQuaternion ? r.rotationQuaternion = C.FromArray(e.rotationQuaternion) : e.rotation && (r.rotation = x.FromArray(e.rotation)),
r.scaling = x.FromArray(e.scaling),
e.localMatrix ? r.setPreTransformMatrix(P.FromArray(e.localMatrix)) : e.pivotMatrix && r.setPivotMatrix(P.FromArray(e.pivotMatrix)),
r.setEnabled(e.isEnabled),
r.isVisible = e.isVisible,
r.infiniteDistance = e.infiniteDistance,
r.showBoundingBox = e.showBoundingBox,
r.showSubMeshesBoundingBox = e.showSubMeshesBoundingBox,
void 0 !== e.applyFog && (r.applyFog = e.applyFog),
void 0 !== e.pickable && (r.isPickable = e.pickable),
void 0 !== e.alphaIndex && (r.alphaIndex = e.alphaIndex),
r.receiveShadows = e.receiveShadows,
r.billboardMode = e.billboardMode,
void 0 !== e.visibility && (r.visibility = e.visibility),
r.checkCollisions = e.checkCollisions,
r.overrideMaterialSideOrientation = e.overrideMaterialSideOrientation,
void 0 !== e.isBlocker && (r.isBlocker = e.isBlocker),
r._shouldGenerateFlatShading = e.useFlatShading,
e.freezeWorldMatrix && (r._waitingData.freezeWorldMatrix = e.freezeWorldMatrix),
void 0 !== e.parentId && (r._waitingParentId = e.parentId),
void 0 !== e.actions && (r._waitingData.actions = e.actions),
void 0 !== e.overlayAlpha && (r.overlayAlpha = e.overlayAlpha),
void 0 !== e.overlayColor && (r.overlayColor = D.FromArray(e.overlayColor)),
void 0 !== e.renderOverlay && (r.renderOverlay = e.renderOverlay),
r.isUnIndexed = !!e.isUnIndexed,
r.hasVertexAlpha = e.hasVertexAlpha,
e.delayLoadingFile ? (r.delayLoadState = a.DELAYLOADSTATE_NOTLOADED,
r.delayLoadingFile = n + e.delayLoadingFile,
r.buildBoundingInfo(x.FromArray(e.boundingBoxMinimum), x.FromArray(e.boundingBoxMaximum)),
e._binaryInfo && (r._binaryInfo = e._binaryInfo),
r._delayInfo = [],
e.hasUVs && r._delayInfo.push(Bi.UVKind),
e.hasUVs2 && r._delayInfo.push(Bi.UV2Kind),
e.hasUVs3 && r._delayInfo.push(Bi.UV3Kind),
e.hasUVs4 && r._delayInfo.push(Bi.UV4Kind),
e.hasUVs5 && r._delayInfo.push(Bi.UV5Kind),
e.hasUVs6 && r._delayInfo.push(Bi.UV6Kind),
e.hasColors && r._delayInfo.push(Bi.ColorKind),
e.hasMatricesIndices && r._delayInfo.push(Bi.MatricesIndicesKind),
e.hasMatricesWeights && r._delayInfo.push(Bi.MatricesWeightsKind),
r._delayLoadingFunction = fr._ImportGeometry,
dr.ForceFullSceneLoadingForIncremental && r._checkDelayState()) : fr._ImportGeometry(e, r),
e.materialUniqueId ? r._waitingMaterialId = e.materialUniqueId : e.materialId && (r._waitingMaterialId = e.materialId),
e.morphTargetManagerId > -1 && (r.morphTargetManager = i.getMorphTargetManagerById(e.morphTargetManagerId)),
void 0 !== e.skeletonId && null !== e.skeletonId && (r.skeleton = i.getLastSkeletonById(e.skeletonId),
e.numBoneInfluencers && (r.numBoneInfluencers = e.numBoneInfluencers)),
e.animations) {
for (var o = 0; o < e.animations.length; o++) {
var s = e.animations[o];
(h = b("BABYLON.Animation")) && r.animations.push(h.Parse(s))
}
Xe.ParseAnimationRanges(r, e, i)
}
if (e.autoAnimate && i.beginAnimation(r, e.autoAnimateFrom, e.autoAnimateTo, e.autoAnimateLoop, e.autoAnimateSpeed || 1),
e.layerMask && !isNaN(e.layerMask) ? r.layerMask = Math.abs(parseInt(e.layerMask)) : r.layerMask = 268435455,
e.physicsImpostor && t._PhysicsImpostorParser(i, r, e),
e.lodMeshIds && (r._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 = r.createInstance(c.name);
if (c.id && (u.id = c.id),
ye && (c.tags ? ye.AddTagsTo(u, c.tags) : ye.AddTagsTo(u, e.tags)),
u.position = x.FromArray(c.position),
void 0 !== c.metadata && (u.metadata = c.metadata),
void 0 !== c.parentId && (u._waitingParentId = c.parentId),
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 = C.FromArray(c.rotationQuaternion) : c.rotation && (u.rotation = x.FromArray(c.rotation)),
u.scaling = x.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),
c.animations) {
for (o = 0; o < c.animations.length; o++) {
var h;
s = c.animations[o],
(h = b("BABYLON.Animation")) && u.animations.push(h.Parse(s))
}
Xe.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 (r.thinInstanceEnablePicking = !!d.enablePicking,
d.matrixData ? (r.thinInstanceSetBuffer("matrix", new Float32Array(d.matrixData), 16, !1),
r._thinInstanceDataStorage.matrixBufferSize = d.matrixBufferSize,
r._thinInstanceDataStorage.instancesCount = d.instancesCount) : r._thinInstanceDataStorage.matrixBufferSize = d.matrixBufferSize,
e.thinInstances.userThinInstance) {
var p = e.thinInstances.userThinInstance;
for (var f in p.data)
r.thinInstanceSetBuffer(f, new Float32Array(p.data[f]), p.strides[f], !1),
r._userThinInstanceBuffersStorage.sizes[f] = p.sizes[f]
}
}
return r
}
,
t.prototype.setPositionsForCPUSkinning = function() {
var e = this._internalMeshDataInfo;
if (!e._sourcePositions) {
var t = this.getVerticesData(Bi.PositionKind);
if (!t)
return e._sourcePositions;
e._sourcePositions = new Float32Array(t),
this.isVertexBufferUpdatable(Bi.PositionKind) || this.setVerticesData(Bi.PositionKind, t, !0)
}
return e._sourcePositions
}
,
t.prototype.setNormalsForCPUSkinning = function() {
var e = this._internalMeshDataInfo;
if (!e._sourceNormals) {
var t = this.getVerticesData(Bi.NormalKind);
if (!t)
return e._sourceNormals;
e._sourceNormals = new Float32Array(t),
this.isVertexBufferUpdatable(Bi.NormalKind) || this.setVerticesData(Bi.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(Bi.PositionKind))
return this;
if (!this.isVerticesDataPresent(Bi.MatricesIndicesKind))
return this;
if (!this.isVerticesDataPresent(Bi.MatricesWeightsKind))
return this;
var t = this.isVerticesDataPresent(Bi.NormalKind)
, i = this._internalMeshDataInfo;
if (!i._sourcePositions) {
var n = this.subMeshes.slice();
this.setPositionsForCPUSkinning(),
this.subMeshes = n
}
t && !i._sourceNormals && this.setNormalsForCPUSkinning();
var r = this.getVerticesData(Bi.PositionKind);
if (!r)
return this;
r instanceof Float32Array || (r = new Float32Array(r));
var o = this.getVerticesData(Bi.NormalKind);
if (t) {
if (!o)
return this;
o instanceof Float32Array || (o = new Float32Array(o))
}
var a = this.getVerticesData(Bi.MatricesIndicesKind)
, s = this.getVerticesData(Bi.MatricesWeightsKind);
if (!s || !a)
return this;
for (var l, c = this.numBoneInfluencers > 4, u = c ? this.getVerticesData(Bi.MatricesIndicesExtraKind) : null, h = c ? this.getVerticesData(Bi.MatricesWeightsExtraKind) : null, d = e.getTransformMatrices(this), p = x.Zero(), f = new P, _ = new P, m = 0, g = 0; g < r.length; g += 3,
m += 4) {
var v = void 0;
for (l = 0; l < 4; l++)
(v = s[m + l]) > 0 && (P.FromFloat32ArrayToRefScaled(d, Math.floor(16 * a[m + l]), v, _),
f.addToSelf(_));
if (c)
for (l = 0; l < 4; l++)
(v = h[m + l]) > 0 && (P.FromFloat32ArrayToRefScaled(d, Math.floor(16 * u[m + l]), v, _),
f.addToSelf(_));
x.TransformCoordinatesFromFloatsToRef(i._sourcePositions[g], i._sourcePositions[g + 1], i._sourcePositions[g + 2], f, p),
p.toArray(r, g),
t && (x.TransformNormalFromFloatsToRef(i._sourceNormals[g], i._sourceNormals[g + 1], i._sourceNormals[g + 2], f, p),
p.toArray(o, g)),
f.reset()
}
return this.updateVerticesData(Bi.PositionKind, r),
t && this.updateVerticesData(Bi.NormalKind, o),
this
}
,
t.MinMax = function(e) {
var t = null
, i = null;
return e.forEach((function(e) {
var n = e.getBoundingInfo().boundingBox;
t && i ? (t.minimizeInPlace(n.minimumWorld),
i.maximizeInPlace(n.maximumWorld)) : (t = n.minimumWorld,
i = n.maximumWorld)
}
)),
t && i ? {
min: t,
max: i
} : {
min: x.Zero(),
max: x.Zero()
}
}
,
t.Center = function(e) {
var i = e instanceof Array ? t.MinMax(e) : e;
return x.Center(i.min, i.max)
}
,
t.MergeMeshes = function(e, i, n, r, o, a) {
return void 0 === i && (i = !0),
Qn(t._MergeMeshesCoroutine(e, i, n, r, o, a, !1))
}
,
t.MergeMeshesAsync = function(e, i, n, r, o, a) {
return void 0 === i && (i = !0),
qn(t._MergeMeshesCoroutine(e, i, n, r, o, a, !0), Yn())
}
,
t._MergeMeshesCoroutine = function(e, i, n, r, o, a, s) {
var l, c, u, h, d, p, f, _, m, g, v, y, b, T, E, S, A, x, R, C, P, M, I, O, D;
return void 0 === i && (i = !0),
z(this, (function(N) {
switch (N.label) {
case 0:
if (0 === (e = e.filter(Boolean)).length)
return [2, null];
if (!n)
for (c = 0,
l = 0; l < e.length; l++)
if ((c += e[l].getTotalVertices()) >= 65536)
return K.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,
l = 0; l < e.length; l++) {
if ((p = e[l]).isAnInstance)
return K.Warn("Cannot merge instance meshes."),
[2, null];
if (o && d.push(p.getTotalIndices()),
a)
if (p.material)
if ((f = p.material)instanceof Dr) {
for (_ = 0; _ < f.subMaterials.length; _++)
u.indexOf(f.subMaterials[_]) < 0 && u.push(f.subMaterials[_]);
for (D = 0; D < p.subMeshes.length; D++)
h.push(u.indexOf(f.subMaterials[p.subMeshes[D].materialIndex])),
d.push(p.subMeshes[D].indexCount)
} else
for (u.indexOf(f) < 0 && u.push(f),
D = 0; D < p.subMeshes.length; D++)
h.push(u.indexOf(f)),
d.push(p.subMeshes[D].indexCount);
else
for (D = 0; D < p.subMeshes.length; D++)
h.push(0),
d.push(p.subMeshes[D].indexCount)
}
return m = e[0],
g = function(e) {
var t = e.computeWorldMatrix(!0);
return [$n.ExtractFromMesh(e, !1, !1), t]
}
,
v = g(m),
y = v[0],
b = v[1],
s ? [4] : [3, 2];
case 1:
N.sent(),
N.label = 2;
case 2:
T = new Array(e.length - 1),
E = 1,
N.label = 3;
case 3:
return E < e.length ? (T[E - 1] = g(e[E]),
s ? [4] : [3, 5]) : [3, 6];
case 4:
N.sent(),
N.label = 5;
case 5:
return E++,
[3, 3];
case 6:
S = y._mergeCoroutine(b, T, n, s, !i),
A = S.next(),
N.label = 7;
case 7:
return A.done ? [3, 10] : s ? [4] : [3, 9];
case 8:
N.sent(),
N.label = 9;
case 9:
return A = S.next(),
[3, 7];
case 10:
x = A.value,
r || (r = new t(m.name + "_merged",m.getScene())),
R = x._applyToCoroutine(r, void 0, s),
C = R.next(),
N.label = 11;
case 11:
return C.done ? [3, 14] : s ? [4] : [3, 13];
case 12:
N.sent(),
N.label = 13;
case 13:
return C = R.next(),
[3, 11];
case 14:
if (r.checkCollisions = m.checkCollisions,
r.overrideMaterialSideOrientation = m.overrideMaterialSideOrientation,
i)
for (l = 0; l < e.length; l++)
e[l].dispose();
if (o || a) {
for (r.releaseSubMeshes(),
l = 0,
P = 0; l < d.length; )
hr.CreateFromIndices(0, P, d[l], r, void 0, !1),
P += d[l],
l++;
for (M = 0,
I = r.subMeshes; M < I.length; M++)
I[M].refreshBoundingInfo();
r.computeWorldMatrix(!0)
}
if (a) {
for ((O = new Dr(m.name + "_merged",m.getScene())).subMaterials = u,
D = 0; D < r.subMeshes.length; D++)
r.subMeshes[D].materialIndex = h[D];
r.material = O
} else
r.material = m.material;
return [2, r]
}
}
))
}
,
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 === Or.CounterClockWiseSideOrientation
}
,
t.FRONTSIDE = $n.FRONTSIDE,
t.BACKSIDE = $n.BACKSIDE,
t.DOUBLESIDE = $n.DOUBLESIDE,
t.DEFAULTSIDE = $n.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 be("GroundMesh")
}
,
t._GoldbergMeshParser = function(e, t) {
throw be("GoldbergMesh")
}
,
t._LinesMeshParser = function(e, t) {
throw be("LinesMesh")
}
,
t
}(Sr);
y("BABYLON.Mesh", Vr),
Vr.prototype.setMaterialByID = function(e) {
return this.setMaterialById(e)
}
,
Vr.CreateDisc = Vr.CreateDisc || function() {
throw new Error("Import MeshBuilder to populate this function")
}
,
Vr.CreateBox = Vr.CreateBox || function() {
throw new Error("Import MeshBuilder to populate this function")
}
,
Vr.CreateSphere = Vr.CreateSphere || function() {
throw new Error("Import MeshBuilder to populate this function")
}
,
Vr.CreateCylinder = Vr.CreateCylinder || function() {
throw new Error("Import MeshBuilder to populate this function")
}
,
Vr.CreateTorusKnot = Vr.CreateTorusKnot || function() {
throw new Error("Import MeshBuilder to populate this function")
}
,
Vr.CreateTorus = Vr.CreateTorus || function() {
throw new Error("Import MeshBuilder to populate this function")
}
,
Vr.CreatePlane = Vr.CreatePlane || function() {
throw new Error("Import MeshBuilder to populate this function")
}
,
Vr.CreateGround = Vr.CreateGround || function() {
throw new Error("Import MeshBuilder to populate this function")
}
,
Vr.CreateTiledGround = Vr.CreateTiledGround || function() {
throw new Error("Import MeshBuilder to populate this function")
}
,
Vr.CreateGroundFromHeightMap = Vr.CreateGroundFromHeightMap || function() {
throw new Error("Import MeshBuilder to populate this function")
}
,
Vr.CreateTube = Vr.CreateTube || function() {
throw new Error("Import MeshBuilder to populate this function")
}
,
Vr.CreatePolyhedron = Vr.CreatePolyhedron || function() {
throw new Error("Import MeshBuilder to populate this function")
}
,
Vr.CreateIcoSphere = Vr.CreateIcoSphere || function() {
throw new Error("Import MeshBuilder to populate this function")
}
,
Vr.CreateDecal = Vr.CreateDecal || function() {
throw new Error("Import MeshBuilder to populate this function")
}
,
Vr.CreateCapsule = Vr.CreateCapsule || function() {
throw new Error("Import MeshBuilder to populate this function")
}
,
Vr.ExtendToGoldberg = Vr.ExtendToGoldberg || function() {
throw new Error("Import MeshBuilder to populate this function")
}
;
var kr = function(e) {
function t() {
return null !== e && e.apply(this, arguments) || this
}
return U(t, e),
t
}(o)
, Gr = function() {
this.rootNodes = [],
this.skeletons = [],
this.animationGroups = []
}
, zr = function(e) {
function t(t) {
var i = e.call(this) || this;
return i._wasAddedToScene = !1,
(t = t || E.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 n = 0, r = i.meshes; n < r.length; n++)
r[n]._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 U(t, e),
t.prototype.instantiateModelsToScene = function(e, t, i) {
var n = this;
void 0 === t && (t = !1);
var r = {}
, o = {}
, a = new Gr
, s = []
, l = [];
i || (i = {
doNotInstantiate: !0
});
var c = function(t, i) {
if (r[t.uniqueId] = i.uniqueId,
o[i.uniqueId] = i,
e && (i.name = e(t.name)),
i instanceof Vr) {
var n = i;
if (n.morphTargetManager) {
var a = t.morphTargetManager;
n.morphTargetManager = a.clone();
for (var s = 0; s < a.numTargets; s++) {
var l = a.getTarget(s)
, c = n.morphTargetManager.getTarget(s);
r[l.uniqueId] = c.uniqueId,
o[c.uniqueId] = c
}
}
}
};
return this.transformNodes.forEach((function(e) {
if (!e.parent) {
var t = e.instantiateHierarchy(null, i, (function(e, t) {
c(e, t)
}
));
t && a.rootNodes.push(t)
}
}
)),
this.meshes.forEach((function(s) {
if (!s.parent) {
var u = s.instantiateHierarchy(null, i, (function(i, a) {
if (c(i, a),
a.material) {
var s = a;
if (s.material)
if (t) {
var u = i.material;
if (-1 === l.indexOf(u)) {
var h = u.clone(e ? e(u.name) : "Clone of " + u.name);
if (l.push(u),
r[u.uniqueId] = h.uniqueId,
o[h.uniqueId] = h,
"MultiMaterial" === u.getClassName()) {
for (var d = u, p = 0, f = d.subMaterials; p < f.length; p++) {
var _ = f[p];
_ && (h = _.clone(e ? e(_.name) : "Clone of " + _.name),
l.push(_),
r[_.uniqueId] = h.uniqueId,
o[h.uniqueId] = h)
}
d.subMaterials = d.subMaterials.map((function(e) {
return e && o[r[e.uniqueId]]
}
))
}
}
"InstancedMesh" !== s.getClassName() && (s.material = o[r[u.uniqueId]])
} else
"MultiMaterial" === s.material.getClassName() ? -1 === n.scene.multiMaterials.indexOf(s.material) && n.scene.addMultiMaterial(s.material) : -1 === n.scene.materials.indexOf(s.material) && n.scene.addMaterial(s.material)
}
}
));
u && a.rootNodes.push(u)
}
}
)),
this.skeletons.forEach((function(t) {
for (var i = t.clone(e ? e(t.name) : "Clone of " + t.name), l = 0, c = n.meshes; l < c.length; l++) {
var u = c[l];
if (u.skeleton === t && !u.isAnInstance) {
var h = o[r[u.uniqueId]];
if (h.isAnInstance)
continue;
if (h.skeleton = i,
-1 !== s.indexOf(i))
continue;
s.push(i);
for (var d = 0, p = i.bones; d < p.length; d++) {
var f = p[d];
f._linkedTransformNode && (f._linkedTransformNode = o[r[f._linkedTransformNode.uniqueId]])
}
}
}
a.skeletons.push(i)
}
)),
this.animationGroups.forEach((function(t) {
var i = t.clone(e ? e(t.name) : "Clone of " + t.name, (function(e) {
return o[r[e.uniqueId]] || e
}
));
a.animationGroups.push(i)
}
)),
a
}
,
t.prototype.addAllToScene = function() {
var e = this;
if (!this._wasAddedToScene) {
this._wasAddedToScene = !0,
this.cameras.forEach((function(t) {
e.scene.addCamera(t)
}
)),
this.lights.forEach((function(t) {
e.scene.addLight(t)
}
)),
this.meshes.forEach((function(t) {
e.scene.addMesh(t)
}
)),
this.skeletons.forEach((function(t) {
e.scene.addSkeleton(t)
}
)),
this.animations.forEach((function(t) {
e.scene.addAnimation(t)
}
)),
this.animationGroups.forEach((function(t) {
e.scene.addAnimationGroup(t)
}
)),
this.multiMaterials.forEach((function(t) {
e.scene.addMultiMaterial(t)
}
)),
this.materials.forEach((function(t) {
e.scene.addMaterial(t)
}
)),
this.morphTargetManagers.forEach((function(t) {
e.scene.addMorphTargetManager(t)
}
)),
this.geometries.forEach((function(t) {
e.scene.addGeometry(t)
}
)),
this.transformNodes.forEach((function(t) {
e.scene.addTransformNode(t)
}
)),
this.actionManagers.forEach((function(t) {
e.scene.addActionManager(t)
}
)),
this.textures.forEach((function(t) {
e.scene.addTexture(t)
}
)),
this.reflectionProbes.forEach((function(t) {
e.scene.addReflectionProbe(t)
}
)),
this.environmentTexture && (this.scene.environmentTexture = this.environmentTexture);
for (var t = 0, i = this.scene._serializableComponents; t < i.length; t++)
i[t].addFromContainer(this);
this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),
this._onContextRestoredObserver = null
}
}
,
t.prototype.removeAllFromScene = function() {
var e = this;
this._wasAddedToScene = !1,
this.cameras.forEach((function(t) {
e.scene.removeCamera(t)
}
)),
this.lights.forEach((function(t) {
e.scene.removeLight(t)
}
)),
this.meshes.forEach((function(t) {
e.scene.removeMesh(t)
}
)),
this.skeletons.forEach((function(t) {
e.scene.removeSkeleton(t)
}
)),
this.animations.forEach((function(t) {
e.scene.removeAnimation(t)
}
)),
this.animationGroups.forEach((function(t) {
e.scene.removeAnimationGroup(t)
}
)),
this.multiMaterials.forEach((function(t) {
e.scene.removeMultiMaterial(t)
}
)),
this.materials.forEach((function(t) {
e.scene.removeMaterial(t)
}
)),
this.morphTargetManagers.forEach((function(t) {
e.scene.removeMorphTargetManager(t)
}
)),
this.geometries.forEach((function(t) {
e.scene.removeGeometry(t)
}
)),
this.transformNodes.forEach((function(t) {
e.scene.removeTransformNode(t)
}
)),
this.actionManagers.forEach((function(t) {
e.scene.removeActionManager(t)
}
)),
this.textures.forEach((function(t) {
e.scene.removeTexture(t)
}
)),
this.reflectionProbes.forEach((function(t) {
e.scene.removeReflectionProbe(t)
}
)),
this.environmentTexture === this.scene.environmentTexture && (this.scene.environmentTexture = null);
for (var t = 0, i = this.scene._serializableComponents; t < i.length; t++)
i[t].removeFromContainer(this)
}
,
t.prototype.dispose = function() {
this.cameras.slice(0).forEach((function(e) {
e.dispose()
}
)),
this.cameras = [],
this.lights.slice(0).forEach((function(e) {
e.dispose()
}
)),
this.lights = [],
this.meshes.slice(0).forEach((function(e) {
e.dispose()
}
)),
this.meshes = [],
this.skeletons.slice(0).forEach((function(e) {
e.dispose()
}
)),
this.skeletons = [],
this.animationGroups.slice(0).forEach((function(e) {
e.dispose()
}
)),
this.animationGroups = [],
this.multiMaterials.slice(0).forEach((function(e) {
e.dispose()
}
)),
this.multiMaterials = [],
this.materials.slice(0).forEach((function(e) {
e.dispose()
}
)),
this.materials = [],
this.geometries.slice(0).forEach((function(e) {
e.dispose()
}
)),
this.geometries = [],
this.transformNodes.slice(0).forEach((function(e) {
e.dispose()
}
)),
this.transformNodes = [],
this.actionManagers.slice(0).forEach((function(e) {
e.dispose()
}
)),
this.actionManagers = [],
this.textures.slice(0).forEach((function(e) {
e.dispose()
}
)),
this.textures = [],
this.reflectionProbes.slice(0).forEach((function(e) {
e.dispose()
}
)),
this.reflectionProbes = [],
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)
for (var n = 0, r = e; n < r.length; n++) {
var o = r[n]
, 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 kr),
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 Vr("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 = E.LastCreatedScene),
void 0 === i && (i = null),
!e)
return K.Error("No scene available to merge animations to"),
[];
var n = i || function(t) {
var i = null
, n = t.animations.length ? t.animations[0].targetProperty : ""
, r = t.name.split(".").join("").split("_primitive")[0];
switch (n) {
case "position":
case "rotationQuaternion":
i = e.getTransformNodeByName(t.name) || e.getTransformNodeByName(r);
break;
case "influence":
i = e.getMorphTargetByName(t.name) || e.getMorphTargetByName(r);
break;
default:
i = e.getNodeByName(t.name) || e.getNodeByName(r)
}
return i
}
;
this.getNodes().forEach((function(e) {
var t = n(e);
if (null !== t) {
for (var i = function(e) {
for (var i = 0, n = t.animations.filter((function(t) {
return t.targetProperty === e.targetProperty
}
)); i < n.length; i++) {
var r = n[i]
, o = t.animations.indexOf(r, 0);
o > -1 && t.animations.splice(o, 1)
}
}, r = 0, o = e.animations; r < o.length; r++)
i(o[r]);
t.animations = t.animations.concat(e.animations)
}
}
));
var r = new Array;
return this.animationGroups.slice().forEach((function(e) {
r.push(e.clone(e.name, n)),
e.animatables.forEach((function(e) {
e.stop()
}
))
}
)),
t.forEach((function(t) {
var i = n(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))
}
)),
r
}
,
t
}(o)
, Wr = 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 || E.LastCreatedScene) && (this._scene = e,
vr.audioEngine ? (this._audioEngine = vr.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))) : gi.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 n = t[i] / this.BARGRAPHAMPLITUDE
, r = this.DEBUGCANVASSIZE.height * n
, o = this.DEBUGCANVASSIZE.height - r - 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, r)
}
}
}
,
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
}();
vr.AudioEngineFactory = function(e, t, i) {
return new Hr(e,t,i)
}
;
var Hr = function() {
function e(e, t, i) {
void 0 === e && (e = null),
void 0 === t && (t = null),
void 0 === i && (i = null);
var n = 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 h,
this.onAudioLockedObservable = new h,
this._tryToRun = !1,
this._onResize = function() {
n._moveButtonToTopLeft()
}
,
nt()) {
void 0 === window.AudioContext && void 0 === window.webkitAudioContext || (window.AudioContext = window.AudioContext || window.webkitAudioContext,
this.canUseWebAudio = !0);
var r = document.createElement("audio");
this._hostElement = e,
this._audioContext = t,
this._audioDestination = i;
try {
r && r.canPlayType && (r.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, "") || r.canPlayType("audio/mp3").replace(/^no$/, "")) && (this.isMP3supported = !0)
} catch (e) {}
try {
r && r.canPlayType && r.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,
K.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
}()
, Xr = function() {
function e(t, i, n, r, o) {
void 0 === r && (r = null);
var a, s, l, c, u, 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 h,
this._spatialSound = !1,
this._panningModel = "equalpower",
this._playbackRate = 1,
this._streaming = !1,
this._startTime = 0,
this._startOffset = 0,
this._position = x.Zero(),
this._localDirection = new x(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,
n = n || E.LastCreatedScene)
if (this._scene = n,
e._SceneComponentInitialization(n),
this._readyToPlayCallback = r,
this._customAttenuationFunction = function(e, t, i, n, r) {
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 === (u = vr.audioEngine) || void 0 === u ? void 0 : u.canUseWebAudio) && vr.audioEngine.audioContext) {
this._soundGain = vr.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" : Array.isArray(i) && (this._urlType = "Array");
var f = []
, _ = !1;
switch (this._urlType) {
case "MediaElement":
this._streaming = !0,
this._isReadyToPlay = !0,
this._streamingSource = vr.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 = vr.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 "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) && vr.audioEngine.isMP3supported || -1 !== t.indexOf(".ogg", t.length - 4) && vr.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,
gi.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 && K.Error("XHR " + e.status + " error on: " + t + "."),
K.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 && window.setTimeout((function() {
d._readyToPlayCallback && d._readyToPlayCallback()
}
), 1e3)) : K.Error("Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.")
} catch (e) {
K.Error("Unexpected error. Sound creation aborted."),
this._scene.mainSoundTrack.removeSound(this)
}
} else
this._scene.mainSoundTrack.addSound(this),
vr.audioEngine && !vr.audioEngine.WarnedWebAudioUnsupported && (K.Error("Web Audio is not supported by your browser."),
vr.audioEngine.WarnedWebAudioUnsupported = !0),
this._readyToPlayCallback && window.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;
var t = this._startOffset;
return this.isPlaying && (null === (e = vr.audioEngine) || void 0 === e ? void 0 : e.audioContext) && (t += vr.audioEngine.audioContext.currentTime - this._startTime),
t
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "spatialSound", {
get: function() {
return this._spatialSound
},
set: function(e) {
var t;
this._spatialSound = e,
this._spatialSound && (null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && vr.audioEngine.audioContext && this._createSpatialParameters()
},
enumerable: !1,
configurable: !0
}),
e.prototype.dispose = function() {
var e;
(null === (e = vr.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))
}
,
e.prototype.isReady = function() {
return this._isReadyToPlay
}
,
e.prototype.getClassName = function() {
return "Sound"
}
,
e.prototype._soundLoaded = function(e) {
var t, i = this;
(null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.audioContext) && vr.audioEngine.audioContext.decodeAudioData(e, (function(e) {
i._audioBuffer = e,
i._isReadyToPlay = !0,
i.autoplay && i.play(0, i._offset, i._length),
i._readyToPlayCallback && i._readyToPlayCallback()
}
), (function(e) {
K.Error("Error while decoding audio data for: " + i.name + " / Error: " + e)
}
))
}
,
e.prototype.setAudioBuffer = function(e) {
var t;
(null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && (this._audioBuffer = e,
this._isReadyToPlay = !0)
}
,
e.prototype.updateOptions = function(e) {
var t, i, n, r, o, a, s, l, c, u;
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 !== (n = e.useCustomAttenuation) && void 0 !== n ? n : this.useCustomAttenuation,
this.rolloffFactor = null !== (r = e.rolloffFactor) && void 0 !== r ? r : 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._offset = null !== (c = e.offset) && void 0 !== c ? c : void 0,
this.setVolume(null !== (u = e.volume) && void 0 !== u ? u : 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 = vr.audioEngine) || void 0 === e ? void 0 : e.canUseWebAudio) && vr.audioEngine.audioContext && (this._scene.headphone && (this._panningModel = "HRTF"),
this._soundPanner = null !== (t = this._soundPanner) && void 0 !== t ? t : vr.audioEngine.audioContext.createPanner(),
this._soundPanner && this._outputAudioNode && (this._updateSpatialParameters(),
this._soundPanner.connect(this._outputAudioNode),
this._inputAudioNode = this._soundPanner))
}
,
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))
}
,
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 = vr.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 = vr.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 ? K.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 K.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
this._coneInnerAngle = e,
(null === (t = vr.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 K.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
this._coneOuterAngle = e,
(null === (t = vr.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 = vr.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 = vr.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 = x.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 = vr.audioEngine) || void 0 === e ? void 0 : e.canUseWebAudio) && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
var t = 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 n, r, o, a, s = this;
if (this._isReadyToPlay && this._scene.audioEnabled && (null === (n = vr.audioEngine) || void 0 === n ? void 0 : n.audioContext))
try {
this._startOffset < 0 && (e = -this._startOffset,
this._startOffset = 0);
var l = e ? (null === (r = vr.audioEngine) || void 0 === r ? void 0 : r.audioContext.currentTime) + e : null === (o = vr.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 = vr.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 = vr.audioEngine) || void 0 === e ? void 0 : e.unlocked) {
var i = s._htmlAudioElement.play();
void 0 !== i && i.catch((function() {
var e, t;
null === (e = vr.audioEngine) || void 0 === e || e.lock(),
(s.loop || s.autoplay) && (null === (t = vr.audioEngine) || void 0 === t || t.onAudioUnlockedObservable.addOnce((function() {
c()
}
)))
}
))
} else
(s.loop || s.autoplay) && (null === (t = vr.audioEngine) || void 0 === t || t.onAudioUnlockedObservable.addOnce((function() {
c()
}
)))
};
c()
}
} else {
var u = function() {
var n, r, o;
if (null === (n = vr.audioEngine) || void 0 === n ? void 0 : n.audioContext) {
if (i = i || s._length,
t = t || s._offset,
s._soundSource) {
var a = s._soundSource;
a.onended = function() {
a.disconnect()
}
}
if (s._soundSource = null === (r = vr.audioEngine) || void 0 === r ? void 0 : r.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 = vr.audioEngine) || void 0 === o ? void 0 : o.audioContext.currentTime) + e : vr.audioEngine.audioContext.currentTime;
var c = s.isPaused ? s._startOffset % s._soundSource.buffer.duration : t || 0;
s._soundSource.start(l, c, s.loop ? void 0 : i)
}
}
};
"suspended" === (null === (a = vr.audioEngine) || void 0 === a ? void 0 : a.audioContext.state) ? setTimeout((function() {
var e;
"suspended" === (null === (e = vr.audioEngine) || void 0 === e ? void 0 : e.audioContext.state) ? (vr.audioEngine.lock(),
(s.loop || s.autoplay) && vr.audioEngine.onAudioUnlockedObservable.addOnce((function() {
u()
}
))) : u()
}
), 500) : u()
}
this._startTime = l,
this.isPlaying = !0,
this.isPaused = !1
} catch (e) {
K.Error("Error while trying to play audio: " + this.name + ", " + e.message)
}
}
,
e.prototype._onended = function() {
this.isPlaying = !1,
this._startOffset = 0,
this.onended && this.onended(),
this.onEndedObservable.notifyObservers(this)
}
,
e.prototype.stop = function(e) {
var t, i = this;
if (this.isPlaying)
if (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 = vr.audioEngine) || void 0 === t ? void 0 : t.audioContext) && this._soundSource) {
var n = e ? vr.audioEngine.audioContext.currentTime + e : void 0;
this._soundSource.stop(n),
void 0 === n ? (this.isPlaying = !1,
this._soundSource.onended = function() {}
) : this._soundSource.onended = function() {
i.isPlaying = !1
}
,
this.isPaused || (this._startOffset = 0)
}
}
,
e.prototype.pause = function() {
var e;
this.isPlaying && (this.isPaused = !0,
this._streaming ? (this._htmlAudioElement ? this._htmlAudioElement.pause() : this._streamingSource.disconnect(),
this.isPlaying = !1) : (null === (e = vr.audioEngine) || void 0 === e ? void 0 : e.audioContext) && (this.stop(0),
this._startOffset += vr.audioEngine.audioContext.currentTime - this._startTime))
}
,
e.prototype.setVolume = function(e, t) {
var i;
(null === (i = vr.audioEngine) || void 0 === i ? void 0 : i.canUseWebAudio) && this._soundGain && (t && vr.audioEngine.audioContext ? (this._soundGain.gain.cancelScheduledValues(vr.audioEngine.audioContext.currentTime),
this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, vr.audioEngine.audioContext.currentTime),
this._soundGain.gain.linearRampToValueAtTime(e, vr.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.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 = vr.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 ? (r._audioBuffer = t.getAudioBuffer(),
r._isReadyToPlay = !0,
r.autoplay && r.play(0, t._offset, t._length)) : window.setTimeout(i, 300)
}
, n = {
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
}
, r = new e(this.name + "_cloned",new ArrayBuffer(0),this._scene,null,n);
return this.useCustomAttenuation && r.setAttenuationFunction(this._customAttenuationFunction),
r.setPosition(this._position),
r.setPlaybackRate(this._playbackRate),
i(),
r
}
,
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, n, r) {
var o, a = t.name;
o = t.url ? n + t.url : n + 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 (r) {
var c = function() {
r._isReadyToPlay ? (s._audioBuffer = r.getAudioBuffer(),
s._isReadyToPlay = !0,
s.autoplay && s.play(0, s._offset, s._length)) : window.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 = x.FromArray(t.position);
s.setPosition(u)
}
if (t.isDirectional && (s.setDirectionalCone(t.coneInnerAngle || 360, t.coneOuterAngle || 360, t.coneOuterGain || 0),
t.localDirectionToMesh)) {
var h = x.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._SceneComponentInitialization = function(e) {
throw be("AudioSceneComponent")
}
,
e
}()
, jr = function() {
function e(e, t) {
void 0 === t && (t = {}),
this.id = -1,
this._isInitialized = !1,
(e = e || E.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 = vr.audioEngine) || void 0 === e ? void 0 : e.canUseWebAudio) && vr.audioEngine.audioContext && (this._outputAudioNode = vr.audioEngine.audioContext.createGain(),
this._outputAudioNode.connect(vr.audioEngine.masterGain),
this._options && this._options.volume && (this._outputAudioNode.gain.value = this._options.volume),
this._isInitialized = !0)
}
,
e.prototype.dispose = function() {
if (vr.audioEngine && vr.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 = vr.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 = vr.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._outputAudioNode && (this._outputAudioNode.gain.value = e)
}
,
e.prototype.switchPanningModelToHRTF = function() {
var e;
if (null === (e = vr.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 = vr.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 = vr.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._outputAudioNode && (this._outputAudioNode.disconnect(),
this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, vr.audioEngine.masterGain))
}
,
e
}();
o.AddParser(Wi.NAME_AUDIO, (function(e, t, i, n) {
var r, 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 === (r = vr.audioEngine) || void 0 === r ? void 0 : r.canUseWebAudio) ? (c.url || (c.url = c.name),
a[c.url] ? i.sounds.push(Xr.Parse(c, t, n, a[c.url])) : (o = Xr.Parse(c, t, n),
a[c.url] = o,
i.sounds.push(o))) : i.sounds.push(new Xr(c.name,null,t))
}
a = []
}
)),
Object.defineProperty(mn.prototype, "mainSoundTrack", {
get: function() {
var e = this._getComponent(Wi.NAME_AUDIO);
return e || (e = new Yr(this),
this._addComponent(e)),
this._mainSoundTrack || (this._mainSoundTrack = new jr(this,{
mainTrack: !0
})),
this._mainSoundTrack
},
enumerable: !0,
configurable: !0
}),
mn.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(mn.prototype, "audioEnabled", {
get: function() {
var e = this._getComponent(Wi.NAME_AUDIO);
return e || (e = new Yr(this),
this._addComponent(e)),
e.audioEnabled
},
set: function(e) {
var t = this._getComponent(Wi.NAME_AUDIO);
t || (t = new Yr(this),
this._addComponent(t)),
e ? t.enableAudio() : t.disableAudio()
},
enumerable: !0,
configurable: !0
}),
Object.defineProperty(mn.prototype, "headphone", {
get: function() {
var e = this._getComponent(Wi.NAME_AUDIO);
return e || (e = new Yr(this),
this._addComponent(e)),
e.headphone
},
set: function(e) {
var t = this._getComponent(Wi.NAME_AUDIO);
t || (t = new Yr(this),
this._addComponent(t)),
e ? t.switchAudioModeForHeadphones() : t.switchAudioModeForNormalSpeakers()
},
enumerable: !0,
configurable: !0
}),
Object.defineProperty(mn.prototype, "audioListenerPositionProvider", {
get: function() {
var e = this._getComponent(Wi.NAME_AUDIO);
return e || (e = new Yr(this),
this._addComponent(e)),
e.audioListenerPositionProvider
},
set: function(e) {
var t = this._getComponent(Wi.NAME_AUDIO);
if (t || (t = new Yr(this),
this._addComponent(t)),
"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(mn.prototype, "audioPositioningRefreshRate", {
get: function() {
var e = this._getComponent(Wi.NAME_AUDIO);
return e || (e = new Yr(this),
this._addComponent(e)),
e.audioPositioningRefreshRate
},
set: function(e) {
var t = this._getComponent(Wi.NAME_AUDIO);
t || (t = new Yr(this),
this._addComponent(t)),
t.audioPositioningRefreshRate = e
},
enumerable: !0,
configurable: !0
});
var Yr = function() {
function e(e) {
this.name = Wi.NAME_AUDIO,
this._audioEnabled = !0,
this._headphone = !1,
this.audioPositioningRefreshRate = 500,
this._audioListenerPositionProvider = null,
this._cachedCameraDirection = new x,
this._cachedCameraPosition = new x,
this._lastCheck = 0,
(e = e || E.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
}),
Object.defineProperty(e.prototype, "audioListenerPositionProvider", {
get: function() {
return this._audioListenerPositionProvider
},
set: function(e) {
this._audioListenerPositionProvider = e
},
enumerable: !1,
configurable: !0
}),
e.prototype.register = function() {
this.scene._afterRenderStage.registerStep(Wi.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], n = 0; n < i.soundCollection.length; n++)
e.sounds.push(i.soundCollection[n].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,
vr.audioEngine && vr.audioEngine.audioContext && vr.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,
vr.audioEngine && vr.audioEngine.audioContext && vr.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 = ct.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 n = vr.audioEngine;
if (n && n.audioContext) {
if (this._audioListenerPositionProvider) {
var r = this._audioListenerPositionProvider();
r.x = r.x || 0,
r.y = r.y || 0,
r.z = r.z || 0,
n.audioContext.listener.setPosition(r.x, r.y, r.z)
} else {
var o = void 0;
if (o = i.activeCameras && i.activeCameras.length > 0 ? i.activeCameras[0] : i.activeCamera) {
this._cachedCameraPosition.equals(o.globalPosition) || (this._cachedCameraPosition.copyFrom(o.globalPosition),
n.audioContext.listener.setPosition(o.globalPosition.x, o.globalPosition.y, o.globalPosition.z)),
o.rigCameras && o.rigCameras.length > 0 && (o = o.rigCameras[0]);
var a = P.Invert(o.getViewMatrix())
, s = x.TransformNormal(e._CameraDirection, a);
s.normalize(),
isNaN(s.x) || isNaN(s.y) || isNaN(s.z) || this._cachedCameraDirection.equals(s) || (this._cachedCameraDirection.copyFrom(s),
n.audioContext.listener.setOrientation(s.x, s.y, s.z, 0, 1, 0))
} else
n.audioContext.listener.setPosition(0, 0, 0)
}
var l = void 0;
for (l = 0; l < i.mainSoundTrack.soundCollection.length; l++)
(u = i.mainSoundTrack.soundCollection[l]).useCustomAttenuation && u.updateDistanceFromListener();
if (i.soundTracks)
for (l = 0; l < i.soundTracks.length; l++)
for (var c = 0; c < i.soundTracks[l].soundCollection.length; c++) {
var u;
(u = i.soundTracks[l].soundCollection[c]).useCustomAttenuation && u.updateDistanceFromListener()
}
}
}
}
}
,
e._CameraDirection = new x(0,0,-1),
e
}();
Xr._SceneComponentInitialization = function(e) {
var t = e._getComponent(Wi.NAME_AUDIO);
t || (t = new Yr(e),
e._addComponent(t))
}
;
var Kr = function() {
function e(e, t, i) {
var n = 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 r = 0, o = 0, a = i; o < a.length; o++)
r += a[o];
for (var s = r > 0 ? 1 / r : 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() {
n._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 K.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 K.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, n = 0; n < this._weights.length; n++)
if (t <= (i += this._weights[n])) {
this._currentIndex = n;
break
}
}
var r = this._sounds[this._currentIndex];
r.isReady() ? r.play(0, this.isPaused ? void 0 : e) : r.autoplay = !0,
this.isPlaying = !0,
this.isPaused = !1
}
,
e
}()
, Qr = function() {
function e(e) {
this._texture = null,
this._isEnabled = !0,
this.isEnabled = !0,
this.time = 0,
(e = e || E.LastCreatedScene) && (this._scene = e,
this.animationParameters = new R(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, n) {
void 0 === i && (i = 0),
void 0 === n && (n = 30),
this.animationParameters = new R(e,t,i,n)
}
,
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) {
Ge.Clone((function() {
return e
}
), this)
}
,
e.prototype.serialize = function() {
return Ge.Serialize(this)
}
,
e.prototype.parse = function(e, t, i) {
var n = this;
Ge.Parse((function() {
return n
}
), e, t, i)
}
,
k([Pe(), Re("_markSubMeshesAsAttributesDirty")], e.prototype, "texture", void 0),
k([Ce(), Re("_markSubMeshesAsAttributesDirty")], e.prototype, "isEnabled", void 0),
k([Ce()], e.prototype, "animationParameters", void 0),
k([Ce()], e.prototype, "time", void 0),
e
}()
, qr = function() {
function e(e) {
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 = je.Zero(),
this._cachedBaseSize = je.Zero(),
this._initialSamplingMode = a.TEXTURE_BILINEAR_SAMPLINGMODE,
this._texture = e,
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.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
}()
, Zr = function(e) {
function t(i) {
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._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 h,
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 = E.LastCreatedScene,
n._scene && (n.uniqueId = n._scene.getUniqueId(),
n._scene.addTexture(n),
n._engine = n._scene.getEngine()),
n._uid = null,
n
}
return U(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 = fi()),
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 P.IdentityReadOnly
}
,
t.prototype.getReflectionTextureMatrix = function() {
return P.IdentityReadOnly
}
,
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, n, r) {
var o = this._getEngine();
if (!o)
return null;
for (var a = o._getUseSRGBBuffer(!!r, t), s = o.getLoadedTexturesCache(), l = 0; l < s.length; l++) {
var c = s[l];
if ((void 0 === r || a === c._useSRGBBuffer) && !(void 0 !== n && n !== c.invertY || c.url !== e || c.generateMipMaps !== !t || i && i !== c.samplingMode))
return c.incrementReferences(),
c
}
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, n, r) {
if (void 0 === e && (e = 0),
void 0 === t && (t = 0),
void 0 === i && (i = null),
void 0 === n && (n = !0),
void 0 === r && (r = !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._readTexturePixels(this._texture, a, s, e, t, i, n, r) : l._readTexturePixels(this._texture, a, s, -1, t, i, n, r)
} catch (e) {
return null
}
}
,
t.prototype._readPixelsSync = function(e, t, i, n, r) {
if (void 0 === e && (e = 0),
void 0 === t && (t = 0),
void 0 === i && (i = null),
void 0 === n && (n = !0),
void 0 === r && (r = !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, n, r) : l._readTexturePixelsSync(this._texture, a, s, -1, t, i, n, r)
} 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() {
if (!this.name)
return null;
var e = Ge.Serialize(this);
return Ge.AppendSerializedAnimations(this, e),
e
}
,
t.WhenAllReady = function(e, t) {
var i = e.length;
if (0 !== i)
for (var n = 0; n < e.length; n++) {
var r = e[n];
if (r.isReady())
0 == --i && t();
else {
var o = r.onLoadObservable;
o && o.addOnce((function() {
0 == --i && t()
}
))
}
}
else
t()
}
,
t._IsScene = function(e) {
return "Scene" === e.getClassName()
}
,
t.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4,
k([Ce()], t.prototype, "uniqueId", void 0),
k([Ce()], t.prototype, "name", void 0),
k([Ce()], t.prototype, "metadata", void 0),
k([Ce("hasAlpha")], t.prototype, "_hasAlpha", void 0),
k([Ce("getAlphaFromRGB")], t.prototype, "_getAlphaFromRGB", void 0),
k([Ce()], t.prototype, "level", void 0),
k([Ce("coordinatesIndex")], t.prototype, "_coordinatesIndex", void 0),
k([Ce("coordinatesMode")], t.prototype, "_coordinatesMode", void 0),
k([Ce()], t.prototype, "wrapU", null),
k([Ce()], t.prototype, "wrapV", null),
k([Ce()], t.prototype, "wrapR", void 0),
k([Ce()], t.prototype, "anisotropicFilteringLevel", void 0),
k([Ce()], t.prototype, "isCube", null),
k([Ce()], t.prototype, "is3D", null),
k([Ce()], t.prototype, "is2DArray", null),
k([Ce()], t.prototype, "gammaSpace", null),
k([Ce()], t.prototype, "invertZ", void 0),
k([Ce()], t.prototype, "lodLevelInAlpha", void 0),
k([Ce()], t.prototype, "lodGenerationOffset", null),
k([Ce()], t.prototype, "lodGenerationScale", null),
k([Ce()], t.prototype, "linearSpecularLOD", null),
k([Pe()], t.prototype, "irradianceTexture", null),
k([Ce()], t.prototype, "isRenderTarget", void 0),
t
}(qr);
function Jr(e, t, i) {
void 0 === i && (i = !1);
var n = t.width
, r = 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 = n,
l.height = r;
var c = l.getContext("2d");
if (!c)
return null;
var u = c.createImageData(n, r);
if (u.data.set(e),
c.putImageData(u, 0, 0),
i) {
var h = document.createElement("canvas");
h.width = n,
h.height = r;
var d = h.getContext("2d");
return d ? (d.translate(0, r),
d.scale(1, -1),
d.drawImage(l, 0, 0),
h.toDataURL("image/png")) : null
}
return l.toDataURL("image/png")
}
function $r(e, t, i) {
void 0 === t && (t = 0),
void 0 === i && (i = 0);
var n = e.getInternalTexture();
if (!n)
return null;
var r = e._readPixelsSync(t, i);
return r ? Jr(r, e.getSize(), n.invertY) : null
}
function eo(e, t, i) {
return void 0 === t && (t = 0),
void 0 === i && (i = 0),
G(this, void 0, void 0, (function() {
var n, r;
return z(this, (function(o) {
switch (o.label) {
case 0:
return (n = e.getInternalTexture()) ? [4, e.readPixels(t, i)] : [2, null];
case 1:
return (r = o.sent()) ? [2, Jr(r, e.getSize(), n.invertY)] : [2, null]
}
}
))
}
))
}
var to = {
GenerateBase64StringFromPixelData: Jr,
GenerateBase64StringFromTexture: $r,
GenerateBase64StringFromTextureAsync: eo
}
, io = function(e) {
function t(i, n, r, o, s, l, c, u, d, p, f, _, m) {
void 0 === s && (s = t.TRILINEAR_SAMPLINGMODE),
void 0 === l && (l = null),
void 0 === c && (c = null),
void 0 === u && (u = null),
void 0 === d && (d = !1);
var g, v, y, b, T, E, S, A, x, R = this;
(R = e.call(this, n) || this).url = null,
R.uOffset = 0,
R.vOffset = 0,
R.uScale = 1,
R.vScale = 1,
R.uAng = 0,
R.vAng = 0,
R.wAng = 0,
R.uRotationCenter = .5,
R.vRotationCenter = .5,
R.wRotationCenter = .5,
R.homogeneousRotationInUVTransform = !1,
R.inspectableCustomProperties = null,
R._noMipmap = !1,
R._invertY = !1,
R._rowGenerationMatrix = null,
R._cachedTextureMatrix = null,
R._projectionModeMatrix = null,
R._t0 = null,
R._t1 = null,
R._t2 = null,
R._cachedUOffset = -1,
R._cachedVOffset = -1,
R._cachedUScale = 0,
R._cachedVScale = 0,
R._cachedUAng = -1,
R._cachedVAng = -1,
R._cachedWAng = -1,
R._cachedProjectionMatrixId = -1,
R._cachedURotationCenter = -1,
R._cachedVRotationCenter = -1,
R._cachedWRotationCenter = -1,
R._cachedHomogeneousRotationInUVTransform = !1,
R._cachedCoordinatesMode = -1,
R._buffer = null,
R._deleteBuffer = !1,
R._format = null,
R._delayedOnLoad = null,
R._delayedOnError = null,
R.onLoadObservable = new h,
R._isBlocking = !0,
R.name = i || "",
R.url = i;
var C = !1;
"object" == typeof r && null !== r ? (x = null !== (g = r.noMipmap) && void 0 !== g && g,
o = null !== (v = r.invertY) && void 0 !== v ? v : !pr.UseOpenGLOrientationForUV,
s = null !== (y = r.samplingMode) && void 0 !== y ? y : t.TRILINEAR_SAMPLINGMODE,
l = null !== (b = r.onLoad) && void 0 !== b ? b : null,
c = null !== (T = r.onError) && void 0 !== T ? T : null,
u = null !== (E = r.buffer) && void 0 !== E ? E : null,
d = null !== (S = r.deleteBuffer) && void 0 !== S && S,
p = r.format,
f = r.mimeType,
_ = r.loaderOptions,
m = r.creationFlags,
C = null !== (A = r.useSRGBBuffer) && void 0 !== A && A) : x = !!r,
R._noMipmap = x,
R._invertY = void 0 === o ? !pr.UseOpenGLOrientationForUV : o,
R._initialSamplingMode = s,
R._buffer = u,
R._deleteBuffer = d,
R._mimeType = f,
R._loaderOptions = _,
R._creationFlags = m,
R._useSRGBBuffer = C,
p && (R._format = p);
var P = R.getScene()
, M = R._getEngine();
if (!M)
return R;
M.onBeforeTextureInitObservable.notifyObservers(R);
var I = function() {
R._texture && (R._texture._invertVScale && (R.vScale *= -1,
R.vOffset += 1),
null !== R._texture._cachedWrapU && (R.wrapU = R._texture._cachedWrapU,
R._texture._cachedWrapU = null),
null !== R._texture._cachedWrapV && (R.wrapV = R._texture._cachedWrapV,
R._texture._cachedWrapV = null),
null !== R._texture._cachedWrapR && (R.wrapR = R._texture._cachedWrapR,
R._texture._cachedWrapR = null)),
R.onLoadObservable.hasObservers() && R.onLoadObservable.notifyObservers(R),
l && l(),
!R.isBlocking && P && P.resetCachedMaterial()
}
, O = function(e, i) {
R._loadingError = !0,
R._errorObject = {
message: e,
exception: i
},
c && c(e, i),
t.OnTextureLoadErrorObservable.notifyObservers(R)
};
if (!R.url)
return R._delayedOnLoad = I,
R._delayedOnError = O,
R;
if (R._texture = R._getFromCache(R.url, x, s, R._invertY, C),
R._texture)
if (R._texture.isReady)
Xt.SetImmediate((function() {
return I()
}
));
else {
var D = R._texture.onLoadedObservable.add(I);
R._texture.onErrorObservable.add((function(e) {
var t;
O(e.message, e.exception),
null === (t = R._texture) || void 0 === t || t.onLoadedObservable.remove(D)
}
))
}
else if (P && P.useDelayedTextureLoading)
R.delayLoadState = a.DELAYLOADSTATE_NOTLOADED,
R._delayedOnLoad = I,
R._delayedOnError = O;
else {
try {
R._texture = M.createTexture(R.url, x, R._invertY, P, s, I, O, R._buffer, void 0, R._format, null, f, _, m, C)
} catch (e) {
throw O("error loading", e),
e
}
d && (R._buffer = null)
}
return R
}
return U(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) {
void 0 === t && (t = null),
this.url && (this.releaseInternalTexture(),
this.getScene().markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)),
this.name && !ae(this.name, "data:") || (this.name = e),
this.url = e,
this._buffer = t,
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 ? Xt.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, null, 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, n) {
e *= this._cachedUScale,
t *= this._cachedVScale,
e -= this.uRotationCenter * this._cachedUScale,
t -= this.vRotationCenter * this._cachedVScale,
i -= this.wRotationCenter,
x.TransformCoordinatesFromFloatsToRef(e, t, i, this._rowGenerationMatrix, n),
n.x += this.uRotationCenter * this._cachedUScale + this._cachedUOffset,
n.y += this.vRotationCenter * this._cachedVScale + this._cachedVOffset,
n.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 = P.Zero(),
this._rowGenerationMatrix = new P,
this._t0 = x.Zero(),
this._t1 = x.Zero(),
this._t2 = x.Zero()),
P.RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix),
this.homogeneousRotationInUVTransform ? (P.TranslationToRef(-this._cachedURotationCenter, -this._cachedVRotationCenter, -this._cachedWRotationCenter, I.Matrix[0]),
P.TranslationToRef(this._cachedURotationCenter, this._cachedVRotationCenter, this._cachedWRotationCenter, I.Matrix[1]),
P.ScalingToRef(this._cachedUScale, this._cachedVScale, 0, I.Matrix[2]),
P.TranslationToRef(this._cachedUOffset, this._cachedVOffset, 0, I.Matrix[3]),
I.Matrix[0].multiplyToRef(this._rowGenerationMatrix, this._cachedTextureMatrix),
this._cachedTextureMatrix.multiplyToRef(I.Matrix[1], this._cachedTextureMatrix),
this._cachedTextureMatrix.multiplyToRef(I.Matrix[2], this._cachedTextureMatrix),
this._cachedTextureMatrix.multiplyToRef(I.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),
P.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 ? (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._cachedTextureMatrix;
if (this.uOffset === this._cachedUOffset && this.vOffset === this._cachedVOffset && this.uScale === this._cachedUScale && this.vScale === this._cachedVScale && this.coordinatesMode === this._cachedCoordinatesMode) {
if (this.coordinatesMode !== t.PROJECTION_MODE)
return this._cachedTextureMatrix;
if (this._cachedProjectionMatrixId === i.getProjectionMatrix().updateFlag)
return this._cachedTextureMatrix
}
this._cachedTextureMatrix || (this._cachedTextureMatrix = P.Zero()),
this._projectionModeMatrix || (this._projectionModeMatrix = P.Zero());
var n = this._cachedCoordinatesMode !== this.coordinatesMode;
switch (this._cachedUOffset = this.uOffset,
this._cachedVOffset = this.vOffset,
this._cachedUScale = this.uScale,
this._cachedVScale = this.vScale,
this._cachedCoordinatesMode = this.coordinatesMode,
this.coordinatesMode) {
case t.PLANAR_MODE:
P.IdentityToRef(this._cachedTextureMatrix),
this._cachedTextureMatrix[0] = this.uScale,
this._cachedTextureMatrix[5] = this.vScale,
this._cachedTextureMatrix[12] = this.uOffset,
this._cachedTextureMatrix[13] = this.vOffset;
break;
case t.PROJECTION_MODE:
P.FromValuesToRef(.5, 0, 0, 0, 0, -.5, 0, 0, 0, 0, 0, 0, .5, .5, 1, 1, this._projectionModeMatrix);
var r = i.getProjectionMatrix();
this._cachedProjectionMatrixId = r.updateFlag,
r.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
break;
default:
P.IdentityToRef(this._cachedTextureMatrix)
}
return n && i.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(t) {
return -1 !== t.getActiveTextures().indexOf(e)
}
)),
this._cachedTextureMatrix
}
,
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 Ge.Clone((function() {
return new t(e._texture ? e._texture.url : null,e.getScene(),i)
}
), this)
}
,
t.prototype.serialize = function() {
var i = this.name;
t.SerializeBuffers || ae(this.name, "data:") && (this.name = ""),
ae(this.name, "data:") && this.url === this.name && (this.url = "");
var n = e.prototype.serialize.call(this);
return n ? ((t.SerializeBuffers || t.ForceSerializeBuffers) && ("string" == typeof this._buffer && "data:" === this._buffer.substr(0, 5) ? (n.base64String = this._buffer,
n.name = n.name.replace("data:", "")) : this.url && ae(this.url, "data:") && this._buffer instanceof Uint8Array ? n.base64String = "data:image/png;base64," + le(this._buffer) : (t.ForceSerializeBuffers || this.url && ae(this.url, "blob:") || this._forceSerialize) && (n.base64String = !this._engine || this._engine._features.supportSyncTextureRead ? $r(this) : eo(this))),
n.invertY = this._invertY,
n.samplingMode = this.samplingMode,
n._creationFlags = this._creationFlags,
n._useSRGBBuffer = this._useSRGBBuffer,
this.name = i,
n) : 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
}
,
t.Parse = function(e, i, n) {
if (e.customType) {
var r = pi.Instantiate(e.customType).Parse(e, i, n);
return e.samplingMode && r.updateSamplingMode && r._samplingMode && r._samplingMode !== e.samplingMode && r.updateSamplingMode(e.samplingMode),
r
}
if (e.isCube && !e.isRenderTarget)
return t._CubeTextureParser(e, i, n);
if (!e.name && !e.isRenderTarget)
return null;
var o = function() {
if (a && a._texture && (a._texture._cachedWrapU = null,
a._texture._cachedWrapV = null,
a._texture._cachedWrapR = null),
e.samplingMode) {
var t = e.samplingMode;
a && a.samplingMode !== t && a.updateSamplingMode(t)
}
if (a && e.animations)
for (var i = 0; i < e.animations.length; i++) {
var n = e.animations[i]
, r = b("BABYLON.Animation");
r && a.animations.push(r.Parse(n))
}
}
, a = Ge.Parse((function() {
var r, a, s, l, c = !0;
if (e.noMipmap && (c = !1),
e.mirrorPlane) {
var u = t._CreateMirror(e.name, e.renderTargetSize, i, c);
return u._waitingRenderList = e.renderList,
u.mirrorPlane = hn.FromArray(e.mirrorPlane),
o(),
u
}
if (e.isRenderTarget) {
var h = null;
if (e.isCube) {
if (i.reflectionProbes)
for (var d = 0; d < i.reflectionProbes.length; d++) {
var p = i.reflectionProbes[d];
if (p.name === e.name)
return p.cubeTexture
}
} else
(h = t._CreateRenderTargetTexture(e.name, e.renderTargetSize, i, c, null !== (r = e._creationFlags) && void 0 !== r ? r : 0))._waitingRenderList = e.renderList;
return o(),
h
}
if (e.base64String)
l = t.CreateFromBase64String(e.base64String, e.name, i, !c, e.invertY, e.samplingMode, o, null !== (a = e._creationFlags) && void 0 !== a ? a : 0, null !== (s = e._useSRGBBuffer) && void 0 !== s && s);
else {
var f = void 0;
f = e.name && e.name.indexOf("://") > 0 ? e.name : n + e.name,
(ae(e.url, "data:") || t.UseSerializedUrlIfAny && e.url) && (f = e.url),
l = new t(f,i,!c,e.invertY,e.samplingMode,o)
}
return l
}
), e, i);
return a
}
,
t.CreateFromBase64String = function(e, i, n, r, 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,n,r,o,s,l,c,e,!1,u,void 0,void 0,h)
}
,
t.LoadFromDataString = function(e, i, n, r, o, s, l, c, u, h, d) {
return void 0 === r && (r = !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,n,o,s,l,c,u,i,r,h,void 0,void 0,d)
}
,
t.SerializeBuffers = !0,
t.ForceSerializeBuffers = !1,
t.OnTextureLoadErrorObservable = new h,
t._CubeTextureParser = function(e, t, i) {
throw be("CubeTexture")
}
,
t._CreateMirror = function(e, t, i, n) {
throw be("MirrorTexture")
}
,
t._CreateRenderTargetTexture = function(e, t, i, n, r) {
throw be("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,
k([Ce()], t.prototype, "url", void 0),
k([Ce()], t.prototype, "uOffset", void 0),
k([Ce()], t.prototype, "vOffset", void 0),
k([Ce()], t.prototype, "uScale", void 0),
k([Ce()], t.prototype, "vScale", void 0),
k([Ce()], t.prototype, "uAng", void 0),
k([Ce()], t.prototype, "vAng", void 0),
k([Ce()], t.prototype, "wAng", void 0),
k([Ce()], t.prototype, "uRotationCenter", void 0),
k([Ce()], t.prototype, "vRotationCenter", void 0),
k([Ce()], t.prototype, "wRotationCenter", void 0),
k([Ce()], t.prototype, "homogeneousRotationInUVTransform", void 0),
k([Ce()], t.prototype, "isBlocking", null),
t
}(Zr);
function no(e, t, i, n) {
var r, o = 1;
n === a.TEXTURETYPE_FLOAT ? r = new Float32Array(t * i * 4) : n === a.TEXTURETYPE_HALF_FLOAT ? (r = new Uint16Array(t * i * 4),
o = 15360) : r = n === 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);
r[u + 0] = e[c + 0],
r[u + 1] = e[c + 1],
r[u + 2] = e[c + 2],
r[u + 3] = o
}
return r
}
function ro(e) {
return function(t, i, n, r, 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 ? At.Raw3D : At.Raw2DArray
, f = new Lt(this,p);
f.baseWidth = i,
f.baseHeight = n,
f.baseDepth = r,
f.width = i,
f.height = n,
f.depth = r,
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 oo(e) {
return function(t, i, n, r, 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(n)
, h = this._getRGBABufferInternalSizedFormat(s, n);
this._bindTextureDirectly(l, t, !0),
this._unpackFlipY(void 0 === r || !!r),
this._doNotHandleContextLost || (t._bufferView = i,
t.format = n,
t.invertY = r,
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
}
}
y("BABYLON.Texture", io),
Ge._TextureParser = io.Parse,
Ht.prototype.updateRawTexture = function(e, t, i, n, r, o) {
if (void 0 === r && (r = null),
void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT),
e) {
var s = this._getRGBABufferInternalSizedFormat(o, i)
, l = this._getInternalFormat(i)
, c = this._getWebGLTextureType(o);
this._bindTextureDirectly(this._gl.TEXTURE_2D, e, !0),
this._unpackFlipY(void 0 === n || !!n),
this._doNotHandleContextLost || (e._bufferView = t,
e.format = i,
e.type = o,
e.invertY = n,
e._compression = r),
e.width % 4 != 0 && this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1),
r && t ? this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[r], e.width, e.height, 0, t) : this._gl.texImage2D(this._gl.TEXTURE_2D, 0, s, e.width, e.height, 0, l, c, t),
e.generateMipMaps && this._gl.generateMipmap(this._gl.TEXTURE_2D),
this._bindTextureDirectly(this._gl.TEXTURE_2D, null),
e.isReady = !0
}
}
,
Ht.prototype.createRawTexture = function(e, t, i, n, r, o, s, l, c, u) {
void 0 === l && (l = null),
void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT),
void 0 === u && (u = 0);
var h = new Lt(this,At.Raw);
h.baseWidth = t,
h.baseHeight = i,
h.width = t,
h.height = i,
h.format = n,
h.generateMipMaps = r,
h.samplingMode = s,
h.invertY = o,
h._compression = l,
h.type = c,
this._doNotHandleContextLost || (h._bufferView = e),
this.updateRawTexture(h, e, n, o, l, c),
this._bindTextureDirectly(this._gl.TEXTURE_2D, h, !0);
var d = this._getSamplingParameters(s, r);
return this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, d.mag),
this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, d.min),
r && this._gl.generateMipmap(this._gl.TEXTURE_2D),
this._bindTextureDirectly(this._gl.TEXTURE_2D, null),
this._internalTexturesCache.push(h),
h
}
,
Ht.prototype.createRawCubeTexture = function(e, t, i, n, r, o, s, l) {
void 0 === l && (l = null);
var c = this._gl
, u = new Lt(this,At.CubeRaw);
u.isCube = !0,
u.format = i,
u.type = n,
this._doNotHandleContextLost || (u._bufferViewArray = e);
var h = this._getWebGLTextureType(n)
, 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 || (r = !1,
K.Warn("Render to half float textures is not supported. Mipmap generation forced to false.")) : (r = !1,
K.Warn("Render to float textures is not supported. Mipmap generation forced to false.")) : (r = !1,
s = a.TEXTURE_NEAREST_SAMPLINGMODE,
K.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")) : (r = !1,
s = a.TEXTURE_NEAREST_SAMPLINGMODE,
K.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;
u.width = p,
u.height = f,
!this.needPOTTextures || gi.IsExponentOfTwo(u.width) && gi.IsExponentOfTwo(u.height) || (r = !1),
e && this.updateRawCubeTexture(u, e, i, n, o, l),
this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, u, !0),
e && r && this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
var _ = this._getSamplingParameters(s, r);
return c.texParameteri(c.TEXTURE_CUBE_MAP, c.TEXTURE_MAG_FILTER, _.mag),
c.texParameteri(c.TEXTURE_CUBE_MAP, c.TEXTURE_MIN_FILTER, _.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 = r,
u.samplingMode = s,
u
}
,
Ht.prototype.updateRawCubeTexture = function(e, t, i, n, r, o, a) {
void 0 === o && (o = null),
void 0 === a && (a = 0),
e._bufferViewArray = t,
e.format = i,
e.type = n,
e.invertY = r,
e._compression = o;
var s = this._gl
, l = this._getWebGLTextureType(n)
, c = this._getInternalFormat(i)
, u = this._getRGBABufferInternalSizedFormat(n)
, h = !1;
c === s.RGB && (c = s.RGBA,
h = !0),
this._bindTextureDirectly(s.TEXTURE_CUBE_MAP, e, !0),
this._unpackFlipY(void 0 === r || !!r),
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 = no(p, e.width, e.height, n)),
s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X + d, a, u, e.width, e.height, 0, c, l, p))
}
(!this.needPOTTextures || gi.IsExponentOfTwo(e.width) && gi.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
}
,
Ht.prototype.createRawCubeTextureFromUrl = function(e, t, i, n, r, 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, n, r, !o, d, h, null);
return null == t || t._addPendingData(_),
_.url = e,
this._internalTexturesCache.push(_),
this._loadFile(e, (function(e) {
!function(e) {
var i = _.width
, o = s(e);
if (o) {
if (l) {
var a = p._getWebGLTextureType(r)
, u = p._getInternalFormat(n)
, h = p._getRGBABufferInternalSizedFormat(r)
, 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 = no(T, y, y, r)),
f.texImage2D(b, v, h, y, y, 0, u, a, T)
}
p._bindTextureDirectly(f.TEXTURE_CUBE_MAP, null)
} else
p.updateRawCubeTexture(_, o, n, r, d);
_.isReady = !0,
null == t || t._removePendingData(_),
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)
}
)),
_
}
,
Ht.prototype.createRawTexture2DArray = ro(!1),
Ht.prototype.createRawTexture3D = ro(!0),
Ht.prototype.updateRawTexture2DArray = oo(!1),
Ht.prototype.updateRawTexture3D = oo(!0);
var ao = function(e) {
function t(t, i, n, r, o, s, l, c, u, h) {
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 d = 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 d.format = r,
d._engine ? (d._engine._caps.textureFloatLinearFiltering || u !== a.TEXTURETYPE_FLOAT || (c = a.TEXTURE_NEAREST_SAMPLINGMODE),
d._engine._caps.textureHalfFloatLinearFiltering || u !== a.TEXTURETYPE_HALF_FLOAT || (c = a.TEXTURE_NEAREST_SAMPLINGMODE),
d._texture = d._engine.createRawTexture(t, i, n, r, s, l, c, null, u, null != h ? h : 0),
d.wrapU = io.CLAMP_ADDRESSMODE,
d.wrapV = io.CLAMP_ADDRESSMODE,
d) : d
}
return U(t, e),
t.prototype.update = function(e) {
this._getEngine().updateRawTexture(this._texture, e, this._texture.format, this._texture.invertY, null, this._texture.type)
}
,
t.CreateLuminanceTexture = function(e, i, n, r, 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,n,a.TEXTUREFORMAT_LUMINANCE,r,o,s,l)
}
,
t.CreateLuminanceAlphaTexture = function(e, i, n, r, 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,n,a.TEXTUREFORMAT_LUMINANCE_ALPHA,r,o,s,l)
}
,
t.CreateAlphaTexture = function(e, i, n, r, 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,n,a.TEXTUREFORMAT_ALPHA,r,o,s,l)
}
,
t.CreateRGBTexture = function(e, i, n, r, o, s, l, c) {
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),
new t(e,i,n,a.TEXTUREFORMAT_RGB,r,o,s,l,c)
}
,
t.CreateRGBATexture = function(e, i, n, r, o, s, l, c) {
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),
new t(e,i,n,a.TEXTUREFORMAT_RGBA,r,o,s,l,c)
}
,
t.CreateRGBAStorageTexture = function(e, i, n, r, o, s, l, c) {
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),
new t(e,i,n,a.TEXTUREFORMAT_RGBA,r,o,s,l,c,a.TEXTURE_CREATIONFLAG_STORAGE)
}
,
t.CreateRTexture = function(e, i, n, r, o, s, l, c) {
return void 0 === o && (o = !0),
void 0 === s && (s = !1),
void 0 === l && (l = io.TRILINEAR_SAMPLINGMODE),
void 0 === c && (c = a.TEXTURETYPE_FLOAT),
new t(e,i,n,a.TEXTUREFORMAT_R,r,o,s,l,c)
}
,
t.CreateRStorageTexture = function(e, i, n, r, o, s, l, c) {
return void 0 === o && (o = !0),
void 0 === s && (s = !1),
void 0 === l && (l = io.TRILINEAR_SAMPLINGMODE),
void 0 === c && (c = a.TEXTURETYPE_FLOAT),
new t(e,i,n,a.TEXTUREFORMAT_R,r,o,s,l,c,a.TEXTURE_CREATIONFLAG_STORAGE)
}
,
t
}(io)
, so = function() {
function e(e, t) {
this._scene = e,
this._mesh = t
}
return e.prototype.bakeVertexData = function(e) {
return G(this, void 0, void 0, (function() {
var t, i, n, r, o, a, s, l;
return z(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.");
n = 0,
r = 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(r, l, n++)] : [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, r]
}
}
))
}
))
}
,
e.prototype._executeAnimationFrame = function(e, t, i) {
return G(this, void 0, void 0, (function() {
var n = this;
return z(this, (function(r) {
return [2, new Promise((function(r, o) {
n._scene.beginAnimation(n._mesh.skeleton, t, t, !1, 1, (function() {
var t = n._mesh.skeleton.getTransformMatrices(n._mesh);
e.set(t, i * t.length),
r()
}
))
}
))]
}
))
}
))
}
,
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 = ao.CreateRGBATexture(e, 4 * (t + 1), e.length / (4 * (t + 1) * 4), this._scene, !1, !1, io.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)
, n = e.length / (4 * (t + 1) * 4);
return {
vertexData: le(e),
width: i,
height: n
}
}
,
e.prototype.loadBakedVertexDataFromObject = function(e) {
return new Float32Array(ue(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
}()
, lo = function() {
function e() {
this._zoomStopsAnimation = !1,
this._idleRotationSpeed = .05,
this._idleRotationWaitTime = 2e3,
this._idleRotationSpinupTime = 2e3,
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 !== Xi.POINTERDOWN ? e.type === Xi.POINTERUP && (t._isPointerDown = !1) : t._isPointerDown = !0
}
)),
this._onAfterCheckInputsObserver = e.onAfterCheckInputsObservable.add((function() {
var e = ct.Now
, i = 0;
null != t._lastFrameTime && (i = e - t._lastFrameTime),
t._lastFrameTime = e,
t._applyUserInteraction();
var n = e - t._lastInteractionTime - t._idleRotationWaitTime
, r = Math.max(Math.min(n / t._idleRotationSpinupTime, 1), 0);
t._cameraRotationSpeed = t._idleRotationSpeed * r,
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 : ct.Now
}
,
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 = ct.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
}()
, co = 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 = Qe.CreateAnimation("radius", Qe.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 n = Qe.TransitionTo("radius", this._attachedCamera.radius + t, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusBounceTransition, this.transitionDuration, (function() {
return i._clearAnimationLocks()
}
));
n && this._animatables.push(n)
}
}
,
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 On(.3),
e.EasingMode = Mn.EASINGMODE_EASEOUT,
e
}()
, uo = function() {
function e() {
this.onTargetFramingAnimationEndObservable = new h,
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 n = this._attachedCamera.getScene();
e.EasingFunction.setEasingMode(e.EasingMode),
this._onPrePointerObservableObserver = n.onPrePointerObservable.add((function(e) {
e.type !== Xi.POINTERDOWN ? e.type === Xi.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 n = e.getBoundingInfo().boundingBox;
this.zoomOnBoundingInfo(n.minimumWorld, n.maximumWorld, t, i)
}
,
e.prototype.zoomOnMeshHierarchy = function(e, t, i) {
void 0 === t && (t = !1),
void 0 === i && (i = null),
e.computeWorldMatrix(!0);
var n = e.getHierarchyBoundingVectors(!0);
this.zoomOnBoundingInfo(n.min, n.max, t, i)
}
,
e.prototype.zoomOnMeshesHierarchy = function(e, t, i) {
void 0 === t && (t = !1),
void 0 === i && (i = null);
for (var n = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE), r = new x(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE), o = 0; o < e.length; o++) {
var a = e[o].getHierarchyBoundingVectors(!0);
x.CheckExtends(a.min, n, r),
x.CheckExtends(a.max, n, r)
}
this.zoomOnBoundingInfo(n, r, t, i)
}
,
e.prototype.zoomOnBoundingInfo = function(t, i, n, r) {
var o, a = this;
if (void 0 === n && (n = !1),
void 0 === r && (r = null),
this._attachedCamera) {
var s = t.y
, l = s + (i.y - s) * this._positionScale
, c = i.subtract(t).scale(.5);
if (n)
o = new x(0,l,0);
else {
var u = t.add(c);
o = new x(u.x,l,u.z)
}
this._vectorTransition || (this._vectorTransition = Qe.CreateAnimation("target", Qe.ANIMATIONTYPE_VECTOR3, 60, e.EasingFunction)),
this._betaIsAnimating = !0;
var h = Qe.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
}
this._radiusTransition || (this._radiusTransition = Qe.CreateAnimation("radius", Qe.ANIMATIONTYPE_FLOAT, 60, e.EasingFunction)),
(h = Qe.TransitionTo("radius", d, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, (function() {
a.stopAllAnimations(),
r && r(),
a._attachedCamera && a._attachedCamera.useInputToRestoreState && a._attachedCamera.storeState()
}
))) && this._animatables.push(h)
}
}
,
e.prototype._calculateLowerRadiusFromModelBoundingSphere = function(t, i) {
var n = i.subtract(t).length()
, r = this._getFrustumSlope()
, o = .5 * n * this._radiusScale
, a = o * Math.sqrt(1 + 1 / (r.x * r.x))
, s = o * Math.sqrt(1 + 1 / (r.y * r.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 = ct.Now - this._lastInteractionTime
, n = .5 * Math.PI - this._defaultElevation
, r = .5 * Math.PI;
if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > r && i >= this._elevationReturnWaitTime) {
this._betaIsAnimating = !0,
this.stopAllAnimations(),
this._betaTransition || (this._betaTransition = Qe.CreateAnimation("beta", Qe.ANIMATIONTYPE_FLOAT, 60, e.EasingFunction));
var o = Qe.TransitionTo("beta", n, 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 = ct.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 Fn,
e.EasingMode = Mn.EASINGMODE_EASEINOUT,
e.IgnoreBoundsSizeMode = 0,
e.FitFrustumSidesMode = 1,
e
}()
, ho = function(e, t, i, n) {
void 0 === t && (t = new x),
void 0 === i && (i = 0),
void 0 === n && (n = !1),
this.direction = e,
this.rotatedDirection = t,
this.diff = i,
this.ignore = n
}
, po = function() {
function e(e) {
this._ui = e,
this.name = "AttachToBoxBehavior",
this.distanceAwayFromFace = .15,
this.distanceAwayFromBottomOfFace = .15,
this._faceVectors = [new ho(x.Up()), new ho(x.Down()), new ho(x.Left()), new ho(x.Right()), new ho(x.Forward()), new ho(x.Forward().scaleInPlace(-1))],
this._tmpMatrix = new P,
this._tmpVector = new x,
this._zeroVector = x.Zero(),
this._lookAtTmpMatrix = new P
}
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 = C.RotationYawPitchRoll(t._target.rotation.y, t._target.rotation.x, t._target.rotation.z)),
t._target.rotationQuaternion.toRotationMatrix(t._tmpMatrix),
x.TransformCoordinatesToRef(i.direction, t._tmpMatrix, i.rotatedDirection),
i.diff = x.GetAngleBetweenVectors(i.rotatedDirection, e, x.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 x(0,1,0)),
P.LookAtLHToRef(this._zeroVector, e, t, this._lookAtTmpMatrix),
this._lookAtTmpMatrix.invert(),
C.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 n = 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),
x.TransformCoordinatesToRef(x.Up(), t._tmpMatrix, t._tmpVector),
t._faceVectors.forEach((function(e) {
n.direction.x && e.direction.x && (e.ignore = !0),
n.direction.y && e.direction.y && (e.ignore = !0),
n.direction.z && e.direction.z && (e.ignore = !0)
}
));
var r = t._closestFace(t._tmpVector);
t._faceVectors.forEach((function(e) {
e.ignore = !1
}
)),
t._ui.position.copyFrom(e.position),
n.direction.x && (n.rotatedDirection.scaleToRef(e.scaling.x / 2 + t.distanceAwayFromFace, t._tmpVector),
t._ui.position.addInPlace(t._tmpVector)),
n.direction.y && (n.rotatedDirection.scaleToRef(e.scaling.y / 2 + t.distanceAwayFromFace, t._tmpVector),
t._ui.position.addInPlace(t._tmpVector)),
n.direction.z && (n.rotatedDirection.scaleToRef(e.scaling.z / 2 + t.distanceAwayFromFace, t._tmpVector),
t._ui.position.addInPlace(t._tmpVector)),
t._ui.rotationQuaternion || (t._ui.rotationQuaternion = C.RotationYawPitchRoll(t._ui.rotation.y, t._ui.rotation.x, t._ui.rotation.z)),
n.rotatedDirection.scaleToRef(-1, t._tmpVector),
t._lookAtToRef(t._tmpVector, r.rotatedDirection, t._ui.rotationQuaternion),
r.direction.x && t._ui.up.scaleToRef(t.distanceAwayFromBottomOfFace - e.scaling.x / 2, t._tmpVector),
r.direction.y && t._ui.up.scaleToRef(t.distanceAwayFromBottomOfFace - e.scaling.y / 2, t._tmpVector),
r.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
}()
, fo = function() {
function e() {
var e = this;
this.delay = 0,
this.fadeInTime = 300,
this._millisecondsPerFrame = 1e3 / 60,
this._hovered = !1,
this._hoverValue = 0,
this._ownerNode = null,
this._update = function() {
if (e._ownerNode) {
if (e._hoverValue += e._hovered ? e._millisecondsPerFrame : -e._millisecondsPerFrame,
e._setAllVisibility(e._ownerNode, (e._hoverValue - e.delay) / e.fadeInTime),
e._ownerNode.visibility > 1)
return e._setAllVisibility(e._ownerNode, 1),
void (e._hoverValue = e.fadeInTime + e.delay);
if (e._ownerNode.visibility < 0 && (e._setAllVisibility(e._ownerNode, 0),
e._hoverValue < 0))
return void (e._hoverValue = 0);
setTimeout(e._update, e._millisecondsPerFrame)
}
}
}
return 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) {
this._hovered = e,
this._update()
}
,
e.prototype._setAllVisibility = function(e, t) {
var i = this;
e.visibility = t,
e.getChildMeshes().forEach((function(e) {
i._setAllVisibility(e, t)
}
))
}
,
e
}()
, _o = 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, n) {
void 0 === n && (n = 0);
var r, o, a, s, l = e._TmpVector3[0].copyFromFloats(t.x - n, t.y - n, t.z - n), c = e._TmpVector3[1].copyFromFloats(i.x + n, i.y + n, i.z + n), 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 (r = 1 / this.direction.x,
o = (l.x - this.origin.x) * r,
(a = (c.x - this.origin.x) * r) == -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 (r = 1 / this.direction.y,
o = (l.y - this.origin.y) * r,
(a = (c.y - this.origin.y) * r) == -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 (r = 1 / this.direction.z,
o = (l.z - this.origin.z) * r,
(a = (c.z - this.origin.z) * r) == -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
, n = e.center.y - this.origin.y
, r = e.center.z - this.origin.z
, o = i * i + n * n + r * r
, a = e.radius + t
, s = a * a;
if (o <= s)
return !0;
var l = i * this.direction.x + n * this.direction.y + r * this.direction.z;
return !(l < 0) && o - l * l <= s
}
,
e.prototype.intersectsTriangle = function(t, i, n) {
var r = e._TmpVector3[0]
, o = e._TmpVector3[1]
, a = e._TmpVector3[2]
, s = e._TmpVector3[3]
, l = e._TmpVector3[4];
i.subtractToRef(t, r),
n.subtractToRef(t, o),
x.CrossToRef(this.direction, o, a);
var c = x.Dot(r, a);
if (0 === c)
return null;
var u = 1 / c;
this.origin.subtractToRef(t, s);
var h = x.Dot(s, a) * u;
if (h < 0 || h > 1)
return null;
x.CrossToRef(s, r, l);
var d = x.Dot(this.direction, l) * u;
if (d < 0 || h + d > 1)
return null;
var p = x.Dot(o, l) * u;
return p > this.length ? null : new er(1 - h - d,h,p)
}
,
e.prototype.intersectsPlane = function(e) {
var t, i = x.Dot(e.normal, this.direction);
if (Math.abs(i) < 9.99999997475243e-7)
return null;
var n = x.Dot(e.normal, this.origin);
return (t = (-e.d - n) / 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 x(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 x(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 x(this.origin.x + this.direction.x * -i,this.origin.y + this.direction.y * -i,t);
default:
return null
}
}
,
e.prototype.intersectsMesh = function(t, i) {
var n = I.Matrix[0];
return t.getWorldMatrix().invertToRef(n),
this._tmpRay ? e.TransformToRef(this, n, this._tmpRay) : this._tmpRay = e.Transform(this, n),
t.intersects(this._tmpRay, i)
}
,
e.prototype.intersectsMeshes = function(e, t, i) {
i ? i.length = 0 : i = [];
for (var n = 0; n < e.length; n++) {
var r = this.intersectsMesh(e[n], t);
r.hit && i.push(r)
}
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, n) {
var r = this.origin
, o = I.Vector3[0]
, a = I.Vector3[1]
, s = I.Vector3[2]
, l = I.Vector3[3];
i.subtractToRef(t, o),
this.direction.scaleToRef(e._Rayl, s),
r.addToRef(s, a),
t.subtractToRef(r, l);
var c, u, h = x.Dot(o, o), d = x.Dot(o, s), p = x.Dot(s, s), f = x.Dot(o, l), _ = x.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 = I.Vector3[4];
s.scaleToRef(b, T);
var E = I.Vector3[5];
o.scaleToRef(y, E),
E.addInPlace(l);
var S = I.Vector3[6];
return E.subtractToRef(T, S),
b > 0 && b <= this.length && S.lengthSquared() < n * n ? E.length() : -1
}
,
e.prototype.update = function(t, i, n, r, o, a, s, l) {
if (void 0 === l && (l = !1),
l) {
e._RayDistant || (e._RayDistant = e.Zero()),
e._RayDistant.unprojectRayToRef(t, i, n, r, P.IdentityReadOnly, a, s);
var c = I.Matrix[0];
o.invertToRef(c),
e.TransformToRef(e._RayDistant, c, this)
} else
this.unprojectRayToRef(t, i, n, r, o, a, s);
return this
}
,
e.Zero = function() {
return new e(x.Zero(),x.Zero())
}
,
e.CreateNew = function(t, i, n, r, o, a, s) {
return e.Zero().update(t, i, n, r, o, a, s)
}
,
e.CreateNewFromTo = function(t, i, n) {
void 0 === n && (n = P.IdentityReadOnly);
var r = i.subtract(t)
, o = Math.sqrt(r.x * r.x + r.y * r.y + r.z * r.z);
return r.normalize(),
e.Transform(new e(t,r,o), n)
}
,
e.Transform = function(t, i) {
var n = new e(new x(0,0,0),new x(0,0,0));
return e.TransformToRef(t, i, n),
n
}
,
e.TransformToRef = function(e, t, i) {
x.TransformCoordinatesToRef(e.origin, t, i.origin),
x.TransformNormalToRef(e.direction, t, i.direction),
i.length = e.length;
var n = i.direction
, r = n.length();
if (0 !== r && 1 !== r) {
var o = 1 / r;
n.x *= o,
n.y *= o,
n.z *= o,
i.length *= r
}
}
,
e.prototype.unprojectRayToRef = function(e, t, i, n, r, o, a) {
var s, l = I.Matrix[0];
r.multiplyToRef(o, l),
l.multiplyToRef(a, l),
l.invert();
var c = I.Vector3[0];
c.x = e / i * 2 - 1,
c.y = -(t / n * 2 - 1),
c.z = (null === (s = E.LastCreatedEngine) || void 0 === s ? void 0 : s.isNDCHalfZRange) ? 0 : -1;
var u = I.Vector3[1].copyFromFloats(c.x, c.y, 1 - 1e-8)
, h = I.Vector3[2]
, d = I.Vector3[3];
x._UnprojectFromInvertedMatrixToRef(c, l, h),
x._UnprojectFromInvertedMatrixToRef(u, l, d),
this.origin.copyFrom(h),
d.subtractToRef(h, this.direction),
this.direction.normalize()
}
,
e._TmpVector3 = g.BuildArray(6, x.Zero),
e._RayDistant = e.Zero(),
e._Smallnum = 1e-8,
e._Rayl = 1e9,
e
}();
mn.prototype.createPickingRay = function(e, t, i, n, r) {
void 0 === r && (r = !1);
var o = _o.Zero();
return this.createPickingRayToRef(e, t, i, o, n, r),
o
}
,
mn.prototype.createPickingRayToRef = function(e, t, i, n, r, o, a) {
void 0 === o && (o = !1),
void 0 === a && (a = !1);
var s = this.getEngine();
if (!r) {
if (!this.activeCamera)
return this;
r = this.activeCamera
}
var l = r.viewport.toGlobal(s.getRenderWidth(), s.getRenderHeight());
return e = e / s.getHardwareScalingLevel() - l.x,
t = t / s.getHardwareScalingLevel() - (s.getRenderHeight() - l.y - l.height),
n.update(e, t, l.width, l.height, i || P.IdentityReadOnly, o ? P.IdentityReadOnly : r.getViewMatrix(), r.getProjectionMatrix(), a),
this
}
,
mn.prototype.createPickingRayInCameraSpace = function(e, t, i) {
var n = _o.Zero();
return this.createPickingRayInCameraSpaceToRef(e, t, n, i),
n
}
,
mn.prototype.createPickingRayInCameraSpaceToRef = function(e, t, i, n) {
if (!Ui)
return this;
var r = this.getEngine();
if (!n) {
if (!this.activeCamera)
throw new Error("Active camera not set");
n = this.activeCamera
}
var o = n.viewport.toGlobal(r.getRenderWidth(), r.getRenderHeight())
, a = P.Identity();
return e = e / r.getHardwareScalingLevel() - o.x,
t = t / r.getHardwareScalingLevel() - (r.getRenderHeight() - o.y - o.height),
i.update(e, t, o.width, o.height, a, a, n.getProjectionMatrix()),
this
}
,
mn.prototype._internalPickForMesh = function(e, t, i, n, r, o, a, s) {
var l = t(n, i.enableDistantPicking)
, c = i.intersects(l, r, a, o, n, s);
return c && c.hit ? !r && null != e && c.distance >= e.distance ? null : c : null
}
,
mn.prototype._internalPick = function(e, t, i, n, r) {
if (!Ui)
return null;
for (var o = null, 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 = s.getWorldMatrix();
if (s.hasThinInstances && s.thinInstanceEnablePicking) {
if (l = this._internalPickForMesh(o, e, s, c, !0, !0, r)) {
if (n)
return l;
for (var u = I.Matrix[1], h = s.thinInstanceGetWorldMatrices(), d = 0; d < h.length; d++) {
h[d].multiplyToRef(c, u);
var p = this._internalPickForMesh(o, e, s, u, i, n, r, !0);
if (p && ((o = p).thinInstanceIndex = d,
i))
return o
}
}
} else if ((l = this._internalPickForMesh(o, e, s, c, i, n, r)) && (o = l,
i))
return o
}
return o || new Ui
}
,
mn.prototype._internalMultiPick = function(e, t, i) {
if (!Ui)
return null;
for (var n = new Array, r = 0; r < this.meshes.length; r++) {
var o = this.meshes[r];
if (t) {
if (!t(o))
continue
} else if (!o.isEnabled() || !o.isVisible || !o.isPickable)
continue;
var a, s = o.getWorldMatrix();
if (o.hasThinInstances && o.thinInstanceEnablePicking) {
if (a = this._internalPickForMesh(null, e, o, s, !0, !0, i))
for (var l = I.Matrix[1], c = o.thinInstanceGetWorldMatrices(), u = 0; u < c.length; u++) {
c[u].multiplyToRef(s, l);
var h = this._internalPickForMesh(null, e, o, l, !1, !1, i, !0);
h && (h.thinInstanceIndex = u,
n.push(h))
}
} else
(a = this._internalPickForMesh(null, e, o, s, !1, !1, i)) && n.push(a)
}
return n
}
,
mn.prototype.pickWithBoundingInfo = function(e, t, i, n, r) {
var o = this;
if (!Ui)
return null;
var a = this._internalPick((function(i) {
return o._tempPickingRay || (o._tempPickingRay = _o.Zero()),
o.createPickingRayToRef(e, t, i, o._tempPickingRay, r || null),
o._tempPickingRay
}
), i, n, !0);
return a && (a.ray = this.createPickingRay(e, t, P.Identity(), r || null)),
a
}
,
mn.prototype.pick = function(e, t, i, n, r, o, a) {
var s = this;
if (void 0 === a && (a = !1),
!Ui)
return null;
var l = this._internalPick((function(i, n) {
return s._tempPickingRay || (s._tempPickingRay = _o.Zero()),
s.createPickingRayToRef(e, t, i, s._tempPickingRay, r || null, !1, n),
s._tempPickingRay
}
), i, n, !1, o);
return l && (l.ray = this.createPickingRay(e, t, P.Identity(), r || null)),
l
}
,
mn.prototype.pickWithRay = function(e, t, i, n) {
var r = this
, o = this._internalPick((function(t) {
return r._pickWithRayInverseMatrix || (r._pickWithRayInverseMatrix = P.Identity()),
t.invertToRef(r._pickWithRayInverseMatrix),
r._cachedRayForTransform || (r._cachedRayForTransform = _o.Zero()),
_o.TransformToRef(e, r._pickWithRayInverseMatrix, r._cachedRayForTransform),
r._cachedRayForTransform
}
), t, i, !1, n);
return o && (o.ray = e),
o
}
,
mn.prototype.multiPick = function(e, t, i, n, r) {
var o = this;
return this._internalMultiPick((function(i) {
return o.createPickingRay(e, t, i, n || null)
}
), i, r)
}
,
mn.prototype.multiPickWithRay = function(e, t, i) {
var n = this;
return this._internalMultiPick((function(t) {
return n._pickWithRayInverseMatrix || (n._pickWithRayInverseMatrix = P.Identity()),
t.invertToRef(n._pickWithRayInverseMatrix),
n._cachedRayForTransform || (n._cachedRayForTransform = _o.Zero()),
_o.TransformToRef(e, n._pickWithRayInverseMatrix, n._cachedRayForTransform),
n._cachedRayForTransform
}
), t, i)
}
,
Rr.prototype.getForwardRay = function(e, t, i) {
return void 0 === e && (e = 100),
this.getForwardRayToRef(new _o(x.Zero(),x.Zero(),e), e, t, i)
}
,
Rr.prototype.getForwardRayToRef = function(e, t, i, n) {
return void 0 === t && (t = 100),
i || (i = this.getWorldMatrix()),
e.length = t,
n ? e.origin.copyFrom(n) : e.origin.copyFrom(this.position),
I.Vector3[2].set(0, 0, this._scene.useRightHandedSystem ? -1 : 1),
x.TransformNormalToRef(I.Vector3[2], i, I.Vector3[3]),
x.NormalizeToRef(I.Vector3[3], e.direction),
e
}
;
var mo = 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(P.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 x,
e._PivotTranslation = new x,
e._PivotTmpVector = new x,
e._PivotPostMultiplyPivotMatrix = !1,
e
}();
function go(e) {
var t = []
, i = []
, n = []
, r = []
, o = e.width || e.size || 1
, a = e.height || e.size || 1
, s = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE
, l = o / 2
, c = a / 2;
i.push(-l, -c, 0),
n.push(0, 0, -1),
r.push(0, pr.UseOpenGLOrientationForUV ? 1 : 0),
i.push(l, -c, 0),
n.push(0, 0, -1),
r.push(1, pr.UseOpenGLOrientationForUV ? 1 : 0),
i.push(l, c, 0),
n.push(0, 0, -1),
r.push(1, pr.UseOpenGLOrientationForUV ? 0 : 1),
i.push(-l, c, 0),
n.push(0, 0, -1),
r.push(0, pr.UseOpenGLOrientationForUV ? 0 : 1),
t.push(0),
t.push(1),
t.push(2),
t.push(0),
t.push(2),
t.push(3),
$n._ComputeSides(s, i, t, n, r, e.frontUVs, e.backUVs);
var u = new $n;
return u.indices = t,
u.positions = i,
u.normals = n,
u.uvs = r,
u
}
function vo(e, t, i) {
void 0 === t && (t = {}),
void 0 === i && (i = null);
var n = new Vr(e,i);
return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
n._originalBuilderSideOrientation = t.sideOrientation,
go(t).applyToMesh(n, t.updatable),
t.sourcePlane && (n.translate(t.sourcePlane.normal, -t.sourcePlane.d),
n.setDirection(t.sourcePlane.normal.scale(-1))),
n
}
var yo = {
CreatePlane: vo
};
$n.CreatePlane = go,
Vr.CreatePlane = function(e, t, i, n, r) {
return vo(e, {
size: t,
width: t,
height: t,
sideOrientation: r,
updatable: n
}, i)
}
;
var bo, To, Eo, So, Ao = function() {
function e(e) {
this._useAlternatePickedPointAboveMaxDragAngleDragSpeed = -1.1,
this.maxDragAngle = 0,
this._useAlternatePickedPointAboveMaxDragAngle = !1,
this.currentDraggingPointerId = -1,
this.dragging = !1,
this.dragDeltaRatio = .2,
this.updateDragPlane = !0,
this._debugMode = !1,
this._moving = !1,
this.onDragObservable = new h,
this.onDragStartObservable = new h,
this.onDragEndObservable = new h,
this.onEnabledObservable = new h,
this.moveAttached = !0,
this._enabled = !0,
this.startAndReleaseDragOnPointerEvents = !0,
this.detachCameraControls = !0,
this.useObjectOrientationForDragging = !0,
this.validateDrag = function(e) {
return !0
}
,
this._tmpVector = new x(0,0,0),
this._alternatePickedPoint = new x(0,0,0),
this._worldDragAxis = new x(0,0,0),
this._targetPosition = new x(0,0,0),
this._attachedToElement = !1,
this._startDragRay = new _o(new x,new x),
this._lastPointerRay = {},
this._dragDelta = new x,
this._pointA = new x(0,0,0),
this._pointC = new x(0,0,0),
this._localAxis = new x(0,0,0),
this._lookAt = new x(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 n = this;
this._scene = t.getScene(),
t.isNearGrabbable = !0,
this.attachedNode = t,
e._PlaneScene || (this._debugMode ? e._PlaneScene = this._scene : (e._PlaneScene = new mn(this._scene.getEngine(),{
virtual: !0
}),
e._PlaneScene.detachControl(),
this._scene.onDisposeObservable.addOnce((function() {
e._PlaneScene.dispose(),
e._PlaneScene = null
}
)))),
this._dragPlane = vo("pointerDragPlane", {
size: this._debugMode ? 1 : 1e4,
updatable: !1,
sideOrientation: Vr.DOUBLESIDE
}, e._PlaneScene),
this.lastDragPosition = new x(0,0,0);
var r = i || function(e) {
return n.attachedNode == e || e.isDescendantOf(n.attachedNode)
}
;
this._pointerObserver = this._scene.onPointerObservable.add((function(t) {
if (n.enabled) {
if (t.type == Xi.POINTERDOWN)
n.startAndReleaseDragOnPointerEvents && !n.dragging && t.pickInfo && t.pickInfo.hit && t.pickInfo.pickedMesh && t.pickInfo.pickedPoint && t.pickInfo.ray && r(t.pickInfo.pickedMesh) && n._startDrag(t.event.pointerId, t.pickInfo.ray, t.pickInfo.pickedPoint);
else if (t.type == Xi.POINTERUP)
n.startAndReleaseDragOnPointerEvents && n.currentDraggingPointerId == t.event.pointerId && n.releaseDrag();
else if (t.type == Xi.POINTERMOVE) {
var i = t.event.pointerId;
if (n.currentDraggingPointerId === e._AnyMouseId && i !== e._AnyMouseId) {
var o = t.event;
("mouse" === o.pointerType || !n._scene.getEngine().hostInformation.isMobile && o instanceof MouseEvent) && (n._lastPointerRay[n.currentDraggingPointerId] && (n._lastPointerRay[i] = n._lastPointerRay[n.currentDraggingPointerId],
delete n._lastPointerRay[n.currentDraggingPointerId]),
n.currentDraggingPointerId = i)
}
n._lastPointerRay[i] || (n._lastPointerRay[i] = new _o(new x,new x)),
t.pickInfo && t.pickInfo.ray && (n._lastPointerRay[i].origin.copyFrom(t.pickInfo.ray.origin),
n._lastPointerRay[i].direction.copyFrom(t.pickInfo.ray.direction),
n.currentDraggingPointerId == i && n.dragging && n._moveDrag(t.pickInfo.ray))
}
} else
n._attachedToElement && n.releaseDrag()
}
)),
this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add((function() {
if (n._moving && n.moveAttached) {
var e = !1;
mo._RemoveAndStorePivotPoint(n.attachedNode),
n._targetPosition.subtractToRef(n.attachedNode.absolutePosition, n._tmpVector),
n._tmpVector.scaleInPlace(n.dragDeltaRatio),
n.attachedNode.getAbsolutePosition().addToRef(n._tmpVector, n._tmpVector),
n.validateDrag(n._tmpVector) && (n.attachedNode.setAbsolutePosition(n._tmpVector),
e = !0),
mo._RestorePivotPoint(n.attachedNode),
e && n.attachedNode.computeWorldMatrix()
}
}
))
}
,
e.prototype.releaseDrag = function() {
if (this.dragging && (this.dragging = !1,
this.onDragEndObservable.notifyObservers({
dragPlanePoint: this.lastDragPosition,
pointerId: this.currentDraggingPointerId
})),
this.currentDraggingPointerId = -1,
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, n) {
void 0 === t && (t = e._AnyMouseId),
this._startDrag(t, i, n);
var r = this._lastPointerRay[t];
t === e._AnyMouseId && (r = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]]),
r && this._moveDrag(r)
}
,
e.prototype._startDrag = function(e, t, i) {
if (this._scene.activeCamera && !this.dragging && this.attachedNode) {
mo._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 n = this._pickWithRayOnDragPlane(this._startDragRay);
n && (this.dragging = !0,
this.currentDraggingPointerId = e,
this.lastDragPosition.copyFrom(n),
this.onDragStartObservable.notifyObservers({
dragPlanePoint: n,
pointerId: this.currentDraggingPointerId
}),
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)),
mo._RestorePivotPoint(this.attachedNode)
}
}
,
e.prototype._moveDrag = function(e) {
this._moving = !0;
var t = this._pickWithRayOnDragPlane(e);
if (t) {
mo._RemoveAndStorePivotPoint(this.attachedNode),
this.updateDragPlane && this._updateDragPlanePosition(e, t);
var i = 0;
this._options.dragAxis ? (this.useObjectOrientationForDragging ? x.TransformCoordinatesToRef(this._options.dragAxis, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis) : this._worldDragAxis.copyFrom(this._options.dragAxis),
t.subtractToRef(this.lastDragPosition, this._tmpVector),
i = x.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
}),
this.lastDragPosition.copyFrom(t),
mo._RestorePivotPoint(this.attachedNode)
}
}
,
e.prototype._pickWithRayOnDragPlane = function(t) {
var i = this;
if (!t)
return null;
var n = Math.acos(x.Dot(this._dragPlane.forward, t.direction));
if (n > Math.PI / 2 && (n = Math.PI - n),
this.maxDragAngle > 0 && n > 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 * x.Dot(this._alternatePickedPoint, this._tmpVector)),
this._tmpVector.addInPlace(this._alternatePickedPoint);
var r = x.Dot(this._dragPlane.forward, this._tmpVector);
return this._dragPlane.forward.scaleToRef(-r, 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 ? x.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(x.Dot(this._localAxis, this._pointC)) > .999 ? Math.abs(x.Dot(x.UpReadOnly, this._pointC)) > .999 ? this._lookAt.copyFrom(x.Right()) : this._lookAt.copyFrom(x.UpReadOnly) : (x.CrossToRef(this._localAxis, this._pointC, this._lookAt),
x.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 ? x.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.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
}(), xo = function() {
function e() {
this._startDistance = 0,
this._initialScale = new x(0,0,0),
this._targetScale = new x(0,0,0),
this._sceneRenderObserver = null,
this._dragBehaviorA = new Ao({}),
this._dragBehaviorA.moveAttached = !1,
this._dragBehaviorB = new Ao({}),
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
}(), Ro = function() {
function e() {
this._attachedToElement = !1,
this._virtualMeshesInfo = {},
this._tmpVector = new x,
this._tmpQuaternion = new C,
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 h,
this.onDragObservable = new h,
this.onDragEndObservable = new h,
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 Sr("",e._virtualScene);
t.rotationQuaternion = new C;
var i = new Sr("",e._virtualScene);
i.rotationQuaternion = new C;
var n = new Sr("",e._virtualScene);
return n.rotationQuaternion = new C,
{
dragging: !1,
moving: !1,
dragMesh: t,
originMesh: i,
pivotMesh: n,
startingPivotPosition: new x,
startingPivotOrientation: new C,
startingPosition: new x,
startingOrientation: new C,
lastOriginPosition: new x,
lastDragPosition: new x
}
}
,
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 != Rr.RIG_MODE_NONE || this._pointerCamera._isLeftCamera || this._pointerCamera._isRightCamera || (e.origin.copyFrom(this._pointerCamera.globalPosition),
i = 0);
var n = this._virtualMeshesInfo[t]
, r = I.Vector3[0];
e.origin.subtractToRef(n.lastOriginPosition, r),
n.lastOriginPosition.copyFrom(e.origin);
var o = -x.Dot(r, e.direction);
n.originMesh.addChild(n.dragMesh),
n.originMesh.addChild(n.pivotMesh),
this._applyZOffset(n.dragMesh, o, i),
this._applyZOffset(n.pivotMesh, o, i),
n.originMesh.position.copyFrom(e.origin);
var a = I.Vector3[0];
e.origin.addToRef(e.direction, a),
n.originMesh.lookAt(a),
n.originMesh.removeChild(n.dragMesh),
n.originMesh.removeChild(n.pivotMesh)
}
,
e.prototype._pointerUpdateXR = function(e, t, i, n) {
var r = this._virtualMeshesInfo[i];
if (r.originMesh.position.copyFrom(e.position),
this._dragging === this._dragType.NEAR_DRAG && t ? r.originMesh.rotationQuaternion.copyFrom(t.rotationQuaternion) : r.originMesh.rotationQuaternion.copyFrom(e.rotationQuaternion),
r.pivotMesh.computeWorldMatrix(!0),
r.dragMesh.computeWorldMatrix(!0),
0 !== n) {
var o = I.Vector3[0]
, a = I.Vector3[1];
o.copyFrom(this._pointerCamera.getForwardRay().direction),
r.originMesh.position.subtractToRef(r.lastOriginPosition, a),
r.lastOriginPosition.copyFrom(r.originMesh.position);
var s = a.length();
a.normalize();
var l = I.Vector3[2]
, c = I.Vector3[3];
r.dragMesh.absolutePosition.subtractToRef(this._pointerCamera.globalPosition, l),
r.dragMesh.absolutePosition.subtractToRef(r.originMesh.position, c);
var u = c.length();
l.normalize(),
c.normalize();
var h = Math.abs(x.Dot(a, c)) * x.Dot(a, o) * n * s * u;
h < 0 && .01 - u > h && (h = Math.min(.01 - u, 0)),
c.scaleInPlace(h),
c.addToRef(r.pivotMesh.absolutePosition, this._tmpVector),
r.pivotMesh.setAbsolutePosition(this._tmpVector),
c.addToRef(r.dragMesh.absolutePosition, this._tmpVector),
r.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 mn(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 n, r = i._virtualMeshesInfo[t], o = "xr" === e.event.pointerType;
if (e.type == Xi.POINTERDOWN) {
if (!r.dragging && e.pickInfo && e.pickInfo.hit && e.pickInfo.pickedMesh && e.pickInfo.pickedPoint && e.pickInfo.ray && (!o || e.pickInfo.aimTransform) && (n = e.pickInfo.pickedMesh,
i._ownerNode === n || n.isDescendantOf(i._ownerNode) && (!i.draggableMeshes || -1 !== i.draggableMeshes.indexOf(n)))) {
if (!i.allowMultiPointer && i.currentDraggingPointerIds.length > 0)
return;
!i._pointerCamera || i._pointerCamera.cameraRigMode !== Rr.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 == Xi.POINTERUP || e.type == Xi.POINTERDOUBLETAP) {
var s = i.currentDraggingPointerIds.indexOf(t);
r.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._pointerCamera.attachControl(!0),
i._attachedToElement = !1)),
r.originMesh.removeChild(r.dragMesh),
r.originMesh.removeChild(r.pivotMesh),
i._targetDragEnd(t),
i.onDragEndObservable.notifyObservers({}))
} else if (e.type == Xi.POINTERMOVE && -1 !== (s = i.currentDraggingPointerIds.indexOf(t)) && r.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(r.startingPivotOrientation),
i._tmpQuaternion.x = -i._tmpQuaternion.x,
i._tmpQuaternion.y = -i._tmpQuaternion.y,
i._tmpQuaternion.z = -i._tmpQuaternion.z,
r.pivotMesh.absoluteRotationQuaternion.multiplyToRef(i._tmpQuaternion, i._tmpQuaternion),
r.pivotMesh.absolutePosition.subtractToRef(r.startingPivotPosition, i._tmpVector),
i.onDragObservable.notifyObservers({
delta: i._tmpVector,
position: r.pivotMesh.position,
pickInfo: e.pickInfo
}),
i._targetDrag(i._tmpVector, i._tmpQuaternion, t),
r.lastDragPosition.copyFrom(r.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.detach = function() {
for (var e in this._scene && (this.detachCameraControls && this._attachedToElement && this._pointerCamera && !this._pointerCamera.leftCamera && (this._pointerCamera.attachControl(!0),
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
}(), Co = function(e) {
function t() {
var t = null !== e && e.apply(this, arguments) || this;
return t._sceneRenderObserver = null,
t._targetPosition = new x(0,0,0),
t._targetOrientation = new C,
t._targetScaling = new x(1,1,1),
t._startingPosition = new x(0,0,0),
t._startingOrientation = new C,
t._startingScaling = new x(1,1,1),
t.onPositionChangedObservable = new h,
t.dragDeltaRatio = .2,
t.rotateDraggedObject = !0,
t.rotateAroundYOnly = !1,
t.rotateWithMotionController = !0,
t.disableMovement = !1,
t.faceCameraOnDragStart = !1,
t
}
return U(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 yr("virtual_sixDof",Ro._virtualScene),
this._virtualTransformNode.rotationQuaternion = C.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)) && C.SlerpToRef(t.rotationQuaternion, i._targetOrientation, i.dragDeltaRatio, t.rotationQuaternion),
t.setParent(e)
}
}
))
}
,
t.prototype._getPositionOffsetAround = function(e, t, i) {
var n = I.Matrix[0]
, r = I.Matrix[1]
, o = I.Matrix[2]
, a = I.Matrix[3]
, s = I.Matrix[4];
return P.TranslationToRef(e.x, e.y, e.z, n),
P.TranslationToRef(-e.x, -e.y, -e.z, r),
P.FromQuaternionToRef(i, o),
P.ScalingToRef(t, t, t, a),
r.multiplyToRef(o, s),
s.multiplyToRef(a, s),
s.multiplyToRef(n, s),
s.getTranslation()
}
,
t.prototype._onePointerPositionUpdated = function(e, t) {
I.Vector3[0].setAll(0),
this._dragging === this._dragType.DRAG ? this.rotateDraggedObject && (this.rotateAroundYOnly ? C.RotationYawPitchRollToRef(t.toEulerAngles().y, 0, 0, I.Quaternion[0]) : I.Quaternion[0].copyFrom(t),
I.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 = I.Vector3[0];
e.addToRef(t, i),
i.scaleInPlace(.5);
var n = I.Vector3[1];
t.subtractToRef(e, n);
var r = this._virtualMeshesInfo[this.currentDraggingPointerIds[0]].dragMesh.absolutePosition
, o = this._virtualMeshesInfo[this.currentDraggingPointerIds[1]].dragMesh.absolutePosition
, a = I.Vector3[2];
r.addToRef(o, a),
a.scaleInPlace(.5);
var s = I.Vector3[3];
o.subtractToRef(r, s);
var l = s.length() / n.length()
, c = a.subtract(i)
, u = C.FromEulerAngles(0, x.GetAngleBetweenVectorsOnPlane(n.normalize(), s.normalize(), x.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 = C.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 n = I.Vector3[0];
this._scene.activeCamera.position.subtractToRef(i, n),
n.normalize();
var r = I.Quaternion[0];
this._scene.useRightHandedSystem ? C.FromLookDirectionRHToRef(n, new x(0,1,0), r) : C.FromLookDirectionLHToRef(n, new x(0,1,0), r),
r.normalize(),
C.RotationYawPitchRollToRef(r.toEulerAngles().y, 0, 0, I.Quaternion[0]),
this._targetOrientation.copyFrom(I.Quaternion[0])
}
this._startingPosition.copyFrom(this._targetPosition),
this._startingOrientation.copyFrom(this._targetOrientation),
this._startingScaling.copyFrom(this._targetScaling)
} else
2 === e && (this._virtualTransformNode.setPivotPoint(new x(0,0,0), Ji.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, Ji.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
}(Ro), Po = function() {
function e() {
this._attachPointLocalOffset = new x,
this._workingPosition = new x,
this._workingQuaternion = new C,
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 = C.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 n = I.Vector3[0];
return n.copyFrom(t),
n.scaleInPlace(this.hitNormalOffset),
n.addInPlace(i),
this._attachedMesh.parent && (I.Matrix[0].copyFrom(this._attachedMesh.parent.getWorldMatrix()).invert(),
x.TransformNormalToRef(n, I.Matrix[0], n)),
{
position: n,
quaternion: C.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 && x.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 = I.Quaternion[0];
t.copyFrom(this._attachedMesh.rotationQuaternion),
this._attachedMesh.rotationQuaternion.copyFromFloats(0, 0, 0, 1),
this._attachedMesh.computeWorldMatrix();
var i = this._attachedMesh.getHierarchyBoundingVectors()
, n = I.Vector3[0];
i.max.addToRef(i.min, n),
n.scaleInPlace(.5),
n.z = i.max.z;
var r = I.Matrix[0];
this._attachedMesh.getWorldMatrix().invertToRef(r),
x.TransformCoordinatesToRef(n, r, 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 = I.Vector3[0];
if (x.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 n = new x;
x.SmoothToRef(this._attachedMesh.position, this._workingPosition, e, this.lerpTime, n),
this._attachedMesh.position.copyFrom(n);
var r = new C;
r.copyFrom(this._attachedMesh.rotationQuaternion),
C.SmoothToRef(r, 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 == Xi.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
}(), Mo = function() {
function e() {
this._tmpQuaternion = new C,
this._tmpVectors = [new x, new x, new x, new x, new x, new x, new x],
this._tmpMatrix = new P,
this._tmpInvertView = new P,
this._tmpForward = new x,
this._tmpNodeForward = new x,
this._tmpPosition = new x,
this._workingPosition = new x,
this._workingQuaternion = new C,
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(x.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
, n = this.maximumDistance
, r = this.defaultDistance
, o = this._tmpVectors[0];
o.copyFrom(e);
var a = o.length();
if (o.normalizeFromLength(a),
this.ignoreCameraPitchAndRoll) {
i = this._length2D(o) * i,
n = this._length2D(o) * n;
var s = this._length2D(e);
o.scaleInPlace(a / s),
a = s
}
var l;
return l = t ? r : d.Clamp(a, i, n),
e.copyFrom(o).scaleInPlace(l),
a !== l
}
,
e.prototype._applyVerticalClamp = function(e) {
0 !== this.verticalMaxDistance && (e.y = d.Clamp(e.y, -this.verticalMaxDistance, this.verticalMaxDistance))
}
,
e.prototype._toOrientationQuatToRef = function(e, t) {
C.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),
x.TransformNormalToRef(t, e, t),
t.y = 0,
t.normalize(),
x.TransformNormalToRef(i, e, i),
C.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 n = this._tmpVectors[6];
n.copyFromFloats(1, 0, 0),
x.TransformNormalToRef(i, e, i),
x.TransformNormalToRef(n, e, n);
var r = x.UpReadOnly;
if (t.length() < m)
return !1;
var o = !1
, a = this._tmpQuaternion;
if (this.ignoreCameraPitchAndRoll) {
var s = x.GetAngleBetweenVectorsOnPlane(t, i, n);
C.RotationAxisToRef(n, s, a),
t.rotateByQuaternionToRef(a, t)
} else {
var l = -x.GetAngleBetweenVectorsOnPlane(t, i, n)
, c = this.maxViewVerticalDegrees * Math.PI / 180 * .5;
l < -c ? (C.RotationAxisToRef(n, -l - c, a),
t.rotateByQuaternionToRef(a, t),
o = !0) : l > c && (C.RotationAxisToRef(n, -l + c, a),
t.rotateByQuaternionToRef(a, t),
o = !0)
}
var u = this._angleBetweenVectorAndPlane(t, n) * (this._scene.useRightHandedSystem ? -1 : 1)
, h = this.maxViewHorizontalDegrees * Math.PI / 180 * .5;
return u < -h ? (C.RotationAxisToRef(r, -u - h, a),
t.rotateByQuaternionToRef(a, t),
o = !0) : u > h && (C.RotationAxisToRef(r, -u + h, a),
t.rotateByQuaternionToRef(a, t),
o = !0),
o
}
,
e.prototype._orientationClamp = function(e, t) {
var i, n = this._tmpVectors[0];
n.copyFrom(e).scaleInPlace(-1).normalize();
var r = this._tmpVectors[1]
, o = this._tmpVectors[2];
r.copyFromFloats(0, 1, 0),
x.CrossToRef(n, r, o);
var a = o.length();
a < m || (o.normalizeFromLength(a),
x.CrossToRef(o, n, r),
(null === (i = this.attachedNode) || void 0 === i ? void 0 : i.getScene().useRightHandedSystem) ? C.FromLookDirectionRHToRef(n, r, t) : C.FromLookDirectionLHToRef(n, r, t))
}
,
e.prototype._passedOrientationDeadzone = function(e, t) {
var i = this._tmpVectors[5];
return i.copyFrom(e),
i.normalize(),
180 * Math.abs(x.GetAngleBetweenVectorsOnPlane(t, i, x.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()
, n = this._workingPosition
, r = this._workingQuaternion
, o = this.attachedNode.getPivotPoint()
, a = this._tmpInvertView;
a.copyFrom(e.getViewMatrix()),
a.invert(),
x.TransformCoordinatesToRef(o, i, n);
var s = this._tmpPosition;
s.copyFromFloats(0, 0, 0),
x.TransformCoordinatesToRef(s, i, s),
s.scaleInPlace(-1).subtractInPlace(o),
n.subtractInPlace(e.globalPosition),
this.ignoreCameraPitchAndRoll && this._applyPitchOffset(a);
var l = !1
, c = this._tmpForward;
c.copyFromFloats(0, 0, this._scene.useRightHandedSystem ? -1 : 1),
x.TransformNormalToRef(c, a, c);
var u = this._tmpNodeForward;
if (u.copyFromFloats(0, 0, this._scene.useRightHandedSystem ? -1 : 1),
x.TransformNormalToRef(u, i, u),
this._recenterNextUpdate)
n.copyFrom(c).scaleInPlace(this.defaultDistance);
else if (this.ignoreAngleClamp) {
var h = n.length();
n.copyFrom(c).scaleInPlace(h)
} else
l = this._angularClamp(a, n);
var d = !1;
this.ignoreDistanceClamp || (d = this._distanceClamp(n, l),
this._applyVerticalClamp(n)),
this.useFixedVerticalOffset && (n.y = s.y - e.globalPosition.y + this.fixedVerticalOffset),
(l || d || this._passedOrientationDeadzone(n, u) || this._recenterNextUpdate) && this._orientationClamp(n, r),
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 = C.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 x;
i.copyFrom(this.attachedNode.position).subtractInPlace(this.followedCamera.globalPosition),
x.SmoothToRef(i, this._workingPosition, e, this.lerpTime, i),
i.addInPlace(this.followedCamera.globalPosition),
this.attachedNode.position.copyFrom(i);
var n = new C;
n.copyFrom(this.attachedNode.rotationQuaternion),
C.SmoothToRef(n, 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
}(), Io = 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
}(), Oo = 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, n) {
void 0 === i && (i = 1),
void 0 === n && (n = !1),
this._AvailableFeatures[e] = this._AvailableFeatures[e] || {
latest: i
},
i > this._AvailableFeatures[e].latest && (this._AvailableFeatures[e].latest = i),
n && (this._AvailableFeatures[e].stable = i),
this._AvailableFeatures[e][i] = t
}
,
e.ConstructFeature = function(e, t, i, n) {
void 0 === t && (t = 1);
var r = this._AvailableFeatures[e][t];
if (!r)
throw new Error("feature not found");
return r(i, n)
}
,
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, n, r, o) {
var a = this;
void 0 === i && (i = "latest"),
void 0 === n && (n = {}),
void 0 === r && (r = !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, n);
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
},
r ? 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 gi.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 G(this, void 0, void 0, (function() {
var t, i, n, r, o, a, s;
return z(this, (function(l) {
switch (l.label) {
case 0:
t = this.getEnabledFeatures(),
i = 0,
n = t,
l.label = 1;
case 1:
return i < n.length ? (r = n[i],
o = this._features[r],
(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 = V(V({}, e), s),
l.label = 3;
case 3:
return i++,
[3, 1];
case 4:
return [2, e]
}
}
))
}
))
}
,
e._AvailableFeatures = {},
e._ConflictingFeatures = ((bo = {})[Io.TELEPORTATION] = Io.MOVEMENT,
bo[Io.MOVEMENT] = Io.TELEPORTATION,
bo),
e
}();
!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"
}(To || (To = {})),
function(e) {
e[e.LOOK_AT_CAMERA = 0] = "LOOK_AT_CAMERA",
e[e.HAND_ROTATION = 1] = "HAND_ROTATION"
}(Eo || (Eo = {})),
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"
}(So || (So = {}));
var Do = function() {
function e() {
this._sceneRenderObserver = null,
this._zoneAxis = {},
this.handConstraintVisibility = So.PALM_AND_GAZE,
this.palmUpStrictness = .95,
this.gazeProximityRadius = .15,
this.targetOffset = .1,
this.targetZone = To.ULNAR_SIDE,
this.zoneOrientationMode = Eo.HAND_ROTATION,
this.nodeOrientationMode = Eo.HAND_ROTATION,
this.handedness = "none",
this.lerpTime = 100,
this._zoneAxis[To.ABOVE_FINGER_TIPS] = new x(0,1,0),
this._zoneAxis[To.RADIAL_SIDE] = new x(-1,0,0),
this._zoneAxis[To.ULNAR_SIDE] = new x(1,0,0),
this._zoneAxis[To.BELOW_WRIST] = new x(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("pinky-finger-metacarpal")
, i = e.getJointMesh("middle-finger-metacarpal")
, n = e.getJointMesh("wrist");
if (n && i && t) {
var r = {
position: i.absolutePosition,
quaternion: new C,
id: e.xrController.uniqueId
}
, o = I.Vector3[0]
, a = I.Vector3[1]
, s = I.Vector3[2];
return o.copyFrom(i.absolutePosition).subtractInPlace(n.absolutePosition).normalize(),
a.copyFrom(t.absolutePosition).subtractInPlace(i.absolutePosition).normalize(),
x.CrossToRef(o, a, a),
x.CrossToRef(a, o, s),
C.FromLookDirectionLHToRef(a, o, r.quaternion),
r
}
}
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 = C.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 n = I.Vector3[0]
, r = t._scene.activeCamera;
n.copyFrom(t._zoneAxis[t.targetZone]);
var o = I.Quaternion[0];
if (r && (t.zoneOrientationMode === Eo.LOOK_AT_CAMERA || t.nodeOrientationMode === Eo.LOOK_AT_CAMERA)) {
var a = I.Vector3[1];
a.copyFrom(r.position).subtractInPlace(e.position).normalize(),
t._scene.useRightHandedSystem ? C.FromLookDirectionRHToRef(a, x.UpReadOnly, o) : C.FromLookDirectionLHToRef(a, x.UpReadOnly, o)
}
t.zoneOrientationMode === Eo.HAND_ROTATION ? e.quaternion.toRotationMatrix(I.Matrix[0]) : o.toRotationMatrix(I.Matrix[0]),
x.TransformNormalToRef(n, I.Matrix[0], n),
n.scaleInPlace(t.targetOffset);
var s = I.Vector3[2]
, l = I.Quaternion[1];
s.copyFrom(e.position).addInPlace(n),
t.nodeOrientationMode === Eo.HAND_ROTATION ? l.copyFrom(e.quaternion) : l.copyFrom(o);
var c = Date.now() - i;
x.SmoothToRef(t._node.position, s, c, t.lerpTime, t._node.position),
C.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
, n = this._scene.activeCamera;
if (n) {
var r = n.getForwardRay();
if (this.handConstraintVisibility === So.GAZE_FOCUS || this.handConstraintVisibility === So.PALM_AND_GAZE) {
i = !1;
var o = void 0;
this._eyeTracking && (o = this._eyeTracking.getEyeGaze()),
o = o || r;
var a = I.Vector3[0];
e ? e.position.subtractToRef(o.origin, a) : this._node.getAbsolutePosition().subtractToRef(o.origin, a);
var s = x.Dot(a, o.direction)
, l = s * s;
s > 0 && a.lengthSquared() - l < this.gazeProximityRadius * this.gazeProximityRadius && (i = !0)
}
if ((this.handConstraintVisibility === So.PALM_UP || this.handConstraintVisibility === So.PALM_AND_GAZE) && (t = !1,
e)) {
var c = I.Vector3[0];
x.LeftHandedForwardReadOnly.rotateByQuaternionToRef(e.quaternion, c),
x.Dot(c, r.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) {
try {
this._eyeTracking = e.featuresManager.getEnabledFeature(Io.EYE_TRACKING)
} catch (e) {}
try {
this._handTracking = e.featuresManager.getEnabledFeature(Io.HAND_TRACKING)
} catch (e) {
alert("Hand tracking must be enabled for the Hand Menu to work")
}
}
,
e
}()
, No = function() {
function e(e, t, i) {
if (this.targetPosition = x.Zero(),
this.poleTargetPosition = x.Zero(),
this.poleTargetLocalOffset = x.Zero(),
this.poleAngle = 0,
this.slerpAmount = 1,
this._bone1Quat = C.Identity(),
this._bone1Mat = P.Identity(),
this._bone2Ang = Math.PI,
this._maxAngle = Math.PI,
this._rightHandedSystem = !1,
this._bendAxis = x.Right(),
this._slerping = !1,
this._adjustRoll = 0,
this._bone2 = t,
this._bone1 = t.getParent(),
this._bone1) {
this.mesh = e;
var n = t.getPosition();
if (t.getAbsoluteTransform().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) {
var r = this._bone1.getScale()
, o = this._bone2.getScale();
this._bone1Length = this._bone1.length * r.y * this.mesh.scaling.y,
this._bone2Length = this._bone2.length * o.y * this.mesh.scaling.y
} else if (this._bone1.children[0]) {
e.computeWorldMatrix(!0);
var a = this._bone2.children[0].getAbsolutePosition(e)
, s = this._bone2.getAbsolutePosition(e)
, l = this._bone1.getAbsolutePosition(e);
this._bone1Length = x.Distance(a, s),
this._bone2Length = x.Distance(s, l)
}
this._bone1.getRotationMatrixToRef(Ji.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() {
var t = this._bone1;
if (t) {
var i = this.targetPosition
, n = this.poleTargetPosition
, r = e._TmpMats[0]
, o = e._TmpMats[1];
this.targetMesh && i.copyFrom(this.targetMesh.getAbsolutePosition()),
this.poleTargetBone ? this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset, this.mesh, n) : this.poleTargetMesh && x.TransformCoordinatesToRef(this.poleTargetLocalOffset, this.poleTargetMesh.getWorldMatrix(), n);
var a = e._TmpVecs[0]
, s = e._TmpVecs[1]
, l = e._TmpVecs[2]
, c = e._TmpVecs[3]
, u = e._TmpVecs[4]
, h = e._TmpQuat;
t.getAbsolutePositionToRef(this.mesh, a),
n.subtractToRef(a, u),
0 == u.x && 0 == u.y && 0 == u.z ? u.y = 1 : u.normalize(),
i.subtractToRef(a, c),
c.normalize(),
x.CrossToRef(c, u, s),
s.normalize(),
x.CrossToRef(c, s, l),
l.normalize(),
P.FromXYZAxesToRef(l, c, s, r);
var d = this._bone1Length
, p = this._bone2Length
, f = x.Distance(a, i);
this._maxReach > 0 && (f = Math.min(this._maxReach, f));
var _ = (p * p + f * f - d * d) / (2 * p * f)
, m = (f * f + d * d - p * p) / (2 * f * d);
_ > 1 && (_ = 1),
m > 1 && (m = 1),
_ < -1 && (_ = -1),
m < -1 && (m = -1);
var g = Math.acos(_)
, v = Math.acos(m)
, y = -g - v;
if (this._rightHandedSystem)
P.RotationYawPitchRollToRef(0, 0, this._adjustRoll, o),
o.multiplyToRef(r, r),
P.RotationAxisToRef(this._bendAxis, v, o),
o.multiplyToRef(r, r);
else {
var b = e._TmpVecs[5];
b.copyFrom(this._bendAxis),
b.x *= -1,
P.RotationAxisToRef(b, -v, o),
o.multiplyToRef(r, r)
}
this.poleAngle && (P.RotationAxisToRef(c, this.poleAngle, o),
r.multiplyToRef(o, r)),
this._bone1 && (this.slerpAmount < 1 ? (this._slerping || C.FromRotationMatrixToRef(this._bone1Mat, this._bone1Quat),
C.FromRotationMatrixToRef(r, h),
C.SlerpToRef(this._bone1Quat, h, this.slerpAmount, this._bone1Quat),
y = this._bone2Ang * (1 - this.slerpAmount) + y * this.slerpAmount,
this._bone1.setRotationQuaternion(this._bone1Quat, Ji.WORLD, this.mesh),
this._slerping = !0) : (this._bone1.setRotationMatrix(r, Ji.WORLD, this.mesh),
this._bone1Mat.copyFrom(r),
this._slerping = !1),
this._updateLinkedTransformRotation(this._bone1)),
this._bone2.setAxisAngle(this._bendAxis, y, Ji.LOCAL),
this._updateLinkedTransformRotation(this._bone2),
this._bone2Ang = y
}
}
,
e.prototype._updateLinkedTransformRotation = function(e) {
e._linkedTransformNode && (e._linkedTransformNode.rotationQuaternion || (e._linkedTransformNode.rotationQuaternion = new C),
e.getRotationQuaternionToRef(Ji.LOCAL, null, e._linkedTransformNode.rotationQuaternion))
}
,
e._TmpVecs = [x.Zero(), x.Zero(), x.Zero(), x.Zero(), x.Zero(), x.Zero()],
e._TmpQuat = C.Identity(),
e._TmpMats = [P.Identity(), P.Identity()],
e
}()
, Lo = function() {
function e(e, t, i, n) {
if (this.upAxis = x.Up(),
this.upAxisSpace = Ji.LOCAL,
this.adjustYaw = 0,
this.adjustPitch = 0,
this.adjustRoll = 0,
this.slerpAmount = 1,
this._boneQuat = C.Identity(),
this._slerping = !1,
this._firstFrameSkipped = !1,
this._fowardAxis = x.Forward(),
this.mesh = e,
this.bone = t,
this.target = i,
n && (n.adjustYaw && (this.adjustYaw = n.adjustYaw),
n.adjustPitch && (this.adjustPitch = n.adjustPitch),
n.adjustRoll && (this.adjustRoll = n.adjustRoll),
null != n.maxYaw ? this.maxYaw = n.maxYaw : this.maxYaw = Math.PI,
null != n.minYaw ? this.minYaw = n.minYaw : this.minYaw = -Math.PI,
null != n.maxPitch ? this.maxPitch = n.maxPitch : this.maxPitch = Math.PI,
null != n.minPitch ? this.minPitch = n.minPitch : this.minPitch = -Math.PI,
null != n.slerpAmount && (this.slerpAmount = n.slerpAmount),
null != n.upAxis && (this.upAxis = n.upAxis),
null != n.upAxisSpace && (this.upAxisSpace = n.upAxisSpace),
null != n.yawAxis || null != n.pitchAxis)) {
var r = vn.Y
, o = vn.X;
null != n.yawAxis && (r = n.yawAxis.clone()).normalize(),
null != n.pitchAxis && (o = n.pitchAxis.clone()).normalize();
var a = x.Cross(o, r);
this._transformYawPitch = P.Identity(),
P.FromXYZAxesToRef(o, r, a, this._transformYawPitch),
this._transformYawPitchInv = this._transformYawPitch.clone(),
this._transformYawPitch.invert()
}
t.getParent() || this.upAxisSpace != Ji.BONE || (this.upAxisSpace = Ji.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 n = this.target
, r = e._TmpMats[0]
, o = e._TmpMats[1]
, a = this.mesh
, s = t.getParent()
, l = e._TmpVecs[1];
l.copyFrom(this.upAxis),
this.upAxisSpace == Ji.BONE && s ? (this._transformYawPitch && x.TransformCoordinatesToRef(l, this._transformYawPitchInv, l),
s.getDirectionToRef(l, this.mesh, l)) : this.upAxisSpace == Ji.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 == Ji.BONE && 1 == l.y && s)
s.getRotationMatrixToRef(Ji.WORLD, this.mesh, h);
else if (this.upAxisSpace != Ji.LOCAL || 1 != l.y || s) {
var p = e._TmpVecs[2];
p.copyFrom(this._fowardAxis),
this._transformYawPitch && x.TransformCoordinatesToRef(p, this._transformYawPitchInv, p),
s ? s.getDirectionToRef(p, this.mesh, p) : a.getDirectionToRef(p, p);
var f = x.Cross(l, p);
f.normalize(),
p = x.Cross(f, l),
P.FromXYZAxesToRef(f, l, p, h)
} else
h.copyFrom(a.getWorldMatrix());
h.invertToRef(d);
var _ = null;
if (u) {
var m = e._TmpVecs[3];
n.subtractToRef(i, m),
x.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 && (x.TransformCoordinatesToRef(m, h, m),
m.addInPlace(i),
n = m)
}
if (c) {
m = e._TmpVecs[4],
n.subtractToRef(i, m),
x.TransformCoordinatesToRef(m, d, m);
var y = Math.atan2(m.x, m.z)
, b = y;
if ((y > this._maxYaw || y < 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 * _,
b = this._maxYaw) : this._isAngleBetween(y, this._midYawConstraint, this._minYaw) && (m.z = this._minYawCos * _,
m.x = this._minYawSin * _,
b = this._minYaw) : y > this._maxYaw ? (m.z = this._maxYawCos * _,
m.x = this._maxYawSin * _,
b = this._maxYaw) : y < this._minYaw && (m.z = this._minYawCos * _,
m.x = this._minYawSin * _,
b = this._minYaw)),
this._slerping && this._yawRange > Math.PI) {
var T = e._TmpVecs[8];
T.copyFrom(vn.Z),
this._transformYawPitch && x.TransformCoordinatesToRef(T, this._transformYawPitchInv, T);
var E = e._TmpMats[4];
this._boneQuat.toRotationMatrix(E),
this.mesh.getWorldMatrix().multiplyToRef(E, E),
x.TransformCoordinatesToRef(T, E, T),
x.TransformCoordinatesToRef(T, d, T);
var S = Math.atan2(T.x, T.z);
if (this._getAngleBetween(S, y) > this._getAngleBetween(S, this._midYawConstraint)) {
null == _ && (_ = Math.sqrt(m.x * m.x + m.z * m.z));
var A = this._getAngleBetween(S, this._maxYaw);
this._getAngleBetween(S, this._minYaw) < A ? (b = S + .75 * Math.PI,
m.z = Math.cos(b) * _,
m.x = Math.sin(b) * _) : (b = S - .75 * Math.PI,
m.z = Math.cos(b) * _,
m.x = Math.sin(b) * _)
}
}
y != b && (x.TransformCoordinatesToRef(m, h, m),
m.addInPlace(i),
n = m)
}
}
var R = e._TmpVecs[5]
, M = e._TmpVecs[6]
, I = e._TmpVecs[7]
, O = e._TmpQuat;
n.subtractToRef(i, R),
R.normalize(),
x.CrossToRef(l, R, M),
M.normalize(),
x.CrossToRef(R, M, I),
I.normalize(),
P.FromXYZAxesToRef(M, I, R, r),
0 === M.x && 0 === M.y && 0 === M.z || 0 === I.x && 0 === I.y && 0 === I.z || 0 === R.x && 0 === R.y && 0 === R.z || ((this.adjustYaw || this.adjustPitch || this.adjustRoll) && (P.RotationYawPitchRollToRef(this.adjustYaw, this.adjustPitch, this.adjustRoll, o),
o.multiplyToRef(r, r)),
this.slerpAmount < 1 ? (this._slerping || this.bone.getRotationQuaternionToRef(Ji.WORLD, this.mesh, this._boneQuat),
this._transformYawPitch && this._transformYawPitch.multiplyToRef(r, r),
C.FromRotationMatrixToRef(r, O),
C.SlerpToRef(this._boneQuat, O, this.slerpAmount, this._boneQuat),
this.bone.setRotationQuaternion(this._boneQuat, Ji.WORLD, this.mesh),
this._slerping = !0) : (this._transformYawPitch && this._transformYawPitch.multiplyToRef(r, r),
this.bone.setRotationMatrix(r, Ji.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 C),
e.getRotationQuaternionToRef(Ji.LOCAL, null, e._linkedTransformNode.rotationQuaternion))
}
,
e._TmpVecs = g.BuildArray(10, x.Zero),
e._TmpQuat = C.Identity(),
e._TmpMats = g.BuildArray(5, P.Identity),
e
}()
, Fo = 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 = P.Identity(),
this._ranges = {},
this._lastAbsoluteTransformsUpdateId = -1,
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 h,
this.bones = [],
this._scene = i || E.LastCreatedScene,
this._uniqueId = this._scene.getUniqueId(),
this._scene.addSkeleton(this),
this._isDirty = !0;
var n = this._scene.getEngine().getCaps();
this._canUseTextureForBones = n.textureFloat && n.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.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 n in this._ranges)
i && (t += ", ",
i = !1),
t += n;
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 We(e,t,i);
for (var n = 0, r = this.bones.length; n < r; n++)
this.bones[n].animations[0] && this.bones[n].animations[0].createRange(e, t, i)
}
}
,
e.prototype.deleteAnimationRange = function(e, t) {
void 0 === t && (t = !0);
for (var i = 0, n = this.bones.length; i < n; 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 n, r, o = !0, a = this._getHighestAnimationFrame() + 1, s = {}, l = e.bones;
for (r = 0,
n = l.length; r < n; r++)
s[l[r].name] = l[r];
this.bones.length !== l.length && (K.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 (r = 0,
n = this.bones.length; r < n; r++) {
var u = this.bones[r].name
, h = s[u];
h ? o = o && this.bones[r].copyAnimationRange(h, t, a, i, c) : (K.Warn("copyAnimationRange: not same rig, missing source bone " + u),
o = !1)
}
var d = e.getAnimationRange(t);
return d && (this._ranges[t] = new We(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 n = this.bones[t].animations[0].getHighestFrame();
e < n && (e = n)
}
return e
}
,
e.prototype.beginAnimation = function(e, t, i, n) {
var r = this.getAnimationRange(e);
return r ? this._scene.beginAnimation(this, r.from, r.to, t, i, n) : null
}
,
e.MakeAnimationAdditive = function(e, t, i) {
void 0 === t && (t = 0);
var n = e.getAnimationRange(i);
if (!n)
return null;
for (var r = e._scene.getAllAnimatablesByTarget(e), o = null, a = 0; a < r.length; a++) {
var s = r[a];
if (s.fromFrame === (null == n ? void 0 : n.from) && s.toFrame === (null == n ? void 0 : n.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++)
Qe.MakeAnimationAdditive(c[u], t, i)
}
return o && (o.isAdditive = !0),
e
}
,
e.prototype._markAsDirty = function() {
this._isDirty = !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 n = this.bones[i];
n._childUpdateId++;
var r = n.getParent();
if (r ? n.getLocalMatrix().multiplyToRef(r.getWorldMatrix(), n.getWorldMatrix()) : t ? n.getLocalMatrix().multiplyToRef(t, n.getWorldMatrix()) : n.getWorldMatrix().copyFrom(n.getLocalMatrix()),
-1 !== n._index) {
var o = null === n._index ? i : n._index;
n.getInvertedAbsoluteTransform().multiplyToArray(n.getWorldMatrix(), 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++)
(u = t[e])._linkedTransformNode && (u._linkedTransformNode.computeWorldMatrix(),
u._matrix = u._linkedTransformNode._localMatrix);
if (this.needInitialSkinMatrix)
for (var i = 0, n = this._meshesWithPoseMatrix; i < n.length; i++) {
var r = n[i]
, o = r.getPoseMatrix()
, s = this._isDirty;
if (r._bonesTransformMatrices && r._bonesTransformMatrices.length === 16 * (this.bones.length + 1) || (r._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1)),
s = !0),
s) {
if (this._synchronizedWithMesh !== r) {
this._synchronizedWithMesh = r;
for (var l = 0, c = this.bones; l < c.length; l++) {
var u;
(u = c[l]).getParent() || (u.getBaseMatrix().multiplyToRef(o, I.Matrix[1]),
u._updateDifferenceMatrix(I.Matrix[1]))
}
if (this.isUsingTextureForMatrices) {
var h = 4 * (this.bones.length + 1);
r._transformMatrixTexture && r._transformMatrixTexture.getSize().width === h || (r._transformMatrixTexture && r._transformMatrixTexture.dispose(),
r._transformMatrixTexture = ao.CreateRGBATexture(r._bonesTransformMatrices, 4 * (this.bones.length + 1), 1, this._scene, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE, a.TEXTURETYPE_FLOAT))
}
}
this._computeTransformMatrices(r._bonesTransformMatrices, o),
this.isUsingTextureForMatrices && r._transformMatrixTexture && r._transformMatrixTexture.update(r._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 = ao.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 n = new e(t,i || t,this._scene);
n.needInitialSkinMatrix = this.needInitialSkinMatrix;
for (var r = 0; r < this.bones.length; r++) {
var o = this.bones[r]
, a = null
, s = o.getParent();
if (s) {
var l = this.bones.indexOf(s);
a = n.bones[l]
}
var c = new yn(o.name,n,a,o.getBaseMatrix().clone(),o.getRestPose().clone());
c._index = o._index,
o._linkedTransformNode && c.linkTransformNode(o._linkedTransformNode),
fe.DeepCopy(o.animations, c.animations)
}
if (this._ranges)
for (var u in n._ranges = {},
this._ranges) {
var h = this._ranges[u];
h && (n._ranges[u] = h.clone())
}
return this._isDirty = !0,
n
}
,
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 = [],
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 n = this.bones[i]
, r = n.getParent()
, o = {
parentBoneIndex: r ? this.bones.indexOf(r) : -1,
index: n.getIndex(),
name: n.name,
id: n.id,
matrix: n.getBaseMatrix().toArray(),
rest: n.getRestPose().toArray(),
linkedTransformNodeId: null === (e = n.getTransformNode()) || void 0 === e ? void 0 : e.id
};
for (var a in t.bones.push(o),
n.length && (o.length = n.length),
n.metadata && (o.metadata = n.metadata),
n.animations && n.animations.length > 0 && (o.animation = n.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 n, r = new e(t.name,t.id,i);
for (t.dimensionsAtRest && (r.dimensionsAtRest = x.FromArray(t.dimensionsAtRest)),
r.needInitialSkinMatrix = t.needInitialSkinMatrix,
n = 0; n < t.bones.length; n++) {
var o = t.bones[n]
, a = t.bones[n].index
, s = null;
o.parentBoneIndex > -1 && (s = r.bones[o.parentBoneIndex]);
var l = o.rest ? P.FromArray(o.rest) : null
, c = new yn(o.name,r,s,P.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(Qe.Parse(o.animation)),
void 0 !== o.linkedTransformNodeId && null !== o.linkedTransformNodeId && (r._hasWaitingData = !0,
c._waitingTransformNodeId = o.linkedTransformNodeId)
}
if (t.ranges)
for (n = 0; n < t.ranges.length; n++) {
var u = t.ranges[n];
r.createAnimationRange(u.name, u.from, u.to)
}
return r
}
,
e.prototype.computeAbsoluteTransforms = function(e) {
void 0 === e && (e = !1);
var t = this._scene.getRenderId();
(this._lastAbsoluteTransformsUpdateId != t || e) && (this.bones[0].computeAbsoluteTransforms(),
this._lastAbsoluteTransformsUpdateId = t)
}
,
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 n = this.bones[e];
void 0 === n._index && (n._index = e);
var r = n.getParent();
r && this._sortBones(this.bones.indexOf(r), t, i),
t.push(n)
}
}
,
e.prototype.setCurrentPoseAsRest = function() {
this.bones.forEach((function(e) {
e.setCurrentPoseAsRest()
}
))
}
,
e
}()
, wo = 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
}()
, Bo = function() {
function e() {
this.wheelPrecisionX = 3,
this.wheelPrecisionY = 3,
this.wheelPrecisionZ = 3,
this.onChangedObservable = new h,
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 = gi.BackCompatCameraNoPreventDefault(arguments),
this._wheel = function(i) {
if (i.type === Xi.POINTERWHEEL) {
var n = i.event
, r = n.deltaMode === $i.DOM_DELTA_LINE ? t._ffMultiplier : 1;
void 0 !== n.deltaY ? (t._wheelDeltaX += t.wheelPrecisionX * r * n.deltaX / t._normalize,
t._wheelDeltaY -= t.wheelPrecisionY * r * n.deltaY / t._normalize,
t._wheelDeltaZ += t.wheelPrecisionZ * r * n.deltaZ / t._normalize) : void 0 !== n.wheelDeltaY ? (t._wheelDeltaX += t.wheelPrecisionX * r * n.wheelDeltaX / t._normalize,
t._wheelDeltaY -= t.wheelPrecisionY * r * n.wheelDeltaY / t._normalize,
t._wheelDeltaZ += t.wheelPrecisionZ * r * n.wheelDeltaZ / t._normalize) : n.wheelDelta && (t._wheelDeltaY -= t.wheelPrecisionY * n.wheelDelta / t._normalize),
n.preventDefault && (e || n.preventDefault())
}
}
,
this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, Xi.POINTERWHEEL)
}
,
e.prototype.detachControl = function() {
this._observer && (this.camera.getScene().onPointerObservable.remove(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"
}
,
k([Ce()], e.prototype, "wheelPrecisionX", void 0),
k([Ce()], e.prototype, "wheelPrecisionY", void 0),
k([Ce()], e.prototype, "wheelPrecisionZ", void 0),
e
}()
, Uo = function() {
function e() {
this._currentActiveButton = -1,
this.buttons = [0, 1, 2]
}
return e.prototype.attachControl = function(e) {
var t = this;
e = gi.BackCompatCameraNoPreventDefault(arguments);
var i = this.camera.getEngine()
, n = i.getInputElement()
, r = 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 = a.event
, l = "touch" === s.pointerType;
if (!i.isInVRExclusivePointerMode && (a.type === Xi.POINTERMOVE || -1 !== t.buttons.indexOf(s.button))) {
var c = s.srcElement || s.target;
if (t._altKey = s.altKey,
t._ctrlKey = s.ctrlKey,
t._metaKey = s.metaKey,
t._shiftKey = s.shiftKey,
t._buttonsPressed = s.buttons,
i.isPointerLock) {
var u = s.movementX || s.mozMovementX || s.webkitMovementX || s.msMovementX || 0
, h = s.movementY || s.mozMovementY || s.webkitMovementY || s.msMovementY || 0;
t.onTouch(null, u, h),
t._pointA = null,
t._pointB = null
} else if (a.type !== Xi.POINTERDOWN || -1 !== t._currentActiveButton && !l)
if (a.type === Xi.POINTERDOUBLETAP)
t.onDoubleTap(s.pointerType);
else if (a.type !== Xi.POINTERUP || t._currentActiveButton !== s.button && !l) {
if (a.type === Xi.POINTERMOVE)
if (e || s.preventDefault(),
t._pointA && null === t._pointB)
u = s.clientX - t._pointA.x,
h = s.clientY - t._pointA.y,
t.onTouch(t._pointA, u, h),
t._pointA.x = s.clientX,
t._pointA.y = s.clientY;
else if (t._pointA && t._pointB) {
var d = t._pointA.pointerId === s.pointerId ? t._pointA : t._pointB;
d.x = s.clientX,
d.y = s.clientY;
var p = t._pointA.x - t._pointB.x
, f = t._pointA.y - t._pointB.y
, _ = p * p + f * f
, m = {
x: (t._pointA.x + t._pointB.x) / 2,
y: (t._pointA.y + t._pointB.y) / 2,
pointerId: s.pointerId,
type: a.type
};
t.onMultiTouch(t._pointA, t._pointB, r, _, o, m),
o = m,
r = _
}
} else {
try {
null == c || c.releasePointerCapture(s.pointerId)
} catch (e) {}
l || (t._pointB = null),
i._badOS ? t._pointA = t._pointB = null : t._pointB && t._pointA && t._pointA.pointerId == s.pointerId ? (t._pointA = t._pointB,
t._pointB = null) : t._pointA && t._pointB && t._pointB.pointerId == s.pointerId ? t._pointB = null : t._pointA = t._pointB = null,
(0 !== r || o) && (t.onMultiTouch(t._pointA, t._pointB, r, 0, o, null),
r = 0,
o = null),
t._currentActiveButton = -1,
t.onButtonUp(s),
e || s.preventDefault()
}
else {
try {
null == c || c.setPointerCapture(s.pointerId)
} catch (e) {}
null === t._pointA ? t._pointA = {
x: s.clientX,
y: s.clientY,
pointerId: s.pointerId,
type: s.pointerType
} : null === t._pointB && (t._pointB = {
x: s.clientX,
y: s.clientY,
pointerId: s.pointerId,
type: s.pointerType
}),
-1 !== t._currentActiveButton || l || (t._currentActiveButton = s.button),
t.onButtonDown(s),
e || (s.preventDefault(),
n && n.focus())
}
}
}
,
this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, Xi.POINTERDOWN | Xi.POINTERUP | Xi.POINTERMOVE | Xi.POINTERDOUBLETAP),
this._onLostFocus = function() {
t._pointA = t._pointB = null,
r = 0,
o = null,
t.onLostFocus()
}
,
this._contextMenuBind = this.onContextMenu.bind(this),
n && n.addEventListener("contextmenu", this._contextMenuBind, !1);
var a = this.camera.getScene().getEngine().getHostWindow();
a && gi.RegisterTopRootEvents(a, [{
name: "blur",
handler: this._onLostFocus
}])
}
,
e.prototype.detachControl = function() {
if (this._onLostFocus) {
var e = this.camera.getScene().getEngine().getHostWindow();
e && gi.UnregisterTopRootEvents(e, [{
name: "blur",
handler: this._onLostFocus
}])
}
if (this._observer) {
if (this.camera.getScene().onPointerObservable.remove(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
}
,
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, n, r, o) {}
,
e.prototype.onContextMenu = function(e) {
e.preventDefault()
}
,
e.prototype.onButtonDown = function(e) {}
,
e.prototype.onButtonUp = function(e) {}
,
e.prototype.onLostFocus = function() {}
,
k([Ce()], e.prototype, "buttons", void 0),
e
}()
, Vo = {}
, ko = 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] ? K.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())
}
,
e.prototype.remove = function(e) {
for (var t in this.attached) {
var i = this.attached[t];
i === e && (i.detachControl(),
i.camera = null,
delete this.attached[t],
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 = !Rr.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 n = this.attached[i]
, r = Ge.Serialize(n);
t[n.getClassName()] = r
}
e.inputsmgr = t
}
,
e.prototype.parse = function(e) {
var t = e.inputsmgr;
if (t) {
this.clear();
var i = function(e) {
var i = Vo[e];
if (i) {
var r = t[e]
, o = Ge.Parse((function() {
return new i
}
), r, null);
n.add(o)
}
}
, n = this;
for (var r in t)
i(r)
} else {
var o = function(t) {
var i = Vo[a.attached[t].getClassName()];
if (i) {
var n = Ge.Parse((function() {
return new i
}
), e, null);
a.remove(a.attached[t]),
a.add(n)
}
}
, a = this;
for (var r in this.attached)
o(r)
}
}
,
e
}()
, Go = function(e, t) {
this.x = e,
this.y = t
}
, zo = function() {
function e(t, i, n, r, o, a, s) {
void 0 === r && (r = 0),
void 0 === o && (o = 1),
void 0 === a && (a = 2),
void 0 === s && (s = 3),
this.id = t,
this.index = i,
this.browserGamepad = n,
this._leftStick = {
x: 0,
y: 0
},
this._rightStick = {
x: 0,
y: 0
},
this._isConnected = !0,
this._invertLeftStickY = !1,
this.type = e.GAMEPAD,
this._leftStickAxisX = r,
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
}()
, Wo = function(e) {
function t(t, i, n) {
var r = e.call(this, t, i, n) || this;
return r.onButtonDownObservable = new h,
r.onButtonUpObservable = new h,
r.type = zo.GENERIC,
r._buttons = new Array(n.buttons.length),
r
}
return U(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
}(zo)
, Ho = 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 !== zo.POSE_ENABLED && (e.gamepad && t.type !== zo.XBOX || (e.gamepad = t))
}
)),
this._onGamepadDisconnectedObserver = t.onGamepadDisconnectedObservable.add((function(t) {
e.gamepad === t && (e.gamepad = null)
}
)),
this.gamepad = t.getGamepadByType(zo.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 n = t.y / this.gamepadRotationSensibility * this._yAxisScale;
0 != n && Math.abs(n) > .005 && (e.inertialBetaOffset += n)
}
}
var r = this.gamepad.leftStick;
if (r && 0 != r.y) {
var o = r.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"
}
,
k([Ce()], e.prototype, "gamepadRotationSensibility", void 0),
k([Ce()], e.prototype, "gamepadMoveSensibility", void 0),
e
}();
Vo.ArcRotateCameraGamepadInput = Ho;
var Xo = 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 = gi.BackCompatCameraNoPreventDefault(arguments),
this._onCanvasBlurObserver || (this._scene = this.camera.getScene(),
this._engine = this._scene.getEngine(),
this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add((function() {
t._keys = []
}
)),
this._onKeyboardObserver = this._scene.onKeyboardObservable.add((function(i) {
var n, r = i.event;
r.metaKey || (i.type === Qi.KEYDOWN ? (t._ctrlPressed = r.ctrlKey,
t._altPressed = r.altKey,
(-1 !== t.keysUp.indexOf(r.keyCode) || -1 !== t.keysDown.indexOf(r.keyCode) || -1 !== t.keysLeft.indexOf(r.keyCode) || -1 !== t.keysRight.indexOf(r.keyCode) || -1 !== t.keysReset.indexOf(r.keyCode)) && (-1 === (n = t._keys.indexOf(r.keyCode)) && t._keys.push(r.keyCode),
r.preventDefault && (e || r.preventDefault()))) : -1 === t.keysUp.indexOf(r.keyCode) && -1 === t.keysDown.indexOf(r.keyCode) && -1 === t.keysLeft.indexOf(r.keyCode) && -1 === t.keysRight.indexOf(r.keyCode) && -1 === t.keysReset.indexOf(r.keyCode) || ((n = t._keys.indexOf(r.keyCode)) >= 0 && t._keys.splice(n, 1),
r.preventDefault && (e || r.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 = []
}
,
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"
}
,
k([Ce()], e.prototype, "keysUp", void 0),
k([Ce()], e.prototype, "keysDown", void 0),
k([Ce()], e.prototype, "keysLeft", void 0),
k([Ce()], e.prototype, "keysRight", void 0),
k([Ce()], e.prototype, "keysReset", void 0),
k([Ce()], e.prototype, "panningSensibility", void 0),
k([Ce()], e.prototype, "zoomingSensibility", void 0),
k([Ce()], e.prototype, "useAltToZoom", void 0),
k([Ce()], e.prototype, "angularSpeed", void 0),
e
}();
Vo.ArcRotateCameraKeyboardMoveInput = Xo;
var jo = function() {
function e() {
this.wheelPrecision = 3,
this.zoomToMouseLocation = !1,
this.wheelDeltaPercentage = 0,
this.customComputeDeltaFromMouseWheel = null,
this._inertialPanning = x.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 = gi.BackCompatCameraNoPreventDefault(arguments),
this._wheel = function(i) {
if (i.type === Xi.POINTERWHEEL) {
var n, r = i.event, o = 0, a = r, s = r.deltaMode === $i.DOM_DELTA_LINE ? 40 : 1;
if (n = void 0 !== r.deltaY ? -r.deltaY * s : void 0 !== r.wheelDeltaY ? -r.wheelDeltaY * s : a.wheelDelta,
t.customComputeDeltaFromMouseWheel)
o = t.customComputeDeltaFromMouseWheel(n, t, r);
else if (t.wheelDeltaPercentage) {
if ((o = t._computeDeltaFromMouseWheelLegacyEvent(n, t.camera.radius)) > 0) {
for (var l = t.camera.radius, c = t.camera.inertialRadiusOffset + o, u = 0; u < 20 && Math.abs(c) > .001; u++)
l -= c,
c *= t.camera.inertia;
l = d.Clamp(l, 0, Number.MAX_VALUE),
o = t._computeDeltaFromMouseWheelLegacyEvent(n, l)
}
} else
o = n / (40 * t.wheelPrecision);
o && (t.zoomToMouseLocation && t._hitPlane ? t._zoomToMouse(o) : t.camera.inertialRadiusOffset += o),
r.preventDefault && (e || r.preventDefault())
}
}
,
this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, Xi.POINTERWHEEL),
this.zoomToMouseLocation && this._inertialPanning.setAll(0)
}
,
e.prototype.detachControl = function() {
this._observer && (this.camera.getScene().onPointerObservable.remove(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 = hn.FromPositionAndNormal(e.target, t)
}
,
e.prototype._getPosition = function() {
var e, t = this.camera, i = t.getScene(), n = i.createPickingRay(i.pointerX, i.pointerY, P.Identity(), t, !1), r = 0;
return this._hitPlane && (r = null !== (e = n.intersectsPlane(this._hitPlane)) && void 0 !== e ? e : 0),
n.origin.addInPlace(n.direction.scaleInPlace(r))
}
,
e.prototype._zoomToMouse = function(e) {
var t, i, n = this.camera, r = 1 - n.inertia;
if (n.lowerRadiusLimit) {
var o = null !== (t = n.lowerRadiusLimit) && void 0 !== t ? t : 0;
n.radius - (n.inertialRadiusOffset + e) / r < o && (e = (n.radius - o) * r - n.inertialRadiusOffset)
}
if (n.upperRadiusLimit) {
var a = null !== (i = n.upperRadiusLimit) && void 0 !== i ? i : 0;
n.radius - (n.inertialRadiusOffset + e) / r > a && (e = (n.radius - a) * r - n.inertialRadiusOffset)
}
var s = e / r / n.radius
, l = this._getPosition()
, c = I.Vector3[6];
l.subtractToRef(n.target, c),
c.scaleInPlace(s),
c.scaleInPlace(r),
this._inertialPanning.addInPlace(c),
n.inertialRadiusOffset += e
}
,
e.prototype._zeroIfClose = function(e) {
Math.abs(e.x) < m && (e.x = 0),
Math.abs(e.y) < m && (e.y = 0),
Math.abs(e.z) < m && (e.z = 0)
}
,
k([Ce()], e.prototype, "wheelPrecision", void 0),
k([Ce()], e.prototype, "zoomToMouseLocation", void 0),
k([Ce()], e.prototype, "wheelDeltaPercentage", void 0),
e
}();
Vo.ArcRotateCameraMouseWheelInput = jo;
var Yo = 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 U(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
, n = t.y - e.y;
this.camera.inertialPanningX += -i / this.panningSensibility,
this.camera.inertialPanningY += n / this.panningSensibility
}
}
,
t.prototype._computePinchZoom = function(e, i) {
var n = this.camera.radius || t.MinimumRadiusForPinch;
this.useNaturalPinchZoom ? this.camera.radius = n * Math.sqrt(e) / Math.sqrt(i) : this.pinchDeltaPercentage ? this.camera.inertialRadiusOffset += .001 * (i - e) * n * 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, n, r, o) {
0 === i && null === r || 0 === n && null === o || (this.multiTouchPanAndZoom ? (this._computePinchZoom(i, n),
this._computeMultiTouchPanning(r, o)) : this.multiTouchPanning && this.pinchZoom ? (this._twoFingerActivityCount++,
this._isPinching || this._twoFingerActivityCount < 20 && Math.abs(Math.sqrt(n) - Math.sqrt(i)) > this.camera.pinchToPanMaxDistance ? (this._computePinchZoom(i, n),
this._isPinching = !0) : this._computeMultiTouchPanning(r, o)) : this.multiTouchPanning ? this._computeMultiTouchPanning(r, o) : this.pinchZoom && this._computePinchZoom(i, n))
}
,
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,
k([Ce()], t.prototype, "buttons", void 0),
k([Ce()], t.prototype, "angularSensibilityX", void 0),
k([Ce()], t.prototype, "angularSensibilityY", void 0),
k([Ce()], t.prototype, "pinchPrecision", void 0),
k([Ce()], t.prototype, "pinchDeltaPercentage", void 0),
k([Ce()], t.prototype, "useNaturalPinchZoom", void 0),
k([Ce()], t.prototype, "pinchZoom", void 0),
k([Ce()], t.prototype, "panningSensibility", void 0),
k([Ce()], t.prototype, "multiTouchPanning", void 0),
k([Ce()], t.prototype, "multiTouchPanAndZoom", void 0),
t
}(Uo);
Vo.ArcRotateCameraPointersInput = Yo;
var Ko = function(e) {
function t(t) {
return e.call(this, t) || this
}
return U(t, e),
t.prototype.addMouseWheel = function() {
return this.add(new jo),
this
}
,
t.prototype.addPointers = function() {
return this.add(new Yo),
this
}
,
t.prototype.addKeyboard = function() {
return this.add(new Xo),
this
}
,
t
}(ko);
Ko.prototype.addVRDeviceOrientation = function() {
return this.add(new Qo),
this
}
;
var Qo = 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 = gi.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) : gi.Warn("Permission not granted.")
}
)).catch((function(e) {
gi.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
}();
Vo.ArcRotateCameraVRDeviceOrientationInput = Qo;
var qo = 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 = gi.BackCompatCameraNoPreventDefault(arguments),
this._onCanvasBlurObserver || (this._scene = this.camera.getScene(),
this._engine = this._scene.getEngine(),
this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add((function() {
t._keys = []
}
)),
this._onKeyboardObserver = this._scene.onKeyboardObservable.add((function(i) {
var n, r = i.event;
i.type === Qi.KEYDOWN ? -1 === t.keysForward.indexOf(r.keyCode) && -1 === t.keysBackward.indexOf(r.keyCode) && -1 === t.keysUp.indexOf(r.keyCode) && -1 === t.keysDown.indexOf(r.keyCode) && -1 === t.keysLeft.indexOf(r.keyCode) && -1 === t.keysRight.indexOf(r.keyCode) || (-1 === (n = t._keys.indexOf(r.keyCode)) && t._keys.push(r.keyCode),
e || r.preventDefault()) : -1 === t.keysForward.indexOf(r.keyCode) && -1 === t.keysBackward.indexOf(r.keyCode) && -1 === t.keysUp.indexOf(r.keyCode) && -1 === t.keysDown.indexOf(r.keyCode) && -1 === t.keysLeft.indexOf(r.keyCode) && -1 === t.keysRight.indexOf(r.keyCode) || ((n = t._keys.indexOf(r.keyCode)) >= 0 && t._keys.splice(n, 1),
e || r.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 = []
}
,
e.prototype.getClassName = function() {
return "FlyCameraKeyboardInput"
}
,
e.prototype._onLostFocus = function() {
this._keys = []
}
,
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]
, n = e._computeLocalCameraSpeed();
-1 !== this.keysForward.indexOf(i) ? e._localDirection.copyFromFloats(0, 0, n) : -1 !== this.keysBackward.indexOf(i) ? e._localDirection.copyFromFloats(0, 0, -n) : -1 !== this.keysUp.indexOf(i) ? e._localDirection.copyFromFloats(0, n, 0) : -1 !== this.keysDown.indexOf(i) ? e._localDirection.copyFromFloats(0, -n, 0) : -1 !== this.keysRight.indexOf(i) ? e._localDirection.copyFromFloats(n, 0, 0) : -1 !== this.keysLeft.indexOf(i) && e._localDirection.copyFromFloats(-n, 0, 0),
e.getScene().useRightHandedSystem && (e._localDirection.z *= -1),
e.getViewMatrix().invertToRef(e._cameraTransformMatrix),
x.TransformNormalToRef(e._localDirection, e._cameraTransformMatrix, e._transformedDirection),
e.cameraDirection.addInPlace(e._transformedDirection)
}
}
,
k([Ce()], e.prototype, "keysForward", void 0),
k([Ce()], e.prototype, "keysBackward", void 0),
k([Ce()], e.prototype, "keysUp", void 0),
k([Ce()], e.prototype, "keysDown", void 0),
k([Ce()], e.prototype, "keysRight", void 0),
k([Ce()], e.prototype, "keysLeft", void 0),
e
}();
Vo.FlyCameraKeyboardInput = qo;
var Zo = 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 = gi.BackCompatCameraNoPreventDefault(arguments),
this._noPreventDefault = e,
this._observer = this.camera.getScene().onPointerObservable.add((function(e) {
t._pointerInput(e)
}
), Xi.POINTERDOWN | Xi.POINTERUP | Xi.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().onPointerObservable.remove(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 === Xi.POINTERMOVE || -1 !== this.buttons.indexOf(t.button))) {
var n = t.srcElement || t.target;
if (e.type === Xi.POINTERDOWN) {
try {
null == n || n.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 === Xi.POINTERUP) {
try {
null == n || n.releasePointerCapture(t.pointerId)
} catch (t) {}
this.activeButton = -1,
this._previousPosition = null,
this._noPreventDefault || t.preventDefault()
} else if (e.type === Xi.POINTERMOVE) {
if (!this._previousPosition)
return void (i.isPointerLock && this._onMouseMove(e.event));
var r = t.clientX - this._previousPosition.x
, o = t.clientY - this._previousPosition.y;
this._rotateCamera(r, 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 || e.mozMovementX || e.webkitMovementX || e.msMovementX || 0
, n = e.movementY || e.mozMovementY || e.webkitMovementY || e.msMovementY || 0;
this._rotateCamera(i, n),
this._previousPosition = null,
this._noPreventDefault || e.preventDefault()
}
}
,
e.prototype._rotateCamera = function(e, t) {
var i = this
, n = this.camera;
this.camera.getScene().useRightHandedSystem && (e *= -1),
n.parent && n.parent._getWorldMatrixDeterminant() < 0 && (e *= -1);
var r, o = e / this.angularSensibility, a = t / this.angularSensibility, s = C.RotationYawPitchRoll(n.rotation.y, n.rotation.x, n.rotation.z);
if (this.buttonsPitch.some((function(e) {
return e === i.activeButton
}
)) && (r = C.RotationAxis(vn.X, a),
s.multiplyInPlace(r)),
this.buttonsYaw.some((function(e) {
return e === i.activeButton
}
))) {
r = C.RotationAxis(vn.Y, o),
s.multiplyInPlace(r);
var l = n.bankedTurnLimit + n._trackRoll;
if (n.bankedTurn && -l < n.rotation.z && n.rotation.z < l) {
var c = n.bankedTurnMultiplier * -o;
r = C.RotationAxis(vn.Z, c),
s.multiplyInPlace(r)
}
}
this.buttonsRoll.some((function(e) {
return e === i.activeButton
}
)) && (r = C.RotationAxis(vn.Z, -o),
n._trackRoll -= o,
s.multiplyInPlace(r)),
s.toEulerAnglesToRef(n.rotation)
}
,
k([Ce()], e.prototype, "buttons", void 0),
k([Ce()], e.prototype, "angularSensibility", void 0),
e
}();
Vo.FlyCameraMouseInput = Zo;
var Jo = 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 = gi.BackCompatCameraNoPreventDefault(arguments),
this._onCanvasBlurObserver || (this._scene = this.camera.getScene(),
this._engine = this._scene.getEngine(),
this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add((function() {
t._keys = []
}
)),
this._onKeyboardObserver = this._scene.onKeyboardObservable.add((function(i) {
var n, r = i.event;
r.metaKey || (i.type === Qi.KEYDOWN ? (t._ctrlPressed = r.ctrlKey,
t._altPressed = r.altKey,
t._shiftPressed = r.shiftKey,
(-1 !== t.keysHeightOffsetIncr.indexOf(r.keyCode) || -1 !== t.keysHeightOffsetDecr.indexOf(r.keyCode) || -1 !== t.keysRotationOffsetIncr.indexOf(r.keyCode) || -1 !== t.keysRotationOffsetDecr.indexOf(r.keyCode) || -1 !== t.keysRadiusIncr.indexOf(r.keyCode) || -1 !== t.keysRadiusDecr.indexOf(r.keyCode)) && (-1 === (n = t._keys.indexOf(r.keyCode)) && t._keys.push(r.keyCode),
r.preventDefault && (e || r.preventDefault()))) : -1 === t.keysHeightOffsetIncr.indexOf(r.keyCode) && -1 === t.keysHeightOffsetDecr.indexOf(r.keyCode) && -1 === t.keysRotationOffsetIncr.indexOf(r.keyCode) && -1 === t.keysRotationOffsetDecr.indexOf(r.keyCode) && -1 === t.keysRadiusIncr.indexOf(r.keyCode) && -1 === t.keysRadiusDecr.indexOf(r.keyCode) || ((n = t._keys.indexOf(r.keyCode)) >= 0 && t._keys.splice(n, 1),
r.preventDefault && (e || r.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 = []
}
,
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
}
,
k([Ce()], e.prototype, "keysHeightOffsetIncr", void 0),
k([Ce()], e.prototype, "keysHeightOffsetDecr", void 0),
k([Ce()], e.prototype, "keysHeightOffsetModifierAlt", void 0),
k([Ce()], e.prototype, "keysHeightOffsetModifierCtrl", void 0),
k([Ce()], e.prototype, "keysHeightOffsetModifierShift", void 0),
k([Ce()], e.prototype, "keysRotationOffsetIncr", void 0),
k([Ce()], e.prototype, "keysRotationOffsetDecr", void 0),
k([Ce()], e.prototype, "keysRotationOffsetModifierAlt", void 0),
k([Ce()], e.prototype, "keysRotationOffsetModifierCtrl", void 0),
k([Ce()], e.prototype, "keysRotationOffsetModifierShift", void 0),
k([Ce()], e.prototype, "keysRadiusIncr", void 0),
k([Ce()], e.prototype, "keysRadiusDecr", void 0),
k([Ce()], e.prototype, "keysRadiusModifierAlt", void 0),
k([Ce()], e.prototype, "keysRadiusModifierCtrl", void 0),
k([Ce()], e.prototype, "keysRadiusModifierShift", void 0),
k([Ce()], e.prototype, "heightSensibility", void 0),
k([Ce()], e.prototype, "rotationSensibility", void 0),
k([Ce()], e.prototype, "radiusSensibility", void 0),
e
}();
Vo.FollowCameraKeyboardMoveInput = Jo;
var $o = 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 = gi.BackCompatCameraNoPreventDefault(arguments),
this._wheel = function(i) {
if (i.type === Xi.POINTERWHEEL) {
var n = i.event
, r = 0
, o = Math.max(-1, Math.min(1, n.deltaY || n.wheelDelta || -n.detail));
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 ? r = .01 * o * t.wheelDeltaPercentage * t.camera.radius : t.axisControlHeight ? r = .01 * o * t.wheelDeltaPercentage * t.camera.heightOffset : t.axisControlRotation && (r = .01 * o * t.wheelDeltaPercentage * t.camera.rotationOffset)) : r = o * t.wheelPrecision,
r && (t.axisControlRadius ? t.camera.radius += r : t.axisControlHeight ? t.camera.heightOffset -= r : t.axisControlRotation && (t.camera.rotationOffset -= r)),
n.preventDefault && (e || n.preventDefault())
}
}
,
this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, Xi.POINTERWHEEL)
}
,
e.prototype.detachControl = function() {
this._observer && (this.camera.getScene().onPointerObservable.remove(this._observer),
this._observer = null,
this._wheel = null)
}
,
e.prototype.getClassName = function() {
return "ArcRotateCameraMouseWheelInput"
}
,
e.prototype.getSimpleName = function() {
return "mousewheel"
}
,
k([Ce()], e.prototype, "axisControlRadius", void 0),
k([Ce()], e.prototype, "axisControlHeight", void 0),
k([Ce()], e.prototype, "axisControlRotation", void 0),
k([Ce()], e.prototype, "wheelPrecision", void 0),
k([Ce()], e.prototype, "wheelDeltaPercentage", void 0),
e
}();
Vo.FollowCameraMouseWheelInput = $o;
var ea = 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 U(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, n, r, o) {
if (!(0 === i && null === r || 0 === n && null === o)) {
var a = (n - 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)
}
}
,
k([Ce()], t.prototype, "angularSensibilityX", void 0),
k([Ce()], t.prototype, "angularSensibilityY", void 0),
k([Ce()], t.prototype, "pinchPrecision", void 0),
k([Ce()], t.prototype, "pinchDeltaPercentage", void 0),
k([Ce()], t.prototype, "axisXControlRadius", void 0),
k([Ce()], t.prototype, "axisXControlHeight", void 0),
k([Ce()], t.prototype, "axisXControlRotation", void 0),
k([Ce()], t.prototype, "axisYControlRadius", void 0),
k([Ce()], t.prototype, "axisYControlHeight", void 0),
k([Ce()], t.prototype, "axisYControlRotation", void 0),
k([Ce()], t.prototype, "axisPinchControlRadius", void 0),
k([Ce()], t.prototype, "axisPinchControlHeight", void 0),
k([Ce()], t.prototype, "axisPinchControlRotation", void 0),
t
}(Uo);
Vo.FollowCameraPointersInput = ea;
var ta = 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._keys = new Array
}
return e.prototype.attachControl = function(e) {
var t = this;
e = gi.BackCompatCameraNoPreventDefault(arguments),
this._onCanvasBlurObserver || (this._scene = this.camera.getScene(),
this._engine = this._scene.getEngine(),
this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add((function() {
t._keys = []
}
)),
this._onKeyboardObserver = this._scene.onKeyboardObservable.add((function(i) {
var n, r = i.event;
r.metaKey || (i.type === Qi.KEYDOWN ? -1 === t.keysUp.indexOf(r.keyCode) && -1 === t.keysDown.indexOf(r.keyCode) && -1 === t.keysLeft.indexOf(r.keyCode) && -1 === t.keysRight.indexOf(r.keyCode) && -1 === t.keysUpward.indexOf(r.keyCode) && -1 === t.keysDownward.indexOf(r.keyCode) && -1 === t.keysRotateLeft.indexOf(r.keyCode) && -1 === t.keysRotateRight.indexOf(r.keyCode) || (-1 === (n = t._keys.indexOf(r.keyCode)) && t._keys.push(r.keyCode),
e || r.preventDefault()) : -1 === t.keysUp.indexOf(r.keyCode) && -1 === t.keysDown.indexOf(r.keyCode) && -1 === t.keysLeft.indexOf(r.keyCode) && -1 === t.keysRight.indexOf(r.keyCode) && -1 === t.keysUpward.indexOf(r.keyCode) && -1 === t.keysDownward.indexOf(r.keyCode) && -1 === t.keysRotateLeft.indexOf(r.keyCode) && -1 === t.keysRotateRight.indexOf(r.keyCode) || ((n = t._keys.indexOf(r.keyCode)) >= 0 && t._keys.splice(n, 1),
e || r.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 = []
}
,
e.prototype.checkInputs = function() {
if (this._onKeyboardObserver)
for (var e = this.camera, t = 0; t < this._keys.length; t++) {
var i = this._keys[t]
, n = e._computeLocalCameraSpeed();
-1 !== this.keysLeft.indexOf(i) ? e._localDirection.copyFromFloats(-n, 0, 0) : -1 !== this.keysUp.indexOf(i) ? e._localDirection.copyFromFloats(0, 0, n) : -1 !== this.keysRight.indexOf(i) ? e._localDirection.copyFromFloats(n, 0, 0) : -1 !== this.keysDown.indexOf(i) ? e._localDirection.copyFromFloats(0, 0, -n) : -1 !== this.keysUpward.indexOf(i) ? e._localDirection.copyFromFloats(0, n, 0) : -1 !== this.keysDownward.indexOf(i) ? e._localDirection.copyFromFloats(0, -n, 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()),
e.getScene().useRightHandedSystem && (e._localDirection.z *= -1),
e.getViewMatrix().invertToRef(e._cameraTransformMatrix),
x.TransformNormalToRef(e._localDirection, e._cameraTransformMatrix, e._transformedDirection),
e.cameraDirection.addInPlace(e._transformedDirection)
}
}
,
e.prototype.getClassName = function() {
return "FreeCameraKeyboardMoveInput"
}
,
e.prototype._onLostFocus = function() {
this._keys = []
}
,
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
}
,
k([Ce()], e.prototype, "keysUp", void 0),
k([Ce()], e.prototype, "keysUpward", void 0),
k([Ce()], e.prototype, "keysDown", void 0),
k([Ce()], e.prototype, "keysDownward", void 0),
k([Ce()], e.prototype, "keysLeft", void 0),
k([Ce()], e.prototype, "keysRight", void 0),
k([Ce()], e.prototype, "rotationSpeed", void 0),
k([Ce()], e.prototype, "keysRotateLeft", void 0),
k([Ce()], e.prototype, "keysRotateRight", void 0),
e
}();
Vo.FreeCameraKeyboardMoveInput = ta;
var ia, na = 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 h,
this._allowCameraRotation = !0,
this._currentActiveButton = -1
}
return e.prototype.attachControl = function(e) {
var t = this;
e = gi.BackCompatCameraNoPreventDefault(arguments);
var i = this.camera.getEngine()
, n = i.getInputElement();
this._pointerInput || (this._pointerInput = function(r) {
var o = r.event
, a = "touch" === o.pointerType;
if (!i.isInVRExclusivePointerMode && (t.touchEnabled || !a) && (r.type === Xi.POINTERMOVE || -1 !== t.buttons.indexOf(o.button))) {
var s = o.srcElement || o.target;
if (r.type !== Xi.POINTERDOWN || -1 !== t._currentActiveButton && !a)
if (r.type !== Xi.POINTERUP || t._currentActiveButton !== o.button && !a) {
if (r.type === Xi.POINTERMOVE)
if (i.isPointerLock && t._onMouseMove)
t._onMouseMove(r.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()
}
} else {
try {
null == s || s.releasePointerCapture(o.pointerId)
} catch (e) {}
t._currentActiveButton = -1,
t._previousPosition = null,
e || o.preventDefault()
}
else {
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(),
n && n.focus()),
i.isPointerLock && t._onMouseMove && t._onMouseMove(r.event)
}
}
}
),
this._onMouseMove = function(n) {
if (i.isPointerLock && !i.isInVRExclusivePointerMode) {
var r = n.movementX || n.mozMovementX || n.webkitMovementX || n.msMovementX || 0;
t.camera.getScene().useRightHandedSystem && (r *= -1),
t.camera.parent && t.camera.parent._getWorldMatrixDeterminant() < 0 && (r *= -1),
t.camera.cameraRotation.y += r / t.angularSensibility;
var o = n.movementY || n.mozMovementY || n.webkitMovementY || n.msMovementY || 0;
t.camera.cameraRotation.x += o / t.angularSensibility,
t._previousPosition = null,
e || n.preventDefault()
}
}
,
this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, Xi.POINTERDOWN | Xi.POINTERUP | Xi.POINTERMOVE),
n && (this._contextMenuBind = this.onContextMenu.bind(this),
n.addEventListener("contextmenu", this._contextMenuBind, !1))
}
,
e.prototype.onContextMenu = function(e) {
e.preventDefault()
}
,
e.prototype.detachControl = function() {
if (this._observer) {
if (this.camera.getScene().onPointerObservable.remove(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
}
}
,
e.prototype.getClassName = function() {
return "FreeCameraMouseInput"
}
,
e.prototype.getSimpleName = function() {
return "mouse"
}
,
k([Ce()], e.prototype, "buttons", void 0),
k([Ce()], e.prototype, "angularSensibility", void 0),
e
}();
Vo.FreeCameraMouseInput = na,
function(e) {
e[e.MoveRelative = 0] = "MoveRelative",
e[e.RotateRelative = 1] = "RotateRelative",
e[e.MoveScene = 2] = "MoveScene"
}(ia || (ia = {}));
var ra = function(e) {
function t() {
var t = null !== e && e.apply(this, arguments) || this;
return t._moveRelative = x.Zero(),
t._rotateRelative = x.Zero(),
t._moveScene = x.Zero(),
t._wheelXAction = ia.MoveRelative,
t._wheelXActionCoordinate = gn.X,
t._wheelYAction = ia.MoveRelative,
t._wheelYActionCoordinate = gn.Z,
t._wheelZAction = null,
t._wheelZActionCoordinate = null,
t
}
return U(t, e),
t.prototype.getClassName = function() {
return "FreeCameraMouseWheelInput"
}
,
Object.defineProperty(t.prototype, "wheelXMoveRelative", {
get: function() {
return this._wheelXAction !== ia.MoveRelative ? null : this._wheelXActionCoordinate
},
set: function(e) {
null === e && this._wheelXAction !== ia.MoveRelative || (this._wheelXAction = ia.MoveRelative,
this._wheelXActionCoordinate = e)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "wheelYMoveRelative", {
get: function() {
return this._wheelYAction !== ia.MoveRelative ? null : this._wheelYActionCoordinate
},
set: function(e) {
null === e && this._wheelYAction !== ia.MoveRelative || (this._wheelYAction = ia.MoveRelative,
this._wheelYActionCoordinate = e)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "wheelZMoveRelative", {
get: function() {
return this._wheelZAction !== ia.MoveRelative ? null : this._wheelZActionCoordinate
},
set: function(e) {
null === e && this._wheelZAction !== ia.MoveRelative || (this._wheelZAction = ia.MoveRelative,
this._wheelZActionCoordinate = e)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "wheelXRotateRelative", {
get: function() {
return this._wheelXAction !== ia.RotateRelative ? null : this._wheelXActionCoordinate
},
set: function(e) {
null === e && this._wheelXAction !== ia.RotateRelative || (this._wheelXAction = ia.RotateRelative,
this._wheelXActionCoordinate = e)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "wheelYRotateRelative", {
get: function() {
return this._wheelYAction !== ia.RotateRelative ? null : this._wheelYActionCoordinate
},
set: function(e) {
null === e && this._wheelYAction !== ia.RotateRelative || (this._wheelYAction = ia.RotateRelative,
this._wheelYActionCoordinate = e)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "wheelZRotateRelative", {
get: function() {
return this._wheelZAction !== ia.RotateRelative ? null : this._wheelZActionCoordinate
},
set: function(e) {
null === e && this._wheelZAction !== ia.RotateRelative || (this._wheelZAction = ia.RotateRelative,
this._wheelZActionCoordinate = e)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "wheelXMoveScene", {
get: function() {
return this._wheelXAction !== ia.MoveScene ? null : this._wheelXActionCoordinate
},
set: function(e) {
null === e && this._wheelXAction !== ia.MoveScene || (this._wheelXAction = ia.MoveScene,
this._wheelXActionCoordinate = e)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "wheelYMoveScene", {
get: function() {
return this._wheelYAction !== ia.MoveScene ? null : this._wheelYActionCoordinate
},
set: function(e) {
null === e && this._wheelYAction !== ia.MoveScene || (this._wheelYAction = ia.MoveScene,
this._wheelYActionCoordinate = e)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "wheelZMoveScene", {
get: function() {
return this._wheelZAction !== ia.MoveScene ? null : this._wheelZActionCoordinate
},
set: function(e) {
null === e && this._wheelZAction !== ia.MoveScene || (this._wheelZAction = ia.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 = P.Zero();
this.camera.getViewMatrix().invertToRef(t);
var i = x.Zero();
x.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 n = null;
switch (t) {
case ia.MoveRelative:
n = this._moveRelative;
break;
case ia.RotateRelative:
n = this._rotateRelative;
break;
case ia.MoveScene:
n = this._moveScene
}
switch (i) {
case gn.X:
n.set(e, 0, 0);
break;
case gn.Y:
n.set(0, e, 0);
break;
case gn.Z:
n.set(0, 0, e)
}
}
}
,
k([Ce()], t.prototype, "wheelXMoveRelative", null),
k([Ce()], t.prototype, "wheelYMoveRelative", null),
k([Ce()], t.prototype, "wheelZMoveRelative", null),
k([Ce()], t.prototype, "wheelXRotateRelative", null),
k([Ce()], t.prototype, "wheelYRotateRelative", null),
k([Ce()], t.prototype, "wheelZRotateRelative", null),
k([Ce()], t.prototype, "wheelXMoveScene", null),
k([Ce()], t.prototype, "wheelYMoveScene", null),
k([Ce()], t.prototype, "wheelZMoveScene", null),
t
}(Bo);
Vo.FreeCameraMouseWheelInput = ra;
var oa = 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
}
return e.prototype.attachControl = function(e) {
var t = this;
e = gi.BackCompatCameraNoPreventDefault(arguments);
var i = null;
if (void 0 === this._pointerInput && (this._onLostFocus = function() {
t._offsetX = null,
t._offsetY = null
}
,
this._pointerInput = function(n) {
var r = n.event
, o = !t.camera.getEngine().hostInformation.isMobile && r instanceof MouseEvent;
if (t.allowMouse || "mouse" !== r.pointerType && !o)
if (n.type === Xi.POINTERDOWN) {
if (e || r.preventDefault(),
t._pointerPressed.push(r.pointerId),
1 !== t._pointerPressed.length)
return;
i = {
x: r.clientX,
y: r.clientY
}
} else if (n.type === Xi.POINTERUP) {
if (e || r.preventDefault(),
-1 === (a = t._pointerPressed.indexOf(r.pointerId)))
return;
if (t._pointerPressed.splice(a, 1),
0 != a)
return;
i = null,
t._offsetX = null,
t._offsetY = null
} else if (n.type === Xi.POINTERMOVE) {
if (e || r.preventDefault(),
!i)
return;
var a;
if (0 != (a = t._pointerPressed.indexOf(r.pointerId)))
return;
t._offsetX = r.clientX - i.x,
t._offsetY = -(r.clientY - i.y)
}
}
),
this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, Xi.POINTERDOWN | Xi.POINTERUP | Xi.POINTERMOVE),
this._onLostFocus) {
var n = this.camera.getEngine()
, r = n.getInputElement();
r && r.addEventListener("blur", this._onLostFocus)
}
}
,
e.prototype.detachControl = function() {
if (this._pointerInput) {
if (this._observer && (this.camera.getScene().onPointerObservable.remove(this._observer),
this._observer = null),
this._onLostFocus) {
var e = this.camera.getEngine().getInputElement();
e && e.removeEventListener("blur", this._onLostFocus),
this._onLostFocus = null
}
this._pointerPressed = [],
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 x(0,0,t * this._offsetY / this.touchMoveSensibility);
P.RotationYawPitchRollToRef(e.rotation.y, e.rotation.x, 0, e._cameraRotationMatrix),
e.cameraDirection.addInPlace(x.TransformCoordinates(i, e._cameraRotationMatrix))
}
}
}
,
e.prototype.getClassName = function() {
return "FreeCameraTouchInput"
}
,
e.prototype.getSimpleName = function() {
return "touch"
}
,
k([Ce()], e.prototype, "touchAngularSensibility", void 0),
k([Ce()], e.prototype, "touchMoveSensibility", void 0),
e
}();
Vo.FreeCameraTouchInput = oa;
var aa = function(e) {
function t(t) {
var i = e.call(this, t) || this;
return i._mouseInput = null,
i._mouseWheelInput = null,
i
}
return U(t, e),
t.prototype.addKeyboard = function() {
return this.add(new ta),
this
}
,
t.prototype.addMouse = function(e) {
return void 0 === e && (e = !0),
this._mouseInput || (this._mouseInput = new na(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 ra,
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 oa),
this
}
,
t.prototype.clear = function() {
e.prototype.clear.call(this),
this._mouseInput = null
}
,
t
}(ko);
aa.prototype.addDeviceOrientation = function() {
return this._deviceOrientationInput || (this._deviceOrientationInput = new sa,
this.add(this._deviceOrientationInput)),
this
}
;
var sa = function() {
function e() {
var e = this;
this._screenOrientationAngle = 0,
this._screenQuaternion = new C,
this._alpha = 0,
this._beta = 0,
this._gamma = 0,
this._onDeviceOrientationChangedObservable = new h,
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 = -gi.ToRadians(e._screenOrientationAngle / 2),
e._screenQuaternion.copyFromFloats(0, Math.sin(e._screenOrientationAngle), 0, Math.cos(e._screenOrientationAngle))
}
,
this._deviceOrientation = function(t) {
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 C(-Math.sqrt(.5),0,0,Math.sqrt(.5)),
this._orientationChanged()
}
return e.WaitForOrientationChangeAsync = function(e) {
return new Promise((function(t, i) {
var n = !1
, r = function() {
window.removeEventListener("deviceorientation", r),
n = !0,
t()
};
e && setTimeout((function() {
n || (window.removeEventListener("deviceorientation", r),
i("WaitForOrientationChangeAsync timed out"))
}
), e),
"undefined" != typeof DeviceOrientationEvent && "function" == typeof DeviceOrientationEvent.requestPermission ? DeviceOrientationEvent.requestPermission().then((function(e) {
"granted" == e ? window.addEventListener("deviceorientation", r) : gi.Warn("Permission not granted.")
}
)).catch((function(e) {
gi.Error(e)
}
)) : window.addEventListener("deviceorientation", r)
}
))
}
,
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 C),
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() : gi.Warn("Permission not granted.")
}
)).catch((function(e) {
gi.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 && (C.RotationYawPitchRollToRef(gi.ToRadians(this._alpha), gi.ToRadians(this._beta), -gi.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
}();
Vo.FreeCameraDeviceOrientationInput = sa;
var la, ca = function() {
function e() {
this.gamepadAngularSensibility = 200,
this.gamepadMoveSensibility = 40,
this.deadzoneDelta = .1,
this._yAxisScale = 1,
this._cameraTransform = P.Identity(),
this._deltaTransform = x.Zero(),
this._vector3 = x.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 !== zo.POSE_ENABLED && (e.gamepad && t.type !== zo.XBOX || (e.gamepad = t))
}
)),
this._onGamepadDisconnectedObserver = t.onGamepadDisconnectedObservable.add((function(t) {
e.gamepad === t && (e.gamepad = null)
}
)),
this.gamepad = t.getGamepadByType(zo.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) : P.RotationYawPitchRollToRef(e.rotation.y, e.rotation.x, 0, this._cameraTransform);
var n = 50 * e._computeLocalCameraSpeed();
this._vector3.copyFromFloats(t.x * n, 0, -t.y * n),
x.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"
}
,
k([Ce()], e.prototype, "gamepadAngularSensibility", void 0),
k([Ce()], e.prototype, "gamepadMoveSensibility", void 0),
e
}();
Vo.FreeCameraGamepadInput = ca,
function(e) {
e[e.X = 0] = "X",
e[e.Y = 1] = "Y",
e[e.Z = 2] = "Z"
}(la || (la = {}));
var ua = function() {
function e(t, i) {
var n = this
, r = V(V({}, e._GetDefaultOptions()), i);
if (this._leftJoystick = !!t,
e._GlobalJoystickIndex++,
this._axisTargetedByLeftAndRight = la.X,
this._axisTargetedByUpAndDown = la.Y,
this.reverseLeftRight = !1,
this.reverseUpDown = !1,
this._touches = new Ei,
this.deltaPosition = x.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.msTouchAction = "none",
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 = r.limitToContainer,
this._joystickColor = r.color,
this.containerSize = r.containerSize,
this.puckSize = r.puckSize,
r.position && this.setPosition(r.position.x, r.position.y),
r.puckImage && this.setPuckImage(r.puckImage),
r.containerImage && this.setContainerImage(r.containerImage),
r.alwaysVisible && e._AlwaysVisibleSticks++,
this.alwaysVisible = r.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) {
n._onPointerDown(e)
}
,
this._onPointerMoveHandlerRef = function(e) {
n._onPointerMove(e)
}
,
this._onPointerUpHandlerRef = function(e) {
n._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() {
n._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)
, n = i.length();
n > this.containerSize && i.scaleInPlace(this.containerSize / n),
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 r = (this.reverseLeftRight ? -1 : 1) * this._deltaJoystickVector.x / this._inversedSensibility;
switch (this._axisTargetedByLeftAndRight) {
case la.X:
this.deltaPosition.x = Math.min(1, Math.max(-1, r));
break;
case la.Y:
this.deltaPosition.y = Math.min(1, Math.max(-1, r));
break;
case la.Z:
this.deltaPosition.z = Math.min(1, Math.max(-1, r))
}
var o = (this.reverseUpDown ? 1 : -1) * this._deltaJoystickVector.y / this._inversedSensibility;
switch (this._axisTargetedByUpAndDown) {
case la.X:
this.deltaPosition.x = Math.min(1, Math.max(-1, o));
break;
case la.Y:
this.deltaPosition.y = Math.min(1, Math.max(-1, o));
break;
case la.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 la.X:
case la.Y:
case la.Z:
this._axisTargetedByLeftAndRight = e;
break;
default:
this._axisTargetedByLeftAndRight = la.X
}
}
,
e.prototype.setAxisForUpDown = function(e) {
switch (e) {
case la.X:
case la.Y:
case la.Z:
this._axisTargetedByUpAndDown = e;
break;
default:
this._axisTargetedByUpAndDown = la.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, this._joystickPreviousPointerPos.y - this._clearPuckSizeOffset, this._clearPuckSize, this._clearPuckSize)
}
,
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.alwaysVisible && this._drawContainer(),
this.pressed && this._touches.forEach((function(i, n) {
n.pointerId === t._joystickPointerId ? (t.alwaysVisible || t._drawContainer(),
t._drawPuck(),
t._joystickPreviousPointerPos = t._joystickPointerPos.clone()) : (e._VJCanvasContext.clearRect(n.prevX - 44, n.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(n.x, n.y, 40, 0, 2 * Math.PI, !0),
e._VJCanvasContext.stroke(),
e._VJCanvasContext.closePath(),
n.prevX = n.x,
n.prevY = n.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)
}
,
e._GlobalJoystickIndex = 0,
e._AlwaysVisibleSticks = 0,
e
}();
aa.prototype.addVirtualJoystick = function() {
return this.add(new ha),
this
}
;
var ha = 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 = P.RotationYawPitchRoll(e.rotation.y, e.rotation.x, 0)
, n = x.TransformCoordinates(new x(this._leftjoystick.deltaPosition.x * t,this._leftjoystick.deltaPosition.y * t,this._leftjoystick.deltaPosition.z * t), i);
e.cameraDirection = e.cameraDirection.add(n),
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 ua(!0),
this._leftjoystick.setAxisForUpDown(la.Z),
this._leftjoystick.setAxisForLeftRight(la.X),
this._leftjoystick.setJoystickSensibility(.15),
this._rightjoystick = new ua(!1),
this._rightjoystick.setAxisForUpDown(la.X),
this._rightjoystick.setAxisForLeftRight(la.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
}();
Vo.FreeCameraVirtualJoystickInput = ha;
var da = function(e) {
function t(t, i, n, r) {
void 0 === r && (r = !0);
var o = e.call(this, t, i, n, r) || this;
return o._tmpUpVector = x.Zero(),
o._tmpTargetVector = x.Zero(),
o.cameraDirection = new x(0,0,0),
o.cameraRotation = new A(0,0),
o.ignoreParentScaling = !1,
o.updateUpVectorFromRotation = !1,
o._tmpQuaternion = new C,
o.rotation = new x(0,0,0),
o.speed = 2,
o.noRotationConstraint = !1,
o.invertRotation = !1,
o.inverseRotationSpeed = .2,
o.lockedTarget = null,
o._currentTarget = x.Zero(),
o._initialFocalDistance = 1,
o._viewMatrix = P.Zero(),
o._camMatrix = P.Zero(),
o._cameraTransformMatrix = P.Zero(),
o._cameraRotationMatrix = P.Zero(),
o._referencePoint = new x(0,0,1),
o._transformedReferencePoint = x.Zero(),
o._defaultUp = x.Up(),
o._cachedRotationZ = 0,
o._cachedQuaternionRotationZ = 0,
o
}
return U(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() {
return this.lockedTarget ? (this.lockedTarget.absolutePosition && this.lockedTarget.computeWorldMatrix(),
this.lockedTarget.absolutePosition || this.lockedTarget) : null
}
,
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 x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
this._cache.rotation = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
this._cache.rotationQuaternion = new C(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 += m),
this._referencePoint.normalize().scaleInPlace(this._initialFocalDistance),
P.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 && C.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(I.Matrix[0]),
x.TransformNormalToRef(this.cameraDirection, I.Matrix[0], I.Vector3[0]),
void this.position.addInPlace(I.Vector3[0]);
this.position.addInPlace(this.cameraDirection)
}
,
t.prototype._checkInputs = function() {
var t = this.invertRotation ? -this.inverseRotationSpeed : 1
, i = this._decideIfNeedsToMove()
, n = Math.abs(this.cameraRotation.x) > 0 || Math.abs(this.cameraRotation.y) > 0;
if (i && this._updatePosition(),
n) {
if (this.rotationQuaternion && this.rotationQuaternion.toEulerAnglesToRef(this.rotation),
this.rotation.x += this.cameraRotation.x * t,
this.rotation.y += this.cameraRotation.y * t,
!this.noRotationConstraint) {
var r = 1.570796;
this.rotation.x > r && (this.rotation.x = r),
this.rotation.x < -r && (this.rotation.x = -r)
}
this.rotationQuaternion && this.rotation.lengthSquared() && C.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion)
}
i && (Math.abs(this.cameraDirection.x) < this.speed * m && (this.cameraDirection.x = 0),
Math.abs(this.cameraDirection.y) < this.speed * m && (this.cameraDirection.y = 0),
Math.abs(this.cameraDirection.z) < this.speed * m && (this.cameraDirection.z = 0),
this.cameraDirection.scaleInPlace(this.inertia)),
n && (Math.abs(this.cameraRotation.x) < this.speed * m && (this.cameraRotation.x = 0),
Math.abs(this.cameraRotation.y) < this.speed * m && (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) : P.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix)
}
,
t.prototype._rotateUpVectorWithCameraRotationMatrix = function() {
return x.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),
x.TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint),
this.position.addToRef(this._transformedReferencePoint, this._currentTarget),
this.updateUpVectorFromRotation && (this.rotationQuaternion ? vn.Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector) : (C.FromEulerVectorToRef(this.rotation, this._tmpQuaternion),
vn.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 n = this.parent.getWorldMatrix();
x.TransformCoordinatesToRef(e, n, this._globalPosition),
x.TransformCoordinatesToRef(t, n, this._tmpTargetVector),
x.TransformNormalToRef(i, n, this._tmpUpVector),
this._markSyncedWithParent()
} else
this._globalPosition.copyFrom(e),
this._tmpTargetVector.copyFrom(t),
this._tmpUpVector.copyFrom(i);
this.getScene().useRightHandedSystem ? P.LookAtRHToRef(this._globalPosition, this._tmpTargetVector, this._tmpUpVector, this._viewMatrix) : P.LookAtLHToRef(this._globalPosition, this._tmpTargetVector, this._tmpUpVector, this._viewMatrix)
} else
this.getScene().useRightHandedSystem ? P.LookAtRHToRef(e, t, i, this._viewMatrix) : P.LookAtLHToRef(e, t, i, this._viewMatrix),
this.parent ? (n = this.parent.getWorldMatrix(),
this._viewMatrix.invert(),
this._viewMatrix.multiplyToRef(n, 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 !== Rr.RIG_MODE_NONE) {
var n = new t(e,this.position.clone(),this.getScene());
return n.isRigCamera = !0,
n.rigParent = this,
this.cameraRigMode !== Rr.RIG_MODE_VR && this.cameraRigMode !== Rr.RIG_MODE_WEBVR || (this.rotationQuaternion || (this.rotationQuaternion = new C),
n._cameraRigParams = {},
n.rotationQuaternion = new C),
n
}
return null
}
,
t.prototype._updateRigCameras = function() {
var t = this._rigCameras[0]
, i = this._rigCameras[1];
switch (this.computeWorldMatrix(),
this.cameraRigMode) {
case Rr.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
case Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
case Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
case Rr.RIG_MODE_STEREOSCOPIC_OVERUNDER:
case Rr.RIG_MODE_STEREOSCOPIC_INTERLACED:
var n = this.cameraRigMode === Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED ? 1 : -1
, r = this.cameraRigMode === Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED ? -1 : 1;
this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * n, t),
this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * r, i);
break;
case Rr.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 n = t._TargetFocalPoint.addInPlace(this.position);
P.TranslationToRef(-n.x, -n.y, -n.z, t._TargetTransformMatrix),
t._TargetTransformMatrix.multiplyToRef(P.RotationAxis(i.upVector, e), t._RigCamTransformMatrix),
P.TranslationToRef(n.x, n.y, n.z, t._TargetTransformMatrix),
t._RigCamTransformMatrix.multiplyToRef(t._TargetTransformMatrix, t._RigCamTransformMatrix),
x.TransformCoordinatesToRef(this.position, t._RigCamTransformMatrix, i.position),
i.setTarget(n)
}
,
t.prototype.getClassName = function() {
return "TargetCamera"
}
,
t._RigCamTransformMatrix = new P,
t._TargetTransformMatrix = new P,
t._TargetFocalPoint = new x,
k([De()], t.prototype, "rotation", void 0),
k([Ce()], t.prototype, "speed", void 0),
k([Ne("lockedTargetId")], t.prototype, "lockedTarget", void 0),
t
}(Rr)
, pa = function(e) {
function t(t, i, n, r) {
void 0 === r && (r = !0);
var o = e.call(this, t, i, n, r) || this;
return o.ellipsoid = new x(.5,1,.5),
o.ellipsoidOffset = new x(0,0,0),
o.checkCollisions = !1,
o.applyGravity = !1,
o._needMoveForGravity = !1,
o._oldPosition = x.Zero(),
o._diffPosition = x.Zero(),
o._newPosition = x.Zero(),
o._collisionMask = -1,
o._onCollisionPositionChange = function(e, t, i) {
var n;
void 0 === i && (i = null),
n = t,
o._newPosition.copyFrom(n),
o._newPosition.subtractToRef(o._oldPosition, o._diffPosition),
o._diffPosition.length() > vr.CollisionsEpsilon && (o.position.addInPlace(o._diffPosition),
o.onCollide && i && o.onCollide(i))
}
,
o.inputs = new aa(o),
o.inputs.addKeyboard().addMouse(),
o
}
return U(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
}),
t.prototype.attachControl = function(e, t) {
t = gi.BackCompatCameraNoPreventDefault(arguments),
this.inputs.attachElement(t)
}
,
t.prototype.detachControl = function() {
this.inputs.detachElement(),
this.cameraDirection = new x(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 ? x.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 = x.Zero(),
this._transformedDirection = x.Zero()),
this.inputs.checkInputs(),
e.prototype._checkInputs.call(this)
}
,
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"
}
,
k([De()], t.prototype, "ellipsoid", void 0),
k([De()], t.prototype, "ellipsoidOffset", void 0),
k([Ce()], t.prototype, "checkCollisions", void 0),
k([Ce()], t.prototype, "applyGravity", void 0),
t
}(da);
Xe.AddNodeConstructor("TouchCamera", (function(e, t) {
return function() {
return new fa(e,x.Zero(),t)
}
}
));
var fa = function(e) {
function t(t, i, n) {
var r = e.call(this, t, i, n) || this;
return r.inputs.addTouch(),
r._setupInputs(),
r
}
return U(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
}(pa);
Xe.AddNodeConstructor("ArcRotateCamera", (function(e, t) {
return function() {
return new _a(e,0,0,1,x.Zero(),t)
}
}
));
var _a = function(e) {
function t(t, i, n, r, o, a, s) {
void 0 === s && (s = !0);
var l = e.call(this, t, x.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 = x.Zero(),
l.panningInertia = .9,
l.zoomOnFactor = 1,
l.targetScreenOffset = A.Zero(),
l.allowUpsideDown = !0,
l.useInputToRestoreState = !0,
l._viewMatrix = new P,
l.panningAxis = new x(1,1,0),
l._transformedDirection = new x,
l.mapPanning = !1,
l.onMeshTargetChangedObservable = new h,
l.checkCollisions = !1,
l.collisionRadius = new x(.5,.5,.5),
l._previousPosition = x.Zero(),
l._collisionVelocity = x.Zero(),
l._newPosition = x.Zero(),
l._computationVector = x.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 n = Math.cos(l.alpha)
, r = 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 * n * a, l.radius * o, l.radius * r * 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 = x.Zero(),
o && l.setTarget(o),
l.alpha = i,
l.beta = n,
l.radius = r,
l.getViewMatrix(),
l.inputs = new Ko(l),
l.inputs.addKeyboard().addMouseWheel().addPointers(),
l
}
return U(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 P,
this._upToYMatrix = new P,
this._upVector = x.Zero()),
e.normalize(),
this._upVector.copyFrom(e),
this.setMatUp()
},
enumerable: !1,
configurable: !0
}),
t.prototype.setMatUp = function() {
P.RotationAlignToRef(x.UpReadOnly, this._upVector, this._yToUpMatrix),
P.RotationAlignToRef(this._upVector, x.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 co,
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 uo,
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 lo,
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 x(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, n) {
var r = this;
void 0 === i && (i = !0),
void 0 === n && (n = 2);
var o = arguments;
t = gi.BackCompatCameraNoPreventDefault(o),
this._useCtrlForPanning = i,
this._panningMouseButton = n,
"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() {
r.inertialAlphaOffset = 0,
r.inertialBetaOffset = 0,
r.inertialRadiusOffset = 0,
r.inertialPanningX = 0,
r.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.inertialAlphaOffset;
this.beta <= 0 && (t *= -1),
this.getScene().useRightHandedSystem && (t *= -1),
this.parent && this.parent._getWorldMatrixDeterminant() < 0 && (t *= -1),
this.alpha += t,
this.beta += this.inertialBetaOffset,
this.radius -= this.inertialRadiusOffset,
this.inertialAlphaOffset *= this.inertia,
this.inertialBetaOffset *= this.inertia,
this.inertialRadiusOffset *= this.inertia,
Math.abs(this.inertialAlphaOffset) < m && (this.inertialAlphaOffset = 0),
Math.abs(this.inertialBetaOffset) < m && (this.inertialBetaOffset = 0),
Math.abs(this.inertialRadiusOffset) < this.speed * m && (this.inertialRadiusOffset = 0)
}
if (0 !== this.inertialPanningX || 0 !== this.inertialPanningY) {
var i = new x(this.inertialPanningX,this.inertialPanningY,this.inertialPanningY);
this._viewMatrix.invertToRef(this._cameraTransformMatrix),
i.multiplyInPlace(this.panningAxis),
x.TransformNormalToRef(i, this._cameraTransformMatrix, this._transformedDirection),
!this.mapPanning && this.panningAxis.y || (this._transformedDirection.y = 0),
this._targetHost || (this.panningDistanceLimit ? (this._transformedDirection.addInPlace(this._target),
x.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 * m && (this.inertialPanningX = 0),
Math.abs(this.inertialPanningY) < this.speed * m && (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 || x.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, n) {
if (void 0 === t && (t = !1),
void 0 === i && (i = !1),
void 0 === n && (n = !1),
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 r = e
, o = this._getTargetPosition();
if (o && !i && o.equals(r))
return;
this._targetHost = null,
this._target = r,
this._targetBoundingCenter = null,
this.onMeshTargetChangedObservable.notifyObservers(null)
}
n || this.rebuildAnglesAndRadius()
}
,
t.prototype._getViewMatrix = function() {
var e = Math.cos(this.alpha)
, t = Math.sin(this.alpha)
, i = Math.cos(this.beta)
, n = Math.sin(this.beta);
0 === n && (n = 1e-4),
0 === this.radius && (this.radius = 1e-4);
var r = this._getTargetPosition();
if (this._computationVector.copyFromFloats(this.radius * e * n, this.radius * i, this.radius * t * n),
0 === this._upVector.x && 1 === this._upVector.y && 0 === this._upVector.z || x.TransformCoordinatesToRef(this._computationVector, this._yToUpMatrix, this._computationVector),
r.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 && n < 0 && (a = a.negate()),
this._computeViewMatrix(this._position, r, a),
this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x),
this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y)
}
return this._currentTarget = r,
this._viewMatrix
}
,
t.prototype.zoomOn = function(e, t) {
void 0 === t && (t = !1),
e = e || this.getScene().meshes;
var i = Vr.MinMax(e)
, n = x.Distance(i.min, i.max);
this.radius = n * this.zoomOnFactor,
this.focusOn({
min: i.min,
max: i.max,
distance: n
}, t)
}
,
t.prototype.focusOn = function(e, t) {
var i, n;
if (void 0 === t && (t = !1),
void 0 === e.min) {
var r = e || this.getScene().meshes;
i = Vr.MinMax(r),
n = x.Distance(i.min, i.max)
} else
i = e,
n = e.distance;
this._target = Vr.Center(i),
t || (this.maxZ = 2 * n)
}
,
t.prototype.createRigCamera = function(e, i) {
var n = 0;
switch (this.cameraRigMode) {
case Rr.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
case Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
case Rr.RIG_MODE_STEREOSCOPIC_OVERUNDER:
case Rr.RIG_MODE_STEREOSCOPIC_INTERLACED:
case Rr.RIG_MODE_VR:
n = this._cameraRigParams.stereoHalfAngle * (0 === i ? 1 : -1);
break;
case Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
n = this._cameraRigParams.stereoHalfAngle * (0 === i ? -1 : 1)
}
var r = new t(e,this.alpha + n,this.beta,this.radius,this._target,this.getScene());
return r._cameraRigParams = {},
r.isRigCamera = !0,
r.rigParent = this,
r.upVector = this.upVector,
r
}
,
t.prototype._updateRigCameras = function() {
var t = this._rigCameras[0]
, i = this._rigCameras[1];
switch (t.beta = i.beta = this.beta,
this.cameraRigMode) {
case Rr.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
case Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
case Rr.RIG_MODE_STEREOSCOPIC_OVERUNDER:
case Rr.RIG_MODE_STEREOSCOPIC_INTERLACED:
case Rr.RIG_MODE_VR:
t.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle,
i.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
break;
case Rr.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"
}
,
k([Ce()], t.prototype, "alpha", void 0),
k([Ce()], t.prototype, "beta", void 0),
k([Ce()], t.prototype, "radius", void 0),
k([De("target")], t.prototype, "_target", void 0),
k([Ne("targetHost")], t.prototype, "_targetHost", void 0),
k([Ce()], t.prototype, "inertialAlphaOffset", void 0),
k([Ce()], t.prototype, "inertialBetaOffset", void 0),
k([Ce()], t.prototype, "inertialRadiusOffset", void 0),
k([Ce()], t.prototype, "lowerAlphaLimit", void 0),
k([Ce()], t.prototype, "upperAlphaLimit", void 0),
k([Ce()], t.prototype, "lowerBetaLimit", void 0),
k([Ce()], t.prototype, "upperBetaLimit", void 0),
k([Ce()], t.prototype, "lowerRadiusLimit", void 0),
k([Ce()], t.prototype, "upperRadiusLimit", void 0),
k([Ce()], t.prototype, "inertialPanningX", void 0),
k([Ce()], t.prototype, "inertialPanningY", void 0),
k([Ce()], t.prototype, "pinchToPanMaxDistance", void 0),
k([Ce()], t.prototype, "panningDistanceLimit", void 0),
k([De()], t.prototype, "panningOriginTarget", void 0),
k([Ce()], t.prototype, "panningInertia", void 0),
k([Ce()], t.prototype, "zoomToMouseLocation", null),
k([Ce()], t.prototype, "zoomOnFactor", void 0),
k([Oe()], t.prototype, "targetScreenOffset", void 0),
k([Ce()], t.prototype, "allowUpsideDown", void 0),
k([Ce()], t.prototype, "useInputToRestoreState", void 0),
t
}(da);
Xe.AddNodeConstructor("DeviceOrientationCamera", (function(e, t) {
return function() {
return new ma(e,x.Zero(),t)
}
}
));
var ma = function(e) {
function t(t, i, n) {
var r = e.call(this, t, i, n) || this;
return r._tmpDragQuaternion = new C,
r._disablePointerInputWhenUsingDeviceOrientation = !0,
r._dragFactor = 0,
r._quaternionCache = new C,
r.inputs.addDeviceOrientation(),
r.inputs._deviceOrientationInput && r.inputs._deviceOrientationInput._onDeviceOrientationChangedObservable.addOnce((function() {
r._disablePointerInputWhenUsingDeviceOrientation && r.inputs._mouseInput && (r.inputs._mouseInput._allowCameraRotation = !1,
r.inputs._mouseInput.onPointerMovedObservable.add((function(e) {
0 != r._dragFactor && (r._initialQuaternion || (r._initialQuaternion = new C),
C.FromEulerAnglesToRef(0, e.offsetX * r._dragFactor, 0, r._tmpDragQuaternion),
r._initialQuaternion.multiplyToRef(r._tmpDragQuaternion, r._initialQuaternion))
}
)))
}
)),
r
}
return U(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 = vn.Y),
this.rotationQuaternion && (this._initialQuaternion || (this._initialQuaternion = new C),
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
}(pa)
, ga = function(e) {
function t(t) {
return e.call(this, t) || this
}
return U(t, e),
t.prototype.addKeyboard = function() {
return this.add(new qo),
this
}
,
t.prototype.addMouse = function() {
return this.add(new Zo),
this
}
,
t
}(ko)
, va = function(e) {
function t(t, i, n, r) {
void 0 === r && (r = !0);
var o = e.call(this, t, i, n, r) || this;
return o.ellipsoid = new x(1,1,1),
o.ellipsoidOffset = new x(0,0,0),
o.checkCollisions = !1,
o.applyGravity = !1,
o.cameraDirection = x.Zero(),
o._trackRoll = 0,
o.rollCorrect = 100,
o.bankedTurn = !1,
o.bankedTurnLimit = Math.PI / 2,
o.bankedTurnMultiplier = 1,
o._needMoveForGravity = !1,
o._oldPosition = x.Zero(),
o._diffPosition = x.Zero(),
o._newPosition = x.Zero(),
o._collisionMask = -1,
o._onCollisionPositionChange = function(e, t, i) {
var n;
void 0 === i && (i = null),
n = t,
o._newPosition.copyFrom(n),
o._newPosition.subtractToRef(o._oldPosition, o._diffPosition),
o._diffPosition.length() > vr.CollisionsEpsilon && (o.position.addInPlace(o._diffPosition),
o.onCollide && i && o.onCollide(i))
}
,
o.inputs = new ga(o),
o.inputs.addKeyboard().addMouse(),
o
}
return U(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 = gi.BackCompatCameraNoPreventDefault(arguments),
this.inputs.attachElement(t)
}
,
t.prototype.detachControl = function() {
this.inputs.detachElement(),
this.cameraDirection = new x(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 ? x.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 = x.Zero(),
this._transformedDirection = x.Zero()),
this.inputs.checkInputs(),
e.prototype._checkInputs.call(this)
}
,
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"
}
,
k([De()], t.prototype, "ellipsoid", void 0),
k([De()], t.prototype, "ellipsoidOffset", void 0),
k([Ce()], t.prototype, "checkCollisions", void 0),
k([Ce()], t.prototype, "applyGravity", void 0),
t
}(da)
, ya = function(e) {
function t(t) {
return e.call(this, t) || this
}
return U(t, e),
t.prototype.addKeyboard = function() {
return this.add(new Jo),
this
}
,
t.prototype.addMouseWheel = function() {
return this.add(new $o),
this
}
,
t.prototype.addPointers = function() {
return this.add(new ea),
this
}
,
t.prototype.addVRDeviceOrientation = function() {
return console.warn("DeviceOrientation support not yet implemented for FollowCamera."),
this
}
,
t
}(ko);
Xe.AddNodeConstructor("FollowCamera", (function(e, t) {
return function() {
return new Ta(e,x.Zero(),t)
}
}
)),
Xe.AddNodeConstructor("ArcFollowCamera", (function(e, t) {
return function() {
return new Ea(e,0,0,1,null,t)
}
}
));
var ba, Ta = function(e) {
function t(t, i, n, r) {
void 0 === r && (r = null);
var o = e.call(this, t, i, n) || 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 = r,
o.inputs = new ya(o),
o.inputs.addKeyboard().addMouseWheel().addPointers(),
o
}
return U(t, e),
t.prototype._follow = function(e) {
if (e) {
var t = I.Matrix[0];
e.absoluteRotationQuaternion.toRotationMatrix(t);
var i = Math.atan2(t.m[8], t.m[10])
, n = gi.ToRadians(this.rotationOffset) + i
, r = e.getAbsolutePosition()
, o = r.x + Math.sin(n) * this.radius
, a = r.z + Math.cos(n) * this.radius
, s = o - this.position.x
, l = r.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 x(this.position.x + u,this.position.y + h,this.position.z + d),
this.setTarget(r)
}
}
,
t.prototype.attachControl = function(e, t) {
t = gi.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"
}
,
k([Ce()], t.prototype, "radius", void 0),
k([Ce()], t.prototype, "lowerRadiusLimit", void 0),
k([Ce()], t.prototype, "upperRadiusLimit", void 0),
k([Ce()], t.prototype, "rotationOffset", void 0),
k([Ce()], t.prototype, "lowerRotationOffsetLimit", void 0),
k([Ce()], t.prototype, "upperRotationOffsetLimit", void 0),
k([Ce()], t.prototype, "heightOffset", void 0),
k([Ce()], t.prototype, "lowerHeightOffsetLimit", void 0),
k([Ce()], t.prototype, "upperHeightOffsetLimit", void 0),
k([Ce()], t.prototype, "cameraAcceleration", void 0),
k([Ce()], t.prototype, "maxCameraSpeed", void 0),
k([Ne("lockedTargetId")], t.prototype, "lockedTarget", void 0),
t
}(da), Ea = function(e) {
function t(t, i, n, r, o, a) {
var s = e.call(this, t, x.Zero(), a) || this;
return s.alpha = i,
s.beta = n,
s.radius = r,
s._cartesianCoordinates = x.Zero(),
s.setMeshTarget(o),
s
}
return U(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
}(da);
!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"
}(ba || (ba = {}));
var Sa, Aa, xa = function() {
function e() {}
return e.InitiateController = function(e) {
for (var t = 0, i = this._ControllerFactories; t < i.length; t++) {
var n = i[t];
if (n.canCreate(e))
return n.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
}(), Ra = function(e) {
function t(t) {
var i = e.call(this, t.id, t.index, t) || this;
return i.isXR = !1,
i._deviceRoomPosition = x.Zero(),
i._deviceRoomRotationQuaternion = new C,
i.devicePosition = x.Zero(),
i.deviceRotationQuaternion = new C,
i.deviceScaleFactor = 1,
i._trackPosition = !0,
i._maxRotationDistFromHeadset = Math.PI / 5,
i._draggedRoomRotation = 0,
i._leftHandSystemQuaternion = new C,
i._deviceToWorld = P.Identity(),
i._pointingPoseNode = null,
i._workingMatrix = P.Identity(),
i._meshAttachedObservable = new h,
i.type = zo.POSE_ENABLED,
i.controllerType = ba.GENERIC,
i.position = x.Zero(),
i.rotationQuaternion = new C,
i._calculatedPosition = x.Zero(),
i._calculatedRotation = new C,
C.RotationYawPitchRollToRef(Math.PI, 0, 0, i._leftHandSystemQuaternion),
i
}
return U(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 && E.LastCreatedScene && E.LastCreatedScene.activeCamera && E.LastCreatedScene.activeCamera.devicePosition) {
var t = E.LastCreatedScene.activeCamera;
if (t._computeDevicePosition(),
this._deviceToWorld.setTranslation(t.devicePosition),
t.deviceRotationQuaternion) {
t._deviceRoomRotationQuaternion.toEulerAnglesToRef(I.Vector3[0]);
var i = Math.atan2(Math.sin(I.Vector3[0].y - this._draggedRoomRotation), Math.cos(I.Vector3[0].y - this._draggedRoomRotation));
if (Math.abs(i) > this._maxRotationDistFromHeadset) {
var n = i - (i < 0 ? -this._maxRotationDistFromHeadset : this._maxRotationDistFromHeadset);
this._draggedRoomRotation += n;
var r = Math.sin(-n)
, o = Math.cos(-n);
this._calculatedPosition.x = this._calculatedPosition.x * o - this._calculatedPosition.z * r,
this._calculatedPosition.z = this._calculatedPosition.x * r + this._calculatedPosition.z * o
}
}
}
x.TransformCoordinatesToRef(this._calculatedPosition, this._deviceToWorld, this.devicePosition),
this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix),
C.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 C),
!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 _o(x.Zero(),new x(0,0,1),e);
var t = this._pointingPoseNode ? this._pointingPoseNode.getWorldMatrix() : this.mesh.getWorldMatrix()
, i = t.getTranslation()
, n = new x(0,0,-1)
, r = x.TransformNormal(n, t)
, o = x.Normalize(r);
return new _o(i,o,e)
}
,
t.POINTING_POSE = "POINTING_POSE",
t
}(zo);
!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"
}(Sa || (Sa = {})),
function(e) {
e[e.Up = 12] = "Up",
e[e.Down = 13] = "Down",
e[e.Left = 14] = "Left",
e[e.Right = 15] = "Right"
}(Aa || (Aa = {}));
var Ca, Pa, Ma = function(e) {
function t(t, i, n, r) {
void 0 === r && (r = !1);
var o = e.call(this, t, i, n, 0, 1, 2, 3) || this;
return o._leftTrigger = 0,
o._rightTrigger = 0,
o.onButtonDownObservable = new h,
o.onButtonUpObservable = new h,
o.onPadDownObservable = new h,
o.onPadUpObservable = new h,
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 = zo.XBOX,
o._isXboxOnePad = r,
o
}
return U(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, Sa.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, Sa.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, Sa.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, Sa.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, Sa.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, Sa.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, Sa.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, Sa.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, Sa.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, Sa.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, Aa.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, Aa.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, Aa.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, Aa.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
}(zo);
!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"
}(Ca || (Ca = {})),
function(e) {
e[e.Up = 12] = "Up",
e[e.Down = 13] = "Down",
e[e.Left = 14] = "Left",
e[e.Right = 15] = "Right"
}(Pa || (Pa = {}));
var Ia = function(e) {
function t(t, i, n) {
var r = e.call(this, t.replace("STANDARD GAMEPAD", "SONY PLAYSTATION DUALSHOCK"), i, n, 0, 1, 2, 3) || this;
return r._leftTrigger = 0,
r._rightTrigger = 0,
r.onButtonDownObservable = new h,
r.onButtonUpObservable = new h,
r.onPadDownObservable = new h,
r.onPadUpObservable = new h,
r._buttonCross = 0,
r._buttonCircle = 0,
r._buttonSquare = 0,
r._buttonTriangle = 0,
r._buttonShare = 0,
r._buttonOptions = 0,
r._buttonL1 = 0,
r._buttonR1 = 0,
r._buttonLeftStick = 0,
r._buttonRightStick = 0,
r._dPadUp = 0,
r._dPadDown = 0,
r._dPadLeft = 0,
r._dPadRight = 0,
r.type = zo.DUALSHOCK,
r
}
return U(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, Ca.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, Ca.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, Ca.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, Ca.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, Ca.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, Ca.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, Ca.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, Ca.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, Ca.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, Ca.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, Pa.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, Pa.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, Pa.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, Pa.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
}(zo)
, Oa = function() {
function e(e) {
var t = this;
if (this._scene = e,
this._babylonGamepads = [],
this._oneGamepadConnected = !1,
this._isMonitoring = !1,
this.onGamepadDisconnectedObservable = new h,
nt() ? (this._gamepadEventSupported = "GamepadEvent"in window,
this._gamepadSupport = navigator && (navigator.getGamepads || navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads)) : this._gamepadEventSupported = !1,
this.onGamepadConnectedObservable = new h((function(e) {
for (var i in t._babylonGamepads) {
var n = t._babylonGamepads[i];
n && n._isConnected && t.onGamepadConnectedObservable.notifyObserver(e, n)
}
}
)),
this._onGamepadConnectedEvent = function(e) {
var i, n = e.gamepad;
n.index in t._babylonGamepads && t._babylonGamepads[n.index].isConnected || (t._babylonGamepads[n.index] ? ((i = t._babylonGamepads[n.index]).browserGamepad = n,
i._isConnected = !0) : i = t._addNewGamepad(n),
t.onGamepadConnectedObservable.notifyObservers(i),
t._startMonitoringGamepads())
}
,
this._onGamepadDisconnectedEvent = function(e) {
var i = e.gamepad;
for (var n in t._babylonGamepads)
if (t._babylonGamepads[n].index === i.index) {
var r = t._babylonGamepads[n];
r._isConnected = !1,
t.onGamepadDisconnectedObservable.notifyObservers(r),
r.dispose && r.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 = zo.XBOX);
for (var t = 0, i = this._babylonGamepads; t < i.length; t++) {
var n = i[t];
if (n && n.type === e)
return n
}
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")
, n = -1 !== e.id.search("Xbox One");
return t = n || -1 !== e.id.search("Xbox 360") || -1 !== e.id.search("xinput") || -1 !== e.id.search("045e") && -1 === e.id.search("Surface Dock") ? new Ma(e.id,e.index,e,n) : i ? new Ia(e.id,e.index,e) : e.pose ? xa.InitiateController(e) : new Wo(e.id,e.index,e),
this._babylonGamepads[t.index] = t,
t
}
,
e.prototype._startMonitoringGamepads = function() {
this._isMonitoring || (this._isMonitoring = !0,
this._scene || 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) && (gi.Warn("Error updating gamepad ".concat(i.id)),
this._loggedErrors.push(i.index))
}
}
this._isMonitoring && !this._scene && vr.QueueNewFrame((function() {
e._checkGamepadsStatus()
}
))
}
,
e.prototype._updateGamepadObjects = function() {
for (var e = navigator.getGamepads ? navigator.getGamepads() : navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : [], 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 n = this._addNewGamepad(i);
this.onGamepadConnectedObservable.notifyObservers(n)
}
}
}
,
e
}();
Object.defineProperty(mn.prototype, "gamepadManager", {
get: function() {
if (!this._gamepadManager) {
this._gamepadManager = new Oa(this);
var e = this._getComponent(Wi.NAME_GAMEPAD);
e || (e = new Da(this),
this._addComponent(e))
}
return this._gamepadManager
},
enumerable: !0,
configurable: !0
}),
aa.prototype.addGamepad = function() {
return this.add(new ca),
this
}
,
Ko.prototype.addGamepad = function() {
return this.add(new Ho),
this
}
;
var Da = function() {
function e(e) {
this.name = Wi.NAME_GAMEPAD,
this.scene = e
}
return e.prototype.register = function() {
this.scene._beforeCameraUpdateStage.registerStep(Wi.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
}();
Xe.AddNodeConstructor("FreeCamera", (function(e, t) {
return function() {
return new Na(e,x.Zero(),t)
}
}
));
var Na = function(e) {
function t(t, i, n) {
var r = e.call(this, t, i, n) || this;
return r.inputs.addGamepad(),
r
}
return U(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
}(fa);
Rr._CreateDefaultParsedCamera = function(e, t) {
return new Na(e,x.Zero(),t)
}
,
Xe.AddNodeConstructor("GamepadCamera", (function(e, t) {
return function() {
return new La(e,x.Zero(),t)
}
}
));
var La = function(e) {
function t(t, i, n) {
return e.call(this, t, i, n) || this
}
return U(t, e),
t.prototype.getClassName = function() {
return "GamepadCamera"
}
,
t
}(Na);
Pt.ShadersStore.postprocessVertexShader = "attribute vec2 position;\nuniform vec2 scale;\nvarying vec2 vUV;\nconst 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;\ngl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";
var Fa = function() {
function e(e, t, i, n) {
this._textures = null,
this._attachments = null,
this._generateStencilBuffer = !1,
this._generateDepthBuffer = !1,
this._depthStencilTextureWithStencil = !1,
this._isMulti = e,
this._isCube = t,
this._size = i,
this._engine = n,
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, "samples", {
get: function() {
var e, t;
return null !== (t = null === (e = this.texture) || void 0 === e ? void 0 : e.samples) && void 0 !== t ? t : 1
},
enumerable: !1,
configurable: !0
}),
e.prototype.setSamples = function(e, t, i) {
return void 0 === t && (t = !0),
void 0 === i && (i = !1),
this.samples !== e || i ? this._isMulti ? this._engine.updateMultipleRenderTargetTextureSampleCount(this, e, t) : this._engine.updateRenderTargetTextureSampleCount(this, e) : e
}
,
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.createDepthStencilTexture = function(e, t, i, n, r) {
var o;
return void 0 === e && (e = 0),
void 0 === t && (t = !0),
void 0 === i && (i = !1),
void 0 === n && (n = 1),
void 0 === r && (r = a.TEXTUREFORMAT_DEPTH32_FLOAT),
null === (o = this._depthStencilTexture) || void 0 === o || o.dispose(),
this._depthStencilTextureWithStencil = i,
this._depthStencilTexture = this._engine.createDepthStencilTexture(this._size, {
bilinearFiltering: t,
comparisonFunction: e,
generateStencil: i,
isCube: this._isCube,
samples: n,
depthTextureFormat: r
}, 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, n, r, o, a = null;
if (this._isMulti) {
var s = this.textures;
if (s && s.length > 0) {
var l = !1
, c = s.length
, u = s[s.length - 1]._source;
u !== At.Depth && u !== At.DepthStencil || (l = !0,
c--);
for (var h = [], d = [], p = 0; p < c; ++p) {
var f = s[p];
h.push(f.samplingMode),
d.push(f.type)
}
var _ = {
samplingModes: h,
generateMipMaps: s[0].generateMipMaps,
generateDepthBuffer: this._generateDepthBuffer,
generateStencilBuffer: this._generateStencilBuffer,
generateDepthTexture: l,
types: d,
textureCount: c
}
, m = {
width: this.width,
height: this.height
};
a = this._engine.createMultipleRenderTarget(m, _)
}
} else {
var g = {};
g.generateDepthBuffer = this._generateDepthBuffer,
g.generateMipMaps = null !== (t = null === (e = this.texture) || void 0 === e ? void 0 : e.generateMipMaps) && void 0 !== t && t,
g.generateStencilBuffer = this._generateStencilBuffer,
g.samplingMode = null === (i = this.texture) || void 0 === i ? void 0 : i.samplingMode,
g.type = null === (n = this.texture) || void 0 === n ? void 0 : n.type,
g.format = null === (r = this.texture) || void 0 === r ? void 0 : r.format,
this.isCube ? a = this._engine.createRenderTargetCubeTexture(this.width, g) : (m = {
width: this.width,
height: this.height,
layers: this.is2DArray ? null === (o = this.texture) || void 0 === o ? void 0 : o.depth : void 0
},
a = this._engine.createRenderTargetTexture(m, g)),
a.texture.isReady = !0
}
return a
}
,
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
}()
, wa = function(e) {
function t(t, i, n, r, o) {
var a = e.call(this, t, i, n, r) || this;
return a._framebuffer = null,
a._depthStencilBuffer = null,
a._MSAAFramebuffer = null,
a._colorTextureArray = null,
a._depthStencilTextureArray = null,
a._context = o,
a
}
return U(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
, n = this._depthStencilBuffer
, r = t._framebuffer;
t._depthStencilBuffer && i.deleteRenderbuffer(t._depthStencilBuffer),
t._depthStencilBuffer = this._depthStencilBuffer,
this._engine._bindUnboundFramebuffer(r),
i.framebufferRenderbuffer(i.FRAMEBUFFER, i.DEPTH_ATTACHMENT, i.RENDERBUFFER, n),
this._engine._bindUnboundFramebuffer(null)
}
,
t.prototype._bindTextureRenderTarget = function(e, t, i, n) {
if (void 0 === t && (t = 0),
void 0 === i && (i = -1),
void 0 === n && (n = 0),
e._hardwareTexture) {
var r = this._context
, o = this._framebuffer
, a = this._engine._currentFramebuffer;
this._engine._bindUnboundFramebuffer(o);
var s = r[this._engine.webGLVersion > 1 ? "COLOR_ATTACHMENT" + t : "COLOR_ATTACHMENT" + t + "_WEBGL"]
, l = -1 !== i ? r.TEXTURE_CUBE_MAP_POSITIVE_X + i : r.TEXTURE_2D;
r.framebufferTexture2D(r.FRAMEBUFFER, s, l, e._hardwareTexture.underlyingResource, n),
this._engine._bindUnboundFramebuffer(a)
}
}
,
t.prototype.setTexture = function(t, i, n) {
void 0 === i && (i = 0),
void 0 === n && (n = !0),
e.prototype.setTexture.call(this, t, i, n),
this._bindTextureRenderTarget(t, i)
}
,
t.prototype.dispose = function(t) {
void 0 === t && (t = !1);
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
}(Fa);
Ht.prototype._createHardwareRenderTargetWrapper = function(e, t, i) {
var n = new wa(e,t,i,this,this._gl);
return this._renderTargetWrapperCache.push(n),
n
}
,
Ht.prototype.createRenderTargetTexture = function(e, t) {
var i = this._createHardwareRenderTargetWrapper(!1, !1, e)
, n = {};
void 0 !== t && "object" == typeof t ? (n.generateDepthBuffer = !!t.generateDepthBuffer,
n.generateStencilBuffer = !!t.generateStencilBuffer) : (n.generateDepthBuffer = !0,
n.generateStencilBuffer = !1);
var r = this._createInternalTexture(e, t, !0, At.RenderTarget)
, o = e.width || e
, a = e.height || e
, s = this._currentFramebuffer
, l = this._gl
, c = l.createFramebuffer();
return this._bindUnboundFramebuffer(c),
i._depthStencilBuffer = this._setupFramebufferDepthAttachments(!!n.generateStencilBuffer, n.generateDepthBuffer, o, a),
r.is2DArray || l.framebufferTexture2D(l.FRAMEBUFFER, l.COLOR_ATTACHMENT0, l.TEXTURE_2D, r._hardwareTexture.underlyingResource, 0),
this._bindUnboundFramebuffer(s),
i._framebuffer = c,
i._generateDepthBuffer = n.generateDepthBuffer,
i._generateStencilBuffer = !!n.generateStencilBuffer,
i.setTextures(r),
i
}
,
Ht.prototype.createDepthStencilTexture = function(e, t, i) {
if (t.isCube) {
var n = e.width || e;
return this._createDepthStencilCubeTexture(n, t, i)
}
return this._createDepthStencilTexture(e, t, i)
}
,
Ht.prototype._createDepthStencilTexture = function(e, t, i) {
var n = this._gl
, r = e.layers || 0
, o = 0 !== r ? n.TEXTURE_2D_ARRAY : n.TEXTURE_2D
, s = new Lt(this,At.DepthStencil);
if (!this._caps.depthTextureExtension)
return K.Error("Depth texture is not supported by your browser or hardware."),
s;
var l = V({
bilinearFiltering: !1,
comparisonFunction: 0,
generateStencil: !1
}, t);
this._bindTextureDirectly(o, s, !0),
this._setupDepthStencilTexture(s, e, l.generateStencil, 0 !== l.comparisonFunction && l.bilinearFiltering, l.comparisonFunction),
s.format = l.generateStencil ? a.TEXTUREFORMAT_DEPTH24_STENCIL8 : a.TEXTUREFORMAT_DEPTH24,
i._depthStencilTexture = s,
i._depthStencilTextureWithStencil = l.generateStencil;
var c = l.generateStencil ? n.UNSIGNED_INT_24_8 : n.UNSIGNED_INT
, u = l.generateStencil ? n.DEPTH_STENCIL : n.DEPTH_COMPONENT
, h = u;
return this.webGLVersion > 1 && (h = l.generateStencil ? n.DEPTH24_STENCIL8 : n.DEPTH_COMPONENT24),
s.is2DArray ? n.texImage3D(o, 0, h, s.width, s.height, r, 0, u, c, null) : n.texImage2D(o, 0, h, s.width, s.height, 0, u, c, null),
this._bindTextureDirectly(o, null),
this._internalTexturesCache.push(s),
s
}
,
Ht.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 n = e.texture._hardwareTexture;
if (n._MSAARenderBuffer && (i.deleteRenderbuffer(n._MSAARenderBuffer),
n._MSAARenderBuffer = null),
t > 1 && i.renderbufferStorageMultisample) {
var r = i.createFramebuffer();
if (!r)
throw new Error("Unable to create multi sampled framebuffer");
e._MSAAFramebuffer = r,
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");
n._MSAARenderBuffer = o
} else
this._bindUnboundFramebuffer(e._framebuffer);
return e.texture.samples = t,
e._depthStencilBuffer = this._setupFramebufferDepthAttachments(e._generateStencilBuffer, e._generateDepthBuffer, e.texture.width, e.texture.height, t),
this._bindUnboundFramebuffer(null),
t
}
;
var Ba = function() {
function e(e, t, i, n, r, o, s, l, c, u, d, p, f, _, m) {
void 0 === s && (s = a.TEXTURE_NEAREST_SAMPLINGMODE),
void 0 === u && (u = null),
void 0 === d && (d = a.TEXTURETYPE_UNSIGNED_INT),
void 0 === p && (p = "postprocess"),
void 0 === _ && (_ = !1),
void 0 === m && (m = a.TEXTUREFORMAT_RGBA),
this._parentContainer = null,
this.width = -1,
this.height = -1,
this.nodeMaterialSource = null,
this._outputTexture = null,
this.autoClear = !0,
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 bi(2),
this._textureCache = [],
this._currentRenderTextureInd = 0,
this._scaleRatio = new A(1,1),
this._texelSize = A.Zero(),
this.onActivateObservable = new h,
this.onSizeChangedObservable = new h,
this.onApplyObservable = new h,
this.onBeforeRenderObservable = new h,
this.onAfterRenderObservable = new h,
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 = r,
this.renderTargetSamplingMode = s || a.TEXTURE_NEAREST_SAMPLINGMODE,
this._reusable = c || !1,
this._textureType = d,
this._textureFormat = m,
this._samplers = n || [],
this._samplers.push("textureSampler"),
this._fragmentUrl = t,
this._vertexUrl = p,
this._parameters = i || [],
this._parameters.push("scale"),
this._indexParameters = f,
this._drawWrapper = new Gt(this._engine),
_ || this.updateEffect(u)
}
return 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.samples !== t._samples && t._engine.updateRenderTargetTextureSampleCount(e, 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 bi(2)),
this._shareOutputWithPostProcess = null
}
,
e.prototype.updateEffect = function(e, t, i, n, r, o, a, s) {
void 0 === e && (e = null),
void 0 === t && (t = null),
void 0 === i && (i = null),
this._postProcessDefines = e,
this._drawWrapper.effect = this._engine.createEffect({
vertex: null != a ? a : this._vertexUrl,
fragment: null != s ? s : this._fragmentUrl
}, ["position"], t || this._parameters, i || this._samplers, null !== e ? e : "", void 0, r, o, n || this._indexParameters)
}
,
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 n = 0; n < this._textureCache.length; n++)
if (this._textureCache[n].texture.width === e.width && this._textureCache[n].texture.height === e.height && this._textureCache[n].postProcessChannel === i && this._textureCache[n].texture._generateDepthBuffer === t.generateDepthBuffer)
return this._textureCache[n].texture;
var r = this._engine.createRenderTargetTexture(e, t);
return this._textureCache.push({
texture: r,
postProcessChannel: i,
lastUsedRenderId: -1
}),
r
}
,
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, n = 0; n < this._textures.length; n++)
if (this._textures.data[n] === 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, n, r) {
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: n,
generateDepthBuffer: r || o === this,
generateStencilBuffer: (r || o === this) && this._engine.isStencilEnable,
samplingMode: this.renderTargetSamplingMode,
type: this._textureType,
format: this._textureFormat
};
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 n, r, 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 ? vr.GetExponentOfTwo(f, c, this.scaleMode) : f),
this._options.height || (_ = l.needPOTTextures ? vr.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 === (r = (n = this._engine)._debugInsertMarker) || void 0 === r || r.call(n, "post process ".concat(this.name, " input")),
this.onActivateObservable.notifyObservers(e),
this.autoClear && this.alphaMode === a.ALPHA_DISABLE && 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 e, t;
return (null === (e = this._drawWrapper.effect) || void 0 === e ? void 0 : e.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),
t = this._shareOutputWithPostProcess ? this._shareOutputWithPostProcess.inputTexture : this._forcedOutputTexture ? this._forcedOutputTexture : this.inputTexture,
this.externalTextureSamplerBinding || this._drawWrapper.effect._bindTexture("textureSampler", null == t ? void 0 : t.texture),
this._drawWrapper.effect.setVector2("scale", this._scaleRatio),
this.onApplyObservable.notifyObservers(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 n = this._camera._getFirstPostProcess();
n && n.markTextureDirty()
}
this.onActivateObservable.clear(),
this.onAfterRenderObservable.clear(),
this.onApplyObservable.clear(),
this.onBeforeRenderObservable.clear(),
this.onSizeChangedObservable.clear()
}
}
,
e.prototype.serialize = function() {
var e = Ge.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 n = b(e.customType);
if (!n || !n._Parse)
return null;
var r = t ? t.getCameraById(e.cameraId) : null;
return n._Parse(e, r, t, i)
}
,
e._Parse = function(t, i, n, r) {
return Ge.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, n, r)
}
,
k([Ce()], e.prototype, "uniqueId", void 0),
k([Ce()], e.prototype, "name", void 0),
k([Ce()], e.prototype, "width", void 0),
k([Ce()], e.prototype, "height", void 0),
k([Ce()], e.prototype, "renderTargetSamplingMode", void 0),
k([Fe()], e.prototype, "clearColor", void 0),
k([Ce()], e.prototype, "autoClear", void 0),
k([Ce()], e.prototype, "alphaMode", void 0),
k([Ce()], e.prototype, "alphaConstants", void 0),
k([Ce()], e.prototype, "enablePixelPerfectMode", void 0),
k([Ce()], e.prototype, "forceFullscreenViewport", void 0),
k([Ce()], e.prototype, "scaleMode", void 0),
k([Ce()], e.prototype, "alwaysForcePOT", void 0),
k([Ce("samples")], e.prototype, "_samples", void 0),
k([Ce()], e.prototype, "adaptScaleToCurrentViewport", void 0),
e
}();
y("BABYLON.PostProcess", Ba);
Pt.ShadersStore.passPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";
Pt.ShadersStore.passCubePixelShader = "varying vec2 vUV;\nuniform samplerCube textureSampler;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{\nvec2 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 Ua = function(e) {
function t(t, i, n, r, o, s, l, c) {
return void 0 === n && (n = null),
void 0 === l && (l = a.TEXTURETYPE_UNSIGNED_INT),
void 0 === c && (c = !1),
e.call(this, t, "pass", null, null, i, n, r, o, s, void 0, l, void 0, null, c) || this
}
return U(t, e),
t.prototype.getClassName = function() {
return "PassPostProcess"
}
,
t._Parse = function(e, i, n, r) {
return Ge.Parse((function() {
return new t(e.name,e.options,i,e.renderTargetSamplingMode,e._engine,e.reusable)
}
), e, n, r)
}
,
t
}(Ba);
y("BABYLON.PassPostProcess", Ua);
var Va = function(e) {
function t(t, i, n, r, o, s, l, c) {
void 0 === n && (n = null),
void 0 === l && (l = a.TEXTURETYPE_UNSIGNED_INT),
void 0 === c && (c = !1);
var u = e.call(this, t, "passCube", null, null, i, n, r, o, s, "#define POSITIVEX", l, void 0, null, c) || this;
return u._face = 0,
u
}
return U(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, n, r) {
return Ge.Parse((function() {
return new t(e.name,e.options,i,e.renderTargetSamplingMode,e._engine,e.reusable)
}
), e, n, r)
}
,
t
}(Ba);
vr._RescalePostProcessFactory = function(e) {
return new Ua("rescale",1,null,a.TEXTURE_BILINEAR_SAMPLINGMODE,e,!1,a.TEXTURETYPE_UNSIGNED_INT)
}
;
Pt.ShadersStore.anaglyphPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D leftSampler;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec4 leftFrag=texture2D(leftSampler,vUV);\nleftFrag=vec4(1.0,leftFrag.g,leftFrag.b,1.0);\nvec4 rightFrag=texture2D(textureSampler,vUV);\nrightFrag=vec4(rightFrag.r,1.0,1.0,1.0);\ngl_FragColor=vec4(rightFrag.rgb*leftFrag.rgb,1.0);\n}";
var ka = function(e) {
function t(t, i, n, r, o, a) {
var s = e.call(this, t, "anaglyph", null, ["leftSampler"], i, n[1], r, o, a) || this;
return s._passedProcess = n[0]._rigPostProcess,
s.onApplyObservable.add((function(e) {
e.setTextureFromPostProcess("leftSampler", s._passedProcess)
}
)),
s
}
return U(t, e),
t.prototype.getClassName = function() {
return "AnaglyphPostProcess"
}
,
t
}(Ba);
function Ga(e) {
e._rigCameras[0]._rigPostProcess = new Ua(e.name + "_passthru",1,e._rigCameras[0]),
e._rigCameras[1]._rigPostProcess = new ka(e.name + "_anaglyph",1,e._rigCameras)
}
y("BABYLON.AnaglyphPostProcess", ka),
Xe.AddNodeConstructor("AnaglyphArcRotateCamera", (function(e, t, i) {
return function() {
return new za(e,0,0,1,x.Zero(),i.interaxial_distance,t)
}
}
));
var za = function(e) {
function t(t, i, n, r, o, a, s) {
var l = e.call(this, t, i, n, r, o, s) || this;
return l._setRigMode = Ga.bind(null, l),
l.interaxialDistance = a,
l.setCameraRigMode(Rr.RIG_MODE_STEREOSCOPIC_ANAGLYPH, {
interaxialDistance: a
}),
l
}
return U(t, e),
t.prototype.getClassName = function() {
return "AnaglyphArcRotateCamera"
}
,
t
}(_a);
Xe.AddNodeConstructor("AnaglyphFreeCamera", (function(e, t, i) {
return function() {
return new Wa(e,x.Zero(),i.interaxial_distance,t)
}
}
));
var Wa = function(e) {
function t(t, i, n, r) {
var o = e.call(this, t, i, r) || this;
return o._setRigMode = Ga.bind(null, o),
o.interaxialDistance = n,
o.setCameraRigMode(Rr.RIG_MODE_STEREOSCOPIC_ANAGLYPH, {
interaxialDistance: n
}),
o
}
return U(t, e),
t.prototype.getClassName = function() {
return "AnaglyphFreeCamera"
}
,
t
}(pa);
Xe.AddNodeConstructor("AnaglyphGamepadCamera", (function(e, t, i) {
return function() {
return new Ha(e,x.Zero(),i.interaxial_distance,t)
}
}
));
var Ha = function(e) {
function t(t, i, n, r) {
var o = e.call(this, t, i, r) || this;
return o._setRigMode = Ga.bind(null, o),
o.interaxialDistance = n,
o.setCameraRigMode(Rr.RIG_MODE_STEREOSCOPIC_ANAGLYPH, {
interaxialDistance: n
}),
o
}
return U(t, e),
t.prototype.getClassName = function() {
return "AnaglyphGamepadCamera"
}
,
t
}(La);
Xe.AddNodeConstructor("AnaglyphUniversalCamera", (function(e, t, i) {
return function() {
return new Xa(e,x.Zero(),i.interaxial_distance,t)
}
}
));
var Xa = function(e) {
function t(t, i, n, r) {
var o = e.call(this, t, i, r) || this;
return o._setRigMode = Ga.bind(null, o),
o.interaxialDistance = n,
o.setCameraRigMode(Rr.RIG_MODE_STEREOSCOPIC_ANAGLYPH, {
interaxialDistance: n
}),
o
}
return U(t, e),
t.prototype.getClassName = function() {
return "AnaglyphUniversalCamera"
}
,
t
}(Na);
Pt.ShadersStore.stereoscopicInterlacePixelShader = "const vec3 TWO=vec3(2.0,2.0,2.0);\nvarying vec2 vUV;\nuniform sampler2D camASampler;\nuniform sampler2D textureSampler;\nuniform vec2 stepSize;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nbool useCamA;\nbool useCamB;\nvec2 texCoord1;\nvec2 texCoord2;\nvec3 frag1;\nvec3 frag2;\n#ifdef IS_STEREOSCOPIC_HORIZ\nuseCamB=vUV.x>0.5;\nuseCamA=!useCamB;\ntexCoord1=vec2(useCamB ? (vUV.x-0.5)*2.0 : vUV.x*2.0,vUV.y);\ntexCoord2=vec2(texCoord1.x+stepSize.x,vUV.y);\n#else\n#ifdef IS_STEREOSCOPIC_INTERLACED\nfloat rowNum=floor(vUV.y/stepSize.y);\nuseCamA=mod(rowNum,2.0)==1.0;\nuseCamB=mod(rowNum,2.0)==0.0;\ntexCoord1=vec2(vUV.x,vUV.y);\ntexCoord2=vec2(vUV.x,vUV.y);\n#else\nuseCamB=vUV.y>0.5;\nuseCamA=!useCamB;\ntexCoord1=vec2(vUV.x,useCamB ? (vUV.y-0.5)*2.0 : vUV.y*2.0);\ntexCoord2=vec2(vUV.x,texCoord1.y+stepSize.y);\n#endif\n#endif\nif (useCamB){\nfrag1=texture2D(textureSampler,texCoord1).rgb;\nfrag2=texture2D(textureSampler,texCoord2).rgb;\n}else if (useCamA){\nfrag1=texture2D(camASampler ,texCoord1).rgb;\nfrag2=texture2D(camASampler ,texCoord2).rgb;\n}else {\ndiscard;\n}\ngl_FragColor=vec4((frag1+frag2)/TWO,1.0);\n}\n";
var ja = function(e) {
function t(t, i, n, r, o, a, s) {
var l = e.call(this, t, "stereoscopicInterlace", ["stepSize"], ["camASampler"], 1, i[1], o, a, s, r ? "#define IS_STEREOSCOPIC_INTERLACED 1" : n ? "#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 U(t, e),
t.prototype.getClassName = function() {
return "StereoscopicInterlacePostProcessI"
}
,
t
}(Ba)
, Ya = function(e) {
function t(t, i, n, r, o, a) {
var s = e.call(this, t, "stereoscopicInterlace", ["stepSize"], ["camASampler"], 1, i[1], r, o, a, n ? "#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 U(t, e),
t.prototype.getClassName = function() {
return "StereoscopicInterlacePostProcess"
}
,
t
}(Ba);
function Ka(e) {
var t = e.cameraRigMode === Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL || e.cameraRigMode === Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED
, i = e.cameraRigMode === Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
e.cameraRigMode === Rr.RIG_MODE_STEREOSCOPIC_INTERLACED ? (e._rigCameras[0]._rigPostProcess = new Ua(e.name + "_passthru",1,e._rigCameras[0]),
e._rigCameras[1]._rigPostProcess = new ja(e.name + "_stereoInterlace",e._rigCameras,!1,!0)) : (e._rigCameras[i ? 1 : 0].viewport = new xr(0,0,t ? .5 : 1,t ? 1 : .5),
e._rigCameras[i ? 0 : 1].viewport = new xr(t ? .5 : 0,t ? 0 : .5,t ? .5 : 1,t ? 1 : .5))
}
Xe.AddNodeConstructor("StereoscopicArcRotateCamera", (function(e, t, i) {
return function() {
return new Qa(e,0,0,1,x.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)
}
}
));
var Qa = function(e) {
function t(t, i, n, r, o, a, s, l) {
var c = e.call(this, t, i, n, r, o, l) || this;
return c._setRigMode = Ka.bind(null, c),
c.interaxialDistance = a,
c.isStereoscopicSideBySide = s,
c.setCameraRigMode(s ? Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : Rr.RIG_MODE_STEREOSCOPIC_OVERUNDER, {
interaxialDistance: a
}),
c
}
return U(t, e),
t.prototype.getClassName = function() {
return "StereoscopicArcRotateCamera"
}
,
t
}(_a);
Xe.AddNodeConstructor("StereoscopicFreeCamera", (function(e, t, i) {
return function() {
return new qa(e,x.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)
}
}
));
var qa = function(e) {
function t(t, i, n, r, o) {
var a = e.call(this, t, i, o) || this;
return a._setRigMode = Ka.bind(null, a),
a.interaxialDistance = n,
a.isStereoscopicSideBySide = r,
a.setCameraRigMode(r ? Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : Rr.RIG_MODE_STEREOSCOPIC_OVERUNDER, {
interaxialDistance: n
}),
a
}
return U(t, e),
t.prototype.getClassName = function() {
return "StereoscopicFreeCamera"
}
,
t
}(pa);
Xe.AddNodeConstructor("StereoscopicGamepadCamera", (function(e, t, i) {
return function() {
return new Za(e,x.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)
}
}
));
var Za = function(e) {
function t(t, i, n, r, o) {
var a = e.call(this, t, i, o) || this;
return a._setRigMode = Ka.bind(null, a),
a.interaxialDistance = n,
a.isStereoscopicSideBySide = r,
a.setCameraRigMode(r ? Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : Rr.RIG_MODE_STEREOSCOPIC_OVERUNDER, {
interaxialDistance: n
}),
a
}
return U(t, e),
t.prototype.getClassName = function() {
return "StereoscopicGamepadCamera"
}
,
t
}(La);
Xe.AddNodeConstructor("StereoscopicFreeCamera", (function(e, t, i) {
return function() {
return new Ja(e,x.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)
}
}
));
var Ja = function(e) {
function t(t, i, n, r, o) {
var a = e.call(this, t, i, o) || this;
return a._setRigMode = Ka.bind(null, a),
a.interaxialDistance = n,
a.isStereoscopicSideBySide = r,
a.setCameraRigMode(r ? Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : Rr.RIG_MODE_STEREOSCOPIC_OVERUNDER, {
interaxialDistance: n
}),
a
}
return U(t, e),
t.prototype.getClassName = function() {
return "StereoscopicUniversalCamera"
}
,
t
}(Na)
, $a = function(e) {
function t(t, i, n, r, o) {
void 0 === r && (r = 1),
void 0 === o && (o = .065);
var a = e.call(this, t, i, n) || this;
return a._distanceBetweenEyes = o,
a._distanceToProjectionPlane = r,
a.setCameraRigMode(Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL, {
stereoHalfAngle: 0
}),
a._cameraRigParams.stereoHalfAngle = 0,
a._cameraRigParams.interaxialDistance = o,
a
}
return U(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 da(e,x.Zero(),this.getScene())
, i = new yr("tm_" + e,this.getScene());
return t.parent = i,
i.setPivotMatrix(P.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
, n = i / this.distanceToProjectionPlane;
e.position.copyFrom(this.position),
e.position.addInPlaceFromFloats(0 === t ? -i : i, 0, -this._distanceToProjectionPlane);
var r = e.parent
, o = r.getPivotMatrix();
o.setTranslationFromFloats(0 === t ? i : -i, 0, 0),
o.setRowFromFloats(2, 0 === t ? n : -n, 0, 1, 0),
r.setPivotMatrix(o, !1)
}
,
t.prototype._setRigMode = function() {
this._rigCameras[0].viewport = new xr(0,0,.5,1),
this._rigCameras[1].viewport = new xr(.5,0,.5,1);
for (var e = 0; e < this._rigCameras.length; e++)
this._updateCamera(this._rigCameras[e], e)
}
,
t
}(Na);
Xe.AddNodeConstructor("VirtualJoysticksCamera", (function(e, t) {
return function() {
return new es(e,x.Zero(),t)
}
}
));
var es = function(e) {
function t(t, i, n) {
var r = e.call(this, t, i, n) || this;
return r.inputs.addVirtualJoystick(),
r
}
return U(t, e),
t.prototype.getClassName = function() {
return "VirtualJoysticksCamera"
}
,
t
}(pa)
, ts = 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 P.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 P.Translation(-e, 0, 0)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "leftPreViewMatrix", {
get: function() {
return P.Translation(.5 * this.interpupillaryDistance, 0, 0)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "rightPreViewMatrix", {
get: function() {
return P.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
}();
Pt.ShadersStore.vrDistortionCorrectionPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 LensCenter;\nuniform vec2 Scale;\nuniform vec2 ScaleIn;\nuniform vec4 HmdWarpParam;\nvec2 HmdWarp(vec2 in01) {\nvec2 theta=(in01-LensCenter)*ScaleIn; \nfloat rSq=theta.x*theta.x+theta.y*theta.y;\nvec2 rvector=theta*(HmdWarpParam.x+HmdWarpParam.y*rSq+HmdWarpParam.z*rSq*rSq+HmdWarpParam.w*rSq*rSq*rSq);\nreturn LensCenter+Scale*rvector;\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec2 tc=HmdWarp(vUV);\nif (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);\nelse{\ngl_FragColor=texture2D(textureSampler,tc);\n}\n}";
var is = function(e) {
function t(t, i, n, r) {
var o = e.call(this, t, "vrDistortionCorrection", ["LensCenter", "Scale", "ScaleIn", "HmdWarpParam"], null, r.postProcessScaleFactor, i, io.BILINEAR_SAMPLINGMODE) || this;
return o._isRightEye = n,
o._distortionFactors = r.distortionK,
o._postProcessScaleFactor = r.postProcessScaleFactor,
o._lensCenterOffset = r.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 U(t, e),
t.prototype.getClassName = function() {
return "VRDistortionCorrectionPostProcess"
}
,
t
}(Ba);
Pt.ShadersStore.vrMultiviewToSingleviewPixelShader = "precision mediump sampler2DArray;\nvarying vec2 vUV;\nuniform sampler2DArray multiviewSampler;\nuniform int imageIndex;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\ngl_FragColor=texture2D(multiviewSampler,vec3(vUV,imageIndex));\n}",
Ht.prototype.createRenderTargetCubeTexture = function(e, t) {
var i = this._createHardwareRenderTargetWrapper(!1, !0, e)
, n = V({
generateMipMaps: !0,
generateDepthBuffer: !0,
generateStencilBuffer: !1,
type: a.TEXTURETYPE_UNSIGNED_INT,
samplingMode: a.TEXTURE_TRILINEAR_SAMPLINGMODE,
format: a.TEXTUREFORMAT_RGBA
}, t);
n.generateStencilBuffer = n.generateDepthBuffer && n.generateStencilBuffer,
(n.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (n.type !== a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (n.samplingMode = a.TEXTURE_NEAREST_SAMPLINGMODE);
var r = this._gl
, o = new Lt(this,At.RenderTarget);
this._bindTextureDirectly(r.TEXTURE_CUBE_MAP, o, !0);
var s = this._getSamplingParameters(n.samplingMode, n.generateMipMaps);
n.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloat || (n.type = a.TEXTURETYPE_UNSIGNED_INT,
K.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type")),
r.texParameteri(r.TEXTURE_CUBE_MAP, r.TEXTURE_MAG_FILTER, s.mag),
r.texParameteri(r.TEXTURE_CUBE_MAP, r.TEXTURE_MIN_FILTER, s.min),
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);
for (var l = 0; l < 6; l++)
r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X + l, 0, this._getRGBABufferInternalSizedFormat(n.type, n.format), e, e, 0, this._getInternalFormat(n.format), this._getWebGLTextureType(n.type), null);
var c = r.createFramebuffer();
return this._bindUnboundFramebuffer(c),
i._depthStencilBuffer = this._setupFramebufferDepthAttachments(n.generateStencilBuffer, n.generateDepthBuffer, e, e),
n.generateMipMaps && r.generateMipmap(r.TEXTURE_CUBE_MAP),
this._bindTextureDirectly(r.TEXTURE_CUBE_MAP, null),
this._bindUnboundFramebuffer(null),
i._framebuffer = c,
i._generateDepthBuffer = n.generateDepthBuffer,
i._generateStencilBuffer = n.generateStencilBuffer,
o.width = e,
o.height = e,
o.isReady = !0,
o.isCube = !0,
o.samples = 1,
o.generateMipMaps = n.generateMipMaps,
o.samplingMode = n.samplingMode,
o.type = n.type,
o.format = n.format,
this._internalTexturesCache.push(o),
i.setTextures(o),
i
}
;
var ns = function(e) {
function t(t, i, n, r, o, s, l, c, u, d, p, f, _, m, g) {
void 0 === o && (o = !0),
void 0 === s && (s = a.TEXTURETYPE_UNSIGNED_INT),
void 0 === l && (l = !1),
void 0 === c && (c = io.TRILINEAR_SAMPLINGMODE),
void 0 === u && (u = !0),
void 0 === d && (d = !1),
void 0 === p && (p = !1),
void 0 === f && (f = a.TEXTUREFORMAT_RGBA),
void 0 === _ && (_ = !1);
var v, y = this;
if ((y = e.call(this, null, n, !r, void 0, c, void 0, void 0, void 0, void 0, f) || this).renderParticles = !0,
y.renderSprites = !1,
y.ignoreCameraViewport = !1,
y.onBeforeBindObservable = new h,
y.onAfterUnbindObservable = new h,
y.onBeforeRenderObservable = new h,
y.onAfterRenderObservable = new h,
y.onClearObservable = new h,
y.onResizeObservable = new h,
y._cleared = !1,
y.skipInitialClear = !1,
y._currentRefreshId = -1,
y._refreshRate = 1,
y._samples = 1,
y._canRescale = !0,
y._renderTarget = null,
y.boundingBoxPosition = x.Zero(),
!(n = y.getScene()))
return y;
var b = y.getScene().getEngine();
return y._coordinatesMode = io.PROJECTION_MODE,
y.renderList = new Array,
y.name = t,
y.isRenderTarget = !0,
y._initialSizeParameter = i,
y._renderPassIds = [],
y._isCubeData = l,
y._processSizeParameter(i),
y.renderPassId = y._renderPassIds[0],
y._resizeObserver = b.onResizeObservable.add((function() {}
)),
y._generateMipMaps = !!r,
y._doNotChangeAspectRatio = o,
y._renderingManager = new zi(n),
y._renderingManager._useSceneAutoClearSetup = !0,
p || (y._renderTargetOptions = {
generateMipMaps: r,
type: s,
format: null !== (v = y._format) && void 0 !== v ? v : void 0,
samplingMode: y.samplingMode,
generateDepthBuffer: u,
generateStencilBuffer: d,
samples: m,
creationFlags: g
},
y.samplingMode === io.NEAREST_SAMPLINGMODE && (y.wrapU = io.CLAMP_ADDRESSMODE,
y.wrapV = io.CLAMP_ADDRESSMODE),
_ || (l ? (y._renderTarget = n.getEngine().createRenderTargetCubeTexture(y.getRenderSize(), y._renderTargetOptions),
y.coordinatesMode = io.INVCUBIC_MODE,
y._textureMatrix = P.Identity()) : y._renderTarget = n.getEngine().createRenderTargetTexture(y._size, y._renderTargetOptions),
y._texture = y._renderTarget.texture,
void 0 !== m && (y.samples = m))),
y
}
return U(t, e),
Object.defineProperty(t.prototype, "renderList", {
get: function() {
return this._renderList
},
set: function(e) {
this._renderList = e,
this._renderList && this._hookArray(this._renderList)
},
enumerable: !1,
configurable: !0
}),
t.prototype._hookArray = function(e) {
var t = this
, i = e.push;
e.push = function() {
for (var n, r = [], o = 0; o < arguments.length; o++)
r[o] = arguments[o];
var a = 0 === e.length
, s = i.apply(e, r);
return a && (null === (n = t.getScene()) || void 0 === n || n.meshes.forEach((function(e) {
e._markSubMeshesAsLightDirty()
}
))),
s
}
;
var n = e.splice;
e.splice = function(i, r) {
var o, a = n.apply(e, [i, r]);
return 0 === e.length && (null === (o = t.getScene()) || void 0 === o || o.meshes.forEach((function(e) {
e._markSubMeshesAsLightDirty()
}
))),
a
}
}
,
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 n = 0; n < i.length; ++n)
for (var r = 0; r < this._renderPassIds.length; ++r)
i[n].setMaterialForRenderPass(this._renderPassIds[r], void 0 !== t ? Array.isArray(t) ? t[r] : t : void 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, n, r) {
var o;
void 0 === e && (e = 0),
void 0 === t && (t = !0),
void 0 === i && (i = !1),
void 0 === n && (n = 1),
void 0 === r && (r = a.TEXTUREFORMAT_DEPTH32_FLOAT),
null === (o = this._renderTarget) || void 0 === o || o.createDepthStencilTexture(e, t, i, n, r)
}
,
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) {
if (e.ratio) {
this._sizeRatio = e.ratio;
var t = this._getEngine();
this._size = {
width: this._bestReflectionRenderTargetDimension(t.getRenderWidth(), this._sizeRatio),
height: this._bestReflectionRenderTargetDimension(t.getRenderHeight(), this._sizeRatio)
}
} else
this._size = e;
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 Vi(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 n = this.getScene();
n && (this._processSizeParameter(e),
this._renderTarget = i ? n.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions) : n.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 n;
void 0 === e && (e = !1),
void 0 === t && (t = !1),
void 0 === i && (i = !1);
var r = this.getScene();
if (!r)
return i;
var o = r.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 = r.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 !== (n = this.activeCamera) && void 0 !== n ? n : r.activeCamera;
d && (d !== r.activeCamera && r.setTransformMatrix(d.getViewMatrix(), d.getProjectionMatrix(!0)),
o.setViewport(d.viewport, this.getRenderWidth(), this.getRenderHeight())),
this._defaultRenderListPrepared = !1;
var p = i;
if (i) {
r.getViewMatrix() || r.updateTransformMatrix();
var f = this.is2DArray ? this.getRenderLayers() : this.isCube ? 6 : 1;
for (y = 0; y < f && p; y++) {
var _ = null
, m = this.renderList ? this.renderList : r.getActiveMeshes().data
, g = this.renderList ? this.renderList.length : r.getActiveMeshes().length;
o.currentRenderPassId = this._renderPassIds[y],
this.onBeforeRenderObservable.notifyObservers(y),
this.getCustomRenderList && (_ = this.getCustomRenderList(y, m, g)),
_ || (_ = m),
this._doNotChangeAspectRatio || r.updateTransformMatrix(!0);
for (var v = 0; v < _.length && p; ++v)
if ((u = _[v]).isEnabled() && !u.isBlocked && u.isVisible && u.subMeshes)
if (this.customIsReadyFunction) {
if (!this.customIsReadyFunction(u, this.refreshRate)) {
p = !1;
break
}
} else if (!u.isReady(!0)) {
p = !1;
break
}
this.onAfterRenderObservable.notifyObservers(y)
}
} else if (this.is2DArray)
for (var y = 0; y < this.getRenderLayers(); y++)
this._renderToTarget(0, e, t, y, d),
r.incrementRenderId(),
r.resetCachedMaterial();
else if (this.isCube)
for (var b = 0; b < 6; b++)
this._renderToTarget(b, e, t, void 0, d),
r.incrementRenderId(),
r.resetCachedMaterial();
else
this._renderToTarget(0, e, t, void 0, d);
return this.onAfterUnbindObservable.notifyObservers(this),
o.currentRenderPassId = h,
r.activeCamera && ((r.getEngine().scenes.length > 1 || this.activeCamera && this.activeCamera !== r.activeCamera) && r.setTransformMatrix(r.activeCamera.getViewMatrix(), r.activeCamera.getProjectionMatrix(!0)),
o.setViewport(r.activeCamera.viewport)),
r.resetCachedMaterial(),
p
}
,
t.prototype._bestReflectionRenderTargetDimension = function(e, t) {
var i = e * t
, n = vr.NearestPOT(i + 16384 / (128 + i));
return Math.min(vr.FloorPOT(e), n)
}
,
t.prototype._prepareRenderingManager = function(e, t, i, n) {
var r = this.getScene();
if (r) {
this._renderingManager.reset();
for (var o = r.getRenderId(), a = 0; a < t; a++) {
var s = e[a];
if (s && !s.isBlocked) {
if (this.customIsReadyFunction) {
if (!this.customIsReadyFunction(s, this.refreshRate)) {
this.resetRefreshCounter();
continue
}
} else if (!s.isReady(0 === this.refreshRate)) {
this.resetRefreshCounter();
continue
}
if (!s._internalAbstractMeshDataInfo._currentLODIsUpToDate && r.activeCamera && (s._internalAbstractMeshDataInfo._currentLOD = r.customLODSelector ? r.customLODSelector(s, this.activeCamera || r.activeCamera) : s.getLOD(this.activeCamera || r.activeCamera),
s._internalAbstractMeshDataInfo._currentLODIsUpToDate = !0),
!s._internalAbstractMeshDataInfo._currentLOD)
continue;
var l = s._internalAbstractMeshDataInfo._currentLOD;
l._preActivateForIntermediateRendering(o);
var c;
if (c = !(!n || !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 < r.particleSystems.length; d++) {
var p = r.particleSystems[d]
, f = p.emitter;
p.isStarted() && f && f.position && f.isEnabled() && e.indexOf(f) >= 0 && 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 n = i.getEngine();
this._renderTarget && n.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, n) {
this._postProcessManager ? this._prePassEnabled || this._postProcessManager._prepareFrame(this._texture, this._postProcesses) : n && e.postProcessManager._prepareFrame(this._texture) || this._bindFrameBuffer(t, i)
}
,
t.prototype._renderToTarget = function(e, t, i, n, r) {
var o, s, l, c;
void 0 === n && (n = 0),
void 0 === r && (r = null);
var u = this.getScene();
if (u) {
var h = u.getEngine();
if (this._texture) {
if (null === (o = h._debugPushGroup) || void 0 === o || o.call(h, "render to face #".concat(e, " layer #").concat(n), 1),
this._prepareFrame(u, e, n, t),
this.is2DArray ? (h.currentRenderPassId = this._renderPassIds[n],
this.onBeforeRenderObservable.notifyObservers(n)) : (h.currentRenderPassId = this._renderPassIds[e],
this.onBeforeRenderObservable.notifyObservers(e)),
h.snapshotRendering && h.snapshotRenderingMode === a.SNAPSHOTRENDERING_FAST)
this.onClearObservable.hasObservers() ? this.onClearObservable.notifyObservers(h) : this.skipInitialClear || h.clear(this.clearColor || u.clearColor, !0, !0, !0);
else {
var d = null
, p = this.renderList ? this.renderList : u.getActiveMeshes().data
, f = this.renderList ? this.renderList.length : u.getActiveMeshes().length;
this.getCustomRenderList && (d = this.getCustomRenderList(this.is2DArray ? n : e, p, f)),
d ? this._prepareRenderingManager(d, d.length, r, !1) : (this._defaultRenderListPrepared || (this._prepareRenderingManager(p, f, r, !this.renderList),
this._defaultRenderListPrepared = !0),
d = p);
for (var _ = 0, m = u._beforeRenderTargetClearStage; _ < m.length; _++)
m[_].action(this, e, n);
this.onClearObservable.hasObservers() ? this.onClearObservable.notifyObservers(h) : this.skipInitialClear || h.clear(this.clearColor || u.clearColor, !0, !0, !0),
this._doNotChangeAspectRatio || u.updateTransformMatrix(!0);
for (var g = 0, v = u._beforeRenderTargetDrawStage; g < v.length; g++)
v[g].action(this, e, n);
this._renderingManager.render(this.customRenderFunction, d, this.renderParticles, this.renderSprites);
for (var y = 0, b = u._afterRenderTargetDrawStage; y < b.length; y++)
b[y].action(this, e, n);
var T = this._texture.generateMipMaps;
this._texture.generateMipMaps = !1,
this._postProcessManager ? this._postProcessManager._finalizeFrame(!1, null !== (s = this._renderTarget) && void 0 !== s ? s : void 0, e, this._postProcesses, this.ignoreCameraViewport) : t && u.postProcessManager._finalizeFrame(!1, null !== (l = this._renderTarget) && void 0 !== l ? l : void 0, e),
this._texture.generateMipMaps = T,
this._doNotChangeAspectRatio || u.updateTransformMatrix(!0),
i && gi.DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), h)
}
this._unbindFrameBuffer(h, e),
this.isCube && 5 === e && h.generateMipMapsForCubemap(this._texture),
null === (c = h._debugPopGroup) || void 0 === c || c.call(h, 1)
}
}
}
,
t.prototype.setRenderingOrder = function(e, t, i, n) {
void 0 === t && (t = null),
void 0 === i && (i = null),
void 0 === n && (n = null),
this._renderingManager.setRenderingOrder(e, t, i, n)
}
,
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 n = i.customRenderTargets.indexOf(this);
n >= 0 && i.customRenderTargets.splice(n, 1);
for (var r = 0, o = i.cameras; r < o.length; r++) {
var a = o[r];
(n = a.customRenderTargets.indexOf(this)) >= 0 && a.customRenderTargets.splice(n, 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
}(io);
io._CreateRenderTargetTexture = function(e, t, i, n, r) {
return new ns(e,t,i,n)
}
;
var rs = function(e) {
function t(t, i) {
void 0 === i && (i = 512);
var n = e.call(this, "multiview rtt", i, t, !1, !0, a.TEXTURETYPE_UNSIGNED_INT, !1, void 0, !1, !1, !0, void 0, !0) || this;
return n._renderTarget = n.getScene().getEngine().createMultiviewRenderTargetTexture(n.getRenderWidth(), n.getRenderHeight()),
n._texture = n._renderTarget.texture,
n._texture.isMultiview = !0,
n._texture.format = a.TEXTUREFORMAT_RGBA,
n.samples = n._getEngine().getCaps().maxSamples || n.samples,
n
}
return U(t, e),
Object.defineProperty(t.prototype, "samples", {
set: function(e) {
this._samples = e
},
enumerable: !1,
configurable: !0
}),
t.prototype._bindFrameBuffer = function() {
this._renderTarget && this.getScene().getEngine().bindMultiviewFramebuffer(this._renderTarget)
}
,
t.prototype.getViewCount = function() {
return 2
}
,
t
}(ns);
function os(e, t) {
var i = new Fi(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
}
vr.prototype.createMultiviewRenderTargetTexture = function(e, t) {
var i = this._gl;
if (!this.getCaps().multiview)
throw "Multiview is not supported";
var n = this._createHardwareRenderTargetWrapper(!1, !1, {
width: e,
height: t
});
n._framebuffer = i.createFramebuffer();
var r = new Lt(this,At.Unknown,!0);
return r.width = e,
r.height = t,
r.isMultiview = !0,
n._colorTextureArray = i.createTexture(),
i.bindTexture(i.TEXTURE_2D_ARRAY, n._colorTextureArray),
i.texStorage3D(i.TEXTURE_2D_ARRAY, 1, i.RGBA8, e, t, 2),
n._depthStencilTextureArray = i.createTexture(),
i.bindTexture(i.TEXTURE_2D_ARRAY, n._depthStencilTextureArray),
i.texStorage3D(i.TEXTURE_2D_ARRAY, 1, i.DEPTH24_STENCIL8, e, t, 2),
r.isReady = !0,
n.setTextures(r),
n._depthStencilTexture = r,
n
}
,
vr.prototype.bindMultiviewFramebuffer = function(e) {
var t = e
, i = this._gl
, n = 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 ? (n.framebufferTextureMultisampleMultiviewOVR(i.DRAW_FRAMEBUFFER, i.COLOR_ATTACHMENT0, t._colorTextureArray, 0, t.samples, 0, 2),
n.framebufferTextureMultisampleMultiviewOVR(i.DRAW_FRAMEBUFFER, i.DEPTH_STENCIL_ATTACHMENT, t._depthStencilTextureArray, 0, t.samples, 0, 2)) : (n.framebufferTextureMultiviewOVR(i.DRAW_FRAMEBUFFER, i.COLOR_ATTACHMENT0, t._colorTextureArray, 0, 0, 2),
n.framebufferTextureMultiviewOVR(i.DRAW_FRAMEBUFFER, i.DEPTH_STENCIL_ATTACHMENT, t._depthStencilTextureArray, 0, 0, 2))
}
,
Rr.prototype._useMultiviewToSingleView = !1,
Rr.prototype._multiviewTexture = null,
Rr.prototype._resizeOrCreateMultiviewTexture = function(e, t) {
this._multiviewTexture ? this._multiviewTexture.getRenderWidth() == e && this._multiviewTexture.getRenderHeight() == t || (this._multiviewTexture.dispose(),
this._multiviewTexture = new rs(this.getScene(),{
width: e,
height: t
})) : this._multiviewTexture = new rs(this.getScene(),{
width: e,
height: t
})
}
;
var as = mn.prototype.createSceneUniformBuffer;
mn.prototype._transformMatrixR = P.Zero(),
mn.prototype._multiviewSceneUbo = null,
mn.prototype._createMultiviewUbo = function() {
this._multiviewSceneUbo = os(this.getEngine(), "scene_multiview")
}
,
mn.prototype.createSceneUniformBuffer = function(e) {
return this._multiviewSceneUbo ? os(this.getEngine(), e) : as.bind(this)(e)
}
,
mn.prototype._updateMultiviewUbo = function(e, t) {
e && t && e.multiplyToRef(t, this._transformMatrixR),
e && t && (e.multiplyToRef(t, I.Matrix[0]),
dn.GetRightPlaneToRef(I.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))
}
,
mn.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 ss = function(e) {
function t(t, i, n) {
var r = e.call(this, t, "vrMultiviewToSingleview", ["imageIndex"], ["multiviewSampler"], n, i, io.BILINEAR_SAMPLINGMODE) || this;
return r.onSizeChangedObservable.add((function() {}
)),
r.onApplyObservable.add((function(e) {
i._scene.activeCamera && i._scene.activeCamera.isLeftCamera ? e.setInt("imageIndex", 0) : e.setInt("imageIndex", 1),
e.setTexture("multiviewSampler", i._multiviewTexture)
}
)),
r
}
return U(t, e),
t.prototype.getClassName = function() {
return "VRMultiviewToSingleviewPostProcess"
}
,
t
}(Ba);
function ls(e, t) {
var i = t.vrCameraMetrics || ts.GetDefault();
e._rigCameras[0]._cameraRigParams.vrMetrics = i,
e._rigCameras[0].viewport = new xr(0,0,.5,1),
e._rigCameras[0]._cameraRigParams.vrWorkMatrix = new P,
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 xr(.5,0,.5,1),
e._rigCameras[1]._cameraRigParams.vrWorkMatrix = new P,
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 ss("VRMultiviewToSingleview",e,i.postProcessScaleFactor)) : (K.Warn("Multiview is not supported, falling back to standard rendering"),
i.multiviewEnabled = !1)),
i.compensateDistortion && (e._rigCameras[0]._rigPostProcess = new is("VR_Distort_Compensation_Left",e._rigCameras[0],!1,i),
e._rigCameras[1]._rigPostProcess = new is("VR_Distort_Compensation_Right",e._rigCameras[1],!0,i))
}
Xe.AddNodeConstructor("VRDeviceOrientationArcRotateCamera", (function(e, t) {
return function() {
return new cs(e,0,0,1,x.Zero(),t)
}
}
));
var cs = function(e) {
function t(t, i, n, r, o, a, s, l) {
void 0 === s && (s = !0),
void 0 === l && (l = ts.GetDefault());
var c = e.call(this, t, i, n, r, o, a) || this;
return c._setRigMode = ls.bind(null, c),
l.compensateDistortion = s,
c.setCameraRigMode(Rr.RIG_MODE_VR, {
vrCameraMetrics: l
}),
c.inputs.addVRDeviceOrientation(),
c
}
return U(t, e),
t.prototype.getClassName = function() {
return "VRDeviceOrientationArcRotateCamera"
}
,
t
}(_a);
Xe.AddNodeConstructor("VRDeviceOrientationFreeCamera", (function(e, t) {
return function() {
return new us(e,x.Zero(),t)
}
}
));
var us = function(e) {
function t(t, i, n, r, o) {
void 0 === r && (r = !0),
void 0 === o && (o = ts.GetDefault());
var a = e.call(this, t, i, n) || this;
return a._setRigMode = ls.bind(null, a),
o.compensateDistortion = r,
a.setCameraRigMode(Rr.RIG_MODE_VR, {
vrCameraMetrics: o
}),
a
}
return U(t, e),
t.prototype.getClassName = function() {
return "VRDeviceOrientationFreeCamera"
}
,
t
}(ma);
Xe.AddNodeConstructor("VRDeviceOrientationGamepadCamera", (function(e, t) {
return function() {
return new hs(e,x.Zero(),t)
}
}
));
var hs = function(e) {
function t(t, i, n, r, o) {
void 0 === r && (r = !0),
void 0 === o && (o = ts.GetDefault());
var a = e.call(this, t, i, n, r, o) || this;
return a._setRigMode = ls.bind(null, a),
a.inputs.addGamepad(),
a
}
return U(t, e),
t.prototype.getClassName = function() {
return "VRDeviceOrientationGamepadCamera"
}
,
t
}(us);
Xe.AddNodeConstructor("Light_Type_3", (function(e, t) {
return function() {
return new ds(e,x.Zero(),t)
}
}
));
var ds = function(e) {
function t(t, i, n) {
var r = e.call(this, t, n) || this;
return r.groundColor = new D(0,0,0),
r.direction = i || x.Up(),
r
}
return U(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 = x.Normalize(e.subtract(x.Zero())),
this.direction
}
,
t.prototype.getShadowGenerator = function() {
return null
}
,
t.prototype.transferToEffect = function(e, t) {
var i = x.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 = x.Normalize(this.direction);
return e.setFloat3(t, i.x, i.y, i.z),
this
}
,
t.prototype.computeWorldMatrix = function() {
return this._worldMatrix || (this._worldMatrix = P.Identity()),
this._worldMatrix
}
,
t.prototype.getTypeID = function() {
return Cr.LIGHTTYPEID_HEMISPHERICLIGHT
}
,
t.prototype.prepareLightSpecificDefines = function(e, t) {
e["HEMILIGHT" + t] = !0
}
,
k([Me()], t.prototype, "groundColor", void 0),
k([De()], t.prototype, "direction", void 0),
t
}(Cr);
function ps(e, t) {
if (t.vrDisplay) {
var i = t.vrDisplay.getEyeParameters("left")
, n = t.vrDisplay.getEyeParameters("right");
e._rigCameras[0].viewport = new xr(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 P,
e._rigCameras[0].getProjectionMatrix = e._getWebVRProjectionMatrix,
e._rigCameras[0].parent = e,
e._rigCameras[0]._getViewMatrix = e._getWebVRViewMatrix,
e._rigCameras[1].viewport = new xr(.5,0,.5,1),
e._rigCameras[1].setCameraRigParameter("eyeParameters", n),
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 P,
e._rigCameras[1].getProjectionMatrix = e._getWebVRProjectionMatrix,
e._rigCameras[1].parent = e,
e._rigCameras[1]._getViewMatrix = e._getWebVRViewMatrix
}
}
Object.defineProperty(vr.prototype, "isInVRExclusivePointerMode", {
get: function() {
return this._vrExclusivePointerMode
},
enumerable: !0,
configurable: !0
}),
vr.prototype._prepareVRComponent = function() {
this._vrSupported = !1,
this._vrExclusivePointerMode = !1,
this.onVRDisplayChangedObservable = new h,
this.onVRRequestPresentComplete = new h,
this.onVRRequestPresentStart = new h
}
,
vr.prototype.isVRDevicePresent = function() {
return !!this._vrDisplay
}
,
vr.prototype.getVRDevice = function() {
return this._vrDisplay
}
,
vr.prototype.initWebVR = function() {
return this.initWebVRAsync(),
this.onVRDisplayChangedObservable
}
,
vr.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 = vr.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
}
,
vr.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
}))
}
))
}
,
vr.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([V({
source: this.getRenderingCanvas(),
attributes: i
}, i)]).then((function() {
t.onVRRequestPresentComplete.notifyObservers(!0),
t._onVRFullScreenTriggered()
}
)).catch((function() {
t.onVRRequestPresentComplete.notifyObservers(!1)
}
))
}
}
,
vr.prototype._onVRFullScreenTriggered = function() {
if (this._vrDisplay && this._vrDisplay.isPresenting) {
this._oldSize = new je(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)
}
,
vr.prototype.disableVR = function() {
var e = this;
this._vrDisplay && this._vrDisplay.isPresenting && this._vrDisplay.exitPresent().then((function() {
return e._onVRFullScreenTriggered()
}
)).catch((function() {
return e._onVRFullScreenTriggered()
}
)),
nt() && (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))
}
,
vr.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()
}
}
,
nt()) {
var n = this.getHostWindow();
n.addEventListener("vrdisplaypointerrestricted", this._onVRDisplayPointerRestricted, !1),
n.addEventListener("vrdisplaypointerunrestricted", this._onVRDisplayPointerUnrestricted, !1)
}
}
,
vr.prototype._submitVRFrame = function() {
if (this._vrDisplay && this._vrDisplay.isPresenting)
try {
this._vrDisplay.submitFrame()
} catch (e) {
gi.Warn("webVR submitFrame has had an unexpected failure: " + e)
}
}
,
vr.prototype.isVRPresenting = function() {
return this._vrDisplay && this._vrDisplay.isPresenting
}
,
vr.prototype._requestVRFrame = function() {
this._frameHandler = vr.QueueNewFrame(this._boundRenderFunction, this._vrDisplay)
}
,
Xe.AddNodeConstructor("WebVRFreeCamera", (function(e, t) {
return function() {
return new fs(e,x.Zero(),t)
}
}
)),
Xe.AddNodeConstructor("WebVRGamepadCamera", (function(e, t) {
return function() {
return new fs(e,x.Zero(),t)
}
}
));
var fs = function(e) {
function t(t, i, n, r) {
void 0 === r && (r = {});
var o = e.call(this, t, i, n) || this;
o._webVROptions = r,
o._vrDevice = null,
o.rawPose = null,
o._specsVersion = "1.1",
o._attached = !1,
o._descendants = [],
o._deviceRoomPosition = x.Zero(),
o._deviceRoomRotationQuaternion = C.Identity(),
o._standingMatrix = null,
o.devicePosition = x.Zero(),
o.deviceRotationQuaternion = C.Identity(),
o.deviceScaleFactor = 1,
o._deviceToWorld = P.Identity(),
o._worldToDevice = P.Identity(),
o.controllers = [],
o.onControllersAttachedObservable = new h,
o.onControllerMeshLoadedObservable = new h,
o.onPoseUpdatedFromDeviceObservable = new h,
o._poseSet = !1,
o.rigParenting = !0,
o._defaultHeight = void 0,
o._setRigMode = ps.bind(null, o),
o._detachIfAttached = function() {
var e = o.getEngine().getVRDevice();
e && !e.isPresenting && o.detachControl()
}
,
o._workingVector = x.Zero(),
o._oneVector = x.One(),
o._workingMatrix = P.Identity(),
o._tmpMatrix = new P,
o._cache.position = x.Zero(),
r.defaultHeight && (o._defaultHeight = r.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 C,
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(Rr.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),
r.useMultiview && (o.getScene().getEngine().getCaps().multiview ? (o._useMultiviewToSingleView = !0,
o._rigPostProcess = new ss("VRMultiviewToSingleview",o,1)) : (K.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 U(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 P,
P.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 n = i[t];
if (n.hand === e)
return n
}
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 = gi.BackCompatCameraNoPreventDefault(arguments),
e.prototype.attachControl.call(this, t),
this._attached = !0,
t = !Rr.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 && (P.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),
x.TransformCoordinatesToRef(this._deviceRoomPosition, this._workingMatrix, this._workingVector),
this.devicePosition.subtractToRef(this._workingVector, this._workingVector),
P.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() {
x.TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition)
}
,
t.prototype.update = function() {
this._computeDevicePosition(),
P.FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix),
this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix),
C.FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion),
this._poseSet && this.onPoseUpdatedFromDeviceObservable.notifyObservers(null),
e.prototype.update.call(this)
}
,
t.prototype._getViewMatrix = function() {
return P.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 P.FromArrayToRef(t, 0, this._webvrViewMatrix),
this.getScene().useRightHandedSystem || this._webvrViewMatrix.toggleModelMatrixHandInPlace(),
this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix),
x.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 || P.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 P.FromArrayToRef(t, 0, this._projectionMatrix),
this.getScene().useRightHandedSystem || this._projectionMatrix.toggleProjectionMatrixHandInPlace(),
this._projectionMatrix
}
,
t.prototype.initControllers = function() {
var e = this;
this.controllers = [];
var t = this.getScene().gamepadManager;
this._onGamepadDisconnectedObserver = t.onGamepadDisconnectedObservable.add((function(t) {
if (t.type === zo.POSE_ENABLED) {
var i = t;
i.defaultModel && i.defaultModel.setEnabled(!1),
"right" === i.hand && (e._rightController = null),
"left" === i.hand && (e._leftController = null);
var n = e.controllers.indexOf(i);
-1 !== n && e.controllers.splice(n, 1)
}
}
)),
this._onGamepadConnectedObserver = t.onGamepadConnectedObservable.add((function(t) {
if (t.type === zo.POSE_ENABLED) {
var i = t;
if (e._webVROptions.trackPosition || (i._disableTrackPosition(new x("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 ds("vrControllersLight",new x(0,1,0),e.getScene()));
var n = function(e, t) {
var i = e.getChildren();
i && 0 !== i.length && i.forEach((function(e) {
t.includedOnlyMeshes.push(e),
n(e, t)
}
))
};
e._lightOnControllers.includedOnlyMeshes.push(t),
n(t, e._lightOnControllers)
}
}
))),
i.attachToPoseControlledCamera(e),
-1 === e.controllers.indexOf(i)) {
e.controllers.push(i);
for (var n = !1, r = 0; r < e.controllers.length; r++)
e.controllers[r].controllerType === ba.VIVE && (n ? e.controllers[r].hand = "right" : (n = !0,
e.controllers[r].hand = "left"));
e.controllers.length >= 2 && e.onControllersAttachedObservable.notifyObservers(e.controllers)
}
}
}
))
}
,
t
}(pa)
, _s = function(e) {
function t(t) {
var i = e.call(this, t) || this;
return i.onTriggerStateChangedObservable = new h,
i.onMainButtonStateChangedObservable = new h,
i.onSecondaryButtonStateChangedObservable = new h,
i.onPadStateChangedObservable = new h,
i.onPadValuesChangedObservable = new h,
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 U(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
}(Ra)
, ms = 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, n, r) {
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] = n.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] = n.clone()
}
}
,
e
}()
, gs = function(e) {
function t(t, i, n) {
void 0 === n && (n = !0);
var r = e.call(this, t, i) || this;
return r._normalMatrix = new P,
r._storeEffectOnSubMeshes = n,
r
}
return U(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
}
,
t.prototype._mustRebind = function(e, t, i) {
return void 0 === i && (i = 1),
e.isCachedMaterialInvalid(this, t, i)
}
,
t
}(Or)
, vs = function() {
function e() {}
return Object.defineProperty(e, "DiffuseTextureEnabled", {
get: function() {
return this._DiffuseTextureEnabled
},
set: function(e) {
this._DiffuseTextureEnabled !== e && (this._DiffuseTextureEnabled = e,
vr.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,
vr.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,
vr.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,
vr.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,
vr.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,
vr.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,
vr.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,
vr.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,
vr.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,
vr.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,
vr.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,
vr.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,
vr.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,
vr.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,
vr.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,
vr.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,
vr.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,
vr.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,
vr.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,
vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
},
enumerable: !1,
configurable: !0
}),
e._DiffuseTextureEnabled = !0,
e._DetailTextureEnabled = !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
}();
Pt.IncludesShadersStore.defaultFragmentDeclaration = "uniform vec4 vEyePosition;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;\nuniform vec3 vAmbientColor;\nuniform 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;\nuniform vec2 vTangentSpaceParams;\n#endif\n#ifdef ALPHATEST\nuniform float alphaCutOff;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\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;\nuniform vec4 refractionRightColor;\n#endif\n#if defined(USE_LOCAL_REFRACTIONMAP_CUBIC) && defined(REFRACTIONMAP_3D)\nuniform vec3 vRefractionPosition;\nuniform vec3 vRefractionSize; \n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\n#endif\n#ifdef DIFFUSEFRESNEL\nuniform vec4 diffuseLeftColor;\nuniform vec4 diffuseRightColor;\n#endif\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;\nuniform 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;\nuniform vec3 vReflectionSize; \n#endif\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif\n#ifdef DETAIL\nuniform vec4 vDetailInfos;\n#endif\n#define ADDITIONAL_FRAGMENT_DECLARATION\n";
Pt.IncludesShadersStore.sceneUboDeclaration = "layout(std140,column_major) uniform;\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif \nmat4 view;\nmat4 projection;\nvec4 vEyePosition;\n};\n";
Pt.IncludesShadersStore.meshUboDeclaration = "uniform mat4 world;\nuniform float visibility;\n#define WORLD_UBO\n";
Pt.IncludesShadersStore.defaultUboDeclaration = "layout(std140,column_major) uniform;\nuniform Material\n{\nvec4 diffuseLeftColor;\nvec4 diffuseRightColor;\nvec4 opacityParts;\nvec4 reflectionLeftColor;\nvec4 reflectionRightColor;\nvec4 refractionLeftColor;\nvec4 refractionRightColor;\nvec4 emissiveLeftColor;\nvec4 emissiveRightColor;\nvec2 vDiffuseInfos;\nvec2 vAmbientInfos;\nvec2 vOpacityInfos;\nvec2 vReflectionInfos;\nvec3 vReflectionPosition;\nvec3 vReflectionSize;\nvec2 vEmissiveInfos;\nvec2 vLightmapInfos;\nvec2 vSpecularInfos;\nvec3 vBumpInfos;\nmat4 diffuseMatrix;\nmat4 ambientMatrix;\nmat4 opacityMatrix;\nmat4 reflectionMatrix;\nmat4 emissiveMatrix;\nmat4 lightmapMatrix;\nmat4 specularMatrix;\nmat4 bumpMatrix;\nvec2 vTangentSpaceParams;\nfloat pointSize;\nfloat alphaCutOff;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec3 vRefractionPosition;\nvec3 vRefractionSize;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nvec4 vDiffuseColor;\nvec3 vAmbientColor;\n#define ADDITIONAL_UBO_DECLARATION\n};\n#include\n#include\n";
Pt.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";
Pt.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;\nlayout(location=2) out vec4 backColor;\n#define MAX_DEPTH 99999.0\nhighp vec4 gl_FragColor;\nuniform sampler2D oitDepthSampler;\nuniform sampler2D oitFrontColorSampler;\n#endif\n";
Pt.IncludesShadersStore.mainUVVaryingDeclaration = "#ifdef MAINUV{X}\nvarying vec2 vMainUV{X};\n#endif\n";
Pt.IncludesShadersStore.helperFunctions = "const float PI=3.1415926535897932384626433832795;\nconst float HALF_MIN=5.96046448e-08; \nconst float LinearEncodePowerApprox=2.2;\nconst float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;\nconst vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);\nconst 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) {\nvec3 i0=inMatrix[0];\nvec3 i1=inMatrix[1];\nvec3 i2=inMatrix[2];\nmat3 outMatrix=mat3(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);\nreturn outMatrix;\n}\nmat3 inverseMat3(mat3 inMatrix) {\nfloat a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];\nfloat a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];\nfloat a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];\nfloat b01=a22*a11-a12*a21;\nfloat b11=-a22*a10+a12*a20;\nfloat b21=a21*a10-a11*a20;\nfloat det=a00*b01+a01*b11+a02*b21;\nreturn 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}\nfloat toLinearSpace(float color)\n{\nreturn pow(color,LinearEncodePowerApprox);\n}\nvec3 toLinearSpace(vec3 color)\n{\nreturn pow(color,vec3(LinearEncodePowerApprox));\n}\nvec4 toLinearSpace(vec4 color)\n{\nreturn vec4(pow(color.rgb,vec3(LinearEncodePowerApprox)),color.a);\n}\nvec3 toGammaSpace(vec3 color)\n{\nreturn pow(color,vec3(GammaEncodePowerApprox));\n}\nvec4 toGammaSpace(vec4 color)\n{\nreturn vec4(pow(color.rgb,vec3(GammaEncodePowerApprox)),color.a);\n}\nfloat toGammaSpace(float color)\n{\nreturn pow(color,GammaEncodePowerApprox);\n}\nfloat square(float value)\n{\nreturn value*value;\n}\nfloat pow5(float value) {\nfloat sq=value*value;\nreturn sq*sq*value;\n}\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,LuminanceEncodeApprox),0.,1.);\n}\nfloat getRand(vec2 seed) {\nreturn fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);\n}\nfloat dither(vec2 seed,float varianceAmount) {\nfloat rand=getRand(seed);\nfloat dither=mix(-varianceAmount/255.0,varianceAmount/255.0,rand);\nreturn dither;\n}\nconst float rgbdMaxRange=255.0;\nvec4 toRGBD(vec3 color) {\nfloat maxRGB=maxEps(max(color.r,max(color.g,color.b)));\nfloat D =max(rgbdMaxRange/maxRGB,1.);\nD =clamp(floor(D)/255.0,0.,1.);\nvec3 rgb=color.rgb*D;\nrgb=toGammaSpace(rgb);\nreturn vec4(clamp(rgb,0.,1.),D); \n}\nvec3 fromRGBD(vec4 rgbd) {\nrgbd.rgb=toLinearSpace(rgbd.rgb);\nreturn rgbd.rgb/rgbd.a;\n}\nvec3 parallaxCorrectNormal( vec3 vertexPos,vec3 origVec,vec3 cubeSize,vec3 cubePos ) {\nvec3 invOrigVec=vec3(1.0,1.0,1.0)/origVec;\nvec3 halfSize=cubeSize*0.5;\nvec3 intersecAtMaxPlane=(cubePos+halfSize-vertexPos)*invOrigVec;\nvec3 intersecAtMinPlane=(cubePos-halfSize-vertexPos)*invOrigVec;\nvec3 largestIntersec=max(intersecAtMaxPlane,intersecAtMinPlane);\nfloat distance=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);\nvec3 intersectPositionWS=vertexPos+origVec*distance;\nreturn intersectPositionWS-cubePos;\n}\n";
Pt.IncludesShadersStore.lightFragmentDeclaration = "#ifdef LIGHT{X}\nuniform vec4 vLightData{X};\nuniform 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}];\nuniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float cascadeBlendFactor{X};\nvarying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying vec4 vPositionFromCamera{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\nuniform highp sampler2DArray depthSampler{X};\nuniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform 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);\nvec3 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};\nvarying float vDepthMetric{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DShadow shadowSampler{X};\nuniform 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};\nuniform vec2 depthValues{X};\n#endif\n#ifdef SPOTLIGHT{X}\nuniform vec4 vLightDirection{X};\nuniform 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};\nuniform sampler2D projectionLightSampler{X};\n#endif\n#endif\n";
Pt.IncludesShadersStore.lightUboDeclaration = "#ifdef LIGHT{X}\nuniform Light{X}\n{\nvec4 vLightData;\nvec4 vLightDiffuse;\nvec4 vLightSpecular;\n#ifdef SPOTLIGHT{X}\nvec4 vLightDirection;\nvec4 vLightFalloff;\n#elif defined(POINTLIGHT{X})\nvec4 vLightFalloff;\n#elif defined(HEMILIGHT{X})\nvec3 vLightGround;\n#endif\nvec4 shadowsInfo;\nvec2 depthValues;\n} light{X};\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nuniform mat4 textureProjectionMatrix{X};\nuniform sampler2D projectionLightSampler{X};\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float cascadeBlendFactor{X};\nvarying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying vec4 vPositionFromCamera{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\nuniform highp sampler2DArray depthSampler{X};\nuniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform 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);\nvec3 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};\nvarying float vDepthMetric{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DShadow shadowSampler{X};\nuniform 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";
Pt.IncludesShadersStore.lightsFragmentFunctions = "struct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef NDOTL\nfloat ndl;\n#endif\n};\nlightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 lightVectorW;\nfloat attenuation=1.0;\nif (lightData.w==0.)\n{\nvec3 direction=lightData.xyz-vPositionW;\nattenuation=max(0.,1.0-length(direction)/range);\nlightVectorW=normalize(direction);\n}\nelse\n{\nlightVectorW=normalize(-lightData.xyz);\n}\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);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 direction=lightData.xyz-vPositionW;\nvec3 lightVectorW=normalize(direction);\nfloat attenuation=max(0.,1.0-length(direction)/range);\nfloat cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));\nif (cosAngle>=lightDirection.w)\n{\ncosAngle=max(0.,pow(cosAngle,lightData.w));\nattenuation*=cosAngle;\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);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nresult.diffuse=vec3(0.);\n#ifdef SPECULARTERM\nresult.specular=vec3(0.);\n#endif\n#ifdef NDOTL\nresult.ndl=0.;\n#endif\nreturn result;\n}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {\nlightingInfo result;\nfloat 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);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor;\n#endif\nreturn result;\n}\n#define inline\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\nstrq/=strq.w;\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\nreturn textureColor;\n}";
Pt.IncludesShadersStore.shadowsFragmentFunctions = "#ifdef SHADOWS\n#ifndef SHADOWFLOAT\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\n#endif\nfloat computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\n{\nfloat mask=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));\nreturn mix(value,1.0,mask);\n}\n#define inline\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.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}\n#define inline\nfloat computeShadowWithPoissonSamplingCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\nfloat visibility=1.;\nvec3 poissonDisk[4];\npoissonDisk[0]=vec3(-1.0,1.0,-1.0);\npoissonDisk[1]=vec3(1.0,-1.0,-1.0);\npoissonDisk[2]=vec3(-1.0,-1.0,-1.0);\npoissonDisk[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}\n#endif\n#define inline\nfloat computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nelse\n{\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadow=texture2D(shadowSampler,uv).x;\n#endif\nreturn shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;\n}\n}\n#define inline\nfloat computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nelse\n{\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\nfloat visibility=1.;\nvec2 poissonDisk[4];\npoissonDisk[0]=vec2(-0.94201624,-0.39906216);\npoissonDisk[1]=vec2(0.94558609,-0.76890725);\npoissonDisk[2]=vec2(-0.094184101,-0.92938870);\npoissonDisk[3]=vec2(0.34495938,0.29387760);\n#ifndef SHADOWFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nelse\n{\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\n}\n#define inline\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nelse\n{\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0); \n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\n}\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)\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{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);\nvec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);\nfloat shadow=texture2D(shadowSampler,uvDepthLayer);\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n#define inline\nfloat computeShadowWithCSMPCF3(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);\nvec2 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;\nvec2 uvw1=1.+2.*st;\nvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\nvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));\nshadow=shadow/16.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n#define inline\nfloat computeShadowWithCSMPCF5(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);\nvec2 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;\nvec2 uvw1=vec2(7.);\nvec2 uvw2=1.+3.*st;\nvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\nvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));\nshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[0]),layer,uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));\nshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[1]),layer,uvDepth.z));\nshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[2]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[2]),layer,uvDepth.z));\nshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[2]),layer,uvDepth.z));\nshadow=shadow/144.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n#define inline\nfloat computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nelse\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=ZINCLIP;\nfloat shadow=texture2D(shadowSampler,uvDepth);\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n}\n#define inline\nfloat computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nelse\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=ZINCLIP;\nvec2 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;\nvec2 uvw1=1.+2.*st;\nvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\nvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow=shadow/16.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n}\n#define inline\nfloat computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nelse\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=ZINCLIP;\nvec2 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;\nvec2 uvw1=vec2(7.);\nvec2 uvw2=1.+3.*st;\nvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\nvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z));\nshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z));\nshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z));\nshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z));\nshadow=shadow/144.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n}\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);\nconst 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{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);\nvec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);\nfloat blockerDepth=0.0;\nfloat sumBlockerDepth=0.0;\nfloat numBlocker=0.0;\nfor (int i=0; i1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nelse\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=ZINCLIP;\nfloat blockerDepth=0.0;\nfloat sumBlockerDepth=0.0;\nfloat numBlocker=0.0;\nfor (int i=0; i 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(), n = 0; n < i.meshes.length; n++) {
var r = i.meshes[n];
if (r.material) {
if (r.computeBonesUsingShaders && 0 !== r.numBoneInfluencers)
if (r.material.getEffect() === t)
r.computeBonesUsingShaders = !1;
else if (r.subMeshes)
for (var o = 0, a = r.subMeshes; o < a.length; o++)
if (a[o].effect === t) {
r.computeBonesUsingShaders = !1;
break
}
} else
!this._mesh.material && r.computeBonesUsingShaders && r.numBoneInfluencers > 0 && (r.computeBonesUsingShaders = !1)
}
} else {
var s = this._defines[this._currentRank];
if (s)
for (n = 0; n < s.length; n++)
e = e.replace("#define " + s[n], "");
this._currentRank++
}
return e
}
,
e
}()
, bs = function() {
function e(e) {
this._plugins = [],
this._activePlugins = [],
this._activePluginsForExtraEvents = [],
this._material = e,
this._scene = e.getScene(),
this._engine = this._scene.getEngine()
}
return e.prototype._addPlugin = function(e) {
for (var t = 0; t < this._plugins.length; ++t)
if (this._plugins[t].name === e.name)
throw 'Plugin "'.concat(e.name, '" already added to the material "').concat(this._material.name, '"!');
if (this._material._uniformBufferLayoutBuilt)
throw 'The plugin "'.concat(e.name, '" can\'t be added to the material "').concat(this._material.name, '" because this material has already been used for rendering! Please add plugins to materials before any rendering with this material occurs.');
this._material._callbackPluginEventGeneric = this._handlePluginEvent.bind(this),
this._plugins.push(e),
this._plugins.sort((function(e, t) {
return e.priority - t.priority
}
)),
this._codeInjectionPoints = {};
for (var i = {}, n = 0, r = this._plugins; n < r.length; n++) {
var o = r[n];
o.collectDefines(i),
this._collectPointNames("vertex", o.getCustomCode("vertex")),
this._collectPointNames("fragment", o.getCustomCode("fragment"))
}
Object.keys(i).length > 0 ? this._defineNamesFromPlugins = i : delete this._defineNamesFromPlugins
}
,
e.prototype._activatePlugin = function(e) {
-1 === this._activePlugins.indexOf(e) && (this._activePlugins.push(e),
this._activePlugins.sort((function(e, t) {
return e.priority - t.priority
}
)),
this._material._callbackPluginEventIsReadyForSubMesh = this._handlePluginEventIsReadyForSubMesh.bind(this),
this._material._callbackPluginEventPrepareDefines = this._handlePluginEventPrepareDefines.bind(this),
this._material._callbackPluginEventBindForSubMesh = this._handlePluginEventBindForSubMesh.bind(this),
e.registerForExtraEvents && (this._activePluginsForExtraEvents.push(e),
this._activePluginsForExtraEvents.sort((function(e, t) {
return e.priority - t.priority
}
)),
this._material._callbackPluginEventHasRenderTargetTextures = this._handlePluginEventHasRenderTargetTextures.bind(this),
this._material._callbackPluginEventFillRenderTargetTextures = this._handlePluginEventFillRenderTargetTextures.bind(this),
this._material._callbackPluginEventHardBindForSubMesh = this._handlePluginEventHardBindForSubMesh.bind(this)))
}
,
e.prototype.getPlugin = function(e) {
for (var t = 0; t < this._plugins.length; ++t)
if (this._plugins[t].name === e)
return this._plugins[t];
return null
}
,
e.prototype._handlePluginEventIsReadyForSubMesh = function(e) {
for (var t = !0, i = 0, n = this._activePlugins; i < n.length; i++) {
var r = n[i];
t = t && r.isReadyForSubMesh(e.defines, this._scene, this._engine, e.subMesh)
}
e.isReadyForSubMesh = t
}
,
e.prototype._handlePluginEventPrepareDefines = function(e) {
for (var t = 0, i = this._activePlugins; t < i.length; t++)
i[t].prepareDefines(e.defines, this._scene, e.mesh)
}
,
e.prototype._handlePluginEventHardBindForSubMesh = function(e) {
for (var t = 0, i = this._activePluginsForExtraEvents; t < i.length; t++)
i[t].hardBindForSubMesh(this._material._uniformBuffer, this._scene, this._engine, e.subMesh)
}
,
e.prototype._handlePluginEventBindForSubMesh = function(e) {
for (var t = 0, i = this._activePlugins; t < i.length; t++)
i[t].bindForSubMesh(this._material._uniformBuffer, this._scene, this._engine, e.subMesh)
}
,
e.prototype._handlePluginEventHasRenderTargetTextures = function(e) {
for (var t = !1, i = 0, n = this._activePluginsForExtraEvents; i < n.length && !(t = n[i].hasRenderTargetTextures()); i++)
;
e.hasRenderTargetTextures = t
}
,
e.prototype._handlePluginEventFillRenderTargetTextures = function(e) {
for (var t = 0, i = this._activePluginsForExtraEvents; t < i.length; t++)
i[t].fillRenderTargetTextures(e.renderTargets)
}
,
e.prototype._handlePluginEvent = function(e, t) {
var i, n, r;
switch (e) {
case Ar.GetActiveTextures:
for (var o = t, a = 0, s = this._activePlugins; a < s.length; a++)
(g = s[a]).getActiveTextures(o.activeTextures);
break;
case Ar.GetAnimatables:
o = t;
for (var l = 0, c = this._activePlugins; l < c.length; l++)
(g = c[l]).getAnimatables(o.animatables);
break;
case Ar.HasTexture:
o = t;
for (var u = !1, h = 0, d = this._activePlugins; h < d.length && !(u = (g = d[h]).hasTexture(o.texture)); h++)
;
o.hasTexture = u;
break;
case Ar.Disposed:
o = t;
for (var p = 0, f = this._plugins; p < f.length; p++)
(g = f[p]).dispose(o.forceDisposeTextures);
break;
case Ar.GetDefineNames:
(o = t).defineNames = this._defineNamesFromPlugins;
break;
case Ar.PrepareEffect:
o = t;
for (var _ = 0, m = this._activePlugins; _ < m.length; _++) {
var g = m[_];
o.fallbackRank = g.addFallbacks(o.defines, o.fallbacks, o.fallbackRank)
}
this._uniformList.length > 0 && (i = o.uniforms).push.apply(i, this._uniformList),
this._samplerList.length > 0 && (n = o.samplers).push.apply(n, this._samplerList),
this._uboList.length > 0 && (r = o.uniformBuffersNames).push.apply(r, this._uboList),
o.customCode = this._injectCustomCode(o.customCode);
break;
case Ar.PrepareUniformBuffer:
o = t,
this._uboDeclaration = "",
this._vertexDeclaration = "",
this._fragmentDeclaration = "",
this._uniformList = [],
this._samplerList = [],
this._uboList = [];
for (var v = 0, y = this._plugins; v < y.length; v++) {
var b = (g = y[v]).getUniforms();
if (b) {
if (b.ubo)
for (var T = 0, E = b.ubo; T < E.length; T++) {
var S = E[T];
o.ubo.addUniform(S.name, S.size),
this._uboDeclaration += "".concat(S.type, " ").concat(S.name, ";\r\n"),
this._uniformList.push(S.name)
}
b.vertex && (this._vertexDeclaration += b.vertex + "\r\n"),
b.fragment && (this._fragmentDeclaration += b.fragment + "\r\n")
}
g.getSamplers(this._samplerList),
g.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) {
var t = this;
return function(i, n) {
var r;
e && (n = e(i, n)),
t._uboDeclaration && (n = n.replace("#define ADDITIONAL_UBO_DECLARATION", t._uboDeclaration)),
t._vertexDeclaration && (n = n.replace("#define ADDITIONAL_VERTEX_DECLARATION", t._vertexDeclaration)),
t._fragmentDeclaration && (n = n.replace("#define ADDITIONAL_FRAGMENT_DECLARATION", t._fragmentDeclaration));
var o = null === (r = t._codeInjectionPoints) || void 0 === r ? void 0 : r[i];
if (!o)
return n;
for (var a in o) {
for (var s = "", l = 0, c = t._activePlugins; l < c.length; l++) {
var u = c[l].getCustomCode(i);
(null == u ? void 0 : u[a]) && (s += u[a] + "\r\n")
}
if (s.length > 0)
if ("!" === a.charAt(0))
for (var h = new RegExp(a.substring(1),"g"), d = h.exec(n); null !== d; )
n = n.replace(d[0], s),
d = h.exec(n);
else {
var p = "#define " + a;
n = n.replace(p, "\r\n" + s + "\r\n" + p)
}
}
return n
}
}
,
e
}()
, Ts = []
, Es = !1;
function Ss(e, t) {
Es || (Or.OnEventObservable.add((function(e) {
for (var t = 0, i = Ts; t < i.length; t++)
(0,
i[t][1])(e)
}
), Ar.Created),
Es = !0);
var i = Ts.filter((function(t) {
var i = t[0];
return t[1],
i === e
}
));
i.length > 0 ? i[0][1] = t : Ts.push([e, t])
}
function As(e) {
for (var t = 0; t < Ts.length; ++t)
if (Ts[t][0] === e)
return Ts.splice(t, 1),
!0;
return !1
}
function xs() {
Ts.length = 0
}
var Rs = function() {
function e(e, t, i, n, r, o) {
void 0 === r && (r = !0),
void 0 === o && (o = !1),
this.priority = 500,
this.registerForExtraEvents = !1,
this._material = e,
this.name = t,
this.priority = i,
e.pluginManager || (e.pluginManager = new bs(e)),
this._pluginDefineNames = n,
this._pluginManager = e.pluginManager,
r && 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, n) {
return !0
}
,
e.prototype.hardBindForSubMesh = function(e, t, i, n) {}
,
e.prototype.bindForSubMesh = function(e, t, i, n) {}
,
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 n = i[t];
if ("_" !== n[0]) {
var r = typeof this._pluginDefineNames[n];
e[n] = {
type: "number" === r ? "number" : "string" === r ? "string" : "boolean" === r ? "boolean" : "object",
default: this._pluginDefineNames[n]
}
}
}
}
,
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.getUniformBuffersNames = function(e) {}
,
e.prototype.getUniforms = function() {
return {}
}
,
e.prototype.copyTo = function(e) {
Ge.Clone((function() {
return e
}
), this)
}
,
e.prototype.serialize = function() {
return Ge.Serialize(this)
}
,
e.prototype.parse = function(e, t, i) {
var n = this;
Ge.Parse((function() {
return n
}
), e, t, i)
}
,
k([Ce()], e.prototype, "name", void 0),
k([Ce()], e.prototype, "priority", void 0),
k([Ce()], e.prototype, "registerForExtraEvents", void 0),
e
}()
, Cs = 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 U(t, e),
t
}(Si)
, Ps = function(e) {
function t(t, i) {
void 0 === i && (i = !0);
var n = e.call(this, t, "DetailMap", 140, new Cs, i) || this;
return n._texture = null,
n.diffuseBlendLevel = 1,
n.roughnessBlendLevel = 1,
n.bumpLevel = 1,
n._normalBlendMethod = Or.MATERIAL_NORMALBLENDMETHOD_WHITEOUT,
n._isEnabled = !1,
n.isEnabled = !1,
n._internalMarkAllSubMeshesAsTexturesDirty = t._dirtyCallbacks[a.MATERIAL_TextureDirtyFlag],
n
}
return U(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 && vs.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 && vs.DetailTextureEnabled && this._isEnabled ? (Mr.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 && vs.DetailTextureEnabled && (e.updateFloat4("vDetailInfos", this._texture.coordinatesIndex, this.diffuseBlendLevel, this.bumpLevel, this.roughnessBlendLevel),
Mr.BindTextureMatrix(this._texture, e, "detail")),
t.texturesEnabled && this._texture && vs.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"
}]
}
}
,
k([Pe("detailTexture"), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "texture", void 0),
k([Ce()], t.prototype, "diffuseBlendLevel", void 0),
k([Ce()], t.prototype, "roughnessBlendLevel", void 0),
k([Ce()], t.prototype, "bumpLevel", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "normalBlendMethod", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isEnabled", void 0),
t
}(Rs)
, Ms = {
effect: null,
subMesh: null
}
, Is = 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.IMAGEPROCESSINGPOSTPROCESS = !1,
i.SKIPFINALCOLORCLAMP = !1,
i.MULTIVIEW = !1,
i.ORDER_INDEPENDENT_TRANSPARENCY = !1,
i.ORDER_INDEPENDENT_TRANSPARENCY_16BITS = !1,
i.IS_REFLECTION_LINEAR = !1,
i.IS_REFRACTION_LINEAR = !1,
i.EXPOSURE = !1,
i.rebuild(),
i
}
return U(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 n = i[t];
this[n] = n === e
}
}
,
t
}(Si)
, Os = function(e) {
function t(i, n) {
var r = e.call(this, i, n) || this;
return r._diffuseTexture = null,
r._ambientTexture = null,
r._opacityTexture = null,
r._reflectionTexture = null,
r._emissiveTexture = null,
r._specularTexture = null,
r._bumpTexture = null,
r._lightmapTexture = null,
r._refractionTexture = null,
r.ambientColor = new D(0,0,0),
r.diffuseColor = new D(1,1,1),
r.specularColor = new D(1,1,1),
r.emissiveColor = new D(0,0,0),
r.specularPower = 64,
r._useAlphaFromDiffuseTexture = !1,
r._useEmissiveAsIllumination = !1,
r._linkEmissiveWithDiffuse = !1,
r._useSpecularOverAlpha = !1,
r._useReflectionOverAlpha = !1,
r._disableLighting = !1,
r._useObjectSpaceNormalMap = !1,
r._useParallax = !1,
r._useParallaxOcclusion = !1,
r.parallaxScaleBias = .05,
r._roughness = 0,
r.indexOfRefraction = .98,
r.invertRefractionY = !0,
r.alphaCutOff = .4,
r._useLightmapAsShadowmap = !1,
r._useReflectionFresnelFromSpecular = !1,
r._useGlossinessFromSpecularMapAlpha = !1,
r._maxSimultaneousLights = 4,
r._invertNormalMapX = !1,
r._invertNormalMapY = !1,
r._twoSidedLighting = !1,
r._renderTargets = new bi(16),
r._worldViewProjectionMatrix = P.Zero(),
r._globalAmbientColor = new D(0,0,0),
r._cacheHasRenderTargetTextures = !1,
r.detailMap = new Ps(r),
r._attachImageProcessingConfiguration(null),
r.prePassConfiguration = new ms,
r.getRenderTargetTextures = function() {
return r._renderTargets.reset(),
t.ReflectionTextureEnabled && r._reflectionTexture && r._reflectionTexture.isRenderTarget && r._renderTargets.push(r._reflectionTexture),
t.RefractionTextureEnabled && r._refractionTexture && r._refractionTexture.isRenderTarget && r._renderTargets.push(r._refractionTexture),
r._eventInfo.renderTargets = r._renderTargets,
r._callbackPluginEventFillRenderTargetTextures(r._eventInfo),
r._renderTargets
}
,
r
}
return U(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 === Or.MATERIAL_ALPHATEST)
}
,
t.prototype._shouldUseAlphaFromDiffuseTexture = function() {
return null != this._diffuseTexture && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture && this._transparencyMode !== Or.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, n) {
if (void 0 === n && (n = !1),
this._uniformBufferLayoutBuilt || this.buildUniformLayout(),
i.effect && this.isFrozen && i.effect._wasPreviouslyReady)
return !0;
i.materialDefines || (this._callbackPluginEventGeneric(Ar.GetDefineNames, this._eventInfo),
i.materialDefines = new Is(this._eventInfo.defineNames));
var r = this.getScene()
, o = i.materialDefines;
if (this._isReadyForSubMesh(i))
return !0;
var s = r.getEngine();
o._needNormals = Mr.PrepareDefinesForLights(r, e, o, !0, this._maxSimultaneousLights, this._disableLighting),
Mr.PrepareDefinesForMultiview(r, o);
var l = this.needAlphaBlendingForMesh(e) && this.getScene().useOrderIndependentTransparency;
if (Mr.PrepareDefinesForPrePass(r, o, this.canRenderToMRT && !l),
Mr.PrepareDefinesForOIT(r, 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 (r.texturesEnabled) {
if (this._diffuseTexture && t.DiffuseTextureEnabled) {
if (!this._diffuseTexture.isReadyOrNotBlocking())
return !1;
Mr.PrepareDefinesForMergedUV(this._diffuseTexture, o, "DIFFUSE")
} else
o.DIFFUSE = !1;
if (this._ambientTexture && t.AmbientTextureEnabled) {
if (!this._ambientTexture.isReadyOrNotBlocking())
return !1;
Mr.PrepareDefinesForMergedUV(this._ambientTexture, o, "AMBIENT")
} else
o.AMBIENT = !1;
if (this._opacityTexture && t.OpacityTextureEnabled) {
if (!this._opacityTexture.isReadyOrNotBlocking())
return !1;
Mr.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 === io.INVCUBIC_MODE,
o.REFLECTIONMAP_3D = this._reflectionTexture.isCube,
o.RGBDREFLECTION = this._reflectionTexture.isRGBD,
o.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !this._reflectionTexture.invertZ : this._reflectionTexture.invertZ,
this._reflectionTexture.coordinatesMode) {
case io.EXPLICIT_MODE:
o.setReflectionMode("REFLECTIONMAP_EXPLICIT");
break;
case io.PLANAR_MODE:
o.setReflectionMode("REFLECTIONMAP_PLANAR");
break;
case io.PROJECTION_MODE:
o.setReflectionMode("REFLECTIONMAP_PROJECTION");
break;
case io.SKYBOX_MODE:
o.setReflectionMode("REFLECTIONMAP_SKYBOX");
break;
case io.SPHERICAL_MODE:
o.setReflectionMode("REFLECTIONMAP_SPHERICAL");
break;
case io.EQUIRECTANGULAR_MODE:
o.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
break;
case io.FIXED_EQUIRECTANGULAR_MODE:
o.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
break;
case io.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
o.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
break;
case io.CUBIC_MODE:
case io.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;
Mr.PrepareDefinesForMergedUV(this._emissiveTexture, o, "EMISSIVE")
} else
o.EMISSIVE = !1;
if (this._lightmapTexture && t.LightmapTextureEnabled) {
if (!this._lightmapTexture.isReadyOrNotBlocking())
return !1;
Mr.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;
Mr.PrepareDefinesForMergedUV(this._specularTexture, o, "SPECULAR"),
o.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha
} else
o.SPECULAR = !1;
if (r.getEngine().getCaps().standardDerivatives && this._bumpTexture && t.BumpTextureEnabled) {
if (!this._bumpTexture.isReady())
return !1;
Mr.PrepareDefinesForMergedUV(this._bumpTexture, o, "BUMP"),
o.PARALLAX = this._useParallax,
o.PARALLAXOCCLUSION = this._useParallaxOcclusion,
o.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap
} else
o.BUMP = !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._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
}
if (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),
Mr.PrepareDefinesForMisc(e, r, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(e) || this._forceAlphaTest, o),
Mr.PrepareDefinesForAttributes(e, o, !0, !0, !0),
Mr.PrepareDefinesForFrameBoundValues(r, s, o, n, null, i.getRenderingMesh().hasThinInstances),
this._eventInfo.defines = o,
this._eventInfo.mesh = e,
this._callbackPluginEventPrepareDefines(this._eventInfo),
o.isDirty) {
var u = o._areLightsDisposed;
o.markAsProcessed();
var h = new ys;
o.REFLECTION && h.addFallback(0, "REFLECTION"),
o.SPECULAR && h.addFallback(0, "SPECULAR"),
o.BUMP && h.addFallback(0, "BUMP"),
o.PARALLAX && h.addFallback(1, "PARALLAX"),
o.PARALLAXOCCLUSION && h.addFallback(0, "PARALLAXOCCLUSION"),
o.SPECULAROVERALPHA && h.addFallback(0, "SPECULAROVERALPHA"),
o.FOG && h.addFallback(1, "FOG"),
o.POINTSIZE && h.addFallback(0, "POINTSIZE"),
o.LOGARITHMICDEPTH && h.addFallback(0, "LOGARITHMICDEPTH"),
Mr.HandleFallbacksForShadows(o, h, this._maxSimultaneousLights),
o.SPECULARTERM && h.addFallback(0, "SPECULARTERM"),
o.DIFFUSEFRESNEL && h.addFallback(1, "DIFFUSEFRESNEL"),
o.OPACITYFRESNEL && h.addFallback(2, "OPACITYFRESNEL"),
o.REFLECTIONFRESNEL && h.addFallback(3, "REFLECTIONFRESNEL"),
o.EMISSIVEFRESNEL && h.addFallback(4, "EMISSIVEFRESNEL"),
o.FRESNEL && h.addFallback(4, "FRESNEL"),
o.MULTIVIEW && h.addFallback(0, "MULTIVIEW");
var d = [Bi.PositionKind];
for (o.NORMAL && d.push(Bi.NormalKind),
o.TANGENT && d.push(Bi.TangentKind),
c = 1; c <= a.MAX_SUPPORTED_UV_SETS; ++c)
o["UV" + c] && d.push("uv".concat(1 === c ? "" : c));
o.VERTEXCOLOR && d.push(Bi.ColorKind),
o.INSTANCESCOLOR && d.push(Bi.ColorInstanceKind),
Mr.PrepareAttributesForBones(d, e, o, h),
Mr.PrepareAttributesForInstances(d, o),
Mr.PrepareAttributesForMorphTargets(d, e, o),
Mr.PrepareAttributesForBakedVertexAnimation(d, e, o);
var p = "default"
, f = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor", "visibility", "vFogInfos", "vFogColor", "pointSize", "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos", "mBones", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "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"]
, _ = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler", "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler", "refractionCubeSampler", "refraction2DSampler", "boneSampler", "morphTargets", "oitDepthSampler", "oitFrontColorSampler"]
, m = ["Material", "Scene", "Mesh"];
this._eventInfo.fallbacks = h,
this._eventInfo.fallbackRank = 0,
this._eventInfo.defines = o,
this._eventInfo.uniforms = f,
this._eventInfo.samplers = _,
this._eventInfo.uniformBuffersNames = m,
this._eventInfo.customCode = void 0,
this._callbackPluginEventGeneric(Ar.PrepareEffect, this._eventInfo),
ms.AddUniforms(f),
ms.AddSamplers(_),
Ri && (Ri.PrepareUniforms(f, o),
Ri.PrepareSamplers(_, o)),
Mr.PrepareUniformsAndSamplersList({
uniformsNames: f,
uniformBuffersNames: m,
samplers: _,
defines: o,
maxSimultaneousLights: this._maxSimultaneousLights
});
var g = {};
this.customShaderNameResolve && (p = this.customShaderNameResolve(p, f, m, _, o, d, g));
var v = o.toString()
, y = i.effect
, b = r.getEngine().createEffect(p, {
attributes: d,
uniformsNames: f,
uniformBuffersNames: m,
samplers: _,
defines: v,
fallbacks: h,
onCompiled: this.onCompiled,
onError: this.onError,
indexParameters: {
maxSimultaneousLights: this._maxSimultaneousLights,
maxSimultaneousMorphTargets: o.NUM_MORPH_INFLUENCERS
},
processFinalCode: g.processFinalCode,
processCodeAfterIncludes: this._eventInfo.customCode,
multiTarget: o.PREPASS
}, s);
if (b)
if (this._onEffectCreatedObservable && (Ms.effect = b,
Ms.subMesh = i,
this._onEffectCreatedObservable.notifyObservers(Ms)),
this.allowShaderHotSwapping && y && !b.isReady()) {
if (b = y,
o.markAsUnprocessed(),
u)
return o._areLightsDisposed = !0,
!1
} else
r.resetCachedMaterial(),
i.setEffect(b, o, this._materialContext)
}
return !(!i.effect || !i.effect.isReady() || (o._renderId = r.getRenderId(),
i.effect._wasPreviouslyReady = !0,
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, n) {
var r, o = this.getScene(), a = n.materialDefines;
if (a) {
var s = n.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 = n,
this._callbackPluginEventHardBindForSubMesh(this._eventInfo),
a.OBJECTSPACE_NORMALMAP && (e.toNormalMatrix(this._normalMatrix),
this.bindOnlyNormalMatrix(this._normalMatrix));
var l = this._mustRebind(o, s, i.visibility);
Mr.BindBonesParameters(i, s);
var c = this._uniformBuffer;
if (l) {
if (this.bindViewProjection(s),
!c.useUbo || !this.isFrozen || !c.isSync) {
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 D(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),
Mr.BindTextureMatrix(this._diffuseTexture, c, "diffuse")),
this._ambientTexture && t.AmbientTextureEnabled && (c.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level),
Mr.BindTextureMatrix(this._ambientTexture, c, "ambient")),
this._opacityTexture && t.OpacityTextureEnabled && (c.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level),
Mr.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),
Mr.BindTextureMatrix(this._emissiveTexture, c, "emissive")),
this._lightmapTexture && t.LightmapTextureEnabled && (c.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level),
Mr.BindTextureMatrix(this._lightmapTexture, c, "lightmap")),
this._specularTexture && t.SpecularTextureEnabled && (c.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level),
Mr.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),
Mr.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 : D.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 = n,
this._callbackPluginEventBindForSubMesh(this._eventInfo),
Mr.BindClipPlane(s, o),
this.bindEyePosition(s)
} else
o.getEngine()._features.needToAlwaysBindUniformBuffers && (this._needToBindSceneUbo = !0);
!l && this.isFrozen || (o.lightsEnabled && !this._disableLighting && Mr.BindLights(o, i, s, a, this._maxSimultaneousLights),
(o.fogEnabled && i.applyFog && o.fogMode !== mn.FOGMODE_NONE || this._reflectionTexture || this._refractionTexture || i.receiveShadows) && this.bindView(s),
Mr.BindFogParameters(o, i, s),
a.NUM_MORPH_INFLUENCERS && Mr.BindMorphTargetParameters(i, s),
a.BAKED_VERTEX_ANIMATION_TEXTURE && (null === (r = i.bakedVertexAnimationManager) || void 0 === r || r.bind(s, a.INSTANCES)),
this.useLogarithmicDepth && Mr.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 n, r, o, a, s, l, c, u, h;
i && (null === (n = this._diffuseTexture) || void 0 === n || n.dispose(),
null === (r = this._ambientTexture) || void 0 === r || r.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) {
var i = this
, n = Ge.Clone((function() {
return new t(e,i.getScene())
}
), this);
return n.name = e,
n.id = e,
this.stencil.copyTo(n.stencil),
n
}
,
t.Parse = function(e, i, n) {
var r = Ge.Parse((function() {
return new t(e.name,i)
}
), e, i, n);
return e.stencil && r.stencil.parse(e.stencil, i, n),
r
}
,
Object.defineProperty(t, "DiffuseTextureEnabled", {
get: function() {
return vs.DiffuseTextureEnabled
},
set: function(e) {
vs.DiffuseTextureEnabled = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t, "DetailTextureEnabled", {
get: function() {
return vs.DetailTextureEnabled
},
set: function(e) {
vs.DetailTextureEnabled = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t, "AmbientTextureEnabled", {
get: function() {
return vs.AmbientTextureEnabled
},
set: function(e) {
vs.AmbientTextureEnabled = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t, "OpacityTextureEnabled", {
get: function() {
return vs.OpacityTextureEnabled
},
set: function(e) {
vs.OpacityTextureEnabled = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t, "ReflectionTextureEnabled", {
get: function() {
return vs.ReflectionTextureEnabled
},
set: function(e) {
vs.ReflectionTextureEnabled = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t, "EmissiveTextureEnabled", {
get: function() {
return vs.EmissiveTextureEnabled
},
set: function(e) {
vs.EmissiveTextureEnabled = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t, "SpecularTextureEnabled", {
get: function() {
return vs.SpecularTextureEnabled
},
set: function(e) {
vs.SpecularTextureEnabled = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t, "BumpTextureEnabled", {
get: function() {
return vs.BumpTextureEnabled
},
set: function(e) {
vs.BumpTextureEnabled = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t, "LightmapTextureEnabled", {
get: function() {
return vs.LightmapTextureEnabled
},
set: function(e) {
vs.LightmapTextureEnabled = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t, "RefractionTextureEnabled", {
get: function() {
return vs.RefractionTextureEnabled
},
set: function(e) {
vs.RefractionTextureEnabled = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t, "ColorGradingTextureEnabled", {
get: function() {
return vs.ColorGradingTextureEnabled
},
set: function(e) {
vs.ColorGradingTextureEnabled = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t, "FresnelEnabled", {
get: function() {
return vs.FresnelEnabled
},
set: function(e) {
vs.FresnelEnabled = e
},
enumerable: !1,
configurable: !0
}),
k([Pe("diffuseTexture")], t.prototype, "_diffuseTexture", void 0),
k([Re("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "diffuseTexture", void 0),
k([Pe("ambientTexture")], t.prototype, "_ambientTexture", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientTexture", void 0),
k([Pe("opacityTexture")], t.prototype, "_opacityTexture", void 0),
k([Re("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "opacityTexture", void 0),
k([Pe("reflectionTexture")], t.prototype, "_reflectionTexture", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionTexture", void 0),
k([Pe("emissiveTexture")], t.prototype, "_emissiveTexture", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveTexture", void 0),
k([Pe("specularTexture")], t.prototype, "_specularTexture", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "specularTexture", void 0),
k([Pe("bumpTexture")], t.prototype, "_bumpTexture", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "bumpTexture", void 0),
k([Pe("lightmapTexture")], t.prototype, "_lightmapTexture", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "lightmapTexture", void 0),
k([Pe("refractionTexture")], t.prototype, "_refractionTexture", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "refractionTexture", void 0),
k([Me("ambient")], t.prototype, "ambientColor", void 0),
k([Me("diffuse")], t.prototype, "diffuseColor", void 0),
k([Me("specular")], t.prototype, "specularColor", void 0),
k([Me("emissive")], t.prototype, "emissiveColor", void 0),
k([Ce()], t.prototype, "specularPower", void 0),
k([Ce("useAlphaFromDiffuseTexture")], t.prototype, "_useAlphaFromDiffuseTexture", void 0),
k([Re("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "useAlphaFromDiffuseTexture", void 0),
k([Ce("useEmissiveAsIllumination")], t.prototype, "_useEmissiveAsIllumination", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useEmissiveAsIllumination", void 0),
k([Ce("linkEmissiveWithDiffuse")], t.prototype, "_linkEmissiveWithDiffuse", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "linkEmissiveWithDiffuse", void 0),
k([Ce("useSpecularOverAlpha")], t.prototype, "_useSpecularOverAlpha", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useSpecularOverAlpha", void 0),
k([Ce("useReflectionOverAlpha")], t.prototype, "_useReflectionOverAlpha", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useReflectionOverAlpha", void 0),
k([Ce("disableLighting")], t.prototype, "_disableLighting", void 0),
k([Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "disableLighting", void 0),
k([Ce("useObjectSpaceNormalMap")], t.prototype, "_useObjectSpaceNormalMap", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useObjectSpaceNormalMap", void 0),
k([Ce("useParallax")], t.prototype, "_useParallax", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useParallax", void 0),
k([Ce("useParallaxOcclusion")], t.prototype, "_useParallaxOcclusion", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useParallaxOcclusion", void 0),
k([Ce()], t.prototype, "parallaxScaleBias", void 0),
k([Ce("roughness")], t.prototype, "_roughness", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "roughness", void 0),
k([Ce()], t.prototype, "indexOfRefraction", void 0),
k([Ce()], t.prototype, "invertRefractionY", void 0),
k([Ce()], t.prototype, "alphaCutOff", void 0),
k([Ce("useLightmapAsShadowmap")], t.prototype, "_useLightmapAsShadowmap", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useLightmapAsShadowmap", void 0),
k([Ie("diffuseFresnelParameters")], t.prototype, "_diffuseFresnelParameters", void 0),
k([Re("_markAllSubMeshesAsFresnelDirty")], t.prototype, "diffuseFresnelParameters", void 0),
k([Ie("opacityFresnelParameters")], t.prototype, "_opacityFresnelParameters", void 0),
k([Re("_markAllSubMeshesAsFresnelAndMiscDirty")], t.prototype, "opacityFresnelParameters", void 0),
k([Ie("reflectionFresnelParameters")], t.prototype, "_reflectionFresnelParameters", void 0),
k([Re("_markAllSubMeshesAsFresnelDirty")], t.prototype, "reflectionFresnelParameters", void 0),
k([Ie("refractionFresnelParameters")], t.prototype, "_refractionFresnelParameters", void 0),
k([Re("_markAllSubMeshesAsFresnelDirty")], t.prototype, "refractionFresnelParameters", void 0),
k([Ie("emissiveFresnelParameters")], t.prototype, "_emissiveFresnelParameters", void 0),
k([Re("_markAllSubMeshesAsFresnelDirty")], t.prototype, "emissiveFresnelParameters", void 0),
k([Ce("useReflectionFresnelFromSpecular")], t.prototype, "_useReflectionFresnelFromSpecular", void 0),
k([Re("_markAllSubMeshesAsFresnelDirty")], t.prototype, "useReflectionFresnelFromSpecular", void 0),
k([Ce("useGlossinessFromSpecularMapAlpha")], t.prototype, "_useGlossinessFromSpecularMapAlpha", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useGlossinessFromSpecularMapAlpha", void 0),
k([Ce("maxSimultaneousLights")], t.prototype, "_maxSimultaneousLights", void 0),
k([Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "maxSimultaneousLights", void 0),
k([Ce("invertNormalMapX")], t.prototype, "_invertNormalMapX", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapX", void 0),
k([Ce("invertNormalMapY")], t.prototype, "_invertNormalMapY", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapY", void 0),
k([Ce("twoSidedLighting")], t.prototype, "_twoSidedLighting", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "twoSidedLighting", void 0),
k([Ce()], t.prototype, "useLogarithmicDepth", null),
t
}(gs);
y("BABYLON.StandardMaterial", Os),
mn.DefaultMaterialFactory = function(e) {
return new Os("default material",e)
}
,
Ht.prototype.createDynamicTexture = function(e, t, i, n) {
var r = new Lt(this,At.Dynamic);
return r.baseWidth = e,
r.baseHeight = t,
i && (e = this.needPOTTextures ? Ht.GetExponentOfTwo(e, this._caps.maxTextureSize) : e,
t = this.needPOTTextures ? Ht.GetExponentOfTwo(t, this._caps.maxTextureSize) : t),
r.width = e,
r.height = t,
r.isReady = !1,
r.generateMipMaps = i,
r.samplingMode = n,
this.updateTextureSamplingMode(n, r),
this._internalTexturesCache.push(r),
r
}
,
Ht.prototype.updateDynamicTexture = function(e, t, i, n, r, o, a) {
if (void 0 === n && (n = !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),
n && s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
var u = this._getWebGLTextureType(e.type)
, h = this._getInternalFormat(r || 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),
n && s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0),
e.isReady = !0
}
}
;
var Ds = function(e) {
function t(t, i, n, r, o, s, l) {
void 0 === n && (n = null),
void 0 === r && (r = !1),
void 0 === o && (o = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
void 0 === s && (s = a.TEXTUREFORMAT_RGBA);
var c = e.call(this, null, n, !r, l, o, void 0, void 0, void 0, void 0, s) || this;
c.name = t,
c.wrapU = io.CLAMP_ADDRESSMODE,
c.wrapV = io.CLAMP_ADDRESSMODE,
c._generateMipMaps = r;
var u = c._getEngine();
if (!u)
return c;
i.getContext ? (c._canvas = i,
c._texture = u.createDynamicTexture(i.width, i.height, r, o)) : (c._canvas = u.createCanvas(1, 1),
i.width || 0 === i.width ? c._texture = u.createDynamicTexture(i.width, i.height, r, o) : c._texture = u.createDynamicTexture(i, i, r, 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 U(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, n, r, 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 = n,
null == t) {
var c = this._context.measureText(e);
t = (l.width - c.width) / 2
}
if (null == i) {
var u = parseInt(n.replace(/\D/g, ""));
i = l.height / 2 + u / 3.65
}
this._context.fillStyle = r || "",
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()
, n = new t(this.name,i,e,this._generateMipMaps);
return n.hasAlpha = this.hasAlpha,
n.level = this.level,
n.wrapU = this.wrapU,
n.wrapV = this.wrapV,
n
}
,
t.prototype.serialize = function() {
var i = this.getScene();
i && !i.isReady() && K.Warn("The scene must be ready before serializing the dynamic texture");
var n = e.prototype.serialize.call(this);
return t._IsCanvasElement(this._canvas) && (n.base64String = this._canvas.toDataURL()),
n.invertY = this._invertY,
n.samplingMode = this.samplingMode,
n
}
,
t._IsCanvasElement = function(e) {
return void 0 !== e.toDataURL
}
,
t.prototype._rebuild = function() {
this.update()
}
,
t
}(io);
Pt.ShadersStore.imageProcessingPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\n#include\n#include\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec4 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;\n}";
var Ns, Ls, Fs = function(e) {
function t(t, i, n, r, o, s, l, c) {
void 0 === n && (n = null),
void 0 === l && (l = a.TEXTURETYPE_UNSIGNED_INT);
var u = e.call(this, t, "imageProcessing", [], [], i, n, r, 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,
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 U(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 n = null
, r = this.getEngine()
, o = this.getCamera();
if (o)
n = o.getScene();
else if (r && r.scenes) {
var a = r.scenes;
n = a[a.length - 1]
} else
n = E.LastCreatedScene;
this._imageProcessingConfiguration = n ? n.imageProcessingConfiguration : new Ri
}
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.vignetteCentreX
},
set: function(e) {
this.imageProcessingConfiguration.vignetteCentreX = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "vignetteCentreY", {
get: function() {
return this.imageProcessingConfiguration.vignetteCentreY
},
set: function(e) {
this.imageProcessingConfiguration.vignetteCentreY = 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, "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, ";\r\n"));
var i = ["textureSampler"]
, n = ["scale"];
Ri && (Ri.PrepareSamplers(i, this._defines),
Ri.PrepareUniforms(n, this._defines)),
this.updateEffect(e, n, 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)
}
,
k([Ce()], t.prototype, "_fromLinearSpace", void 0),
t
}(Ba), ws = function() {
function e(e, t, i, n, r) {
this.getWidth = e,
this.getHeight = t,
this.layer = i,
this.layerType = n,
this.createRenderTargetTextureProvider = r
}
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
}(), Bs = 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 Lt(this._engine,At.Unknown,!0);
return i.width = e.width,
i.height = e.height,
i._hardwareTexture = new kt(t,this._engine._gl),
i.isReady = !0,
i
}
,
e.prototype._createRenderTargetTexture = function(e, t, i, n, r, o) {
if (!this._engine)
throw new Error("Engine is disposed");
var a = {
width: e,
height: t
}
, s = o ? new rs(this._scene,a) : new ns("XR renderTargetTexture",a,this._scene)
, l = s.renderTarget;
if (!i && n || (l._framebuffer = i),
n)
if (o)
l._colorTextureArray = n;
else {
var c = this._createInternalTexture(a, n);
l.setTexture(c, 0),
s._texture = c
}
return r && (o ? l._depthStencilTextureArray = r : l._depthStencilTexture = this._createInternalTexture(a, r)),
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
}(), Us = function(e) {
function t(t) {
var i = e.call(this, (function() {
return t.framebufferWidth
}
), (function() {
return t.framebufferHeight
}
), t, "XRWebGLLayer", (function(e) {
return new Vs(e.scene,i)
}
)) || this;
return i.layer = t,
i
}
return U(t, e),
t
}(ws), Vs = function(e) {
function t(t, i) {
var n = e.call(this, t, i) || this;
return n.layerWrapper = i,
n._layer = i.layer,
n._framebufferDimensions = {
framebufferWidth: n._layer.framebufferWidth,
framebufferHeight: n._layer.framebufferHeight
},
n
}
return U(t, e),
t.prototype.trySetViewportForView = function(e, t) {
var i = this._layer.getViewport(t)
, n = this._framebufferDimensions.framebufferWidth
, r = this._framebufferDimensions.framebufferHeight;
return e.x = i.x / n,
e.y = i.y / r,
e.width = i.width / n,
e.height = i.height / r,
!0
}
,
t.prototype.getRenderTargetTextureForEye = function(e) {
var t = this._layer.framebufferWidth
, i = this._layer.framebufferHeight
, n = this._layer.framebuffer;
return this._rtt && t === this._framebufferDimensions.framebufferWidth && i === this._framebufferDimensions.framebufferHeight && n === this._framebuffer || (this._rtt = this._createRenderTargetTexture(t, i, n),
this._framebufferDimensions.framebufferWidth = t,
this._framebufferDimensions.framebufferHeight = i,
this._framebuffer = n),
this._rtt
}
,
t.prototype.getRenderTargetTextureForView = function(e) {
return this.getRenderTargetTextureForEye(e.eye)
}
,
t
}(Bs), ks = 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,
multiview: !1,
framebufferScaleFactor: 1
},
i.newCanvasCssStyle = "position:absolute; bottom:0px;right:0px;z-index:10;width:90%;height:100%;background-color: #000000;",
i
}
,
e
}(), Gs = function() {
function e(e, t) {
void 0 === t && (t = ks.GetDefaults());
var i = this;
if (this._options = t,
this._canvas = null,
this._engine = null,
this.xrLayer = null,
this._xrLayerWrapper = null,
this.onXRLayerInitObservable = new h,
this._engine = e.scene.getEngine(),
this._engine.onDisposeObservable.addOnce((function() {
i._engine = null
}
)),
t.canvasElement)
this._setManagedOutputCanvas(t.canvasElement);
else {
var n = document.createElement("canvas");
n.style.cssText = this._options.newCanvasCssStyle || "position:absolute; bottom:0px;right:0px;",
this._setManagedOutputCanvas(n)
}
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 G(this, void 0, void 0, (function() {
var t, i = this;
return z(this, (function(n) {
return t = function() {
return i.xrLayer = new XRWebGLLayer(e,i.canvasContext,i._options.canvasOptions),
i._xrLayerWrapper = new Us(i.xrLayer),
i.onXRLayerInitObservable.notifyObservers(i.xrLayer),
i.xrLayer
}
,
this.canvasContext.makeXRCompatible ? [2, this.canvasContext.makeXRCompatible().then((function() {}
), (function() {
gi.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
}(), zs = function(e) {
function t(t) {
var i = e.call(this, (function() {
return t.framebufferWidth
}
), (function() {
return t.framebufferHeight
}
), t, "XRWebGLLayer", (function(e) {
return new Ws(e,i)
}
)) || this;
return i.layer = t,
i
}
return U(t, e),
t
}(ws), Ws = function(e) {
function t(t, i) {
var n = e.call(this, t.scene, i) || this;
return n.layerWrapper = i,
n._nativeRTTProvider = navigator.xr.getNativeRenderTargetProvider(t.session, n._createRenderTargetTexture.bind(n), n._destroyRenderTargetTexture.bind(n)),
n._nativeLayer = i.layer,
n
}
return U(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
}(Bs), Hs = function() {
function e(e) {
this._nativeRenderTarget = navigator.xr.getWebXRRenderTarget(e.scene.getEngine())
}
return e.prototype.initializeXRLayerAsync = function(e) {
return G(this, void 0, void 0, (function() {
return z(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
}(), Xs = function() {
function e(e) {
var t = this;
this.scene = e,
this.currentTimestamp = -1,
this.defaultHeightCompensation = 1.7,
this.onXRFrameObservable = new h,
this.onXRReferenceSpaceChanged = new h,
this.onXRSessionEnded = new h,
this.onXRSessionInit = new h,
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() {
K.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 Hs(this) : ((e = e || ks.GetDefaults(t)).canvasElement = e.canvasElement || t.getRenderingCanvas() || void 0,
new Gs(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 n;
t.inXRSession && t._engine && (t.currentFrame = i,
t.currentTimestamp = e,
i && (t.inXRFrameLoop = !0,
t._engine.framebufferDimensionsObject = (null === (n = t._baseLayerRTTProvider) || void 0 === n ? void 0 : n.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 K.Error("XR.requestReferenceSpace failed for the following reason: "),
K.Error(e),
K.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 K.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.updateRenderState = function(e) {
e.baseLayer && this._setBaseLayerWrapper(this.isNative ? new zs(e.baseLayer) : new Us(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 K.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
}),
e
}();
function js(e) {
var t = e.height || 2
, i = 0 === e.diameterTop ? 0 : e.diameterTop || e.diameter || 1
, n = 0 === e.diameterBottom ? 0 : e.diameterBottom || e.diameter || 1;
i = i || 1e-5,
n = n || 1e-5;
var r, o = e.tessellation || 24, a = e.subdivisions || 1, s = !!e.hasRings, l = !!e.enclose, c = 0 === e.cap ? 0 : e.cap || Vr.CAP_ALL, u = e.arc && (e.arc <= 0 || e.arc > 1) ? 1 : e.arc || 1, h = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE, d = e.faceUV || new Array(3), p = e.faceColors, f = 2 + (1 + (1 !== u && l ? 2 : 0)) * (s ? a : 1);
for (r = 0; r < f; r++)
p && void 0 === p[r] && (p[r] = new N(1,1,1,1));
for (r = 0; r < f; r++)
d && void 0 === d[r] && (d[r] = new R(0,0,1,1));
var _, m, g, v, y, b, T = new Array, E = new Array, S = new Array, C = new Array, P = new Array, M = 2 * Math.PI * u / o, I = (n - i) / 2 / t, O = x.Zero(), D = x.Zero(), L = x.Zero(), F = x.Zero(), w = x.Zero(), B = vn.Y, U = 1, V = 1, k = 0, G = 0;
for (v = 0; v <= a; v++)
for (g = ((m = v / a) * (i - n) + n) / 2,
U = s && 0 !== v && v !== a ? 2 : 1,
b = 0; b < U; b++) {
for (s && (V += b),
l && (V += 2 * b),
y = 0; y <= o; y++)
_ = y * M,
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) * I,
D.normalize()),
0 === y && (L.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,
C.push(d[V].x + (d[V].z - d[V].x) * y / o, pr.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(L.x, L.y, L.z),
x.CrossToRef(B, D, w),
w.normalize(),
S.push(w.x, w.y, w.z, w.x, w.y, w.z),
x.CrossToRef(F, B, w),
w.normalize(),
S.push(w.x, w.y, w.z, w.x, w.y, w.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,
C.push(d[V + 1].x, pr.UseOpenGLOrientationForUV ? 1 - G : G),
C.push(d[V + 1].z, pr.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,
C.push(d[V + 2].x, pr.UseOpenGLOrientationForUV ? 1 - G : G),
C.push(d[V + 2].z, pr.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 r = e ? i / 2 : n / 2;
if (0 !== r) {
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 x(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);
C.push(c.x + .5 * (c.z - c.x), pr.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)
, R = Math.sin(-a);
s = new x(b * r,m,R * r);
var M = new A(b * y.x + .5,R * y.y + .5);
E.push(s.x, s.y, s.z),
S.push(0, e ? 1 : -1, 0);
var I = c.y + (c.w - c.y) * M.y;
C.push(c.x + (c.z - c.x) * M.x, pr.UseOpenGLOrientationForUV ? 1 - I : I),
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 !== Vr.CAP_START && c !== Vr.CAP_ALL || Y(!1),
c !== Vr.CAP_END && c !== Vr.CAP_ALL || Y(!0),
$n._ComputeSides(h, E, T, S, C, e.frontUVs, e.backUVs);
var K = new $n;
return K.indices = T,
K.positions = E,
K.normals = S,
K.uvs = C,
p && (K.colors = P),
K
}
function Ys(e, t, i) {
void 0 === t && (t = {});
var n = new Vr(e,i);
return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
n._originalBuilderSideOrientation = t.sideOrientation,
js(t).applyToMesh(n, t.updatable),
n
}
!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"
}(Ns || (Ns = {})),
function(e) {
e[e.NOT_TRACKING = 0] = "NOT_TRACKING",
e[e.TRACKING_LOST = 1] = "TRACKING_LOST",
e[e.TRACKING = 2] = "TRACKING"
}(Ls || (Ls = {}));
var Ks = {
CreateCylinder: Ys
};
function Qs(e) {
for (var t = [], i = [], n = [], r = [], o = e.diameter || 1, a = e.thickness || .5, s = e.tessellation || 16, l = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE, c = s + 1, u = 0; u <= s; u++)
for (var h = u / s, d = u * Math.PI * 2 / s - Math.PI / 2, p = P.Translation(o / 2, 0, 0).multiply(P.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 x(g,v,0)
, b = y.scale(a / 2)
, T = new A(h,_);
b = x.TransformCoordinates(b, p),
y = x.TransformNormal(y, p),
i.push(b.x, b.y, b.z),
n.push(y.x, y.y, y.z),
r.push(T.x, pr.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)
}
$n._ComputeSides(l, i, t, n, r, e.frontUVs, e.backUVs);
var R = new $n;
return R.indices = t,
R.positions = i,
R.normals = n,
R.uvs = r,
R
}
function qs(e, t, i) {
void 0 === t && (t = {});
var n = new Vr(e,i);
return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
n._originalBuilderSideOrientation = t.sideOrientation,
Qs(t).applyToMesh(n, t.updatable),
n
}
$n.CreateCylinder = js,
Vr.CreateCylinder = function(e, t, i, n, r, o, a, s, l) {
return void 0 !== a && a instanceof mn || (void 0 !== a && (l = s || Vr.DEFAULTSIDE,
s = a),
a = o,
o = 1),
Ys(e, {
height: t,
diameterTop: i,
diameterBottom: n,
tessellation: r,
subdivisions: o,
sideOrientation: l,
updatable: s
}, a)
}
;
var Zs = {
CreateTorus: qs
};
$n.CreateTorus = Qs,
Vr.CreateTorus = function(e, t, i, n, r, o, a) {
return qs(e, {
diameter: t,
thickness: i,
tessellation: n,
sideOrientation: a,
updatable: o
}, r)
}
,
Vr._GroundMeshParser = function(e, t) {
return Js.Parse(e, t)
}
;
var Js = function(e) {
function t(t, i) {
var n = e.call(this, t, i) || this;
return n.generateOctree = !1,
n
}
return U(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()
, n = I.Matrix[5];
i.invertToRef(n);
var r = I.Vector3[8];
if (x.TransformCoordinatesFromFloatsToRef(e, 0, t, n, r),
e = r.x,
t = r.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 x.TransformCoordinatesFromFloatsToRef(0, a, 0, i, r),
r.y
}
,
t.prototype.getNormalAtCoordinates = function(e, t) {
var i = new x(0,1,0);
return this.getNormalAtCoordinatesToRef(e, t, i),
i
}
,
t.prototype.getNormalAtCoordinatesToRef = function(e, t, i) {
var n = this.getWorldMatrix()
, r = I.Matrix[5];
n.invertToRef(r);
var o = I.Vector3[8];
if (x.TransformCoordinatesFromFloatsToRef(e, 0, t, r, 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 x.TransformNormalFromFloatsToRef(a.x, a.y, a.z, n, 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)
, n = Math.floor(-(t + this._maxZ) * this._subdivisionsY / this._height + this._subdivisionsY)
, r = this._heightQuads[n * this._subdivisionsX + i];
return t < r.slope.x * e + r.slope.y ? r.facet1 : r.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 n = 0; n < e; n++) {
var r = {
slope: A.Zero(),
facet1: new R(0,0,0,0),
facet2: new R(0,0,0,0)
};
this._heightQuads[i * e + n] = r
}
return this
}
,
t.prototype._computeHeightQuads = function() {
var e = this.getVerticesData(Bi.PositionKind);
if (!e)
return this;
for (var t = I.Vector3[3], i = I.Vector3[2], n = I.Vector3[1], r = I.Vector3[0], o = I.Vector3[4], a = I.Vector3[5], s = I.Vector3[6], l = I.Vector3[7], c = I.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],
n.x = e[d + u],
n.y = e[d + u + 1],
n.z = e[d + u + 2],
r.x = e[d + u + 3],
r.y = e[d + u + 4],
r.z = e[d + u + 5],
p = (r.z - t.z) / (r.x - t.x),
f = t.z - p * t.x,
i.subtractToRef(t, o),
n.subtractToRef(t, a),
r.subtractToRef(t, s),
x.CrossToRef(s, a, l),
x.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 n = new t(e.name,i);
return n._subdivisionsX = e.subdivisionsX || 1,
n._subdivisionsY = e.subdivisionsY || 1,
n._minX = e.minX,
n._maxX = e.maxX,
n._minZ = e.minZ,
n._maxZ = e.maxZ,
n._width = e.width,
n._height = e.height,
n
}
,
t
}(Vr);
function $s(e) {
var t, i, n = [], r = [], o = [], a = [], s = e.width || 1, l = e.height || 1, c = e.subdivisionsX || e.subdivisions || 1, u = e.subdivisionsY || e.subdivisions || 1;
for (t = 0; t <= u; t++)
for (i = 0; i <= c; i++) {
var h = new x(i * s / c - s / 2,0,(u - t) * l / u - l / 2)
, d = new x(0,1,0);
r.push(h.x, h.y, h.z),
o.push(d.x, d.y, d.z),
a.push(i / c, pr.UseOpenGLOrientationForUV ? t / u : 1 - t / u)
}
for (t = 0; t < u; t++)
for (i = 0; i < c; i++)
n.push(i + 1 + (t + 1) * (c + 1)),
n.push(i + 1 + t * (c + 1)),
n.push(i + t * (c + 1)),
n.push(i + (t + 1) * (c + 1)),
n.push(i + 1 + (t + 1) * (c + 1)),
n.push(i + t * (c + 1));
var p = new $n;
return p.indices = n,
p.positions = r,
p.normals = o,
p.uvs = a,
p
}
function el(e) {
var t, i, n, r, 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, n, r, 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 = x.Zero()
, _ = new x(0,1,0);
for (t = 0; t <= u.h; t++)
for (c.z = t * (o - n) / u.h + n,
i = 0; i <= u.w; i++)
c.x = i * (r - 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 (n = 0; n < c.h; n++)
for (r = 0; r < c.w; r++)
g(o + r * _, a + n * m, o + (r + 1) * _, a + (n + 1) * m);
var v = new $n;
return v.indices = h,
v.positions = d,
v.normals = p,
v.uvs = f,
v
}
function tl(e) {
var t, i, n = [], r = [], o = [], a = [], s = e.colorFilter || new D(.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 x(i * e.width / e.subdivisions - e.width / 2,0,(e.subdivisions - t) * e.height / e.subdivisions - e.height / 2)
, d = 4 * (((h.x + e.width / 2) / e.width * (e.bufferWidth - 1) | 0) + ((1 - (h.z + e.height / 2) / e.height) * (e.bufferHeight - 1) | 0) * e.bufferWidth)
, p = e.buffer[d] / 255
, f = e.buffer[d + 1] / 255
, _ = e.buffer[d + 2] / 255
, g = e.buffer[d + 3] / 255;
c && (p = 1 - p,
f = 1 - f,
_ = 1 - _);
var v = p * s.r + f * s.g + _ * s.b;
h.y = g >= l ? e.minHeight + (e.maxHeight - e.minHeight) * v : e.minHeight - m,
r.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 = r[3 * y + 1] >= e.minHeight
, A = r[3 * b + 1] >= e.minHeight
, R = r[3 * T + 1] >= e.minHeight;
S && A && R && (n.push(y),
n.push(b),
n.push(T)),
r[3 * E + 1] >= e.minHeight && S && R && (n.push(E),
n.push(y),
n.push(T))
}
$n.ComputeNormals(r, n, o);
var C = new $n;
return C.indices = n,
C.positions = r,
C.normals = o,
C.uvs = a,
C
}
function il(e, t, i) {
void 0 === t && (t = {});
var n = new Js(e,i);
return n._setReady(!1),
n._subdivisionsX = t.subdivisionsX || t.subdivisions || 1,
n._subdivisionsY = t.subdivisionsY || t.subdivisions || 1,
n._width = t.width || 1,
n._height = t.height || 1,
n._maxX = n._width / 2,
n._maxZ = n._height / 2,
n._minX = -n._maxX,
n._minZ = -n._maxZ,
$s(t).applyToMesh(n, t.updatable),
n._setReady(!0),
n
}
function nl(e, t, i) {
void 0 === i && (i = null);
var n = new Vr(e,i);
return el(t).applyToMesh(n, t.updatable),
n
}
function rl(e, t, i, n) {
void 0 === i && (i = {}),
void 0 === n && (n = null);
var r = i.width || 10
, o = i.height || 10
, a = i.subdivisions || 1
, s = i.minHeight || 0
, l = i.maxHeight || 1
, c = i.colorFilter || new D(.3,.59,.11)
, u = i.alphaFilter || 0
, h = i.updatable
, d = i.onReady;
n = n || E.LastCreatedScene;
var p = new Js(e,n);
return p._subdivisionsX = a,
p._subdivisionsY = a,
p._width = r,
p._height = o,
p._maxX = p._width / 2,
p._maxZ = p._height / 2,
p._minX = -p._maxX,
p._minZ = -p._maxZ,
p._setReady(!1),
gi.LoadImage(t, (function(e) {
var t = e.width
, i = e.height;
if (!n.isDisposed) {
var f = null == n ? void 0 : n.getEngine().resizeImageBitmap(e, t, i);
tl({
width: r,
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() {}
), n.offlineProvider),
p
}
var ol = {
CreateGround: il,
CreateGroundFromHeightMap: rl,
CreateTiledGround: nl
};
$n.CreateGround = $s,
$n.CreateTiledGround = el,
$n.CreateGroundFromHeightMap = tl,
Vr.CreateGround = function(e, t, i, n, r, o) {
return il(e, {
width: t,
height: i,
subdivisions: n,
updatable: o
}, r)
}
,
Vr.CreateTiledGround = function(e, t, i, n, r, o, a, s, l) {
return nl(e, {
xmin: t,
zmin: i,
xmax: n,
zmax: r,
subdivisions: o,
precision: a,
updatable: l
}, s)
}
,
Vr.CreateGroundFromHeightMap = function(e, t, i, n, r, o, a, s, l, c, u) {
return rl(e, t, {
width: i,
height: n,
subdivisions: r,
minHeight: o,
maxHeight: a,
updatable: l,
onReady: c,
alphaFilter: u
}, s)
}
;
var al, sl = 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 = qs("gazeTracker", {
diameter: .0035,
thickness: .0025,
tessellation: 20,
updatable: !1
}, t),
this._gazeTracker.bakeCurrentTransformIntoVertices(),
this._gazeTracker.isPickable = !1,
this._gazeTracker.isVisible = !1;
var n = new Os("targetMat",t);
n.specularColor = D.Black(),
n.emissiveColor = new D(.7,.7,.7),
n.backFaceCulling = !1,
this._gazeTracker.material = n
}
}
return e.prototype._getForwardRay = function(e) {
return new _o(x.Zero(),new x(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
}(), ll = function(e) {
function t(t, i, n) {
var r = e.call(this, i, n) || this;
r.webVRController = t,
r._laserPointer = Ys("laserPointer", {
updatable: !1,
height: 1,
diameterTop: .004,
diameterBottom: 2e-4,
tessellation: 20,
subdivisions: 1
}, i);
var o = new Os("laserPointerMat",i);
if (o.emissiveColor = new D(.7,.7,.7),
o.alpha = .6,
r._laserPointer.material = o,
r._laserPointer.rotation.x = Math.PI / 2,
r._laserPointer.position.z = -.5,
r._laserPointer.isVisible = !1,
r._laserPointer.isPickable = !1,
!t.mesh) {
var a = new Vr("preloadControllerMesh",i)
, s = new Vr(Ra.POINTING_POSE,i);
s.rotation.x = -.7,
a.addChild(s),
t.attachToMesh(a)
}
return r._setLaserPointerParent(t.mesh),
r._meshAttachedObserver = t._meshAttachedObservable.add((function(e) {
r._setLaserPointerParent(e)
}
)),
r
}
return U(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)
, n = e;
this.webVRController._pointingPoseNode = null;
for (var r = 0; r < i.length; r++)
if (i[r].name && i[r].name.indexOf(Ra.POINTING_POSE) >= 0) {
n = i[r],
this.webVRController._pointingPoseNode = n;
break
}
this._laserPointer.parent = n
}
,
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
}(sl), cl = function(e) {
function t(t, i) {
var n = e.call(this, i) || this;
return n._getCamera = t,
n
}
return U(t, e),
t.prototype._getForwardRay = function(e) {
var t = this._getCamera();
return t ? t.getForwardRay(e) : new _o(x.Zero(),x.Forward())
}
,
t
}(sl), ul = function() {}, hl = function() {
function e(t, i) {
void 0 === i && (i = {});
var n = 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 h,
this.onAfterEnteringVRObservable = new h,
this.onExitingVRObservable = new h,
this.onControllerMeshLoadedObservable = new h,
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 x(0,-1,-1),
this._isDefaultTeleportationTarget = !0,
this._teleportationFillColor = "#444444",
this._teleportationBorderColor = "#FFFFFF",
this._rotationAngle = 0,
this._haloCenter = new x(0,0,0),
this._padSensibilityUp = .65,
this._padSensibilityDown = .35,
this._leftController = null,
this._rightController = null,
this._gazeColor = new D(.7,.7,.7),
this._laserColor = new D(.7,.7,.7),
this._pickedLaserColor = new D(.2,.2,1),
this._pickedGazeColor = new D(0,0,1),
this.onNewMeshSelected = new h,
this.onMeshSelectedWithController = new h,
this.onNewMeshPicked = new h,
this.onBeforeCameraTeleport = new h,
this.onAfterCameraTeleport = new h,
this.onSelectedMeshUnselected = new h,
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() {
n._moveButtonToBottomRight(),
n._fullscreenVRpresenting && n._webVRready && n.exitVR()
}
,
this._onFullscreenChange = function() {
var e = document;
void 0 !== e.fullscreen ? n._fullscreenVRpresenting = document.fullscreen : void 0 !== e.mozFullScreen ? n._fullscreenVRpresenting = e.mozFullScreen : void 0 !== e.webkitIsFullScreen ? n._fullscreenVRpresenting = e.webkitIsFullScreen : void 0 !== e.msIsFullScreen ? n._fullscreenVRpresenting = e.msIsFullScreen : void 0 !== document.msFullscreenElement && (n._fullscreenVRpresenting = document.msFullscreenElement),
!n._fullscreenVRpresenting && n._inputElement && (n.exitVR(),
!n._useCustomVRButton && n._btnVR && (n._btnVR.style.top = n._inputElement.offsetTop + n._inputElement.offsetHeight - 70 + "px",
n._btnVR.style.left = n._inputElement.offsetLeft + n._inputElement.offsetWidth - 100 + "px",
n._updateButtonVisibility()))
}
,
this._cachedAngularSensibility = {
angularSensibilityX: null,
angularSensibilityY: null,
angularSensibility: null
},
this._beforeRender = function() {
n._leftController && n._leftController._activePointer && n._castRayAndSelectObject(n._leftController),
n._rightController && n._rightController._activePointer && n._castRayAndSelectObject(n._rightController),
n._noControllerIsActive && (n._scene.getEngine().isPointerLock || n.enableGazeEvenWhenNoPointerLock) ? n._castRayAndSelectObject(n._cameraGazer) : n._cameraGazer._gazeTracker.isVisible = !1
}
,
this._onNewGamepadConnected = function(e) {
if (e.type !== zo.POSE_ENABLED)
e.leftStick && e.onleftstickchanged((function(e) {
n._teleportationInitialized && n.teleportationEnabled && (!n._leftController && !n._rightController || n._leftController && !n._leftController._activePointer && n._rightController && !n._rightController._activePointer) && (n._checkTeleportWithRay(e, n._cameraGazer),
n._checkTeleportBackwards(e, n._cameraGazer))
}
)),
e.rightStick && e.onrightstickchanged((function(e) {
n._teleportationInitialized && n._checkRotate(e, n._cameraGazer)
}
)),
e.type === zo.XBOX && (e.onbuttondown((function(e) {
n._interactionsEnabled && e === Sa.A && n._cameraGazer._selectionPointerDown()
}
)),
e.onbuttonup((function(e) {
n._interactionsEnabled && e === Sa.A && n._cameraGazer._selectionPointerUp()
}
)));
else {
var t = e
, i = new ll(t,n._scene,n._cameraGazer._gazeTracker);
"right" === t.hand || n._leftController && n._leftController.webVRController != t ? n._rightController = i : n._leftController = i,
n._tryEnableInteractionOnController(i)
}
}
,
this._tryEnableInteractionOnController = function(e) {
n._interactionsRequested && !e._interactionsEnabled && n._enableInteractionOnController(e),
n._teleportationRequested && !e._teleportationEnabled && n._enableTeleportationOnController(e)
}
,
this._onNewGamepadDisconnected = function(e) {
e instanceof _s && ("left" === e.hand && null != n._leftController && (n._leftController.dispose(),
n._leftController = null),
"right" === e.hand && null != n._rightController && (n._rightController.dispose(),
n._rightController = null))
}
,
this._workingVector = x.Zero(),
this._workingQuaternion = C.Identity(),
this._workingMatrix = P.Identity(),
K.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 x(0,this._defaultHeight,0),
i.createDeviceOrientationCamera || !this._scene.activeCamera) {
if (this._deviceOrientationCamera = new ma("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 da && this._scene.activeCamera.rotation)) {
var r = this._scene.activeCamera;
r.rotationQuaternion ? this._deviceOrientationCamera.rotationQuaternion.copyFrom(r.rotationQuaternion) : this._deviceOrientationCamera.rotationQuaternion.copyFrom(C.RotationYawPitchRoll(r.rotation.y, r.rotation.x, r.rotation.z)),
this._deviceOrientationCamera.rotation = r.rotation.clone()
}
this._scene.activeCamera = this._deviceOrientationCamera,
this._inputElement && this._scene.activeCamera.attachControl()
} else
this._existingCamera = this._scene.activeCamera;
this.webVROptions.useXR && navigator.xr ? Xs.IsSessionSupportedAsync("immersive-vr").then((function(e) {
e ? (K.Log("Using WebXR. It is recommended to use the WebXRDefaultExperience directly"),
t.createDefaultXRExperienceAsync({
floorMeshes: i.floorMeshes || []
}).then((function(e) {
n.xr = e,
n.xrTestDone = !0,
n._cameraGazer = new cl((function() {
return n.xr.baseExperience.camera
}
),t),
n.xr.baseExperience.onStateChangedObservable.add((function(e) {
switch (e) {
case Ns.ENTERING_XR:
n.onEnteringVRObservable.notifyObservers(n),
n._interactionsEnabled || n.xr.pointerSelection.detach(),
n.xr.pointerSelection.displayLaserPointer = n._displayLaserPointer;
break;
case Ns.EXITING_XR:
n.onExitingVRObservable.notifyObservers(n),
n._scene.getEngine().resize();
break;
case Ns.IN_XR:
n._hasEnteredVR = !0;
break;
case Ns.NOT_IN_XR:
n._hasEnteredVR = !1
}
}
))
}
))) : n._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 = ts.GetDefault()),
t.vrDeviceOrientationCameraMetrics.multiviewEnabled = !0),
this._vrDeviceOrientationCamera = new us("VRDeviceOrientationVRHelper",this._position,this._scene,!0,t.vrDeviceOrientationCameraMetrics),
this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE),
this._webVRCamera = new fs("WebVRHelper",this._position,this._scene,t),
this._webVRCamera.useStandingMatrix(),
this._cameraGazer = new cl((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 n = ".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) }";
n += ".babylonVRicon.vrdisplaypresenting { display: none; }";
var r = document.createElement("style");
r.appendChild(document.createTextNode(n)),
document.getElementsByTagName("head")[0].appendChild(r),
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),
document.addEventListener("mozfullscreenchange", this._onFullscreenChange, !1),
document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, !1),
document.addEventListener("msfullscreenchange", this._onFullscreenChange, !1),
document.onmsfullscreenchange = this._onFullscreenChange,
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())
}
), Xi.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 In,
this._circleEase.setEasingMode(Mn.EASINGMODE_EASEINOUT),
this._teleportationEasing = this._circleEase,
e.onPointerObservable.add((function(t) {
i._interactionsEnabled && e.activeCamera === i.vrDeviceOrientationCamera && "mouse" === t.event.pointerType && (t.type === Xi.POINTERDOWN ? i._cameraGazer._selectionPointerDown() : t.type === Xi.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) {
K.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 === Ns.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
K.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) {
K.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 = C.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles(),
this.vrDeviceOrientationCamera.angularSensibility = 2e3),
this.webVRCamera) {
var t = this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y
, i = C.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y - t
, n = this.webVRCamera.rotationQuaternion.toEulerAngles().y;
this.webVRCamera.rotationQuaternion = C.FromEulerAngles(0, n + 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) {
K.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 === Ns.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 n = this._scene.getMeshByName(e.floorMeshName);
n && i.push(n)
}
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 r = function() {
t.xrTestDone && (t._scene.unregisterBeforeRender(r),
t.xr ? t.xr.teleportation.attached || t.xr.teleportation.attach() : t.enableTeleportation(e))
};
return void this._scene.registerBeforeRender(r)
}
}
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 Ri;
o.vignetteColor = new N(0,0,0,0),
o.vignetteEnabled = !0,
this._postProcessMove = new Fs("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 n = e;
t._noControllerIsActive && (n = t._cameraGazer),
n._pointerDownOnMeshAsked ? i.value < t._padSensibilityDown && n._selectionPointerUp() : i.value > t._padSensibilityUp && n._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 = C.FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix())
, n = this.currentVRCamera.position;
this.currentVRCamera.devicePosition && this.currentVRCamera.deviceRotationQuaternion && (i = this.currentVRCamera.deviceRotationQuaternion,
n = this.currentVRCamera.devicePosition),
i.toEulerAnglesToRef(this._workingVector),
this._workingVector.z = 0,
this._workingVector.x = 0,
C.RotationYawPitchRollToRef(this._workingVector.y, this._workingVector.x, this._workingVector.z, this._workingQuaternion),
this._workingQuaternion.toRotationMatrix(this._workingMatrix),
x.TransformCoordinatesToRef(this._teleportBackwardsVector, this._workingMatrix, this._workingVector);
var r = new _o(n,this._workingVector)
, o = this._scene.pickWithRay(r, 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 === ba.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 = il("teleportationTarget", {
width: 2,
height: 2,
subdivisions: 2
}, this._scene),
this._teleportationTarget.isPickable = !1;
var e = new Ds("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 Os("TextPlaneMaterial",this._scene);
i.diffuseTexture = e,
this._teleportationTarget.material = i;
var n = qs("torusTeleportation", {
diameter: .75,
thickness: .1,
tessellation: 25,
updatable: !1
}, this._scene);
n.isPickable = !1,
n.parent = this._teleportationTarget;
var r = new Qe("animationInnerCircle","position.y",30,Qe.ANIMATIONTYPE_FLOAT,Qe.ANIMATIONLOOPMODE_CYCLE)
, o = [];
o.push({
frame: 0,
value: 0
}),
o.push({
frame: 30,
value: .4
}),
o.push({
frame: 60,
value: 0
}),
r.setKeys(o);
var a = new kn;
a.setEasingMode(Mn.EASINGMODE_EASEINOUT),
r.setEasingFunction(a),
n.animations = [],
n.animations.push(r),
this._scene.beginAnimation(n, 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 pa) {
e ? this._rotationAngle++ : this._rotationAngle--,
this.currentVRCamera.animations = [];
var i = C.FromRotationMatrix(P.RotationY(Math.PI / 4 * this._rotationAngle))
, n = new Qe("animationRotation","rotationQuaternion",90,Qe.ANIMATIONTYPE_QUATERNION,Qe.ANIMATIONLOOPMODE_CONSTANT)
, r = [];
r.push({
frame: 0,
value: this.currentVRCamera.rotationQuaternion
}),
r.push({
frame: 6,
value: i
}),
n.setKeys(r),
n.setEasingFunction(this._circleEase),
this.currentVRCamera.animations.push(n),
this._postProcessMove.animations = [];
var o = new Qe("animationPP","vignetteWeight",90,Qe.ANIMATIONTYPE_FLOAT,Qe.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 Qe("animationPP2","vignetteStretch",90,Qe.ANIMATIONTYPE_FLOAT,Qe.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 n = this._convertNormalToDirectionOfRay(e.getNormal(!0, !1), i);
if (n) {
var r = x.Cross(vn.Y, n)
, o = x.Cross(n, r);
x.RotationFromAxisToRef(o, n, r, this._teleportationTarget.rotation)
}
this._teleportationTarget.position.y += .1
}
}
,
e.prototype.teleportCamera = function(t) {
var i = this;
if (this.currentVRCamera instanceof pa) {
var n, r;
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) {
r = 90;
var o = x.Distance(this.currentVRCamera.position, this._workingVector);
n = this._teleportationSpeed / o
} else
r = Math.round(90 * this._teleportationTime / 1e3),
n = 1;
this.currentVRCamera.animations = [];
var a = new Qe("animationCameraTeleportation","position",90,Qe.ANIMATIONTYPE_VECTOR3,Qe.ANIMATIONLOOPMODE_CONSTANT)
, s = [{
frame: 0,
value: this.currentVRCamera.position
}, {
frame: r,
value: this._workingVector
}];
a.setKeys(s),
a.setEasingFunction(this._teleportationEasing),
this.currentVRCamera.animations.push(a),
this._postProcessMove.animations = [];
var l = Math.round(r / 2)
, c = new Qe("animationPP","vignetteWeight",90,Qe.ANIMATIONTYPE_FLOAT,Qe.ANIMATIONLOOPMODE_CONSTANT)
, u = [];
u.push({
frame: 0,
value: 0
}),
u.push({
frame: l,
value: 8
}),
u.push({
frame: r,
value: 0
}),
c.setKeys(u),
this._postProcessMove.animations.push(c);
var h = new Qe("animationPP2","vignetteStretch",90,Qe.ANIMATIONTYPE_FLOAT,Qe.ANIMATIONLOOPMODE_CONSTANT)
, d = [];
d.push({
frame: 0,
value: 0
}),
d.push({
frame: l,
value: 10
}),
d.push({
frame: r,
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, r, !1, n, (function() {
i._webVRCamera.detachPostProcess(i._postProcessMove)
}
)),
this._scene.beginAnimation(this.currentVRCamera, 0, r, !1, n, (function() {
i.onAfterCameraTeleport.notifyObservers(i._workingVector)
}
)),
this._hideTeleportationTarget()
}
}
,
e.prototype._convertNormalToDirectionOfRay = function(e, t) {
return e && Math.acos(x.Dot(e, t.direction)) < Math.PI / 2 && e.scaleInPlace(-1),
e
}
,
e.prototype._castRayAndSelectObject = function(e) {
if (this.currentVRCamera instanceof pa) {
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 n = 1;
e._gazeTracker.isVisible = !0,
e._isActionableMesh && (n = 3),
this.updateGazeTrackerScale && (e._gazeTracker.scaling.x = i.distance * n,
e._gazeTracker.scaling.y = i.distance * n,
e._gazeTracker.scaling.z = i.distance * n);
var r = this._convertNormalToDirectionOfRay(i.getNormal(), t)
, o = .002;
if (r) {
var a = x.Cross(vn.Y, r)
, s = x.Cross(r, a);
x.RotationFromAxisToRef(s, r, 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) {
K.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 = [],
document.removeEventListener("keydown", this._onKeyDown),
window.removeEventListener("vrdisplaypresentchange", this._onVrDisplayPresentChangeBind),
window.removeEventListener("resize", this._onResize),
document.removeEventListener("fullscreenchange", this._onFullscreenChange),
document.removeEventListener("mozfullscreenchange", this._onFullscreenChange),
document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange),
document.removeEventListener("msfullscreenchange", this._onFullscreenChange),
document.onmsfullscreenchange = null,
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
}(), dl = (al = {
root: 0,
found: !1
},
function(e, t, i, n) {
al.root = 0,
al.found = !1;
var r = t * t - 4 * e * i;
if (r < 0)
return al;
var o = Math.sqrt(r)
, a = (-t - o) / (2 * e)
, s = (-t + o) / (2 * e);
if (a > s) {
var l = s;
s = a,
a = l
}
return a > 0 && a < n ? (al.root = a,
al.found = !0,
al) : s > 0 && s < n ? (al.root = s,
al.found = !0,
al) : al
}
), pl = function() {
function e() {
this._collisionPoint = x.Zero(),
this._planeIntersectionPoint = x.Zero(),
this._tempVector = x.Zero(),
this._tempVector2 = x.Zero(),
this._tempVector3 = x.Zero(),
this._tempVector4 = x.Zero(),
this._edge = x.Zero(),
this._baseToVertex = x.Zero(),
this._destinationPoint = x.Zero(),
this._slidePlaneNormal = x.Zero(),
this._displacementVector = x.Zero(),
this._radius = x.One(),
this._retry = 0,
this._basePointWorld = x.Zero(),
this._velocityWorld = x.Zero(),
this._normalizedVelocity = x.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 n = Math.sqrt(this._velocitySquaredLength);
0 === n || 1 === n ? this._normalizedVelocity.copyFromFloats(t._x, t._y, t._z) : t.scaleToRef(1 / n, 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, n, r) {
t.subtractToRef(e, this._tempVector),
i.subtractToRef(e, this._tempVector2),
x.CrossToRef(this._tempVector, this._tempVector2, this._tempVector4);
var o = x.Dot(this._tempVector4, r);
return !(o < 0) && (n.subtractToRef(e, this._tempVector3),
x.CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4),
!((o = x.Dot(this._tempVector4, r)) < 0) && (x.CrossToRef(this._tempVector3, this._tempVector, this._tempVector4),
(o = x.Dot(this._tempVector4, r)) >= 0))
}
,
e.prototype._canDoCollision = function(e, t, i, n) {
var r = x.Distance(this._basePointWorld, e)
, o = Math.max(this._radius.x, this._radius.y, this._radius.z);
return !(r > this._velocityWorldLength + o + t || !function(e, t, i, n) {
return !(e.x > i.x + n || i.x - n > t.x || e.y > i.y + n || i.y - n > t.y || e.z > i.z + n || i.z - n > t.z)
}(i, n, this._basePointWorld, this._velocityWorldLength + o))
}
,
e.prototype._testTriangle = function(e, t, i, n, r, o, a) {
var s, l = !1;
t || (t = []),
t[e] || (t[e] = new hn(0,0,0,0),
t[e].copyFromPoints(i, n, r));
var c = t[e];
if (o || c.isFrontFacingTo(this._normalizedVelocity, 0)) {
var u = c.signedDistanceTo(this._basePoint)
, h = x.Dot(c.normal, this._velocity);
if (0 == h) {
if (Math.abs(u) >= 1)
return;
l = !0,
s = 0
} else {
var d = (1 - u) / h;
if ((s = (-1 - u) / h) > d) {
var p = d;
d = s,
s = p
}
if (s > 1 || d < 0)
return;
s < 0 && (s = 0),
s > 1 && (s = 1)
}
this._collisionPoint.copyFromFloats(0, 0, 0);
var f = !1
, _ = 1;
if (l || (this._basePoint.subtractToRef(c.normal, this._planeIntersectionPoint),
this._velocity.scaleToRef(s, this._tempVector),
this._planeIntersectionPoint.addInPlace(this._tempVector),
this._checkPointInTriangle(this._planeIntersectionPoint, i, n, r, c.normal) && (f = !0,
_ = s,
this._collisionPoint.copyFrom(this._planeIntersectionPoint))),
!f) {
var m = this._velocitySquaredLength;
this._basePoint.subtractToRef(i, this._tempVector);
var g = 2 * x.Dot(this._velocity, this._tempVector)
, v = this._tempVector.lengthSquared() - 1
, y = dl(m, g, v, _);
y.found && (_ = y.root,
f = !0,
this._collisionPoint.copyFrom(i)),
this._basePoint.subtractToRef(n, this._tempVector),
g = 2 * x.Dot(this._velocity, this._tempVector),
v = this._tempVector.lengthSquared() - 1,
(y = dl(m, g, v, _)).found && (_ = y.root,
f = !0,
this._collisionPoint.copyFrom(n)),
this._basePoint.subtractToRef(r, this._tempVector),
g = 2 * x.Dot(this._velocity, this._tempVector),
v = this._tempVector.lengthSquared() - 1,
(y = dl(m, g, v, _)).found && (_ = y.root,
f = !0,
this._collisionPoint.copyFrom(r)),
n.subtractToRef(i, this._edge),
i.subtractToRef(this._basePoint, this._baseToVertex);
var b, T = this._edge.lengthSquared(), E = x.Dot(this._edge, this._velocity), S = x.Dot(this._edge, this._baseToVertex);
m = T * -this._velocitySquaredLength + E * E,
g = 2 * (T * x.Dot(this._velocity, this._baseToVertex) - E * S),
v = T * (1 - this._baseToVertex.lengthSquared()) + S * S,
(y = dl(m, g, v, _)).found && (b = (E * y.root - S) / T) >= 0 && b <= 1 && (_ = y.root,
f = !0,
this._edge.scaleInPlace(b),
i.addToRef(this._edge, this._collisionPoint)),
r.subtractToRef(n, this._edge),
n.subtractToRef(this._basePoint, this._baseToVertex),
T = this._edge.lengthSquared(),
E = x.Dot(this._edge, this._velocity),
S = x.Dot(this._edge, this._baseToVertex),
m = T * -this._velocitySquaredLength + E * E,
g = 2 * (T * x.Dot(this._velocity, this._baseToVertex) - E * S),
v = T * (1 - this._baseToVertex.lengthSquared()) + S * S,
(y = dl(m, g, v, _)).found && (b = (E * y.root - S) / T) >= 0 && b <= 1 && (_ = y.root,
f = !0,
this._edge.scaleInPlace(b),
n.addToRef(this._edge, this._collisionPoint)),
i.subtractToRef(r, this._edge),
r.subtractToRef(this._basePoint, this._baseToVertex),
T = this._edge.lengthSquared(),
E = x.Dot(this._edge, this._velocity),
S = x.Dot(this._edge, this._baseToVertex),
m = T * -this._velocitySquaredLength + E * E,
g = 2 * (T * x.Dot(this._velocity, this._baseToVertex) - E * S),
v = T * (1 - this._baseToVertex.lengthSquared()) + S * S,
(y = dl(m, g, v, _)).found && (b = (E * y.root - S) / T) >= 0 && b <= 1 && (_ = y.root,
f = !0,
this._edge.scaleInPlace(b),
r.addToRef(this._edge, this._collisionPoint))
}
if (f) {
var A = _ * _ * this._velocitySquaredLength;
(!this.collisionFound || A < this._nearestDistanceSquared) && (a.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 = a)
}
}
}
,
e.prototype._collide = function(e, t, i, n, r, o, a, s, l, c) {
if (void 0 === c && (c = !1),
c)
if (i && 0 !== i.length)
for (p = n; p < r - 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 = n; p < r; 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(hn.SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint)),
this._destinationPoint.subtractInPlace(this._slidePlaneNormal),
this._destinationPoint.subtractToRef(this.intersectionPoint, t)
}
,
e
}(), fl = function() {
function e() {
this._scaledPosition = x.Zero(),
this._scaledVelocity = x.Zero(),
this._finalPosition = x.Zero()
}
return e.prototype.getNewPosition = function(e, t, i, n, r, 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, n, this._finalPosition, r),
this._finalPosition.multiplyInPlace(i._radius),
o(a, this._finalPosition, i.collidedMesh)
}
,
e.prototype.createCollider = function() {
return new pl
}
,
e.prototype.init = function(e) {
this._scene = e
}
,
e.prototype._collideWithWorld = function(e, t, i, n, r, o) {
void 0 === o && (o = null);
var a = 10 * vr.CollisionsEpsilon;
if (i._retry >= n)
r.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 ? r.copyFrom(e) : (i._retry++,
this._collideWithWorld(e, t, i, n, r, o))) : e.addToRef(t, r)
}
}
,
e
}();
mn.CollisionCoordinatorFactory = function() {
return new fl
}
;
var _l, ml = function() {
function e(t, i, n, r) {
void 0 === r && (r = "");
var o, a, s, l = this;
this.name = null,
this.defines = "",
this.onCompiled = null,
this.onError = null,
this.uniqueId = 0,
this.onCompileObservable = new h,
this.onErrorObservable = new h,
this.onBindObservable = new h,
this._wasPreviouslyReady = !1,
this._isReady = !1,
this._compilationError = "",
this._key = "",
this._computeSourceCodeOverride = "",
this._pipelineContext = null,
this._computeSourceCode = "",
this._rawComputeSourceCode = "",
this._shaderLanguage = st.WGSL,
this.name = t,
this._key = r,
this._engine = n,
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 = Pt.GetShadersStore(this._shaderLanguage),
this._shaderRepository = Pt.GetShadersRepository(this._shaderLanguage),
this._includeShaderStore = Pt.GetIncludesShadersStore(this._shaderLanguage);
var c = nt() ? 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 u = {
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) {
Ct.Initialize(u),
Ct.PreProcess(e, u, (function(n) {
l._rawComputeSourceCode = e,
i.processFinalCode && (n = i.processFinalCode(n));
var r = Ct.Finalize(n, "", u);
l._useFinalCode(r.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, n) {
var r;
"undefined" != typeof HTMLElement && e instanceof HTMLElement ? n(at(e)) : "source:" !== e.substr(0, 7) ? "base64:" !== e.substr(0, 7) ? this._shaderStore[e + t + "Shader"] ? n(this._shaderStore[e + t + "Shader"]) : i && this._shaderStore[e + i + "Shader"] ? n(this._shaderStore[e + i + "Shader"]) : (r = "." === e[0] || "/" === e[0] || e.indexOf("http") > -1 ? e : this._shaderRepository + e,
this._engine._loadFile(r + "." + t.toLowerCase() + ".fx", n)) : n(window.atob(e.substr(7))) : n(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 n = this._engine;
this._pipelineContext = n.createComputePipelineContext(),
this._pipelineContext._name = this._key,
n._prepareComputePipelineContext(this._pipelineContext, this._computeSourceCodeOverride ? this._computeSourceCodeOverride : this._computeSourceCode, this._rawComputeSourceCode, this._computeSourceCodeOverride ? null : t, this._entryPoint),
n._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 n = t.match(/COMPUTE SHADER ERROR: 0:(\d+?):/);
if (n && 2 === n.length) {
var r = parseInt(n[1])
, o = e.split("\n", -1);
o.length >= r && (i = "Offending line [".concat(r, "] in compute code: ").concat(o[r - 1]))
}
}
return [e, i]
}
,
e.prototype._processCompilationErrors = function(t, i) {
var n, r;
if (void 0 === i && (i = null),
this._compilationError = t.message,
K.Error("Unable to compile compute effect:"),
K.Error("Defines:\r\n" + this.defines),
e.LogShaderCodeOnCompilationError) {
var o = null
, a = null;
(null === (r = this._pipelineContext) || void 0 === r ? void 0 : r._getComputeShaderCode()) && (a = (n = this._getShaderCodeAndErrorLine(this._pipelineContext._getComputeShaderCode(), this._compilationError))[0],
o = n[1],
a && (K.Error("Compute code:"),
K.Error(a))),
o && K.Error(o)
}
K.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) {
Pt.GetShadersStore(st.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"
}(_l || (_l = {})),
Ht.prototype.createComputeEffect = function(e, t) {
throw new Error("createComputeEffect: This engine does not support compute shaders!")
}
,
Ht.prototype.createComputePipelineContext = function() {
throw new Error("createComputePipelineContext: This engine does not support compute shaders!")
}
,
Ht.prototype.createComputeContext = function() {}
,
Ht.prototype.computeDispatch = function(e, t, i, n, r, o, a) {
throw new Error("computeDispatch: This engine does not support compute shaders!")
}
,
Ht.prototype.areAllComputeEffectsReady = function() {
return !0
}
,
Ht.prototype.releaseComputeEffects = function() {}
,
Ht.prototype._prepareComputePipelineContext = function(e, t, i, n, r) {}
,
Ht.prototype._rebuildComputeEffects = function() {}
,
Ht.prototype._executeWhenComputeStateIsCompiled = function(e, t) {
t()
}
,
Ht.prototype._releaseComputeEffect = function(e) {}
,
Ht.prototype._deleteComputePipelineContext = function(e) {}
;
var gl = function() {
function e(e, t, i, n) {
void 0 === n && (n = {}),
this._bindings = {},
this._samplers = {},
this._contextIsDirty = !1,
this.onCompiled = null,
this.onError = null,
this.name = e,
this._engine = t,
this.uniqueId = pn.UniqueId,
this._engine.getCaps().supportComputeShaders ? n.bindingsMapping ? (this._context = t.createComputeContext(),
this._shaderPath = i,
this._options = V({
bindingsMapping: {},
defines: []
}, n)) : K.Error("You must provide the binding mappings as browsers don't support reflection for wgsl shaders yet!") : K.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 n = this._bindings[e];
this._bindings[e] = {
type: i ? _l.Texture : _l.TextureWithoutSampler,
object: t,
indexInGroupEntries: null == n ? void 0 : n.indexInGroupEntries
},
this._contextIsDirty || (this._contextIsDirty = !n || n.object !== t || n.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: _l.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: _l.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: _l.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: _l.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]
, n = i.type
, r = i.object;
switch (n) {
case _l.Texture:
case _l.TextureWithoutSampler:
case _l.StorageTexture:
if (!r.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 n;
if (!this.isReady())
return !1;
for (var r in this._bindings) {
var o = this._bindings[r];
if (!this._options.bindingsMapping[r])
throw new Error("ComputeShader ('" + this.name + "'): No binding mapping has been provided for the property '" + r + "'");
if (o.type === _l.Texture) {
var a = this._samplers[r]
, s = o.object;
a && s._texture && a.compareSampler(s._texture) || (this._samplers[r] = (new Nt).setParameters(s.wrapU, s.wrapV, s.wrapR, s.anisotropicFilteringLevel, s._texture.samplingMode, null === (n = s._texture) || void 0 === n ? void 0 : n._comparisonFunction),
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, n) {
var r = this;
return void 0 === n && (n = 10),
new Promise((function(o) {
var a = function() {
r.dispatch(e, t, i) ? o() : setTimeout(a, n)
};
a()
}
))
}
,
e.prototype.serialize = function() {
var e = Ge.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]
, n = i.object;
switch (i.type) {
case _l.Texture:
case _l.TextureWithoutSampler:
case _l.StorageTexture:
var r = n.serialize();
r && (e.textures[t] = r,
e.bindings[t] = {
type: i.type
});
case _l.UniformBuffer:
}
}
return e
}
,
e.Parse = function(t, i, n) {
var r = Ge.Parse((function() {
return new e(t.name,i.getEngine(),t.shaderPath,t.options)
}
), t, i, n);
for (var o in t.textures) {
var a = t.bindings[o]
, s = io.Parse(t.textures[o], i, n);
a.type === _l.Texture ? r.setTexture(o, s) : a.type === _l.TextureWithoutSampler ? r.setTexture(o, s, !1) : r.setStorageTexture(o, s)
}
return r
}
,
k([Ce()], e.prototype, "name", void 0),
e
}();
y("BABYLON.ComputeShader", gl);
var vl = function() {
function e(e, t, i, n, r, o) {
this.entries = new Array,
this._boundingVectors = new Array,
this._capacity = i,
this._depth = n,
this._maxDepth = r,
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 (tr.IsInFrustum(this._boundingVectors, e)) {
if (this.blocks) {
for (var n = 0; n < this.blocks.length; n++)
this.blocks[n].select(e, t, i);
return
}
i ? t.concat(this.entries) : t.concatWithNoDuplicate(this.entries)
}
}
,
e.prototype.intersects = function(e, t, i, n) {
if (tr.IntersectsSphere(this._minPoint, this._maxPoint, e, t)) {
if (this.blocks) {
for (var r = 0; r < this.blocks.length; r++)
this.blocks[r].intersects(e, t, i, n);
return
}
n ? 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)
}
,
e._CreateBlocks = function(t, i, n, r, o, a, s, l) {
s.blocks = new Array;
for (var c = new x((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)),r,o + 1,a,l);
p.addEntries(n),
s.blocks.push(p)
}
}
,
e
}()
, yl = 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 Ti(1024),
this._creationFunc = e
}
return e.prototype.update = function(e, t, i) {
vl._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 n = 0; n < this.blocks.length; n++)
this.blocks[n].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
}();
mn.prototype.createOrUpdateSelectionOctree = function(e, t) {
void 0 === e && (e = 64),
void 0 === t && (t = 2);
var i = this._getComponent(Wi.NAME_OCTREE);
i || (i = new Tl(this),
this._addComponent(i)),
this._selectionOctree || (this._selectionOctree = new yl(yl.CreationFuncForMeshes,e,t));
var n = this.getWorldExtends();
return this._selectionOctree.update(n.min, n.max, this.meshes),
this._selectionOctree
}
,
Object.defineProperty(mn.prototype, "selectionOctree", {
get: function() {
return this._selectionOctree
},
enumerable: !0,
configurable: !0
}),
Sr.prototype.createOrUpdateSubmeshesOctree = function(e, t) {
void 0 === e && (e = 64),
void 0 === t && (t = 2);
var i = this.getScene()
, n = i._getComponent(Wi.NAME_OCTREE);
n || (n = new Tl(i),
i._addComponent(n)),
this._submeshesOctree || (this._submeshesOctree = new yl(yl.CreationFuncForSubMeshes,e,t)),
this.computeWorldMatrix(!0);
var r = this.getBoundingInfo().boundingBox;
return this._submeshesOctree.update(r.minimumWorld, r.maximumWorld, this.subMeshes),
this._submeshesOctree
}
;
var bl, Tl = function() {
function e(e) {
this.name = Wi.NAME_OCTREE,
this.checksIsEnabled = !0,
this._tempRay = new _o(x.Zero(),new x(1,1,1)),
(e = e || E.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 n = i.dynamicContent.indexOf(t);
-1 !== n && i.dynamicContent.splice(n, 1)
}
}
)),
this.scene.onMeshImportedObservable.add((function(t) {
var i = e.scene.selectionOctree;
null != i && i.addMesh(t)
}
))
}
,
e.prototype.getActiveMeshCandidates = function() {
return this.scene._selectionOctree ? this.scene._selectionOctree.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 ? (_o.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
}(), El = 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 h,
this.utilityLayerScene = new mn(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 === Xi.POINTERMOVE || t.type === Xi.POINTERUP || t.type === Xi.POINTERDOWN || t.type === Xi.POINTERDOUBLETAP)) {
i.utilityLayerScene.pointerX = e.pointerX,
i.utilityLayerScene.pointerY = e.pointerY;
var n = t.event;
if (e.isPointerCaptured(n.pointerId))
i._pointerCaptures[n.pointerId] = !1;
else {
var r = function(n) {
var r = null;
if (t.nearInteractionPickingInfo)
r = t.nearInteractionPickingInfo.pickedMesh.getScene() == n ? t.nearInteractionPickingInfo : new Ui;
else {
var o = null;
i._renderCamera && (o = n._activeCamera,
n._activeCamera = i._renderCamera,
t.ray = null),
r = t.ray ? n.pickWithRay(t.ray) : n.pick(e.pointerX, e.pointerY),
o && (n._activeCamera = o)
}
return r
}
, o = r(i.utilityLayerScene);
if (!t.ray && o && (t.ray = o.ray),
i.utilityLayerScene.onPrePointerObservable.notifyObservers(t),
i.onlyCheckPointerDownEvents && t.type != Xi.POINTERDOWN)
return t.skipOnPointerObservable || i.utilityLayerScene.onPointerObservable.notifyObservers(new Ki(t.type,t.event,o), t.type),
void (t.type === Xi.POINTERUP && i._pointerCaptures[n.pointerId] && (i._pointerCaptures[n.pointerId] = !1));
if (i.utilityLayerScene.autoClearDepthAndStencil || i.pickUtilitySceneFirst)
o && o.hit && (t.skipOnPointerObservable || i.utilityLayerScene.onPointerObservable.notifyObservers(new Ki(t.type,t.event,o), t.type),
t.skipOnPointerObservable = !0);
else {
var a = r(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 === Xi.POINTERDOWN ? i._pointerCaptures[s.pointerId] = !0 : t.type !== Xi.POINTERMOVE && t.type !== Xi.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 !== Xi.POINTERMOVE && t.type !== Xi.POINTERUP || (i._lastPointerEvents[s.pointerId] && (i.onPointerOutObservable.notifyObservers(s.pointerId),
delete i._lastPointerEvents[s.pointerId]),
i._notifyObservers(t, o, s))),
t.type === Xi.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.onAfterCameraRenderObservable.add((function(e) {
i.shouldRender && e == i.getRenderCamera() && (e.outputRenderTarget && e.isRigCamera && i.originalScene.getEngine().clear(null, !1, !0, !1),
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 ds("shared gizmo light",new x(0,1,0),this.utilityLayerScene),
this._sharedGizmoLight.intensity = 2,
this._sharedGizmoLight.groundColor = D.Gray()),
this._sharedGizmoLight
}
,
Object.defineProperty(e, "DefaultUtilityLayer", {
get: function() {
return null == e._DefaultUtilityLayer ? e._CreateDefaultUtilityLayerFromScene(E.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(E.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 Ki(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
}(), Sl = function() {
function e(e) {
void 0 === e && (e = El.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.updateScale = !0,
this._interactionsEnabled = !0,
this._tempQuaternion = new C(0,0,0,1),
this._tempVector = new x,
this._tempVector2 = new x,
this._tempMatrix1 = new P,
this._tempMatrix2 = new P,
this._rightHandtoLeftHandMatrix = P.RotationY(Math.PI),
this._rootMesh = new Vr("gizmoRootNode",e.utilityLayerScene),
this._rootMesh.rotationQuaternion = C.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
}),
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 e = this.attachedNode;
if (this.attachedMesh && (e = this.attachedMesh || this.attachedNode),
this.updateGizmoPositionToMatchAttachedMesh) {
var t = e.getWorldMatrix().getRow(3)
, i = t ? t.toVector3() : new x(0,0,0);
this._rootMesh.position.copyFrom(i)
}
if (this.updateGizmoRotationToMatchAttachedMesh ? e.getWorldMatrix().decompose(void 0, this._rootMesh.rotationQuaternion) : this._customRotationQuaternion ? this._rootMesh.rotationQuaternion.copyFrom(this._customRotationQuaternion) : this._rootMesh.rotationQuaternion.set(0, 0, 0, 1),
this.updateScale) {
var n = this.gizmoLayer.utilityLayerScene.activeCamera
, r = n.globalPosition;
n.devicePosition && (r = n.devicePosition),
this._rootMesh.position.subtractToRef(r, this._tempVector);
var o = this._tempVector.length() * this.scaleRatio;
this._rootMesh.scaling.set(o, o, o),
e._getWorldMatrixDeterminant() < 0 && (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 e = this._attachedNode
, t = void 0
, i = void 0;
if (e.parent) {
var n = this._tempMatrix2;
e.parent._worldMatrix.invertToRef(n),
this._attachedNode._worldMatrix.multiplyToRef(n, this._tempMatrix1),
t = this._tempMatrix1
} else
t = this._attachedNode._worldMatrix;
if (e.getScene().useRightHandedSystem ? (this._rightHandtoLeftHandMatrix.multiplyToRef(t, this._tempMatrix2),
i = this._tempMatrix2) : i = t,
i.decompose(this._tempVector2, this._tempQuaternion, this._tempVector),
"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 r = this._attachedNode;
r.rotation = this._tempQuaternion.toEulerAngles(),
r.rotationQuaternion && (r.rotationQuaternion.copyFrom(this._tempQuaternion),
r.rotationQuaternion.normalize())
}
e.position.copyFrom(this._tempVector)
} else if (this._attachedNode._isMesh || "AbstractMesh" === this._attachedNode.getClassName() || "TransformNode" === this._attachedNode.getClassName() || "InstancedMesh" === this._attachedNode.getClassName()) {
var o = this._attachedNode;
if (o.parent) {
n = this._tempMatrix1;
var a = this._tempMatrix2;
o.parent.getWorldMatrix().invertToRef(n),
this._attachedNode.getWorldMatrix().multiplyToRef(n, a),
a.decompose(o.scaling, this._tempQuaternion, o.position)
} else
this._attachedNode._worldMatrix.decompose(o.scaling, this._tempQuaternion, o.position);
o.billboardMode || (o.rotationQuaternion ? (o.rotationQuaternion.copyFrom(this._tempQuaternion),
o.rotationQuaternion.normalize()) : o.rotation = this._tempQuaternion.toEulerAngles())
} else if ("Bone" === this._attachedNode.getClassName()) {
var s = this._attachedNode
, l = s.getParent();
if (l) {
var c = this._tempMatrix1
, u = this._tempMatrix2;
l.getWorldMatrix().invertToRef(c),
s.getWorldMatrix().multiplyToRef(c, u),
s.getLocalMatrix().copyFrom(u)
} else
s.getLocalMatrix().copyFrom(s.getWorldMatrix());
s.markAsDirty()
} else {
var h = this._attachedNode;
if (h.getTypeID) {
var d = h.getTypeID();
if (d === Cr.LIGHTTYPEID_DIRECTIONALLIGHT || d === Cr.LIGHTTYPEID_SPOTLIGHT || d === Cr.LIGHTTYPEID_POINTLIGHT) {
var p = h.parent;
if (p) {
c = this._tempMatrix1;
var f = this._tempMatrix2;
p.getWorldMatrix().invertToRef(c),
h.getWorldMatrix().multiplyToRef(c, f),
f.decompose(void 0, this._tempQuaternion, this._tempVector)
} else
this._attachedNode._worldMatrix.decompose(void 0, this._tempQuaternion, this._tempVector);
h.position = new x(this._tempVector.x,this._tempVector.y,this._tempVector.z),
x.Backward(!1).rotateByQuaternionToRef(this._tempQuaternion, this._tempVector),
h.direction = new x(this._tempVector.x,this._tempVector.y,this._tempVector.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
, n = e.utilityLayerScene.onPointerObservable.add((function(e) {
var n, r;
if (e.pickInfo) {
if (e.type === Xi.POINTERMOVE) {
if (i)
return;
t.forEach((function(t) {
var i, n;
if (t.colliderMeshes && t.gizmoMeshes) {
var r = -1 != (null === (i = t.colliderMeshes) || void 0 === i ? void 0 : i.indexOf(null === (n = null == e ? void 0 : e.pickInfo) || void 0 === n ? void 0 : n.pickedMesh))
, o = t.dragBehavior.enabled ? r || t.active ? t.hoverMaterial : t.material : t.disableMaterial;
t.gizmoMeshes.forEach((function(e) {
e.material = o,
e.color && (e.color = o.diffuseColor)
}
))
}
}
))
}
e.type === Xi.POINTERDOWN && t.has(null === (n = e.pickInfo.pickedMesh) || void 0 === n ? void 0 : n.parent) && (i = !0,
t.get(null === (r = e.pickInfo.pickedMesh) || void 0 === r ? void 0 : r.parent).active = !0,
t.forEach((function(t) {
var i, n, r = (-1 != (null === (i = t.colliderMeshes) || void 0 === i ? void 0 : i.indexOf(null === (n = null == e ? void 0 : e.pickInfo) || void 0 === n ? void 0 : n.pickedMesh)) || t.active) && t.dragBehavior.enabled ? t.hoverMaterial : t.disableMaterial;
t.gizmoMeshes.forEach((function(e) {
e.material = r,
e.color && (e.color = r.diffuseColor)
}
))
}
))),
e.type === Xi.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 n
}
,
e.prototype.dispose = function() {
this._rootMesh.dispose(),
this._beforeRenderObserver && this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver)
}
,
e
}(), Al = function(e) {
function t(i, n, r, o, a) {
void 0 === n && (n = D.Gray()),
void 0 === r && (r = El.DefaultUtilityLayer),
void 0 === o && (o = null),
void 0 === a && (a = 1);
var s, l = this;
(l = e.call(this, r) || this)._pointerObserver = null,
l.snapDistance = 0,
l.onSnapObservable = new h,
l._isEnabled = !0,
l._parent = null,
l._dragging = !1,
l._parent = o,
l._coloredMaterial = new Os("",r.utilityLayerScene),
l._coloredMaterial.diffuseColor = n,
l._coloredMaterial.specularColor = n.subtract(new D(.1,.1,.1)),
l._hoverMaterial = new Os("",r.utilityLayerScene),
l._hoverMaterial.diffuseColor = D.Yellow(),
l._disableMaterial = new Os("",r.utilityLayerScene),
l._disableMaterial.diffuseColor = D.Gray(),
l._disableMaterial.alpha = .4;
var c = t._CreateArrow(r.utilityLayerScene, l._coloredMaterial, a)
, u = t._CreateArrow(r.utilityLayerScene, l._coloredMaterial, a + 4, !0);
l._gizmoMesh = new Vr("",r.utilityLayerScene),
l._gizmoMesh.addChild(c),
l._gizmoMesh.addChild(u),
l._gizmoMesh.lookAt(l._rootMesh.position.add(i)),
l._gizmoMesh.scaling.scaleInPlace(1 / 3),
l._gizmoMesh.parent = l._rootMesh;
var d = 0
, p = new x
, f = new x
, _ = {
snapDistance: 0
};
l.dragBehavior = new Ao({
dragAxis: i
}),
l.dragBehavior.moveAttached = !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(f),
f.addInPlace(e.delta),
l.dragBehavior.validateDrag(f) && (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(p),
p.scaleInPlace(l.snapDistance * i),
l.attachedNode.getWorldMatrix().getTranslationToRef(f),
f.addInPlace(p),
l.dragBehavior.validateDrag(f) && (l.attachedNode.getWorldMatrix().addTranslationFromFloats(p.x, p.y, p.z),
l.attachedNode.updateCache(),
_.snapDistance = l.snapDistance * i,
l.onSnapObservable.notifyObservers(_),
t = !0)
}
t && l._matrixChanged()
}
}
)),
l.dragBehavior.onDragStartObservable.add((function() {
l._dragging = !0
}
)),
l.dragBehavior.onDragEndObservable.add((function() {
l._dragging = !1
}
));
var m = r._getSharedGizmoLight();
m.includedOnlyMeshes = m.includedOnlyMeshes.concat(l._rootMesh.getChildMeshes(!1));
var g = {
gizmoMeshes: c.getChildMeshes(),
colliderMeshes: u.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(u, g),
l._pointerObserver = r.utilityLayerScene.onPointerObservable.add((function(e) {
var t;
if (!l._customMeshSet && (l._isHovered = !(-1 == g.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(g.gizmoMeshes, i)
}
}
)),
l.dragBehavior.onEnabledObservable.add((function(e) {
l._setGizmoMeshMaterial(g.gizmoMeshes, e ? g.material : g.disableMaterial)
}
)),
l
}
return U(t, e),
t._CreateArrow = function(e, t, i, n) {
void 0 === i && (i = 1),
void 0 === n && (n = !1);
var r = new yr("arrow",e)
, o = Ys("cylinder", {
diameterTop: 0,
height: .075,
diameterBottom: .0375 * (1 + (i - 1) / 4),
tessellation: 96
}, e)
, a = Ys("cylinder", {
diameterTop: .005 * i,
height: .275,
diameterBottom: .005 * i,
tessellation: 96
}, e);
return o.parent = r,
o.material = t,
o.rotation.x = Math.PI / 2,
o.position.z += .3,
a.parent = r,
a.material = t,
a.position.z += .1375,
a.rotation.x = Math.PI / 2,
n && (a.visibility = 0,
o.visibility = 0),
r
}
,
t._CreateArrowInstance = function(e, t) {
for (var i = new yr("arrow",e), n = 0, r = t.getChildMeshes(); n < r.length; n++) {
var o = r[n];
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
}(Sl), xl = function() {
function e(t, i, n, r, o, a, s) {
if (void 0 === i && (i = 1),
void 0 === n && (n = 2),
void 0 === s && (s = 1),
this._scaleLinesFactor = 4,
this._instanced = !1,
this.scene = null,
this.scaleLines = 1,
t = t || E.LastCreatedScene) {
if (this.scaleLines = i,
!r) {
var l = new Os("",t);
l.disableLighting = !0,
l.emissiveColor = D.Red().scale(.5),
r = Al._CreateArrow(t, l, s)
}
if (!o) {
var c = new Os("",t);
c.disableLighting = !0,
c.emissiveColor = D.Green().scale(.5),
o = Al._CreateArrow(t, c, s)
}
if (!a) {
var u = new Os("",t);
u.disableLighting = !0,
u.emissiveColor = D.Blue().scale(.5),
a = Al._CreateArrow(t, u, s)
}
this._xAxis = r,
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 != n && (e._SetRenderingGroupId(this._xAxis, n),
e._SetRenderingGroupId(this._yAxis, n),
e._SetRenderingGroupId(this._zAxis, n)),
this.scene = t,
this.update(new x, x.Right(), x.Up(), x.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, n) {
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(n),
this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor)
}
,
e.prototype.createInstance = function() {
var t = Al._CreateArrowInstance(this.scene, this._xAxis)
, i = Al._CreateArrowInstance(this.scene, this._yAxis)
, n = Al._CreateArrowInstance(this.scene, this._zAxis)
, r = new e(this.scene,this.scaleLines,null,t,i,n);
return r._instanced = !0,
r
}
,
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
}(), Rl = function(e) {
function t(t, i, n, r) {
void 0 === r && (r = 1);
var o = e.call(this, t, r) || this;
return o.pos = x.Zero(),
o.xaxis = x.Zero(),
o.yaxis = x.Zero(),
o.zaxis = x.Zero(),
o.mesh = n,
o.bone = i,
o
}
return U(t, e),
t.prototype.update = function() {
if (this.mesh && this.bone) {
var t = this.bone;
t._markAsDirtyAndCompose(),
t.getAbsolutePositionToRef(this.mesh, this.pos),
t.getDirectionToRef(vn.X, this.mesh, this.xaxis),
t.getDirectionToRef(vn.Y, this.mesh, this.yaxis),
t.getDirectionToRef(vn.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
}(xl);
Object.defineProperty(mn.prototype, "debugLayer", {
get: function() {
return this._debugLayer || (this._debugLayer = new Cl(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"
}(bl || (bl = {}));
var Cl = function() {
function e(e) {
var t = this;
this.BJSINSPECTOR = this._getGlobalInspector(),
this._scene = e || E.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 h),
this._onPropertyChangedObservable)
},
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 n = i[t];
this.BJSINSPECTOR.Inspector.OnPropertyChangedObservable.add(n)
}
this._onPropertyChangedObservable.clear(),
this._onPropertyChangedObservable = void 0
}
var r = V({
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, r)
}
}
,
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(n) {
if (void 0 === i.BJSINSPECTOR) {
var r = t && t.inspectorURL ? t.inspectorURL : e.InspectorURL;
gi.LoadScript(r, (function() {
i._createInspector(t),
n(i)
}
))
} else
i._createInspector(t),
n(i)
}
))
}
,
e.InspectorURL = "https://unpkg.com/babylonjs-inspector@".concat(vr.Version, "/babylon.inspector.bundle.js"),
e
}();
function Pl(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], n = [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], r = [], 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 || $n.DEFAULTSIDE, b = e.faceUV || new Array(6), T = e.faceColors, E = [], S = 0; S < 6; S++)
void 0 === b[S] && (b[S] = new R(0,0,1,1)),
T && void 0 === T[S] && (T[S] = new N(1,1,1,1));
for (var A = 0; A < 6; A++)
if (r.push(b[A].z, pr.UseOpenGLOrientationForUV ? 1 - b[A].w : b[A].w),
r.push(b[A].x, pr.UseOpenGLOrientationForUV ? 1 - b[A].w : b[A].w),
r.push(b[A].x, pr.UseOpenGLOrientationForUV ? 1 - b[A].y : b[A].y),
r.push(b[A].z, pr.UseOpenGLOrientationForUV ? 1 - b[A].y : b[A].y),
T)
for (var x = 0; x < 4; x++)
E.push(T[A].r, T[A].g, T[A].b, T[A].a);
$n._ComputeSides(y, t, i, n, r, e.frontUVs, e.backUVs);
var C = new $n;
if (C.indices = i,
C.positions = t,
C.normals = n,
C.uvs = r,
T) {
var P = y === $n.DOUBLESIDE ? E.concat(E) : E;
C.colors = P
}
return C
}
function Ml(e, t, i) {
void 0 === t && (t = {}),
void 0 === i && (i = null);
var n = new Vr(e,i);
return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
n._originalBuilderSideOrientation = t.sideOrientation,
Pl(t).applyToMesh(n, t.updatable),
n
}
var Il = {
CreateBox: Ml
};
function Ol(e) {
for (var t = e.segments || 32, i = e.diameterX || e.diameter || 1, n = e.diameterY || e.diameter || 1, r = 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 || $n.DEFAULTSIDE, l = !!e.dedupTopBottomIndices, c = new x(i / 2,n / 2,r / 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 = P.RotationZ(-v)
, S = P.RotationY(T)
, A = x.TransformCoordinates(x.Up(), E)
, R = x.TransformCoordinates(A, S)
, C = R.multiply(c)
, M = R.divide(c).normalize();
p.push(C.x, C.y, C.z),
f.push(M.x, M.y, M.z),
_.push(b, pr.UseOpenGLOrientationForUV ? 1 - g : g)
}
if (m > 0)
for (var I = p.length / 3, O = I - 2 * (h + 1); O + h + 2 < I; 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))
}
$n._ComputeSides(s, p, d, f, _, e.frontUVs, e.backUVs);
var D = new $n;
return D.indices = d,
D.positions = p,
D.normals = f,
D.uvs = _,
D
}
function Dl(e, t, i) {
void 0 === t && (t = {}),
void 0 === i && (i = null);
var n = new Vr(e,i);
return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
n._originalBuilderSideOrientation = t.sideOrientation,
Ol(t).applyToMesh(n, t.updatable),
n
}
$n.CreateBox = Pl,
Vr.CreateBox = function(e, t, i, n, r) {
return void 0 === i && (i = null),
Ml(e, {
size: t,
sideOrientation: r,
updatable: n
}, i)
}
;
var Nl = {
CreateSphere: Dl
};
$n.CreateSphere = Ol,
Vr.CreateSphere = function(e, t, i, n, r, o) {
return Dl(e, {
segments: t,
diameterX: i,
diameterY: i,
diameterZ: i,
sideOrientation: o,
updatable: r
}, n)
}
;
var Ll = 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
}()
, Fl = function(e) {
function t(t) {
return e.call(this, Ll.DistanceJoint, t) || this
}
return U(t, e),
t.prototype.updateDistance = function(e, t) {
this._physicsPlugin.updateDistanceJoint(this, e, t)
}
,
t
}(Ll)
, wl = function(e) {
function t(t, i) {
return e.call(this, t, i) || this
}
return U(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
}(Ll)
, Bl = function(e) {
function t(t) {
return e.call(this, Ll.HingeJoint, t) || this
}
return U(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
}(wl)
, Ul = function(e) {
function t(t) {
return e.call(this, Ll.Hinge2Joint, t) || this
}
return U(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
}(wl);
Vr._PhysicsImpostorParser = function(e, t, i) {
return new Vl(t,i.physicsImpostor,{
mass: i.physicsMass,
friction: i.physicsFriction,
restitution: i.physicsRestitution
},e)
}
;
var Vl = function() {
function e(e, t, i, n) {
void 0 === i && (i = {
mass: 0
});
var r = this;
this.object = e,
this.type = t,
this._options = i,
this._scene = n,
this._pluginData = {},
this._bodyUpdateRequired = !1,
this._onBeforePhysicsStepCallbacks = new Array,
this._onAfterPhysicsStepCallbacks = new Array,
this._onPhysicsCollideCallbacks = [],
this._deltaPosition = x.Zero(),
this._isDisposed = !1,
this.soft = !1,
this.segments = 0,
this._tmpQuat = new C,
this._tmpQuat2 = new C,
this.beforeStep = function() {
r._physicsEngine && (r.object.translate(r._deltaPosition, -1),
r._deltaRotationConjugated && r.object.rotationQuaternion && r.object.rotationQuaternion.multiplyToRef(r._deltaRotationConjugated, r.object.rotationQuaternion),
r.object.computeWorldMatrix(!1),
r.object.parent && r.object.rotationQuaternion ? (r.getParentsRotation(),
r._tmpQuat.multiplyToRef(r.object.rotationQuaternion, r._tmpQuat)) : r._tmpQuat.copyFrom(r.object.rotationQuaternion || new C),
r._options.disableBidirectionalTransformation || r.object.rotationQuaternion && r._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(r, r.object.getAbsolutePosition(), r._tmpQuat),
r._onBeforePhysicsStepCallbacks.forEach((function(e) {
e(r)
}
)))
}
,
this.afterStep = function() {
r._physicsEngine && (r._onAfterPhysicsStepCallbacks.forEach((function(e) {
e(r)
}
)),
r._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(r),
r.object.parent && r.object.rotationQuaternion && (r.getParentsRotation(),
r._tmpQuat.conjugateInPlace(),
r._tmpQuat.multiplyToRef(r.object.rotationQuaternion, r.object.rotationQuaternion)),
r.object.setAbsolutePosition(r.object.position),
r._deltaRotation && r.object.rotationQuaternion && r.object.rotationQuaternion.multiplyToRef(r._deltaRotation, r.object.rotationQuaternion),
r.object.translate(r._deltaPosition, 1))
}
,
this.onCollideEvent = null,
this.onCollide = function(e) {
if ((r._onPhysicsCollideCallbacks.length || r.onCollideEvent) && r._physicsEngine) {
var t = r._physicsEngine.getImpostorWithPhysicsBody(e.body);
t && (r.onCollideEvent && r.onCollideEvent(r, t),
r._onPhysicsCollideCallbacks.filter((function(e) {
return -1 !== e.otherImpostors.indexOf(t)
}
)).forEach((function(i) {
i.callback(r, t, e.point)
}
)))
}
}
,
this.object ? (this.object.parent && 0 !== i.mass && K.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 && e.getScene && (this._scene = e.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 = C.RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z) : this.object.rotationQuaternion = new C),
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,
this.soft && (this._options.mass = this._options.mass > 0 ? this._options.mass : 1,
this._options.pressure = void 0 === i.pressure ? 200 : i.pressure,
this._options.stiffness = void 0 === i.stiffness ? 1 : i.stiffness,
this._options.velocityIterations = void 0 === i.velocityIterations ? 20 : i.velocityIterations,
this._options.positionIterations = void 0 === i.positionIterations ? 20 : i.positionIterations,
this._options.fixedPoints = void 0 === i.fixedPoints ? 0 : i.fixedPoints,
this._options.margin = void 0 === i.margin ? 0 : i.margin,
this._options.damping = void 0 === i.damping ? 0 : i.damping,
this._options.path = void 0 === i.path ? null : i.path,
this._options.shape = void 0 === i.shape ? null : i.shape),
this._joints = [],
!this.object.parent || this._options.ignoreParent ? this._init() : this.object.parent.physicsImpostor && K.Warn("You must affect impostors to children before affecting impostor to parent.")) : K.Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors."))) : K.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 Sr ? this.object.parent.physicsImpostor : null
}
,
e.prototype.isBodyInitRequired = function() {
return this._bodyUpdateRequired || !this._physicsBody && !this._parent
}
,
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.getObjectExtendSize = function() {
if (this.object.getBoundingInfo) {
var t = this.object.rotationQuaternion
, i = this.object.scaling.clone();
this.object.rotationQuaternion = e.IDENTITY_QUATERNION;
var n = this.object.computeWorldMatrix && this.object.computeWorldMatrix(!0);
n && n.decompose(i, void 0, void 0);
var r = this.object.getBoundingInfo().boundingBox.extendSize.scale(2).multiplyInPlace(i);
return r.x = Math.abs(r.x),
r.y = Math.abs(r.y),
r.z = Math.abs(r.z),
this.object.rotationQuaternion = t,
this.object.computeWorldMatrix && this.object.computeWorldMatrix(!0),
r
}
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) : x.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) : x.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) : K.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) : K.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]
, n = -1;
this._onPhysicsCollideCallbacks.some((function(e, r) {
if (e.callback === t && e.otherImpostors.length === i.length) {
var o = e.otherImpostors.every((function(e) {
return i.indexOf(e) > -1
}
));
return o && (n = r),
o
}
return !1
}
)) ? this._onPhysicsCollideCallbacks.splice(n, 1) : K.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) : C.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 n = new Ll(t,i);
return this.addJoint(e, n),
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, n, r) {
if (!this._physicsEngine)
return this;
var o = this._physicsEngine.getPhysicsPlugin();
return o.appendAnchor ? (this._physicsEngine && o.appendAnchor(this, e, t, i, n, r),
this) : this
}
,
e.prototype.addHook = function(e, t, i, n) {
if (!this._physicsEngine)
return this;
var r = this._physicsEngine.getPhysicsPlugin();
return r.appendAnchor ? (this._physicsEngine && r.appendHook(this, e, t, i, n),
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 C),
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, n, r, 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, Ji.WORLD, i)
} else
t.setRotationQuaternion(s.rotationQuaternion, Ji.WORLD, i);
a.x = 0,
a.y = 0,
a.z = 0,
n && (a.x = n.x,
a.y = n.y,
a.z = n.z,
t.getDirectionToRef(a, i, a),
null == r && (r = n.length()),
a.x *= r,
a.y *= r,
a.z *= r),
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, n, r, o, a) {
var s = this.object;
if (s.rotationQuaternion)
if (o) {
var l = e._TmpQuat;
t.getRotationQuaternionToRef(Ji.WORLD, i, l),
l.multiplyToRef(o, s.rotationQuaternion)
} else
t.getRotationQuaternionToRef(Ji.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 == r && n && (r = n.length()),
null != r && (c.x += u.x * r,
c.y += u.y * r,
c.z += u.z * r),
s.setAbsolutePosition(c)
}
,
e.DEFAULT_OBJECT_SIZE = new x(1,1,1),
e.IDENTITY_QUATERNION = C.Identity(),
e._TmpVecs = g.BuildArray(3, x.Zero),
e._TmpQuat = C.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 kl(e) {
void 0 === e && (e = {
subdivisions: 2,
tessellation: 16,
height: 1,
radius: .25,
capSubdivisions: 6
});
var t, i, n = Math.max(e.subdivisions ? e.subdivisions : 2, 1), r = 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 = Math.max(e.capSubdivisions ? e.capSubdivisions : 6, 1), l = r, c = n, 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, R = .5 * Math.PI, C = x.Zero(), M = x.Zero(), I = Math.cos(m), O = Math.sin(m), D = new A(u * O,S + u * I).subtract(new A(h * O,h * I - S)).length(), N = u * m + D + h * (R - m), L = 0;
for (i = 0; i <= f; i++) {
var F = []
, w = R - m * (i / f);
L += 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);
M.x = V * G,
M.y = S + U * u,
M.z = V * z,
v.push(M.x, M.y, M.z),
C.set(B * G, U, B * z),
y.push(C.x, C.y, C.z),
b.push(X, pr.UseOpenGLOrientationForUV ? L / N : 1 - L / N),
F.push(T),
T++
}
E.push(F)
}
var W = o - u - h + I * u - I * h
, H = O * (h - u) / W;
for (i = 1; i <= c; i++) {
for (F = [],
L += 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),
M.x = V * G,
M.y = S + I * u - i * W / c,
M.z = V * z,
v.push(M.x, M.y, M.z),
C.set(G, H, z).normalize(),
y.push(C.x, C.y, C.z),
b.push(X, pr.UseOpenGLOrientationForUV ? L / N : 1 - L / N),
F.push(T),
T++;
E.push(F)
}
for (i = 1; i <= _; i++) {
for (F = [],
w = R - m - (Math.PI - m) * (i / _),
L += 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),
M.x = V * G,
M.y = U * h - S,
M.z = V * z,
v.push(M.x, M.y, M.z),
C.set(B * G, U, B * z),
y.push(C.x, C.y, C.z),
b.push(X, pr.UseOpenGLOrientationForUV ? L / N : 1 - L / N),
F.push(T),
T++
}
E.push(F)
}
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(x.Up())) {
var q = new P;
e.orientation.clone().scale(.5 * Math.PI).cross(x.Up()).toQuaternion().toRotationMatrix(q);
for (var Z = x.Zero(), J = 0; J < v.length; J += 3)
Z.set(v[J], v[J + 1], v[J + 2]),
x.TransformCoordinatesToRef(Z.clone(), q, Z),
v[J] = Z.x,
v[J + 1] = Z.y,
v[J + 2] = Z.z
}
var $ = new $n;
return $.positions = v,
$.normals = y,
$.uvs = b,
$.indices = g,
$
}
function Gl(e, t, i) {
void 0 === t && (t = {
orientation: x.Up(),
subdivisions: 2,
tessellation: 16,
height: 1,
radius: .25,
capSubdivisions: 6,
updatable: !1
}),
void 0 === i && (i = null);
var n = new Vr(e,i);
return kl(t).applyToMesh(n, t.updatable),
n
}
var zl = {
CreateCapsule: Gl
};
Vr.CreateCapsule = function(e, t, i) {
return Gl(e, t, i)
}
,
$n.CreateCapsule = kl;
var Wl = function() {
function e(e) {
if (this._impostors = [],
this._meshes = [],
this._numMeshes = 0,
this._debugMeshMeshes = new Array,
this._scene = e || E.LastCreatedScene,
this._scene) {
var t = this._scene.getPhysicsEngine();
t && (this._physicsEnginePlugin = t.getPhysicsPlugin()),
this._utilityLayer = new El(this._scene,!1),
this._utilityLayer.pickUtilitySceneFirst = !1,
this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = !0
}
}
return e.prototype._updateDebugMeshes = 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 === Vl.MeshImpostor)
continue;
var n = this._meshes[t];
n && e && e.syncMeshWithImpostor(n, i)
}
}
}
,
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 n = this._getDebugMesh(e, t);
return n && (this._impostors[this._numMeshes] = e,
this._meshes[this._numMeshes] = n,
0 === this._numMeshes && (this._renderFunction = this._updateDebugMeshes.bind(this),
this._scene.registerBeforeRender(this._renderFunction)),
this._numMeshes++),
n
}
,
e.prototype.hideImpostor = function(e) {
if (e && this._scene && this._utilityLayer) {
for (var t = !1, i = this._utilityLayer.utilityLayerScene, n = 0; n < this._numMeshes; n++)
if (this._impostors[n] == e) {
var r = this._meshes[n];
if (!r)
continue;
i.removeMesh(r),
r.dispose();
var o = this._debugMeshMeshes.indexOf(r);
o > -1 && this._debugMeshMeshes.splice(o, 1),
this._numMeshes--,
this._numMeshes > 0 ? (this._meshes[n] = this._meshes[this._numMeshes],
this._impostors[n] = 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._getDebugMaterial = function(e) {
return this._debugMaterial || (this._debugMaterial = new Os("",e),
this._debugMaterial.wireframe = !0,
this._debugMaterial.emissiveColor = D.White(),
this._debugMaterial.disableLighting = !0),
this._debugMaterial
}
,
e.prototype._getDebugBoxMesh = function(e) {
return this._debugBoxMesh || (this._debugBoxMesh = Ml("physicsBodyBoxViewMesh", {
size: 1
}, e),
this._debugBoxMesh.rotationQuaternion = C.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 = Dl("physicsBodySphereViewMesh", {
diameter: 1
}, e),
this._debugSphereMesh.rotationQuaternion = C.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 = Gl("physicsBodyCapsuleViewMesh", {
height: 1
}, e),
this._debugCapsuleMesh.rotationQuaternion = C.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 = Ys("physicsBodyCylinderViewMesh", {
diameterTop: 1,
diameterBottom: 1,
height: 1
}, e),
this._debugCylinderMesh.rotationQuaternion = C.Identity(),
this._debugCylinderMesh.material = this._getDebugMaterial(e),
this._debugCylinderMesh.setEnabled(!1)),
this._debugCylinderMesh.createInstance("physicsBodyCylinderViewInstance")
}
,
e.prototype._getDebugMeshMesh = function(e, t) {
var i = new Vr(e.name,t,null,e);
return i.setParent(e),
i.position = x.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 n = null
, r = this._utilityLayer.utilityLayerScene;
switch (e.type) {
case Vl.BoxImpostor:
n = this._getDebugBoxMesh(r),
e.getBoxSizeToRef(n.scaling);
break;
case Vl.SphereImpostor:
n = this._getDebugSphereMesh(r);
var o = e.getRadius();
n.scaling.x = 2 * o,
n.scaling.y = 2 * o,
n.scaling.z = 2 * o;
break;
case Vl.CapsuleImpostor:
n = this._getDebugCapsuleMesh(r);
var a = e.object.getBoundingInfo();
n.scaling.x = 2 * (a.boundingBox.maximum.x - a.boundingBox.minimum.x) * e.object.scaling.x,
n.scaling.y = (a.boundingBox.maximum.y - a.boundingBox.minimum.y) * e.object.scaling.y,
n.scaling.z = 2 * (a.boundingBox.maximum.z - a.boundingBox.minimum.z) * e.object.scaling.z;
break;
case Vl.MeshImpostor:
t && (n = this._getDebugMeshMesh(t, r));
break;
case Vl.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 Vl.BoxImpostor:
(n = i._getDebugBoxMesh(r)).position.copyFrom(o),
n.position.addInPlace(a),
n.position.scaleInPlace(.5);
break;
case Vl.SphereImpostor:
n = i._getDebugSphereMesh(r);
break;
case Vl.CylinderImpostor:
n = i._getDebugCylinderMesh(r);
break;
default:
n = null
}
n && (n.scaling.x = a.x - o.x,
n.scaling.y = a.y - o.y,
n.scaling.z = a.z - o.z,
n.parent = e)
}
}
)),
n = null;
break;
case Vl.CylinderImpostor:
n = this._getDebugCylinderMesh(r),
a = e.object.getBoundingInfo(),
n.scaling.x = (a.boundingBox.maximum.x - a.boundingBox.minimum.x) * e.object.scaling.x,
n.scaling.y = (a.boundingBox.maximum.y - a.boundingBox.minimum.y) * e.object.scaling.y,
n.scaling.z = (a.boundingBox.maximum.z - a.boundingBox.minimum.z) * e.object.scaling.z
}
return n
}
,
e.prototype.dispose = function() {
for (var e = this._numMeshes, t = 0; t < e; t++)
this.hideImpostor(this._impostors[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
}();
Vr._instancedMeshFactory = function(e, t) {
var i = new Hl(e,t);
if (t.instancedBuffers)
for (var n in i.instancedBuffers = {},
t.instancedBuffers)
i.instancedBuffers[n] = t.instancedBuffers[n];
return i
}
;
var Hl = function(e) {
function t(t, i) {
var n = e.call(this, t, i.getScene()) || this;
n._indexInSourceMeshInstanceArray = -1,
n._distanceToCamera = 0,
i.addInstance(n),
n._sourceMesh = i,
n._unIndexed = i._unIndexed,
n.position.copyFrom(i.position),
n.rotation.copyFrom(i.rotation),
n.scaling.copyFrom(i.scaling),
i.rotationQuaternion && (n.rotationQuaternion = i.rotationQuaternion.clone()),
n.animations = gi.Slice(i.animations);
for (var r = 0, o = i.getAnimationRanges(); r < o.length; r++) {
var a = o[r];
null != a && n.createAnimationRange(a.name, a.from, a.to)
}
return n.infiniteDistance = i.infiniteDistance,
n.setPivotMatrix(i.getPivotMatrix()),
n.refreshBoundingInfo(!0, !0),
n._syncSubMeshes(),
n
}
return U(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
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "material", {
get: function() {
return this._sourceMesh.material
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "visibility", {
get: function() {
return this._sourceMesh.visibility
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "skeleton", {
get: function() {
return this._sourceMesh.skeleton
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "renderingGroupId", {
get: function() {
return this._sourceMesh.renderingGroupId
},
set: function(e) {
this._sourceMesh && e !== this._sourceMesh.renderingGroupId && K.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) {
return this._sourceMesh.getVerticesData(e, t)
}
,
t.prototype.setVerticesData = function(e, t, i, n) {
return this.sourceMesh && this.sourceMesh.setVerticesData(e, t, i, n),
this.sourceMesh
}
,
t.prototype.updateVerticesData = function(e, t, i, n) {
return this.sourceMesh && this.sourceMesh.updateVerticesData(e, t, i, n),
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(e, t) {
if (this._sourceMesh.subMeshes || K.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, e),
t) {
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 !== yr.BILLBOARDMODE_NONE && this._currentLOD._masterMesh !== this) {
this._billboardWorldMatrix || (this._billboardWorldMatrix = new P);
var t = this._currentLOD._masterMesh;
return this._currentLOD._masterMesh = this,
I.Vector3[7].copyFrom(this._currentLOD.position),
this._currentLOD.position.set(0, 0, 0),
this._billboardWorldMatrix.copyFrom(this._currentLOD.computeWorldMatrix(!0)),
this._currentLOD.position.copyFrom(I.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) {
void 0 === t && (t = null);
var n = this._sourceMesh.createInstance(e);
if (fe.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"], []),
this.refreshBoundingInfo(),
t && (n.parent = t),
!i)
for (var r = 0; r < this.getScene().meshes.length; r++) {
var o = this.getScene().meshes[r];
o.parent === this && o.clone(o.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
}(Sr);
Vr.prototype.edgesShareWithInstances = !1,
Vr.prototype.registerInstancedBuffer = function(e, t) {
var i, n;
if (null === (n = null === (i = this._userInstancedBuffersStorage) || void 0 === i ? void 0 : i.vertexBuffers[e]) || void 0 === n || n.dispose(),
!this.instancedBuffers) {
this.instancedBuffers = {};
for (var r = 0, o = this.instances; r < o.length; r++)
o[r].instancedBuffers = {};
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 Bi(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()
}
,
Vr.prototype._processInstancedBuffers = function(e, t) {
var i = e.length;
for (var n in this.instancedBuffers) {
for (var r = this._userInstancedBuffersStorage.sizes[n], o = this._userInstancedBuffersStorage.strides[n], a = (i + 1) * o; r < a; )
r *= 2;
this._userInstancedBuffersStorage.data[n].length != r && (this._userInstancedBuffersStorage.data[n] = new Float32Array(r),
this._userInstancedBuffersStorage.sizes[n] = r,
this._userInstancedBuffersStorage.vertexBuffers[n] && (this._userInstancedBuffersStorage.vertexBuffers[n].dispose(),
this._userInstancedBuffersStorage.vertexBuffers[n] = null));
var s = this._userInstancedBuffersStorage.data[n]
, l = 0;
t && ((u = this.instancedBuffers[n]).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[n]).toArray ? u.toArray(s, l) : u.copyToArray ? u.copyToArray(s, l) : s[l] = u,
l += o
}
this._userInstancedBuffersStorage.vertexBuffers[n] ? this._userInstancedBuffersStorage.vertexBuffers[n].updateDirectly(s, 0) : (this._userInstancedBuffersStorage.vertexBuffers[n] = new Bi(this.getEngine(),this._userInstancedBuffersStorage.data[n],n,!0,!1,o,!0),
this._invalidateInstanceVertexArrayObject())
}
}
,
Vr.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 = {}
}
}
,
Vr.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 Xl = {
effect: null,
subMesh: null
}
, jl = function(e) {
function t(t, i, n, r, o) {
void 0 === r && (r = {}),
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._floatsArrays = {},
a._colors3 = {},
a._colors3Arrays = {},
a._colors4 = {},
a._colors4Arrays = {},
a._vectors2 = {},
a._vectors3 = {},
a._vectors4 = {},
a._matrices = {},
a._matrixArrays = {},
a._matrices3x3 = {},
a._matrices2x2 = {},
a._vectors2Arrays = {},
a._vectors3Arrays = {},
a._vectors4Arrays = {},
a._uniformBuffers = {},
a._textureSamplers = {},
a._storageBuffers = {},
a._cachedWorldViewMatrix = new P,
a._cachedWorldViewProjectionMatrix = new P,
a._multiview = !1,
a._shaderPath = n,
a._options = V({
needAlphaBlending: !1,
needAlphaTesting: !1,
attributes: ["position", "normal", "uv"],
uniforms: ["worldViewProjection"],
uniformBuffers: [],
samplers: [],
externalTextures: [],
samplerObjects: [],
storageBuffers: [],
defines: [],
useClipPlane: !1
}, r),
a
}
return U(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
}),
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.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.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), n = 0; n < t.length; n++)
t[n].copyToArray(i, 16 * n);
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.isReadyForSubMesh = function(e, t, i) {
return this.isReady(e, i, t)
}
,
t.prototype.isReady = function(e, t, i) {
var n, r, 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 && this._effectUsesInstances === t)
return !0
}
var c = this.getScene()
, u = c.getEngine()
, h = []
, d = []
, p = new ys
, 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(Bi.ColorKind) && (d.push(Bi.ColorKind),
h.push("#define VERTEXCOLOR")),
t && (h.push("#define INSTANCES"),
Mr.PushAttributesForInstances(d),
(null == e ? void 0 : e.hasThinInstances) && (h.push("#define THIN_INSTANCES"),
e && e.isVerticesDataPresent(Bi.ColorInstanceKind) && (d.push(Bi.ColorInstanceKind),
h.push("#define INSTANCESCOLOR")))),
e && e.useBones && e.computeBonesUsingShaders && e.skeleton) {
d.push(Bi.MatricesIndicesKind),
d.push(Bi.MatricesWeightsKind),
e.numBoneInfluencers > 4 && (d.push(Bi.MatricesIndicesExtraKind),
d.push(Bi.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")
, A = E.supportsTangents && -1 !== h.indexOf("#define TANGENT")
, x = E.supportsNormals && -1 !== h.indexOf("#define NORMAL");
for (T = E.numInfluencers,
S && h.push("#define MORPHTARGETS_UV"),
A && h.push("#define MORPHTARGETS_TANGENT"),
x && 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(Bi.PositionKind + v),
x && d.push(Bi.NormalKind + v),
A && d.push(Bi.TangentKind + v),
S && d.push(Bi.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")),
Mr.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"),
(null === this._options.useClipPlane && c.clipPlane || this._options.useClipPlane) && (h.push("#define CLIPPLANE"),
-1 === _.indexOf("vClipPlane") && _.push("vClipPlane")),
(null === this._options.useClipPlane && c.clipPlane2 || this._options.useClipPlane) && (h.push("#define CLIPPLANE2"),
-1 === _.indexOf("vClipPlane2") && _.push("vClipPlane2")),
(null === this._options.useClipPlane && c.clipPlane3 || this._options.useClipPlane) && (h.push("#define CLIPPLANE3"),
-1 === _.indexOf("vClipPlane3") && _.push("vClipPlane3")),
(null === this._options.useClipPlane && c.clipPlane4 || this._options.useClipPlane) && (h.push("#define CLIPPLANE4"),
-1 === _.indexOf("vClipPlane4") && _.push("vClipPlane4")),
(null === this._options.useClipPlane && c.clipPlane5 || this._options.useClipPlane) && (h.push("#define CLIPPLANE5"),
-1 === _.indexOf("vClipPlane5") && _.push("vClipPlane5")),
(null === this._options.useClipPlane && c.clipPlane6 || this._options.useClipPlane) && (h.push("#define CLIPPLANE6"),
-1 === _.indexOf("vClipPlane6") && _.push("vClipPlane6")),
this.customShaderNameResolve && (_ = _.slice(),
m = m.slice(),
g = g.slice(),
f = this.customShaderNameResolve(f, _, m, g, h, d));
var P = s ? i._getDrawWrapper() : this._drawWrapper
, M = null !== (n = null == P ? void 0 : P.effect) && void 0 !== n ? n : null
, I = null !== (r = null == P ? void 0 : P.defines) && void 0 !== r ? r : null
, O = h.join("\n")
, D = M;
return I !== 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 && (Xl.effect = D,
Xl.subMesh = null !== (o = null != i ? i : null == e ? void 0 : e.subMeshes[0]) && void 0 !== o ? o : null,
this._onEffectCreatedObservable.notifyObservers(Xl))),
this._effectUsesInstances = !!t,
null !== (a = !(null == D ? void 0 : D.isReady())) && void 0 !== a && !a && (M !== D && c.resetCachedMaterial(),
D._wasPreviouslyReady = !0,
!0)
}
,
t.prototype.bindOnlyWorldMatrix = function(e, t) {
var i = this.getScene()
, n = null != t ? t : this.getEffect();
n && (-1 !== this._options.uniforms.indexOf("world") && n.setMatrix("world", e),
-1 !== this._options.uniforms.indexOf("worldView") && (e.multiplyToRef(i.getViewMatrix(), this._cachedWorldViewMatrix),
n.setMatrix("worldView", this._cachedWorldViewMatrix)),
-1 !== this._options.uniforms.indexOf("worldViewProjection") && (e.multiplyToRef(i.getTransformMatrix(), this._cachedWorldViewProjectionMatrix),
n.setMatrix("worldViewProjection", this._cachedWorldViewProjectionMatrix)))
}
,
t.prototype.bindForSubMesh = function(e, t, i) {
var n;
this.bind(e, t, null === (n = i._drawWrapperOverride) || void 0 === n ? void 0 : n.effect, i)
}
,
t.prototype.bind = function(e, t, i, n) {
var r, o = n && this._storeEffectOnSubMeshes, a = null != i ? i : o ? n.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":
Mr.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),
Mr.BindBonesParameters(t, a),
Mr.BindClipPlane(a, 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._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._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._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 && Mr.BindMorphTargetParameters(t, a);
var _ = t.bakedVertexAnimationManager;
_ && _.isEnabled && (null === (r = t.bakedVertexAnimationManager) || void 0 === r || r.bind(a, this._effectUsesInstances))
}
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 n in this._textureArrays)
for (var r = this._textureArrays[n], o = 0; o < r.length; o++)
t.push(r[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 n in this._textureArrays)
for (var r = this._textureArrays[n], o = 0; o < r.length; o++)
if (r[o] === t)
return !0;
return !1
}
,
t.prototype.clone = function(e) {
var i = this
, n = Ge.Clone((function() {
return new t(e,i.getScene(),i._shaderPath,i._options,i._storeEffectOnSubMeshes)
}
), this);
for (var r in n.name = e,
n.id = e,
"object" == typeof n._shaderPath && (n._shaderPath = V({}, n._shaderPath)),
this._options = V({}, 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(n.stencil),
this._textures)
n.setTexture(r, this._textures[r]);
for (var r in this._textureArrays)
n.setTextureArray(r, this._textureArrays[r]);
for (var r in this._externalTextures)
n.setExternalTexture(r, this._externalTextures[r]);
for (var r in this._ints)
n.setInt(r, this._ints[r]);
for (var r in this._floats)
n.setFloat(r, this._floats[r]);
for (var r in this._floatsArrays)
n.setFloats(r, this._floatsArrays[r]);
for (var r in this._colors3)
n.setColor3(r, this._colors3[r]);
for (var r in this._colors3Arrays)
n._colors3Arrays[r] = this._colors3Arrays[r];
for (var r in this._colors4)
n.setColor4(r, this._colors4[r]);
for (var r in this._colors4Arrays)
n._colors4Arrays[r] = this._colors4Arrays[r];
for (var r in this._vectors2)
n.setVector2(r, this._vectors2[r]);
for (var r in this._vectors3)
n.setVector3(r, this._vectors3[r]);
for (var r in this._vectors4)
n.setVector4(r, this._vectors4[r]);
for (var r in this._matrices)
n.setMatrix(r, this._matrices[r]);
for (var r in this._matrixArrays)
n._matrixArrays[r] = this._matrixArrays[r].slice();
for (var r in this._matrices3x3)
n.setMatrix3x3(r, this._matrices3x3[r]);
for (var r in this._matrices2x2)
n.setMatrix2x2(r, this._matrices2x2[r]);
for (var r in this._vectors2Arrays)
n.setArray2(r, this._vectors2Arrays[r]);
for (var r in this._vectors3Arrays)
n.setArray3(r, this._vectors3Arrays[r]);
for (var r in this._vectors4Arrays)
n.setArray4(r, this._vectors4Arrays[r]);
for (var r in this._uniformBuffers)
n.setUniformBuffer(r, this._uniformBuffers[r]);
for (var r in this._textureSamplers)
n.setTextureSampler(r, this._textureSamplers[r]);
for (var r in this._storageBuffers)
n.setStorageBuffer(r, this._storageBuffers[r]);
return n
}
,
t.prototype.dispose = function(t, i, n) {
if (i) {
var r;
for (r in this._textures)
this._textures[r].dispose();
for (r in this._textureArrays)
for (var o = this._textureArrays[r], a = 0; a < o.length; a++)
o[a].dispose()
}
this._textures = {},
e.prototype.dispose.call(this, t, i, n)
}
,
t.prototype.serialize = function() {
var e, t = Ge.Serialize(this);
for (e in t.customType = "BABYLON.ShaderMaterial",
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], n = 0; n < i.length; n++)
t.textureArrays[e].push(i[n].serialize())
}
for (e in t.ints = {},
this._ints)
t.ints[e] = this._ints[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.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];
return t
}
,
t.Parse = function(e, i, n) {
var r, o = Ge.Parse((function() {
return new t(e.name,i,e.shaderPath,e.options,e.storeEffectOnSubMeshes)
}
), e, i, n);
for (r in e.stencil && o.stencil.parse(e.stencil, i, n),
e.textures)
o.setTexture(r, io.Parse(e.textures[r], i, n));
for (r in e.textureArrays) {
for (var a = e.textureArrays[r], s = new Array, l = 0; l < a.length; l++)
s.push(io.Parse(a[l], i, n));
o.setTextureArray(r, s)
}
for (r in e.ints)
o.setInt(r, e.ints[r]);
for (r in e.floats)
o.setFloat(r, e.floats[r]);
for (r in e.floatsArrays)
o.setFloats(r, e.floatsArrays[r]);
for (r in e.colors3)
o.setColor3(r, D.FromArray(e.colors3[r]));
for (r in e.colors3Arrays) {
var c = e.colors3Arrays[r].reduce((function(e, t, i) {
return i % 3 == 0 ? e.push([t]) : e[e.length - 1].push(t),
e
}
), []).map((function(e) {
return D.FromArray(e)
}
));
o.setColor3Array(r, c)
}
for (r in e.colors4)
o.setColor4(r, N.FromArray(e.colors4[r]));
for (r in e.colors4Arrays)
c = e.colors4Arrays[r].reduce((function(e, t, i) {
return i % 4 == 0 ? e.push([t]) : e[e.length - 1].push(t),
e
}
), []).map((function(e) {
return N.FromArray(e)
}
)),
o.setColor4Array(r, c);
for (r in e.vectors2)
o.setVector2(r, A.FromArray(e.vectors2[r]));
for (r in e.vectors3)
o.setVector3(r, x.FromArray(e.vectors3[r]));
for (r in e.vectors4)
o.setVector4(r, R.FromArray(e.vectors4[r]));
for (r in e.matrices)
o.setMatrix(r, P.FromArray(e.matrices[r]));
for (r in e.matrixArray)
o._matrixArrays[r] = new Float32Array(e.matrixArray[r]);
for (r in e.matrices3x3)
o.setMatrix3x3(r, e.matrices3x3[r]);
for (r in e.matrices2x2)
o.setMatrix2x2(r, e.matrices2x2[r]);
for (r in e.vectors2Arrays)
o.setArray2(r, e.vectors2Arrays[r]);
for (r in e.vectors3Arrays)
o.setArray3(r, e.vectors3Arrays[r]);
for (r in e.vectors4Arrays)
o.setArray4(r, e.vectors4Arrays[r]);
return o
}
,
t.ParseFromFileAsync = function(e, t, i, n) {
var r = this;
return void 0 === n && (n = ""),
new Promise((function(o, a) {
var s = new Ye;
s.addEventListener("readystatechange", (function() {
if (4 == s.readyState)
if (200 == s.status) {
var t = JSON.parse(s.responseText)
, l = r.Parse(t, i || E.LastCreatedScene, n);
e && (l.name = e),
o(l)
} else
a("Unable to load the ShaderMaterial")
}
)),
s.open("GET", t),
s.send()
}
))
}
,
t.CreateFromSnippetAsync = function(e, t, i) {
var n = this;
return void 0 === i && (i = ""),
new Promise((function(r, o) {
var a = new Ye;
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 = n.Parse(l, t || E.LastCreatedScene, i);
c.snippetId = e,
r(c)
} else
o("Unable to load the snippet " + e)
}
)),
a.open("GET", n.SnippetUrl + "/" + e.replace(/#/g, "/")),
a.send()
}
))
}
,
t.SnippetUrl = "https://snippet.babylonjs.com",
t
}(gs);
y("BABYLON.ShaderMaterial", jl);
Pt.ShadersStore.colorPixelShader = "#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\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)\ngl_FragColor=vColor;\n#else\ngl_FragColor=color;\n#endif\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
Pt.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)\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) {\ngl_Position=viewProjection*worldPos;\n} else {\ngl_Position=viewProjectionR*worldPos;\n}\n#else\ngl_Position=viewProjection*worldPos;\n#endif\n#include\n#ifdef VERTEXCOLOR\nvColor=color;\n#elif INSTANCESCOLOR\nvColor=instanceColor;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}",
Vr._LinesMeshParser = function(e, t) {
return Yl.Parse(e, t)
}
;
var Yl = function(e) {
function t(t, i, n, r, o, a, s, l) {
void 0 === i && (i = null),
void 0 === n && (n = null),
void 0 === r && (r = null);
var c = e.call(this, t, i, n, r, o) || this;
c.useVertexColor = a,
c.useVertexAlpha = s,
c.color = new D(1,1,1),
c.alpha = 1,
r && (c.color = r.color.clone(),
c.alpha = r.alpha,
c.useVertexColor = r.useVertexColor,
c.useVertexAlpha = r.useVertexAlpha),
c.intersectionThreshold = .1;
var u = {
attributes: [Bi.PositionKind],
uniforms: ["vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "world", "viewProjection"],
needAlphaBlending: !0,
defines: [],
useClipPlane: null
};
return !1 === s && (u.needAlphaBlending = !1),
a ? (u.defines.push("#define VERTEXCOLOR"),
u.attributes.push(Bi.ColorKind)) : (u.uniforms.push("color"),
c._color4 = new N),
c.material = l || new jl("colorShader",c.getScene(),"color",u,!1),
c
}
return U(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 = Or.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() {
if (!this._geometry)
return this;
var e = this._lineMaterial.getEffect()
, t = this.isUnIndexed ? null : this._geometry.getIndexBuffer();
if (this._userInstancedBuffersStorage ? this._geometry._bind(e, t, this._userInstancedBuffersStorage.vertexBuffers, this._userInstancedBuffersStorage.vertexArrayObjects) : this._geometry._bind(e, t),
!this.useVertexColor && this._isShaderMaterial(this._lineMaterial)) {
var i = this.color
, n = i.r
, r = i.g
, o = i.b;
this._color4.set(n, r, o, 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 n = this.getScene().getEngine();
return this._unIndexed ? n.drawArraysType(Or.LineListDrawMode, e.verticesStart, e.verticesCount, i) : n.drawElementsType(Or.LineListDrawMode, e.indexStart, e.indexCount, i),
this
}
,
t.prototype.dispose = function(t) {
this._lineMaterial.dispose(!1, !1, !0),
e.prototype.dispose.call(this, t)
}
,
t.prototype.clone = function(e, i, n) {
return void 0 === i && (i = null),
new t(e,this.getScene(),i,this,n)
}
,
t.prototype.createInstance = function(e) {
var t = new Kl(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 n = new t(e.name,i);
return n.color = D.FromArray(e.color),
n.alpha = e.alpha,
n
}
,
t
}(Vr)
, Kl = function(e) {
function t(t, i) {
var n = e.call(this, t, i) || this;
return n.intersectionThreshold = i.intersectionThreshold,
n
}
return U(t, e),
t.prototype.getClassName = function() {
return "InstancedLinesMesh"
}
,
t
}(Hl);
function Ql(e) {
for (var t = [], i = [], n = e.lines, r = e.colors, o = [], a = 0, s = 0; s < n.length; s++)
for (var l = n[s], c = 0; c < l.length; c++) {
if (i.push(l[c].x, l[c].y, l[c].z),
r) {
var u = r[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 $n;
return h.indices = t,
h.positions = i,
r && (h.colors = o),
h
}
function ql(e) {
var t, i, n = e.dashSize || 3, r = e.gapSize || 1, o = e.dashNb || 200, a = e.points, s = new Array, l = new Array, c = x.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 = n * (t = u / o) / (n + r),
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 $n;
return m.positions = s,
m.indices = l,
m
}
function Zl(e, t, i) {
var n = t.instance
, r = t.lines
, o = t.colors;
if (n) {
var a = n.getVerticesData(Bi.PositionKind)
, s = void 0
, l = void 0;
o && (s = n.getVerticesData(Bi.ColorKind));
for (var c = 0, u = 0, h = 0; h < r.length; h++)
for (var d = r[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 n.updateVerticesData(Bi.PositionKind, a, !1, !1),
o && s && n.updateVerticesData(Bi.ColorKind, s, !1, !1),
n
}
var f = new Yl(e,i,null,void 0,void 0,!!o,t.useVertexAlpha,t.material);
return Ql(t).applyToMesh(f, t.updatable),
f
}
function Jl(e, t, i) {
void 0 === i && (i = null);
var n = t.colors ? [t.colors] : null;
return Zl(e, {
lines: [t.points],
updatable: t.updatable,
instance: t.instance,
colors: n,
useVertexAlpha: t.useVertexAlpha,
material: t.material
}, i)
}
function $l(e, t, i) {
void 0 === i && (i = null);
var n = t.points
, r = t.instance
, o = t.gapSize || 1
, a = t.dashSize || 3;
if (r)
return r.updateMeshPositions((function(e) {
var t, i, o = x.Zero(), a = e.length / 6, s = 0, l = 0, c = 0, u = 0, h = 0, d = 0;
for (h = 0; h < n.length - 1; h++)
n[h + 1].subtractToRef(n[h], o),
s += o.length();
t = s / a;
var p = r._creationDataStorage.dashSize;
for (i = p * t / (p + r._creationDataStorage.gapSize),
h = 0; h < n.length - 1; h++)
for (n[h + 1].subtractToRef(n[h], o),
l = Math.floor(o.length() / t),
o.normalize(),
d = 0; d < l && u < e.length; )
c = t * d,
e[u] = n[h].x + c * o.x,
e[u + 1] = n[h].y + c * o.y,
e[u + 2] = n[h].z + c * o.z,
e[u + 3] = n[h].x + (c + i) * o.x,
e[u + 4] = n[h].y + (c + i) * o.y,
e[u + 5] = n[h].z + (c + i) * o.z,
u += 6,
d++;
for (; u < e.length; )
e[u] = n[h].x,
e[u + 1] = n[h].y,
e[u + 2] = n[h].z,
u += 3
}
), !1),
r;
var s = new Yl(e,i,null,void 0,void 0,void 0,t.useVertexAlpha,t.material);
return ql(t).applyToMesh(s, t.updatable),
s._creationDataStorage = new Lr,
s._creationDataStorage.dashSize = a,
s._creationDataStorage.gapSize = o,
s
}
var ec = {
CreateDashedLines: $l,
CreateLineSystem: Zl,
CreateLines: Jl
};
$n.CreateLineSystem = Ql,
$n.CreateDashedLines = ql,
Vr.CreateLines = function(e, t, i, n, r) {
return void 0 === i && (i = null),
void 0 === n && (n = !1),
void 0 === r && (r = null),
Jl(e, {
points: t,
updatable: n,
instance: r
}, i)
}
,
Vr.CreateDashedLines = function(e, t, i, n, r, o, a, s) {
return void 0 === o && (o = null),
$l(e, {
points: t,
dashSize: i,
gapSize: n,
dashNb: r,
updatable: a,
instance: s
}, o)
}
;
var tc = function() {
function e(e) {
this.ray = e
}
return e.CreateAndShow = function(t, i, n) {
var r = new e(t);
return r.show(i, n),
r
}
,
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 = Jl("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]
, n = Math.min(t.length, 1e6);
i.copyFrom(t.direction),
i.scaleInPlace(n),
i.addInPlace(t.origin),
this._renderPoints[0].copyFrom(t.origin),
Jl("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, n) {
var r = this;
this._attachedToMesh = e;
var o = this.ray;
o && (o.direction || (o.direction = x.Zero()),
o.origin || (o.origin = x.Zero()),
n && (o.length = n),
i || (i = x.Zero()),
t || (t = new x(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 r._updateToMesh()
}
)),
this._onAfterStepObserver = this._scene.onAfterStepObservable.add((function() {
return r._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),
x.TransformCoordinatesToRef(this._meshSpaceOrigin, this._attachedToMesh.getWorldMatrix(), e.origin)))
}
,
e.prototype.dispose = function() {
this.hide(),
this.detachFromMesh(),
this.ray = null
}
,
e
}();
function ic(e) {
var t = e.pathArray
, i = e.closeArray || !1
, n = e.closePath || !1
, r = 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 || $n.DEFAULTSIDE, d = e.uvs, p = e.colors, f = [], _ = [], m = [], g = [], v = [], y = [], b = [], T = [], E = [], S = [];
if (t.length < 2) {
var A = []
, x = [];
for (c = 0; c < t[0].length - a; c++)
A.push(t[0][c]),
x.push(t[0][c + a]);
t = [A, x]
}
var R, C, P, M, I, O = 0, D = n ? 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++;
n && (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, L, F = null, w = null;
for (c = 0; c < s + D; c++) {
for (T[c] = 0,
y[c] = [0],
l = 0; l < t.length - 1; l++)
M = t[l],
I = t[l + 1],
c === s ? (F = M[0],
w = I[0]) : (F = M[c],
w = I[c]),
P = w.subtract(F).length() + T[c],
y[c].push(P),
T[c] = P;
i && w && F && (M = t[l],
I = t[0],
c === s && (w = I[0]),
P = w.subtract(F).length() + T[c],
T[c] = P)
}
if (d)
for (l = 0; l < d.length; l++)
g.push(d[l].x, pr.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,
L = 0 != T[c] ? y[c][l] / T[c] : 0,
r ? g.push(L, N) : g.push(N, pr.UseOpenGLOrientationForUV ? 1 - L : L);
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 ($n.ComputeNormals(f, _, m),
n) {
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]
}
$n._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 $n
, 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, Bi.ColorKind),
n && (Y._idx = S),
Y
}
function nc(e, t, i) {
void 0 === i && (i = null);
var n = t.pathArray
, r = t.closeArray
, o = t.closePath
, a = Vr._GetDefaultSideOrientation(t.sideOrientation)
, s = t.instance
, l = t.updatable;
if (s) {
var c = I.Vector3[0].setAll(Number.MAX_VALUE)
, u = I.Vector3[1].setAll(-Number.MAX_VALUE)
, h = s.getVerticesData(Bi.PositionKind);
if (function(e) {
for (var t = n[0].length, i = s, r = 0, o = i._originalBuilderSideOrientation === Vr.DOUBLESIDE ? 2 : 1, a = 1; a <= o; ++a)
for (var l = 0; l < n.length; ++l) {
var h = n[l]
, d = h.length;
t = t < d ? t : d;
for (var p = 0; p < t; ++p) {
var f = h[p];
e[r] = f.x,
e[r + 1] = f.y,
e[r + 2] = f.z,
c.minimizeInPlaceFromFloats(f.x, f.y, f.z),
u.maximizeInPlaceFromFloats(f.x, f.y, f.z),
r += 3
}
i._creationDataStorage && i._creationDataStorage.closePath && (f = h[0],
e[r] = f.x,
e[r + 1] = f.y,
e[r + 2] = f.z,
r += 3)
}
}(h),
s.hasBoundingInfo ? s.getBoundingInfo().reConstruct(c, u, s._worldMatrix) : s.buildBoundingInfo(c, u, s._worldMatrix),
s.updateVerticesData(Bi.PositionKind, h, !1, !1),
t.colors) {
for (var d = s.getVerticesData(Bi.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(Bi.ColorKind, d, !1, !1)
}
if (t.uvs) {
for (var m = s.getVerticesData(Bi.UVKind), g = 0; g < t.uvs.length; g++)
m[2 * g] = t.uvs[g].x,
m[2 * g + 1] = pr.UseOpenGLOrientationForUV ? 1 - t.uvs[g].y : t.uvs[g].y;
s.updateVerticesData(Bi.UVKind, m, !1, !1)
}
if (!s.areNormalsFrozen || s.isFacetDataEnabled) {
var v = s.getIndices()
, y = s.getVerticesData(Bi.NormalKind)
, b = s.isFacetDataEnabled ? s.getFacetDataParameters() : null;
if ($n.ComputeNormals(h, v, y, b),
s._creationDataStorage && s._creationDataStorage.closePath)
for (var T = 0, E = 0, S = 0; S < n.length; S++)
T = 3 * s._creationDataStorage.idx[S],
E = S + 1 < n.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(Bi.NormalKind, y, !1, !1)
}
return s
}
var A = new Vr(e,i);
A._originalBuilderSideOrientation = a,
A._creationDataStorage = new Lr;
var x = ic(t);
return o && (A._creationDataStorage.idx = x._idx),
A._creationDataStorage.closePath = o,
A._creationDataStorage.closeArray = r,
x.applyToMesh(A, l),
A
}
var rc = {
CreateRibbon: nc
};
function oc(e, t, i) {
void 0 === i && (i = null);
var n = t.path
, r = t.shape
, o = t.scale || 1
, a = t.rotation || 0
, s = 0 === t.cap ? 0 : t.cap || Vr.NO_CAP
, l = t.updatable
, c = Vr._GetDefaultSideOrientation(t.sideOrientation)
, u = t.instance || null
, h = t.invertUV || !1
, d = t.closeShape || !1;
return sc(e, r, n, o, a, null, null, t.closePath || !1, d, s, !1, i, !!l, c, u, h, t.frontUVs || null, t.backUVs || null)
}
function ac(e, t, i) {
void 0 === i && (i = null);
var n = t.path;
return sc(e, t.shape, n, null, null, t.scaleFunction || function() {
return 1
}
, t.rotationFunction || function() {
return 0
}
, t.closePath || t.ribbonCloseArray || !1, t.closeShape || t.ribbonClosePath || !1, 0 === t.cap ? 0 : t.cap || Vr.NO_CAP, !0, i, !!t.updatable, Vr._GetDefaultSideOrientation(t.sideOrientation), t.instance || null, t.invertUV || !1, t.frontUVs || null, t.backUVs || null)
}
function sc(e, t, i, n, r, o, a, s, l, c, u, h, d, p, f, _, m, g) {
var v, y, b = function(e, t, i, n, r, o, a, s, l, c) {
for (var u = i.getTangents(), h = i.getNormals(), d = i.getBinormals(), p = i.getDistances(), f = 0, _ = c && s ? s : function() {
return null !== o ? o : 0
}
, m = c && a ? a : function() {
return null !== r ? r : 1
}
, g = l === Vr.NO_CAP || l === Vr.CAP_END ? 0 : 2, v = I.Matrix[0], y = 0; y < t.length; y++) {
for (var b = new Array, T = _(y, p[y]), E = m(y, p[y]), S = 0; S < e.length; S++) {
P.RotationAxisToRef(u[y], f, v);
var A = u[y].scale(e[S].z).add(h[y].scale(e[S].x)).add(d[y].scale(e[S].y))
, R = b[S] ? b[S] : x.Zero();
x.TransformCoordinatesToRef(A, v, R),
R.scaleInPlace(E).addInPlace(t[y]),
b[S] = R
}
n[g] = b,
f += T,
g++
}
var C = function(e) {
var t, i = Array(), n = x.Zero();
for (t = 0; t < e.length; t++)
n.addInPlace(e[t]);
for (n.scaleInPlace(1 / e.length),
t = 0; t < e.length; t++)
i.push(n);
return i
};
switch (l) {
case Vr.NO_CAP:
break;
case Vr.CAP_START:
n[0] = C(n[2]),
n[1] = n[2];
break;
case Vr.CAP_END:
n[g] = n[g - 1],
n[g + 1] = C(n[g - 1]);
break;
case Vr.CAP_ALL:
n[0] = C(n[2]),
n[1] = n[2],
n[g] = n[g - 1],
n[g + 1] = C(n[g - 1])
}
return n
};
if (f) {
var T = f._creationDataStorage;
return v = T.path3D.update(i),
nc("", {
pathArray: y = b(t, i, T.path3D, T.pathArray, n, r, o, a, T.cap, u),
closeArray: !1,
closePath: !1,
offset: 0,
updatable: !1,
sideOrientation: 0,
instance: f
}, h || void 0)
}
c = c < 0 || c > 3 ? 0 : c;
var E = nc(e, {
pathArray: y = b(t, i, v = new Cn(i), new Array, n, r, o, a, c, u),
closeArray: s,
closePath: l,
updatable: d,
sideOrientation: p,
invertUV: _,
frontUVs: m || void 0,
backUVs: g || void 0
}, h);
return E._creationDataStorage.pathArray = y,
E._creationDataStorage.path3D = v,
E._creationDataStorage.cap = c,
E
}
$n.CreateRibbon = ic,
Vr.CreateRibbon = function(e, t, i, n, r, o, a, s, l) {
return void 0 === i && (i = !1),
void 0 === a && (a = !1),
nc(e, {
pathArray: t,
closeArray: i,
closePath: n,
offset: r,
updatable: a,
sideOrientation: s,
instance: l
}, o)
}
;
var lc = {
ExtrudeShape: oc,
ExtrudeShapeCustom: ac
};
Vr.ExtrudeShape = function(e, t, i, n, r, o, a, s, l, c) {
return void 0 === a && (a = null),
oc(e, {
shape: t,
path: i,
scale: n,
rotation: r,
cap: 0 === o ? 0 : o || Vr.NO_CAP,
sideOrientation: l,
instance: c,
updatable: s
}, a)
}
,
Vr.ExtrudeShapeCustom = function(e, t, i, n, r, o, a, s, l, c, u, h) {
return ac(e, {
shape: t,
path: i,
scaleFunction: n,
rotationFunction: r,
ribbonCloseArray: o,
ribbonClosePath: a,
cap: 0 === s ? 0 : s || Vr.NO_CAP,
sideOrientation: u,
instance: h,
updatable: c
}, l)
}
;
var cc = function() {
function e(t, i, n, r, o, a) {
var s, l, c, u, h, d, p, f, _, m, g, v, y, b;
void 0 === r && (r = !0),
void 0 === o && (o = 3),
void 0 === a && (a = {}),
this.skeleton = t,
this.mesh = i,
this.autoUpdateBonesMatrices = r,
this.renderingGroupId = o,
this.options = a,
this.color = D.White(),
this._debugLines = new Array,
this._localAxes = null,
this._isEnabled = !0,
this._obs = null,
this._scene = n,
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(Bi.MatricesIndicesKind)
, E = i.getVerticesData(Bi.MatricesWeightsKind);
if (this._boneIndices = new Set,
!a.useAllBones && T && E)
for (var S = 0; S < T.length; ++S) {
var A = T[S];
0 !== E[S] && this._boneIndices.add(A)
}
this._utilityLayer = new El(this._scene,!1),
this._utilityLayer.pickUtilitySceneFirst = !1,
this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = !0;
var x = this.options.displayMode || 0;
x > e.DISPLAY_SPHERE_AND_SPURS && (x = e.DISPLAY_LINES),
this.displayMode = x,
this.update(),
this._bindObs()
}
return e.CreateBoneWeightShader = function(e, t) {
var i, n, r, o, a, s, l = e.skeleton, c = null !== (i = e.colorBase) && void 0 !== i ? i : D.Black(), u = null !== (n = e.colorZero) && void 0 !== n ? n : D.Blue(), h = null !== (r = e.colorQuarter) && void 0 !== r ? r : D.Green(), d = null !== (o = e.colorHalf) && void 0 !== o ? o : D.Yellow(), p = null !== (a = e.colorFull) && void 0 !== a ? a : D.Red(), f = null !== (s = e.targetBoneIndex) && void 0 !== s ? s : 0;
Mt.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 }",
Mt.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 jl("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 = Or.MATERIAL_OPAQUE,
_
}
,
e.CreateSkeletonMapShader = function(t, i) {
var n, r = t.skeleton, o = null !== (n = t.colorMap) && void 0 !== n ? n : [{
color: new D(1,.38,.18),
location: 0
}, {
color: new D(.59,.18,1),
location: .2
}, {
color: new D(.59,1,.18),
location: .4
}, {
color: new D(1,.87,.17),
location: .6
}, {
color: new D(1,.17,.42),
location: .8
}, {
color: new D(.17,.68,1),
location: 1
}], a = r.bones.length + 1, s = e._CreateBoneMapColorBuffer(a, o, i), l = new jl("boneWeights:" + r.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 * r.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 = Or.MATERIAL_OPAQUE,
l
}
,
e._CreateBoneMapColorBuffer = function(e, t, i) {
var n = new Ds("temp",{
width: e,
height: 1
},i,!1)
, r = n.getContext()
, o = r.createLinearGradient(0, 0, e, 0);
t.forEach((function(e) {
o.addColorStop(e.location, e.color.toHexString())
}
)),
r.fillStyle = o,
r.fillRect(0, 0, e, 1),
n.update();
for (var a = [], s = r.getImageData(0, 0, e, 1).data, l = 0; l < s.length; l++)
a.push(.00392156862745098 * s[l]);
return n.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, n, r, o) {
void 0 === n && (n = 0),
void 0 === r && (r = 0),
void 0 === o && (o = 0);
var a = I.Matrix[0]
, s = t.getParent();
if (a.copyFrom(t.getLocalMatrix()),
0 !== n || 0 !== r || 0 !== o) {
var l = I.Matrix[1];
P.IdentityToRef(l),
l.setTranslationFromFloats(n, r, o),
l.multiplyToRef(a, a)
}
s && a.multiplyToRef(s.getAbsoluteTransform(), 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, n = this.mesh.position, r = 0, o = 0; o < i; o++) {
var a = e[o]
, s = this._debugLines[r];
-1 !== a._index && (this._boneIndices.has(a.getIndex()) || this.options.useAllBones) && (s || (s = [x.Zero(), x.Zero()],
this._debugLines[r] = s),
this._getBonePosition(s[0], a, t),
this._getBonePosition(s[1], a, t, 0, a.length, 0),
s[0].subtractInPlace(n),
s[1].subtractInPlace(n),
r++)
}
}
,
e.prototype._getLinesForBonesNoLength = function(e) {
for (var t = e.length, i = 0, n = this.mesh, r = n.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 = [x.Zero(), x.Zero()],
this._debugLines[i] = l),
a.getAbsolutePositionToRef(n, l[0]),
s.getAbsolutePositionToRef(n, l[1]),
l[0].subtractInPlace(r),
l[1].subtractInPlace(r),
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.getBaseMatrix().multiplyToRef(t, t)) : t.copyFrom(P.Identity())
}
,
e.prototype._buildSpheresAndSpurs = function(e) {
var t, i;
void 0 === e && (e = !0),
this._debugMesh && (this._debugMesh.dispose(),
this._debugMesh = null,
this.ready = !1),
this._ready = !1;
var n = null === (t = this.utilityLayer) || void 0 === t ? void 0 : t.utilityLayerScene
, r = this.skeleton.bones
, o = []
, a = []
, s = this.scene.animationsEnabled;
try {
this.options.pauseAnimations && (this.scene.animationsEnabled = !1,
n.animationsEnabled = !1),
this.options.returnToRest && this.skeleton.returnToRest(),
this.autoUpdateBonesMatrices && this.skeleton.computeAbsoluteTransforms();
for (var l = Number.NEGATIVE_INFINITY, c = this.options.displayOptions || {}, u = function(t) {
var i = r[t];
if (-1 === i._index || !h._boneIndices.has(i.getIndex()) && !h.options.useAllBones)
return "continue";
var s = new P;
h._getAbsoluteBindPoseToRef(i, s);
var u = new x;
s.decompose(void 0, void 0, u),
i.children.forEach((function(t) {
var r = new P;
t.getBaseMatrix().multiplyToRef(s, r);
var o = new x;
r.decompose(void 0, void 0, o);
var h = x.Distance(u, o);
if (h > l && (l = h),
!e) {
for (var d = o.clone().subtract(u.clone()), p = d.length(), f = d.normalize().scale(p), _ = c.midStep || .165, m = c.midStepFactor || .215, g = f.scale(_), v = ac("skeletonViewer", {
shape: [new x(1,-1,0), new x(1,1,0), new x(-1,1,0), new x(-1,-1,0), new x(1,-1,0)],
path: [x.Zero(), g, f],
scaleFunction: function(e) {
switch (e) {
case 0:
case 2:
return 0;
case 1:
return p * m
}
return 0
},
sideOrientation: Vr.DEFAULTSIDE,
updatable: !1
}, n), y = v.getTotalVertices(), b = [], T = [], E = 0; E < y; E++)
b.push(1, 0, 0, 0),
c.spurFollowsChild && E > 9 ? T.push(t.getIndex(), 0, 0, 0) : T.push(i.getIndex(), 0, 0, 0);
v.position = u.clone(),
v.setVerticesData(Bi.MatricesWeightsKind, b, !1),
v.setVerticesData(Bi.MatricesIndicesKind, T, !1),
v.convertToFlatShadedMesh(),
a.push(v)
}
}
));
for (var d = Dl("skeletonViewer", {
segments: 6,
diameter: c.sphereBaseSize || .2,
updatable: !0
}, n), p = d.getTotalVertices(), f = [], _ = [], m = 0; m < p; m++)
f.push(1, 0, 0, 0),
_.push(i.getIndex(), 0, 0, 0);
d.setVerticesData(Bi.MatricesWeightsKind, f, !1),
d.setVerticesData(Bi.MatricesIndicesKind, _, !1),
d.position = u.clone(),
o.push([d, i])
}, h = this, d = 0; d < r.length; d++)
u(d);
var p = c.sphereScaleUnit || 2
, f = c.sphereFactor || .85
, _ = [];
for (d = 0; d < o.length; d++) {
for (var m = o[d], g = m[0], v = m[1], y = 1 / (p / l), b = 0, T = v; T.getParent() && -1 !== T.getParent().getIndex(); )
b++,
T = T.getParent();
g.scaling.scaleInPlace(y * Math.pow(f, b)),
_.push(g)
}
this.debugMesh = Vr.MergeMeshes(_.concat(a), !0, !0),
this.debugMesh && (this.debugMesh.renderingGroupId = this.renderingGroupId,
this.debugMesh.skeleton = this.skeleton,
this.debugMesh.parent = this.mesh,
this.debugMesh.computeBonesUsingShaders = null === (i = this.options.computeBonesUsingShaders) || void 0 === i || i,
this.debugMesh.alwaysSelectAsActiveMesh = !0),
this.utilityLayer._getSharedGizmoLight().intensity = .7,
this._revert(s),
this.ready = !0
} catch (e) {
console.error(e),
this._revert(s),
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
, n = t.localAxesSize || .075
, r = []
, o = []
, a = new N(1,0,0,1)
, s = new N(0,1,0,1)
, l = new N(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 P
, f = new x;
this._getAbsoluteBindPoseToRef(d, p),
p.decompose(void 0, void 0, f);
var _ = d.getBaseMatrix().getRotationMatrix()
, m = x.TransformCoordinates(new x(0 + n,0,0), _)
, g = x.TransformCoordinates(new x(0,0 + n,0), _)
, v = x.TransformCoordinates(new x(0,0,0 + n), _)
, y = [[f, f.add(m)], [f, f.add(g)], [f, f.add(v)]]
, b = [[a, a], [s, s], [l, l]];
r.push.apply(r, 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 = Zl("localAxes", {
lines: r,
colors: o,
updatable: !0
}, i),
this._localAxes.setVerticesData(Bi.MatricesWeightsKind, c, !1),
this._localAxes.setVerticesData(Bi.MatricesIndicesKind, u, !1),
this._localAxes.skeleton = this.skeleton,
this._localAxes.renderingGroupId = this.renderingGroupId,
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.computeAbsoluteTransforms(),
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 ? Zl("", {
lines: this._debugLines,
updatable: !0,
instance: this._debugMesh
}, e) : (this._debugMesh = Zl("", {
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
}()
, uc = function() {
function e(e, t) {
this._oldPosition = new x(Number.NaN,Number.NaN,Number.NaN),
this._oldDirection = new x(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 = P.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, n, r, 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,
I.Vector3[0].set(this._light.orthoLeft, this._light.orthoBottom, void 0 !== this._light.shadowMinZ ? this._light.shadowMinZ : this._camera.minZ),
I.Vector3[1].set(this._light.orthoRight, this._light.orthoTop, void 0 !== this._light.shadowMaxZ ? this._light.shadowMaxZ : this._camera.maxZ);
var a = this._getInvertViewMatrix();
I.Vector3[2].copyFromFloats(I.Vector3[1].x, I.Vector3[1].y, I.Vector3[0].z),
I.Vector3[3].copyFromFloats(I.Vector3[1].x, I.Vector3[0].y, I.Vector3[0].z),
I.Vector3[4].copyFromFloats(I.Vector3[0].x, I.Vector3[0].y, I.Vector3[0].z),
I.Vector3[5].copyFromFloats(I.Vector3[0].x, I.Vector3[1].y, I.Vector3[0].z),
x.TransformCoordinatesToRef(I.Vector3[2], a, I.Vector3[2]),
x.TransformCoordinatesToRef(I.Vector3[3], a, I.Vector3[3]),
x.TransformCoordinatesToRef(I.Vector3[4], a, I.Vector3[4]),
x.TransformCoordinatesToRef(I.Vector3[5], a, I.Vector3[5]),
I.Vector3[6].copyFromFloats(I.Vector3[1].x, I.Vector3[1].y, I.Vector3[1].z),
I.Vector3[7].copyFromFloats(I.Vector3[1].x, I.Vector3[0].y, I.Vector3[1].z),
I.Vector3[8].copyFromFloats(I.Vector3[0].x, I.Vector3[0].y, I.Vector3[1].z),
I.Vector3[9].copyFromFloats(I.Vector3[0].x, I.Vector3[1].y, I.Vector3[1].z),
x.TransformCoordinatesToRef(I.Vector3[6], a, I.Vector3[6]),
x.TransformCoordinatesToRef(I.Vector3[7], a, I.Vector3[7]),
x.TransformCoordinatesToRef(I.Vector3[8], a, I.Vector3[8]),
x.TransformCoordinatesToRef(I.Vector3[9], a, I.Vector3[9]),
Jl("nearlines", {
updatable: !0,
points: this._nearLinesPoints,
instance: this._lightHelperFrustumMeshes[0]
}, this._scene),
Jl("farlines", {
updatable: !0,
points: this._farLinesPoints,
instance: this._lightHelperFrustumMeshes[1]
}, this._scene),
Jl("trlines", {
updatable: !0,
points: this._trLinesPoints,
instance: this._lightHelperFrustumMeshes[2]
}, this._scene),
Jl("brlines", {
updatable: !0,
points: this._brLinesPoints,
instance: this._lightHelperFrustumMeshes[3]
}, this._scene),
Jl("tllines", {
updatable: !0,
points: this._tlLinesPoints,
instance: this._lightHelperFrustumMeshes[4]
}, this._scene),
Jl("bllines", {
updatable: !0,
points: this._blLinesPoints,
instance: this._lightHelperFrustumMeshes[5]
}, this._scene),
I.Vector3[2].toArray(this._nearPlaneVertices, 0),
I.Vector3[3].toArray(this._nearPlaneVertices, 3),
I.Vector3[4].toArray(this._nearPlaneVertices, 6),
I.Vector3[5].toArray(this._nearPlaneVertices, 9),
null === (e = this._lightHelperFrustumMeshes[6].geometry) || void 0 === e || e.updateVerticesDataDirectly("position", this._nearPlaneVertices, 0),
I.Vector3[6].toArray(this._farPlaneVertices, 0),
I.Vector3[7].toArray(this._farPlaneVertices, 3),
I.Vector3[8].toArray(this._farPlaneVertices, 6),
I.Vector3[9].toArray(this._farPlaneVertices, 9),
null === (t = this._lightHelperFrustumMeshes[7].geometry) || void 0 === t || t.updateVerticesDataDirectly("position", this._farPlaneVertices, 0),
I.Vector3[2].toArray(this._rightPlaneVertices, 0),
I.Vector3[6].toArray(this._rightPlaneVertices, 3),
I.Vector3[7].toArray(this._rightPlaneVertices, 6),
I.Vector3[3].toArray(this._rightPlaneVertices, 9),
null === (i = this._lightHelperFrustumMeshes[8].geometry) || void 0 === i || i.updateVerticesDataDirectly("position", this._rightPlaneVertices, 0),
I.Vector3[5].toArray(this._leftPlaneVertices, 0),
I.Vector3[9].toArray(this._leftPlaneVertices, 3),
I.Vector3[8].toArray(this._leftPlaneVertices, 6),
I.Vector3[4].toArray(this._leftPlaneVertices, 9),
null === (n = this._lightHelperFrustumMeshes[9].geometry) || void 0 === n || n.updateVerticesDataDirectly("position", this._leftPlaneVertices, 0),
I.Vector3[2].toArray(this._topPlaneVertices, 0),
I.Vector3[6].toArray(this._topPlaneVertices, 3),
I.Vector3[9].toArray(this._topPlaneVertices, 6),
I.Vector3[5].toArray(this._topPlaneVertices, 9),
null === (r = this._lightHelperFrustumMeshes[10].geometry) || void 0 === r || r.updateVerticesDataDirectly("position", this._topPlaneVertices, 0),
I.Vector3[3].toArray(this._bottomPlaneVertices, 0),
I.Vector3[7].toArray(this._bottomPlaneVertices, 3),
I.Vector3[8].toArray(this._bottomPlaneVertices, 6),
I.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 yr("directionalLightHelperRoot_" + this._light.name,this._scene),
this._rootNode.parent = this._light.parent,
this._nearLinesPoints = [x.ZeroReadOnly, x.ZeroReadOnly, x.ZeroReadOnly, x.ZeroReadOnly, x.ZeroReadOnly];
var t = Jl("nearlines", {
updatable: !0,
points: this._nearLinesPoints
}, this._scene);
t.parent = this._rootNode,
t.alwaysSelectAsActiveMesh = !0,
this._farLinesPoints = [x.ZeroReadOnly, x.ZeroReadOnly, x.ZeroReadOnly, x.ZeroReadOnly, x.ZeroReadOnly];
var i = Jl("farlines", {
updatable: !0,
points: this._farLinesPoints
}, this._scene);
i.parent = this._rootNode,
i.alwaysSelectAsActiveMesh = !0,
this._trLinesPoints = [x.ZeroReadOnly, x.ZeroReadOnly];
var n = Jl("trlines", {
updatable: !0,
points: this._trLinesPoints
}, this._scene);
n.parent = this._rootNode,
n.alwaysSelectAsActiveMesh = !0,
this._brLinesPoints = [x.ZeroReadOnly, x.ZeroReadOnly];
var r = Jl("brlines", {
updatable: !0,
points: this._brLinesPoints
}, this._scene);
r.parent = this._rootNode,
r.alwaysSelectAsActiveMesh = !0,
this._tlLinesPoints = [x.ZeroReadOnly, x.ZeroReadOnly];
var o = Jl("tllines", {
updatable: !0,
points: this._tlLinesPoints
}, this._scene);
o.parent = this._rootNode,
o.alwaysSelectAsActiveMesh = !0,
this._blLinesPoints = [x.ZeroReadOnly, x.ZeroReadOnly];
var a = Jl("bllines", {
updatable: !0,
points: this._blLinesPoints
}, this._scene);
a.parent = this._rootNode,
a.alwaysSelectAsActiveMesh = !0,
this._lightHelperFrustumMeshes.push(t, i, n, r, o, a);
var s = function(t, i, n) {
var r = new Vr(t + "plane",e._scene)
, o = new Os(t + "PlaneMat",e._scene);
r.material = o,
r.parent = e._rootNode,
r.alwaysSelectAsActiveMesh = !0,
o.emissiveColor = i,
o.alpha = e.transparency,
o.backFaceCulling = !1,
o.disableLighting = !0;
var a = new $n;
a.positions = n,
a.indices = [0, 1, 2, 0, 2, 3],
a.applyToMesh(r, !0),
e._lightHelperFrustumMeshes.push(r)
};
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 D(1,0,0), this._nearPlaneVertices),
s("far", new D(.3,0,0), this._farPlaneVertices),
s("right", new D(0,1,0), this._rightPlaneVertices),
s("left", new D(0,.3,0), this._leftPlaneVertices),
s("top", new D(0,0,1), this._topPlaneVertices),
s("bottom", new D(0,0,.3), this._bottomPlaneVertices),
this._nearLinesPoints[0] = I.Vector3[2],
this._nearLinesPoints[1] = I.Vector3[3],
this._nearLinesPoints[2] = I.Vector3[4],
this._nearLinesPoints[3] = I.Vector3[5],
this._nearLinesPoints[4] = I.Vector3[2],
this._farLinesPoints[0] = I.Vector3[6],
this._farLinesPoints[1] = I.Vector3[7],
this._farLinesPoints[2] = I.Vector3[8],
this._farLinesPoints[3] = I.Vector3[9],
this._farLinesPoints[4] = I.Vector3[6],
this._trLinesPoints[0] = I.Vector3[2],
this._trLinesPoints[1] = I.Vector3[6],
this._brLinesPoints[0] = I.Vector3[3],
this._brLinesPoints[1] = I.Vector3[7],
this._tlLinesPoints[0] = I.Vector3[4],
this._tlLinesPoints[1] = I.Vector3[8],
this._blLinesPoints[0] = I.Vector3[5],
this._blLinesPoints[1] = I.Vector3[9]
}
,
e.prototype._getInvertViewMatrix = function() {
return P.LookAtLHToRef(this._light.position, this._light.position.add(this._light.direction), x.UpReadOnly, this._inverseViewMatrix),
this._inverseViewMatrix.invertToRef(this._inverseViewMatrix),
this._inverseViewMatrix
}
,
e
}()
, hc = function() {
this.renderWidth = 512,
this.renderHeight = 256,
this.textureSize = 512,
this.deterministicLockstep = !1,
this.lockstepMaxSteps = 4
}
, dc = function(t) {
function i(i) {
void 0 === i && (i = new hc);
var n = t.call(this, null) || this;
vr.Instances.push(n),
void 0 === i.deterministicLockstep && (i.deterministicLockstep = !1),
void 0 === i.lockstepMaxSteps && (i.lockstepMaxSteps = 4),
n._options = i,
T.SetMatrixPrecision(!!i.useHighPrecisionMatrix),
n._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,
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
},
n._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,
_collectUbosUpdatedInFrame: !1
},
K.Log("Babylon.js v".concat(vr.Version, " - Null engine"));
var r = "undefined" != typeof self ? self : void 0 !== e.g ? e.g : window;
return "undefined" == typeof URL && (r.URL = {
createObjectURL: function() {},
revokeObjectURL: function() {}
}),
"undefined" == typeof Blob && (r.Blob = function() {}
),
n
}
return U(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 Bt;
return t.references = 1,
t
}
,
i.prototype.createIndexBuffer = function(e) {
var t = new Bt;
return t.references = 1,
t
}
,
i.prototype.clear = function(e, t, i, n) {
void 0 === n && (n = !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, n, r) {
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 && Gt.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, n, r, o, a) {
void 0 === t && (t = 0),
void 0 === n && (n = !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, n) {
return !0
}
,
i.prototype.setBool = function(e, t) {
return !0
}
,
i.prototype.setFloat4 = function(e, t, i, n, r) {
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, n) {}
,
i.prototype.drawElementsType = function(e, t, i, n) {}
,
i.prototype.drawArraysType = function(e, t, i, n) {}
,
i.prototype._createTexture = function() {
return {}
}
,
i.prototype._releaseTexture = function(e) {}
,
i.prototype.createTexture = function(e, t, i, n, r, o, s, l, c, u, h, d) {
void 0 === r && (r = 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 Lt(this,At.Url)
, f = String(e);
return p.url = f,
p.generateMipMaps = !t,
p.samplingMode = r,
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 && o(),
this._internalTexturesCache.push(p),
p
}
,
i.prototype._createHardwareRenderTargetWrapper = function(e, t, i) {
var n = new Fa(e,t,i,this);
return this._renderTargetWrapperCache.push(n),
n
}
,
i.prototype.createRenderTargetTexture = function(e, t) {
var i = this._createHardwareRenderTargetWrapper(!1, !1, e)
, n = {};
void 0 !== t && "object" == typeof t ? (n.generateMipMaps = t.generateMipMaps,
n.generateDepthBuffer = void 0 === t.generateDepthBuffer || t.generateDepthBuffer,
n.generateStencilBuffer = n.generateDepthBuffer && t.generateStencilBuffer,
n.type = void 0 === t.type ? a.TEXTURETYPE_UNSIGNED_INT : t.type,
n.samplingMode = void 0 === t.samplingMode ? a.TEXTURE_TRILINEAR_SAMPLINGMODE : t.samplingMode) : (n.generateMipMaps = t,
n.generateDepthBuffer = !0,
n.generateStencilBuffer = !1,
n.type = a.TEXTURETYPE_UNSIGNED_INT,
n.samplingMode = a.TEXTURE_TRILINEAR_SAMPLINGMODE);
var r = new Lt(this,At.RenderTarget)
, o = e.width || e
, s = e.height || e;
return i._generateDepthBuffer = n.generateDepthBuffer,
i._generateStencilBuffer = !!n.generateStencilBuffer,
r.baseWidth = o,
r.baseHeight = s,
r.width = o,
r.height = s,
r.isReady = !0,
r.samples = 1,
r.generateMipMaps = !!n.generateMipMaps,
r.samplingMode = n.samplingMode,
r.type = n.type,
this._internalTexturesCache.push(r),
i
}
,
i.prototype.updateTextureSamplingMode = function(e, t) {
t.samplingMode = e
}
,
i.prototype.createRawTexture = function(e, t, i, n, r, o, s, l, c, u) {
void 0 === l && (l = null),
void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT),
void 0 === u && (u = 0);
var h = new Lt(this,At.Raw);
return h.baseWidth = t,
h.baseHeight = i,
h.width = t,
h.height = i,
h.format = n,
h.generateMipMaps = r,
h.samplingMode = s,
h.invertY = o,
h._compression = l,
h.type = c,
this._doNotHandleContextLost || (h._bufferView = e),
h
}
,
i.prototype.updateRawTexture = function(e, t, i, n, r, o) {
void 0 === r && (r = null),
void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT),
e && (e._bufferView = t,
e.format = i,
e.invertY = n,
e._compression = r,
e.type = o)
}
,
i.prototype.bindFramebuffer = function(e, t, i, n, r) {
this._currentRenderTarget && this.unBindFramebuffer(this._currentRenderTarget),
this._currentRenderTarget = e,
this._currentFramebuffer = null,
this._cachedViewport && !r && this.setViewport(this._cachedViewport, i, n)
}
,
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 Bt;
return t.references = 1,
t.capacity = 1,
t
}
,
i.prototype.updateDynamicTexture = function(e, t, i, n, r) {
void 0 === n && (n = !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, n) {}
,
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() {}
,
i.prototype._uploadCompressedDataToTextureDirectly = function(e, t, i, n, r, o, a) {
void 0 === o && (o = 0),
void 0 === a && (a = 0)
}
,
i.prototype._uploadDataToTextureDirectly = function(e, t, i, n) {
void 0 === i && (i = 0),
void 0 === n && (n = 0)
}
,
i.prototype._uploadArrayBufferViewToTexture = function(e, t, i, n) {
void 0 === i && (i = 0),
void 0 === n && (n = 0)
}
,
i.prototype._uploadImageToTexture = function(e, t, i, n) {
void 0 === i && (i = 0),
void 0 === n && (n = 0)
}
,
i
}(vr);
Ht.prototype._debugPushGroup = function(e, t) {}
,
Ht.prototype._debugPopGroup = function(e) {}
,
Ht.prototype._debugInsertMarker = function(e, t) {}
,
Ht.prototype._debugFlushPendingCommands = function() {}
;
var pc = function() {
this._timeElapsedQueryEnded = !1
}
, fc = function() {
this.occlusionInternalRetryCounter = 0,
this.isOcclusionQueryInProgress = !1,
this.isOccluded = !1,
this.occlusionRetryCount = -1,
this.occlusionType = Sr.OCCLUSION_TYPE_NONE,
this.occlusionQueryAlgorithmType = Sr.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE,
this.forceRenderingWhenOccluded = !1
};
vr.prototype.createQuery = function() {
return this._gl.createQuery()
}
,
vr.prototype.deleteQuery = function(e) {
return this._gl.deleteQuery(e),
this
}
,
vr.prototype.isQueryResultAvailable = function(e) {
return this._gl.getQueryParameter(e, this._gl.QUERY_RESULT_AVAILABLE)
}
,
vr.prototype.getQueryResult = function(e) {
return this._gl.getQueryParameter(e, this._gl.QUERY_RESULT)
}
,
vr.prototype.beginOcclusionQuery = function(e, t) {
var i = this._getGlAlgorithmType(e);
return this._gl.beginQuery(i, t),
!0
}
,
vr.prototype.endOcclusionQuery = function(e) {
var t = this._getGlAlgorithmType(e);
return this._gl.endQuery(t),
this
}
,
vr.prototype._createTimeQuery = function() {
var e = this.getCaps().timerQuery;
return e.createQueryEXT ? e.createQueryEXT() : this.createQuery()
}
,
vr.prototype._deleteTimeQuery = function(e) {
var t = this.getCaps().timerQuery;
t.deleteQueryEXT ? t.deleteQueryEXT(e) : this.deleteQuery(e)
}
,
vr.prototype._getTimeQueryResult = function(e) {
var t = this.getCaps().timerQuery;
return t.getQueryObjectEXT ? t.getQueryObjectEXT(e, t.QUERY_RESULT_EXT) : this.getQueryResult(e)
}
,
vr.prototype._getTimeQueryAvailability = function(e) {
var t = this.getCaps().timerQuery;
return t.getQueryObjectEXT ? t.getQueryObjectEXT(e, t.QUERY_RESULT_AVAILABLE_EXT) : this.isQueryResultAvailable(e)
}
,
vr.prototype.startTimeQuery = function() {
var e = this.getCaps()
, t = e.timerQuery;
if (!t)
return null;
var i = new pc;
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
}
,
vr.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),
e._timeElapsedQueryEnded = !0
}
var n = this._gl.getParameter(i.GPU_DISJOINT_EXT)
, r = !1;
if (e._endTimeQuery ? r = this._getTimeQueryAvailability(e._endTimeQuery) : e._timeElapsedQuery && (r = this._getTimeQueryAvailability(e._timeElapsedQuery)),
r && !n) {
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,
this._currentNonTimestampToken = null
}
return o
}
return -1
}
,
vr.prototype._captureGPUFrameTime = !1,
vr.prototype._gpuFrameTime = new un,
vr.prototype.getGPUFrameTimeCounter = function() {
return this._gpuFrameTime
}
,
vr.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))
}
,
vr.prototype._getGlAlgorithmType = function(e) {
return e === Sr.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED
}
,
Object.defineProperty(Sr.prototype, "isOcclusionQueryInProgress", {
get: function() {
return this._occlusionDataStorage.isOcclusionQueryInProgress
},
set: function(e) {
this._occlusionDataStorage.isOcclusionQueryInProgress = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(Sr.prototype, "_occlusionDataStorage", {
get: function() {
return this.__occlusionDataStorage || (this.__occlusionDataStorage = new fc),
this.__occlusionDataStorage
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(Sr.prototype, "isOccluded", {
get: function() {
return this._occlusionDataStorage.isOccluded
},
set: function(e) {
this._occlusionDataStorage.isOccluded = e
},
enumerable: !0,
configurable: !0
}),
Object.defineProperty(Sr.prototype, "occlusionQueryAlgorithmType", {
get: function() {
return this._occlusionDataStorage.occlusionQueryAlgorithmType
},
set: function(e) {
this._occlusionDataStorage.occlusionQueryAlgorithmType = e
},
enumerable: !0,
configurable: !0
}),
Object.defineProperty(Sr.prototype, "occlusionType", {
get: function() {
return this._occlusionDataStorage.occlusionType
},
set: function(e) {
this._occlusionDataStorage.occlusionType = e
},
enumerable: !0,
configurable: !0
}),
Object.defineProperty(Sr.prototype, "occlusionRetryCount", {
get: function() {
return this._occlusionDataStorage.occlusionRetryCount
},
set: function(e) {
this._occlusionDataStorage.occlusionRetryCount = e
},
enumerable: !0,
configurable: !0
}),
Object.defineProperty(Sr.prototype, "forceRenderingWhenOccluded", {
get: function() {
return this._occlusionDataStorage.forceRenderingWhenOccluded
},
set: function(e) {
this._occlusionDataStorage.forceRenderingWhenOccluded = e
},
enumerable: !0,
configurable: !0
}),
Sr.prototype._checkOcclusionQuery = function() {
var e = this._occlusionDataStorage;
if (e.occlusionType === Sr.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 !== Sr.OCCLUSION_TYPE_OPTIMISTIC && e.isOccluded;
e.isOcclusionQueryInProgress = !1,
e.occlusionInternalRetryCounter = 0,
e.isOccluded = e.occlusionType !== Sr.OCCLUSION_TYPE_OPTIMISTIC && e.isOccluded
}
var n = this.getScene();
if (n.getBoundingBoxRenderer) {
var r = n.getBoundingBoxRenderer();
null === this._occlusionQuery && (this._occlusionQuery = t.createQuery()),
t.beginOcclusionQuery(e.occlusionQueryAlgorithmType, this._occlusionQuery) && (r.renderOcclusionBoundingBox(this),
t.endOcclusionQuery(e.occlusionQueryAlgorithmType),
this._occlusionDataStorage.isOcclusionQueryInProgress = !0)
}
return e.isOccluded
}
;
var _c = !0;
vr.prototype.createTransformFeedback = function() {
return this._gl.createTransformFeedback()
}
,
vr.prototype.deleteTransformFeedback = function(e) {
this._gl.deleteTransformFeedback(e)
}
,
vr.prototype.bindTransformFeedback = function(e) {
this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, e)
}
,
vr.prototype.beginTransformFeedback = function(e) {
void 0 === e && (e = !0),
this._gl.beginTransformFeedback(e ? this._gl.POINTS : this._gl.TRIANGLES)
}
,
vr.prototype.endTransformFeedback = function() {
this._gl.endTransformFeedback()
}
,
vr.prototype.setTranformFeedbackVaryings = function(e, t) {
this._gl.transformFeedbackVaryings(e, t, this._gl.INTERLEAVED_ATTRIBS)
}
,
vr.prototype.bindTransformFeedbackBuffer = function(e) {
this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, e ? e.underlyingResource : null)
}
,
Ht.prototype.createExternalTexture = function(e) {
return null
}
,
Ht.prototype.setExternalTexture = function(e, t) {
throw new Error("setExternalTexture: This engine does not support external textures!")
}
,
Ht.prototype.updateVideoTexture = function(e, t, i) {
if (e && !e._isDisabled) {
var n = 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, this._gl.RGBA, this._gl.RGBA, 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, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, t);
else {
if (!e._workingCanvas) {
e._workingCanvas = this.createCanvas(e.width, e.height);
var r = e._workingCanvas.getContext("2d");
if (!r)
throw new Error("Unable to get 2d context");
e._workingContext = r,
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, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, e._workingCanvas)
}
e.generateMipMaps && this._gl.generateMipmap(this._gl.TEXTURE_2D),
n || this._bindTextureDirectly(this._gl.TEXTURE_2D, null),
e.isReady = !0
} catch (t) {
e._isDisabled = !0
}
}
}
,
Ht.prototype.restoreSingleAttachment = function() {
var e = this._gl;
this.bindAttachments([e.BACK])
}
,
Ht.prototype.restoreSingleAttachmentForRenderTarget = function() {
var e = this._gl;
this.bindAttachments([e.COLOR_ATTACHMENT0])
}
,
Ht.prototype.buildTextureLayout = function(e) {
for (var t = this._gl, i = [], n = 0; n < e.length; n++)
e[n] ? i.push(t["COLOR_ATTACHMENT" + n]) : i.push(t.NONE);
return i
}
,
Ht.prototype.bindAttachments = function(e) {
this._gl.drawBuffers(e)
}
,
Ht.prototype.unBindMultiColorAttachmentFramebuffer = function(e, t, i) {
void 0 === t && (t = !1),
this._currentRenderTarget = null;
var n = this._gl
, r = e._attachments
, o = r.length;
if (e._MSAAFramebuffer) {
n.bindFramebuffer(n.READ_FRAMEBUFFER, e._MSAAFramebuffer),
n.bindFramebuffer(n.DRAW_FRAMEBUFFER, e._framebuffer);
for (var a = 0; a < o; a++) {
for (var s = e.textures[a], l = 0; l < o; l++)
r[l] = n.NONE;
r[a] = n[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + a : "COLOR_ATTACHMENT" + a + "_WEBGL"],
n.readBuffer(r[a]),
n.drawBuffers(r),
n.blitFramebuffer(0, 0, s.width, s.height, 0, 0, s.width, s.height, n.COLOR_BUFFER_BIT, n.NEAREST)
}
for (a = 0; a < o; a++)
r[a] = n[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + a : "COLOR_ATTACHMENT" + a + "_WEBGL"];
n.drawBuffers(r)
}
for (a = 0; a < o; a++)
!(s = e.textures[a]).generateMipMaps || t || s.isCube || (this._bindTextureDirectly(n.TEXTURE_2D, s, !0),
n.generateMipmap(n.TEXTURE_2D),
this._bindTextureDirectly(n.TEXTURE_2D, null));
i && (e._MSAAFramebuffer && this._bindUnboundFramebuffer(e._framebuffer),
i()),
this._bindUnboundFramebuffer(null)
}
,
Ht.prototype.createMultipleRenderTarget = function(e, t, i) {
void 0 === i && (i = !0);
var n = !1
, r = !0
, o = !1
, s = !1
, l = a.TEXTUREFORMAT_DEPTH16
, c = 1
, u = a.TEXTURETYPE_UNSIGNED_INT
, h = a.TEXTURE_TRILINEAR_SAMPLINGMODE
, d = new Array
, p = new Array
, f = this._createHardwareRenderTargetWrapper(!0, !1, e);
void 0 !== t && (n = void 0 !== t.generateMipMaps && t.generateMipMaps,
r = void 0 === t.generateDepthBuffer || t.generateDepthBuffer,
o = void 0 !== t.generateStencilBuffer && t.generateStencilBuffer,
s = void 0 !== t.generateDepthTexture && t.generateDepthTexture,
c = t.textureCount || 1,
t.types && (d = t.types),
t.samplingModes && (p = t.samplingModes),
this.webGLVersion > 1 && (t.depthTextureFormat === a.TEXTUREFORMAT_DEPTH24_STENCIL8 || t.depthTextureFormat === a.TEXTUREFORMAT_DEPTH24 || t.depthTextureFormat === a.TEXTUREFORMAT_DEPTH32_FLOAT) && (l = t.depthTextureFormat));
var _ = this._gl
, m = _.createFramebuffer();
this._bindUnboundFramebuffer(m);
var g = e.width || e
, v = e.height || e
, y = []
, b = []
, T = this.webGLVersion > 1 && s && t.depthTextureFormat === a.TEXTUREFORMAT_DEPTH24_STENCIL8
, E = this._setupFramebufferDepthAttachments(!T && o, !s && r, g, v);
f._framebuffer = m,
f._depthStencilBuffer = E,
f._generateDepthBuffer = !s && r,
f._generateStencilBuffer = !T && o,
f._attachments = b;
for (var S = 0; S < c; S++) {
var A = p[S] || h
, x = d[S] || u;
(x !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (x !== a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (A = a.TEXTURE_NEAREST_SAMPLINGMODE);
var R = this._getSamplingParameters(A, n);
x !== a.TEXTURETYPE_FLOAT || this._caps.textureFloat || (x = a.TEXTURETYPE_UNSIGNED_INT,
K.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));
var C = new Lt(this,At.MultiRenderTarget)
, P = _[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + S : "COLOR_ATTACHMENT" + S + "_WEBGL"];
y.push(C),
b.push(P),
_.activeTexture(_["TEXTURE" + S]),
_.bindTexture(_.TEXTURE_2D, C._hardwareTexture.underlyingResource),
_.texParameteri(_.TEXTURE_2D, _.TEXTURE_MAG_FILTER, R.mag),
_.texParameteri(_.TEXTURE_2D, _.TEXTURE_MIN_FILTER, R.min),
_.texParameteri(_.TEXTURE_2D, _.TEXTURE_WRAP_S, _.CLAMP_TO_EDGE),
_.texParameteri(_.TEXTURE_2D, _.TEXTURE_WRAP_T, _.CLAMP_TO_EDGE),
_.texImage2D(_.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(x), g, v, 0, _.RGBA, this._getWebGLTextureType(x), null),
_.framebufferTexture2D(_.DRAW_FRAMEBUFFER, P, _.TEXTURE_2D, C._hardwareTexture.underlyingResource, 0),
n && this._gl.generateMipmap(this._gl.TEXTURE_2D),
this._bindTextureDirectly(_.TEXTURE_2D, null),
C.baseWidth = g,
C.baseHeight = v,
C.width = g,
C.height = v,
C.isReady = !0,
C.samples = 1,
C.generateMipMaps = n,
C.samplingMode = A,
C.type = x,
this._internalTexturesCache.push(C)
}
if (s && this._caps.depthTextureExtension) {
var M = new Lt(this,At.Depth)
, I = a.TEXTURETYPE_UNSIGNED_SHORT
, O = _.DEPTH_COMPONENT16
, D = _.DEPTH_COMPONENT
, N = _.UNSIGNED_SHORT
, L = _.DEPTH_ATTACHMENT;
this.webGLVersion < 2 ? O = _.DEPTH_COMPONENT : l === a.TEXTUREFORMAT_DEPTH32_FLOAT ? (I = a.TEXTURETYPE_FLOAT,
N = _.FLOAT,
O = _.DEPTH_COMPONENT32F) : l === a.TEXTUREFORMAT_DEPTH24 ? (I = a.TEXTURETYPE_UNSIGNED_INT,
N = _.UNSIGNED_INT,
O = _.DEPTH_COMPONENT24,
L = _.DEPTH_ATTACHMENT) : l === a.TEXTUREFORMAT_DEPTH24_STENCIL8 && (I = a.TEXTURETYPE_UNSIGNED_INT_24_8,
N = _.UNSIGNED_INT_24_8,
O = _.DEPTH24_STENCIL8,
D = _.DEPTH_STENCIL,
L = _.DEPTH_STENCIL_ATTACHMENT),
_.activeTexture(_.TEXTURE0),
_.bindTexture(_.TEXTURE_2D, M._hardwareTexture.underlyingResource),
_.texParameteri(_.TEXTURE_2D, _.TEXTURE_MAG_FILTER, _.NEAREST),
_.texParameteri(_.TEXTURE_2D, _.TEXTURE_MIN_FILTER, _.NEAREST),
_.texParameteri(_.TEXTURE_2D, _.TEXTURE_WRAP_S, _.CLAMP_TO_EDGE),
_.texParameteri(_.TEXTURE_2D, _.TEXTURE_WRAP_T, _.CLAMP_TO_EDGE),
_.texImage2D(_.TEXTURE_2D, 0, O, g, v, 0, D, N, null),
_.framebufferTexture2D(_.FRAMEBUFFER, L, _.TEXTURE_2D, M._hardwareTexture.underlyingResource, 0),
M.baseWidth = g,
M.baseHeight = v,
M.width = g,
M.height = v,
M.isReady = !0,
M.samples = 1,
M.generateMipMaps = n,
M.samplingMode = a.TEXTURE_NEAREST_SAMPLINGMODE,
M.format = l,
M.type = I,
y.push(M),
this._internalTexturesCache.push(M)
}
return f.setTextures(y),
i && _.drawBuffers(b),
this._bindUnboundFramebuffer(null),
this.resetTextureCache(),
f
}
,
Ht.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 n = e._attachments.length;
if (0 === n)
return 1;
var r = this._gl;
t = Math.min(t, this.getCaps().maxMSAASamples),
e._depthStencilBuffer && (r.deleteRenderbuffer(e._depthStencilBuffer),
e._depthStencilBuffer = null),
e._MSAAFramebuffer && (r.deleteFramebuffer(e._MSAAFramebuffer),
e._MSAAFramebuffer = null);
for (var o = 0; o < n; o++)
(null == (c = e.textures[o]._hardwareTexture) ? void 0 : c._MSAARenderBuffer) && (r.deleteRenderbuffer(c._MSAARenderBuffer),
c._MSAARenderBuffer = null);
if (t > 1 && r.renderbufferStorageMultisample) {
var a = r.createFramebuffer();
if (!a)
throw new Error("Unable to create multi sampled framebuffer");
e._MSAAFramebuffer = a,
this._bindUnboundFramebuffer(a);
var s = [];
for (o = 0; o < n; o++) {
var l = e.textures[o]
, c = l._hardwareTexture
, u = r[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + o : "COLOR_ATTACHMENT" + o + "_WEBGL"]
, h = this._createRenderBuffer(l.width, l.height, t, -1, this._getRGBAMultiSampleBufferFormat(l.type), u);
if (!h)
throw new Error("Unable to create multi sampled framebuffer");
c._MSAARenderBuffer = h,
l.samples = t,
s.push(u)
}
i && r.drawBuffers(s)
} else
this._bindUnboundFramebuffer(e._framebuffer);
return e._depthStencilBuffer = this._setupFramebufferDepthAttachments(e._generateStencilBuffer, e._generateDepthBuffer, e.texture.width, e.texture.height, t),
this._bindUnboundFramebuffer(null),
t
}
,
Ht.prototype._createDepthStencilCubeTexture = function(e, t, i) {
var n = new Lt(this,At.DepthStencil);
if (n.isCube = !0,
1 === this.webGLVersion)
return K.Error("Depth cube texture is not supported by WebGL 1."),
n;
var r = V({
bilinearFiltering: !1,
comparisonFunction: 0,
generateStencil: !1
}, t)
, o = this._gl;
this._bindTextureDirectly(o.TEXTURE_CUBE_MAP, n, !0),
this._setupDepthStencilTexture(n, e, r.generateStencil, r.bilinearFiltering, r.comparisonFunction),
i._depthStencilTexture = n,
i._depthStencilTextureWithStencil = r.generateStencil;
for (var a = 0; a < 6; a++)
r.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(n),
n
}
,
Ht.prototype._partialLoadFile = function(e, t, i, n, r) {
void 0 === r && (r = null),
this._loadFile(e, (function(e) {
i[t] = e,
i._internalCount++,
6 === i._internalCount && n(i)
}
), void 0, void 0, !0, (function(e, t) {
r && e && r(e.status + " " + e.statusText, t)
}
))
}
,
Ht.prototype._cascadeLoadFiles = function(e, t, i, n) {
void 0 === n && (n = null);
var r = [];
r._internalCount = 0;
for (var o = 0; o < 6; o++)
this._partialLoadFile(i[o], o, r, t, n)
}
,
Ht.prototype._cascadeLoadImgs = function(e, t, i, n, r, o) {
void 0 === r && (r = null);
var a = [];
a._internalCount = 0;
for (var s = 0; s < 6; s++)
this._partialLoadImg(n[s], s, a, e, t, i, r, o)
}
,
Ht.prototype._partialLoadImg = function(e, t, i, n, r, o, a, s) {
void 0 === a && (a = null);
var l = fi();
$t(e, (function(e) {
i[t] = e,
i._internalCount++,
n && n._removePendingData(l),
6 === i._internalCount && o && o(r, i)
}
), (function(e, t) {
n && n._removePendingData(l),
a && a(e, t)
}
), n ? n.offlineProvider : null, s),
n && n._addPendingData(l)
}
,
Ht.prototype._setCubeMapTextureParams = function(e, t, i) {
var n = this._gl;
n.texParameteri(n.TEXTURE_CUBE_MAP, n.TEXTURE_MAG_FILTER, n.LINEAR),
n.texParameteri(n.TEXTURE_CUBE_MAP, n.TEXTURE_MIN_FILTER, t ? n.LINEAR_MIPMAP_LINEAR : n.LINEAR),
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),
e.samplingMode = t ? a.TEXTURE_TRILINEAR_SAMPLINGMODE : a.TEXTURE_LINEAR_LINEAR,
t && this.getCaps().textureMaxLevel && void 0 !== i && i > 0 && (n.texParameteri(n.TEXTURE_CUBE_MAP, n.TEXTURE_MAX_LEVEL, i),
e._maxLodLevel = i),
this._bindTextureDirectly(n.TEXTURE_CUBE_MAP, null)
}
,
Ht.prototype.createCubeTextureBase = function(e, t, i, n, r, o, a, s, l, c, u, h, d, p, f) {
var _ = this;
void 0 === r && (r = 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 Lt(this,At.Cube);
m.isCube = !0,
m.url = e,
m.generateMipMaps = !n,
m._lodGenerationScale = c,
m._lodGenerationOffset = u,
m._useSRGBBuffer = !!f && this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || this.isWebGPU || !!n),
this._doNotHandleContextLost || (m._extension = s,
m._files = i);
var g = e;
this._transformTextureUrl && !h && (e = this._transformTextureUrl(e));
for (var v = e.lastIndexOf("."), y = s || (v > -1 ? e.substring(v).toLowerCase() : ""), b = null, T = 0, E = Ht._TextureLoaders; T < E.length; T++) {
var S = E[T];
if (S.canLoad(y)) {
b = S;
break
}
}
if (b) {
var A = function(e) {
d && d(m, e),
b.loadCubeData(e, m, l, r, o)
};
i && 6 === i.length ? b.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.") : K.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) : (K.Warn("Failed to load ".concat(e, ", falling back to the ").concat(g)),
_.createCubeTextureBase(g, t, i, !!n, r, 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
}
,
Ht.prototype.createCubeTexture = function(e, t, i, n, r, o, a, s, l, c, u, h, d, p) {
var f = this;
void 0 === r && (r = 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, !!n, r, o, a, s, l, c, u, h, (function(e) {
return f._bindTextureDirectly(_.TEXTURE_CUBE_MAP, e, !0)
}
), (function(e, t) {
var i = f.needPOTTextures ? Ht.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 ? _.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 K.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]);
n || _.generateMipmap(_.TEXTURE_CUBE_MAP),
f._setCubeMapTextureParams(e, !n),
e.width = i,
e.height = o,
e.isReady = !0,
a && (e.format = a),
e.onLoadedObservable.notifyObservers(e),
e.onLoadedObservable.clear(),
r && r()
}
), !!p)
}
,
Ht.prototype.setTextureSampler = function(e, t) {
throw new Error("setTextureSampler: This engine does not support separate texture sampler objects!")
}
;
var mc = function() {};
function gc(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("?")
, n = i > -1 ? e.substring(i, e.length) : "";
return (t > -1 ? e.substring(0, t) : e) + this._textureFormatInUse + n
}
Object.defineProperty(vr.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))
}
}),
vr.prototype.getInputElement = function() {
return this.inputElement || this.getRenderingCanvas()
}
,
vr.prototype.registerView = function(e, t, i) {
var n = this;
this.views || (this.views = []);
for (var r = 0, o = this.views; r < o.length; r++) {
var a = o[r];
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
};
return this.views.push(l),
t && t.onDisposeObservable.add((function() {
n.unRegisterView(e)
}
)),
l
}
,
vr.prototype.unRegisterView = function(e) {
if (!this.views)
return this;
for (var t = 0, i = this.views; t < i.length; t++) {
var n = i[t];
if (n.target === e) {
var r = this.views.indexOf(n);
-1 !== r && this.views.splice(r, 1);
break
}
}
return this
}
,
vr.prototype._renderViews = function() {
if (!this.views)
return !1;
var e = this.getRenderingCanvas();
if (!e)
return !1;
for (var t = 0, i = this.views; t < i.length; t++) {
var n = i[t];
if (n.enabled) {
var r = n.target
, o = r.getContext("2d");
if (o) {
var a = n.camera
, s = null
, l = null;
if (a) {
if ((l = a.getScene()).activeCameras && l.activeCameras.length)
continue;
this.activeView = n,
s = l.activeCamera,
l.activeCamera = a
}
if (n.customResize)
n.customResize(r);
else {
var c = Math.floor(r.clientWidth / this._hardwareScalingLevel)
, u = Math.floor(r.clientHeight / this._hardwareScalingLevel)
, h = c !== r.width || e.width !== r.width || u !== r.height || e.height !== r.height;
r.clientWidth && r.clientHeight && h && (r.width = c,
r.height = u,
this.setSize(c, u))
}
if (!e.width || !e.height)
return !1;
this._renderFrame(),
this.flushFramebuffer(),
n.clearBeforeCopy && o.clearRect(0, 0, e.width, e.height),
o.drawImage(e, 0, 0),
s && l && (l.activeCamera = s)
}
}
}
return this.activeView = null,
!0
}
,
Ht.prototype.createStorageBuffer = function(e, t) {
throw new Error("createStorageBuffer: Unsupported method in this engine!")
}
,
Ht.prototype.updateStorageBuffer = function(e, t, i, n) {}
,
Ht.prototype.readFromStorageBuffer = function(e, t, i, n) {
throw new Error("readFromStorageBuffer: Unsupported method in this engine!")
}
,
Ht.prototype.setStorageBuffer = function(e, t) {
throw new Error("setStorageBuffer: Unsupported method in this engine!")
}
,
Object.defineProperty(vr.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(vr.prototype, "textureFormatInUse", {
get: function() {
return this._textureFormatInUse || null
},
enumerable: !0,
configurable: !0
}),
vr.prototype.setCompressedTextureExclusions = function(e) {
this._excludedCompressedTextures = e
}
,
vr.prototype.setTextureFormatToUse = function(e) {
for (var t = this.texturesSupported, i = 0, n = t.length; i < n; i++)
for (var r = 0, o = e.length; r < o; r++)
if (t[i] === e[r].toLowerCase())
return this._transformTextureUrl = gc.bind(this),
this._textureFormatInUse = t[i];
return this._textureFormatInUse = "",
this._transformTextureUrl = null,
null
}
;
var vc, yc, bc = 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
}(), Tc = function() {
function e(e, t) {
void 0 === e && (e = x.Zero()),
void 0 === t && (t = x.Up()),
this.position = e,
this.normal = t
}
return e.prototype.clone = function() {
return new e(this.position.clone(),this.normal.clone())
}
,
e
}(), Ec = function() {
function e(e, t, i) {
void 0 === e && (e = x.Zero()),
void 0 === t && (t = x.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
}(), Sc = [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))], Ac = [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
}
], xc = function(e, t) {
return Sc[e] * Ac[e](t)
}, Rc = [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], Cc = function() {
function e() {
this.preScaled = !1,
this.l00 = x.Zero(),
this.l1_1 = x.Zero(),
this.l10 = x.Zero(),
this.l11 = x.Zero(),
this.l2_2 = x.Zero(),
this.l2_1 = x.Zero(),
this.l20 = x.Zero(),
this.l21 = x.Zero(),
this.l22 = x.Zero()
}
return e.prototype.addLight = function(e, t, i) {
I.Vector3[0].set(t.r, t.g, t.b);
var n = I.Vector3[0]
, r = I.Vector3[1];
n.scaleToRef(i, r),
r.scaleToRef(xc(0, e), I.Vector3[2]),
this.l00.addInPlace(I.Vector3[2]),
r.scaleToRef(xc(1, e), I.Vector3[2]),
this.l1_1.addInPlace(I.Vector3[2]),
r.scaleToRef(xc(2, e), I.Vector3[2]),
this.l10.addInPlace(I.Vector3[2]),
r.scaleToRef(xc(3, e), I.Vector3[2]),
this.l11.addInPlace(I.Vector3[2]),
r.scaleToRef(xc(4, e), I.Vector3[2]),
this.l2_2.addInPlace(I.Vector3[2]),
r.scaleToRef(xc(5, e), I.Vector3[2]),
this.l2_1.addInPlace(I.Vector3[2]),
r.scaleToRef(xc(6, e), I.Vector3[2]),
this.l20.addInPlace(I.Vector3[2]),
r.scaleToRef(xc(7, e), I.Vector3[2]),
this.l21.addInPlace(I.Vector3[2]),
r.scaleToRef(xc(8, e), I.Vector3[2]),
this.l22.addInPlace(I.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(Rc[0]),
this.l1_1.scaleInPlace(Rc[1]),
this.l10.scaleInPlace(Rc[2]),
this.l11.scaleInPlace(Rc[3]),
this.l2_2.scaleInPlace(Rc[4]),
this.l2_1.scaleInPlace(Rc[5]),
this.l20.scaleInPlace(Rc[6]),
this.l21.scaleInPlace(Rc[7]),
this.l22.scaleInPlace(Rc[8])
}
,
e.prototype.convertIrradianceToLambertianRadiance = function() {
this.scaleInPlace(1 / Math.PI)
}
,
e.prototype.preScaleForRendering = function() {
this.preScaled = !0,
this.l00.scaleInPlace(Sc[0]),
this.l1_1.scaleInPlace(Sc[1]),
this.l10.scaleInPlace(Sc[2]),
this.l11.scaleInPlace(Sc[3]),
this.l2_2.scaleInPlace(Sc[4]),
this.l2_1.scaleInPlace(Sc[5]),
this.l20.scaleInPlace(Sc[6]),
this.l21.scaleInPlace(Sc[7]),
this.l22.scaleInPlace(Sc[8])
}
,
e.prototype.updateFromArray = function(e) {
return x.FromArrayToRef(e[0], 0, this.l00),
x.FromArrayToRef(e[1], 0, this.l1_1),
x.FromArrayToRef(e[2], 0, this.l10),
x.FromArrayToRef(e[3], 0, this.l11),
x.FromArrayToRef(e[4], 0, this.l2_2),
x.FromArrayToRef(e[5], 0, this.l2_1),
x.FromArrayToRef(e[6], 0, this.l20),
x.FromArrayToRef(e[7], 0, this.l21),
x.FromArrayToRef(e[8], 0, this.l22),
this
}
,
e.prototype.updateFromFloatsArray = function(e) {
return x.FromFloatsToRef(e[0], e[1], e[2], this.l00),
x.FromFloatsToRef(e[3], e[4], e[5], this.l1_1),
x.FromFloatsToRef(e[6], e[7], e[8], this.l10),
x.FromFloatsToRef(e[9], e[10], e[11], this.l11),
x.FromFloatsToRef(e[12], e[13], e[14], this.l2_2),
x.FromFloatsToRef(e[15], e[16], e[17], this.l2_1),
x.FromFloatsToRef(e[18], e[19], e[20], this.l20),
x.FromFloatsToRef(e[21], e[22], e[23], this.l21),
x.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
}(), Pc = function() {
function e() {
this.x = x.Zero(),
this.y = x.Zero(),
this.z = x.Zero(),
this.xx = x.Zero(),
this.yy = x.Zero(),
this.zz = x.Zero(),
this.xy = x.Zero(),
this.yz = x.Zero(),
this.zx = x.Zero()
}
return Object.defineProperty(e.prototype, "preScaledHarmonics", {
get: function() {
return this._harmonics || (this._harmonics = Cc.FromPolynomial(this)),
this._harmonics.preScaled || this._harmonics.preScaleForRendering(),
this._harmonics
},
enumerable: !1,
configurable: !0
}),
e.prototype.addAmbient = function(e) {
I.Vector3[0].copyFromFloats(e.r, e.g, e.b);
var t = I.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),
I.Vector3[0].copyFrom(e.l20).scaleInPlace(.247708),
I.Vector3[1].copyFrom(e.l22).scaleInPlace(.429043),
this.xx.scaleInPlace(.886277).subtractInPlace(I.Vector3[0]).addInPlace(I.Vector3[1]),
this.yy.copyFrom(e.l00),
this.yy.scaleInPlace(.886277).subtractInPlace(I.Vector3[0]).subtractInPlace(I.Vector3[1]),
this.zz.copyFrom(e.l00),
I.Vector3[0].copyFrom(e.l20).scaleInPlace(.495417),
this.zz.scaleInPlace(.886277).addInPlace(I.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 x.FromArrayToRef(t[0], 0, i.x),
x.FromArrayToRef(t[1], 0, i.y),
x.FromArrayToRef(t[2], 0, i.z),
x.FromArrayToRef(t[3], 0, i.xx),
x.FromArrayToRef(t[4], 0, i.yy),
x.FromArrayToRef(t[5], 0, i.zz),
x.FromArrayToRef(t[6], 0, i.yz),
x.FromArrayToRef(t[7], 0, i.zx),
x.FromArrayToRef(t[8], 0, i.xy),
i
}
,
e
}();
function Mc(e, t, i, n) {
void 0 === n && (n = !0);
var r = e.getScene()
, o = r.getEngine()
, s = new ns("resized" + e.name,{
width: t,
height: i
},r,!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 = io.CLAMP_ADDRESSMODE,
e.wrapV = io.CLAMP_ADDRESSMODE;
var l = new Ua("pass",1,null,n ? io.BILINEAR_SAMPLINGMODE : io.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 && (r.postProcessManager.directRender([l], t),
o.unBindFramebuffer(t),
s.disposeFramebufferObjects(),
l.dispose(),
s.getInternalTexture().isReady = !0)
}
)),
s
}
function Ic(e, t, i, n, r, o) {
var s = t.getEngine();
return t.isReady = !1,
r = null != r ? r : t.samplingMode,
n = null != n ? n : t.type,
o = null != o ? o : t.format,
-1 === n && (n = a.TEXTURETYPE_UNSIGNED_BYTE),
new Promise((function(l) {
var c = new Ba("postprocess",e,null,null,1,null,r,s,!1,void 0,n,void 0,null,!1,o);
c.externalTextureSamplerBinding = !0;
var u = s.createRenderTargetTexture({
width: t.width,
height: t.height
}, {
generateDepthBuffer: !1,
generateMipMaps: !1,
generateStencilBuffer: !1,
samplingMode: r,
type: n,
format: o
});
c.getEffect().executeWhenCompiled((function() {
c.onApply = function(e) {
e._bindTexture("textureSampler", t),
e.setFloat2("scale", 1, 1)
}
,
i.postProcessManager.directRender([c], u, !0),
s.restoreDefaultFramebuffer(),
s._releaseTexture(t),
c && c.dispose(),
u._swapAndDie(t),
t.type = n,
t.format = a.TEXTUREFORMAT_RGBA,
t.isReady = !0,
l(t)
}
))
}
))
}
function Oc(e) {
vc || (vc = new Float32Array(1),
yc = new Int32Array(vc.buffer)),
vc[0] = e;
var t = yc[0]
, i = t >> 16 & 32768
, n = t >> 12 & 2047
, r = t >> 23 & 255;
return r < 103 ? i : r > 142 ? (i |= 31744,
i |= (255 == r ? 0 : 1) && 8388607 & t) : r < 113 ? i |= ((n |= 2048) >> 114 - r) + (n >> 113 - r & 1) : (i |= r - 112 << 10 | n >> 1,
i += 1 & n)
}
function Dc(e) {
var t = (32768 & e) >> 15
, i = (31744 & e) >> 10
, n = 1023 & e;
return 0 === i ? (t ? -1 : 1) * Math.pow(2, -14) * (n / Math.pow(2, 10)) : 31 == i ? n ? NaN : 1 / 0 * (t ? -1 : 1) : (t ? -1 : 1) * Math.pow(2, i - 15) * (1 + n / Math.pow(2, 10))
}
Pt.ShadersStore.rgbdDecodePixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{\ngl_FragColor=vec4(fromRGBD(texture2D(textureSampler,vUV)),1.0);\n}";
var Nc = {
CreateResizedCopy: Mc,
ApplyPostProcess: Ic,
ToHalfFloat: Oc,
FromHalfFloat: Dc
}
, Lc = function() {
function e() {}
return e.ExpandRGBDTexture = function(e) {
var t = e._texture;
if (t && e.isRGBD) {
var i = t.getEngine()
, n = i.getCaps()
, r = t.isReady
, o = !1;
n.textureHalfFloatRender && n.textureHalfFloatLinearFiltering ? (o = !0,
t.type = a.TEXTURETYPE_HALF_FLOAT) : n.textureFloatRender && n.textureFloatLinearFiltering && (o = !0,
t.type = a.TEXTURETYPE_FLOAT),
o && (t.isReady = !1,
t._isRGBD = !1,
t.invertY = !1);
var s = function() {
if (o) {
var n = new Ba("rgbdDecode","rgbdDecode",null,null,1,null,a.TEXTURE_TRILINEAR_SAMPLINGMODE,i,!1,void 0,t.type,void 0,null,!1);
n.externalTextureSamplerBinding = !0;
var r = i.createRenderTargetTexture(t.width, {
generateDepthBuffer: !1,
generateMipMaps: !1,
generateStencilBuffer: !1,
samplingMode: t.samplingMode,
type: t.type,
format: a.TEXTUREFORMAT_RGBA
});
n.getEffect().executeWhenCompiled((function() {
n.onApply = function(e) {
e._bindTexture("textureSampler", t),
e.setFloat2("scale", 1, 1)
}
,
e.getScene().postProcessManager.directRender([n], r, !0),
i.restoreDefaultFramebuffer(),
i._releaseTexture(t),
n && n.dispose(),
r._swapAndDie(t),
t.isReady = !0
}
))
}
};
r ? s() : e.onLoadObservable.addOnce(s)
}
}
,
e.EncodeTextureToRGBD = function(e, t, i) {
return void 0 === i && (i = a.TEXTURETYPE_UNSIGNED_BYTE),
Ic("rgbdEncode", e, t, i, a.TEXTURE_NEAREST_SAMPLINGMODE, a.TEXTUREFORMAT_RGBA)
}
,
e
}()
, Fc = function(e, t, i, n) {
this.name = e,
this.worldAxisForNormal = t,
this.worldAxisForFileX = i,
this.worldAxisForFileY = n
}
, wc = 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 n, r, o = e.getSize().width, s = e.readPixels(0, void 0, void 0, !1), l = e.readPixels(1, void 0, void 0, !1);
e.isRenderTarget ? (n = e.readPixels(3, void 0, void 0, !1),
r = e.readPixels(2, void 0, void 0, !1)) : (n = e.readPixels(2, void 0, void 0, !1),
r = 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, n, r, c, u]).then((function(t) {
var n = t[0]
, r = t[1]
, a = t[2]
, s = t[3]
, l = t[4]
, c = t[5]
, u = {
size: o,
right: r,
left: n,
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 Cc, i = 0, n = 2 / e.size, r = n, o = .5 * n, s = o - 1, l = 0; l < 6; l++)
for (var c = this._FileFaces[l], u = e[c.name], h = s, p = 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(h)).add(c.worldAxisForNormal);
v.normalize();
var y = this._AreaElement(m - o, h - o) - this._AreaElement(m - o, h + o) - this._AreaElement(m + o, h - o) + this._AreaElement(m + o, h + o)
, b = u[_ * e.size * p + g * p + 0]
, T = u[_ * e.size * p + g * p + 1]
, E = u[_ * e.size * p + g * p + 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(d.Clamp(b), f),
T = Math.pow(d.Clamp(T), f),
E = Math.pow(d.Clamp(E), f));
var S = 4096;
b = d.Clamp(b, 0, S),
T = d.Clamp(T, 0, S),
E = d.Clamp(E, 0, S);
var A = new D(b,T,E);
t.addLight(v, A, y),
i += y,
m += n
}
h += r
}
var x = 4 * Math.PI * 6 / 6 / i;
return t.scaleInPlace(x),
t.convertIncidentRadianceToIrradiance(),
t.convertIrradianceToLambertianRadiance(),
Pc.FromHarmonics(t)
}
,
e._FileFaces = [new Fc("right",new x(1,0,0),new x(0,0,-1),new x(0,-1,0)), new Fc("left",new x(-1,0,0),new x(0,0,1),new x(0,-1,0)), new Fc("up",new x(0,1,0),new x(1,0,0),new x(0,0,1)), new Fc("down",new x(0,-1,0),new x(1,0,0),new x(0,0,-1)), new Fc("front",new x(0,0,1),new x(1,0,0),new x(0,-1,0)), new Fc("back",new x(0,0,-1),new x(-1,0,0),new x(0,-1,0))],
e
}();
Zr.prototype.forceSphericalPolynomialsRecompute = function() {
this._texture && (this._texture._sphericalPolynomial = null,
this._texture._sphericalPolynomialPromise = null,
this._texture._sphericalPolynomialComputed = !1)
}
,
Object.defineProperty(Zr.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 = wc.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
});
Pt.ShadersStore.rgbdEncodePixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}";
var Bc = "image/png"
, Uc = [134, 22, 135, 150, 246, 214, 150, 54];
function Vc(e) {
for (var t = new DataView(e.buffer,e.byteOffset,e.byteLength), i = 0, n = 0; n < Uc.length; n++)
if (t.getUint8(i++) !== Uc[n])
return K.Error("Not a babylon environment map"),
null;
for (var r = "", o = 0; o = t.getUint8(i++); )
r += String.fromCharCode(o);
var a = JSON.parse(r);
return (a = kc(a)).specular && (a.specular.specularDataPosition = i,
a.specular.lodGenerationScale = a.specular.lodGenerationScale || .8),
a
}
function kc(e) {
if (e.version > 2)
throw new Error('Unsupported babylon environment map version "'.concat(e.version, '". Latest supported version is "').concat(2, '".'));
return 2 === e.version ? e : e = V(V({}, e), {
version: 2,
imageType: Bc
})
}
function Gc(e, t) {
var i;
return void 0 === t && (t = {}),
G(this, void 0, void 0, (function() {
var n, r, o, s, l, c, u, h, p, f, _, m, g, v, y, b, T, E, S, A, x, R, C, P, M, I, O, D, N, L;
return z(this, (function(F) {
switch (F.label) {
case 0:
if (!(n = e.getInternalTexture()))
return [2, Promise.reject("The cube texture is invalid.")];
if (r = null !== (i = t.imageType) && void 0 !== i ? i : Bc,
o = 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 (s = a.TEXTURETYPE_FLOAT,
!o.getCaps().textureFloatRender && (s = a.TEXTURETYPE_HALF_FLOAT,
!o.getCaps().textureHalfFloatRender))
return [2, Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.")];
l = n.width,
c = new mn(o),
u = {},
o.flushFramebuffer(),
h = d.ILog2(n.width),
D = 0,
F.label = 1;
case 1:
if (!(D <= h))
return [3, 9];
p = Math.pow(2, h - D),
N = 0,
F.label = 2;
case 2:
return N < 6 ? [4, e.readPixels(N, D, void 0, !1)] : [3, 8];
case 3:
if ((f = F.sent()) && f.byteLength === f.length) {
for (_ = new Float32Array(4 * f.byteLength),
m = 0; m < f.byteLength; m++)
_[m] = f[m] / 255,
_[m] = Math.pow(_[m], 2.2);
f = _
}
return g = o.createRawTexture(f, p, p, a.TEXTUREFORMAT_RGBA, !1, !0, a.TEXTURE_NEAREST_SAMPLINGMODE, null, s),
[4, Lc.EncodeTextureToRGBD(g, c, s)];
case 4:
return F.sent(),
[4, o._readTexturePixels(g, p, p)];
case 5:
return v = F.sent(),
[4, gi.DumpDataAsync(p, p, v, r, void 0, !1, !0, t.imageQuality)];
case 6:
y = F.sent(),
u[6 * D + N] = y,
g.dispose(),
F.label = 7;
case 7:
return N++,
[3, 2];
case 8:
return D++,
[3, 1];
case 9:
for (c.dispose(),
b = {
version: 2,
width: l,
imageType: r,
irradiance: zc(e),
specular: {
mipmaps: [],
lodGenerationScale: e.lodGenerationScale
}
},
T = 0,
D = 0; D <= h; D++)
for (N = 0; N < 6; N++)
E = u[6 * D + N].byteLength,
b.specular.mipmaps.push({
length: E,
position: T
}),
T += E;
for (S = JSON.stringify(b),
A = new ArrayBuffer(S.length + 1),
x = new Uint8Array(A),
D = 0,
R = S.length; D < R; D++)
x[D] = S.charCodeAt(D);
for (x[S.length] = 0,
C = Uc.length + T + A.byteLength,
P = new ArrayBuffer(C),
M = new Uint8Array(P),
I = new DataView(P),
O = 0,
D = 0; D < Uc.length; D++)
I.setUint8(O++, Uc[D]);
for (M.set(new Uint8Array(A), O),
O += A.byteLength,
D = 0; D <= h; D++)
for (N = 0; N < 6; N++)
L = u[6 * D + N],
M.set(new Uint8Array(L), O),
O += L.byteLength;
return [2, P]
}
}
))
}
))
}
function zc(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 Wc(e, t) {
var i = (t = kc(t)).specular
, n = d.Log2(t.width);
if (n = Math.round(n) + 1,
i.mipmaps.length !== 6 * n)
throw new Error('Unsupported specular mipmaps number "'.concat(i.mipmaps.length, '"'));
for (var r = new Array(n), o = 0; o < n; o++) {
r[o] = new Array(6);
for (var a = 0; a < 6; a++) {
var s = i.mipmaps[6 * o + a];
r[o][a] = new Uint8Array(e.buffer,e.byteOffset + i.specularDataPosition + s.position,s.length)
}
}
return r
}
function Hc(e, t, i) {
var n = (i = kc(i)).specular;
return n ? (e._lodGenerationScale = n.lodGenerationScale,
jc(e, Wc(t, i), i.imageType)) : Promise.resolve()
}
function Xc(e, t, i, n, r, 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);
n.getEffect().executeWhenCompiled((function() {
n.externalTextureSamplerBinding = !0,
n.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([n], u, !0, o, s),
t.restoreDefaultFramebuffer(),
f.dispose(),
URL.revokeObjectURL(r),
d())
}
))
} else {
if (t._uploadImageToTexture(h, e, o, s),
l) {
var _ = c[s];
_ && t._uploadImageToTexture(_._texture, e, o, 0)
}
d()
}
}
))
}
function jc(e, t, i) {
if (void 0 === i && (i = Bc),
!gi.IsExponentOfTwo(e.width))
throw new Error("Texture size must be a power of two");
var n = d.ILog2(e.width) + 1
, r = e.getEngine()
, o = !1
, s = !1
, l = null
, c = null
, u = null
, h = r.getCaps();
if (e.format = a.TEXTUREFORMAT_RGBA,
e.type = a.TEXTURETYPE_UNSIGNED_INT,
e.generateMipMaps = !0,
e._cachedAnisotropicFilteringLevel = null,
r.updateTextureSamplingMode(a.TEXTURE_TRILINEAR_SAMPLINGMODE, e),
h.textureLOD ? r._features.supportRenderAndCopyToLodForFloatTextures ? h.textureHalfFloatRender && h.textureHalfFloatLinearFiltering ? (o = !0,
e.type = a.TEXTURETYPE_HALF_FLOAT) : h.textureFloatRender && h.textureFloatLinearFiltering && (o = !0,
e.type = a.TEXTURETYPE_FLOAT) : o = !1 : (o = !1,
s = !0,
u = {}),
o)
l = new Ba("rgbdDecode","rgbdDecode",null,null,1,null,a.TEXTURE_TRILINEAR_SAMPLINGMODE,r,!1,void 0,e.type,void 0,null,!1),
e._isRGBD = !1,
e.invertY = !1,
c = r.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 = (n - 1) * p + f
, g = f + (m - f) * (1 - _ / 2)
, v = Math.round(Math.min(Math.max(g, 0), m))
, y = new Lt(r,At.Temp);
y.isCube = !0,
y.invertY = !0,
y.generateMipMaps = !1,
r.updateTextureSamplingMode(a.TEXTURE_LINEAR_LINEAR, y);
var b = new Zr(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(n) {
for (var a = function(a) {
var h = t[n][a]
, d = new Blob([h],{
type: i
})
, p = URL.createObjectURL(d)
, f = void 0;
if ("undefined" == typeof Image || r._features.forceBitmapOverHTMLImageElement)
f = r.createImageBitmap(d, {
premultiplyAlpha: "none"
}).then((function(t) {
return Xc(t, r, o, l, p, a, n, s, u, c, e)
}
));
else {
var _ = new Image;
_.src = p,
f = new Promise((function(t, i) {
_.onload = function() {
Xc(_, r, o, l, p, a, n, 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 < n) {
var S = void 0
, A = Math.pow(2, n - 1 - t.length)
, x = A * A * 4;
switch (e.type) {
case a.TEXTURETYPE_UNSIGNED_INT:
S = new Uint8Array(x);
break;
case a.TEXTURETYPE_HALF_FLOAT:
S = new Uint16Array(x);
break;
case a.TEXTURETYPE_FLOAT:
S = new Float32Array(x)
}
for (_ = t.length; _ < n; _++)
for (var R = 0; R < 6; R++)
r._uploadArrayBufferViewToTexture(e, S, R, _)
}
return Promise.all(T).then((function() {
c && (r._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 Yc(e, t) {
var i = (t = kc(t)).irradiance;
if (i) {
var n = new Pc;
x.FromArrayToRef(i.x, 0, n.x),
x.FromArrayToRef(i.y, 0, n.y),
x.FromArrayToRef(i.z, 0, n.z),
x.FromArrayToRef(i.xx, 0, n.xx),
x.FromArrayToRef(i.yy, 0, n.yy),
x.FromArrayToRef(i.zz, 0, n.zz),
x.FromArrayToRef(i.yz, 0, n.yz),
x.FromArrayToRef(i.zx, 0, n.zx),
x.FromArrayToRef(i.xy, 0, n.xy),
e._sphericalPolynomial = n
}
}
function Kc(e, t, i, n, r) {
var o = jc(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 = At.CubeRawRGBD,
e._bufferViewArrayArray = t,
e._lodGenerationScale = n,
e._lodGenerationOffset = r,
e._sphericalPolynomial = i,
jc(e, t).then((function() {
return e.isReady = !0,
e
}
))
}
var Qc = {
GetEnvInfo: Vc,
CreateEnvTextureAsync: Gc,
CreateImageDataArrayBufferViews: Wc,
UploadEnvLevelsAsync: Hc,
UploadLevelsAsync: jc,
UploadEnvSpherical: Yc
};
function qc(e, t, i, n) {
for (var r = n, o = 0, a = ""; r < i.length; ) {
var s = i.charAt(r);
if (a)
s === a ? '"' === a || "'" === a ? "\\" !== i.charAt(r - 1) && (a = "") : a = "" : "*/" === a && "*" === s && r + 1 < i.length && ("/" === i.charAt(r + 1) && (a = ""),
"" === a && r++);
else
switch (s) {
case e:
o++;
break;
case t:
o--;
break;
case '"':
case "'":
case "`":
a = s;
break;
case "/":
if (r + 1 < i.length) {
var l = i.charAt(r + 1);
"/" === l ? a = "\n" : "*" === l && (a = "*/")
}
}
if (r++,
0 === o)
break
}
return 0 === o ? r - 1 : -1
}
function Zc(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 Jc(e) {
var t = e.charCodeAt(0);
return t >= 48 && t <= 57 || t >= 65 && t <= 90 || t >= 97 && t <= 122 || 95 == t
}
function $c(e) {
for (var t = 0, i = "", n = !1, r = []; t < e.length; ) {
var o = e.charAt(t);
if (i)
o === i ? '"' === i || "'" === i ? ("\\" !== e.charAt(t - 1) && (i = ""),
r.push(o)) : (i = "",
n = !1) : "*/" === i && "*" === o && t + 1 < e.length ? ("/" === e.charAt(t + 1) && (i = ""),
"" === i && (n = !1,
t++)) : n || r.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",
n = !0) : "*" === a && (i = "*/",
n = !0)
}
}
n || r.push(o)
}
t++
}
return r.join("")
}
function eu(e, t, i) {
for (; t >= 0 && e.charAt(t) !== i; )
t--;
return t
}
var tu, iu = 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 = 0; t < this._sourceCode.length; ) {
var i = this._sourceCode.indexOf(this.inlineToken, t);
if (i < 0)
break;
var n = this._sourceCode.indexOf("(", i + this.inlineToken.length);
if (n < 0)
this.debug && console.warn("Could not find the opening parenthesis after the token. startIndex=".concat(t)),
t = i + this.inlineToken.length;
else {
var r = e._RegexpFindFunctionNameAndType.exec(this._sourceCode.substring(i + this.inlineToken.length, n));
if (r) {
var o = [r[3], r[4]]
, a = o[0]
, s = o[1]
, l = qc("(", ")", 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)),
t = i + this.inlineToken.length;
else {
var c = this._sourceCode.substring(n + 1, l)
, u = Zc(this._sourceCode, l + 1);
if (u !== this._sourceCode.length) {
var h = qc("{", "}", 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)),
t = i + this.inlineToken.length;
else {
for (var d = this._sourceCode.substring(u, h + 1), p = $c(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
}),
t = h + 1;
var v = i > 0 ? this._sourceCode.substring(0, i) : ""
, y = h + 1 < this._sourceCode.length - 1 ? this._sourceCode.substring(h + 1) : "";
this._sourceCode = v + y,
t -= h + 1 - i
}
} else
this.debug && console.warn("Could not extract the body of the function '".concat(s, "' (type=").concat(a, "). funcParamsEndIndex=").concat(l)),
t = i + this.inlineToken.length
}
} else
this.debug && console.warn("Could not extract the name/type of the function from: ".concat(this._sourceCode.substring(i + this.inlineToken.length, n))),
t = i + 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 n = i[t], r = n.name, o = n.type, a = n.parameters, s = n.body, l = 0; l < this._sourceCode.length; ) {
var c = this._sourceCode.indexOf(r, l);
if (c < 0)
break;
if (0 === c || Jc(this._sourceCode.charAt(c - 1)))
l = c + r.length;
else {
var u = Zc(this._sourceCode, c + r.length);
if (u !== this._sourceCode.length && "(" === this._sourceCode.charAt(u)) {
var h = qc("(", ")", this._sourceCode, u);
if (h < 0)
this.debug && console.warn("Could not extract the parameters of the function call. Function '".concat(r, "' (type=").concat(o, "). callParamsStartIndex=").concat(u)),
l = c + r.length;
else {
var d = this._sourceCode.substring(u + 1, h)
, p = function(e) {
for (var t = [], i = 0, n = 0; i < e.length; ) {
if ("(" === e.charAt(i)) {
var r = qc("(", ")", e, i);
if (r < 0)
return null;
i = r
} else
"," === e.charAt(i) && (t.push(e.substring(n, i)),
n = i + 1);
i++
}
return n < i && t.push(e.substring(n, i)),
t
}($c(d));
if (null !== p) {
for (var f = [], _ = 0; _ < p.length; ++_) {
var m = p[_].trim();
f.push(m)
}
var g = "void" !== o ? r + "_" + n.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 = eu(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(r, "' (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(r, "' (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(r, "' (type=").concat(o, "). function parameters=").concat(a, ", call parameters=").concat(f)),
l = c + r.length
} else
this.debug && console.warn("Invalid function call: can't extract the parameters of the function call. Function '".concat(r, "' (type=").concat(o, "). callParamsStartIndex=").concat(u, ", callParams=") + d),
l = c + r.length
}
} else
l = c + r.length
}
}
return e
}
,
e.prototype._replaceNames = function(e, t, i) {
for (var n = function(n) {
var r = new RegExp(t[n].replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),"g")
, o = t[n].length
, a = i[n];
e = e.replace(r, (function(i) {
for (var r = [], s = 1; s < arguments.length; s++)
r[s - 1] = arguments[s];
var l = r[0];
return Jc(e.charAt(l - 1)) || Jc(e.charAt(l + o)) ? t[n] : a
}
))
}, r = 0; r < t.length; ++r)
n(r);
return e
}
,
e._RegexpFindFunctionNameAndType = /((\s+?)(\w+)\s+(\w+)\s*?)$/,
e
}(), nu = new h;
function ru() {
return new Promise((function(e) {
"undefined" == typeof _native ? nu.addOnce((function(t) {
return e(t)
}
)) : e(_native)
}
))
}
function ou(e, t) {
return G(this, void 0, void 0, (function() {
return z(this, (function(i) {
switch (i.label) {
case 0:
return [4, ru()];
case 1:
return i.sent()[e] = t,
[2]
}
}
))
}
))
}
"undefined" == typeof self || Object.prototype.hasOwnProperty.call(self, "_native") || Object.defineProperty(self, "_native", {
get: function() {
return tu
},
set: function(e) {
(tu = e) && nu.notifyObservers(tu)
}
});
var au = function() {
function e(e) {
this.isAsync = !1,
this.isReady = !1,
this._valueCache = {},
this.engine = e
}
return 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, n, r, 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) {
n[i[t]] = e
}
)),
this._uniforms = n,
l = 0; l < r.length; l++)
null == e.getUniform(r[l]) && (r.splice(l, 1),
l--);
r.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]
, n = t.updateFlag;
return (void 0 === i || i !== n) && (this._valueCache[e] = n,
!0)
}
,
e.prototype._cacheFloat2 = function(e, t, i) {
var n = this._valueCache[e];
if (!n)
return n = [t, i],
this._valueCache[e] = n,
!0;
var r = !1;
return n[0] !== t && (n[0] = t,
r = !0),
n[1] !== i && (n[1] = i,
r = !0),
r
}
,
e.prototype._cacheFloat3 = function(e, t, i, n) {
var r = this._valueCache[e];
if (!r)
return r = [t, i, n],
this._valueCache[e] = r,
!0;
var o = !1;
return r[0] !== t && (r[0] = t,
o = !0),
r[1] !== i && (r[1] = i,
o = !0),
r[2] !== n && (r[2] = n,
o = !0),
o
}
,
e.prototype._cacheFloat4 = function(e, t, i, n, r) {
var o = this._valueCache[e];
if (!o)
return o = [t, i, n, r],
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] !== n && (o[2] = n,
a = !0),
o[3] !== r && (o[3] = r,
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, n) {
this._cacheFloat3(e, t, i, n) && (this.engine.setInt3(this._uniforms[e], t, i, n) || (this._valueCache[e] = null))
}
,
e.prototype.setInt4 = function(e, t, i, n, r) {
this._cacheFloat4(e, t, i, n, r) && (this.engine.setInt4(this._uniforms[e], t, i, n, r) || (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.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, n) {
this._cacheFloat3(e, t, i, n) && (this.engine.setFloat3(this._uniforms[e], t, i, n) || (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.setFloat4 = function(e, t, i, n, r) {
this._cacheFloat4(e, t, i, n, r) && (this.engine.setFloat4(this._uniforms[e], t, i, n, r) || (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
}()
, su = function(e) {
function t(t, i, n, r) {
var o = e.call(this, t, i, n, r) || this;
return o.__framebuffer = null,
o.__framebufferDepthStencil = null,
o._engine = r,
o
}
return U(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
}(Fa)
, lu = function(e) {
function t() {
return null !== e && e.apply(this, arguments) || this
}
return U(t, e),
t
}(Bt)
, cu = function() {
function e(e) {
this._engine = e,
this._pending = new Array,
this._isCommandBufferScopeActive = !1,
this._commandStream = uu._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
}()
, uu = function(e) {
function t(i) {
void 0 === i && (i = {});
var n = e.call(this, null, !1, void 0, i.adaptToDeviceRatio) || this;
if (n._engine = new _native.Engine,
n._camera = _native.Camera ? new _native.Camera : null,
n._commandBufferEncoder = new cu(n._engine),
n._boundBuffersVertexArray = null,
n._currentDepthTest = _native.Engine.DEPTH_TEST_LEQUAL,
n._stencilTest = !1,
n._stencilMask = 255,
n._stencilFunc = a.ALWAYS,
n._stencilFuncRef = 0,
n._stencilFuncMask = 255,
n._stencilOpStencilFail = a.KEEP,
n._stencilOpDepthFail = a.KEEP,
n._stencilOpStencilDepthPass = a.REPLACE,
n._zOffset = 0,
n._zOffsetUnits = 0,
n._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)"));
n._webGLVersion = 2,
n.disableUniformBuffers = !0,
n._caps = {
maxTexturesImageUnits: 16,
maxVertexTextureImageUnits: 16,
maxCombinedTexturesImageUnits: 32,
maxTextureSize: 512,
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: !1,
textureHalfFloat: !1,
textureHalfFloatLinearFiltering: !1,
textureHalfFloatRender: !1,
textureLOD: !0,
drawBuffersExtension: !1,
depthTextureExtension: !1,
vertexArrayObject: !0,
instancedArrays: !1,
supportOcclusionQuery: !1,
canUseTimestampForTimerQuery: !1,
blendMinMax: !1,
maxMSAASamples: 1,
canUseGLInstanceID: !0,
canUseGLVertexID: !0,
supportComputeShaders: !1,
supportSRGBBuffers: !0,
supportTransformFeedbacks: !1,
textureMaxLevel: !1
},
n._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,
_collectUbosUpdatedInFrame: !1
},
gi.Log("Babylon Native (v" + vr.Version + ") launched"),
gi.LoadScript = function(e, t, i, n) {
gi.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
}
);
var r = window && window.devicePixelRatio || 1;
n._hardwareScalingLevel = i.adaptToDeviceRatio ? r : 1,
n.resize();
var o = n.getDepthFunction();
return o && n.setDepthFunction(o),
n._shaderProcessor = new wt,
n.onNewSceneAddedObservable.add((function(e) {
var t = e.render;
e.render = function() {
for (var i = [], r = 0; r < arguments.length; r++)
i[r] = arguments[r];
n._commandBufferEncoder.beginCommandScope(),
t.apply(e, i),
n._commandBufferEncoder.endCommandScope()
}
}
)),
n
}
return U(t, e),
t.prototype.getHardwareScalingLevel = function() {
return this._engine.getHardwareScalingLevel()
}
,
t.prototype.setHardwareScalingLevel = function(e) {
this._engine.setHardwareScalingLevel(e)
}
,
t.prototype.dispose = function() {
e.prototype.dispose.call(this),
this._boundBuffersVertexArray && this._deleteVertexArray(this._boundBuffersVertexArray),
this._engine.dispose()
}
,
t._createNativeDataStream = function() {
return new bc
}
,
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, n) {
if (void 0 === n && (n = !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(n ? 1 : 0),
this._commandBufferEncoder.encodeCommandArgAsUInt32(0),
this._commandBufferEncoder.finishEncodingCommand()
}
,
t.prototype.createIndexBuffer = function(e, t) {
var i = this._normalizeIndexData(e)
, n = new lu;
return n.references = 1,
n.is32Bits = 4 === i.BYTES_PER_ELEMENT,
i.byteLength && (n.nativeIndexBuffer = this._engine.createIndexBuffer(i.buffer, i.byteOffset, i.byteLength, n.is32Bits, null != t && t)),
n
}
,
t.prototype.createVertexBuffer = function(e, t) {
var i = ArrayBuffer.isView(e) ? e : new Float32Array(e)
, n = new lu;
return n.references = 1,
i.byteLength && (n.nativeVertexBuffer = this._engine.createVertexBuffer(i.buffer, i.byteOffset, i.byteLength, null != t && t)),
n
}
,
t.prototype._recordVertexArrayObject = function(e, t, i, n) {
i && this._engine.recordIndexBuffer(e, i.nativeIndexBuffer);
for (var r = n.getAttributesNames(), o = 0; o < r.length; o++) {
var a = n.getAttributeLocation(o);
if (a >= 0) {
var s = t[r[o]];
if (s) {
var l = s.getBuffer();
l && this._engine.recordVertexBuffer(e, l.nativeVertexBuffer, a, s.byteOffset, s.byteStride, s.getSize(), this._getNativeAttribType(s.type), s.normalized, s.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) {
var n = this._engine.createVertexArray();
return this._recordVertexArrayObject(n, e, t, i),
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, n) {
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, n) {
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 au(this)
}
,
t.prototype.createMaterialContext = function() {}
,
t.prototype.createDrawContext = function() {}
,
t.prototype._preparePipelineContext = function(e, t, i, n, r, o, a, s, l) {
e.nativeProgram = n ? this.createRawShaderProgram(e, t, i, void 0, l) : this.createShaderProgram(e, t, i, s, void 0, l)
}
,
t.prototype._isRenderingStateCompiled = function(e) {
return !0
}
,
t.prototype._executeWhenRenderingStateIsCompiled = function(e, t) {
t()
}
,
t.prototype.createRawShaderProgram = function(e, t, i, n, r) {
throw void 0 === r && (r = null),
new Error("Not Supported")
}
,
t.prototype.createShaderProgram = function(e, t, i, n, r, o) {
void 0 === o && (o = null),
this.onBeforeShaderCompilationObservable.notifyObservers(this);
var a = new iu(t);
a.processCode(),
t = a.code;
var s = new iu(i);
s.processCode(),
i = s.code,
t = Ht._ConcatenateShader(t, n),
i = Ht._ConcatenateShader(i, n);
var l = this._engine.createProgram(t, i);
return this.onAfterShaderCompilationObservable.notifyObservers(this),
l
}
,
t.prototype.inlineShaderCode = function(e) {
var t = new iu(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(), n = 0; n < i.length; n++) {
var r = e.getUniform(i[n]);
r && (this._boundUniforms[n] = r)
}
this._currentEffect = null
}
,
t.prototype.setMatrix = function(e, t) {
if (e) {
var i = t.toArray();
this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRIX),
this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
this._commandBufferEncoder.encodeCommandArgAsFloat32s(i),
this._commandBufferEncoder.finishEncodingCommand()
}
}
,
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._engine.setViewPort(e.x, e.y, e.width, e.height)
}
,
t.prototype.setState = function(e, t, i, n, r, o, a) {
var s, l;
void 0 === t && (t = 0),
void 0 === n && (n = !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 : r) || void 0 === l || l ? 1 : 0),
this._commandBufferEncoder.encodeCommandArgAsUInt32(n ? 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, n, r, o) {
this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETSTENCIL),
this._commandBufferEncoder.encodeCommandArgAsUInt32(e),
this._commandBufferEncoder.encodeCommandArgAsUInt32(t),
this._commandBufferEncoder.encodeCommandArgAsUInt32(i),
this._commandBufferEncoder.encodeCommandArgAsUInt32(n),
this._commandBufferEncoder.encodeCommandArgAsUInt32(r),
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, n) {
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, n) {
return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT3),
this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
this._commandBufferEncoder.encodeCommandArgAsFloat32(t),
this._commandBufferEncoder.encodeCommandArgAsFloat32(i),
this._commandBufferEncoder.encodeCommandArgAsFloat32(n),
this._commandBufferEncoder.finishEncodingCommand(),
!0)
}
,
t.prototype.setFloat4 = function(e, t, i, n, r) {
return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT4),
this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
this._commandBufferEncoder.encodeCommandArgAsFloat32(t),
this._commandBufferEncoder.encodeCommandArgAsFloat32(i),
this._commandBufferEncoder.encodeCommandArgAsFloat32(n),
this._commandBufferEncoder.encodeCommandArgAsFloat32(r),
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, n, r) {
if (void 0 === n && (n = !1),
void 0 === n && (n = !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, n) {
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, n)
}
,
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 n = e._hardwareTexture.underlyingResource;
this._camera.updateVideoTexture(n, t, i)
}
}
,
t.prototype.createRawTexture = function(e, t, i, n, r, o, s, l, c) {
void 0 === l && (l = null),
void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT);
var u = new Lt(this,At.Raw);
if (u.format = n,
u.generateMipMaps = r,
u.samplingMode = s,
u.invertY = o,
u.baseWidth = t,
u.baseHeight = i,
u.width = u.baseWidth,
u.height = u.baseHeight,
u._compression = l,
u.type = c,
this.updateRawTexture(u, e, n, o, l, c),
u._hardwareTexture) {
var h = u._hardwareTexture.underlyingResource
, d = this._getNativeSamplingMode(s);
this._setTextureSampling(h, d)
}
return this._internalTexturesCache.push(u),
u
}
,
t.prototype.createRawTexture2DArray = function(e, t, i, n, r, o, s, l, c, u) {
void 0 === c && (c = null),
void 0 === u && (u = a.TEXTURETYPE_UNSIGNED_INT);
var h = new Lt(this,At.Raw2DArray);
if (h.baseWidth = t,
h.baseHeight = i,
h.baseDepth = n,
h.width = t,
h.height = i,
h.depth = n,
h.format = r,
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, n, this._getNativeTextureFormat(r, 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, n, r, o) {
if (void 0 === r && (r = null),
void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT),
e) {
if (t && e._hardwareTexture) {
var s = e._hardwareTexture.underlyingResource;
this._engine.loadRawTexture(s, t, e.width, e.height, this._getNativeTextureFormat(i, o), e.generateMipMaps, e.invertY)
}
e.isReady = !0
}
}
,
t.prototype.createTexture = function(e, t, i, n, r, o, s, l, c, u, h, d, p, f, _) {
var m = this;
void 0 === r && (r = 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 Lt(this,At.Url)
, b = e;
!this._transformTextureUrl || v || c || l || (e = this._transformTextureUrl(e));
for (var T = e.lastIndexOf("."), S = h || (T > -1 ? e.substring(T).toLowerCase() : ""), A = null, x = 0, R = vr._TextureLoaders; x < R.length; x++) {
var C = R[x];
if (C.canLoad(S)) {
A = C;
break
}
}
n && n._addPendingData(y),
y.url = e,
y.generateMipMaps = !t,
y.samplingMode = r,
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),
A)
throw new Error("Loading textures from IInternalTextureLoader not yet implemented.");
var M = function(e) {
if (y._hardwareTexture) {
var o = y._hardwareTexture.underlyingResource;
m._engine.loadTexture(o, e, !t, i, _, (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(r);
m._setTextureSampling(o, e),
n && n._removePendingData(y),
y.onLoadedObservable.notifyObservers(y),
y.onLoadedObservable.clear()
}
), (function() {
throw new Error("Could not load a native texture.")
}
))
} else
n && n._removePendingData(y)
};
if (g && l)
if (l instanceof ArrayBuffer)
M(new Uint8Array(l));
else if (ArrayBuffer.isView(l))
M(l);
else {
if ("string" != typeof l)
throw new Error("Unsupported buffer type");
M(new Uint8Array(gi.DecodeBase64(l)))
}
else
v ? M(new Uint8Array(gi.DecodeBase64(e))) : this._loadFile(e, (function(e) {
return M(new Uint8Array(e))
}
), void 0, void 0, !0, (function(i, a) {
var c;
c = "Unable to load " + (i && i.responseURL,
a),
n && n._removePendingData(y),
e === b ? (P && y.onLoadedObservable.remove(P),
E.UseFallbackTexture && m.createTexture(E.FallbackTexture, t, y.invertY, n, r, null, s, l, y),
s && s((c || "Unknown error") + (E.UseFallbackTexture ? " - Fallback texture was used" : ""), void 0)) : (K.Warn("Failed to load ".concat(e, ", falling back to ").concat(b)),
m.createTexture(b, t, y.invertY, n, r, o, s, l, y, u, h, d, p))
}
));
return y
}
,
t.prototype._createDepthStencilTexture = function(e, t, i) {
var n = i
, r = new Lt(this,At.DepthStencil)
, o = e.width || e
, a = e.height || e
, s = this._engine.createFrameBuffer(r._hardwareTexture.underlyingResource, o, a, _native.Engine.TEXTURE_FORMAT_RGBA8, !1, !0, !1);
return n._framebufferDepthStencil = s,
r
}
,
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, n) {
var r = i.createCanvasImage();
r.onload = function() {
var e = i._engine.createImageBitmap(r);
e ? t(e) : n("Error loading image ".concat(r.src))
}
,
r.onerror = function() {
n("Error loading image ".concat(r.src))
}
,
r.src = e
}
))
}
,
t.prototype.createImageBitmap = function(e, t) {
var i = this;
return new Promise((function(t, n) {
if (Array.isArray(e)) {
var r = e;
if (r.length) {
var o = i._engine.createImageBitmap(r[0]);
if (o)
return void t(o)
}
}
n("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, n, r, o, s, l, c, u, h, d, p, f) {
var _ = this;
void 0 === r && (r = 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 Lt(this,At.Cube);
m.isCube = !0,
m.url = e,
m.generateMipMaps = !n,
m._lodGenerationScale = u,
m._lodGenerationOffset = h,
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 = Vc(e);
m.width = t.width,
m.height = t.width,
Yc(m, t);
var i = t.specular;
if (!i)
throw new Error("Nothing else parsed so far");
m._lodGenerationScale = i.lodGenerationScale;
var n = Wc(e, t);
m.format = a.TEXTUREFORMAT_RGBA,
m.type = a.TEXTURETYPE_UNSIGNED_INT,
m.generateMipMaps = !0,
m.getEngine().updateTextureSamplingMode(io.TRILINEAR_SAMPLINGMODE, m),
m._isRGBD = !0,
m.invertY = !0,
_._engine.loadCubeTextureWithMips(m._hardwareTexture.underlyingResource, n, !1, f, (function() {
m.isReady = !0,
r && r()
}
), (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 gi.LoadFileAsync(e).then((function(e) {
return new Uint8Array(e)
}
))
}
))).then((function(e) {
return new Promise((function(t, i) {
_._engine.loadCubeTexture(m._hardwareTexture.underlyingResource, e, !n, !0, f, t, i)
}
))
}
)).then((function() {
m.isReady = !0,
r && r()
}
), (function(e) {
o && o("Failed to load cubemap: ".concat(e.message), e)
}
))
}
return this._internalTexturesCache.push(m),
m
}
,
t.prototype._createHardwareRenderTargetWrapper = function(e, t, i) {
var n = new su(e,t,i,this);
return this._renderTargetWrapperCache.push(n),
n
}
,
t.prototype.createRenderTargetTexture = function(e, t) {
var i = this._createHardwareRenderTargetWrapper(!1, !1, e)
, n = {};
void 0 !== t && "object" == typeof t ? (n.generateMipMaps = t.generateMipMaps,
n.generateDepthBuffer = void 0 === t.generateDepthBuffer || t.generateDepthBuffer,
n.generateStencilBuffer = n.generateDepthBuffer && t.generateStencilBuffer,
n.type = void 0 === t.type ? a.TEXTURETYPE_UNSIGNED_INT : t.type,
n.samplingMode = void 0 === t.samplingMode ? a.TEXTURE_TRILINEAR_SAMPLINGMODE : t.samplingMode,
n.format = void 0 === t.format ? a.TEXTUREFORMAT_RGBA : t.format) : (n.generateMipMaps = t,
n.generateDepthBuffer = !0,
n.generateStencilBuffer = !1,
n.type = a.TEXTURETYPE_UNSIGNED_INT,
n.samplingMode = a.TEXTURE_TRILINEAR_SAMPLINGMODE,
n.format = a.TEXTUREFORMAT_RGBA),
(n.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (n.type !== a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (n.samplingMode = a.TEXTURE_NEAREST_SAMPLINGMODE);
var r = new Lt(this,At.RenderTarget)
, o = e.width || e
, s = e.height || e;
n.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloat || (n.type = a.TEXTURETYPE_UNSIGNED_INT,
K.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));
var l = this._engine.createFrameBuffer(r._hardwareTexture.underlyingResource, o, s, this._getNativeTextureFormat(n.format, n.type), !!n.generateStencilBuffer, n.generateDepthBuffer, !!n.generateMipMaps);
return i._framebuffer = l,
i._generateDepthBuffer = n.generateDepthBuffer,
i._generateStencilBuffer = !!n.generateStencilBuffer,
r.baseWidth = o,
r.baseHeight = s,
r.width = o,
r.height = s,
r.isReady = !0,
r.samples = 1,
r.generateMipMaps = !!n.generateMipMaps,
r.samplingMode = n.samplingMode,
r.type = n.type,
r.format = n.format,
this._internalTexturesCache.push(r),
i.setTextures(r),
i
}
,
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, n, r) {
var o = e;
if (t)
throw new Error("Cuboid frame buffers are not yet supported in NativeEngine.");
if (i || n)
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),
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 n = e
, r = this._normalizeIndexData(t);
n.is32Bits = 4 === r.BYTES_PER_ELEMENT,
this._engine.updateDynamicIndexBuffer(n.nativeIndexBuffer, r.buffer, r.byteOffset, r.byteLength, i)
}
,
t.prototype.updateDynamicVertexBuffer = function(e, t, i, n) {
var r = e
, o = ArrayBuffer.isView(t) ? t : new Float32Array(t);
this._engine.updateDynamicVertexBuffer(r.nativeVertexBuffer, o.buffer, o.byteOffset + (null != i ? i : 0), null != n ? n : o.byteLength)
}
,
t.prototype._setTexture = function(e, t, i, n) {
void 0 === i && (i = !1),
void 0 === n && (n = !1);
var r, o = this._boundUniforms[e];
if (!o)
return !1;
if (!t)
return null != this._boundTexturesCache[e] && (this._activeChannel = e,
this._setTextureCore(o, null)),
!1;
if (t.video)
this._activeChannel = e,
t.update();
else if (t.delayLoadState === a.DELAYLOADSTATE_NOTLOADED)
return t.delayLoad(),
!1;
return r = n ? t.depthStencilTexture : t.isReady() ? t.getInternalTexture() : t.isCube ? this.emptyCubeTexture : t.is3D ? this.emptyTexture3D : t.is2DArray ? this.emptyTexture2DArray : this.emptyTexture,
this._activeChannel = e,
!(!r || !r._hardwareTexture || (this._setTextureWrapMode(r._hardwareTexture.underlyingResource, this._getAddressMode(t.wrapU), this._getAddressMode(t.wrapV), this._getAddressMode(t.wrapR)),
this._updateAnisotropicLevel(t),
this._setTextureCore(o, r._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, n) {
this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTUREWRAPMODE),
this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
this._commandBufferEncoder.encodeCommandArgAsUInt32(t),
this._commandBufferEncoder.encodeCommandArgAsUInt32(i),
this._commandBufferEncoder.encodeCommandArgAsUInt32(n),
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 n = t._hardwareTexture.underlyingResource;
this._setTextureCore(i, n)
}
}
,
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._uploadCompressedDataToTextureDirectly = function(e, t, i, n, r, 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, n) {
throw void 0 === i && (i = 0),
void 0 === n && (n = 0),
new Error("_uploadDataToTextureDirectly not implemented.")
}
,
t.prototype._uploadArrayBufferViewToTexture = function(e, t, i, n) {
throw void 0 === i && (i = 0),
void 0 === n && (n = 0),
new Error("_uploadArrayBufferViewToTexture not implemented.")
}
,
t.prototype._uploadImageToTexture = function(e, t, i, n) {
throw void 0 === i && (i = 0),
void 0 === n && (n = 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_FLOAT)
return _native.Engine.TEXTURE_FORMAT_RGBA32F;
throw new ft("Unsupported texture format or type: format ".concat(e, ", type ").concat(t, "."),pt.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 Bi.BYTE:
return _native.Engine.ATTRIB_TYPE_INT8;
case Bi.UNSIGNED_BYTE:
return _native.Engine.ATTRIB_TYPE_UINT8;
case Bi.SHORT:
return _native.Engine.ATTRIB_TYPE_INT16;
case Bi.UNSIGNED_SHORT:
return _native.Engine.ATTRIB_TYPE_UINT16;
case Bi.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.PROTOCOL_VERSION = 5,
t
}(vr);
uu._createNativeDataStream = function() {
return _native.NativeDataStream.VALIDATION_ENABLED ? new Ku : new bc
}
;
var hu, du, pu, fu, _u, mu, gu, vu, yu, bu, Tu, Eu, Su, Au, xu, Ru, Cu, Pu, Mu, Iu, Ou, Du, Nu, Lu, Fu, wu, Bu, Uu, Vu, ku, Gu, zu, Wu, Hu, Xu, ju, Yu, Ku = function(e) {
function t() {
return e.call(this) || this
}
return U(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
}(bc);
!function(e) {
e.SRGB = "srgb"
}(hu || (hu = {})),
function(e) {
e.LowPower = "low-power",
e.HighPerformance = "high-performance"
}(du || (du = {})),
function(e) {
e.DepthClipControl = "depth-clip-control",
e.Depth24UnormStencil8 = "depth24unorm-stencil8",
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"
}(pu || (pu = {})),
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"
}(fu || (fu = {})),
function(e) {
e[e.Read = 1] = "Read",
e[e.Write = 2] = "Write"
}(_u || (_u = {})),
function(e) {
e.E1d = "1d",
e.E2d = "2d",
e.E3d = "3d"
}(mu || (mu = {})),
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"
}(gu || (gu = {})),
function(e) {
e.E1d = "1d",
e.E2d = "2d",
e.E2dArray = "2d-array",
e.Cube = "cube",
e.CubeArray = "cube-array",
e.E3d = "3d"
}(vu || (vu = {})),
function(e) {
e.All = "all",
e.StencilOnly = "stencil-only",
e.DepthOnly = "depth-only"
}(yu || (yu = {})),
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"
}(bu || (bu = {})),
function(e) {
e.ClampToEdge = "clamp-to-edge",
e.Repeat = "repeat",
e.MirrorRepeat = "mirror-repeat"
}(Tu || (Tu = {})),
function(e) {
e.Nearest = "nearest",
e.Linear = "linear"
}(Eu || (Eu = {})),
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"
}(Su || (Su = {})),
function(e) {
e[e.Vertex = 1] = "Vertex",
e[e.Fragment = 2] = "Fragment",
e[e.Compute = 4] = "Compute"
}(Au || (Au = {})),
function(e) {
e.Uniform = "uniform",
e.Storage = "storage",
e.ReadOnlyStorage = "read-only-storage"
}(xu || (xu = {})),
function(e) {
e.Filtering = "filtering",
e.NonFiltering = "non-filtering",
e.Comparison = "comparison"
}(Ru || (Ru = {})),
function(e) {
e.Float = "float",
e.UnfilterableFloat = "unfilterable-float",
e.Depth = "depth",
e.Sint = "sint",
e.Uint = "uint"
}(Cu || (Cu = {})),
function(e) {
e.WriteOnly = "write-only"
}(Pu || (Pu = {})),
function(e) {
e.Error = "error",
e.Warning = "warning",
e.Info = "info"
}(Mu || (Mu = {})),
function(e) {
e.PointList = "point-list",
e.LineList = "line-list",
e.LineStrip = "line-strip",
e.TriangleList = "triangle-list",
e.TriangleStrip = "triangle-strip"
}(Iu || (Iu = {})),
function(e) {
e.CCW = "ccw",
e.CW = "cw"
}(Ou || (Ou = {})),
function(e) {
e.None = "none",
e.Front = "front",
e.Back = "back"
}(Du || (Du = {})),
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"
}(Nu || (Nu = {})),
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"
}(Lu || (Lu = {})),
function(e) {
e.Add = "add",
e.Subtract = "subtract",
e.ReverseSubtract = "reverse-subtract",
e.Min = "min",
e.Max = "max"
}(Fu || (Fu = {})),
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"
}(wu || (wu = {})),
function(e) {
e.Uint16 = "uint16",
e.Uint32 = "uint32"
}(Bu || (Bu = {})),
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"
}(Uu || (Uu = {})),
function(e) {
e.Vertex = "vertex",
e.Instance = "instance"
}(Vu || (Vu = {})),
function(e) {
e.Beginning = "beginning",
e.End = "end"
}(ku || (ku = {})),
function(e) {
e.Beginning = "beginning",
e.End = "end"
}(Gu || (Gu = {})),
function(e) {
e.Load = "load",
e.Clear = "clear"
}(zu || (zu = {})),
function(e) {
e.Store = "store",
e.Discard = "discard"
}(Wu || (Wu = {})),
function(e) {
e.Occlusion = "occlusion",
e.Timestamp = "timestamp"
}(Hu || (Hu = {})),
function(e) {
e.Opaque = "opaque",
e.Premultiplied = "premultiplied"
}(Xu || (Xu = {})),
function(e) {
e.Destroyed = "destroyed"
}(ju || (ju = {})),
function(e) {
e.OutOfMemory = "out-of-memory",
e.Validation = "validation"
}(Yu || (Yu = {}));
var Qu = function() {
function e() {
this.shaderLanguage = st.GLSL
}
return e.prototype._addUniformToLeftOverUBO = function(e, t, i) {
var n, r;
e = (n = this._getArraySize(e, t, i))[0],
t = n[1],
r = n[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: r
})
}
,
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, xu.Uniform, !0),
this._addBufferBindingDescription(t, i, xu.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 n = this._webgpuProcessingContext.bindGroupLayoutEntries[e][i]
, r = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[e][n.binding].name
, o = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[e][n.binding].nameInArrayOfTexture;
n && (n.texture || n.externalTexture || n.storageTexture ? this._webgpuProcessingContext.textureNames.push(o) : n.sampler ? this._webgpuProcessingContext.samplerNames.push(r) : n.buffer && this._webgpuProcessingContext.bufferNames.push(r))
}
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], n = [], r = 0; r < i.length; r++) {
var o = this._webgpuProcessingContext.bindGroupLayoutEntries[t][r];
o.sampler || o.texture || o.storageTexture || o.externalTexture ? n.push({
binding: o.binding,
resource: void 0
}) : o.buffer && n.push({
binding: o.binding,
resource: {
buffer: void 0,
offset: 0,
size: 0
}
})
}
e[t] = n
}
}
,
e.prototype._addTextureBindingDescription = function(e, t, i, n, r, o) {
var a = t.textures[i]
, s = a.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 === n ? this._webgpuProcessingContext.bindGroupLayoutEntries[s].push({
binding: l,
visibility: 0,
externalTexture: {}
}) : r ? this._webgpuProcessingContext.bindGroupLayoutEntries[s].push({
binding: l,
visibility: 0,
storageTexture: {
access: Pu.WriteOnly,
format: r,
viewDimension: n
}
}) : this._webgpuProcessingContext.bindGroupLayoutEntries[s].push({
binding: l,
visibility: 0,
texture: {
sampleType: t.sampleType,
viewDimension: n,
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 ? Au.Vertex : Au.Fragment
}
,
e.prototype._addSamplerBindingDescription = function(e, t, i) {
var n = t.binding
, r = n.groupIndex
, o = n.bindingIndex;
if (this._webgpuProcessingContext.bindGroupLayoutEntries[r] || (this._webgpuProcessingContext.bindGroupLayoutEntries[r] = [],
this._webgpuProcessingContext.bindGroupLayoutEntryInfo[r] = []),
!this._webgpuProcessingContext.bindGroupLayoutEntryInfo[r][o]) {
var a = this._webgpuProcessingContext.bindGroupLayoutEntries[r].push({
binding: o,
visibility: 0,
sampler: {
type: t.type
}
});
this._webgpuProcessingContext.bindGroupLayoutEntryInfo[r][o] = {
name: e,
index: a - 1
}
}
o = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[r][o].index,
this._webgpuProcessingContext.bindGroupLayoutEntries[r][o].visibility |= i ? Au.Vertex : Au.Fragment
}
,
e.prototype._addBufferBindingDescription = function(e, t, i, n) {
var r = t.binding
, o = r.groupIndex
, a = r.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 |= n ? Au.Vertex : Au.Fragment
}
,
e.prototype._injectStartingAndEndingCode = function(e, t, i, n) {
if (i) {
var r = e.indexOf(t);
if (r >= 0) {
for (; r++ < e.length && "{" != e.charAt(r); )
;
if (r < e.length) {
for (; r++ < e.length && "\n" != e.charAt(r); )
;
if (r < e.length) {
var o = e.substring(0, r + 1)
, a = e.substring(r + 1);
e = o + i + a
}
}
}
}
if (n) {
var s = e.lastIndexOf("}");
e = e.substring(0, s),
e += n + "\n}"
}
return e
}
,
e.AutoSamplerSuffix = "Sampler",
e.LeftOvertUBOName = "LeftOver",
e.InternalsUBOName = "Internals",
e.UniformSizes = {
bool: 1,
int: 1,
float: 1,
vec2: 2,
ivec2: 2,
vec3: 3,
ivec3: 3,
vec4: 4,
ivec4: 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: vu.Cube,
textureCubeArray: vu.CubeArray,
texture2D: vu.E2d,
texture2DArray: vu.E2dArray,
texture3D: vu.E3d
},
e._SamplerTypeByWebGLSamplerType = {
sampler2DShadow: "samplerShadow",
sampler2DArrayShadow: "samplerShadow"
},
e._IsComparisonSamplerByWebGPUSamplerType = {
samplerShadow: !0,
samplerArrayShadow: !0,
sampler: !1
},
e
}()
, qu = function() {
function e(e, t) {
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, n, r, o, a, s) {
var l = this.engine;
e._fragmentSourceCode = "",
e._vertexSourceCode = "";
var c, u = this.shaderProcessingContext.availableTextures;
for (c = 0; c < r.length; c++) {
var h = r[c]
, d = u[r[c]];
null == d || null == d ? (r.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 Fi(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]
, n = i.type.replace(/^(.*?)(<.*>)?$/, "$1")
, r = Qu.UniformSizes[n];
this.uniformBuffer.addUniform(i.name, r, 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, n) {
this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateInt3(e, t, i, n)
}
,
e.prototype.setInt4 = function(e, t, i, n, r) {
this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateInt4(e, t, i, n, r)
}
,
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.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, n) {
this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateFloat3(e, t, i, n)
}
,
e.prototype.setVector4 = function(e, t) {
this.setFloat4(e, t.x, t.y, t.z, t.w)
}
,
e.prototype.setFloat4 = function(e, t, i, n, r) {
this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateFloat4(e, t, i, n, r)
}
,
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
}()
, Zu = {
mat2: 2,
mat3: 3,
mat4: 4,
mat2x2: 2,
mat3x3: 3,
mat4x4: 4
}
, Ju = 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 n in t) {
var r = t[n].binding;
-1 !== r.groupIndex && (void 0 === i[r.groupIndex] ? i[r.groupIndex] = r.bindingIndex : i[r.groupIndex] = Math.max(i[r.groupIndex], r.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 n = this._attributeNextLocation;
return this._attributeNextLocation += (null !== (i = Zu[e]) && void 0 !== i ? i : 1) * (t || 1),
n
}
,
e.prototype.getVaryingNextLocation = function(e, t) {
var i;
void 0 === t && (t = 0);
var n = this._varyingNextLocation;
return this._varyingNextLocation += (null !== (i = Zu[e]) && void 0 !== i ? i : 1) * (t || 1),
n
}
,
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
}()
, $u = function(e) {
function t() {
var t = null !== e && e.apply(this, arguments) || this;
return t._missingVaryings = [],
t._textureArrayProcessing = [],
t.shaderLanguage = st.GLSL,
t
}
return U(t, e),
t.prototype._getArraySize = function(e, t, i) {
var n = 0
, r = e.indexOf("[")
, o = e.indexOf("]");
if (r > 0 && o > 0) {
var a = e.substring(r + 1, o);
n = +a,
isNaN(n) && (n = +i[a.trim()]),
e = e.substr(0, r)
}
return [e, t, n]
}
,
t.prototype.initializeShaders = function(e) {
this._webgpuProcessingContext = e,
this._missingVaryings.length = 0,
this._textureArrayProcessing.length = 0
}
,
t.prototype.preProcessShaderCode = function(e, t) {
var i = "uniform ".concat(Qu.InternalsUBOName, " {\nfloat yFactor__;\nfloat textureOutputHeight__;\n};\n");
return t ? i + "##INJECTCODE##\n" + e : i + e
}
,
t.prototype.varyingProcessor = function(e, t, i) {
this._preProcessors = i;
var n = /\s*varying\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm.exec(e);
if (null != n) {
var r, o = n[1], a = n[2];
t ? (r = this._webgpuProcessingContext.availableVaryings[a],
this._missingVaryings[r] = "",
void 0 === r && K.Warn('Invalid fragment shader: The varying named "'.concat(a, '" is not declared in the vertex shader! This declaration will be ignored.'))) : (r = this._webgpuProcessingContext.getVaryingNextLocation(o, this._getArraySize(a, o, i)[2]),
this._webgpuProcessingContext.availableVaryings[a] = r,
this._missingVaryings[r] = "layout(location = ".concat(r, ") in ").concat(o, " ").concat(a, ";")),
e = e.replace(n[0], void 0 === r ? "" : "layout(location = ".concat(r, ") ").concat(t ? "in" : "out", " ").concat(o, " ").concat(a, ";"))
}
return e
}
,
t.prototype.attributeProcessor = function(e, t) {
this._preProcessors = t;
var i = /\s*attribute\s+(\S+)\s+(\S+)\s*;/gm.exec(e);
if (null != i) {
var n = i[1]
, r = i[2]
, o = this._webgpuProcessingContext.getAttributeNextLocation(n, this._getArraySize(r, n, t)[2]);
this._webgpuProcessingContext.availableAttributes[r] = o,
this._webgpuProcessingContext.orderedAttributes[o] = r,
e = e.replace(i[0], "layout(location = ".concat(o, ") in ").concat(n, " ").concat(r, ";"))
}
return e
}
,
t.prototype.uniformProcessor = function(e, t, i) {
var n, r;
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 = (n = this._getArraySize(s, a, i))[0],
a = n[1],
l = n[2];
var c = this._webgpuProcessingContext.availableTextures[s];
if (!c) {
c = {
autoBindSampler: !0,
isTextureArray: l > 0,
isStorageTexture: !1,
textures: [],
sampleType: Cu.Float
};
for (var u = 0; u < (l || 1); ++u)
c.textures.push(this._webgpuProcessingContext.getNextFreeUBOBinding())
}
var h = null !== (r = Qu._SamplerTypeByWebGLSamplerType[a]) && void 0 !== r ? r : "sampler"
, d = !!Qu._IsComparisonSamplerByWebGPUSamplerType[h]
, p = d ? Ru.Comparison : Ru.Filtering
, f = s + Qu.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 ? Cu.Depth : "u" === m ? Cu.Uint : "i" === m ? Cu.Sint : Cu.Float;
c.sampleType = g;
var v = l > 0
, y = _.binding.groupIndex
, b = _.binding.bindingIndex
, T = Qu._SamplerFunctionByWebGLSamplerType[a]
, E = Qu._TextureTypeByWebGLSamplerType[a]
, S = Qu._GpuTextureViewDimensionByWebGPUTextureType[E];
if (v) {
var A = [];
for (A.push("layout(set = ".concat(y, ", binding = ").concat(b, ") uniform ").concat(m).concat(h, " ").concat(f, ";")),
e = "\r\n",
u = 0; u < l; ++u) {
var x = c.textures[u].groupIndex
, R = c.textures[u].bindingIndex;
A.push("layout(set = ".concat(x, ", binding = ").concat(R, ") uniform ").concat(E, " ").concat(s, "Texture").concat(u, ";")),
e += "".concat(u > 0 ? "\r\n" : "", "#define ").concat(s).concat(u, " ").concat(m).concat(T, "(").concat(s, "Texture").concat(u, ", ").concat(f, ")")
}
e = A.join("\r\n") + e,
this._textureArrayProcessing.push(s)
} else
l = 1,
e = "layout(set = ".concat(y, ", binding = ").concat(b, ") uniform ").concat(m).concat(h, " ").concat(f, ";\n layout(set = ").concat(c.textures[0].groupIndex, ", binding = ").concat(c.textures[0].bindingIndex, ") uniform ").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 n = i[1]
, r = this._webgpuProcessingContext.availableBuffers[n];
if (!r) {
var o = Ju.KnownUBOs[n];
r = {
binding: o && -1 !== o.binding.groupIndex ? o.binding : this._webgpuProcessingContext.getNextFreeUBOBinding()
},
this._webgpuProcessingContext.availableBuffers[n] = r
}
this._addBufferBindingDescription(n, r, xu.Uniform, !t),
e = e.replace("uniform", "layout(set = ".concat(r.binding.groupIndex, ", binding = ").concat(r.binding.bindingIndex, ") uniform"))
}
return e
}
,
t.prototype.postProcessor = function(e, t, i, n, r) {
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" : "";
e = (e = (e = (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__")).replace(/void\s+?main\s*\(/g, (o ? "" : "layout(location = 0) out vec4 glFragColor;\n") + "void main(")).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 l = e.lastIndexOf("}");
e = e.substring(0, l),
e += "gl_Position.y *= yFactor__;\n",
r.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"), n = i.exec(e); null != n; ) {
var r = n[1]
, o = +r;
this._preProcessors && isNaN(o) && (o = +this._preProcessors[r.trim()]),
e = e.replace(n[0], t + o),
n = 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 "), n = 0, r = this._webgpuProcessingContext.leftOverUniforms; n < r.length; n++) {
var o = r[n];
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 n = this._textureArrayProcessing[i];
e = this._applyTextureArrayProcessing(e, n),
t = this._applyTextureArrayProcessing(t, n)
}
for (i = 0; i < this._missingVaryings.length; ++i) {
var r = this._missingVaryings[i];
r && r.length > 0 && (t = r + "\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
}(Qu);
Pt.IncludesShadersStoreWGSL.bonesDeclaration = "#if NUM_BONE_INFLUENCERS>0\nattribute matricesIndices : vec4;\nattribute matricesWeights : vec4;\n#if NUM_BONE_INFLUENCERS>4\nattribute matricesIndicesExtra : vec4;\nattribute matricesWeightsExtra : vec4;\n#endif\n#ifndef BAKED_VERTEX_ANIMATION_TEXTURE\n#ifdef BONETEXTURE\nvar boneSampler : texture_2d;\nuniform 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{\nlet offset=i32(index) *4; \nlet m0=textureLoad(smp,vec2(offset+0,0),0);\nlet m1=textureLoad(smp,vec2(offset+1,0),0);\nlet m2=textureLoad(smp,vec2(offset+2,0),0);\nlet m3=textureLoad(smp,vec2(offset+3,0),0);\nreturn mat4x4(m0,m1,m2,m3);\n}\n#endif\n#endif\n#endif\n";
Pt.IncludesShadersStoreWGSL.bonesVertex = "#ifndef BAKED_VERTEX_ANIMATION_TEXTURE\n#if NUM_BONE_INFLUENCERS>0\nvar influence : mat4x4;\n#ifdef BONETEXTURE\ninfluence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1];\n#endif \n#if NUM_BONE_INFLUENCERS>2\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2];\n#endif \n#if NUM_BONE_INFLUENCERS>3\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3];\n#endif \n#if NUM_BONE_INFLUENCERS>4\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0];\n#endif \n#if NUM_BONE_INFLUENCERS>5\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1];\n#endif \n#if NUM_BONE_INFLUENCERS>6\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2];\n#endif \n#if NUM_BONE_INFLUENCERS>7\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3];\n#endif \n#else \ninfluence=uniforms.mBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence=influence+uniforms.mBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif \n#if NUM_BONE_INFLUENCERS>2\ninfluence=influence+uniforms.mBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif \n#if NUM_BONE_INFLUENCERS>3\ninfluence=influence+uniforms.mBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif \n#if NUM_BONE_INFLUENCERS>4\ninfluence=influence+uniforms.mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif \n#if NUM_BONE_INFLUENCERS>5\ninfluence=influence+uniforms.mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif \n#if NUM_BONE_INFLUENCERS>6\ninfluence=influence+uniforms.mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif \n#if NUM_BONE_INFLUENCERS>7\ninfluence=influence+uniforms.mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif \n#endif\nfinalWorld=finalWorld*influence;\n#endif\n#endif\n";
Pt.IncludesShadersStoreWGSL.bakedVertexAnimationDeclaration = "#ifdef BAKED_VERTEX_ANIMATION_TEXTURE\nuniform bakedVertexAnimationTime: f32;\nuniform bakedVertexAnimationTextureSizeInverted: vec2;\nuniform bakedVertexAnimationSettings: vec4;\nvar bakedVertexAnimationTexture : texture_2d;\n#ifdef INSTANCES\nattribute bakedVertexAnimationSettingsInstanced : vec4;\n#endif\nfn readMatrixFromRawSamplerVAT(smp : texture_2d,index : f32,frame : f32)->mat4x4\n{\nlet offset=i32(index)*4;\nlet frameUV=i32(frame);\nlet m0=textureLoad(smp,vec2(offset+0,frameUV),0);\nlet m1=textureLoad(smp,vec2(offset+1,frameUV),0);\nlet m2=textureLoad(smp,vec2(offset+2,frameUV),0);\nlet m3=textureLoad(smp,vec2(offset+3,frameUV),0);\nreturn mat4x4(m0,m1,m2,m3);\n}\n#endif\n";
Pt.IncludesShadersStoreWGSL.bakedVertexAnimation = "#ifdef BAKED_VERTEX_ANIMATION_TEXTURE\n{\n#ifdef INSTANCES\nlet VATStartFrame: f32=bakedVertexAnimationSettingsInstanced.x;\nlet VATEndFrame: f32=bakedVertexAnimationSettingsInstanced.y;\nlet VATOffsetFrame: f32=bakedVertexAnimationSettingsInstanced.z;\nlet VATSpeed: f32=bakedVertexAnimationSettingsInstanced.w;\n#else\nlet VATStartFrame: f32=uniforms.bakedVertexAnimationSettings.x;\nlet VATEndFrame: f32=uniforms.bakedVertexAnimationSettings.y;\nlet VATOffsetFrame: f32=uniforms.bakedVertexAnimationSettings.z;\nlet VATSpeed: f32=uniforms.bakedVertexAnimationSettings.w;\n#endif\nlet totalFrames: f32=VATEndFrame-VATStartFrame+1.0;\nlet time: f32=uniforms.bakedVertexAnimationTime*VATSpeed/totalFrames;\nlet frameCorrection: f32=select(1.0,0.0,time<1.0);\nlet numOfFrames: f32=totalFrames-frameCorrection;\nvar VATFrameNum: f32=fract(time)*numOfFrames;\nVATFrameNum=(VATFrameNum+VATOffsetFrame) % numOfFrames;\nVATFrameNum=floor(VATFrameNum);\nVATFrameNum=VATFrameNum+VATStartFrame+frameCorrection;\nvar VATInfluence : mat4x4;\nVATInfluence=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[0],VATFrameNum)*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[1],VATFrameNum)*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[2],VATFrameNum)*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[3],VATFrameNum)*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[0],VATFrameNum)*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[1],VATFrameNum)*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[2],VATFrameNum)*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[3],VATFrameNum)*matricesWeightsExtra[3];\n#endif\nfinalWorld=finalWorld*VATInfluence;\n}\n#endif\n";
Pt.IncludesShadersStoreWGSL.clipPlaneFragment = "#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\nif (false) {}\n#endif\n#ifdef CLIPPLANE\nelseif (fClipDistance>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE2\nelseif (fClipDistance2>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE3\nelseif (fClipDistance3>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE4\nelseif (fClipDistance4>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE5\nelseif (fClipDistance5>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE6\nelseif (fClipDistance6>0.0)\n{\ndiscard;\n}\n#endif\n";
Pt.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";
Pt.IncludesShadersStoreWGSL.clipPlaneVertex = "#ifdef CLIPPLANE\nfClipDistance=dot(worldPos,uniforms.vClipPlane);\n#endif\n#ifdef CLIPPLANE2\nfClipDistance2=dot(worldPos,uniforms.vClipPlane2);\n#endif\n#ifdef CLIPPLANE3\nfClipDistance3=dot(worldPos,uniforms.vClipPlane3);\n#endif\n#ifdef CLIPPLANE4\nfClipDistance4=dot(worldPos,uniforms.vClipPlane4);\n#endif\n#ifdef CLIPPLANE5\nfClipDistance5=dot(worldPos,uniforms.vClipPlane5);\n#endif\n#ifdef CLIPPLANE6\nfClipDistance6=dot(worldPos,uniforms.vClipPlane6);\n#endif\n";
Pt.IncludesShadersStoreWGSL.clipPlaneVertexDeclaration = "#ifdef CLIPPLANE\nuniform vClipPlane: vec4;\nvarying fClipDistance: f32;\n#endif\n#ifdef CLIPPLANE2\nuniform vClipPlane2: vec4;\nvarying fClipDistance2: f32;\n#endif\n#ifdef CLIPPLANE3\nuniform vClipPlane3: vec4;\nvarying fClipDistance3: f32;\n#endif\n#ifdef CLIPPLANE4\nuniform vClipPlane4: vec4;\nvarying fClipDistance4: f32;\n#endif\n#ifdef CLIPPLANE5\nuniform vClipPlane5: vec4;\nvarying fClipDistance5: f32;\n#endif\n#ifdef CLIPPLANE6\nuniform vClipPlane6: vec4;\nvarying fClipDistance6: f32;\n#endif\n";
Pt.IncludesShadersStoreWGSL.instancesDeclaration = "#ifdef INSTANCES\nattribute world0 : vec4;\nattribute world1 : vec4;\nattribute world2 : vec4;\nattribute 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;\nattribute previousWorld1 : vec4;\nattribute previousWorld2 : vec4;\nattribute 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";
Pt.IncludesShadersStoreWGSL.instancesVertex = "#ifdef INSTANCES\nvar finalWorld=mat4x4(world0,world1,world2,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";
Pt.IncludesShadersStoreWGSL.meshUboDeclaration = "struct Mesh {\nworld : mat4x4;\nvisibility : f32;\n};\nvar mesh : Mesh;\n#define WORLD_UBO\n";
Pt.IncludesShadersStoreWGSL.morphTargetsVertex = "#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_TEXTURE \nvertexID=f32(gl_VertexID)*uniforms.morphTargetTextureInfo.x;\npositionUpdated=positionUpdated+(readVector3FromRawSampler({X},vertexID)-position)*uniforms.morphTargetInfluences[{X}];\nvertexID=vertexID+1.0;\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated=normalUpdated+(readVector3FromRawSampler({X},vertexID) -normal)*uniforms.morphTargetInfluences[{X}];\nvertexID=vertexID+1.0;\n#endif\n#ifdef MORPHTARGETS_UV\nuvUpdated=uvUpdated+(readVector3FromRawSampler({X},vertexID).xy-uv)*uniforms.morphTargetInfluences[{X}];\nvertexID=vertexID+1.0;\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz=tangentUpdated.xyz+(readVector3FromRawSampler({X},vertexID) -tangent.xyz)*uniforms.morphTargetInfluences[{X}];\n#endif\n#else\npositionUpdated=positionUpdated+(position{X}-position)*uniforms.morphTargetInfluences[{X}];\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated+=(normal{X}-normal)*uniforms.morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz=tangentUpdated.xyz+(tangent{X}-tangent.xyz)*uniforms.morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_UV\nuvUpdated=uvUpdated+(uv_{X}-uv)*uniforms.morphTargetInfluences[{X}];\n#endif\n#endif\n#endif\n";
Pt.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";
Pt.IncludesShadersStoreWGSL.morphTargetsVertexGlobal = "#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_TEXTURE\nvar vertexID : f32;\n#endif\n#endif\n";
Pt.IncludesShadersStoreWGSL.morphTargetsVertexGlobalDeclaration = "#ifdef MORPHTARGETS\nuniform morphTargetInfluences : array;\n#ifdef MORPHTARGETS_TEXTURE \nuniform morphTargetTextureIndices : array;\nuniform morphTargetTextureInfo : vec3;\nvar morphTargets : texture_2d_array;\nvar morphTargetsSampler : sampler;\nfn readVector3FromRawSampler(targetIndex : i32,vertexIndex : f32)->vec3\n{ \nlet y=floor(vertexIndex/uniforms.morphTargetTextureInfo.y);\nlet x=vertexIndex-y*uniforms.morphTargetTextureInfo.y;\nlet textureUV=vec2((x+0.5)/uniforms.morphTargetTextureInfo.y,(y+0.5)/uniforms.morphTargetTextureInfo.z);\nreturn textureSampleLevel(morphTargets,morphTargetsSampler,textureUV,i32(uniforms.morphTargetTextureIndices[targetIndex]),0.0).xyz;\n}\n#endif\n#endif\n";
Pt.IncludesShadersStoreWGSL.sceneUboDeclaration = "struct Scene {\nviewProjection : mat4x4;\n#ifdef MULTIVIEW\nviewProjectionR : mat4x4;\n#endif \nview : mat4x4;\nprojection : mat4x4;\nvEyePosition : vec4;\n};\nvar scene : Scene;\n";
var eh, th = "gl_VertexID", ih = "gl_InstanceID", nh = "gl_Position", rh = "gl_FragCoord", oh = "gl_FrontFacing", ah = "gl_FragDepth", sh = "gl_FragColor", lh = {
texture_1d: vu.E1d,
texture_2d: vu.E2d,
texture_2d_array: vu.E2dArray,
texture_3d: vu.E3d,
texture_cube: vu.Cube,
texture_cube_array: vu.CubeArray,
texture_multisampled_2d: vu.E2d,
texture_depth_2d: vu.E2d,
texture_depth_2d_array: vu.E2dArray,
texture_depth_cube: vu.Cube,
texture_depth_cube_array: vu.CubeArray,
texture_depth_multisampled_2d: vu.E2d,
texture_storage_1d: vu.E1d,
texture_storage_2d: vu.E2d,
texture_storage_2d_array: vu.E2dArray,
texture_storage_3d: vu.E3d,
texture_external: null
}, ch = function(e) {
function t() {
var t = null !== e && e.apply(this, arguments) || this;
return t.shaderLanguage = st.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 U(t, e),
t.prototype._getArraySize = function(e, t, i) {
var n = 0
, r = t.lastIndexOf(">");
if (t.indexOf("array") >= 0 && r > 0) {
for (var o = r; o > 0 && " " !== t.charAt(o) && "," !== t.charAt(o); )
o--;
var a = t.substring(o + 1, r);
for (n = +a,
isNaN(n) && (n = +i[a.trim()]); o > 0 && (" " === t.charAt(o) || "," === t.charAt(o)); )
o--;
t = t.substring(t.indexOf("<") + 1, o + 1)
}
return [e, t, n]
}
,
t.prototype.initializeShaders = function(e) {
this._webgpuProcessingContext = e,
this._attributesWGSL = [],
this._attributesDeclWGSL = [],
this._attributeNamesWGSL = [],
this._varyingsWGSL = [],
this._varyingsDeclWGSL = [],
this._varyingNamesWGSL = []
}
,
t.prototype.preProcessShaderCode = function(e) {
return "struct ".concat(Qu.InternalsUBOName, " {\nyFactor__: f32;\ntextureOutputHeight__: f32;\n};\nvar ").concat("internals", " : ").concat(Qu.InternalsUBOName, ";\n") + $c(e)
}
,
t.prototype.varyingProcessor = function(e, t, i) {
var n = /\s*varying\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s*:\s*(.+)\s*;/gm.exec(e);
if (null !== n) {
var r, o = n[2], a = n[1];
t ? void 0 === (r = this._webgpuProcessingContext.availableVaryings[a]) && K.Warn('Invalid fragment shader: The varying named "'.concat(a, '" is not declared in the vertex shader! This declaration will be ignored.')) : (r = this._webgpuProcessingContext.getVaryingNextLocation(o, this._getArraySize(a, o, i)[2]),
this._webgpuProcessingContext.availableVaryings[a] = r,
this._varyingsWGSL.push("@location(".concat(r, ") ").concat(a, " : ").concat(o, ";")),
this._varyingsDeclWGSL.push("var ".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 n = i[2]
, r = i[1]
, o = this._webgpuProcessingContext.getAttributeNextLocation(n, this._getArraySize(r, n, t)[2]);
this._webgpuProcessingContext.availableAttributes[r] = o,
this._webgpuProcessingContext.orderedAttributes[o] = r,
this._attributesWGSL.push("@location(".concat(o, ") ").concat(r, " : ").concat(n, ";")),
this._attributesDeclWGSL.push("var ".concat(r, " : ").concat(n, ";")),
this._attributeNamesWGSL.push(r),
e = ""
}
return e
}
,
t.prototype.uniformProcessor = function(e, t, i) {
var n = this.uniformRegexp.exec(e);
if (null !== n) {
var r = n[2]
, o = n[1];
this._addUniformToLeftOverUBO(o, r, i),
e = ""
}
return e
}
,
t.prototype.textureProcessor = function(e, t, i) {
var n = this.textureRegexp.exec(e);
if (null !== n) {
var r = n[1]
, o = n[2]
, a = !!n[3]
, s = n[4]
, l = s.indexOf("storage") > 0
, c = n[6]
, u = l ? c.substring(0, c.indexOf(",")).trim() : null
, h = a ? this._getArraySize(r, o, i)[2] : 0
, d = this._webgpuProcessingContext.availableTextures[r];
if (d)
h = d.textures.length;
else {
d = {
isTextureArray: h > 0,
isStorageTexture: l,
textures: [],
sampleType: Cu.Float
},
h = h || 1;
for (var p = 0; p < h; ++p)
d.textures.push(this._webgpuProcessingContext.getNextFreeUBOBinding())
}
this._webgpuProcessingContext.availableTextures[r] = d;
var f = s.indexOf("depth") > 0
, _ = lh[s]
, m = f ? Cu.Depth : "u32" === c ? Cu.Uint : "i32" === c ? Cu.Sint : Cu.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(r, d, p, _, u, !t)
}
}
return e
}
,
t.prototype.postProcessor = function(e) {
return e
}
,
t.prototype.finalizeShaders = function(e, t) {
var i = t.indexOf("gl_FragCoord") >= 0 ? "\n if (internals.yFactor__ == 1.) {\n gl_FragCoord.y = internals.textureOutputHeight__ - gl_FragCoord.y;\n }\n " : "";
e = this._processSamplers(e, !0),
t = this._processSamplers(t, !1),
e = this._processCustomBuffers(e, !0),
t = this._processCustomBuffers(t, !1);
var n = this._buildLeftOverUBO();
t = n + t,
e = (e = n + e).replace(/#define /g, "//#define ");
var r = this._varyingsDeclWGSL.join("\n") + "\n"
, o = "var ".concat(th, " : u32;\nvar ").concat(ih, " : u32;\nvar ").concat(nh, " : vec4;\n")
, a = this._attributesDeclWGSL.join("\n") + "\n"
, s = "struct VertexInputs {\n @builtin(vertex_index) vertexIndex : u32;\n @builtin(instance_index) instanceIndex : u32;\n";
this._attributesWGSL.length > 0 && (s += this._attributesWGSL.join("\n")),
s += "\n};\n";
var l = "struct FragmentInputs {\n @builtin(position) position : vec4;\n";
this._varyingsWGSL.length > 0 && (l += this._varyingsWGSL.join("\n")),
e = o + s + a + (l += "\n};\n") + r + e;
for (var c = " var output : FragmentInputs;\n ".concat(th, " = input.vertexIndex;\n ").concat(ih, " = input.instanceIndex;\n"), u = 0; u < this._attributeNamesWGSL.length; ++u) {
var h = this._attributeNamesWGSL[u];
c += " ".concat(h, " = input.").concat(h, ";\n")
}
var d = " output.position = ".concat(nh, ";\n output.position.y = output.position.y * internals.yFactor__;\n");
for (u = 0; u < this._varyingNamesWGSL.length; ++u) {
var p = this._varyingNamesWGSL[u];
d += " output.".concat(p, " = ").concat(p, ";\n")
}
d += " return output;",
e = this._injectStartingAndEndingCode(e, "fn main", c, d),
t = (t = t.replace(/#define /g, "//#define ")).replace(/dpdy/g, "(-internals.yFactor__)*dpdy");
var f = "var ".concat(rh, " : vec4;\nvar ").concat(oh, " : bool;\nvar ").concat(sh, " : vec4;\nvar ").concat(ah, " : f32;\n")
, _ = "struct FragmentInputs {\n @builtin(position) position : vec4;\n @builtin(front_facing) frontFacing : bool;\n";
this._varyingsWGSL.length > 0 && (_ += this._varyingsWGSL.join("\n")),
_ += "\n};\n";
for (var m = "struct FragmentOutputs {\n @location(0) color : vec4;\n", g = !1, v = 0; !(g || (v = t.indexOf(ah, v)) < 0); ) {
var y = v;
for (g = !0; v > 1 && "\n" !== t.charAt(v); ) {
if ("/" === t.charAt(v) && "/" === t.charAt(v - 1)) {
g = !1;
break
}
v--
}
v = y + ah.length
}
g && (m += " @builtin(frag_depth) fragDepth: f32;\n"),
t = f + _ + r + (m += "};\n") + t;
var b = " var output : FragmentOutputs;\n ".concat(rh, " = input.position;\n ").concat(oh, " = input.frontFacing;\n") + i;
for (u = 0; u < this._varyingNamesWGSL.length; ++u) {
var T = this._varyingNamesWGSL[u];
b += " ".concat(T, " = input.").concat(T, ";\n")
}
var E = " output.color = ".concat(sh, ";\n");
return g && (E += " output.fragDepth = ".concat(ah, ";\n")),
E += " return output;",
t = this._injectStartingAndEndingCode(t, "fn main", b, E),
this._collectBindingNames(),
this._preCreateBindGroupEntries(),
{
vertexCode: e,
fragmentCode: t
}
}
,
t.prototype._generateLeftOverUBOCode = function(e, t) {
for (var i = "struct ".concat(e, " {\n"), n = 0, r = this._webgpuProcessingContext.leftOverUniforms; n < r.length; n++) {
var o = r[n]
, a = o.type.replace(/^(.*?)(<.*>)?$/, "$1")
, s = Qu.UniformSizes[a];
o.length > 0 ? i += s <= 2 ? " @align(16) ".concat(o.name, " : @stride(16) array<").concat(o.type, ", ").concat(o.length, ">;\n") : " ".concat(o.name, " : array<").concat(o.type, ", ").concat(o.length, ">;\n") : i += " ".concat(o.name, " : ").concat(o.type, ";\n")
}
return (i += "};\n") + "@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 n = i.exec(e);
if (null === n)
break;
var r = n[1]
, o = n[2]
, a = r.indexOf(Qu.AutoSamplerSuffix) === r.length - Qu.AutoSamplerSuffix.length ? r.substring(0, r.indexOf(Qu.AutoSamplerSuffix)) : null
, s = "sampler_comparison" === o ? Ru.Comparison : Ru.Filtering;
if (a) {
var l = this._webgpuProcessingContext.availableTextures[a];
l && (l.autoBindSampler = !0)
}
var c = this._webgpuProcessingContext.availableSamplers[r];
c || (c = {
binding: this._webgpuProcessingContext.getNextFreeUBOBinding(),
type: s
},
this._webgpuProcessingContext.availableSamplers[r] = c),
this._addSamplerBindingDescription(r, c, t);
var u = e.substring(0, n.index)
, h = "@group(".concat(c.binding.groupIndex, ") @binding(").concat(c.binding.bindingIndex, ") ")
, d = e.substring(n.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 n = i.exec(e);
if (null === n)
break;
var r = n[1]
, o = n[3]
, a = n[4]
, s = n[5]
, l = this._webgpuProcessingContext.availableBuffers[a];
if (!l) {
var c = "uniform" === r ? Ju.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 ? xu.Storage : "storage" === r ? xu.ReadOnlyStorage : xu.Uniform, t);
var h = l.binding.groupIndex
, d = l.binding.bindingIndex
, p = e.substring(0, n.index)
, f = "@group(".concat(h, ") @binding(").concat(d, ") ")
, _ = e.substring(n.index);
e = p + f + _,
i.lastIndex += f.length
}
return e
}
,
t
}(Qu), uh = function() {
function e(e) {
void 0 === e && (e = null),
this.format = bu.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
}),
Object.defineProperty(e.prototype, "msaaTexture", {
get: function() {
return this._webgpuMSAATexture
},
set: function(e) {
this._webgpuMSAATexture = e
},
enumerable: !1,
configurable: !0
}),
e.prototype.set = function(e) {
this._webgpuTexture = e
}
,
e.prototype.setUsage = function(e, t, i, n, r) {
t = e !== At.RenderTarget && t,
this.createView({
format: this.format,
dimension: i ? vu.Cube : vu.E2d,
mipLevelCount: t ? d.ILog2(Math.max(n, r)) + 1 : 1,
baseArrayLayer: 0,
baseMipLevel: 0,
arrayLayerCount: i ? 6 : 1,
aspect: yu.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, i;
null === (e = this._webgpuTexture) || void 0 === e || e.destroy(),
null === (t = this._webgpuMSAATexture) || void 0 === t || t.destroy(),
null === (i = this._copyInvertYTempTexture) || void 0 === i || i.destroy(),
this.reset()
}
,
e
}();
!function(e) {
e[e.MipMap = 0] = "MipMap",
e[e.InvertYPremultiplyAlpha = 1] = "InvertYPremultiplyAlpha",
e[e.Clear = 2] = "Clear",
e[e.InvertYPremultiplyAlphaWithOfst = 3] = "InvertYPremultiplyAlphaWithOfst"
}(eh || (eh = {}));
var hh, dh = [{
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: "\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 ",
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: "\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 ",
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 "
}], ph = {
"": 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,
"depth24unorm-stencil8": 37,
"depth32float-stencil8": 38
}, fh = function() {
function e(e, t, i, n) {
this._pipelines = {},
this._compiledShaders = [],
this._deferredReleaseTextures = [],
this._device = e,
this._glslang = t,
this._tintWASM = i,
this._bufferManager = n,
this._mipmapSampler = e.createSampler({
minFilter: Eu.Linear
}),
this._ubCopyWithOfst = this._bufferManager.createBuffer(16, fu.Uniform | fu.CopyDst).underlyingResource,
this._getPipeline(bu.RGBA8Unorm)
}
return e.ComputeNumMipmapLevels = function(e, t) {
return d.ILog2(Math.max(e, t)) + 1
}
,
e.prototype._getPipeline = function(e, t, i) {
void 0 === t && (t = eh.MipMap);
var n = t === eh.MipMap ? 1 : t === eh.InvertYPremultiplyAlpha ? ((i.invertY ? 1 : 0) << 1) + ((i.premultiplyAlpha ? 1 : 0) << 2) : t === eh.Clear ? 8 : t === eh.InvertYPremultiplyAlphaWithOfst ? ((i.invertY ? 1 : 0) << 4) + ((i.premultiplyAlpha ? 1 : 0) << 5) : 0;
this._pipelines[e] || (this._pipelines[e] = []);
var r = this._pipelines[e][n];
if (!r) {
var o = "#version 450\r\n";
t !== eh.InvertYPremultiplyAlpha && t !== eh.InvertYPremultiplyAlphaWithOfst || (i.invertY && (o += "#define INVERTY\r\n"),
i.premultiplyAlpha && (o += "#define PREMULTIPLYALPHA\r\n"));
var a = this._compiledShaders[n];
if (!a) {
var s = this._glslang.compileGLSL(o + dh[t].vertex, "vertex")
, l = this._glslang.compileGLSL(o + dh[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[n] = [c, u]
}
var h = this._device.createRenderPipeline({
vertex: {
module: a[0],
entryPoint: "main"
},
fragment: {
module: a[1],
entryPoint: "main",
targets: [{
format: e
}]
},
primitive: {
topology: Iu.TriangleStrip,
stripIndexFormat: Bu.Uint16
}
});
r = this._pipelines[e][n] = [h, h.getBindGroupLayout(0)]
}
return r
}
,
e._GetTextureTypeFromFormat = function(e) {
switch (e) {
case bu.R8Unorm:
case bu.R8Snorm:
case bu.R8Uint:
case bu.R8Sint:
case bu.RG8Unorm:
case bu.RG8Snorm:
case bu.RG8Uint:
case bu.RG8Sint:
case bu.RGBA8Unorm:
case bu.RGBA8UnormSRGB:
case bu.RGBA8Snorm:
case bu.RGBA8Uint:
case bu.RGBA8Sint:
case bu.BGRA8Unorm:
case bu.BGRA8UnormSRGB:
case bu.RGB10A2Unorm:
case bu.RGB9E5UFloat:
case bu.RG11B10UFloat:
case bu.Depth24UnormStencil8:
case bu.Depth32FloatStencil8:
case bu.BC7RGBAUnorm:
case bu.BC7RGBAUnormSRGB:
case bu.BC6HRGBUFloat:
case bu.BC6HRGBFloat:
case bu.BC5RGUnorm:
case bu.BC5RGSnorm:
case bu.BC3RGBAUnorm:
case bu.BC3RGBAUnormSRGB:
case bu.BC2RGBAUnorm:
case bu.BC2RGBAUnormSRGB:
case bu.BC4RUnorm:
case bu.BC4RSnorm:
case bu.BC1RGBAUnorm:
case bu.BC1RGBAUnormSRGB:
case bu.ETC2RGB8Unorm:
case bu.ETC2RGB8UnormSRGB:
case bu.ETC2RGB8A1Unorm:
case bu.ETC2RGB8A1UnormSRGB:
case bu.ETC2RGBA8Unorm:
case bu.ETC2RGBA8UnormSRGB:
case bu.EACR11Unorm:
case bu.EACR11Snorm:
case bu.EACRG11Unorm:
case bu.EACRG11Snorm:
case bu.ASTC4x4Unorm:
case bu.ASTC4x4UnormSRGB:
case bu.ASTC5x4Unorm:
case bu.ASTC5x4UnormSRGB:
case bu.ASTC5x5Unorm:
case bu.ASTC5x5UnormSRGB:
case bu.ASTC6x5Unorm:
case bu.ASTC6x5UnormSRGB:
case bu.ASTC6x6Unorm:
case bu.ASTC6x6UnormSRGB:
case bu.ASTC8x5Unorm:
case bu.ASTC8x5UnormSRGB:
case bu.ASTC8x6Unorm:
case bu.ASTC8x6UnormSRGB:
case bu.ASTC8x8Unorm:
case bu.ASTC8x8UnormSRGB:
case bu.ASTC10x5Unorm:
case bu.ASTC10x5UnormSRGB:
case bu.ASTC10x6Unorm:
case bu.ASTC10x6UnormSRGB:
case bu.ASTC10x8Unorm:
case bu.ASTC10x8UnormSRGB:
case bu.ASTC10x10Unorm:
case bu.ASTC10x10UnormSRGB:
case bu.ASTC12x10Unorm:
case bu.ASTC12x10UnormSRGB:
case bu.ASTC12x12Unorm:
case bu.ASTC12x12UnormSRGB:
return a.TEXTURETYPE_UNSIGNED_BYTE;
case bu.R16Uint:
case bu.R16Sint:
case bu.RG16Uint:
case bu.RG16Sint:
case bu.RGBA16Uint:
case bu.RGBA16Sint:
case bu.Depth16Unorm:
return a.TEXTURETYPE_UNSIGNED_SHORT;
case bu.R16Float:
case bu.RG16Float:
case bu.RGBA16Float:
return a.TEXTURETYPE_HALF_FLOAT;
case bu.R32Uint:
case bu.R32Sint:
case bu.RG32Uint:
case bu.RG32Sint:
case bu.RGBA32Uint:
case bu.RGBA32Sint:
return a.TEXTURETYPE_UNSIGNED_INTEGER;
case bu.R32Float:
case bu.RG32Float:
case bu.RGBA32Float:
case bu.Depth32Float:
return a.TEXTURETYPE_FLOAT;
case bu.Stencil8:
throw "No fixed size for Stencil8 format!";
case bu.Depth24Plus:
throw "No fixed size for Depth24Plus format!";
case bu.Depth24PlusStencil8:
throw "No fixed size for Depth24PlusStencil8 format!"
}
return a.TEXTURETYPE_UNSIGNED_BYTE
}
,
e._GetBlockInformationFromFormat = function(e) {
switch (e) {
case bu.R8Unorm:
case bu.R8Snorm:
case bu.R8Uint:
case bu.R8Sint:
return {
width: 1,
height: 1,
length: 1
};
case bu.R16Uint:
case bu.R16Sint:
case bu.R16Float:
case bu.RG8Unorm:
case bu.RG8Snorm:
case bu.RG8Uint:
case bu.RG8Sint:
return {
width: 1,
height: 1,
length: 2
};
case bu.R32Uint:
case bu.R32Sint:
case bu.R32Float:
case bu.RG16Uint:
case bu.RG16Sint:
case bu.RG16Float:
case bu.RGBA8Unorm:
case bu.RGBA8UnormSRGB:
case bu.RGBA8Snorm:
case bu.RGBA8Uint:
case bu.RGBA8Sint:
case bu.BGRA8Unorm:
case bu.BGRA8UnormSRGB:
case bu.RGB9E5UFloat:
case bu.RGB10A2Unorm:
case bu.RG11B10UFloat:
return {
width: 1,
height: 1,
length: 4
};
case bu.RG32Uint:
case bu.RG32Sint:
case bu.RG32Float:
case bu.RGBA16Uint:
case bu.RGBA16Sint:
case bu.RGBA16Float:
return {
width: 1,
height: 1,
length: 8
};
case bu.RGBA32Uint:
case bu.RGBA32Sint:
case bu.RGBA32Float:
return {
width: 1,
height: 1,
length: 16
};
case bu.Stencil8:
throw "No fixed size for Stencil8 format!";
case bu.Depth16Unorm:
return {
width: 1,
height: 1,
length: 2
};
case bu.Depth24Plus:
throw "No fixed size for Depth24Plus format!";
case bu.Depth24PlusStencil8:
throw "No fixed size for Depth24PlusStencil8 format!";
case bu.Depth32Float:
case bu.Depth24UnormStencil8:
return {
width: 1,
height: 1,
length: 4
};
case bu.Depth32FloatStencil8:
return {
width: 1,
height: 1,
length: 5
};
case bu.BC7RGBAUnorm:
case bu.BC7RGBAUnormSRGB:
case bu.BC6HRGBUFloat:
case bu.BC6HRGBFloat:
case bu.BC5RGUnorm:
case bu.BC5RGSnorm:
case bu.BC3RGBAUnorm:
case bu.BC3RGBAUnormSRGB:
case bu.BC2RGBAUnorm:
case bu.BC2RGBAUnormSRGB:
return {
width: 4,
height: 4,
length: 16
};
case bu.BC4RUnorm:
case bu.BC4RSnorm:
case bu.BC1RGBAUnorm:
case bu.BC1RGBAUnormSRGB:
case bu.ETC2RGB8Unorm:
case bu.ETC2RGB8UnormSRGB:
case bu.ETC2RGB8A1Unorm:
case bu.ETC2RGB8A1UnormSRGB:
case bu.EACR11Unorm:
case bu.EACR11Snorm:
return {
width: 4,
height: 4,
length: 8
};
case bu.ETC2RGBA8Unorm:
case bu.ETC2RGBA8UnormSRGB:
case bu.EACRG11Unorm:
case bu.EACRG11Snorm:
case bu.ASTC4x4Unorm:
case bu.ASTC4x4UnormSRGB:
return {
width: 4,
height: 4,
length: 16
};
case bu.ASTC5x4Unorm:
case bu.ASTC5x4UnormSRGB:
return {
width: 5,
height: 4,
length: 16
};
case bu.ASTC5x5Unorm:
case bu.ASTC5x5UnormSRGB:
return {
width: 5,
height: 5,
length: 16
};
case bu.ASTC6x5Unorm:
case bu.ASTC6x5UnormSRGB:
return {
width: 6,
height: 5,
length: 16
};
case bu.ASTC6x6Unorm:
case bu.ASTC6x6UnormSRGB:
return {
width: 6,
height: 6,
length: 16
};
case bu.ASTC8x5Unorm:
case bu.ASTC8x5UnormSRGB:
return {
width: 8,
height: 5,
length: 16
};
case bu.ASTC8x6Unorm:
case bu.ASTC8x6UnormSRGB:
return {
width: 8,
height: 6,
length: 16
};
case bu.ASTC8x8Unorm:
case bu.ASTC8x8UnormSRGB:
return {
width: 8,
height: 8,
length: 16
};
case bu.ASTC10x5Unorm:
case bu.ASTC10x5UnormSRGB:
return {
width: 10,
height: 5,
length: 16
};
case bu.ASTC10x6Unorm:
case bu.ASTC10x6UnormSRGB:
return {
width: 10,
height: 6,
length: 16
};
case bu.ASTC10x8Unorm:
case bu.ASTC10x8UnormSRGB:
return {
width: 10,
height: 8,
length: 16
};
case bu.ASTC10x10Unorm:
case bu.ASTC10x10UnormSRGB:
return {
width: 10,
height: 10,
length: 16
};
case bu.ASTC12x10Unorm:
case bu.ASTC12x10UnormSRGB:
return {
width: 12,
height: 10,
length: 16
};
case bu.ASTC12x12Unorm:
case bu.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 bu.BC7RGBAUnormSRGB:
case bu.BC7RGBAUnorm:
case bu.BC6HRGBFloat:
case bu.BC6HRGBUFloat:
case bu.BC5RGSnorm:
case bu.BC5RGUnorm:
case bu.BC4RSnorm:
case bu.BC4RUnorm:
case bu.BC3RGBAUnormSRGB:
case bu.BC3RGBAUnorm:
case bu.BC2RGBAUnormSRGB:
case bu.BC2RGBAUnorm:
case bu.BC1RGBAUnormSRGB:
case bu.BC1RGBAUnorm:
case bu.ETC2RGB8Unorm:
case bu.ETC2RGB8UnormSRGB:
case bu.ETC2RGB8A1Unorm:
case bu.ETC2RGB8A1UnormSRGB:
case bu.ETC2RGBA8Unorm:
case bu.ETC2RGBA8UnormSRGB:
case bu.EACR11Unorm:
case bu.EACR11Snorm:
case bu.EACRG11Unorm:
case bu.EACRG11Snorm:
case bu.ASTC4x4Unorm:
case bu.ASTC4x4UnormSRGB:
case bu.ASTC5x4Unorm:
case bu.ASTC5x4UnormSRGB:
case bu.ASTC5x5Unorm:
case bu.ASTC5x5UnormSRGB:
case bu.ASTC6x5Unorm:
case bu.ASTC6x5UnormSRGB:
case bu.ASTC6x6Unorm:
case bu.ASTC6x6UnormSRGB:
case bu.ASTC8x5Unorm:
case bu.ASTC8x5UnormSRGB:
case bu.ASTC8x6Unorm:
case bu.ASTC8x6UnormSRGB:
case bu.ASTC8x8Unorm:
case bu.ASTC8x8UnormSRGB:
case bu.ASTC10x5Unorm:
case bu.ASTC10x5UnormSRGB:
case bu.ASTC10x6Unorm:
case bu.ASTC10x6UnormSRGB:
case bu.ASTC10x8Unorm:
case bu.ASTC10x8UnormSRGB:
case bu.ASTC10x10Unorm:
case bu.ASTC10x10UnormSRGB:
case bu.ASTC12x10Unorm:
case bu.ASTC12x10UnormSRGB:
case bu.ASTC12x12Unorm:
case bu.ASTC12x12UnormSRGB:
return !0
}
return !1
}
,
e.GetWebGPUTextureFormat = function(e, t, i) {
switch (void 0 === i && (i = !1),
t) {
case a.TEXTUREFORMAT_DEPTH16:
return bu.Depth16Unorm;
case a.TEXTUREFORMAT_DEPTH24:
return bu.Depth24Plus;
case a.TEXTUREFORMAT_DEPTH24_STENCIL8:
return bu.Depth24PlusStencil8;
case a.TEXTUREFORMAT_DEPTH32_FLOAT:
return bu.Depth32Float;
case a.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM:
return i ? bu.BC7RGBAUnormSRGB : bu.BC7RGBAUnorm;
case a.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT:
return bu.BC6HRGBUFloat;
case a.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT:
return bu.BC6HRGBFloat;
case a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5:
return i ? bu.BC3RGBAUnormSRGB : bu.BC3RGBAUnorm;
case a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3:
return i ? bu.BC2RGBAUnormSRGB : bu.BC2RGBAUnorm;
case a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1:
case a.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1:
return i ? bu.BC1RGBAUnormSRGB : bu.BC1RGBAUnorm;
case a.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4:
return i ? bu.ASTC4x4UnormSRGB : bu.ASTC4x4Unorm;
case a.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL:
return i ? bu.ETC2RGB8UnormSRGB : bu.ETC2RGB8Unorm
}
switch (e) {
case a.TEXTURETYPE_BYTE:
switch (t) {
case a.TEXTUREFORMAT_RED:
return bu.R8Snorm;
case a.TEXTUREFORMAT_RG:
return bu.RG8Snorm;
case a.TEXTUREFORMAT_RGB:
throw "RGB format not supported in WebGPU";
case a.TEXTUREFORMAT_RED_INTEGER:
return bu.R8Sint;
case a.TEXTUREFORMAT_RG_INTEGER:
return bu.RG8Sint;
case a.TEXTUREFORMAT_RGB_INTEGER:
throw "RGB_INTEGER format not supported in WebGPU";
case a.TEXTUREFORMAT_RGBA_INTEGER:
return bu.RGBA8Sint;
default:
return bu.RGBA8Snorm
}
case a.TEXTURETYPE_UNSIGNED_BYTE:
switch (t) {
case a.TEXTUREFORMAT_RED:
return bu.R8Unorm;
case a.TEXTUREFORMAT_RG:
return bu.RG8Unorm;
case a.TEXTUREFORMAT_RGB:
throw "TEXTUREFORMAT_RGB format not supported in WebGPU";
case a.TEXTUREFORMAT_RGBA:
return i ? bu.RGBA8UnormSRGB : bu.RGBA8Unorm;
case a.TEXTUREFORMAT_BGRA:
return i ? bu.BGRA8UnormSRGB : bu.BGRA8Unorm;
case a.TEXTUREFORMAT_RED_INTEGER:
return bu.R8Uint;
case a.TEXTUREFORMAT_RG_INTEGER:
return bu.RG8Uint;
case a.TEXTUREFORMAT_RGB_INTEGER:
throw "RGB_INTEGER format not supported in WebGPU";
case a.TEXTUREFORMAT_RGBA_INTEGER:
return bu.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 bu.RGBA8Unorm
}
case a.TEXTURETYPE_SHORT:
switch (t) {
case a.TEXTUREFORMAT_RED_INTEGER:
return bu.R16Sint;
case a.TEXTUREFORMAT_RG_INTEGER:
return bu.RG16Sint;
case a.TEXTUREFORMAT_RGB_INTEGER:
throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";
case a.TEXTUREFORMAT_RGBA_INTEGER:
default:
return bu.RGBA16Sint
}
case a.TEXTURETYPE_UNSIGNED_SHORT:
switch (t) {
case a.TEXTUREFORMAT_RED_INTEGER:
return bu.R16Uint;
case a.TEXTUREFORMAT_RG_INTEGER:
return bu.RG16Uint;
case a.TEXTUREFORMAT_RGB_INTEGER:
throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";
case a.TEXTUREFORMAT_RGBA_INTEGER:
default:
return bu.RGBA16Uint
}
case a.TEXTURETYPE_INT:
switch (t) {
case a.TEXTUREFORMAT_RED_INTEGER:
return bu.R32Sint;
case a.TEXTUREFORMAT_RG_INTEGER:
return bu.RG32Sint;
case a.TEXTUREFORMAT_RGB_INTEGER:
throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";
case a.TEXTUREFORMAT_RGBA_INTEGER:
default:
return bu.RGBA32Sint
}
case a.TEXTURETYPE_UNSIGNED_INTEGER:
switch (t) {
case a.TEXTUREFORMAT_RED_INTEGER:
return bu.R32Uint;
case a.TEXTUREFORMAT_RG_INTEGER:
return bu.RG32Uint;
case a.TEXTUREFORMAT_RGB_INTEGER:
throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";
case a.TEXTUREFORMAT_RGBA_INTEGER:
default:
return bu.RGBA32Uint
}
case a.TEXTURETYPE_FLOAT:
switch (t) {
case a.TEXTUREFORMAT_RED:
return bu.R32Float;
case a.TEXTUREFORMAT_RG:
return bu.RG32Float;
case a.TEXTUREFORMAT_RGB:
throw "TEXTUREFORMAT_RGB format not supported in WebGPU";
case a.TEXTUREFORMAT_RGBA:
default:
return bu.RGBA32Float
}
case a.TEXTURETYPE_HALF_FLOAT:
switch (t) {
case a.TEXTUREFORMAT_RED:
return bu.R16Float;
case a.TEXTUREFORMAT_RG:
return bu.RG16Float;
case a.TEXTUREFORMAT_RGB:
throw "TEXTUREFORMAT_RGB format not supported in WebGPU";
case a.TEXTUREFORMAT_RGBA:
default:
return bu.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:
throw "TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV format not supported in WebGPU";
case a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
throw "TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV format not supported in WebGPU";
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 bu.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 bu.RGB10A2Unorm
}
}
return i ? bu.RGBA8UnormSRGB : bu.RGBA8Unorm
}
,
e.GetNumChannelsFromWebGPUTextureFormat = function(e) {
switch (e) {
case bu.R8Unorm:
case bu.R8Snorm:
case bu.R8Uint:
case bu.R8Sint:
case bu.BC4RUnorm:
case bu.BC4RSnorm:
case bu.R16Uint:
case bu.R16Sint:
case bu.Depth16Unorm:
case bu.R16Float:
case bu.R32Uint:
case bu.R32Sint:
case bu.R32Float:
case bu.Depth32Float:
case bu.Stencil8:
case bu.Depth24Plus:
case bu.EACR11Unorm:
case bu.EACR11Snorm:
return 1;
case bu.RG8Unorm:
case bu.RG8Snorm:
case bu.RG8Uint:
case bu.RG8Sint:
case bu.Depth24UnormStencil8:
case bu.Depth32FloatStencil8:
case bu.BC5RGUnorm:
case bu.BC5RGSnorm:
case bu.RG16Uint:
case bu.RG16Sint:
case bu.RG16Float:
case bu.RG32Uint:
case bu.RG32Sint:
case bu.RG32Float:
case bu.Depth24PlusStencil8:
case bu.EACRG11Unorm:
case bu.EACRG11Snorm:
return 2;
case bu.RGB9E5UFloat:
case bu.RG11B10UFloat:
case bu.BC6HRGBUFloat:
case bu.BC6HRGBFloat:
case bu.ETC2RGB8Unorm:
case bu.ETC2RGB8UnormSRGB:
return 3;
case bu.RGBA8Unorm:
case bu.RGBA8UnormSRGB:
case bu.RGBA8Snorm:
case bu.RGBA8Uint:
case bu.RGBA8Sint:
case bu.BGRA8Unorm:
case bu.BGRA8UnormSRGB:
case bu.RGB10A2Unorm:
case bu.BC7RGBAUnorm:
case bu.BC7RGBAUnormSRGB:
case bu.BC3RGBAUnorm:
case bu.BC3RGBAUnormSRGB:
case bu.BC2RGBAUnorm:
case bu.BC2RGBAUnormSRGB:
case bu.BC1RGBAUnorm:
case bu.BC1RGBAUnormSRGB:
case bu.RGBA16Uint:
case bu.RGBA16Sint:
case bu.RGBA16Float:
case bu.RGBA32Uint:
case bu.RGBA32Sint:
case bu.RGBA32Float:
case bu.ETC2RGB8A1Unorm:
case bu.ETC2RGB8A1UnormSRGB:
case bu.ETC2RGBA8Unorm:
case bu.ETC2RGBA8UnormSRGB:
case bu.ASTC4x4Unorm:
case bu.ASTC4x4UnormSRGB:
case bu.ASTC5x4Unorm:
case bu.ASTC5x4UnormSRGB:
case bu.ASTC5x5Unorm:
case bu.ASTC5x5UnormSRGB:
case bu.ASTC6x5Unorm:
case bu.ASTC6x5UnormSRGB:
case bu.ASTC6x6Unorm:
case bu.ASTC6x6UnormSRGB:
case bu.ASTC8x5Unorm:
case bu.ASTC8x5UnormSRGB:
case bu.ASTC8x6Unorm:
case bu.ASTC8x6UnormSRGB:
case bu.ASTC8x8Unorm:
case bu.ASTC8x8UnormSRGB:
case bu.ASTC10x5Unorm:
case bu.ASTC10x5UnormSRGB:
case bu.ASTC10x6Unorm:
case bu.ASTC10x6UnormSRGB:
case bu.ASTC10x8Unorm:
case bu.ASTC10x8UnormSRGB:
case bu.ASTC10x10Unorm:
case bu.ASTC10x10UnormSRGB:
case bu.ASTC12x10Unorm:
case bu.ASTC12x10UnormSRGB:
case bu.ASTC12x12Unorm:
case bu.ASTC12x12UnormSRGB:
return 4
}
throw "Unknown format ".concat(e, "!")
}
,
e.HasStencilAspect = function(e) {
switch (e) {
case bu.Stencil8:
case bu.Depth24UnormStencil8:
case bu.Depth32FloatStencil8:
case bu.Depth24PlusStencil8:
return !0
}
return !1
}
,
e.prototype.invertYPreMultiplyAlpha = function(t, i, n, r, 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, A = void 0 === f, x = this._getPipeline(r, S ? eh.InvertYPremultiplyAlphaWithOfst : eh.InvertYPremultiplyAlpha, {
invertY: o,
premultiplyAlpha: a
}), R = x[0], C = x[1];
if (s = Math.max(s, 0),
A && (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
, M = null !== (v = null == P ? void 0 : P._copyInvertYTempTexture) && void 0 !== v ? v : this.createTexture({
width: i,
height: n,
layers: 1
}, !1, !1, !1, !1, !1, r, 1, f, gu.CopySrc | gu.RenderAttachment | gu.TextureBinding)
, I = null !== (y = null == P ? void 0 : P._copyInvertYRenderPassDescr) && void 0 !== y ? y : {
colorAttachments: [{
view: M.createView({
format: r,
dimension: vu.E2d,
baseMipLevel: 0,
mipLevelCount: 1,
arrayLayerCount: 1,
baseArrayLayer: 0
}),
loadOp: zu.Load,
storeOp: Wu.Store
}]
}
, O = f.beginRenderPass(I)
, 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: r,
dimension: vu.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: M
}, {
texture: E,
mipLevel: l,
origin: {
x: 0,
y: 0,
z: s
}
}, {
width: i,
height: n,
depthOrArrayLayers: 1
}),
P ? (P._copyInvertYTempTexture = M,
P._copyInvertYRenderPassDescr = I,
S ? P._copyInvertYBindGroupWithOfst = D : P._copyInvertYBindGroup = D) : this._deferredReleaseTextures.push([M, null]),
null === (T = (b = f).popDebugGroup) || void 0 === T || T.call(b),
A && (this._device.queue.submit([f.finish()]),
f = null)
}
}
,
e.prototype.copyWithInvertY = function(e, t, i, n) {
var r, o, a, s, l = void 0 === n, c = this._getPipeline(t, eh.InvertYPremultiplyAlpha, {
invertY: !0,
premultiplyAlpha: !1
}), u = c[0], h = c[1];
l && (n = this._device.createCommandEncoder({})),
null === (o = (r = n).pushDebugGroup) || void 0 === o || o.call(r, "internal copy texture with invertY");
var d = n.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 = n).popDebugGroup) || void 0 === s || s.call(a),
l && (this._device.queue.submit([n.finish()]),
n = null)
}
,
e.prototype.createTexture = function(t, i, n, r, o, a, s, l, c, u, h) {
void 0 === i && (i = !1),
void 0 === n && (n = !1),
void 0 === r && (r = !1),
void 0 === o && (o = !1),
void 0 === a && (a = !1),
void 0 === s && (s = bu.RGBA8Unorm),
void 0 === l && (l = 1),
void 0 === u && (u = -1),
void 0 === h && (h = 0),
l > 1 && (l = 4);
var d = t.layers || 1
, p = {
width: t.width,
height: t.height,
depthOrArrayLayers: d
}
, f = e.IsCompressedFormat(s)
, _ = i ? e.ComputeNumMipmapLevels(t.width, t.height) : 1
, m = u >= 0 ? u : gu.CopySrc | gu.CopyDst | gu.TextureBinding;
h |= i && !f ? gu.CopySrc | gu.RenderAttachment : 0,
f || (h |= gu.RenderAttachment | gu.CopyDst);
var g = this._device.createTexture({
size: p,
dimension: a ? mu.E3d : mu.E2d,
format: s,
usage: m | h,
sampleCount: l,
mipLevelCount: _
});
return e.IsImageBitmap(t) && (this.updateTexture(t, g, t.width, t.height, d, s, 0, 0, r, o, 0, 0),
i && n && this.generateMipmaps(g, s, _, 0, c)),
g
}
,
e.prototype.createCubeTexture = function(t, i, n, r, o, a, s, l, c, u) {
void 0 === i && (i = !1),
void 0 === n && (n = !1),
void 0 === r && (r = !1),
void 0 === o && (o = !1),
void 0 === a && (a = bu.RGBA8Unorm),
void 0 === s && (s = 1),
void 0 === c && (c = -1),
void 0 === u && (u = 0),
s > 1 && (s = 4);
var h = e.IsImageBitmapArray(t) ? t[0].width : t.width
, d = e.IsImageBitmapArray(t) ? t[0].height : t.height
, p = e.IsCompressedFormat(a)
, f = i ? e.ComputeNumMipmapLevels(h, d) : 1
, _ = c >= 0 ? c : gu.CopySrc | gu.CopyDst | gu.TextureBinding;
u |= i && !p ? gu.CopySrc | gu.RenderAttachment : 0,
p || (u |= gu.RenderAttachment | gu.CopyDst);
var m = this._device.createTexture({
size: {
width: h,
height: d,
depthOrArrayLayers: 6
},
dimension: mu.E2d,
format: a,
usage: _ | u,
sampleCount: s,
mipLevelCount: f
});
return e.IsImageBitmapArray(t) && (this.updateCubeTextures(t, m, h, d, a, r, o, 0, 0),
i && n && this.generateCubeMipmaps(m, a, f, l)),
m
}
,
e.prototype.generateCubeMipmaps = function(e, t, i, n) {
var r, o, a, s, l = void 0 === n;
l && (n = this._device.createCommandEncoder({})),
null === (o = (r = n).pushDebugGroup) || void 0 === o || o.call(r, "create cube mipmaps - ".concat(i, " levels"));
for (var c = 0; c < 6; ++c)
this.generateMipmaps(e, t, i, c, n);
null === (s = (a = n).popDebugGroup) || void 0 === s || s.call(a),
l && (this._device.queue.submit([n.finish()]),
n = null)
}
,
e.prototype.generateMipmaps = function(t, i, n, r, o) {
var a, s, l, c, u, h, d, p;
void 0 === r && (r = 0);
var f, _ = void 0 === o, m = this._getPipeline(i), g = m[0], v = m[1];
if (r = Math.max(r, 0),
_ && (o = this._device.createCommandEncoder({})),
null === (s = (a = o).pushDebugGroup) || void 0 === s || s.call(a, "create mipmaps for face #".concat(r, " - ").concat(n, " 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 < n; ++b) {
var T = null !== (c = null === (l = null == y ? void 0 : y._mipmapGenRenderPassDescr[r]) || void 0 === l ? void 0 : l[b - 1]) && void 0 !== c ? c : {
colorAttachments: [{
view: f.createView({
format: i,
dimension: vu.E2d,
baseMipLevel: b,
mipLevelCount: 1,
arrayLayerCount: 1,
baseArrayLayer: r
}),
loadOp: zu.Load,
storeOp: Wu.Store
}]
};
y && (y._mipmapGenRenderPassDescr[r] = y._mipmapGenRenderPassDescr[r] || [],
y._mipmapGenRenderPassDescr[r][b - 1] = T);
var E = o.beginRenderPass(T)
, S = null !== (h = null === (u = null == y ? void 0 : y._mipmapGenBindGroup[r]) || 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: vu.E2d,
baseMipLevel: b - 1,
mipLevelCount: 1,
arrayLayerCount: 1,
baseArrayLayer: r
})
}]
});
y && (y._mipmapGenBindGroup[r] = y._mipmapGenBindGroup[r] || [],
y._mipmapGenBindGroup[r][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, n, r, o) {
t._hardwareTexture || (t._hardwareTexture = new uh),
void 0 === i && (i = t.width),
void 0 === n && (n = t.height),
void 0 === r && (r = 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 === At.RenderTarget || t.source === At.MultiRenderTarget ? gu.TextureBinding | gu.CopySrc | gu.RenderAttachment : t._source === At.DepthStencil ? gu.TextureBinding | gu.RenderAttachment : -1,
s.textureAdditionalUsages = l ? gu.StorageBinding : 0;
var c, u = t.generateMipMaps, h = r || 1;
if (c = null !== t._maxLodLevel ? t._maxLodLevel : u ? e.ComputeNumMipmapLevels(i, n) : 1,
t.isCube) {
var d = this.createCubeTexture({
width: i,
height: n
}, t.generateMipMaps, t.generateMipMaps, t.invertY, !1, s.format, 1, this._commandEncoderForCreation, s.textureUsages, s.textureAdditionalUsages);
s.set(d),
s.createView({
format: s.format,
dimension: vu.Cube,
mipLevelCount: c,
baseArrayLayer: 0,
baseMipLevel: 0,
arrayLayerCount: 6,
aspect: yu.All
}, l)
} else
d = this.createTexture({
width: i,
height: n,
layers: h
}, t.generateMipMaps, t.generateMipMaps, t.invertY, !1, t.is3D, s.format, 1, this._commandEncoderForCreation, s.textureUsages, s.textureAdditionalUsages),
s.set(d),
s.createView({
format: s.format,
dimension: t.is2DArray ? vu.E2dArray : t.is3D ? mu.E3d : vu.E2d,
mipLevelCount: c,
baseArrayLayer: 0,
baseMipLevel: 0,
arrayLayerCount: t.is3D ? 1 : h,
aspect: yu.All
}, l);
return t.width = t.baseWidth = i,
t.height = t.baseHeight = n,
t.depth = t.baseDepth = r,
this.createMSAATexture(t, t.samples),
s
}
,
e.prototype.createMSAATexture = function(e, t) {
var i = e._hardwareTexture;
if ((null == i ? void 0 : i.msaaTexture) && (this.releaseTexture(i.msaaTexture),
i.msaaTexture = null),
i && !((null != t ? t : 1) <= 1)) {
var n = e.width
, r = e.height
, o = e.depth || 1;
if (e.isCube) {
var a = this.createCubeTexture({
width: n,
height: r
}, !1, !1, e.invertY, !1, i.format, t, this._commandEncoderForCreation, i.textureUsages, i.textureAdditionalUsages);
i.msaaTexture = a
} else
a = this.createTexture({
width: n,
height: r,
layers: o
}, !1, !1, e.invertY, !1, e.is3D, i.format, t, this._commandEncoderForCreation, i.textureUsages, i.textureAdditionalUsages),
i.msaaTexture = a
}
}
,
e.prototype.updateCubeTextures = function(e, t, i, n, r, 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, n, 1, r, u, 0, o, a, s, l)
}
}
,
e.prototype.updateTexture = function(t, i, n, r, 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(n / _.width) * _.width,
height: Math.ceil(r / _.height) * _.height,
depthOrArrayLayers: o || 1
};
if (void 0 !== t.byteLength) {
t = t;
var y = Math.ceil(n / _.width) * _.length;
if (256 * Math.ceil(y / 256) === y) {
var b = this._device.createCommandEncoder({})
, T = this._bufferManager.createRawBuffer(t.byteLength, fu.MapWrite | fu.CopySrc, !0)
, E = T.getMappedRange();
new Uint8Array(E).set(t),
T.unmap(),
b.copyBufferToTexture({
buffer: T,
offset: 0,
bytesPerRow: y,
rowsPerImage: r
}, g, v),
this._device.queue.submit([b.finish()]),
this._bufferManager.releaseBuffer(T)
} else
this._device.queue.writeTexture(g, t, {
offset: 0,
bytesPerRow: y,
rowsPerImage: r
}, 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 && n === i.width && r === i.height;
this.invertYPreMultiplyAlpha(m, i.width, i.height, a, c, u, s, l, o || 1, h, d, S ? 0 : n, S ? 0 : r, void 0, p)
}
} else if (t = t,
c)
if (g.premultipliedAlpha = !1,
e._IsInternalTexture(i) && 0 === h && 0 === d && n === i.width && r === i.height)
this._device.queue.copyExternalImageToTexture({
source: t
}, g, v),
this.invertYPreMultiplyAlpha(m, n, r, a, c, u, s, l, o || 1, 0, 0, 0, 0, void 0, p);
else {
b = this._device.createCommandEncoder({});
var A = this.createTexture({
width: n,
height: r,
layers: 1
}, !1, !1, !1, !1, !1, a, 1, b, gu.CopySrc | gu.TextureBinding);
this._deferredReleaseTextures.push([A, null]),
v.depthOrArrayLayers = 1,
this._device.queue.copyExternalImageToTexture({
source: t
}, {
texture: A
}, v),
v.depthOrArrayLayers = o || 1,
this.invertYPreMultiplyAlpha(A, n, r, a, c, u, s, l, o || 1, 0, 0, 0, 0, b, p),
b.copyTextureToTexture({
texture: A
}, g, v),
this._device.queue.submit([b.finish()])
}
else
this._device.queue.copyExternalImageToTexture({
source: t
}, g, v)
}
,
e.prototype.readPixels = function(t, i, n, r, 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(r / h.width) * h.length
, p = 256 * Math.ceil(d / 256)
, f = p * o
, _ = this._bufferManager.createRawBuffer(f, fu.MapRead | fu.CopyDst)
, m = this._device.createCommandEncoder({});
return m.copyTextureToBuffer({
texture: t,
mipLevel: l,
origin: {
x: i,
y: n,
z: Math.max(s, 0)
}
}, {
buffer: _,
offset: 0,
bytesPerRow: p
}, {
width: r,
height: o,
depthOrArrayLayers: 1
}),
this._device.queue.submit([m.finish()]),
this._bufferManager.readDataFromBuffer(_, f, r, o, d, p, e._GetTextureTypeFromFormat(a), 0, c, !0, u)
}
,
e.prototype.releaseTexture = function(t) {
if (e._IsInternalTexture(t)) {
var i = t._hardwareTexture
, n = t._irradianceTexture;
this._deferredReleaseTextures.push([i, n])
} else
this._deferredReleaseTextures.push([t, null])
}
,
e.prototype.destroyDeferredTextures = function() {
for (var t = 0; t < this._deferredReleaseTextures.length; ++t) {
var i = this._deferredReleaseTextures[t]
, n = i[0]
, r = i[1];
n && (e._IsHardwareTexture(n) ? n.release() : n.destroy()),
null == r || r.dispose()
}
this._deferredReleaseTextures.length = 0
}
,
e
}(), _h = function(e) {
function t(t) {
var i = e.call(this) || this;
return i._buffer = t,
i
}
return U(t, e),
Object.defineProperty(t.prototype, "underlyingResource", {
get: function() {
return this._buffer
},
enumerable: !1,
configurable: !0
}),
t
}(Bt), mh = 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 n = {
mappedAtCreation: i,
size: void 0 !== e.byteLength ? e.byteLength + 3 & -4 : e + 3 & -4,
usage: t
};
return this._device.createBuffer(n)
}
,
e.prototype.createBuffer = function(e, t) {
var i = void 0 !== e.byteLength
, n = this.createRawBuffer(e, t)
, r = new _h(n);
return r.references = 1,
r.capacity = i ? e.byteLength : e,
i && this.setSubData(r, 0, e),
r
}
,
e.prototype.setRawData = function(e, t, i, n, r) {
this._device.queue.writeBuffer(e, t, i.buffer, n, r)
}
,
e.prototype.setSubData = function(e, t, i, n, r) {
void 0 === n && (n = 0),
void 0 === r && (r = 0);
var o = e.underlyingResource;
r = r || i.byteLength,
r = Math.min(r, e.capacity - t);
var a = i.byteOffset + n
, s = a + r
, l = r + 3 & -4;
if (l !== r) {
var c = new Uint8Array(i.buffer.slice(a, s));
(i = new Uint8Array(l)).set(c),
n = 0,
a = 0,
s = l,
r = 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, r - h)
}
,
e.prototype._getHalfFloatAsFloatRGBAArrayBuffer = function(e, t, i) {
i || (i = new Float32Array(e));
for (var n = new Uint16Array(t); e--; )
i[e] = Dc(n[e]);
return i
}
,
e.prototype.readDataFromBuffer = function(e, t, i, n, r, 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(_u.Read, l, t).then((function() {
var a = e.getMappedRange(l, t)
, f = c;
if (h)
f = null === f ? gr(s, t, !0, a) : gr(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 (r !== o) {
1 !== p || h || (r *= 2,
o *= 2);
for (var _ = new Uint8Array(f.buffer), m = r, g = 0, v = 1; v < n; ++v) {
g = v * o;
for (var y = 0; y < r; ++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
}(), gh = 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
}(), vh = [0, 0, 3, 7, 0, 2, 6, 2, 4, 1, 5, 3, 1], yh = [0, 64, 32, 96, 16, 80, 48, 112, 8], bh = [0, 128, 128, 0, 0, 0, 0, 128, 0, 0, 0, 0, 128], Th = function() {
function e(e) {
this._samplers = {},
this._device = e,
this.disabled = !1
}
return e.GetSamplerHashCode = function(e) {
var t, i, n, r = e._cachedAnisotropicFilteringLevel && e._cachedAnisotropicFilteringLevel > 1 ? 4 : 1;
return vh[e.samplingMode] + yh[(e._comparisonFunction || 514) - 512 + 1] + bh[e.samplingMode] + ((null !== (t = e._cachedWrapU) && void 0 !== t ? t : 1) << 8) + ((null !== (i = e._cachedWrapV) && void 0 !== i ? i : 1) << 10) + ((null !== (n = e._cachedWrapR) && void 0 !== n ? n : 1) << 12) + ((e.useMipMaps ? 1 : 0) << 14) + (r << 15)
}
,
e._GetSamplerFilterDescriptor = function(e, t) {
var i, n, r, o, s, l = e.useMipMaps;
switch (e.samplingMode) {
case a.TEXTURE_LINEAR_LINEAR_MIPNEAREST:
i = Eu.Linear,
n = Eu.Linear,
r = Eu.Nearest,
l || (o = s = 0);
break;
case a.TEXTURE_LINEAR_LINEAR_MIPLINEAR:
case a.TEXTURE_TRILINEAR_SAMPLINGMODE:
i = Eu.Linear,
n = Eu.Linear,
l ? r = Eu.Linear : (r = Eu.Nearest,
o = s = 0);
break;
case a.TEXTURE_NEAREST_NEAREST_MIPLINEAR:
i = Eu.Nearest,
n = Eu.Nearest,
l ? r = Eu.Linear : (r = Eu.Nearest,
o = s = 0);
break;
case a.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
i = Eu.Nearest,
n = Eu.Nearest,
r = Eu.Nearest,
l || (o = s = 0);
break;
case a.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
i = Eu.Nearest,
n = Eu.Linear,
r = Eu.Nearest,
l || (o = s = 0);
break;
case a.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
i = Eu.Nearest,
n = Eu.Linear,
l ? r = Eu.Linear : (r = Eu.Nearest,
o = s = 0);
break;
case a.TEXTURE_NEAREST_LINEAR:
i = Eu.Nearest,
n = Eu.Linear,
r = Eu.Nearest,
o = s = 0;
break;
case a.TEXTURE_NEAREST_NEAREST:
case a.TEXTURE_NEAREST_SAMPLINGMODE:
i = Eu.Nearest,
n = Eu.Nearest,
r = Eu.Nearest,
o = s = 0;
break;
case a.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
i = Eu.Linear,
n = Eu.Nearest,
r = Eu.Nearest,
l || (o = s = 0);
break;
case a.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
i = Eu.Linear,
n = Eu.Nearest,
l ? r = Eu.Linear : (r = Eu.Nearest,
o = s = 0);
break;
case a.TEXTURE_LINEAR_LINEAR:
case a.TEXTURE_BILINEAR_SAMPLINGMODE:
i = Eu.Linear,
n = Eu.Linear,
r = Eu.Nearest,
o = s = 0;
break;
case a.TEXTURE_LINEAR_NEAREST:
i = Eu.Linear,
n = Eu.Nearest,
r = Eu.Nearest,
o = s = 0;
break;
default:
i = Eu.Nearest,
n = Eu.Nearest,
r = Eu.Nearest,
o = s = 0
}
return t > 1 && (0 !== o || 0 !== s) ? {
magFilter: Eu.Linear,
minFilter: Eu.Linear,
mipmapFilter: Eu.Linear,
anisotropyEnabled: !0
} : {
magFilter: i,
minFilter: n,
mipmapFilter: r,
lodMinClamp: o,
lodMaxClamp: s
}
}
,
e._GetWrappingMode = function(e) {
switch (e) {
case a.TEXTURE_WRAP_ADDRESSMODE:
return Tu.Repeat;
case a.TEXTURE_CLAMP_ADDRESSMODE:
return Tu.ClampToEdge;
case a.TEXTURE_MIRROR_ADDRESSMODE:
return Tu.MirrorRepeat
}
return Tu.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
, n = this._GetSamplerFilterDescriptor(t, i);
return V(V(V({}, n), this._GetSamplerWrappingDescriptor(t)), {
compare: t._comparisonFunction ? e.GetCompareFunction(t._comparisonFunction) : void 0,
maxAnisotropy: n.anisotropyEnabled ? i : 1
})
}
,
e.GetCompareFunction = function(e) {
switch (e) {
case a.ALWAYS:
return Su.Always;
case a.EQUAL:
return Su.Equal;
case a.GREATER:
return Su.Greater;
case a.GEQUAL:
return Su.GreaterEqual;
case a.LESS:
return Su.Less;
case a.LEQUAL:
return Su.LessEqual;
case a.NEVER:
return Su.Never;
case a.NOTEQUAL:
return Su.NotEqual;
default:
return Su.Less
}
}
,
e.prototype.getSampler = function(t, i, n) {
if (void 0 === i && (i = !1),
void 0 === n && (n = 0),
this.disabled)
return this._device.createSampler(e._GetSamplerDescriptor(t));
i ? n = 0 : 0 === n && (n = e.GetSamplerHashCode(t));
var r = i ? void 0 : this._samplers[n];
return r || (r = this._device.createSampler(e._GetSamplerDescriptor(t)),
i || (this._samplers[n] = r)),
r
}
,
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"
}(hh || (hh = {}));
var Eh = {
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
}
, Sh = {
0: 0,
7680: 1,
7681: 2,
7682: 3,
7683: 4,
5386: 5,
34055: 6,
34056: 7
}
, Ah = 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 = [bu.BGRA8Unorm],
this.setColorFormat(bu.BGRA8Unorm),
this.setMRT([]),
this.setAlphaBlendEnabled(!1),
this.setAlphaBlendFactors([null, null, null, null], [null, null]),
this.setWriteMask(15),
this.setDepthStencilFormat(bu.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, n, r) {
if (void 0 === r && (r = 0),
n > 1 && (n = 4),
this.disabled) {
var o = e._GetTopology(t);
return this._setVertexState(i),
this._parameter.pipeline = this._createRenderPipeline(i, o, n),
e.NumCacheMiss++,
e._NumPipelineCreationCurrentFrame++,
this._parameter.pipeline
}
if (this._setShaderStage(i.uniqueId),
this._setRasterizationState(t, n),
this._setColorStates(),
this._setDepthStencilState(),
this._setVertexState(i),
this._setTextureState(r),
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, n),
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, n, r, 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(n),
this.setDepthBias(r)
}
,
e.prototype.setDepthBias = function(e) {
this._depthBias !== e && (this._depthBias = e,
this._states[hh.DepthBias] = e,
this._isDirty = !0,
this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.DepthBias))
}
,
e.prototype.setDepthBiasSlopeScale = function(e) {
this._depthBiasSlopeScale !== e && (this._depthBiasSlopeScale = e,
this._states[hh.DepthBiasSlopeScale] = e,
this._isDirty = !0,
this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.DepthBiasSlopeScale))
}
,
e.prototype.setColorFormat = function(e) {
this._webgpuColorFormat[0] = e,
this._colorFormat = ph[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, hh.MRTAttachments1))
}
,
e.prototype.setMRT = function(e, t) {
var i;
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], r = 0, o = 0, a = 0, s = 0; s < t; ++s) {
var l = e[s]
, c = null == l ? void 0 : l._hardwareTexture;
this._mrtFormats[a] = null !== (i = null == c ? void 0 : c.format) && void 0 !== i ? i : this._webgpuColorFormat[0],
n[r] += ph[this._mrtFormats[a]] << o,
a++,
(o += 6) >= 32 && (o = 0,
r++)
}
this._mrtFormats.length = a,
this._mrtAttachments1 === n[0] && this._mrtAttachments2 === n[1] || (this._mrtAttachments1 = n[0],
this._mrtAttachments2 = n[1],
this._states[hh.MRTAttachments1] = n[0],
this._states[hh.MRTAttachments2] = n[1],
this._isDirty = !0,
this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.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 : ph[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 : Sh[e]
}
,
e.prototype.setStencilPassOp = function(e) {
this._stencilFrontPassOp = null === e ? 2 : Sh[e]
}
,
e.prototype.setStencilFailOp = function(e) {
this._stencilFrontFailOp = null === e ? 1 : Sh[e]
}
,
e.prototype.setStencilReadMask = function(e) {
this._stencilReadMask !== e && (this._stencilReadMask = e,
this._states[hh.StencilReadMask] = e,
this._isDirty = !0,
this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.StencilReadMask))
}
,
e.prototype.setStencilWriteMask = function(e) {
this._stencilWriteMask !== e && (this._stencilWriteMask = e,
this._states[hh.StencilWriteMask] = e,
this._isDirty = !0,
this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.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, n, r, o, s) {
this._stencilEnabled = e,
this._stencilFrontCompare = (null != t ? t : a.ALWAYS) - 512,
this._stencilFrontDepthFailOp = null === i ? 1 : Sh[i],
this._stencilFrontPassOp = null === n ? 2 : Sh[n],
this._stencilFrontFailOp = null === r ? 1 : Sh[r],
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 Iu.TriangleList;
case a.MATERIAL_PointFillMode:
return Iu.PointList;
case a.MATERIAL_WireFrameFillMode:
return Iu.LineList;
case a.MATERIAL_PointListDrawMode:
return Iu.PointList;
case a.MATERIAL_LineListDrawMode:
return Iu.LineList;
case a.MATERIAL_LineLoopDrawMode:
throw "LineLoop is an unsupported fillmode in WebGPU";
case a.MATERIAL_LineStripDrawMode:
return Iu.LineStrip;
case a.MATERIAL_TriangleStripDrawMode:
return Iu.TriangleStrip;
case a.MATERIAL_TriangleFanDrawMode:
throw "TriangleFan is an unsupported fillmode in WebGPU";
default:
return Iu.TriangleList
}
}
,
e._GetAphaBlendOperation = function(e) {
switch (e) {
case a.GL_ALPHA_EQUATION_ADD:
return Fu.Add;
case a.GL_ALPHA_EQUATION_SUBTRACT:
return Fu.Subtract;
case a.GL_ALPHA_EQUATION_REVERSE_SUBTRACT:
return Fu.ReverseSubtract;
case a.GL_ALPHA_EQUATION_MIN:
return Fu.Min;
case a.GL_ALPHA_EQUATION_MAX:
return Fu.Max;
default:
return Fu.Add
}
}
,
e._GetAphaBlendFactor = function(e) {
switch (e) {
case 0:
return Lu.Zero;
case 1:
return Lu.One;
case a.GL_ALPHA_FUNCTION_SRC:
return Lu.Src;
case a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR:
return Lu.OneMinusSrc;
case a.GL_ALPHA_FUNCTION_SRC_ALPHA:
return Lu.SrcAlpha;
case a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA:
return Lu.OneMinusSrcAlpha;
case a.GL_ALPHA_FUNCTION_DST_ALPHA:
return Lu.DstAlpha;
case a.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA:
return Lu.OneMinusDstAlpha;
case a.GL_ALPHA_FUNCTION_DST_COLOR:
return Lu.Dst;
case a.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR:
return Lu.OneMinusDst;
case a.GL_ALPHA_FUNCTION_SRC_ALPHA_SATURATED:
return Lu.SrcAlphaSaturated;
case a.GL_ALPHA_FUNCTION_CONSTANT_COLOR:
return Lu.Constant;
case a.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR:
return Lu.OneMinusConstant;
case a.GL_ALPHA_FUNCTION_CONSTANT_ALPHA:
return Lu.Constant;
case a.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA:
return Lu.OneMinusConstant;
default:
return Lu.One
}
}
,
e._GetCompareFunction = function(e) {
switch (e) {
case 0:
return Su.Never;
case 1:
return Su.Less;
case 2:
return Su.Equal;
case 3:
return Su.LessEqual;
case 4:
return Su.Greater;
case 5:
return Su.NotEqual;
case 6:
return Su.GreaterEqual;
case 7:
return Su.Always
}
return Su.Never
}
,
e._GetStencilOpFunction = function(e) {
switch (e) {
case 0:
return wu.Zero;
case 1:
return wu.Keep;
case 2:
return wu.Replace;
case 3:
return wu.IncrementClamp;
case 4:
return wu.DecrementClamp;
case 5:
return wu.Invert;
case 6:
return wu.IncrementWrap;
case 7:
return wu.DecrementWrap
}
return wu.Keep
}
,
e._GetVertexInputDescriptorFormat = function(e) {
var t = e.type
, i = e.normalized
, n = e.getSize();
switch (t) {
case Bi.BYTE:
switch (n) {
case 1:
case 2:
return i ? Uu.Snorm8x2 : Uu.Sint8x2;
case 3:
case 4:
return i ? Uu.Snorm8x4 : Uu.Sint8x4
}
break;
case Bi.UNSIGNED_BYTE:
switch (n) {
case 1:
case 2:
return i ? Uu.Unorm8x2 : Uu.Uint8x2;
case 3:
case 4:
return i ? Uu.Unorm8x4 : Uu.Uint8x4
}
break;
case Bi.SHORT:
switch (n) {
case 1:
case 2:
return i ? Uu.Snorm16x2 : Uu.Sint16x2;
case 3:
case 4:
return i ? Uu.Snorm16x4 : Uu.Sint16x4
}
break;
case Bi.UNSIGNED_SHORT:
switch (n) {
case 1:
case 2:
return i ? Uu.Unorm16x2 : Uu.Uint16x2;
case 3:
case 4:
return i ? Uu.Unorm16x4 : Uu.Uint16x4
}
break;
case Bi.INT:
switch (n) {
case 1:
return Uu.Sint32;
case 2:
return Uu.Sint32x2;
case 3:
return Uu.Sint32x3;
case 4:
return Uu.Sint32x4
}
break;
case Bi.UNSIGNED_INT:
switch (n) {
case 1:
return Uu.Uint32;
case 2:
return Uu.Uint32x2;
case 3:
return Uu.Uint32x3;
case 4:
return Uu.Uint32x4
}
break;
case Bi.FLOAT:
switch (n) {
case 1:
return Uu.Float32;
case 2:
return Uu.Float32x2;
case 3:
return Uu.Float32x3;
case 4:
return Uu.Float32x4
}
}
throw new Error("Invalid Format '".concat(e.getKind(), "' - type=").concat(t, ", normalized=").concat(i, ", size=").concat(n))
}
,
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[hh.ShaderStage] = e,
this._isDirty = !0,
this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.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[hh.RasterizationState] = this._rasterizationState,
this._isDirty = !0,
this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.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 : Eh[this._alphaBlendFuncParams[0]]) << 0) + ((null === this._alphaBlendFuncParams[1] ? 2 : Eh[this._alphaBlendFuncParams[1]]) << 4) + ((null === this._alphaBlendFuncParams[2] ? 2 : Eh[this._alphaBlendFuncParams[2]]) << 8) + ((null === this._alphaBlendFuncParams[3] ? 2 : Eh[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[hh.ColorStates] = this._colorStates,
this._isDirty = !0,
this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.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[hh.DepthStencilState] = this._depthStencilState,
this._isDirty = !0,
this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.DepthStencilState))
}
,
e.prototype._setVertexState = function(e) {
for (var t, i, n, r = this._statesLength, o = hh.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)
}
n && n === p && d._validOffsetRange || (this.vertexBuffers[c++] = d,
n = 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 !== r,
this._isDirty && (this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.VertexState))
}
,
e.prototype._setTextureState = function(e) {
this._textureState !== e && (this._textureState = e,
this._states[hh.TextureStage] = this._textureState,
this._isDirty = !0,
this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.TextureStage))
}
,
e.prototype._createPipelineLayout = function(e) {
if (this._useTextureStage)
return this._createPipelineLayoutWithTextureStage(e);
for (var t = [], i = e.shaderProcessingContext.bindGroupLayoutEntries, n = 0; n < i.length; n++) {
var r = i[n];
t[n] = this._device.createBindGroupLayout({
entries: r
})
}
return e.bindGroupLayouts = t,
this._device.createPipelineLayout({
bindGroupLayouts: t
})
}
,
e.prototype._createPipelineLayoutWithTextureStage = function(e) {
for (var t, i = e.shaderProcessingContext, n = i.bindGroupLayoutEntries, r = 1, o = 0; o < n.length; o++)
for (var a = n[o], s = 0; s < a.length; s++) {
var l = n[o][s];
if (l.texture) {
var c = i.bindGroupLayoutEntryInfo[o][l.binding].name
, u = i.availableTextures[c]
, h = u.autoBindSampler ? i.availableSamplers[c + Qu.AutoSamplerSuffix] : null
, d = u.sampleType
, p = null !== (t = null == h ? void 0 : h.type) && void 0 !== t ? t : Ru.Filtering;
if (this._textureState & r && d !== Cu.Depth && (u.autoBindSampler && (p = Ru.NonFiltering),
d = Cu.UnfilterableFloat),
l.texture.sampleType = d,
h) {
var f = i.bindGroupLayoutEntryInfo[h.binding.groupIndex][h.binding.bindingIndex].index;
n[h.binding.groupIndex][f].sampler.type = p
}
r <<= 1
}
}
var _ = [];
for (o = 0; o < n.length; ++o)
_[o] = this._device.createBindGroupLayout({
entries: n[o]
});
return e.bindGroupLayouts = _,
this._device.createPipelineLayout({
bindGroupLayouts: _
})
}
,
e.prototype._getVertexInputDescriptor = function(t) {
for (var i, n, r, 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 === (n = d.getBuffer()) || void 0 === n ? void 0 : n.underlyingResource
, f = d.byteOffset
, _ = !d._validOffsetRange;
if (!r || !o || r !== p || _) {
var m = {
arrayStride: d.byteStride,
stepMode: d.getIsInstanced() ? Vu.Instance : Vu.Vertex,
attributes: []
};
a.push(m),
o = m.attributes,
_ && (f = 0,
p = null)
}
o.push({
shaderLocation: h,
offset: f,
format: e._GetVertexInputDescriptorFormat(d)
}),
r = p
}
return a
}
,
e.prototype._createRenderPipeline = function(t, i, n) {
var r = t._pipelineContext
, o = this._getVertexInputDescriptor(t)
, a = this._createPipelineLayout(r)
, s = []
, l = this._getAphaBlendState()
, c = this._getColorBlendState();
if (this._mrtAttachments1 > 0)
for (var u = 0; u < this._mrtFormats.length; ++u) {
var h = {
format: this._mrtFormats[u],
writeMask: 0 != (this._mrtEnabledMask & 1 << u) ? this._writeMask : 0
};
l && c && (h.blend = {
alpha: l,
color: c
}),
s.push(h)
}
else
h = {
format: this._webgpuColorFormat[0],
writeMask: this._writeMask
},
l && c && (h.blend = {
alpha: l,
color: c
}),
s.push(h);
var d = {
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)
}
, p = void 0;
i !== Iu.LineStrip && i !== Iu.TriangleStrip || (p = !this._indexBuffer || this._indexBuffer.is32Bits ? Bu.Uint32 : Bu.Uint16);
var f = !!this._webgpuDepthStencilFormat && fh.HasStencilAspect(this._webgpuDepthStencilFormat);
return this._device.createRenderPipeline({
layout: a,
vertex: {
module: r.stages.vertexStage.module,
entryPoint: r.stages.vertexStage.entryPoint,
buffers: o
},
primitive: {
topology: i,
stripIndexFormat: p,
frontFace: 1 === this._frontFace ? Ou.CCW : Ou.CW,
cullMode: this._cullEnabled ? 2 === this._cullFace ? Du.Front : Du.Back : Du.None
},
fragment: r.stages.fragmentStage ? {
module: r.stages.fragmentStage.module,
entryPoint: r.stages.fragmentStage.entryPoint,
targets: s
} : void 0,
multisample: {
count: n
},
depthStencil: void 0 === this._webgpuDepthStencilFormat ? void 0 : {
depthWriteEnabled: this._depthWriteEnabled,
depthCompare: this._depthTestEnabled ? e._GetCompareFunction(this._depthCompare) : Su.Always,
format: this._webgpuDepthStencilFormat,
stencilFront: this._stencilEnabled && f ? d : void 0,
stencilBack: this._stencilEnabled && f ? d : void 0,
stencilReadMask: this._stencilEnabled && f ? this._stencilReadMask : void 0,
stencilWriteMask: this._stencilEnabled && f ? 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
}()
, xh = 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 n = this.values[i].count();
e += n[0],
t += n[1],
e++
}
return [e, t]
}
,
e
}()
, Rh = function(e) {
function t(i, n, r) {
var o = e.call(this, i, n, r) || this;
return o._nodeStack = [],
o._nodeStack[0] = t._Cache,
o
}
return U(t, e),
t.GetNodeCounts = function() {
var e = t._Cache.count();
return {
nodeCount: e[0],
pipelineCount: e[1]
}
}
,
t._GetPipelines = function(e, i, n, r) {
if (e.pipeline) {
var o = n.slice();
o.length = r,
i.push(o)
}
for (var a in e.values) {
var s = e.values[a];
n[r] = parseInt(a),
t._GetPipelines(s, i, n, r + 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 n = t.values[this._states[i]];
n || (n = new xh,
t.values[this._states[i]] = n),
t = n,
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 xh,
t
}(Ah)
, Ch = function(e) {
function t(t) {
var i = e.call(this, !1) || this;
return i._cache = t,
i.reset(),
i
}
return U(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
}(zt)
, Ph = function(e) {
function t(t) {
var i = e.call(this, !1) || this;
return i._cache = t,
i.reset(),
i
}
return U(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
}(It)
, Mh = function() {
function e(e) {
this.useMipMaps = !1,
this.type = a.TEXTURETYPE_UNDEFINED,
this._video = e,
this.uniqueId = Lt._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
}()
, Ih = function() {
function e() {
this.uniqueId = e._Counter++,
this.updateId = 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]
, n = -1;
i ? n = i.hashCode : this.samplers[e] = i = {
sampler: t,
hashCode: 0
},
i.sampler = t,
i.hashCode = t ? Th.GetSamplerHashCode(t) : 0;
var r = n !== i.hashCode;
r && this.updateId++,
this.isDirty || (this.isDirty = r)
}
,
e.prototype.setTexture = function(e, t) {
var i, n, r, o = this.textures[e], s = -1;
o ? s = null !== (n = null === (i = o.texture) || void 0 === i ? void 0 : i.uniqueId) && void 0 !== n ? n : -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 = Mh.IsExternalTexture(t),
o.isFloatTexture && this._numFloatTextures++,
o.isExternalTexture && this._numExternalTextures++) : (o.isFloatTexture = !1,
o.isExternalTexture = !1),
o.texture = t;
var l = s !== (null !== (r = null == t ? void 0 : t.uniqueId) && void 0 !== r ? r : -1);
l && this.updateId++,
this.isDirty || (this.isDirty = l)
}
,
e._Counter = 0,
e
}()
, Oh = 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(40, fu.CopyDst | fu.Indirect),
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
}()
, Dh = function() {
this.values = {}
}
, Nh = 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, n) {
var r, o, a, s, l, c, u, h, d, p, f = void 0, _ = e._Cache, m = this.disabled || n.forceBindGroupCreation;
if (!m) {
if (!i.isDirty(n.updateId) && !n.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 === (r = i.buffers[y]) || void 0 === r ? void 0 : r.uniqueId) && void 0 !== o ? o : 0;
(C = _.values[b]) || (C = new Dh,
_.values[b] = C),
_ = C
}
for (var T = 0, E = t.shaderProcessingContext.samplerNames; T < E.length; T++) {
var S = E[T]
, A = null !== (s = null === (a = n.samplers[S]) || void 0 === a ? void 0 : a.hashCode) && void 0 !== s ? s : 0;
(C = _.values[A]) || (C = new Dh,
_.values[A] = C),
_ = C
}
for (var x = 0, R = t.shaderProcessingContext.textureNames; x < R.length; x++) {
var C, P = R[x], M = null !== (u = null === (c = null === (l = n.textures[P]) || void 0 === l ? void 0 : l.texture) || void 0 === c ? void 0 : c.uniqueId) && void 0 !== u ? u : 0;
(C = _.values[M]) || (C = new Dh,
_.values[M] = C),
_ = C
}
f = _.bindGroups
}
if (i.resetIsDirty(n.updateId),
n.isDirty = !1,
f)
return i.bindGroups = f,
e._NumBindGroupsLookupCurrentFrame++,
f;
f = [],
i.bindGroups = f,
m || (_.bindGroups = f),
e.NumBindGroupsCreatedTotal++,
e._NumBindGroupsCreatedCurrentFrame++;
for (var I = t.bindGroupLayouts, O = 0; O < t.shaderProcessingContext.bindGroupLayoutEntries.length; O++) {
for (var D = t.shaderProcessingContext.bindGroupLayoutEntries[O], N = t.shaderProcessingContext.bindGroupEntries[O], L = 0; L < D.length; L++) {
var F = t.shaderProcessingContext.bindGroupLayoutEntries[O][L]
, w = t.shaderProcessingContext.bindGroupLayoutEntryInfo[O][F.binding]
, B = null !== (h = w.nameInArrayOfTexture) && void 0 !== h ? h : w.name;
if (F.sampler)
if (k = n.samplers[B]) {
var U = k.sampler;
if (!U) {
this._engine.dbgSanityChecks && K.Error("Trying to bind a null sampler! entry=".concat(JSON.stringify(F), ", name=").concat(B, ", bindingInfo=").concat(JSON.stringify(k, (function(e, t) {
return "texture" === e ? "" : t
}
)), ", materialContext.uniqueId=").concat(n.uniqueId), 50);
continue
}
N[L].resource = this._cacheSampler.getSampler(U, !1, k.hashCode)
} else
K.Error('Sampler "'.concat(B, '" could not be bound. entry=').concat(JSON.stringify(F), ", materialContext=").concat(JSON.stringify(n, (function(e, t) {
return "texture" === e || "sampler" === e ? "" : t
}
))), 50);
else if (F.texture || F.storageTexture)
if (k = n.textures[B]) {
if (this._engine.dbgSanityChecks && null === k.texture) {
K.Error("Trying to bind a null texture! entry=".concat(JSON.stringify(F), ", bindingInfo=").concat(JSON.stringify(k, (function(e, t) {
return "texture" === e ? "" : t
}
)), ", materialContext.uniqueId=").concat(n.uniqueId), 50);
continue
}
var V = k.texture._hardwareTexture;
if (this._engine.dbgSanityChecks && (!V || F.texture && !V.view || F.storageTexture && !V.viewForWriting)) {
K.Error("Trying to bind a null gpu texture or view! entry=".concat(JSON.stringify(F), ", 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(n.uniqueId), 50);
continue
}
N[L].resource = F.storageTexture ? V.viewForWriting : V.view
} else
K.Error('Texture "'.concat(B, '" could not be bound. entry=').concat(JSON.stringify(F), ", materialContext=").concat(JSON.stringify(n, (function(e, t) {
return "texture" === e || "sampler" === e ? "" : t
}
))), 50);
else if (F.externalTexture) {
var k;
if (k = n.textures[B]) {
if (this._engine.dbgSanityChecks && null === k.texture) {
K.Error("Trying to bind a null external texture! entry=".concat(JSON.stringify(F), ", name=").concat(B, ", bindingInfo=").concat(JSON.stringify(k, (function(e, t) {
return "texture" === e ? "" : t
}
)), ", materialContext.uniqueId=").concat(n.uniqueId), 50);
continue
}
var G = k.texture.underlyingResource;
if (this._engine.dbgSanityChecks && !G) {
K.Error("Trying to bind a null gpu external texture! entry=".concat(JSON.stringify(F), ", 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(n.uniqueId), 50);
continue
}
N[L].resource = this._device.importExternalTexture({
source: G
})
} else
K.Error('Texture "'.concat(B, '" could not be bound. entry=').concat(JSON.stringify(F), ", materialContext=").concat(JSON.stringify(n, (function(e, t) {
return "texture" === e || "sampler" === e ? "" : t
}
))), 50)
} else if (F.buffer) {
var z = i.buffers[B];
if (z) {
var W = z.underlyingResource;
N[L].resource.buffer = W,
N[L].resource.size = z.capacity
} else
K.Error("Can't find buffer \"".concat(B, '". entry=').concat(JSON.stringify(F), ", buffers=").concat(JSON.stringify(i.buffers), ", drawContext.uniqueId=").concat(i.uniqueId), 50)
}
}
var H = I[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 Dh,
e._NumBindGroupsCreatedCurrentFrame = 0,
e._NumBindGroupsLookupCurrentFrame = 0,
e._NumBindGroupsNoLookupCurrentFrame = 0,
e
}();
Pt.ShadersStore.clearQuadVertexShader = "uniform float depthValue;\nconst vec2 pos[4]={\nvec2(-1.0,1.0),\nvec2(1.0,1.0),\nvec2(-1.0,-1.0),\nvec2(1.0,-1.0)\n};\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";
Pt.ShadersStore.clearQuadPixelShader = "uniform vec4 color;\nvoid main() {\ngl_FragColor=color;\n}\n";
var Lh = function() {
function e(e, t, i) {
this._bindGroups = {},
this._bundleCache = {},
this._keyTemp = [],
this._device = e,
this._engine = t,
this._cacheRenderPipeline = new Rh(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, n, r) {
var o, s;
void 0 === r && (r = 1);
var l, c = null, u = !!this._engine._currentRenderTarget;
if (e)
s = e;
else {
var h = 0;
this._keyTemp.length = 0;
for (var d = 0; d < this._cacheRenderPipeline.colorFormats.length; ++d)
this._keyTemp[h++] = ph[this._cacheRenderPipeline.colorFormats[d]];
var p = ph[null !== (o = this._depthTextureFormat) && void 0 !== o ? o : 0];
if (this._keyTemp[h] = (t ? t.r + 256 * t.g + 256 * t.b * 256 + 256 * t.a * 256 * 256 : 0) + (i ? Math.pow(2, 32) : 0) + (n ? Math.pow(2, 33) : 0) + (this._engine.useReverseDepthBuffer ? Math.pow(2, 34) : 0) + (u ? Math.pow(2, 35) : 0) + (r > 1 ? Math.pow(2, 36) : 0) + p * Math.pow(2, 37),
l = this._keyTemp.join("_"),
c = this._bundleCache[l])
return c;
s = this._device.createRenderBundleEncoder({
colorFormats: this._cacheRenderPipeline.colorFormats,
depthStencilFormat: this._depthTextureFormat,
sampleCount: r
})
}
this._cacheRenderPipeline.setDepthWriteEnabled(!!i),
this._cacheRenderPipeline.setStencilEnabled(!!n && !!this._depthTextureFormat && fh.HasStencilAspect(this._depthTextureFormat)),
this._cacheRenderPipeline.setStencilWriteMask(n ? 255 : 0),
this._cacheRenderPipeline.setStencilCompare(n ? a.ALWAYS : a.NEVER),
this._cacheRenderPipeline.setStencilPassOp(n ? a.REPLACE : a.KEEP),
this._cacheRenderPipeline.setWriteMask(t ? 15 : 0);
var f = this._cacheRenderPipeline.getRenderPipeline(a.MATERIAL_TriangleStripDrawMode, this._effect, r)
, _ = this._effect._pipelineContext;
t && this._effect.setDirectColor4("color", t),
this._effect.setFloat("depthValue", this._engine.useReverseDepthBuffer ? this._engine._clearReverseDepthValue : this._engine._clearDepthValue),
_.uniformBuffer.update();
var m = u ? this._engine._ubInvertY : this._engine._ubDontInvertY
, g = _.uniformBuffer.getBuffer()
, v = g.uniqueId + "-" + m.uniqueId
, y = this._bindGroups[v];
if (!y) {
var b = _.bindGroupLayouts;
(y = this._bindGroups[v] = []).push(this._device.createBindGroup({
layout: b[0],
entries: []
})),
Ju._SimplifiedKnownBindings || y.push(this._device.createBindGroup({
layout: b[1],
entries: []
})),
y.push(this._device.createBindGroup({
layout: b[Ju._SimplifiedKnownBindings ? 1 : 2],
entries: [{
binding: 0,
resource: {
buffer: m.underlyingResource,
size: m.capacity
}
}, {
binding: 1,
resource: {
buffer: g.underlyingResource,
size: g.capacity
}
}]
}))
}
for (s.setPipeline(f),
d = 0; d < y.length; ++d)
s.setBindGroup(d, y[d]);
return s.draw(4, 1, 0, 0),
e || (c = s.finish(),
this._bundleCache[l] = c),
c
}
,
e
}()
, Fh = function() {
function e(e, t, i, n) {
this.x = Math.floor(e),
this.y = Math.floor(t),
this.w = Math.floor(i),
this.h = Math.floor(n)
}
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
}()
, wh = function() {
function e(e, t, i, n) {
this.x = e,
this.y = t,
this.w = i,
this.h = n
}
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
}()
, Bh = 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
}()
, Uh = 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
}()
, Vh = 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
}()
, kh = function() {
function e() {}
return e.prototype.run = function(e) {
e.endOcclusionQuery()
}
,
e.prototype.clone = function() {
return new e
}
,
e
}()
, Gh = 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
}()
, zh = 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 Gh;
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
}()
, Wh = function() {
function e(e, t, i, n, r) {
void 0 === r && (r = !0),
this._dstBuffers = [],
this._device = i,
this._bufferManager = n,
this._count = e,
this._canUseMultipleBuffers = r,
this._querySet = i.createQuerySet({
type: t,
count: e
}),
this._queryBuffer = n.createRawBuffer(8 * e, fu.QueryResolve | fu.CopySrc),
r || this._dstBuffers.push(this._bufferManager.createRawBuffer(8 * this._count, fu.MapRead | fu.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, n = this._device.createCommandEncoder();
return 0 === this._dstBuffers.length ? i = this._bufferManager.createRawBuffer(8 * this._count, fu.MapRead | fu.CopyDst) : (i = this._dstBuffers[this._dstBuffers.length - 1],
this._dstBuffers.length--),
n.resolveQuerySet(this._querySet, e, t, this._queryBuffer, 0),
n.copyBufferToBuffer(this._queryBuffer, 0, i, 0, 8 * t),
this._device.queue.submit([n.finish()]),
i
}
,
e.prototype.readValues = function(e, t) {
return void 0 === e && (e = 0),
void 0 === t && (t = 1),
G(this, void 0, void 0, (function() {
var i, n;
return z(this, (function(r) {
switch (r.label) {
case 0:
return null === (i = this._getBuffer(e, t)) ? [2, null] : [4, i.mapAsync(_u.Read)];
case 1:
return r.sent(),
n = new BigUint64Array(i.getMappedRange()).slice(),
i.unmap(),
this._dstBuffers[this._dstBuffers.length] = i,
[2, n]
}
}
))
}
))
}
,
e.prototype.readValue = function(e) {
return void 0 === e && (e = 0),
G(this, void 0, void 0, (function() {
var t, i, n;
return z(this, (function(r) {
switch (r.label) {
case 0:
return null === (t = this._getBuffer(e, 1)) ? [2, null] : [4, t.mapAsync(_u.Read)];
case 1:
return r.sent(),
i = new BigUint64Array(t.getMappedRange()),
n = Number(i[0]),
t.unmap(),
this._dstBuffers[this._dstBuffers.length] = t,
[2, n]
}
}
))
}
))
}
,
e.prototype.readTwoValuesAndSubtract = function(e) {
return void 0 === e && (e = 0),
G(this, void 0, void 0, (function() {
var t, i, n;
return z(this, (function(r) {
switch (r.label) {
case 0:
return null === (t = this._getBuffer(e, 2)) ? [2, null] : [4, t.mapAsync(_u.Read)];
case 1:
return r.sent(),
i = new BigUint64Array(t.getMappedRange()),
n = Number(i[1] - i[0]),
t.unmap(),
this._dstBuffers[this._dstBuffers.length] = t,
[2, n]
}
}
))
}
))
}
,
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
}()
, Hh = function() {
function e(e, t) {
this._enabled = !1,
this._gpuFrameTimeCounter = new un,
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 Xh(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
}()
, Xh = function() {
function e(e, t) {
this._querySet = new Wh(2,Hu.Timestamp,e,t)
}
return e.prototype.start = function(e) {
e.writeTimestamp(this._querySet.querySet, 0)
}
,
e.prototype.stop = function(e) {
return G(this, void 0, void 0, (function() {
return z(this, (function(t) {
return e.writeTimestamp(this._querySet.querySet, 1),
[2, this._querySet.readTwoValuesAndSubtract(0)]
}
))
}
))
}
,
e.prototype.dispose = function() {
this._querySet.dispose()
}
,
e
}()
, jh = function() {
function e(e, t, i, n, r) {
void 0 === n && (n = 50),
void 0 === r && (r = 100),
this._availableIndices = [],
this._engine = e,
this._device = t,
this._bufferManager = i,
this._frameLastBuffer = -1,
this._currentTotalIndices = 0,
this._countIncrement = r,
this._allocateNewIndices(n)
}
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 Wh(this._currentTotalIndices,Hu.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 = []
}
,
e
}()
, Yh = function() {
function e() {
this._twgsl = null
}
return e.prototype.initTwgsl = function(t) {
return G(this, void 0, void 0, (function() {
var i;
return z(this, (function(n) {
switch (n.label) {
case 0:
return t = t || {},
(t = V(V({}, e._TWgslDefaultOptions), t)).twgsl ? (this._twgsl = t.twgsl,
[2, Promise.resolve()]) : t.jsPath && t.wasmPath ? nt() ? [4, gi.LoadScriptAsync(t.jsPath)] : [3, 2] : [3, 3];
case 1:
return n.sent(),
[3, 3];
case 2:
importScripts(t.jsPath),
n.label = 3;
case 3:
return self.twgsl ? (i = this,
[4, self.twgsl(t.wasmPath)]) : [3, 5];
case 4:
return i._twgsl = n.sent(),
[2, Promise.resolve()];
case 5:
return [2, Promise.reject("twgsl is not available.")]
}
}
))
}
))
}
,
e.prototype.convertSpirV2WGSL = function(e) {
return this._twgsl.convertSpirV2WGSL(e)
}
,
e._TWgslDefaultOptions = {
jsPath: "https://preview.babylonjs.com/twgsl/twgsl.js",
wasmPath: "https://preview.babylonjs.com/twgsl/twgsl.wasm"
},
e
}()
, Kh = function() {
function e(e, t, i, n) {
this._record = !1,
this._play = !1,
this._mainPassBundleList = [],
this._enabled = !1,
this._engine = e,
this._mode = t,
this._bundleList = i,
this._bundleListRenderTarget = n
}
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, n, r, o;
if (this._play)
null === (n = null === (i = t._bundleLists) || void 0 === i ? void 0 : i[t._currentLayer]) || void 0 === n || n.run(e),
this._mode === a.SNAPSHOTRENDERING_FAST && this._engine._reportDrawCall(null === (o = null === (r = t._bundleLists) || void 0 === r ? void 0 : r[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
}()
, Qh = function(e) {
function t(t, i) {
void 0 === i && (i = {});
var n, r, o, a, s = this;
if ((s = e.call(this, null) || this)._uploadEncoderDescriptor = {
label: "upload"
},
s._renderEncoderDescriptor = {
label: "render"
},
s._renderTargetEncoderDescriptor = {
label: "renderTarget"
},
s._clearDepthValue = 1,
s._clearReverseDepthValue = 0,
s._clearStencilValue = 0,
s._defaultSampleCount = 4,
s._glslang = null,
s._tintWASM = null,
s._compiledComputeEffects = {},
s._counters = {
numEnableEffects: 0,
numEnableDrawWrapper: 0,
numBundleCreationNonCompatMode: 0,
numBundleReuseNonCompatMode: 0
},
s.countersLastFrame = {
numEnableEffects: 0,
numEnableDrawWrapper: 0,
numBundleCreationNonCompatMode: 0,
numBundleReuseNonCompatMode: 0
},
s.numMaxUncapturedErrors = 20,
s._commandBuffers = [null, null, null],
s._currentRenderPass = null,
s._mainRenderPassWrapper = new gh,
s._rttRenderPassWrapper = new gh,
s._pendingDebugCommands = [],
s._onAfterUnbindFrameBufferObservable = new h,
s._currentOverrideVertexBuffers = null,
s._currentIndexBuffer = null,
s._colorWriteLocal = !0,
s._forceEnableEffect = !1,
s.dbgShowShaderCode = !1,
s.dbgSanityChecks = !0,
s.dbgVerboseLogsForFirstFrames = !1,
s.dbgVerboseLogsNumFrames = 10,
s.dbgLogIfNotDrawWrapper = !0,
s.dbgShowEmptyEnableEffectCalls = !0,
s._viewportsCurrent = [{
x: 0,
y: 0,
w: 0,
h: 0
}, {
x: 0,
y: 0,
w: 0,
h: 0
}],
s._scissorsCurrent = [{
x: 0,
y: 0,
w: 0,
h: 0
}, {
x: 0,
y: 0,
w: 0,
h: 0
}],
s._scissorCached = {
x: 0,
y: 0,
z: 0,
w: 0
},
s._stencilRefsCurrent = [-1, -1],
s._blendColorsCurrent = [[null, null, null, null], [null, null, null, null]],
s._name = "WebGPU",
s.isNDCHalfZRange = !0,
s.hasOriginBottomLeft = !1,
i.deviceDescriptor = i.deviceDescriptor || {},
i.swapChainFormat = i.swapChainFormat || bu.BGRA8Unorm,
i.antialiasing = void 0 === i.antialiasing || i.antialiasing,
i.stencil = null === (n = i.stencil) || void 0 === n || n,
i.enableGPUDebugMarkers = null !== (r = i.enableGPUDebugMarkers) && void 0 !== r && r,
K.Log("Babylon.js v".concat(vr.Version, " - ").concat(s.description, " engine")),
!navigator.gpu)
return K.Error("WebGPU is not supported by your browser."),
s;
s._isWebGPU = !0,
s._shaderPlatformName = "WEBGPU",
void 0 === i.deterministicLockstep && (i.deterministicLockstep = !1),
void 0 === i.lockstepMaxSteps && (i.lockstepMaxSteps = 4),
void 0 === i.audioEngine && (i.audioEngine = !0),
s._deterministicLockstep = i.deterministicLockstep,
s._lockstepMaxSteps = i.lockstepMaxSteps,
s._timeStep = i.timeStep || 1 / 60,
s._doNotHandleContextLost = !!i.doNotHandleContextLost,
s._canvas = t,
s._options = i,
s.premultipliedAlpha = null === (o = i.premultipliedAlpha) || void 0 === o || o;
var l = nt() && window.devicePixelRatio || 1
, c = i.limitDeviceRatio || l
, u = null !== (a = i.adaptToDeviceRatio) && void 0 !== a && a;
return s._hardwareScalingLevel = u ? 1 / Math.min(c, l) : 1,
s._mainPassSampleCount = i.antialiasing ? s._defaultSampleCount : 1,
s._isStencilEnable = i.stencil,
s._sharedInit(t, !!i.doNotHandleTouchAction, i.audioEngine),
s._shaderProcessor = new $u,
s._shaderProcessorWGSL = new ch,
s
}
return U(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 K.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, "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: "unknown vendor",
renderer: "unknown renderer",
version: "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 n = new t(e,i);
return new Promise((function(e) {
n.initAsync(i.glslangOptions, i.twgslOptions).then((function() {
return e(n)
}
))
}
))
}
,
t.prototype.initAsync = function(e, i) {
var n, r = this;
return this._initGlslang(null != e ? e : null === (n = this._options) || void 0 === n ? void 0 : n.glslangOptions).then((function(e) {
var n;
return r._glslang = e,
r._tintWASM = t.UseTWGSL ? new Yh : null,
r._tintWASM ? r._tintWASM.initTwgsl(null != i ? i : null === (n = r._options) || void 0 === n ? void 0 : n.twgslOptions).then((function() {
return navigator.gpu.requestAdapter(r._options)
}
), (function(e) {
throw K.Error("Can not initialize twgsl!"),
K.Error(e),
Error("WebGPU initializations stopped.")
}
)) : navigator.gpu.requestAdapter(r._options)
}
), (function(e) {
throw K.Error("Can not initialize glslang!"),
K.Error(e),
Error("WebGPU initializations stopped.")
}
)).then((function(e) {
var t;
if (e) {
r._adapter = e,
r._adapterSupportedExtensions = [],
null === (t = r._adapter.features) || void 0 === t || t.forEach((function(e) {
return r._adapterSupportedExtensions.push(e)
}
));
var i = r._options.deviceDescriptor;
if (null == i ? void 0 : i.requiredFeatures) {
for (var n = [], o = 0, a = i.requiredFeatures; o < a.length; o++) {
var s = a[o];
-1 !== r._adapterSupportedExtensions.indexOf(s) && n.push(s)
}
i.requiredFeatures = n
}
return r._adapter.requestDevice(r._options.deviceDescriptor)
}
throw "Could not retrieve a WebGPU adapter (adapter is null)."
}
)).then((function(e) {
var t, i;
r._device = e,
r._deviceEnabledExtensions = [],
null === (t = r._device.features) || void 0 === t || t.forEach((function(e) {
return r._deviceEnabledExtensions.push(e)
}
));
var n = -1;
r._device.addEventListener("uncapturederror", (function(e) {
++n < r.numMaxUncapturedErrors ? K.Warn("WebGPU uncaptured error (".concat(n + 1, "): ").concat(e.error, " - ").concat(e.error.message)) : n++ === r.numMaxUncapturedErrors && K.Warn("WebGPU uncaptured error: too many warnings (".concat(r.numMaxUncapturedErrors, "), no more warnings will be reported to the console for this engine."))
}
)),
r._doNotHandleContextLost || null === (i = r._device.lost) || void 0 === i || i.then((function(e) {
r._contextWasLost = !0,
K.Warn("WebGPU context lost. " + e),
r.onContextLostObservable.notifyObservers(r),
r._restoreEngineAfterContextLost(r.initAsync.bind(r))
}
))
}
), (function(e) {
K.Error("Could not retrieve a WebGPU device."),
K.Error(e)
}
)).then((function() {
r._bufferManager = new mh(r._device),
r._textureHelper = new fh(r._device,r._glslang,r._tintWASM,r._bufferManager),
r._cacheSampler = new Th(r._device),
r._cacheBindGroups = new Nh(r._device,r._cacheSampler,r),
r._timestampQuery = new Hh(r._device,r._bufferManager),
r._occlusionQuery = r._device.createQuerySet ? new jh(r,r._device,r._bufferManager) : void 0,
r._bundleList = new zh(r._device),
r._bundleListRenderTarget = new zh(r._device),
r._snapshotRendering = new Kh(r,r._snapshotRenderingMode,r._bundleList,r._bundleListRenderTarget),
r._ubInvertY = r._bufferManager.createBuffer(new Float32Array([-1, 0]), fu.Uniform | fu.CopyDst),
r._ubDontInvertY = r._bufferManager.createBuffer(new Float32Array([1, 0]), fu.Uniform | fu.CopyDst),
r.dbgVerboseLogsForFirstFrames && void 0 === r._count && (r._count = 0,
console.log("%c frame #" + r._count + " - begin", "background: #ffff00")),
r._uploadEncoder = r._device.createCommandEncoder(r._uploadEncoderDescriptor),
r._renderEncoder = r._device.createCommandEncoder(r._renderEncoderDescriptor),
r._renderTargetEncoder = r._device.createCommandEncoder(r._renderTargetEncoderDescriptor),
r._emptyVertexBuffer = new Bi(r,[0],"",!1,!1,1,!1,0,1),
r._initializeLimits(),
r._cacheRenderPipeline = new Rh(r._device,r._emptyVertexBuffer,!r._caps.textureFloatLinearFiltering),
r._depthCullingState = new Ph(r._cacheRenderPipeline),
r._stencilStateComposer = new Ch(r._cacheRenderPipeline),
r._stencilStateComposer.stencilGlobal = r._stencilState,
r._depthCullingState.depthTest = !0,
r._depthCullingState.depthFunc = a.LEQUAL,
r._depthCullingState.depthMask = !0,
r._textureHelper.setCommandEncoder(r._uploadEncoder),
r._clearQuad = new Lh(r._device,r,r._emptyVertexBuffer),
r._defaultDrawContext = r.createDrawContext(),
r._currentDrawContext = r._defaultDrawContext,
r._defaultMaterialContext = r.createMaterialContext(),
r._currentMaterialContext = r._defaultMaterialContext,
r._initializeContextAndSwapChain(),
r._initializeMainAttachments(),
r.resize()
}
)).catch((function(e) {
K.Error("Can not create WebGPU Device and/or context."),
K.Error(e),
console.trace && console.trace()
}
))
}
,
t.prototype._initGlslang = function(e) {
return e = e || {},
(e = V(V({}, t._GLSLslangDefaultOptions), e)).glslang ? Promise.resolve(e.glslang) : self.glslang ? self.glslang(e.wasmPath) : e.jsPath && e.wasmPath ? nt() ? gi.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: 16,
maxVertexTextureImageUnits: 16,
maxCombinedTexturesImageUnits: 32,
maxTextureSize: 8192,
maxCubemapTextureSize: 2048,
maxRenderTextureSize: 8192,
maxVertexAttribs: 16,
maxVaryingVectors: 15,
maxFragmentUniformVectors: 1024,
maxVertexUniformVectors: 1024,
standardDerivatives: !0,
astc: this._deviceEnabledExtensions.indexOf(pu.TextureCompressionASTC) >= 0 || void 0,
s3tc: this._deviceEnabledExtensions.indexOf(pu.TextureCompressionBC) >= 0 || void 0,
pvrtc: null,
etc1: null,
etc2: this._deviceEnabledExtensions.indexOf(pu.TextureCompressionETC2) >= 0 || void 0,
bptc: this._deviceEnabledExtensions.indexOf(pu.TextureCompressionBC) >= 0 || void 0,
maxAnisotropy: 4,
uintIndices: !0,
fragmentDepthSupported: !0,
highPrecisionShaderSupported: !0,
colorBufferFloat: !0,
textureFloat: !0,
textureFloatLinearFiltering: !1,
textureFloatRender: !0,
textureHalfFloat: !0,
textureHalfFloatLinearFiltering: !0,
textureHalfFloatRender: !0,
textureLOD: !0,
drawBuffersExtension: !0,
depthTextureExtension: !0,
vertexArrayObject: !1,
instancedArrays: !0,
timerQuery: "undefined" != typeof BigUint64Array && -1 !== this.enabledExtensions.indexOf(pu.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
},
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,
_collectUbosUpdatedInFrame: !1
}
}
,
t.prototype._initializeContextAndSwapChain = function() {
this._context = this._canvas.getContext("webgpu"),
this._configureContext(this._canvas.width, this._canvas.height),
this._colorFormat = this._options.swapChainFormat,
this._mainRenderPassWrapper.colorAttachmentGPUTextures = [new uh],
this._mainRenderPassWrapper.colorAttachmentGPUTextures[0].format = this._colorFormat
}
,
t.prototype._initializeMainAttachments = function() {
var e;
this._mainTextureExtends = {
width: this.getRenderWidth(),
height: this.getRenderHeight(),
depthOrArrayLayers: 1
};
var t, i = new Float32Array([this.getRenderHeight()]);
if (this._bufferManager.setSubData(this._ubInvertY, 4, i),
this._bufferManager.setSubData(this._ubDontInvertY, 4, i),
this._options.antialiasing) {
var n = {
size: this._mainTextureExtends,
mipLevelCount: 1,
sampleCount: this._mainPassSampleCount,
dimension: mu.E2d,
format: this._options.swapChainFormat,
usage: gu.RenderAttachment
};
null === (e = this._mainTexture) || void 0 === e || e.destroy(),
this._mainTexture = this._device.createTexture(n),
t = [{
view: this._mainTexture.createView(),
clearValue: new N(0,0,0,1),
loadOp: zu.Clear,
storeOp: Wu.Store
}]
} else
t = [{
view: void 0,
clearValue: new N(0,0,0,1),
loadOp: zu.Clear,
storeOp: Wu.Store
}];
this._mainRenderPassWrapper.depthTextureFormat = this.isStencilEnable ? bu.Depth24PlusStencil8 : bu.Depth32Float,
this._setDepthTextureFormat(this._mainRenderPassWrapper);
var r = {
size: this._mainTextureExtends,
mipLevelCount: 1,
sampleCount: this._mainPassSampleCount,
dimension: mu.E2d,
format: this._mainRenderPassWrapper.depthTextureFormat,
usage: gu.RenderAttachment
};
this._depthTexture && this._depthTexture.destroy(),
this._depthTexture = this._device.createTexture(r);
var o = {
view: this._depthTexture.createView(),
depthClearValue: this._clearDepthValue,
depthLoadOp: zu.Clear,
depthStoreOp: Wu.Store,
stencilClearValue: this._clearStencilValue,
stencilLoadOp: zu.Clear,
stencilStoreOp: Wu.Store
};
this._mainRenderPassWrapper.renderPassDescriptor = {
colorAttachments: t,
depthStencilAttachment: o
},
null !== this._mainRenderPassWrapper.renderPass && this._endMainRenderPass()
}
,
t.prototype._configureContext = function(e, t) {
this._context.configure({
device: this._device,
format: this._options.swapChainFormat,
usage: gu.RenderAttachment | gu.CopySrc,
compositingAlphaMode: this.premultipliedAlpha ? Xu.Premultiplied : Xu.Opaque,
size: {
width: e,
height: t,
depthOrArrayLayers: 1
}
})
}
,
t.prototype.setSize = function(t, i, n) {
return void 0 === n && (n = !1),
!!e.prototype.setSize.call(this, t, i, n) && (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._configureContext(t, i),
this._initializeMainAttachments(),
this.snapshotRendering && this.snapshotRenderingReset(),
!0)
}
,
t.prototype._getShaderProcessor = function(e) {
return e === st.WGSL ? this._shaderProcessorWGSL : this._shaderProcessor
}
,
t.prototype._getShaderProcessingContext = function(e) {
return new Ju(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,
1 === e && (this._viewportCached.x = 0,
this._viewportCached.y = 0,
this._viewportCached.z = 0,
this._viewportCached.w = 0)
}
,
t.prototype._mustUpdateViewport = function(e) {
var t = e === this._mainRenderPassWrapper.renderPass ? 0 : 1
, i = this._viewportCached.x
, n = this._viewportCached.y
, r = this._viewportCached.z
, o = this._viewportCached.w
, a = this._viewportsCurrent[t].x !== i || this._viewportsCurrent[t].y !== n || this._viewportsCurrent[t].w !== r || 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() - 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, n) {
this._viewportCached.x = e,
this._viewportCached.y = t,
this._viewportCached.z = i,
this._viewportCached.w = n
}
,
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
, n = this._scissorCached.y
, r = this._scissorCached.z
, o = this._scissorCached.w
, a = this._scissorsCurrent[t].x !== i || this._scissorsCurrent[t].y !== n || this._scissorsCurrent[t].w !== r || 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, n) {
this._scissorCached.x = e,
this._scissorCached.y = t,
this._scissorCached.z = i,
this._scissorCached.w = n
}
,
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
, n = 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 n && (this._blendColorsCurrent[t][0] = i[0],
this._blendColorsCurrent[t][1] = i[1],
this._blendColorsCurrent[t][2] = i[2],
this._blendColorsCurrent[t][3] = i[3]),
n
}
,
t.prototype._applyBlendColor = function(e) {
e.setBlendConstant(this._alphaState._blendConstants)
}
,
t.prototype.clear = function(e, t, i, n) {
void 0 === n && (n = !1),
e && void 0 === e.a && (e.a = 1);
var r = 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=", n, " scissor is active=", r)),
this._currentRenderTarget ? r ? (this._rttRenderPassWrapper.renderPass || this._startRenderTargetRenderPass(this._currentRenderTarget, !1, t ? e : null, i, n),
this.compatibilityMode ? this._applyScissor(this._currentRenderPass) : this._bundleListRenderTarget.addItem(new wh(this._scissorCached.x,this._scissorCached.y,this._scissorCached.z,this._scissorCached.w)),
this._clearFullQuad(t ? e : null, i, n)) : (this._currentRenderPass && this._endRenderTargetRenderPass(),
this._startRenderTargetRenderPass(this._currentRenderTarget, !0, t ? e : null, i, n)) : (this._mainRenderPassWrapper.renderPass && r || this._startMainRenderPass(!r, t ? e : null, i, n),
r && (this.compatibilityMode ? this._applyScissor(this._currentRenderPass) : this._bundleList.addItem(new wh(this._scissorCached.x,this._scissorCached.y,this._scissorCached.z,this._scissorCached.w)),
this._clearFullQuad(t ? e : null, i, n)))
}
,
t.prototype._clearFullQuad = function(e, t, i) {
var n, r, 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 !== (n = this._cacheRenderPipeline.mrtAttachments) && void 0 !== n ? n : [], null !== (r = this._cacheRenderPipeline.mrtTextureArray) && void 0 !== r ? r : [], this._cacheRenderPipeline.mrtTextureCount),
this.compatibilityMode ? a.setStencilReference(this._clearStencilValue) : s.addItem(new Bh(this._clearStencilValue));
var l = this._clearQuad.clear(a, e, t, i, this.currentSampleCount);
this.compatibilityMode ? this._applyStencilRef(a) : (s.addBundle(l),
s.addItem(new Bh(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, fu.Vertex | fu.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 n = this._bufferManager.createBuffer(t, fu.Index | fu.CopyDst);
return n.is32Bits = i,
n
}
,
t.prototype._createBuffer = function(e, t) {
var i;
i = e instanceof Array ? new Float32Array(e) : e instanceof ArrayBuffer ? new Uint8Array(e) : e;
var n = 0;
return t & a.BUFFER_CREATIONFLAG_READ && (n |= fu.CopySrc),
t & a.BUFFER_CREATIONFLAG_WRITE && (n |= fu.CopyDst),
t & a.BUFFER_CREATIONFLAG_UNIFORM && (n |= fu.Uniform),
t & a.BUFFER_CREATIONFLAG_VERTEX && (n |= fu.Vertex),
t & a.BUFFER_CREATIONFLAG_INDEX && (n |= fu.Index),
t & a.BUFFER_CREATIONFLAG_STORAGE && (n |= fu.Storage),
this._bufferManager.createBuffer(i, n)
}
,
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, n) {
this._currentIndexBuffer = t,
this._currentOverrideVertexBuffers = null != n ? n : 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, n, r, o, a, s, l, c) {
var u;
void 0 === c && (c = st.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 != r ? r : 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 Mt(e,t,i,n,this,r,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, n) {
return this._compileRawShaderToSpirV(n + (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) {
return this._tintWASM && i === st.GLSL && (e = this._tintWASM.convertSpirV2WGSL(e),
t = this._tintWASM.convertSpirV2WGSL(t)),
{
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 n = i === st.GLSL ? this._compileRawShaderToSpirV(e, "vertex") : e
, r = i === st.GLSL ? this._compileRawShaderToSpirV(t, "fragment") : t;
return this._createPipelineStageDescriptor(n, r, i)
}
,
t.prototype._compilePipelineStageDescriptor = function(e, t, i, n) {
this.onBeforeShaderCompilationObservable.notifyObservers(this);
var r = "#version 450\n"
, o = n === st.GLSL ? this._compileShaderToSpirV(e, "vertex", i, r) : this._getWGSLShader(e, "vertex", i)
, a = n === st.GLSL ? this._compileShaderToSpirV(t, "fragment", i, r) : this._getWGSLShader(t, "fragment", i)
, s = this._createPipelineStageDescriptor(o, a, n);
return this.onAfterShaderCompilationObservable.notifyObservers(this),
s
}
,
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 iu(e);
return t.debug = !1,
t.processCode(),
t.code
}
,
t.prototype.createPipelineContext = function(e) {
return new qu(e,this)
}
,
t.prototype.createMaterialContext = function() {
return new Ih
}
,
t.prototype.createDrawContext = function() {
return new Oh(this._bufferManager)
}
,
t.prototype._preparePipelineContext = function(e, t, i, n, r, o, a, s) {
var l = e
, c = l.shaderProcessingContext.shaderLanguage;
this.dbgShowShaderCode && (console.log(s),
console.log(t),
console.log(i)),
l.sources = {
fragment: i,
vertex: t,
rawVertex: r,
rawFragment: o
},
l.stages = n ? this._compileRawPipelineStageDescriptor(t, i, c) : this._compilePipelineStageDescriptor(t, i, s, c)
}
,
t.prototype.getAttributes = function(e, t) {
for (var i = new Array(t.length), n = e, r = 0; r < t.length; r++) {
var o = t[r]
, a = n.shaderProcessingContext.availableAttributes[o];
void 0 !== a && (i[r] = a)
}
return i
}
,
t.prototype.enableEffect = function(e) {
if (e) {
var t = !0;
if (Gt.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 && K.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 uh
}
,
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, n) {
var r, o;
void 0 === i && (i = !0),
void 0 === n && (n = At.Unknown);
var s = {};
void 0 !== t && "object" == typeof t ? (s.generateMipMaps = t.generateMipMaps,
s.type = void 0 === t.type ? a.TEXTURETYPE_UNSIGNED_INT : t.type,
s.samplingMode = void 0 === t.samplingMode ? a.TEXTURE_TRILINEAR_SAMPLINGMODE : t.samplingMode,
s.format = void 0 === t.format ? a.TEXTUREFORMAT_RGBA : t.format,
s.samples = null !== (r = t.samples) && void 0 !== r ? r : 1,
s.creationFlags = null !== (o = t.creationFlags) && void 0 !== o ? o : 0) : (s.generateMipMaps = t,
s.type = a.TEXTURETYPE_UNSIGNED_INT,
s.samplingMode = a.TEXTURE_TRILINEAR_SAMPLINGMODE,
s.format = a.TEXTUREFORMAT_RGBA,
s.samples = 1,
s.creationFlags = 0),
(s.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (s.type !== a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (s.samplingMode = a.TEXTURE_NEAREST_SAMPLINGMODE),
s.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloat || (s.type = a.TEXTURETYPE_UNSIGNED_INT,
K.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));
var l = new Lt(this,n)
, c = e.width || e
, u = e.height || e
, h = e.layers || 0;
return l.baseWidth = c,
l.baseHeight = u,
l.width = c,
l.height = u,
l.depth = h,
l.isReady = !0,
l.samples = s.samples,
l.generateMipMaps = !!s.generateMipMaps,
l.samplingMode = s.samplingMode,
l.type = s.type,
l.format = s.format,
l.is2DArray = h > 0,
l._cachedWrapU = a.TEXTURE_CLAMP_ADDRESSMODE,
l._cachedWrapV = a.TEXTURE_CLAMP_ADDRESSMODE,
this._internalTexturesCache.push(l),
i || this._textureHelper.createGPUTextureForInternalTexture(l, c, u, h || 1, s.creationFlags),
l
}
,
t.prototype.createTexture = function(e, t, i, n, r, o, s, l, c, u, h, d, p, f, _) {
var m = this;
return void 0 === r && (r = 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, n, r, o, s, (function(e, t, i, n, r, o, a, s) {
var l, c = n;
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);
fh.IsImageBitmap(c) && (m._textureHelper.updateTexture(c, e, c.width, c.height, e.depth, h.format, 0, 0, r, !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.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 === At.RenderTarget || e.source === At.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, n) {
void 0 === i && (i = null),
void 0 === n && (n = null),
null !== t && (e._cachedWrapU = t),
null !== i && (e._cachedWrapV = i),
(e.is2DArray || e.is3D) && null !== n && (e._cachedWrapR = n)
}
,
t.prototype.updateTextureDimensions = function(e, t, i, n) {
if (void 0 === n && (n = 1),
e._hardwareTexture && (e.width !== t || e.height !== i || e.depth !== n)) {
var r = e._hardwareTexture.textureAdditionalUsages;
e._hardwareTexture.release(),
this._textureHelper.createGPUTextureForInternalTexture(e, t, i, n, r)
}
}
,
t.prototype._setInternalTexture = function(e, t, i) {
if (i = null != i ? i : e,
this._currentEffect) {
var n = this._currentEffect._pipelineContext.shaderProcessingContext.availableTextures[i];
if (this._currentMaterialContext.setTexture(e, t),
n && n.autoBindSampler) {
var r = i + Qu.AutoSamplerSuffix;
this._currentMaterialContext.setSampler(r, t)
}
}
}
,
t.prototype.setTexture = function(e, t, i, n) {
this._setTexture(e, i, !1, !1, n, n)
}
,
t.prototype.setTextureArray = function(e, t, i, n) {
for (var r = 0; r < i.length; r++)
this._setTexture(-1, i[r], !0, !1, n + r.toString(), n)
}
,
t.prototype._setTexture = function(e, t, i, n, r, o) {
if (void 0 === i && (i = !1),
void 0 === n && (n = !1),
void 0 === r && (r = ""),
o = null != o ? o : r,
this._currentEffect) {
if (!t)
return this._currentMaterialContext.setTexture(r, null),
!1;
if (t.video)
t.update();
else if (t.delayLoadState === a.DELAYLOADSTATE_NOTLOADED)
return t.delayLoad(),
!1;
var s = null;
if ((s = n ? 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(r, 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 n = e._hardwareTexture.format
, r = fh.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, n, r, t) : this._textureHelper.generateMipmaps(i, n, r, 0, t)
}
}
,
t.prototype.updateTextureData = function(e, t, i, n, r, o, a, s) {
var l;
void 0 === a && (a = 0),
void 0 === s && (s = 0);
var c = e._hardwareTexture;
(null === (l = e._hardwareTexture) || void 0 === l ? void 0 : l.underlyingResource) || (c = this._textureHelper.createGPUTextureForInternalTexture(e));
var u = new Uint8Array(t.buffer,t.byteOffset,t.byteLength);
this._textureHelper.updateTexture(u, e, r, o, e.depth, c.format, a, s, e.invertY, !1, i, n)
}
,
t.prototype._uploadCompressedDataToTextureDirectly = function(e, t, i, n, r, 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, n));
var c = new Uint8Array(r.buffer,r.byteOffset,r.byteLength);
this._textureHelper.updateTexture(c, e, i, n, e.depth, l.format, o, a, !1, !1, 0, 0)
}
,
t.prototype._uploadDataToTextureDirectly = function(e, t, i, n, r, o) {
var a;
void 0 === i && (i = 0),
void 0 === n && (n = 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 - n, 0))
, u = o ? e.height : Math.pow(2, Math.max(l - n, 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, n, e.invertY, !1, 0, 0)
}
,
t.prototype._uploadArrayBufferViewToTexture = function(e, t, i, n) {
void 0 === i && (i = 0),
void 0 === n && (n = 0),
this._uploadDataToTextureDirectly(e, t, i, n)
}
,
t.prototype._uploadImageToTexture = function(e, t, i, n) {
var r;
void 0 === i && (i = 0),
void 0 === n && (n = 0);
var o = e._hardwareTexture;
(null === (r = e._hardwareTexture) || void 0 === r ? void 0 : r.underlyingResource) || (o = this._textureHelper.createGPUTextureForInternalTexture(e));
var a = t
, s = Math.ceil(e.width / (1 << n))
, l = Math.ceil(e.height / (1 << n));
this._textureHelper.updateTexture(a, e, s, l, e.depth, o.format, i, n, e.invertY, !1, 0, 0)
}
,
t.prototype.readPixels = function(e, t, i, n, r, o) {
void 0 === r && (r = !0),
void 0 === o && (o = !0);
var a = this._rttRenderPassWrapper.renderPass ? this._rttRenderPassWrapper : this._mainRenderPassWrapper
, s = a.colorAttachmentGPUTextures[0].underlyingResource
, l = a.colorAttachmentGPUTextures[0].format;
return s ? (o && this.flushFramebuffer(),
this._textureHelper.readPixels(s, e, t, i, n, 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 Fi._UpdatedUbosInFrame)
t.push(i + ":" + Fi._UpdatedUbosInFrame[i]);
console.log("frame #" + this._count + " - updated ubos -", t.join(", "))
}
Fi._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, n, r) {
var o, a, s, l = e, c = l._depthStencilTexture, u = null == c ? void 0 : c._hardwareTexture, h = null == u ? void 0 : u.underlyingResource, d = null == u ? void 0 : u.msaaTexture, p = null == h ? void 0 : h.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor), f = null == d ? void 0 : d.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor), _ = [];
this.useReverseDepthBuffer && this.setDepthFunctionToGreaterOrEqual();
var m = t && i
, g = t && n
, v = t && r;
if (l._attachments && l.isMulti) {
this._mrtAttachments && 0 !== this._mrtAttachments.length || (this._mrtAttachments = l._defaultAttachments);
for (var y = 0; y < this._mrtAttachments.length; ++y) {
var b = this._mrtAttachments[y]
, T = l.textures[y]
, E = null == T ? void 0 : T._hardwareTexture
, S = null == E ? void 0 : E.underlyingResource;
if (E && S) {
var A = V(V({}, this._rttRenderPassWrapper.colorAttachmentViewDescriptor), {
format: E.format
})
, x = E.msaaTexture
, R = S.createView(A)
, C = null == x ? void 0 : x.createView(A);
_.push({
view: C || R,
resolveTarget: x ? R : void 0,
clearValue: 0 !== b && m ? i : void 0,
loadOp: 0 !== b && m ? zu.Clear : zu.Load,
storeOp: Wu.Store
})
}
}
this._cacheRenderPipeline.setMRT(l.textures, this._mrtAttachments.length),
this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments)
} else {
var P = (I = l.texture)._hardwareTexture
, M = P.underlyingResource;
x = P.msaaTexture,
R = M.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor),
C = null == x ? void 0 : x.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor),
_.push({
view: C || R,
resolveTarget: x ? R : void 0,
clearValue: m ? i : void 0,
loadOp: m ? zu.Clear : zu.Load,
storeOp: Wu.Store
})
}
if (null === (o = this._debugPushGroup) || void 0 === o || o.call(this, "render target pass", 1),
this._rttRenderPassWrapper.renderPassDescriptor = {
colorAttachments: _,
depthStencilAttachment: c && h ? {
view: f || p,
depthClearValue: g ? this.useReverseDepthBuffer ? this._clearReverseDepthValue : this._clearDepthValue : void 0,
depthLoadOp: g ? zu.Clear : zu.Load,
depthStoreOp: Wu.Store,
stencilClearValue: l._depthStencilTextureWithStencil && v ? this._clearStencilValue : void 0,
stencilLoadOp: l._depthStencilTextureWithStencil && v ? zu.Clear : zu.Load,
stencilStoreOp: Wu.Store
} : void 0,
occlusionQuerySet: (null === (a = this._occlusionQuery) || void 0 === a ? void 0 : a.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 I = l.texture;
console.log("frame #" + this._count + " - render target begin pass - internalTexture.uniqueId=", I.uniqueId, "width=", I.width, "height=", I.height, this._rttRenderPassWrapper.renderPassDescriptor)
}
this._currentRenderPass = this._rttRenderPassWrapper.renderPass,
null === (s = this._debugFlushPendingCommands) || void 0 === s || s.call(this),
this._resetCurrentViewport(1),
this._resetCurrentScissor(1),
this._resetCurrentStencilRef(1),
this._resetCurrentColorBlend(1),
u && fh.HasStencilAspect(u.format) || (this._stencilStateComposer.enabled = !1)
}
,
t.prototype._endRenderTargetRenderPass = function() {
var e, t, i;
if (this._currentRenderPass) {
var n = this._currentRenderTarget.texture._hardwareTexture;
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 === (t = null === (e = this._currentRenderTarget) || void 0 === e ? void 0 : e.texture) || void 0 === t ? void 0 : t.uniqueId)),
null === (i = this._debugPopGroup) || void 0 === i || i.call(this, 1),
this._resetCurrentViewport(1),
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, n) {
var r, o, a;
this._mainRenderPassWrapper.renderPass && this._endMainRenderPass(),
this.useReverseDepthBuffer && this.setDepthFunctionToGreaterOrEqual();
var s = e && t
, l = e && i
, c = e && n;
this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].clearValue = s ? t : void 0,
this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].loadOp = s ? zu.Clear : zu.Load,
this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.depthClearValue = l ? this.useReverseDepthBuffer ? this._clearReverseDepthValue : this._clearDepthValue : void 0,
this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.depthLoadOp = l ? zu.Clear : zu.Load,
this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.stencilClearValue = c ? this._clearStencilValue : void 0,
this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.stencilLoadOp = c ? zu.Clear : zu.Load,
this._mainRenderPassWrapper.renderPassDescriptor.occlusionQuerySet = (null === (r = this._occlusionQuery) || void 0 === r ? void 0 : r.hasQueries) ? this._occlusionQuery.querySet : void 0,
this._swapChainTexture = this._context.getCurrentTexture(),
this._mainRenderPassWrapper.colorAttachmentGPUTextures[0].set(this._swapChainTexture),
this._options.antialiasing ? this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].resolveTarget = this._swapChainTexture.createView() : this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].view = this._swapChainTexture.createView(),
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, n, r, 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;
u ? (this._currentRenderTarget && this.unBindFramebuffer(this._currentRenderTarget),
this._currentRenderTarget = e,
u._currentLayer = e.isCube ? 6 * s + t : s,
this._rttRenderPassWrapper.colorAttachmentGPUTextures[0] = u,
this._rttRenderPassWrapper.depthTextureFormat = this._currentRenderTarget._depthStencilTexture ? fh.GetWebGPUTextureFormat(-1, this._currentRenderTarget._depthStencilTexture.format) : void 0,
this._setDepthTextureFormat(this._rttRenderPassWrapper),
this._setColorFormat(this._rttRenderPassWrapper),
this._rttRenderPassWrapper.colorAttachmentViewDescriptor = {
format: this._colorFormat,
dimension: vu.E2d,
mipLevelCount: 1,
baseArrayLayer: e.isCube ? 6 * s + t : s,
baseMipLevel: o,
arrayLayerCount: 1,
aspect: yu.All
},
this._rttRenderPassWrapper.depthAttachmentViewDescriptor = {
format: this._depthTextureFormat,
dimension: vu.E2d,
mipLevelCount: 1,
baseArrayLayer: e.isCube ? 6 * s + t : s,
baseMipLevel: 0,
arrayLayerCount: 1,
aspect: yu.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 && !r ? this.setViewport(this._cachedViewport, i, n) : (i || (i = e.width,
o && (i /= Math.pow(2, o))),
n || (n = e.height,
o && (n /= Math.pow(2, o))),
this._viewport(0, 0, i, n)),
this.wipeCaches()) : this.dbgSanityChecks && console.error("bindFramebuffer: Trying to bind a texture that does not have a hardware texture!", e, u)
}
,
t.prototype.unBindFramebuffer = function(e, t, i) {
var n, r;
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 === (n = e.texture) || void 0 === n ? void 0 : n.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 === (r = e.texture) || void 0 === r ? void 0 : r.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 = e.colorAttachmentGPUTextures[0].format;
this._cacheRenderPipeline.setColorFormat(t),
this._colorFormat !== t && (this._colorFormat = t)
}
,
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, n, r, o, a) {
var s, l;
void 0 === t && (t = 0),
void 0 === n && (n = !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 : r) || void 0 === l || l ? 1 : 2;
(this._depthCullingState.cullFace !== c || i) && (this._depthCullingState.cullFace = c),
this.setZOffset(t),
this.setZOffsetUnits(a);
var u = n ? 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, n = this._mustUpdateViewport(e), r = this._mustUpdateScissor(e), o = !!this._stencilStateComposer.enabled && this._mustUpdateStencilRef(e), a = !!this._alphaState.alphaBlend && this._mustUpdateBlendColor(e);
t ? (n && t.addItem(new Fh(this._viewportCached.x,this._viewportCached.y,this._viewportCached.z,this._viewportCached.w)),
r && t.addItem(new wh(this._scissorCached.x,this._scissorCached.y,this._scissorCached.z,this._scissorCached.w)),
o && t.addItem(new Bh(null !== (i = this._stencilStateComposer.funcRef) && void 0 !== i ? i : 0)),
a && t.addItem(new Uh(this._alphaState._blendConstants.slice()))) : (n && this._applyViewport(e),
r && this._applyScissor(e),
o && this._applyStencilRef(e),
a && this._applyBlendColor(e))
}
,
t.prototype._draw = function(e, t, i, n, r) {
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, Qu.InternalsUBOName),
c.uniformBuffer && (c.uniformBuffer.update(),
this.bindUniformBufferBase(c.uniformBuffer.getBuffer(), 0, Qu.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(n, r || 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
}
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 ? Bu.Uint32 : Bu.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(n, r || 1, i),
0 === e ? u.drawIndexedIndirect(this._currentDrawContext.indirectDrawBuffer, 0) : u.drawIndirect(this._currentDrawContext.indirectDrawBuffer, 0)) : 0 === e ? u.drawIndexed(n, r || 1, i, 0, 0) : u.draw(n, r || 1, i, 0),
E && (this._currentDrawContext.fastBundle = u.finish(),
l.addBundle(this._currentDrawContext.fastBundle)),
this._reportDrawCall()
}
}
,
t.prototype.drawElementsType = function(e, t, i, n) {
void 0 === n && (n = 1),
this._draw(0, e, t, i, n)
}
,
t.prototype.drawArraysType = function(e, t, i, n) {
void 0 === n && (n = 1),
this._currentIndexBuffer = null,
this._draw(1, e, t, i, n)
}
,
t.prototype.dispose = function() {
var t, i, n;
null === (t = this._mainTexture) || void 0 === t || t.destroy(),
null === (i = this._mainTextureLastCopy) || void 0 === i || i.destroy(),
null === (n = this._depthTexture) || void 0 === n || n.destroy(),
e.prototype.dispose.call(this)
}
,
t.prototype.getRenderWidth = function(e) {
return void 0 === e && (e = !1),
!e && this._currentRenderTarget ? this._currentRenderTarget.width : this._canvas.width
}
,
t.prototype.getRenderHeight = function(e) {
return void 0 === e && (e = !1),
!e && this._currentRenderTarget ? this._currentRenderTarget.height : this._canvas.height
}
,
t.prototype.getRenderingCanvas = function() {
return this._canvas
}
,
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
}(vr);
Qh.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)) {
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 === vr.ALPHA_DISABLE),
this._cacheRenderPipeline.setDepthWriteEnabled(e === vr.ALPHA_DISABLE)),
this._alphaMode = e,
this._cacheRenderPipeline.setAlphaBlendEnabled(this._alphaState.alphaBlend),
this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters, this._alphaState._blendEquationParameters)
}
}
,
Qh.prototype.setAlphaEquation = function(e) {
vr.prototype.setAlphaEquation.call(this, e),
this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters, this._alphaState._blendEquationParameters)
}
;
var qh = 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 n = this._bindGroupEntries.length > 0;
for (var r in e) {
var o = e[r]
, a = i[r]
, 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 _l.Sampler:
var d = u;
void 0 !== h && n ? v[h].resource = this._cacheSampler.getSampler(d) : (o.indexInGroupEntries = v.length,
v.push({
binding: l,
resource: this._cacheSampler.getSampler(d)
}));
break;
case _l.Texture:
case _l.TextureWithoutSampler:
var p = (f = u)._texture._hardwareTexture;
void 0 !== h && n ? (c === _l.Texture && (v[h++].resource = this._cacheSampler.getSampler(f._texture)),
v[h].resource = p.view) : (o.indexInGroupEntries = v.length,
c === _l.Texture && v.push({
binding: l - 1,
resource: this._cacheSampler.getSampler(f._texture)
}),
v.push({
binding: l,
resource: p.view
}));
break;
case _l.StorageTexture:
var f;
0 == ((p = (f = u)._texture._hardwareTexture).textureAdditionalUsages & gu.StorageBinding) && K.Error("computeDispatch: The texture (name=".concat(f.name, ", uniqueId=").concat(f.uniqueId, ") is not a storage texture!"), 50),
void 0 !== h && n ? v[h].resource = p.viewForWriting : (o.indexInGroupEntries = v.length,
v.push({
binding: l,
resource: p.viewForWriting
}));
break;
case _l.UniformBuffer:
case _l.StorageBuffer:
var _ = (_l.UniformBuffer,
u).getBuffer()
, m = _.underlyingResource;
void 0 !== h && n ? (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
}()
, Zh = 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
}();
Qh.prototype.createComputeContext = function() {
return new qh(this._device,this._cacheSampler)
}
,
Qh.prototype.createComputeEffect = function(e, t) {
var i = (e.computeElement || e.compute || e.computeToken || e.computeSource || e) + "@" + t.defines;
if (this._compiledComputeEffects[i]) {
var n = this._compiledComputeEffects[i];
return t.onCompiled && n.isReady() && t.onCompiled(n),
n
}
var r = new ml(e,t,this,i);
return this._compiledComputeEffects[i] = r,
r
}
,
Qh.prototype.createComputePipelineContext = function() {
return new Zh(this)
}
,
Qh.prototype.areAllComputeEffectsReady = function() {
for (var e in this._compiledComputeEffects)
if (!this._compiledComputeEffects[e].isReady())
return !1;
return !0
}
,
Qh.prototype.computeDispatch = function(e, t, i, n, r, o, a) {
var s = this;
if (this._currentRenderTarget)
this._onAfterUnbindFrameBufferObservable.addOnce((function() {
s.computeDispatch(e, t, i, n, r, o, a)
}
));
else {
var l = e._pipelineContext
, c = t;
l.computePipeline || (l.computePipeline = this._device.createComputePipeline({
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.dispatch(n, r, o),
u.end()
}
}
,
Qh.prototype.releaseComputeEffects = function() {
for (var e in this._compiledComputeEffects) {
var t = this._compiledComputeEffects[e].getPipelineContext();
this._deleteComputePipelineContext(t)
}
this._compiledComputeEffects = {}
}
,
Qh.prototype._prepareComputePipelineContext = function(e, t, i, n, r) {
var o = e;
this.dbgShowShaderCode && (console.log(n),
console.log(t)),
o.sources = {
compute: t,
rawCompute: i
},
o.stage = this._createComputePipelineStageDescriptor(t, n, r)
}
,
Qh.prototype._releaseComputeEffect = function(e) {
this._compiledComputeEffects[e._key] && (delete this._compiledComputeEffects[e._key],
this._deleteComputePipelineContext(e.getPipelineContext()))
}
,
Qh.prototype._rebuildComputeEffects = function() {
for (var e in this._compiledComputeEffects) {
var t = this._compiledComputeEffects[e];
t._pipelineContext = null,
t._wasPreviouslyReady = !1,
t._prepareEffect()
}
}
,
Qh.prototype._deleteComputePipelineContext = function(e) {
e && e.dispose()
}
,
Qh.prototype._createComputePipelineStageDescriptor = function(e, t, i) {
return t = t ? "//" + t.split("\n").join("\n//") + "\n" : "",
{
module: this._device.createShaderModule({
code: t + e
}),
entryPoint: i
}
}
,
Qh.prototype._createDepthStencilCubeTexture = function(e, t) {
var i = new Lt(this,At.DepthStencil);
i.isCube = !0;
var n = V({
bilinearFiltering: !1,
comparisonFunction: 0,
generateStencil: !1,
samples: 1
}, t);
return i.format = n.generateStencil ? a.TEXTUREFORMAT_DEPTH24_STENCIL8 : a.TEXTUREFORMAT_DEPTH32_FLOAT,
this._setupDepthStencilTexture(i, e, n.generateStencil, n.bilinearFiltering, n.comparisonFunction, n.samples),
this._textureHelper.createGPUTextureForInternalTexture(i),
this._internalTexturesCache.push(i),
i
}
,
Qh.prototype.createCubeTexture = function(e, t, i, n, r, o, a, s, l, c, u, h, d) {
var p = this;
return void 0 === r && (r = 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, !!n, r, o, a, s, l, c, u, h, null, (function(e, t) {
var i = t
, o = i[0].width
, s = o;
p._setCubeMapTextureParams(e, !n),
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),
n || p._generateMipmaps(e, p._uploadEncoder),
e.isReady = !0,
e.onLoadedObservable.notifyObservers(e),
e.onLoadedObservable.clear(),
r && r()
}
), !!d)
}
,
Qh.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)
}
,
Qh.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]))
}
,
Qh.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]))
}
,
Qh.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]))
}
,
Qh.prototype._debugFlushPendingCommands = function() {
for (var e = 0; e < this._pendingDebugCommands.length; ++e) {
var t = this._pendingDebugCommands[e]
, i = t[0]
, n = t[1];
switch (i) {
case "push":
this._debugPushGroup(n);
break;
case "pop":
this._debugPopGroup();
break;
case "insert":
this._debugInsertMarker(n)
}
}
this._pendingDebugCommands.length = 0
}
,
Qh.prototype.updateDynamicIndexBuffer = function(e, t, i) {
void 0 === i && (i = 0);
var n, r = e;
n = t instanceof Uint16Array ? e.is32Bits ? Uint32Array.from(t) : t : t instanceof Uint32Array ? e.is32Bits ? t : Uint16Array.from(t) : e.is32Bits ? new Uint32Array(t) : new Uint16Array(t),
this._bufferManager.setSubData(r, i, n)
}
,
Qh.prototype.updateDynamicVertexBuffer = function(e, t, i, n) {
var r, o = e;
void 0 === i && (i = 0),
void 0 === n ? n = (r = t instanceof Array ? new Float32Array(t) : t instanceof ArrayBuffer ? new Uint8Array(t) : t).byteLength : r = t instanceof Array ? new Float32Array(t) : t instanceof ArrayBuffer ? new Uint8Array(t) : t,
this._bufferManager.setSubData(o, i, r, 0, n)
}
,
Qh.prototype.updateDynamicTexture = function(e, t, i, n, r, o, a) {
var s;
if (void 0 === n && (n = !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, n, 0, 0, a),
e.generateMipMaps && this._generateMipmaps(e, this._uploadEncoder),
e.isReady = !0
}
}
;
var Jh = function(e) {
function t(t) {
return e.call(this, t) || this
}
return U(t, e),
t
}(Mh);
function $h(e, t, i, n) {
var r, o = 1;
n === a.TEXTURETYPE_FLOAT ? r = new Float32Array(t * i * 4) : n === a.TEXTURETYPE_HALF_FLOAT ? (r = new Uint16Array(t * i * 4),
o = 15360) : r = n === 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);
r[u + 0] = e[c + 0],
r[u + 1] = e[c + 1],
r[u + 2] = e[c + 2],
r[u + 3] = o
}
return r
}
Mt.prototype.setExternalTexture = function(e, t) {
this._engine.setExternalTexture(e, t)
}
,
Qh.prototype.createExternalTexture = function(e) {
return new Jh(e)
}
,
Qh.prototype.setExternalTexture = function(e, t) {
t ? this._setInternalTexture(e, t) : this._currentMaterialContext.setTexture(e, null)
}
,
Qh.prototype.unBindMultiColorAttachmentFramebuffer = function(e, t, i) {
void 0 === t && (t = !1),
i && i();
var n = e._attachments.length;
this._currentRenderPass && this._currentRenderPass !== this._mainRenderPassWrapper.renderPass && this._endRenderTargetRenderPass();
for (var r = 0; r < n; r++) {
var o = e.textures[r];
!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)
}
,
Qh.prototype.createMultipleRenderTarget = function(e, t, i) {
var n, r = !1, o = !0, s = !1, l = !1, c = a.TEXTUREFORMAT_DEPTH16, u = 1, h = a.TEXTURETYPE_UNSIGNED_INT, d = a.TEXTURE_TRILINEAR_SAMPLINGMODE, p = new Array, f = new Array, _ = this._createHardwareRenderTargetWrapper(!0, !1, e);
void 0 !== t && (r = 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,
c = null !== (n = t.depthTextureFormat) && void 0 !== n ? n : a.TEXTUREFORMAT_DEPTH16,
t.types && (p = t.types),
t.samplingModes && (f = t.samplingModes));
var m = e.width || e
, g = e.height || e
, v = null;
(o || s || l) && (v = _.createDepthStencilTexture(0, !1, s, 1, c));
var y = []
, b = []
, T = [];
_._generateDepthBuffer = o,
_._generateStencilBuffer = s,
_._attachments = b,
_._defaultAttachments = T;
for (var E = 0; E < u; E++) {
var S = f[E] || d
, A = p[E] || h;
(A !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (A !== a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (S = a.TEXTURE_NEAREST_SAMPLINGMODE),
A !== a.TEXTURETYPE_FLOAT || this._caps.textureFloat || (A = a.TEXTURETYPE_UNSIGNED_INT,
K.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));
var x = new Lt(this,At.MultiRenderTarget);
y.push(x),
b.push(E + 1),
T.push(i ? E + 1 : 0 === E ? 1 : 0),
x.baseWidth = m,
x.baseHeight = g,
x.width = m,
x.height = g,
x.isReady = !0,
x.samples = 1,
x.generateMipMaps = r,
x.samplingMode = S,
x.type = A,
x._cachedWrapU = a.TEXTURE_CLAMP_ADDRESSMODE,
x._cachedWrapV = a.TEXTURE_CLAMP_ADDRESSMODE,
this._internalTexturesCache.push(x),
this._textureHelper.createGPUTextureForInternalTexture(x)
}
return v && (v.incrementReferences(),
y.push(v),
this._internalTexturesCache.push(v)),
_.setTextures(y),
_
}
,
Qh.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 n = 0; n < i; ++n) {
var r = e.textures[n];
this._textureHelper.createMSAATexture(r, t),
r.samples = t
}
return e._depthStencilTexture && e._depthStencilTexture !== e.textures[e.textures.length - 1] && (this._textureHelper.createMSAATexture(e._depthStencilTexture, t),
e._depthStencilTexture.samples = t),
t
}
,
Qh.prototype.bindAttachments = function(e) {
0 !== e.length && this._currentRenderTarget && (this._mrtAttachments = e,
this._currentRenderPass && this._cacheRenderPipeline.setMRTAttachments(e))
}
,
Qh.prototype.buildTextureLayout = function(e) {
for (var t = [], i = 0; i < e.length; i++)
e[i] ? t.push(i + 1) : t.push(0);
return t
}
,
Qh.prototype.restoreSingleAttachment = function() {}
,
Qh.prototype.restoreSingleAttachmentForRenderTarget = function() {}
,
Qh.prototype.getGPUFrameTimeCounter = function() {
return this._timestampQuery.gpuFrameTimeCounter
}
,
Qh.prototype.captureGPUFrameTime = function(e) {
this._timestampQuery.enable = e && !!this._caps.timerQuery
}
,
Qh.prototype.createQuery = function() {
return this._occlusionQuery.createQuery()
}
,
Qh.prototype.deleteQuery = function(e) {
return this._occlusionQuery.deleteQuery(e),
this
}
,
Qh.prototype.isQueryResultAvailable = function(e) {
return this._occlusionQuery.isQueryResultAvailable(e)
}
,
Qh.prototype.getQueryResult = function(e) {
return this._occlusionQuery.getQueryResult(e)
}
,
Qh.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 Vh(t)),
!0)
}
,
Qh.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 kh),
this
}
,
Qh.prototype.createRawTexture = function(e, t, i, n, r, o, s, l, c, u) {
void 0 === l && (l = null),
void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT),
void 0 === u && (u = 0);
var h = new Lt(this,At.Raw);
return h.baseWidth = t,
h.baseHeight = i,
h.width = t,
h.height = i,
h.format = n,
h.generateMipMaps = r,
h.samplingMode = s,
h.invertY = o,
h._compression = l,
h.type = c,
this._doNotHandleContextLost || (h._bufferView = e),
this._textureHelper.createGPUTextureForInternalTexture(h, t, i, void 0, u),
this.updateRawTexture(h, e, n, o, l, c),
this._internalTexturesCache.push(h),
h
}
,
Qh.prototype.updateRawTexture = function(e, t, i, n, r, o) {
if (void 0 === r && (r = null),
void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT),
e) {
if (this._doNotHandleContextLost || (e._bufferView = t,
e.invertY = n,
e._compression = r),
t) {
var s = e._hardwareTexture;
i === a.TEXTUREFORMAT_RGB && (t = $h(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, n, !1, 0, 0),
e.generateMipMaps && this._generateMipmaps(e, this._uploadEncoder)
}
e.isReady = !0
}
}
,
Qh.prototype.createRawCubeTexture = function(e, t, i, n, r, o, s, l) {
void 0 === l && (l = null);
var c = new Lt(this,At.CubeRaw);
return n !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering ? n !== a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering ? n !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatRender ? n !== a.TEXTURETYPE_HALF_FLOAT || this._caps.colorBufferFloat || (r = !1,
K.Warn("Render to half float textures is not supported. Mipmap generation forced to false.")) : (r = !1,
K.Warn("Render to float textures is not supported. Mipmap generation forced to false.")) : (r = !1,
s = a.TEXTURE_NEAREST_SAMPLINGMODE,
K.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")) : (r = !1,
s = a.TEXTURE_NEAREST_SAMPLINGMODE,
K.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 = n,
c.generateMipMaps = r,
c.width = t,
c.height = t,
c.samplingMode = s,
this._doNotHandleContextLost || (c._bufferViewArray = e),
c._cachedWrapU = a.TEXTURE_CLAMP_ADDRESSMODE,
c._cachedWrapV = a.TEXTURE_CLAMP_ADDRESSMODE,
this._textureHelper.createGPUTextureForInternalTexture(c),
e && this.updateRawCubeTexture(c, e, i, n, o, l),
c
}
,
Qh.prototype.updateRawCubeTexture = function(e, t, i, n, r, o) {
void 0 === o && (o = null),
e._bufferViewArray = t,
e.invertY = r,
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 = $h(t[u], e.width, e.height, n)),
c.push(new Uint8Array(h.buffer,h.byteOffset,h.byteLength))
}
this._textureHelper.updateCubeTextures(c, s.underlyingResource, e.width, e.height, s.format, r, !1, 0, 0),
e.generateMipMaps && this._generateMipmaps(e, this._uploadEncoder),
e.isReady = !0
}
,
Qh.prototype.createRawCubeTextureFromUrl = function(e, t, i, n, r, 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, n, r, !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 = n === 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 = $h(E, y, y, r)),
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, n, r, 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
}
,
Qh.prototype.createRawTexture3D = function(e, t, i, n, r, 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 = At.Raw3D
, p = new Lt(this,d);
return p.baseWidth = t,
p.baseHeight = i,
p.baseDepth = n,
p.width = t,
p.height = i,
p.depth = n,
p.format = r,
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, r, s, c, u),
this._internalTexturesCache.push(p),
p
}
,
Qh.prototype.updateRawTexture3D = function(e, t, i, n, r, o) {
if (void 0 === r && (r = null),
void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT),
this._doNotHandleContextLost || (e._bufferView = t,
e.format = i,
e.invertY = n,
e._compression = r),
t) {
var s = e._hardwareTexture;
i === a.TEXTUREFORMAT_RGB && (t = $h(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, n, !1, 0, 0),
e.generateMipMaps && this._generateMipmaps(e, this._uploadEncoder)
}
e.isReady = !0
}
,
Qh.prototype.createRawTexture2DArray = function(e, t, i, n, r, 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 = At.Raw2DArray
, p = new Lt(this,d);
return p.baseWidth = t,
p.baseHeight = i,
p.baseDepth = n,
p.width = t,
p.height = i,
p.depth = n,
p.format = r,
p.type = u,
p.generateMipMaps = o,
p.samplingMode = l,
p.is2DArray = !0,
this._doNotHandleContextLost || (p._bufferView = e),
this._textureHelper.createGPUTextureForInternalTexture(p, t, i, n, h),
this.updateRawTexture2DArray(p, e, r, s, c, u),
this._internalTexturesCache.push(p),
p
}
,
Qh.prototype.updateRawTexture2DArray = function(e, t, i, n, r, o) {
if (void 0 === r && (r = null),
void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT),
this._doNotHandleContextLost || (e._bufferView = t,
e.format = i,
e.invertY = n,
e._compression = r),
t) {
var s = e._hardwareTexture;
i === a.TEXTUREFORMAT_RGB && (t = $h(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, n, !1, 0, 0),
e.generateMipMaps && this._generateMipmaps(e, this._uploadEncoder)
}
e.isReady = !0
}
,
Qh.prototype._readTexturePixels = function(e, t, i, n, r, o, a, s) {
void 0 === n && (n = -1),
void 0 === r && (r = 0),
void 0 === o && (o = null),
void 0 === a && (a = !0),
void 0 === s && (s = !1);
var l = e._hardwareTexture;
return a && this.flushFramebuffer(),
this._textureHelper.readPixels(l.underlyingResource, 0, 0, t, i, l.format, n, r, o, s)
}
,
Qh.prototype._readTexturePixelsSync = function() {
throw "_readTexturePixelsSync is unsupported in WebGPU!"
}
;
var ed = function(e) {
function t() {
return null !== e && e.apply(this, arguments) || this
}
return U(t, e),
t
}(Fa);
Qh.prototype._createHardwareRenderTargetWrapper = function(e, t, i) {
var n = new ed(e,t,i,this);
return this._renderTargetWrapperCache.push(n),
n
}
,
Qh.prototype.createRenderTargetTexture = function(e, t) {
var i, n = 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.samplingMode = void 0 === t.samplingMode ? a.TEXTURE_TRILINEAR_SAMPLINGMODE : t.samplingMode,
r.creationFlags = null !== (i = t.creationFlags) && void 0 !== i ? i : 0) : (r.generateMipMaps = t,
r.generateDepthBuffer = !0,
r.generateStencilBuffer = !1,
r.samplingMode = a.TEXTURE_TRILINEAR_SAMPLINGMODE,
r.creationFlags = 0);
var o = this._createInternalTexture(e, t, !0, At.RenderTarget);
return n._generateDepthBuffer = r.generateDepthBuffer,
n._generateStencilBuffer = !!r.generateStencilBuffer,
n.setTextures(o),
(n._generateDepthBuffer || n._generateStencilBuffer) && n.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, n._generateStencilBuffer, n.samples),
void 0 !== t && "object" == typeof t && t.createMipMaps && !r.generateMipMaps && (o.generateMipMaps = !0),
this._textureHelper.createGPUTextureForInternalTexture(o, void 0, void 0, void 0, r.creationFlags),
void 0 !== t && "object" == typeof t && t.createMipMaps && !r.generateMipMaps && (o.generateMipMaps = !1),
n
}
,
Qh.prototype._createDepthStencilTexture = function(e, t) {
var i = new Lt(this,At.DepthStencil)
, n = V({
bilinearFiltering: !1,
comparisonFunction: 0,
generateStencil: !1,
samples: 1,
depthTextureFormat: a.TEXTUREFORMAT_DEPTH32_FLOAT
}, t);
return i.format = n.generateStencil ? a.TEXTUREFORMAT_DEPTH24_STENCIL8 : n.depthTextureFormat,
this._setupDepthStencilTexture(i, e, n.generateStencil, n.bilinearFiltering, n.comparisonFunction, n.samples),
this._textureHelper.createGPUTextureForInternalTexture(i),
this._internalTexturesCache.push(i),
i
}
,
Qh.prototype._setupDepthStencilTexture = function(e, t, i, n, r, 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 = n ? a.TEXTURE_BILINEAR_SAMPLINGMODE : a.TEXTURE_NEAREST_SAMPLINGMODE,
e.type = a.TEXTURETYPE_FLOAT,
e._comparisonFunction = r,
e._cachedWrapU = a.TEXTURE_CLAMP_ADDRESSMODE,
e._cachedWrapV = a.TEXTURE_CLAMP_ADDRESSMODE
}
,
Qh.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.texture.samples = t,
t) : t
}
,
Qh.prototype.createRenderTargetCubeTexture = function(e, t) {
var i = this._createHardwareRenderTargetWrapper(!1, !0, e)
, n = V({
generateMipMaps: !0,
generateDepthBuffer: !0,
generateStencilBuffer: !1,
type: a.TEXTURETYPE_UNSIGNED_INT,
samplingMode: a.TEXTURE_TRILINEAR_SAMPLINGMODE,
format: a.TEXTUREFORMAT_RGBA,
samples: 1
}, t);
n.generateStencilBuffer = n.generateDepthBuffer && n.generateStencilBuffer,
i._generateDepthBuffer = n.generateDepthBuffer,
i._generateStencilBuffer = n.generateStencilBuffer;
var r = new Lt(this,At.RenderTarget);
return r.width = e,
r.height = e,
r.depth = 0,
r.isReady = !0,
r.isCube = !0,
r.samples = n.samples,
r.generateMipMaps = n.generateMipMaps,
r.samplingMode = n.samplingMode,
r.type = n.type,
r.format = n.format,
this._internalTexturesCache.push(r),
i.setTextures(r),
(i._generateDepthBuffer || i._generateStencilBuffer) && i.createDepthStencilTexture(0, void 0 === n.samplingMode || n.samplingMode === a.TEXTURE_BILINEAR_SAMPLINGMODE || n.samplingMode === a.TEXTURE_LINEAR_LINEAR || n.samplingMode === a.TEXTURE_TRILINEAR_SAMPLINGMODE || n.samplingMode === a.TEXTURE_LINEAR_LINEAR_MIPLINEAR || n.samplingMode === a.TEXTURE_NEAREST_LINEAR_MIPNEAREST || n.samplingMode === a.TEXTURE_NEAREST_LINEAR_MIPLINEAR || n.samplingMode === a.TEXTURE_NEAREST_LINEAR || n.samplingMode === a.TEXTURE_LINEAR_LINEAR_MIPNEAREST, i._generateStencilBuffer, i.samples),
t && t.createMipMaps && !n.generateMipMaps && (r.generateMipMaps = !0),
this._textureHelper.createGPUTextureForInternalTexture(r),
t && t.createMipMaps && !n.generateMipMaps && (r.generateMipMaps = !1),
i
}
,
Mt.prototype.setTextureSampler = function(e, t) {
this._engine.setTextureSampler(e, t)
}
,
Qh.prototype.setTextureSampler = function(e, t) {
var i;
null === (i = this._currentMaterialContext) || void 0 === i || i.setSampler(e, t)
}
,
Mt.prototype.setStorageBuffer = function(e, t) {
this._engine.setStorageBuffer(e, t)
}
,
Qh.prototype.createStorageBuffer = function(e, t) {
return this._createBuffer(e, t | a.BUFFER_CREATIONFLAG_STORAGE)
}
,
Qh.prototype.updateStorageBuffer = function(e, t, i, n) {
var r, o = e;
void 0 === i && (i = 0),
void 0 === n ? n = (r = t instanceof Array ? new Float32Array(t) : t instanceof ArrayBuffer ? new Uint8Array(t) : t).byteLength : r = t instanceof Array ? new Float32Array(t) : t instanceof ArrayBuffer ? new Uint8Array(t) : t,
this._bufferManager.setSubData(o, i, r, 0, n)
}
,
Qh.prototype.readFromStorageBuffer = function(e, t, i, n) {
var r = this;
i = i || e.capacity;
var o = this._bufferManager.createRawBuffer(i, fu.MapRead | fu.CopyDst);
return this._renderTargetEncoder.copyBufferToBuffer(e.underlyingResource, null != t ? t : 0, o, 0, i),
new Promise((function(e, t) {
r.onEndFrameObservable.addOnce((function() {
o.mapAsync(_u.Read, 0, i).then((function() {
var t = o.getMappedRange(0, i)
, a = n;
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(),
r._bufferManager.releaseBuffer(o),
e(a)
}
), (function(e) {
return t(e)
}
))
}
))
}
))
}
,
Qh.prototype.setStorageBuffer = function(e, t) {
var i, n;
null === (i = this._currentDrawContext) || void 0 === i || i.setBuffer(e, null !== (n = null == t ? void 0 : t.getBuffer()) && void 0 !== n ? n : null)
}
,
Qh.prototype.createUniformBuffer = function(e) {
var t;
return t = e instanceof Array ? new Float32Array(e) : e,
this._bufferManager.createBuffer(t, fu.Uniform | fu.CopyDst)
}
,
Qh.prototype.createDynamicUniformBuffer = function(e) {
return this.createUniformBuffer(e)
}
,
Qh.prototype.updateUniformBuffer = function(e, t, i, n) {
void 0 === i && (i = 0);
var r, o = e;
void 0 === n ? n = (r = t instanceof Float32Array ? t : new Float32Array(t)).byteLength : r = t instanceof Float32Array ? t : new Float32Array(t),
this._bufferManager.setSubData(o, i, r, 0, n)
}
,
Qh.prototype.bindUniformBufferBase = function(e, t, i) {
this._currentDrawContext.setBuffer(i, e)
}
,
Qh.prototype.bindUniformBlock = function() {}
,
Qh.prototype.updateVideoTexture = function(e, t, i) {
var n, r = this;
if (e && !e._isDisabled) {
void 0 === this._videoTextureSupported && (this._videoTextureSupported = !0);
var o = e._hardwareTexture;
(null === (n = e._hardwareTexture) || void 0 === n ? void 0 : n.underlyingResource) || (o = this._textureHelper.createGPUTextureForInternalTexture(e)),
this.createImageBitmap(t).then((function(t) {
r._textureHelper.updateTexture(t, e, e.width, e.height, e.depth, o.format, 0, 0, !i, !1, 0, 0),
e.generateMipMaps && r._generateMipmaps(e, r._uploadEncoder),
e.isReady = !0
}
)).catch((function() {
e.isReady = !0
}
))
}
}
;
var td, id = function() {
function e() {}
return e.CreateAsync = function(e, t) {
return Qh.IsSupportedAsync.then((function(i) {
return i ? Qh.CreateAsync(e, t) : vr.IsSupported ? new Promise((function(i) {
i(new vr(e,void 0,t))
}
)) : new Promise((function(e) {
e(new dc(t))
}
))
}
))
}
,
e
}(), nd = function() {
function e() {}
return e.COPY = 1,
e.CUT = 2,
e.PASTE = 3,
e
}(), rd = function() {
function e(e, t) {
this.type = e,
this.event = t
}
return e.GetTypeFromCharacter = function(e) {
switch (e) {
case 67:
return nd.COPY;
case 86:
return nd.PASTE;
case 88:
return nd.CUT;
default:
return -1
}
}
,
e
}();
!function(e) {
e[e.Clean = 0] = "Clean",
e[e.Stop = 1] = "Stop",
e[e.Sync = 2] = "Sync",
e[e.NoSync = 3] = "NoSync"
}(td || (td = {}));
var od = function() {
function e() {}
return Object.defineProperty(e, "ForceFullSceneLoadingForIncremental", {
get: function() {
return dr.ForceFullSceneLoadingForIncremental
},
set: function(e) {
dr.ForceFullSceneLoadingForIncremental = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "ShowLoadingScreen", {
get: function() {
return dr.ShowLoadingScreen
},
set: function(e) {
dr.ShowLoadingScreen = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "loggingLevel", {
get: function() {
return dr.loggingLevel
},
set: function(e) {
dr.loggingLevel = e
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e, "CleanBoneMatrixWeights", {
get: function() {
return dr.CleanBoneMatrixWeights
},
set: function(e) {
dr.CleanBoneMatrixWeights = e
},
enumerable: !1,
configurable: !0
}),
e.GetDefaultPlugin = function() {
return e._RegisteredPlugins[".babylon"]
}
,
e._GetPluginForExtension = function(t) {
return e._RegisteredPlugins[t] || (K.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/how_to/load_from_any_file_type"),
e.GetDefaultPlugin())
}
,
e._GetPluginForDirectLoad = function(t) {
for (var i in e._RegisteredPlugins) {
var n = e._RegisteredPlugins[i].plugin;
if (n.canDirectLoad && n.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 n = t.lastIndexOf(".")
, r = t.substring(n, t.length).toLowerCase();
return e._GetPluginForExtension(r)
}
,
e._GetDirectLoad = function(e) {
return "data:" === e.substr(0, 5) ? e.substr(5) : null
}
,
e._FormatErrorMessage = function(e, t, i) {
var n = "Unable to load from " + e.url;
return t ? n += ": ".concat(t) : i && (n += ": ".concat(i)),
n
}
,
e._LoadData = function(t, i, n, r, o, a, s) {
var l, c = e._GetDirectLoad(t.url), u = s ? e._GetPluginForExtension(s) : c ? e._GetPluginForDirectLoad(t.url) : e._GetPluginForFilename(t.url);
if (!(l = void 0 !== u.plugin.createPlugin ? u.plugin.createPlugin() : u.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(l),
c && (l.canDirectLoad && l.canDirectLoad(t.url) || !ri(t.url))) {
if (l.directLoad) {
var h = l.directLoad(i, c);
h.then ? h.then((function(e) {
n(l, e)
}
)).catch((function(e) {
o("Error in directLoad of _loadData: " + e, e)
}
)) : n(l, h)
} else
n(l, c);
return l
}
var d = u.isBinary
, p = function(e, t) {
i.isDisposed ? o("Scene has been disposed") : n(l, e, t)
}
, f = null
, _ = !1
, m = l.onDisposeObservable;
m && m.add((function() {
_ = !0,
f && (f.abort(),
f = null),
a()
}
));
var g = function() {
if (!_) {
var e = function(e, t) {
o(null == e ? void 0 : e.statusText, t)
}
, n = t.file || t.url;
f = l.loadFile ? l.loadFile(i, n, p, r, d, e) : i._loadFile(n, p, r, !0, d, e)
}
}
, v = i.getEngine()
, y = v.enableOfflineSupport;
if (y) {
for (var b = !1, T = 0, E = i.disableOfflineSupportExceptionRules; T < E.length; T++)
if (E[T].test(t.url)) {
b = !0;
break
}
y = !b
}
return y && vr.OfflineProviderFactory ? i.offlineProvider = vr.OfflineProviderFactory(t.url, g, v.disableManifestCheck) : g(),
l
}
,
e._GetFileInfo = function(e, t) {
var i, n, r = null;
if (t)
if (t.name) {
var o = t;
i = "file:".concat(o.name),
n = o.name,
r = o
} else if ("string" == typeof t && ae(t, "data:"))
i = t,
n = "";
else {
var a = t;
if ("/" === a.substr(0, 1))
return gi.Error("Wrong sceneFilename parameter"),
null;
i = e + a,
n = a
}
else
i = e,
n = gi.GetFilename(e),
e = gi.GetFolderPath(e);
return {
url: i,
rootUrl: e,
name: n,
file: r
}
}
,
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 n = t.extensions;
Object.keys(n).forEach((function(i) {
e._RegisteredPlugins[i.toLowerCase()] = {
plugin: t,
isBinary: n[i].isBinary
}
}
))
}
}
,
e.ImportMesh = function(t, i, n, r, o, a, s, l) {
if (void 0 === n && (n = ""),
void 0 === r && (r = E.LastCreatedScene),
void 0 === o && (o = null),
void 0 === a && (a = null),
void 0 === s && (s = null),
void 0 === l && (l = null),
!r)
return K.Error("No scene available to import mesh to"),
null;
var c = e._GetFileInfo(i, n);
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);
s ? s(r, n, new ft(n,pt.SceneLoaderError,i)) : K.Error(n),
h()
}
, p = a ? function(e) {
try {
a(e)
} catch (e) {
d("Error in onProgress callback: " + e, e)
}
}
: void 0
, f = function(e, t, i, n, a, s, l) {
if (r.importedMeshesFiles.push(c.url),
o)
try {
o(e, t, i, n, a, s, l)
} catch (e) {
d("Error in onSuccess callback: " + e, e)
}
r._removePendingData(u)
};
return e._LoadData(c, r, (function(e, i, n) {
if (e.rewriteRootURL && (c.rootUrl = e.rewriteRootURL(c.rootUrl, n)),
e.importMesh) {
var o = e
, a = new Array
, s = new Array
, l = new Array;
if (!o.importMesh(t, r, i, c.rootUrl, a, s, l, d))
return;
r.loadingPluginName = e.name,
f(a, s, l, [], [], [], [])
} else
e.importMeshAsync(t, r, i, c.rootUrl, p, c.name).then((function(t) {
r.loadingPluginName = e.name,
f(t.meshes, t.particleSystems, t.skeletons, t.animationGroups, t.transformNodes, t.geometries, t.lights)
}
)).catch((function(e) {
d(e.message, e)
}
))
}
), p, d, h, l)
}
,
e.ImportMeshAsync = function(t, i, n, r, o, a) {
return void 0 === n && (n = ""),
void 0 === r && (r = E.LastCreatedScene),
void 0 === o && (o = null),
void 0 === a && (a = null),
new Promise((function(s, l) {
e.ImportMesh(t, i, n, r, (function(e, t, i, n, r, o, a) {
s({
meshes: e,
particleSystems: t,
skeletons: i,
animationGroups: n,
transformNodes: r,
geometries: o,
lights: a
})
}
), o, (function(e, t, i) {
l(i || new Error(t))
}
), a)
}
))
}
,
e.Load = function(t, i, n, r, o, a, s) {
return void 0 === i && (i = ""),
void 0 === n && (n = E.LastCreatedEngine),
void 0 === r && (r = null),
void 0 === o && (o = null),
void 0 === a && (a = null),
void 0 === s && (s = null),
n ? e.Append(t, i, new mn(n), r, o, a, s) : (gi.Error("No engine available"),
null)
}
,
e.LoadAsync = function(t, i, n, r, o) {
return void 0 === i && (i = ""),
void 0 === n && (n = E.LastCreatedEngine),
void 0 === r && (r = null),
void 0 === o && (o = null),
new Promise((function(a, s) {
e.Load(t, i, n, (function(e) {
a(e)
}
), r, (function(e, t, i) {
s(i || new Error(t))
}
), o)
}
))
}
,
e.Append = function(t, i, n, r, o, a, s) {
var l = this;
if (void 0 === i && (i = ""),
void 0 === n && (n = E.LastCreatedScene),
void 0 === r && (r = null),
void 0 === o && (o = null),
void 0 === a && (a = null),
void 0 === s && (s = null),
!n)
return K.Error("No scene available to append to"),
null;
var c = e._GetFileInfo(t, i);
if (!c)
return null;
e.ShowLoadingScreen && !this._ShowingLoadingScreen && (this._ShowingLoadingScreen = !0,
n.getEngine().displayLoadingUI(),
n.executeWhenReady((function() {
n.getEngine().hideLoadingUI(),
l._ShowingLoadingScreen = !1
}
)));
var u = {};
n._addPendingData(u);
var h = function() {
n._removePendingData(u)
}
, d = function(t, i) {
var r = e._FormatErrorMessage(c, t, i);
a ? a(n, r, new ft(r,pt.SceneLoaderError,i)) : K.Error(r),
h()
}
, p = o ? function(e) {
try {
o(e)
} catch (e) {
d("Error in onProgress callback", e)
}
}
: void 0
, f = function() {
if (r)
try {
r(n)
} catch (e) {
d("Error in onSuccess callback", e)
}
n._removePendingData(u)
};
return e._LoadData(c, n, (function(e, t) {
if (e.load) {
if (!e.load(n, t, c.rootUrl, d))
return;
n.loadingPluginName = e.name,
f()
} else
e.loadAsync(n, t, c.rootUrl, p, c.name).then((function() {
n.loadingPluginName = e.name,
f()
}
)).catch((function(e) {
d(e.message, e)
}
))
}
), p, d, h, s)
}
,
e.AppendAsync = function(t, i, n, r, o) {
return void 0 === i && (i = ""),
void 0 === n && (n = E.LastCreatedScene),
void 0 === r && (r = null),
void 0 === o && (o = null),
new Promise((function(a, s) {
e.Append(t, i, n, (function(e) {
a(e)
}
), r, (function(e, t, i) {
s(i || new Error(t))
}
), o)
}
))
}
,
e.LoadAssetContainer = function(t, i, n, r, o, a, s) {
if (void 0 === i && (i = ""),
void 0 === n && (n = E.LastCreatedScene),
void 0 === r && (r = null),
void 0 === o && (o = null),
void 0 === a && (a = null),
void 0 === s && (s = null),
!n)
return K.Error("No scene available to load asset container to"),
null;
var l = e._GetFileInfo(t, i);
if (!l)
return null;
var c = {};
n._addPendingData(c);
var u = function() {
n._removePendingData(c)
}
, h = function(t, i) {
var r = e._FormatErrorMessage(l, t, i);
a ? a(n, r, new ft(r,pt.SceneLoaderError,i)) : K.Error(r),
u()
}
, d = o ? function(e) {
try {
o(e)
} catch (e) {
h("Error in onProgress callback", e)
}
}
: void 0
, p = function(e) {
if (r)
try {
r(e)
} catch (e) {
h("Error in onSuccess callback", e)
}
n._removePendingData(c)
};
return e._LoadData(l, n, (function(e, t) {
if (e.loadAssetContainer) {
var i = e.loadAssetContainer(n, t, l.rootUrl, h);
if (!i)
return;
n.loadingPluginName = e.name,
p(i)
} else
e.loadAssetContainerAsync ? e.loadAssetContainerAsync(n, t, l.rootUrl, d, l.name).then((function(t) {
n.loadingPluginName = e.name,
p(t)
}
)).catch((function(e) {
h(e.message, e)
}
)) : h("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.")
}
), d, h, u, s)
}
,
e.LoadAssetContainerAsync = function(t, i, n, r, o) {
return void 0 === i && (i = ""),
void 0 === n && (n = E.LastCreatedScene),
void 0 === r && (r = null),
void 0 === o && (o = null),
new Promise((function(a, s) {
e.LoadAssetContainer(t, i, n, (function(e) {
a(e)
}
), r, (function(e, t, i) {
s(i || new Error(t))
}
), o)
}
))
}
,
e.ImportAnimations = function(e, t, i, n, r, o, a, s, l, c) {
if (void 0 === t && (t = ""),
void 0 === i && (i = E.LastCreatedScene),
void 0 === n && (n = !0),
void 0 === r && (r = td.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 (n) {
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 (r) {
case td.Clean:
i.animationGroups.slice().forEach((function(e) {
e.dispose()
}
));
break;
case td.Stop:
i.animationGroups.forEach((function(e) {
e.stop()
}
));
break;
case td.Sync:
i.animationGroups.forEach((function(e) {
e.reset(),
e.restart()
}
));
break;
case td.NoSync:
break;
default:
return void K.Error("Unknown animation group loading mode value '" + r + "'")
}
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
K.Error("No scene available to load animations to")
}
,
e.ImportAnimationsAsync = function(t, i, n, r, o, a, s, l, c, u) {
return void 0 === i && (i = ""),
void 0 === n && (n = E.LastCreatedScene),
void 0 === r && (r = !0),
void 0 === o && (o = td.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, n, r, 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 h,
e._RegisteredPlugins = {},
e._ShowingLoadingScreen = !1,
e
}()
, ad = function(e) {
function t(t) {
var i = e.call(this, t) || this;
return i.controllerType = ba.DAYDREAM,
i
}
return U(t, e),
t.prototype.initControllerMesh = function(e, i) {
var n = this;
od.ImportMesh("", t.MODEL_BASE_URL, t.MODEL_FILENAME, e, (function(e) {
n._defaultModel = e[1],
n.attachToMesh(n._defaultModel),
i && i(n._defaultModel)
}
))
}
,
t.prototype._handleButtonChange = function(e, t) {
if (0 === e) {
var i = this.onTriggerStateChangedObservable;
i && i.notifyObservers(t)
} else
K.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
}(_s);
xa._ControllerFactories.push({
canCreate: function(e) {
return 0 === e.id.indexOf(ad.GAMEPAD_ID_PREFIX)
},
create: function(e) {
return new ad(e)
}
});
var sd = function(e) {
function t(t) {
var i = e.call(this, t) || this;
return i._buttonIndexToObservableNameMap = ["onPadStateChangedObservable", "onTriggerStateChangedObservable"],
i.controllerType = ba.GEAR_VR,
i._calculatedPosition = new x("left" == i.hand ? -.15 : .15,-.5,.25),
i._disableTrackPosition(i._calculatedPosition),
i
}
return U(t, e),
t.prototype.initControllerMesh = function(e, i) {
var n = this;
od.ImportMesh("", t.MODEL_BASE_URL, t.MODEL_FILENAME, e, (function(t) {
var r = new Vr("",e);
t[1].parent = r,
t[1].position.z = -.15,
n._defaultModel = r,
n.attachToMesh(n._defaultModel),
i && i(n._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
}(_s);
xa._ControllerFactories.push({
canCreate: function(e) {
return 0 === e.id.indexOf(sd.GAMEPAD_ID_PREFIX) || -1 !== e.id.indexOf("Oculus Go") || -1 !== e.id.indexOf("Vive Focus")
},
create: function(e) {
return new sd(e)
}
});
var ld = function(e) {
function t(t) {
return e.call(this, t) || this
}
return U(t, e),
t.prototype.initControllerMesh = function(e, i) {
var n = this;
od.ImportMesh("", t.MODEL_BASE_URL, t.MODEL_FILENAME, e, (function(e) {
n._defaultModel = e[1],
n.attachToMesh(n._defaultModel),
i && i(n._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
}(_s);
xa._DefaultControllerFactory = function(e) {
return new ld(e)
}
;
var cd = function(e) {
function t(t) {
var i = e.call(this, t) || this;
return i.onSecondaryTriggerStateChangedObservable = new h,
i.onThumbRestChangedObservable = new h,
i.controllerType = ba.OCULUS,
i
}
return U(t, e),
t.prototype.initControllerMesh = function(e, i) {
var n, r = this;
n = "left" === this.hand ? t.MODEL_LEFT_FILENAME : t.MODEL_RIGHT_FILENAME,
od.ImportMesh("", t._IsQuest ? t.QUEST_MODEL_BASE_URL : t.MODEL_BASE_URL, n, e, (function(e) {
r._defaultModel = t._IsQuest ? e[0] : e[1],
r.attachToMesh(r._defaultModel),
i && i(r._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 n = i
, r = "right" === this.hand ? -1 : 1;
switch (e) {
case 0:
return void this.onPadStateChangedObservable.notifyObservers(n);
case 1:
return !t._IsQuest && this._defaultModel && (this._defaultModel.getChildren()[3].rotation.x = .2 * -n.value,
this._defaultModel.getChildren()[3].position.y = .005 * -n.value,
this._defaultModel.getChildren()[3].position.z = .005 * -n.value),
void this.onTriggerStateChangedObservable.notifyObservers(n);
case 2:
return !t._IsQuest && this._defaultModel && (this._defaultModel.getChildren()[4].position.x = r * n.value * .0035),
void this.onSecondaryTriggerStateChangedObservable.notifyObservers(n);
case 3:
return !t._IsQuest && this._defaultModel && (n.pressed ? this._defaultModel.getChildren()[1].position.y = -.001 : this._defaultModel.getChildren()[1].position.y = 0),
void this.onMainButtonStateChangedObservable.notifyObservers(n);
case 4:
return !t._IsQuest && this._defaultModel && (n.pressed ? this._defaultModel.getChildren()[2].position.y = -.001 : this._defaultModel.getChildren()[2].position.y = 0),
void this.onSecondaryButtonStateChangedObservable.notifyObservers(n);
case 5:
return void this.onThumbRestChangedObservable.notifyObservers(n)
}
}
,
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
}(_s);
xa._ControllerFactories.push({
canCreate: function(e) {
return E.LastCreatedEngine && E.LastCreatedEngine._vrDisplay && "Oculus Quest" === E.LastCreatedEngine._vrDisplay.displayName && (cd._IsQuest = !0),
-1 !== e.id.indexOf("Oculus Touch")
},
create: function(e) {
return new cd(e)
}
});
var ud = function(e) {
function t(t) {
var i = e.call(this, t) || this;
return i.controllerType = ba.VIVE,
i._invertLeftStickY = !0,
i
}
return U(t, e),
t.prototype.initControllerMesh = function(e, i) {
var n = this;
od.ImportMesh("", t.MODEL_BASE_URL, t.MODEL_FILENAME, e, (function(e) {
n._defaultModel = e[1],
n.attachToMesh(n._defaultModel),
i && i(n._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
}(_s);
xa._ControllerFactories.push({
canCreate: function(e) {
return -1 !== e.id.toLowerCase().indexOf("openvr")
},
create: function(e) {
return new ud(e)
}
});
var hd = function() {
this.buttonMeshes = {},
this.axisMeshes = {}
}
, dd = 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: Ra.POINTING_POSE
},
i.onTrackpadChangedObservable = new h,
i.onTrackpadValuesChangedObservable = new h,
i.trackpad = {
x: 0,
y: 0
},
i.controllerType = ba.WINDOWS,
i._loadedMeshInfo = null,
i
}
return U(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 n = this[this._mapping.buttonObservableNames[i]];
n && n.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 && (C.SlerpToRef(i.unpressed.rotationQuaternion, i.pressed.rotationQuaternion, t, i.value.rotationQuaternion),
x.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 n = .5 * t + .5;
C.SlerpToRef(i.min.rotationQuaternion, i.max.rotationQuaternion, n, i.value.rotationQuaternion),
x.LerpToRef(i.min.position, i.max.position, n, i.value.position)
}
}
}
,
t.prototype.initControllerMesh = function(e, i, n) {
var r, o, a = this;
if (void 0 === n && (n = !1),
od.IsPluginForExtensionAvailable(".glb")) {
var s = "default";
if (this.id && !n) {
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,
r = t.MODEL_BASE_URL + s + "/"
} else
K.Warn("You need to reference GLTF loader to load Windows Motion Controllers model. Falling back to generic models"),
r = ld.MODEL_BASE_URL,
o = ld.MODEL_FILENAME;
od.ImportMesh("", r, 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) {
K.Log(t),
K.Warn("Failed to retrieve controller model from the remote server: " + r + o),
n || a.initControllerMesh(e, i, !0)
}
))
}
,
t.prototype._processModel = function(e, t) {
for (var i = null, n = new Vr(this.id + " " + this.hand,e), r = null, o = 0; o < t.length; o++) {
var a = t[o];
if (!a.parent) {
a.isPickable = !1,
r = a;
break
}
}
return r ? (r.setParent(n),
i = this._createMeshInfo(n)) : K.Warn("Could not find root node in model file."),
i
}
,
t.prototype._createMeshInfo = function(e) {
var t, i = new hd;
for (i.rootNode = e,
i.buttonMeshes = {},
i.axisMeshes = {},
t = 0; t < this._mapping.buttons.length; t++) {
var n = this._mapping.buttonMeshNames[this._mapping.buttons[t]];
if (n) {
var r = c(e, n);
if (r) {
var o = {
index: t,
value: u(r, "VALUE"),
pressed: u(r, "PRESSED"),
unpressed: u(r, "UNPRESSED")
};
o.value && o.pressed && o.unpressed ? i.buttonMeshes[this._mapping.buttons[t]] = o : K.Warn("Missing button submesh under mesh with name: " + n + "(VALUE: " + !!o.value + ", PRESSED: " + !!o.pressed + ", UNPRESSED:" + !!o.unpressed + ")")
} else
K.Warn("Missing button mesh with name: " + n)
} else
K.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 : K.Warn("Missing axis submesh under mesh with name: " + a + "(VALUE: " + !!l.value + ", MIN: " + !!l.min + ", MAX:" + !!l.max + ")")
} else
K.Warn("Missing axis mesh with name: " + a)
} else
K.Log("Skipping unknown axis at index: " + t)
}
return i.pointingPoseNode = c(e, this._mapping.pointingPoseMeshName),
i.pointingPoseNode ? this._pointingPoseNode = i.pointingPoseNode : K.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()
, n = i.getTranslation()
, r = new x(0,0,-1)
, o = x.TransformNormal(r, i)
, a = x.Normalize(o);
return new _o(n,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
}(_s)
, pd = 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: Ra.POINTING_POSE
},
i.thumbstickValues = {
x: 0,
y: 0
},
i.onThumbstickStateChangedObservable = new h,
i.onThumbstickValuesChangedObservable = new h,
i.onTrackpadChangedObservable = i.onPadStateChangedObservable,
i.onTrackpadValuesChangedObservable = i.onPadValuesChangedObservable,
i
}
return U(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
}(dd);
xa._ControllerFactories.push({
canCreate: function(e) {
return 0 === e.id.indexOf(dd.GAMEPAD_ID_PREFIX)
},
create: function(e) {
return new dd(e)
}
});
var fd = function(e) {
function t(t, i, n, r, o) {
void 0 === i && (i = D.Gray()),
void 0 === n && (n = El.DefaultUtilityLayer),
void 0 === r && (r = null),
void 0 === o && (o = 1);
var a, s, l, c, u, d, p, f = this;
(f = e.call(this, n) || this)._pointerObserver = null,
f.snapDistance = 0,
f.onSnapObservable = new h,
f.uniformScaling = !1,
f.sensitivity = 1,
f.dragScale = 1,
f._isEnabled = !0,
f._parent = null,
f._dragging = !1,
f._tmpVector = new x,
f._tmpMatrix = new P,
f._tmpMatrix2 = new P,
f._parent = r,
f._coloredMaterial = new Os("",n.utilityLayerScene),
f._coloredMaterial.diffuseColor = i,
f._coloredMaterial.specularColor = i.subtract(new D(.1,.1,.1)),
f._hoverMaterial = new Os("",n.utilityLayerScene),
f._hoverMaterial.diffuseColor = D.Yellow(),
f._disableMaterial = new Os("",n.utilityLayerScene),
f._disableMaterial.diffuseColor = D.Gray(),
f._disableMaterial.alpha = .4,
f._gizmoMesh = new Vr("axis",n.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),
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 Ao({
dragAxis: t
}),
f.dragBehavior.moveAttached = !1,
f._rootMesh.addBehavior(f.dragBehavior);
var A = 0
, R = new x
, C = {
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())
, n = !1
, r = 0;
f.uniformScaling ? R.setAll(.57735) : R.copyFrom(t),
0 == f.snapDistance ? R.scaleToRef(i, R) : (A += i,
Math.abs(A) > f.snapDistance ? (r = Math.floor(Math.abs(A) / f.snapDistance),
A < 0 && (r *= -1),
A %= f.snapDistance,
R.scaleToRef(f.snapDistance * r, R),
n = !0) : R.scaleInPlace(0)),
P.ScalingToRef(1 + R.x, 1 + R.y, 1 + R.z, f._tmpMatrix2),
f._tmpMatrix2.multiplyToRef(f.attachedNode.getWorldMatrix(), f._tmpMatrix),
f._tmpMatrix.decompose(f._tmpVector);
var o = 1e5;
Math.abs(f._tmpVector.x) < o && Math.abs(f._tmpVector.y) < o && Math.abs(f._tmpVector.z) < o && f.attachedNode.getWorldMatrix().copyFrom(f._tmpMatrix),
n && (C.snapDistance = f.snapDistance * r,
f.onSnapObservable.notifyObservers(C)),
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 == r ? void 0 : r.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 === (u = null === (c = null == r ? void 0 : r.uniformScaleGizmo) || void 0 === c ? void 0 : c.dragBehavior) || void 0 === u ? void 0 : u.onDragEndObservable) || void 0 === d || d.add(S);
var M = {
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, M),
f._pointerObserver = n.utilityLayerScene.onPointerObservable.add((function(e) {
var t;
if (!f._customMeshSet && (f._isHovered = !(-1 == M.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(M.gizmoMeshes, i)
}
}
)),
f.dragBehavior.onEnabledObservable.add((function(e) {
f._setGizmoMeshMaterial(M.gizmoMeshes, e ? f._coloredMaterial : f._disableMaterial)
}
));
var I = n._getSharedGizmoLight();
return I.includedOnlyMeshes = I.includedOnlyMeshes.concat(f._rootMesh.getChildMeshes()),
f
}
return U(t, e),
t.prototype._createGizmoMesh = function(e, t, i) {
void 0 === i && (i = !1);
var n = Ml("yPosMesh", {
size: .4 * (1 + (t - 1) / 4)
}, this.gizmoLayer.utilityLayerScene)
, r = Ys("cylinder", {
diameterTop: .005 * t,
height: .275,
diameterBottom: .005 * t,
tessellation: 96
}, this.gizmoLayer.utilityLayerScene);
return n.scaling.scaleInPlace(.1),
n.material = this._coloredMaterial,
n.rotation.x = Math.PI / 2,
n.position.z += .3,
r.material = this._coloredMaterial,
r.position.z += .1375,
r.rotation.x = Math.PI / 2,
i && (n.visibility = 0,
r.visibility = 0),
e.addChild(n),
e.addChild(r),
{
arrowMesh: n,
arrowTail: 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.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 n = this;
void 0 === i && (i = !1),
e.prototype.setCustomMesh.call(this, t),
i && (this._rootMesh.getChildMeshes().forEach((function(e) {
e.material = n._coloredMaterial,
e.color && (e.color = n._coloredMaterial.diffuseColor)
}
)),
this._customMeshSet = !1)
}
,
t
}(Sl)
, _d = function(e) {
function t(t, i) {
void 0 === t && (t = D.Gray()),
void 0 === i && (i = El.DefaultKeepDepthUtilityLayer);
var n = e.call(this, i) || this;
n._boundingDimensions = new x(1,1,1),
n._renderObserver = null,
n._pointerObserver = null,
n._scaleDragSpeed = .2,
n._tmpQuaternion = new C,
n._tmpVector = new x(0,0,0),
n._tmpRotationMatrix = new P,
n.ignoreChildren = !1,
n.includeChildPredicate = null,
n.rotationSphereSize = .1,
n.scaleBoxSize = .1,
n.fixedDragMeshScreenSize = !1,
n.fixedDragMeshBoundsSize = !1,
n.fixedDragMeshScreenSizeDistanceFactor = 10,
n.onDragStartObservable = new h,
n.onScaleBoxDragObservable = new h,
n.onScaleBoxDragEndObservable = new h,
n.onRotationSphereDragObservable = new h,
n.onRotationSphereDragEndObservable = new h,
n.scalePivot = null,
n._axisFactor = new x(1,1,1),
n._existingMeshScale = new x,
n._dragMesh = null,
n._pointerDragBehavior = new Ao,
n.updateScale = !1,
n._anchorMesh = new Sr("anchor",i.utilityLayerScene),
n._coloredMaterial = new Os("",i.utilityLayerScene),
n._coloredMaterial.disableLighting = !0,
n._hoverColoredMaterial = new Os("",i.utilityLayerScene),
n._hoverColoredMaterial.disableLighting = !0,
n._lineBoundingBox = new Sr("",i.utilityLayerScene),
n._lineBoundingBox.rotationQuaternion = new C;
var r = [];
r.push(Jl("lines", {
points: [new x(0,0,0), new x(n._boundingDimensions.x,0,0)]
}, i.utilityLayerScene)),
r.push(Jl("lines", {
points: [new x(0,0,0), new x(0,n._boundingDimensions.y,0)]
}, i.utilityLayerScene)),
r.push(Jl("lines", {
points: [new x(0,0,0), new x(0,0,n._boundingDimensions.z)]
}, i.utilityLayerScene)),
r.push(Jl("lines", {
points: [new x(n._boundingDimensions.x,0,0), new x(n._boundingDimensions.x,n._boundingDimensions.y,0)]
}, i.utilityLayerScene)),
r.push(Jl("lines", {
points: [new x(n._boundingDimensions.x,0,0), new x(n._boundingDimensions.x,0,n._boundingDimensions.z)]
}, i.utilityLayerScene)),
r.push(Jl("lines", {
points: [new x(0,n._boundingDimensions.y,0), new x(n._boundingDimensions.x,n._boundingDimensions.y,0)]
}, i.utilityLayerScene)),
r.push(Jl("lines", {
points: [new x(0,n._boundingDimensions.y,0), new x(0,n._boundingDimensions.y,n._boundingDimensions.z)]
}, i.utilityLayerScene)),
r.push(Jl("lines", {
points: [new x(0,0,n._boundingDimensions.z), new x(n._boundingDimensions.x,0,n._boundingDimensions.z)]
}, i.utilityLayerScene)),
r.push(Jl("lines", {
points: [new x(0,0,n._boundingDimensions.z), new x(0,n._boundingDimensions.y,n._boundingDimensions.z)]
}, i.utilityLayerScene)),
r.push(Jl("lines", {
points: [new x(n._boundingDimensions.x,n._boundingDimensions.y,n._boundingDimensions.z), new x(0,n._boundingDimensions.y,n._boundingDimensions.z)]
}, i.utilityLayerScene)),
r.push(Jl("lines", {
points: [new x(n._boundingDimensions.x,n._boundingDimensions.y,n._boundingDimensions.z), new x(n._boundingDimensions.x,0,n._boundingDimensions.z)]
}, i.utilityLayerScene)),
r.push(Jl("lines", {
points: [new x(n._boundingDimensions.x,n._boundingDimensions.y,n._boundingDimensions.z), new x(n._boundingDimensions.x,n._boundingDimensions.y,0)]
}, i.utilityLayerScene)),
r.forEach((function(e) {
e.color = t,
e.position.addInPlace(new x(-n._boundingDimensions.x / 2,-n._boundingDimensions.y / 2,-n._boundingDimensions.z / 2)),
e.isPickable = !1,
n._lineBoundingBox.addChild(e)
}
)),
n._rootMesh.addChild(n._lineBoundingBox),
n.setColor(t),
n._rotateSpheresParent = new Sr("",i.utilityLayerScene),
n._rotateSpheresParent.rotationQuaternion = new C;
for (var o = function(e) {
var t = Dl("", {
diameter: 1
}, i.utilityLayerScene);
t.rotationQuaternion = new C,
t.material = a._coloredMaterial,
t.isNearGrabbable = !0;
var r = new Ao({});
r.moveAttached = !1,
r.updateDragPlane = !1,
t.addBehavior(r);
var o = new x(1,0,0)
, s = 0;
r.onDragStartObservable.add((function() {
o.copyFrom(t.forward),
s = 0
}
)),
r.onDragObservable.add((function(t) {
if (n.onRotationSphereDragObservable.notifyObservers({}),
n.attachedMesh) {
var i = n.attachedMesh.parent;
if (i && i.scaling && i.scaling.isNonUniformWithinEpsilon(.001))
return void K.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
mo._RemoveAndStorePivotPoint(n.attachedMesh);
var r = o
, a = t.dragPlaneNormal.scale(x.Dot(t.dragPlaneNormal, r))
, l = r.subtract(a).normalizeToNew()
, c = x.Dot(l, t.delta) < 0 ? Math.abs(t.delta.length()) : -Math.abs(t.delta.length());
c = c / n._boundingDimensions.length() * n._anchorMesh.scaling.length(),
n.attachedMesh.rotationQuaternion || (n.attachedMesh.rotationQuaternion = C.RotationYawPitchRoll(n.attachedMesh.rotation.y, n.attachedMesh.rotation.x, n.attachedMesh.rotation.z)),
n._anchorMesh.rotationQuaternion || (n._anchorMesh.rotationQuaternion = C.RotationYawPitchRoll(n._anchorMesh.rotation.y, n._anchorMesh.rotation.x, n._anchorMesh.rotation.z)),
s += c,
Math.abs(s) <= 2 * Math.PI && (e >= 8 ? C.RotationYawPitchRollToRef(0, 0, c, n._tmpQuaternion) : e >= 4 ? C.RotationYawPitchRollToRef(c, 0, 0, n._tmpQuaternion) : C.RotationYawPitchRollToRef(0, c, 0, n._tmpQuaternion),
n._anchorMesh.addChild(n.attachedMesh),
n._anchorMesh.rotationQuaternion.multiplyToRef(n._tmpQuaternion, n._anchorMesh.rotationQuaternion),
n._anchorMesh.removeChild(n.attachedMesh),
n.attachedMesh.setParent(i)),
n.updateBoundingBox(),
mo._RestorePivotPoint(n.attachedMesh)
}
n._updateDummy()
}
)),
r.onDragStartObservable.add((function() {
n.onDragStartObservable.notifyObservers({}),
n._selectNode(t)
}
)),
r.onDragEndObservable.add((function() {
n.onRotationSphereDragEndObservable.notifyObservers({}),
n._selectNode(null),
n._updateDummy()
}
)),
a._rotateSpheresParent.addChild(t)
}, a = this, s = 0; s < 12; s++)
o(s);
for (n._rootMesh.addChild(n._rotateSpheresParent),
n._scaleBoxesParent = new Sr("",i.utilityLayerScene),
n._scaleBoxesParent.rotationQuaternion = new C,
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 r = Ml("", {
size: 1
}, i.utilityLayerScene);
r.material = u._coloredMaterial,
r.metadata = 2 === t,
r.isNearGrabbable = !0;
var o = new x(s - 1,l - 1,e - 1).normalize()
, a = new Ao({
dragAxis: o
});
a.updateDragPlane = !1,
a.moveAttached = !1,
r.addBehavior(a),
a.onDragObservable.add((function(e) {
if (n.onScaleBoxDragObservable.notifyObservers({}),
n.attachedMesh) {
var i = n.attachedMesh.parent;
if (i && i.scaling && i.scaling.isNonUniformWithinEpsilon(.001))
return void K.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
mo._RemoveAndStorePivotPoint(n.attachedMesh);
var a = e.dragDistance / n._boundingDimensions.length() * n._anchorMesh.scaling.length()
, s = new x(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(n._scaleDragSpeed),
s.multiplyInPlace(n._axisFactor),
n.updateBoundingBox(),
n.scalePivot ? (n.attachedMesh.getWorldMatrix().getRotationMatrixToRef(n._tmpRotationMatrix),
n._boundingDimensions.scaleToRef(.5, n._tmpVector),
x.TransformCoordinatesToRef(n._tmpVector, n._tmpRotationMatrix, n._tmpVector),
n._anchorMesh.position.subtractInPlace(n._tmpVector),
n._boundingDimensions.multiplyToRef(n.scalePivot, n._tmpVector),
x.TransformCoordinatesToRef(n._tmpVector, n._tmpRotationMatrix, n._tmpVector),
n._anchorMesh.position.addInPlace(n._tmpVector)) : (r.absolutePosition.subtractToRef(n._anchorMesh.position, n._tmpVector),
n._anchorMesh.position.subtractInPlace(n._tmpVector)),
n._anchorMesh.addChild(n.attachedMesh),
n._anchorMesh.scaling.addInPlace(s),
(n._anchorMesh.scaling.x < 0 || n._anchorMesh.scaling.y < 0 || n._anchorMesh.scaling.z < 0) && n._anchorMesh.scaling.subtractInPlace(s),
n._anchorMesh.removeChild(n.attachedMesh),
n.attachedMesh.setParent(i),
mo._RestorePivotPoint(n.attachedMesh)
}
n._updateDummy()
}
)),
a.onDragStartObservable.add((function() {
n.onDragStartObservable.notifyObservers({}),
n._selectNode(r)
}
)),
a.onDragEndObservable.add((function() {
n.onScaleBoxDragEndObservable.notifyObservers({}),
n._selectNode(null),
n._updateDummy()
}
)),
u._scaleBoxesParent.addChild(r)
}, u = this, d = 0; d < 3; d++)
c(d);
n._rootMesh.addChild(n._scaleBoxesParent);
var p = new Array;
return n._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 = n._coloredMaterial,
delete p[e.event.pointerId]) : n._rotateSpheresParent.getChildMeshes().concat(n._scaleBoxesParent.getChildMeshes()).forEach((function(t) {
e.pickInfo && e.pickInfo.pickedMesh == t && (p[e.event.pointerId] = t,
t.material = n._hoverColoredMaterial)
}
))
}
)),
n._renderObserver = n.gizmoLayer.originalScene.onBeforeRenderObservable.add((function() {
n.attachedMesh && !n._existingMeshScale.equals(n.attachedMesh.scaling) ? n.updateBoundingBox() : (n.fixedDragMeshScreenSize || n.fixedDragMeshBoundsSize) && (n._updateRotationSpheres(),
n._updateScaleBoxes()),
n._dragMesh && n.attachedMesh && n._pointerDragBehavior.dragging && (n._lineBoundingBox.position.rotateByQuaternionToRef(n._rootMesh.rotationQuaternion, n._tmpVector),
n.attachedMesh.setAbsolutePosition(n._dragMesh.position.add(n._tmpVector.scale(-1))))
}
)),
n.updateBoundingBox(),
n
}
return U(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, n = 0; n < 3; n++)
for (var r = 0; r < 3; r++)
for (var o = 0; o < 3; o++) {
var a = (1 === n ? 1 : 0) + (1 === r ? 1 : 0) + (1 === o ? 1 : 0);
if (1 !== a && 3 !== a) {
if (t[i]) {
var s = new x(n - 1,r - 1,o - 1);
s.multiplyInPlace(this._axisFactor),
t[i].setEnabled(s.lengthSquared() > m)
}
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
}),
t.prototype.setColor = function(e) {
this._coloredMaterial.emissiveColor = e,
this._hoverColoredMaterial.emissiveColor = e.clone().add(new D(.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),
mo._RemoveAndStorePivotPoint(e);
var i = e.parent;
this._anchorMesh.addChild(e),
this._anchorMesh.removeChild(e),
e.setParent(i),
mo._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.updateBoundingBox = function() {
if (this.attachedMesh) {
mo._RemoveAndStorePivotPoint(this.attachedMesh);
var e = this.attachedMesh.parent;
this.attachedMesh.setParent(null),
this._update(),
this.attachedMesh.rotationQuaternion || (this.attachedMesh.rotationQuaternion = C.RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z)),
this._anchorMesh.rotationQuaternion || (this._anchorMesh.rotationQuaternion = C.RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z)),
this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion),
this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion),
this._tmpVector.copyFrom(this.attachedMesh.position),
this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1),
this.attachedMesh.position.set(0, 0, 0);
var t = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);
t.max.subtractToRef(t.min, this._boundingDimensions),
this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions),
this._lineBoundingBox.position.set((t.max.x + t.min.x) / 2, (t.max.y + t.min.y) / 2, (t.max.z + t.min.z) / 2),
this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position),
this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position),
this._lineBoundingBox.computeWorldMatrix(),
this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition),
this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion),
this.attachedMesh.position.copyFrom(this._tmpVector),
this.attachedMesh.setParent(e)
}
this._updateRotationSpheres(),
this._updateScaleBoxes(),
this.attachedMesh && (this._existingMeshScale.copyFrom(this.attachedMesh.scaling),
mo._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 n = 0; n < 2; n++) {
var r = 4 * t + 2 * i + n;
if (0 == t && (e[r].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * i, this._boundingDimensions.z * n),
e[r].position.addInPlace(new x(-this._boundingDimensions.x / 2,-this._boundingDimensions.y / 2,-this._boundingDimensions.z / 2)),
e[r].lookAt(x.Cross(e[r].position.normalizeToNew(), x.Right()).normalizeToNew().add(e[r].position))),
1 == t && (e[r].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y / 2, this._boundingDimensions.z * n),
e[r].position.addInPlace(new x(-this._boundingDimensions.x / 2,-this._boundingDimensions.y / 2,-this._boundingDimensions.z / 2)),
e[r].lookAt(x.Cross(e[r].position.normalizeToNew(), x.Up()).normalizeToNew().add(e[r].position))),
2 == t && (e[r].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y * n, this._boundingDimensions.z / 2),
e[r].position.addInPlace(new x(-this._boundingDimensions.x / 2,-this._boundingDimensions.y / 2,-this._boundingDimensions.z / 2)),
e[r].lookAt(x.Cross(e[r].position.normalizeToNew(), x.Forward()).normalizeToNew().add(e[r].position))),
this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
e[r].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
var o = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
e[r].scaling.set(o, o, o)
} else
this.fixedDragMeshBoundsSize ? e[r].scaling.set(this.rotationSphereSize * this._boundingDimensions.x, this.rotationSphereSize * this._boundingDimensions.y, this.rotationSphereSize * this._boundingDimensions.z) : e[r].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 n = 0; n < 3; n++)
for (var r = 0; r < 3; r++) {
var o = (1 === i ? 1 : 0) + (1 === n ? 1 : 0) + (1 === r ? 1 : 0);
if (1 !== o && 3 !== o) {
if (e[t])
if (e[t].position.set(this._boundingDimensions.x * (i / 2), this._boundingDimensions.y * (n / 2), this._boundingDimensions.z * (r / 2)),
e[t].position.addInPlace(new x(-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 n = e;
t && !0 === i.metadata && (n = !1),
i.setEnabled(n)
}
))
}
,
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 = Ml("dummy", {
size: 1
}, this.gizmoLayer.utilityLayerScene),
this._dragMesh.visibility = 0,
this._dragMesh.rotationQuaternion = new C,
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 = C.RotationYawPitchRoll(e.rotation.y, e.rotation.x, e.rotation.z));
var i = e.position.clone()
, n = e.rotationQuaternion.clone();
e.rotationQuaternion.set(0, 0, 0, 1),
e.position.set(0, 0, 0);
var r = Ml("box", {
size: 1
}, e.getScene())
, o = e.getHierarchyBoundingVectors();
return o.max.subtractToRef(o.min, r.scaling),
0 === r.scaling.y && (r.scaling.y = m),
0 === r.scaling.x && (r.scaling.x = m),
0 === r.scaling.z && (r.scaling.z = m),
r.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(r),
e.rotationQuaternion.copyFrom(n),
e.position.copyFrom(i),
e.removeChild(r),
r.addChild(e),
r.visibility = 0,
r
}
,
t.prototype.setCustomMesh = function() {
K.Error("Custom meshes are not supported on this gizmo")
}
,
t
}(Sl)
, md = function(e) {
function t(i, n, r, o, a, s, l) {
void 0 === n && (n = D.Gray()),
void 0 === r && (r = El.DefaultUtilityLayer),
void 0 === o && (o = 32),
void 0 === a && (a = null),
void 0 === s && (s = !1),
void 0 === l && (l = 1);
var c, u = this;
(u = e.call(this, r) || this)._pointerObserver = null,
u.snapDistance = 0,
u.onSnapObservable = new h,
u.angle = 0,
u._isEnabled = !0,
u._parent = null,
u._dragging = !1,
u._angles = new x,
u._parent = a,
u._coloredMaterial = new Os("",r.utilityLayerScene),
u._coloredMaterial.diffuseColor = n,
u._coloredMaterial.specularColor = n.subtract(new D(.1,.1,.1)),
u._hoverMaterial = new Os("",r.utilityLayerScene),
u._hoverMaterial.diffuseColor = D.Yellow(),
u._disableMaterial = new Os("",r.utilityLayerScene),
u._disableMaterial.diffuseColor = D.Gray(),
u._disableMaterial.alpha = .4,
u._gizmoMesh = new Vr("",r.utilityLayerScene);
var d = u._createGizmoMesh(u._gizmoMesh, l, o)
, p = d.rotationMesh
, f = d.collider;
u._rotationDisplayPlane = vo("rotationDisplay", {
size: .6,
updatable: !1
}, u.gizmoLayer.utilityLayerScene),
u._rotationDisplayPlane.rotation.z = .5 * Math.PI,
u._rotationDisplayPlane.parent = u._gizmoMesh,
u._rotationDisplayPlane.setEnabled(!1),
Mt.ShadersStore.rotationGizmoVertexShader = t._RotationGizmoVertexShader,
Mt.ShadersStore.rotationGizmoFragmentShader = t._RotationGizmoFragmentShader,
u._rotationShaderMaterial = new jl("shader",u.gizmoLayer.utilityLayerScene,{
vertex: "rotationGizmo",
fragment: "rotationGizmo"
},{
attributes: ["position", "uv"],
uniforms: ["worldViewProjection", "angles"]
}),
u._rotationShaderMaterial.backFaceCulling = !1,
u._rotationDisplayPlane.material = u._rotationShaderMaterial,
u._rotationDisplayPlane.visibility = .999,
u._gizmoMesh.lookAt(u._rootMesh.position.add(i)),
u._rootMesh.addChild(u._gizmoMesh),
u._gizmoMesh.scaling.scaleInPlace(1 / 3),
u.dragBehavior = new Ao({
dragPlaneNormal: i
}),
u.dragBehavior.moveAttached = !1,
u.dragBehavior.maxDragAngle = t.MaxDragAngle,
u.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = !0,
u._rootMesh.addBehavior(u.dragBehavior);
var _ = new x
, m = new P
, g = new x
, v = new x;
u.dragBehavior.onDragStartObservable.add((function(e) {
u.attachedNode && (_.copyFrom(e.dragPlanePoint),
u._rotationDisplayPlane.setEnabled(!0),
u._rotationDisplayPlane.getWorldMatrix().invertToRef(m),
x.TransformCoordinatesToRef(e.dragPlanePoint, m, _),
u._angles.x = Math.atan2(_.y, _.x) + Math.PI,
u._angles.y = 0,
u._angles.z = u.updateGizmoRotationToMatchAttachedMesh ? 1 : 0,
u._dragging = !0,
_.copyFrom(e.dragPlanePoint),
u._rotationShaderMaterial.setVector3("angles", u._angles),
u.angle = 0)
}
)),
u.dragBehavior.onDragEndObservable.add((function() {
u._dragging = !1,
u._rotationDisplayPlane.setEnabled(!1)
}
));
var y = {
snapDistance: 0
}
, b = 0
, T = new P
, E = new C;
u.dragBehavior.onDragObservable.add((function(e) {
if (u.attachedNode) {
var t = new x(1,1,1)
, n = new C(0,0,0,1)
, o = new x(0,0,0);
u._handlePivot(),
u.attachedNode.getWorldMatrix().decompose(t, n, o);
var a = e.dragPlanePoint.subtract(o).normalize()
, s = _.subtract(o).normalize()
, l = x.Cross(a, s)
, c = x.Dot(a, s)
, h = Math.atan2(l.length(), c);
g.copyFrom(i),
v.copyFrom(i),
u.updateGizmoRotationToMatchAttachedMesh && (n.toRotationMatrix(m),
v = x.TransformCoordinates(g, m));
var d = !1;
if (r.utilityLayerScene.activeCamera) {
var p = r.utilityLayerScene.activeCamera.position.subtract(o).normalize();
x.Dot(p, v) > 0 && (g.scaleInPlace(-1),
v.scaleInPlace(-1),
d = !0)
}
x.Dot(v, l) > 0 && (h = -h);
var f = !1;
if (0 != u.snapDistance)
if (b += h,
Math.abs(b) > u.snapDistance) {
var S = Math.floor(Math.abs(b) / u.snapDistance);
b < 0 && (S *= -1),
b %= u.snapDistance,
h = u.snapDistance * S,
f = !0
} else
h = 0;
var A = Math.sin(h / 2);
if (E.set(g.x * A, g.y * A, g.z * A, Math.cos(h / 2)),
T.determinant() > 0) {
var R = new x;
E.toEulerAnglesToRef(R),
C.RotationYawPitchRollToRef(R.y, -R.x, -R.z, E)
}
u.updateGizmoRotationToMatchAttachedMesh ? n.multiplyToRef(E, n) : E.multiplyToRef(n, n),
u.attachedNode.getWorldMatrix().copyFrom(P.Compose(t, n, o)),
_.copyFrom(e.dragPlanePoint),
f && (y.snapDistance = h,
u.onSnapObservable.notifyObservers(y)),
u._angles.y += h,
u.angle += d ? -h : h,
u._rotationShaderMaterial.setVector3("angles", u._angles),
u._matrixChanged()
}
}
));
var S = r._getSharedGizmoLight();
S.includedOnlyMeshes = S.includedOnlyMeshes.concat(u._rootMesh.getChildMeshes(!1));
var A = {
colliderMeshes: [f],
gizmoMeshes: [p],
material: u._coloredMaterial,
hoverMaterial: u._hoverMaterial,
disableMaterial: u._disableMaterial,
active: !1,
dragBehavior: u.dragBehavior
};
return null === (c = u._parent) || void 0 === c || c.addToAxisCache(u._gizmoMesh, A),
u._pointerObserver = r.utilityLayerScene.onPointerObservable.add((function(e) {
var i;
if (!u._customMeshSet && (u.dragBehavior.maxDragAngle = t.MaxDragAngle,
u._isHovered = !(-1 == A.colliderMeshes.indexOf(null === (i = null == e ? void 0 : e.pickInfo) || void 0 === i ? void 0 : i.pickedMesh)),
!u._parent)) {
var n = A.dragBehavior.enabled ? u._isHovered || u._dragging ? u._hoverMaterial : u._coloredMaterial : u._disableMaterial;
u._setGizmoMeshMaterial(A.gizmoMeshes, n)
}
}
)),
u.dragBehavior.onEnabledObservable.add((function(e) {
u._setGizmoMeshMaterial(A.gizmoMeshes, e ? u._coloredMaterial : u._disableMaterial)
}
)),
u
}
return U(t, e),
t.prototype._createGizmoMesh = function(e, t, i) {
var n = qs("ignore", {
diameter: .6,
thickness: .03 * t,
tessellation: i
}, this.gizmoLayer.utilityLayerScene);
n.visibility = 0;
var r = qs("", {
diameter: .6,
thickness: .005 * t,
tessellation: i
}, this.gizmoLayer.utilityLayerScene);
return r.material = this._coloredMaterial,
r.rotation.x = Math.PI / 2,
n.rotation.x = Math.PI / 2,
e.addChild(r),
e.addChild(n),
{
rotationMesh: r,
collider: 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.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
}(Sl)
, gd = function(e) {
function t(t, i, n, r, o, a) {
void 0 === t && (t = El.DefaultUtilityLayer),
void 0 === i && (i = 32),
void 0 === n && (n = !1),
void 0 === r && (r = 1);
var s = e.call(this, t) || this;
s.onDragStartObservable = new h,
s.onDragEndObservable = new h,
s._observables = [],
s._gizmoAxisCache = new Map;
var l = a && a.xOptions && a.xOptions.color ? a.xOptions.color : D.Red().scale(.5)
, c = a && a.yOptions && a.yOptions.color ? a.yOptions.color : D.Green().scale(.5)
, u = a && a.zOptions && a.zOptions.color ? a.zOptions.color : D.Blue().scale(.5);
return s.xGizmo = new md(new x(1,0,0),l,t,i,s,n,r),
s.yGizmo = new md(new x(0,1,0),c,t,i,s,n,r),
s.zGizmo = new md(new x(0,0,1),u,t,i,s,n,r),
[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) : Sl.GizmoAxisPointerObserver(t, s._gizmoAxisCache),
s
}
return U(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, "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, "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() {
K.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
}(Sl)
, vd = function(e) {
function t(i, n, r, o) {
void 0 === n && (n = D.Gray()),
void 0 === r && (r = El.DefaultUtilityLayer),
void 0 === o && (o = null);
var a, s = this;
(s = e.call(this, r) || this)._pointerObserver = null,
s.snapDistance = 0,
s.onSnapObservable = new h,
s._isEnabled = !1,
s._parent = null,
s._dragging = !1,
s._parent = o,
s._coloredMaterial = new Os("",r.utilityLayerScene),
s._coloredMaterial.diffuseColor = n,
s._coloredMaterial.specularColor = n.subtract(new D(.1,.1,.1)),
s._hoverMaterial = new Os("",r.utilityLayerScene),
s._hoverMaterial.diffuseColor = D.Yellow(),
s._disableMaterial = new Os("",r.utilityLayerScene),
s._disableMaterial.diffuseColor = D.Gray(),
s._disableMaterial.alpha = .4,
s._gizmoMesh = t._CreatePlane(r.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 x
, u = {
snapDistance: 0
};
s.dragBehavior = new Ao({
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().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().addTranslationFromFloats(c.x, c.y, c.z),
u.snapDistance = s.snapDistance * t,
s.onSnapObservable.notifyObservers(u)
}
s._matrixChanged()
}
}
)),
s.dragBehavior.onDragStartObservable.add((function() {
s._dragging = !0
}
)),
s.dragBehavior.onDragEndObservable.add((function() {
s._dragging = !1
}
));
var d = r._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 = r.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 U(t, e),
t._CreatePlane = function(e, t) {
var i = new yr("plane",e)
, n = vo("dragPlane", {
width: .1375,
height: .1375,
sideOrientation: 2
}, e);
return n.material = t,
n.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
}(Sl)
, yd = function(e) {
function t(t, i, n) {
void 0 === t && (t = El.DefaultUtilityLayer),
void 0 === i && (i = 1);
var r = e.call(this, t) || this;
return r._meshAttached = null,
r._nodeAttached = null,
r._observables = [],
r._gizmoAxisCache = new Map,
r.onDragStartObservable = new h,
r.onDragEndObservable = new h,
r._planarGizmoEnabled = !1,
r.xGizmo = new Al(new x(1,0,0),D.Red().scale(.5),t,r,i),
r.yGizmo = new Al(new x(0,1,0),D.Green().scale(.5),t,r,i),
r.zGizmo = new Al(new x(0,0,1),D.Blue().scale(.5),t,r,i),
r.xPlaneGizmo = new vd(new x(1,0,0),D.Red().scale(.5),r.gizmoLayer,r),
r.yPlaneGizmo = new vd(new x(0,1,0),D.Green().scale(.5),r.gizmoLayer,r),
r.zPlaneGizmo = new vd(new x(0,0,1),D.Blue().scale(.5),r.gizmoLayer,r),
[r.xGizmo, r.yGizmo, r.zGizmo, r.xPlaneGizmo, r.yPlaneGizmo, r.zPlaneGizmo].forEach((function(e) {
e.dragBehavior.onDragStartObservable.add((function() {
r.onDragStartObservable.notifyObservers({})
}
)),
e.dragBehavior.onDragEndObservable.add((function() {
r.onDragEndObservable.notifyObservers({})
}
))
}
)),
r.attachedMesh = null,
n ? n.addToAxisCache(r._gizmoAxisCache) : Sl.GizmoAxisPointerObserver(t, r._gizmoAxisCache),
r
}
return U(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, "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() {
K.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
}(Sl);
function bd(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, n, r, 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 || $n.DEFAULTSIDE, y = new Array, b = new Array, T = new Array, E = new Array, S = new Array, A = 0, x = 0, C = new Array, P = 0, M = 0;
if (g)
for (M = 0; M < f; M++)
m && void 0 === m[M] && (m[M] = new N(1,1,1,1)),
_ && void 0 === _[M] && (_[M] = new R(0,0,1,1));
if (g)
for (M = 0; M < f; M++) {
var I = p.face[M].length;
for (r = 2 * Math.PI / I,
o = .5 * Math.tan(r / 2),
a = .5,
P = 0; P < I; P++)
y.push(p.vertex[p.face[M][P]][0] * u, p.vertex[p.face[M][P]][1] * h, p.vertex[p.face[M][P]][2] * d),
C.push(A),
A++,
i = _[M].x + (_[M].z - _[M].x) * (.5 + o),
n = _[M].y + (_[M].w - _[M].y) * (a - .5),
E.push(i, pr.UseOpenGLOrientationForUV ? 1 - n : n),
s = o * Math.cos(r) - a * Math.sin(r),
a = o * Math.sin(r) + a * Math.cos(r),
o = s,
m && S.push(m[M].r, m[M].g, m[M].b, m[M].a);
for (P = 0; P < I - 2; P++)
b.push(C[0 + x], C[P + 2 + x], C[P + 1 + x]);
x += I
}
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, pr.UseOpenGLOrientationForUV ? 1 : 0);
for (M = 0; M < f; M++)
for (P = 0; P < p.face[M].length - 2; P++)
b.push(p.face[M][0], p.face[M][P + 2], p.face[M][P + 1])
}
$n.ComputeNormals(y, b, T),
$n._ComputeSides(v, y, b, T, E, e.frontUVs, e.backUVs);
var O = new $n;
return O.positions = y,
O.indices = b,
O.normals = T,
O.uvs = E,
m && g && (O.colors = S),
O
}
function Td(e, t, i) {
void 0 === t && (t = {}),
void 0 === i && (i = null);
var n = new Vr(e,i);
return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
n._originalBuilderSideOrientation = t.sideOrientation,
bd(t).applyToMesh(n, t.updatable),
n
}
var Ed = {
CreatePolyhedron: Td
};
$n.CreatePolyhedron = bd,
Vr.CreatePolyhedron = function(e, t, i) {
return Td(e, t, i)
}
;
var Sd = function(e) {
function t(t, i, n) {
void 0 === t && (t = El.DefaultUtilityLayer),
void 0 === i && (i = 1);
var r = e.call(this, t) || this;
return r._meshAttached = null,
r._nodeAttached = null,
r._sensitivity = 1,
r._observables = [],
r._gizmoAxisCache = new Map,
r.onDragStartObservable = new h,
r.onDragEndObservable = new h,
r.uniformScaleGizmo = r._createUniformScaleMesh(),
r.xGizmo = new fd(new x(1,0,0),D.Red().scale(.5),t,r,i),
r.yGizmo = new fd(new x(0,1,0),D.Green().scale(.5),t,r,i),
r.zGizmo = new fd(new x(0,0,1),D.Blue().scale(.5),t,r,i),
[r.xGizmo, r.yGizmo, r.zGizmo, r.uniformScaleGizmo].forEach((function(e) {
e.dragBehavior.onDragStartObservable.add((function() {
r.onDragStartObservable.notifyObservers({})
}
)),
e.dragBehavior.onDragEndObservable.add((function() {
r.onDragEndObservable.notifyObservers({})
}
))
}
)),
r.attachedMesh = null,
r.attachedNode = null,
n ? n.addToAxisCache(r._gizmoAxisCache) : Sl.GizmoAxisPointerObserver(t, r._gizmoAxisCache),
r
}
return U(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.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, "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 Os("",this.gizmoLayer.utilityLayerScene),
this._coloredMaterial.diffuseColor = D.Gray(),
this._hoverMaterial = new Os("",this.gizmoLayer.utilityLayerScene),
this._hoverMaterial.diffuseColor = D.Yellow(),
this._disableMaterial = new Os("",this.gizmoLayer.utilityLayerScene),
this._disableMaterial.diffuseColor = D.Gray(),
this._disableMaterial.alpha = .4;
var e = new fd(new x(0,1,0),D.Gray().scale(.5),this.gizmoLayer,this);
e.updateGizmoRotationToMatchAttachedMesh = !1,
e.uniformScaling = !0,
this._uniformScalingMesh = Td("uniform", {
type: 1
}, e.gizmoLayer.utilityLayerScene),
this._uniformScalingMesh.scaling.scaleInPlace(.01),
this._uniformScalingMesh.visibility = 0,
this._octahedron = Td("", {
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)
}
))) : K.Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.")
},
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
}(Sl)
, Ad = function() {
function e(e, t, i, n) {
void 0 === t && (t = 1),
void 0 === i && (i = El.DefaultUtilityLayer),
void 0 === n && (n = El.DefaultKeepDepthUtilityLayer),
this._scene = e,
this.clearGizmoOnEmptyPointerEvent = !1,
this.enableAutoPicking = !0,
this.onAttachedToMeshObservable = new h,
this.onAttachedToNodeObservable = new h,
this._gizmosEnabled = {
positionGizmo: !1,
rotationGizmo: !1,
scaleGizmo: !1,
boundingBoxGizmo: !1
},
this._pointerObservers = [],
this._attachedMesh = null,
this._attachedNode = null,
this._boundingBoxColor = D.FromHexString("#0984e3"),
this._thickness = 1,
this._scaleRatio = 1,
this._gizmoAxisCache = new Map,
this.boundingBoxDragBehavior = new Co,
this.attachableMeshes = null,
this.attachableNodes = null,
this.usePointerToAttachGizmos = !0,
this._defaultUtilityLayer = i,
this._defaultKeepDepthUtilityLayer = n,
this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = !1,
this._thickness = t,
this.gizmos = {
positionGizmo: null,
rotationGizmo: null,
scaleGizmo: null,
boundingBoxGizmo: null
};
var r = this._attachToMeshPointerObserver(e)
, o = Sl.GizmoAxisPointerObserver(this._defaultUtilityLayer, this._gizmoAxisCache);
this._pointerObservers = [r, 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
}),
e.prototype._attachToMeshPointerObserver = function(e) {
var t = this;
return e.onPointerObservable.add((function(e) {
if (t.usePointerToAttachGizmos && e.type == Xi.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 n = !1;
t.attachableMeshes.forEach((function(e) {
i && (i == e || i.isDescendantOf(e)) && (i = e,
n = !0)
}
)),
n || (i = null)
}
i instanceof Sr ? 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 yd(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 gd(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 Sd(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 _d(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 n in this._pointerObservers.forEach((function(e) {
i._scene.onPointerObservable.remove(e)
}
)),
this.gizmos) {
var r = this.gizmos[n];
r && r.dispose()
}
this._defaultKeepDepthUtilityLayer !== El._DefaultKeepDepthUtilityLayer && (null === (e = this._defaultKeepDepthUtilityLayer) || void 0 === e || e.dispose()),
this._defaultUtilityLayer !== El._DefaultUtilityLayer && (null === (t = this._defaultUtilityLayer) || void 0 === t || t.dispose()),
this.boundingBoxDragBehavior.detach(),
this.onAttachedToMeshObservable.clear()
}
,
e
}()
, xd = function(e) {
function t() {
var t = null !== e && e.apply(this, arguments) || this;
return t._needProjectionMatrixCompute = !0,
t
}
return U(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 = x.Zero()),
x.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition),
this.direction && (this.transformedDirection || (this.transformedDirection = x.Zero()),
x.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 = x.Normalize(e.subtract(this.position)),
this.direction
}
,
t.prototype.getRotation = function() {
this.direction.normalize();
var e = x.Cross(this.direction, vn.Y)
, t = x.Cross(e, this.direction);
return x.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 = x.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 = P.Identity()),
P.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
}
,
k([De()], t.prototype, "position", null),
k([De()], t.prototype, "direction", null),
k([Ce()], t.prototype, "shadowMinZ", null),
k([Ce()], t.prototype, "shadowMaxZ", null),
t
}(Cr);
Xe.AddNodeConstructor("Light_Type_1", (function(e, t) {
return function() {
return new Rd(e,x.Zero(),t)
}
}
));
var Rd = function(e) {
function t(t, i, n) {
var r = e.call(this, t, n) || this;
return r._shadowFrustumSize = 0,
r._shadowOrthoScale = .1,
r.autoUpdateExtends = !0,
r.autoCalcShadowZBounds = !1,
r._orthoLeft = Number.MAX_VALUE,
r._orthoRight = Number.MIN_VALUE,
r._orthoTop = Number.MIN_VALUE,
r._orthoBottom = Number.MAX_VALUE,
r.position = i.scale(-1),
r.direction = i,
r
}
return U(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 Cr.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 && P.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 n = this.getScene().activeCamera;
if (n) {
if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
var r = x.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++)
x.TransformCoordinatesToRef(c.vectorsWorld[u], t, r),
r.x < this._orthoLeft && (this._orthoLeft = r.x),
r.y < this._orthoBottom && (this._orthoBottom = r.y),
r.x > this._orthoRight && (this._orthoRight = r.x),
r.y > this._orthoTop && (this._orthoTop = r.y),
this.autoCalcShadowZBounds && (r.z < o && (o = r.z),
r.z > a && (a = r.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 : n.minZ
, f = void 0 !== this.shadowMaxZ ? this.shadowMaxZ : n.maxZ
, _ = this.getScene().getEngine().useReverseDepthBuffer;
P.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
}
,
k([Ce()], t.prototype, "shadowFrustumSize", null),
k([Ce()], t.prototype, "shadowOrthoScale", null),
k([Ce()], t.prototype, "autoUpdateExtends", void 0),
k([Ce()], t.prototype, "autoCalcShadowZBounds", void 0),
k([Ce("orthoLeft")], t.prototype, "_orthoLeft", void 0),
k([Ce("orthoRight")], t.prototype, "_orthoRight", void 0),
k([Ce("orthoTop")], t.prototype, "_orthoTop", void 0),
k([Ce("orthoBottom")], t.prototype, "_orthoBottom", void 0),
t
}(xd);
function Cd(e) {
var t = new Array
, i = new Array
, n = new Array
, r = 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 || $n.DEFAULTSIDE;
t.push(0, 0, 0),
r.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),
r.push(_, pr.UseOpenGLOrientationForUV ? 1 - m : m),
h += u
}
1 === s && (t.push(t[3], t[4], t[5]),
r.push(r[2], pr.UseOpenGLOrientationForUV ? 1 - r[3] : r[3]));
for (var g = t.length / 3, v = 1; v < g - 1; v++)
i.push(v + 1, 0, v);
$n.ComputeNormals(t, i, n),
$n._ComputeSides(l, t, i, n, r, e.frontUVs, e.backUVs);
var y = new $n;
return y.indices = i,
y.positions = t,
y.normals = n,
y.uvs = r,
y
}
function Pd(e, t, i) {
void 0 === t && (t = {}),
void 0 === i && (i = null);
var n = new Vr(e,i);
return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
n._originalBuilderSideOrientation = t.sideOrientation,
Cd(t).applyToMesh(n, t.updatable),
n
}
var Md = {
CreateDisc: Pd
};
function Id(e, t, i) {
void 0 === t && (t = {}),
t.diameter || (t.diameter = 1),
t.segments || (t.segments = 16);
var n = Dl("", {
slice: .5,
diameter: t.diameter,
segments: t.segments
}, i)
, r = Pd("", {
radius: t.diameter / 2,
tessellation: 3 * t.segments + (4 - t.segments)
}, i);
r.rotation.x = -Math.PI / 2,
r.parent = n;
var o = Vr.MergeMeshes([r, n], !0);
return o.name = e,
o
}
$n.CreateDisc = Cd,
Vr.CreateDisc = function(e, t, i, n, r, o) {
return void 0 === n && (n = null),
Pd(e, {
radius: t,
tessellation: i,
sideOrientation: o,
updatable: r
}, n)
}
;
var Od = {
CreateHemisphere: Id
};
Vr.CreateHemisphere = function(e, t, i, n) {
return Id(e, {
segments: t,
diameter: i
}, n)
}
,
Xe.AddNodeConstructor("Light_Type_2", (function(e, t) {
return function() {
return new Dd(e,x.Zero(),x.Zero(),0,0,t)
}
}
));
var Dd = function(e) {
function t(t, i, n, r, o, a) {
var s = e.call(this, t, a) || this;
return s._innerAngle = 0,
s._projectionTextureMatrix = P.Zero(),
s._projectionTextureLightNear = 1e-6,
s._projectionTextureLightFar = 1e3,
s._projectionTextureUpDirection = x.Up(),
s._projectionTextureViewLightDirty = !0,
s._projectionTextureProjectionLightDirty = !0,
s._projectionTextureDirty = !0,
s._projectionTextureViewTargetVector = x.Zero(),
s._projectionTextureViewLightMatrix = P.Zero(),
s._projectionTextureProjectionLightMatrix = P.Zero(),
s._projectionTextureScalingMatrix = P.FromValues(.5, 0, 0, 0, 0, .5, 0, 0, 0, 0, .5, 0, .5, .5, .5, 1),
s.position = i,
s.direction = n,
s.angle = r,
s.exponent = o,
s
}
return U(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 Cr.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 n = this.getScene().activeCamera;
if (n) {
this._shadowAngleScale = this._shadowAngleScale || 1;
var r = this._shadowAngleScale * this._angle
, o = void 0 !== this.shadowMinZ ? this.shadowMinZ : n.minZ
, a = void 0 !== this.shadowMaxZ ? this.shadowMaxZ : n.maxZ
, s = this.getScene().getEngine().useReverseDepthBuffer;
P.PerspectiveFovLHToRef(r, 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.position.addToRef(this.direction, this._projectionTextureViewTargetVector),
P.LookAtLHToRef(this.position, 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)
, n = -i * t
, r = 1 / Math.tan(this._angle / 2);
P.FromValuesToRef(r / 1, 0, 0, 0, 0, r, 0, 0, 0, 0, i, 1, 0, 0, n, 0, this._projectionTextureProjectionLightMatrix)
}
,
t.prototype._computeProjectionTextureMatrix = function() {
if (this._projectionTextureDirty = !1,
this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix),
this._projectionTexture instanceof io) {
var e = this._projectionTexture.uScale / 2
, t = this._projectionTexture.vScale / 2;
P.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 = x.Normalize(this.transformedDirection)) : (this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, this.exponent, t),
i = x.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() ? x.Normalize(this.transformedDirection) : x.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())
}
,
k([Ce()], t.prototype, "angle", null),
k([Ce()], t.prototype, "innerAngle", null),
k([Ce()], t.prototype, "shadowAngleScale", null),
k([Ce()], t.prototype, "exponent", void 0),
k([Ce()], t.prototype, "projectionTextureLightNear", null),
k([Ce()], t.prototype, "projectionTextureLightFar", null),
k([Ce()], t.prototype, "projectionTextureUpDirection", null),
k([Pe("projectedLightTexture")], t.prototype, "_projectionTexture", void 0),
t
}(xd)
, Nd = function(e) {
function t(t) {
void 0 === t && (t = El.DefaultUtilityLayer);
var i = e.call(this, t) || this;
return i._cachedPosition = new x,
i._cachedForward = new x(0,0,1),
i._pointerObserver = null,
i.onClickedObservable = new h,
i._light = null,
i.attachedMesh = new Sr("",i.gizmoLayer.utilityLayerScene),
i._attachedMeshParent = new yr("parent",i.gizmoLayer.utilityLayerScene),
i.attachedMesh.parent = i._attachedMeshParent,
i._material = new Os("light",i.gizmoLayer.utilityLayerScene),
i._material.diffuseColor = new D(.5,.5,.5),
i._material.specularColor = new D(.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))
}
), Xi.POINTERDOWN),
i
}
return U(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 ds ? t._CreateHemisphericLightMesh(this.gizmoLayer.utilityLayerScene) : e instanceof Rd ? t._CreateDirectionalLightMesh(this.gizmoLayer.utilityLayerScene) : e instanceof Dd ? 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 n = this.gizmoLayer._getSharedGizmoLight();
n.includedOnlyMeshes = n.includedOnlyMeshes.concat(this._lightMesh.getChildMeshes(!1)),
this._lightMesh.rotationQuaternion = new C,
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),
this._cachedForward.copyFrom(this.attachedMesh.forward)),
this._update()
}
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "material", {
get: function() {
return this._material
},
enumerable: !1,
configurable: !0
}),
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 x(t.x,t.y,t.z),
this._cachedPosition.copyFrom(this.attachedMesh.position)
}
if (this._light.direction)
if (x.DistanceSquared(this.attachedMesh.forward, this._cachedForward) > 1e-4) {
var i = this.attachedMesh.forward;
this._light.direction = new x(i.x,i.y,i.z),
this._cachedForward.copyFrom(this.attachedMesh.forward)
} else
x.DistanceSquared(this.attachedMesh.forward, this._light.direction) > 1e-4 && (this.attachedMesh.setDirection(this._light.direction),
this.attachedMesh.computeWorldMatrix(!0),
this._cachedForward.copyFrom(this.attachedMesh.forward))
}
}
,
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 Vr("hemisphereLight",e)
, n = Id(i.name, {
segments: 10,
diameter: 1
}, e);
return n.position.z = -.15,
n.rotation.x = Math.PI / 2,
n.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 Vr("pointLight",e)
, n = Dl(i.name, {
segments: 10,
diameter: 1
}, e);
return n.rotation.x = Math.PI / 2,
n.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 Vr("spotLight",e);
Dl(i.name, {
segments: 10,
diameter: 1
}, e).parent = i;
var n = Id(i.name, {
segments: 10,
diameter: 2
}, e);
return n.parent = i,
n.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 Vr("directionalLight",e)
, n = new Vr(i.name,e);
n.parent = i,
Dl(i.name, {
diameter: 1.2,
segments: 10
}, e).parent = n;
var r = Ys(i.name, {
updatable: !1,
height: 6,
diameterTop: .3,
diameterBottom: .3,
tessellation: 6,
subdivisions: 1
}, e);
r.parent = n;
var o = r.clone(i.name);
o.scaling.y = .5,
o.position.x += 1.25;
var a = r.clone(i.name);
a.scaling.y = .5,
a.position.x += -1.25;
var s = Ys(i.name, {
updatable: !1,
height: 1,
diameterTop: 0,
diameterBottom: .6,
tessellation: 6,
subdivisions: 1
}, e);
return s.position.y += 3,
s.parent = n,
(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,
n.scaling.scaleInPlace(t._Scale),
n.rotation.z = Math.PI / 2,
n.rotation.y = Math.PI / 2,
i
}
,
t._Scale = .007,
t._CreateLightLines = function(e, t) {
var i = new Vr("root",t);
i.rotation.x = Math.PI / 2;
var n = new Vr("linePivot",t);
n.parent = i;
var r = Ys("line", {
updatable: !1,
height: 2,
diameterTop: .2,
diameterBottom: .3,
tessellation: 6,
subdivisions: 1
}, t);
if (r.position.y = r.scaling.y / 2 + 1.2,
r.parent = n,
e < 2)
return n;
for (var o = 0; o < 4; o++) {
var a = n.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 = n.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 = n.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 || (n.clone("linePivotClone").rotation.z = Math.PI),
i
}
,
t
}(Sl)
, Ld = function(e) {
function t(t) {
void 0 === t && (t = El.DefaultUtilityLayer);
var i = e.call(this, t) || this;
return i._pointerObserver = null,
i.onClickedObservable = new h,
i._camera = null,
i._invProjection = new P,
i._material = new Os("cameraGizmoMaterial",i.gizmoLayer.utilityLayerScene),
i._material.diffuseColor = new D(.5,.5,.5),
i._material.specularColor = new D(.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))
}
), Xi.POINTERDOWN),
i
}
return U(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 n = this.gizmoLayer._getSharedGizmoLight();
n.includedOnlyMeshes = n.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 Vr("rootCameraGizmo",e)
, n = new Vr(i.name,e);
n.parent = i,
Ml(i.name, {
width: 1,
height: .8,
depth: .5
}, e).parent = n;
var r = Ys(i.name, {
height: .5,
diameterTop: .8,
diameterBottom: .8
}, e);
r.parent = n,
r.position.y = .3,
r.position.x = -.6,
r.rotation.x = .5 * Math.PI;
var o = Ys(i.name, {
height: .5,
diameterTop: .6,
diameterBottom: .6
}, e);
o.parent = n,
o.position.y = .5,
o.position.x = .4,
o.rotation.x = .5 * Math.PI;
var a = Ys(i.name, {
height: .5,
diameterTop: .5,
diameterBottom: .5
}, e);
return a.parent = n,
a.position.y = 0,
a.position.x = .6,
a.rotation.z = .5 * Math.PI,
i.scaling.scaleInPlace(t._Scale),
n.position.x = -.9,
i
}
,
t._CreateCameraFrustum = function(e) {
var t = new Vr("rootCameraGizmo",e)
, i = new Vr(t.name,e);
i.parent = t;
for (var n = 0; n < 4; n += 2)
for (var r = 0; r < 4; r += 2) {
var o = Jl("lines", {
points: [new x(-1 + r,-1 + n,-1), new x(-1 + r,-1 + n,1)]
}, e);
o.parent = i,
o.alwaysSelectAsActiveMesh = !0,
o.isPickable = !1,
(o = Jl("lines", {
points: [new x(-1,-1 + r,-1 + n), new x(1,-1 + r,-1 + n)]
}, e)).parent = i,
o.alwaysSelectAsActiveMesh = !0,
o.isPickable = !1,
(o = Jl("lines", {
points: [new x(-1 + r,-1,-1 + n), new x(-1 + r,1,-1 + n)]
}, e)).parent = i,
o.alwaysSelectAsActiveMesh = !0,
o.isPickable = !1
}
return t
}
,
t._Scale = .05,
t
}(Sl);
Pt.IncludesShadersStore.kernelBlurVaryingDeclaration = "varying vec2 sampleCoord{X};";
Pt.IncludesShadersStore.packingFunctions = "vec4 pack(float depth)\n{\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(depth*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}";
Pt.IncludesShadersStore.kernelBlurFragment = "#ifdef DOF\nfactor=sampleCoC(sampleCoord{X}); \ncomputedWeight=KERNEL_WEIGHT{X}*factor;\nsumOfWeights+=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";
Pt.IncludesShadersStore.kernelBlurFragment2 = "#ifdef DOF\nfactor=sampleCoC(sampleCenter+delta*KERNEL_DEP_OFFSET{X});\ncomputedWeight=KERNEL_DEP_WEIGHT{X}*factor;\nsumOfWeights+=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";
Pt.ShadersStore.kernelBlurPixelShader = "uniform sampler2D textureSampler;\nuniform vec2 delta;\nvarying vec2 sampleCenter;\n#ifdef DOF\nuniform sampler2D circleOfConfusionSampler;\nuniform vec2 cameraMinMaxZ;\nfloat sampleDistance(in vec2 offset) {\nfloat depth=texture2D(circleOfConfusionSampler,offset).g; \nreturn cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth; \n}\nfloat sampleCoC(in vec2 offset) {\nfloat coc=texture2D(circleOfConfusionSampler,offset).r; \nreturn coc; \n}\n#endif\n#include[0..varyingCount]\n#ifdef PACKEDFLOAT\n#include\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nfloat 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}";
Pt.IncludesShadersStore.kernelBlurVertex = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";
Pt.ShadersStore.kernelBlurVertexShader = "attribute vec2 position;\nuniform vec2 delta;\nvarying 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 Fd = function(e) {
function t(t, i, n, r, o, s, l, c, u, h, d) {
void 0 === s && (s = io.BILINEAR_SAMPLINGMODE),
void 0 === u && (u = a.TEXTURETYPE_UNSIGNED_INT),
void 0 === h && (h = ""),
void 0 === d && (d = !1);
var p = e.call(this, t, "kernelBlur", ["delta", "direction", "cameraMinMaxZ"], ["circleOfConfusionSampler"], r, o, s, l, c, null, u, "kernelBlur", {
varyingCount: 0,
depCount: 0
}, !0) || this;
return p._blockCompilation = d,
p._packedFloat = !1,
p._staticDefines = "",
p._staticDefines = h,
p.direction = i,
p.onApplyObservable.add((function(e) {
p._outputTexture ? e.setFloat2("delta", 1 / p._outputTexture.width * p.direction.x, 1 / p._outputTexture.height * p.direction.y) : e.setFloat2("delta", 1 / p.width * p.direction.x, 1 / p.height * p.direction.y)
}
)),
p.kernel = n,
p
}
return U(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, n, r, o) {
void 0 === e && (e = null),
void 0 === t && (t = null),
void 0 === i && (i = null),
this._updateParameters(r, o)
}
,
t.prototype._updateParameters = function(t, i) {
for (var n = this._kernel, r = (n - 1) / 2, o = [], a = [], s = 0, l = 0; l < n; l++) {
var c = l / (n - 1)
, u = this._gaussianWeight(2 * c - 1);
o[l] = l - r,
a[l] = u,
s += u
}
for (l = 0; l < a.length; l++)
a[l] /= s;
var h = []
, d = []
, p = [];
for (l = 0; l <= r; l += 2) {
var f = Math.min(l + 1, Math.floor(r));
if (l === f)
p.push({
o: o[l],
w: a[l]
});
else {
var _ = f === r
, 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]), "\r\n"),
b--),
l = 0; l < b; l++)
T += "#define KERNEL_OFFSET".concat(l, " ").concat(this._glslFloat(o[l]), "\r\n"),
T += "#define KERNEL_WEIGHT".concat(l, " ").concat(this._glslFloat(a[l]), "\r\n");
var E = 0;
for (l = y; l < o.length; l++)
T += "#define KERNEL_DEP_OFFSET".concat(E, " ").concat(this._glslFloat(o[l]), "\r\n"),
T += "#define KERNEL_DEP_WEIGHT".concat(E, " ").concat(this._glslFloat(a[l]), "\r\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, n = [t, t - 1, t + 1, t - 2, t + 2]; i < n.length; i++) {
var r = n[i];
if (r % 2 != 0 && Math.floor(r / 2) % 2 == 0 && r > 0)
return Math.max(r, 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, n, r) {
return Ge.Parse((function() {
return new t(e.name,e.direction,e.kernel,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable,e.textureType,void 0,!1)
}
), e, n, r)
}
,
k([Ce("kernel")], t.prototype, "_kernel", void 0),
k([Ce("packedFloat")], t.prototype, "_packedFloat", void 0),
k([Oe()], t.prototype, "direction", void 0),
t
}(Ba);
y("BABYLON.BlurPostProcess", Fd);
var wd = function(e) {
function t(t, i, n, r, o, s, l) {
void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT),
void 0 === s && (s = io.BILINEAR_SAMPLINGMODE),
void 0 === l && (l = !0);
var c = e.call(this, t, i, n, r, !0, o, !1, s, l) || this;
if (c.mirrorPlane = new hn(0,1,0,1),
c._transformMatrix = P.Zero(),
c._mirrorMatrix = P.Zero(),
c._adaptiveBlurKernel = 0,
c._blurKernelX = 0,
c._blurKernelY = 0,
c._blurRatio = 1,
!(n = c.getScene()))
return c;
c.ignoreCameraViewport = !0,
c._updateGammaSpace(),
c._imageProcessingConfigChangeObserver = n.imageProcessingConfiguration.onUpdateParameters.add((function() {
c._updateGammaSpace()
}
));
var u, h = n.getEngine();
return h.supportsUniformBuffers && (c._sceneUBO = n.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 = n.getSceneUniformBuffer(),
n.setSceneUniformBuffer(c._sceneUBO),
n.getSceneUniformBuffer().unbindEffect()),
P.ReflectionToRef(c.mirrorPlane, c._mirrorMatrix),
c._mirrorMatrix.multiplyToRef(n.getViewMatrix(), c._transformMatrix),
n.setTransformMatrix(c._transformMatrix, n.getProjectionMatrix()),
u = n.clipPlane,
n.clipPlane = c.mirrorPlane,
n.getEngine().cullBackFaces = !1,
n._mirroredCameraPosition = x.TransformCoordinates(n.activeCamera.globalPosition, c._mirrorMatrix)
}
)),
c.onAfterRenderObservable.add((function() {
c._sceneUBO && n.setSceneUniformBuffer(c._currentSceneUBO),
n.updateTransformMatrix(),
n.getEngine().cullBackFaces = null,
n._mirroredCameraPosition = null,
n.clipPlane = u
}
)),
c
}
return U(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 Fd("horizontal blur",new A(1,0),this._blurKernelX,this._blurRatio,null,io.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 Fd("vertical blur",new A(0,1),this._blurKernelY,this._blurRatio,null,io.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()
, n = new t(this.name,i.width,e,this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);
return n.hasAlpha = this.hasAlpha,
n.level = this.level,
n.mirrorPlane = this.mirrorPlane.clone(),
this.renderList && (n.renderList = this.renderList.slice(0)),
n
}
,
t.prototype.serialize = function() {
if (!this.name)
return null;
var t = e.prototype.serialize.call(this);
return t.mirrorPlane = this.mirrorPlane.asArray(),
t
}
,
t.prototype.dispose = function() {
var t;
e.prototype.dispose.call(this);
var i = this.getScene();
i && i.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver),
null === (t = this._sceneUBO) || void 0 === t || t.dispose()
}
,
t
}(ns);
io._CreateMirror = function(e, t, i, n) {
return new wd(e,t,i,n)
}
;
var Bd = function(e) {
function t(t, i, n, r, o, s, l, c, u, d, p, f, _, m, g) {
void 0 === n && (n = null),
void 0 === r && (r = !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 === u && (u = !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 h,
y.boundingBoxPosition = x.Zero(),
y._rotationY = 0,
y._files = null,
y._forcedExtension = null,
y._extensions = null,
y.name = t,
y.url = t,
y._noMipmap = r,
y.hasAlpha = !1,
y._format = c,
y.isCube = !0,
y._textureMatrix = P.Identity(),
y._createPolynomials = p,
y.coordinatesMode = io.CUBIC_MODE,
y._extensions = n,
y._files = o,
y._forcedExtension = d,
y._loaderOptions = m,
y._useSRGBBuffer = g,
y._lodScale = f,
y._lodOffset = _,
t || o ? (y.updateURL(t, d, s, u, l, n, null === (v = y.getScene()) || void 0 === v ? void 0 : v.useDelayedTextureLoading, o),
y) : y
}
return U(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(P.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, n) {
var r = "";
return e.forEach((function(e) {
return r += e
}
)),
new t(r,i,null,n,e)
}
,
t.CreateFromPrefilteredData = function(e, i, n, r) {
void 0 === n && (n = null),
void 0 === r && (r = !0);
var o = i.useDelayedTextureLoading;
i.useDelayedTextureLoading = !1;
var a = new t(e,i,null,!1,null,null,null,void 0,!0,n,r);
return i.useDelayedTextureLoading = o,
a
}
,
t.prototype.getClassName = function() {
return "CubeTexture"
}
,
t.prototype.updateURL = function(e, t, i, n, r, o, s, l) {
void 0 === i && (i = null),
void 0 === n && (n = !1),
void 0 === r && (r = null),
void 0 === o && (o = null),
void 0 === s && (s = !1),
void 0 === l && (l = null),
this.name && !ae(this.name, "data:") || (this.name = e),
this.url = e;
var c = e.lastIndexOf(".")
, u = t || (c > -1 ? e.substring(c).toLowerCase() : "")
, h = 0 === u.indexOf(".dds")
, d = 0 === u.indexOf(".env");
if (d ? (this.gammaSpace = !1,
this._prefiltered = !1,
this.anisotropicFilteringLevel = 1) : (this._prefiltered = n,
n && (this.gammaSpace = !1,
this.anisotropicFilteringLevel = 1)),
l)
this._files = l;
else if (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 p = 0; p < o.length; p++)
this._files.push(e + o[p]);
this._extensions = o
}
s ? (this.delayLoadState = a.DELAYLOADSTATE_NOTLOADED,
this._delayedOnLoad = i,
this._delayedOnError = r) : this._loadTexture(i, r)
}
,
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 = this;
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)
}
))),
this._textureMatrix = e)
}
,
t.prototype._loadTexture = function(e, t) {
var i, n = this;
void 0 === e && (e = null),
void 0 === t && (t = null);
var r = this.getScene()
, o = this._texture;
this._texture = this._getFromCache(this.url, this._noMipmap, void 0, void 0, this._useSRGBBuffer);
var s = function() {
var t;
n.onLoadObservable.notifyObservers(n),
o && (o.dispose(),
null === (t = n.getScene()) || void 0 === t || t.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)),
e && e()
}
, l = function(e, i) {
n._loadingError = !0,
n._errorObject = {
message: e,
exception: i
},
t && t(e, i),
io.OnTextureLoadErrorObservable.notifyObservers(n)
};
this._texture ? this._texture.isReady ? gi.SetImmediate((function() {
return s()
}
)) : this._texture.onLoadedObservable.add((function() {
return s()
}
)) : (this._prefiltered ? this._texture = this._getEngine().createPrefilteredCubeTexture(this.url, r, this._lodScale, this._lodOffset, e, l, this._format, this._forcedExtension, this._createPolynomials) : this._texture = this._getEngine().createCubeTexture(this.url, r, 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 n.onLoadObservable.notifyObservers(n)
}
)))
}
,
t.Parse = function(e, i, n) {
var r = Ge.Parse((function() {
var r = !1;
return e.prefiltered && (r = e.prefiltered),
new t(n + e.name,i,e.extensions,!1,e.files || null,null,null,void 0,r,e.forcedExtension)
}
), e, i);
if (e.boundingBoxPosition && (r.boundingBoxPosition = x.FromArray(e.boundingBoxPosition)),
e.boundingBoxSize && (r.boundingBoxSize = x.FromArray(e.boundingBoxSize)),
e.animations)
for (var o = 0; o < e.animations.length; o++) {
var a = e.animations[o]
, s = b("BABYLON.Animation");
s && r.animations.push(s.Parse(a))
}
return r
}
,
t.prototype.clone = function() {
var e = this
, i = 0
, n = Ge.Clone((function() {
var n = new t(e.url,e.getScene() || e._getEngine(),e._extensions,e._noMipmap,e._files);
return i = n.uniqueId,
n
}
), this);
return n.uniqueId = i,
n
}
,
k([Ce()], t.prototype, "url", void 0),
k([Ce("rotationY")], t.prototype, "rotationY", null),
k([Ce("files")], t.prototype, "_files", void 0),
k([Ce("forcedExtension")], t.prototype, "_forcedExtension", void 0),
k([Ce("extensions")], t.prototype, "_extensions", void 0),
k([Ue("textureMatrix")], t.prototype, "_textureMatrix", void 0),
t
}(Zr);
io._CubeTextureParser = Bd.Parse,
y("BABYLON.CubeTexture", Bd);
Pt.IncludesShadersStore.backgroundFragmentDeclaration = "uniform vec4 vEyePosition;\nuniform vec4 vPrimaryColor;\n#ifdef USEHIGHLIGHTANDSHADOWCOLORS\nuniform vec4 vPrimaryColorShadow;\n#endif\nuniform float shadowLevel;\nuniform float alpha;\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform 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";
Pt.IncludesShadersStore.backgroundUboDeclaration = "layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec4 vPrimaryColor;\nuniform vec4 vPrimaryColorShadow;\nuniform vec2 vDiffuseInfos;\nuniform vec2 vReflectionInfos;\nuniform mat4 diffuseMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float fFovMultiplier;\nuniform float pointSize;\nuniform float shadowLevel;\nuniform 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";
Pt.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;\nuniform 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;\nuniform 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{\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));\n}\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.;\nfloat globalShadow=0.;\nfloat 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;\nreflectionColor=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);\n#else\nfloat lodReflectionNormalized=saturate(reflectionLOD);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 reflectionSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nreflectionColor=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nreflectionSpecularMid,\nlodReflectionNormalizedDoubled\n);\n} else {\nreflectionColor=mix(\nreflectionSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#else\nvec4 reflectionSample=sampleReflection(reflectionSampler,reflectionCoords);\nreflectionColor=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.);\nfloat 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;\nvec3 reflectionReflectance0=vReflectionControl.yyy;\nvec3 reflectionReflectance90=vReflectionControl.zzz;\nfloat VdotN=dot(normalize(vEyePosition.xyz),normalW);\nvec3 planarReflectionFresnel=fresnelSchlickEnvironmentGGX(saturate(VdotN),reflectionReflectance0,reflectionReflectance90,1.0);\nreflectionAmount*=planarReflectionFresnel;\n#ifdef REFLECTIONFALLOFF\nfloat reflectionDistanceFalloff=1.0-saturate(length(vPositionW.xyz-vBackgroundCenter)*vReflectionControl.w);\nreflectionDistanceFalloff*=reflectionDistanceFalloff;\nreflectionAmount*=reflectionDistanceFalloff;\n#endif\nfinalColor=mix(finalColor,reflectionColor.rgb,saturate(reflectionAmount));\n#endif\n#ifdef OPACITYFRESNEL\nfloat viewAngleToFloor=dot(normalW,normalize(vEyePosition.xyz-vBackgroundCenter));\nconst float startAngle=0.1;\nfloat fadeFactor=saturate(viewAngleToFloor/startAngle);\nfinalAlpha*=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);\ncolor=max(color,0.0);\n#endif\ngl_FragColor=color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";
Pt.IncludesShadersStore.backgroundVertexDeclaration = "uniform mat4 view;\nuniform mat4 viewProjection;\nuniform float shadowLevel;\n#ifdef DIFFUSE\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float fFovMultiplier;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n";
Pt.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) {\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n} else {\ngl_Position=viewProjectionR*finalWorld*vec4(position,1.0);\n}\n#else\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#endif\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=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));\nvec3 segment=mix(vDirectionW,screenToWorld*vec3(0.0,0.0,1.0),abs(fFovMultiplier-1.0));\nif (fFovMultiplier<=1.0) {\nvDirectionW=normalize(segment);\n} else {\nvDirectionW=normalize(vDirectionW+(vDirectionW-segment));\n}\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{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\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 Ud = 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.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 U(t, e),
t
}(Si)
, Vd = function(e) {
function t(t, i) {
var n = e.call(this, t, i) || this;
return n.primaryColor = D.White(),
n._primaryColorShadowLevel = 0,
n._primaryColorHighlightLevel = 0,
n.reflectionTexture = null,
n.reflectionBlur = 0,
n.diffuseTexture = null,
n._shadowLights = null,
n.shadowLights = null,
n.shadowLevel = 0,
n.sceneCenter = x.Zero(),
n.opacityFresnel = !0,
n.reflectionFresnel = !1,
n.reflectionFalloffDistance = 0,
n.reflectionAmount = 1,
n.reflectionReflectance0 = .05,
n.reflectionReflectance90 = .5,
n.useRGBColor = !0,
n.enableNoise = !1,
n._fovMultiplier = 1,
n.useEquirectangularFOV = !1,
n._maxSimultaneousLights = 4,
n.maxSimultaneousLights = 4,
n._shadowOnly = !1,
n.shadowOnly = !1,
n._imageProcessingObserver = null,
n.switchToBGR = !1,
n._renderTargets = new bi(16),
n._reflectionControls = R.Zero(),
n._white = D.White(),
n._primaryShadowColor = D.Black(),
n._primaryHighlightColor = D.Black(),
n._attachImageProcessingConfiguration(null),
n.getRenderTargetTextures = function() {
return n._renderTargets.reset(),
n._diffuseTexture && n._diffuseTexture.isRenderTarget && n._renderTargets.push(n._diffuseTexture),
n._reflectionTexture && n._reflectionTexture.isRenderTarget && n._renderTargets.push(n._reflectionTexture),
n._renderTargets
}
,
n
}
return U(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)
return !0;
t.materialDefines || (t.materialDefines = new Ud);
var n = this.getScene()
, r = t.materialDefines;
if (this._isReadyForSubMesh(t))
return !0;
var o = n.getEngine();
if (Mr.PrepareDefinesForLights(n, e, r, !1, this._maxSimultaneousLights),
r._needNormals = !0,
Mr.PrepareDefinesForMultiview(n, r),
r._areTexturesDirty) {
if (r._needUVs = !1,
n.texturesEnabled) {
if (n.getEngine().getCaps().textureLOD && (r.TEXTURELODSUPPORT = !0),
this._diffuseTexture && vs.DiffuseTextureEnabled) {
if (!this._diffuseTexture.isReadyOrNotBlocking())
return !1;
Mr.PrepareDefinesForMergedUV(this._diffuseTexture, r, "DIFFUSE"),
r.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha,
r.GAMMADIFFUSE = this._diffuseTexture.gammaSpace,
r.OPACITYFRESNEL = this._opacityFresnel
} else
r.DIFFUSE = !1,
r.DIFFUSEHASALPHA = !1,
r.GAMMADIFFUSE = !1,
r.OPACITYFRESNEL = !1;
var s = this._reflectionTexture;
if (s && vs.ReflectionTextureEnabled) {
if (!s.isReadyOrNotBlocking())
return !1;
switch (r.REFLECTION = !0,
r.GAMMAREFLECTION = s.gammaSpace,
r.RGBDREFLECTION = s.isRGBD,
r.REFLECTIONBLUR = this._reflectionBlur > 0,
r.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !s.invertZ : s.invertZ,
r.LODINREFLECTIONALPHA = s.lodLevelInAlpha,
r.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV,
r.REFLECTIONBGR = this.switchToBGR,
s.coordinatesMode === io.INVCUBIC_MODE && (r.INVERTCUBICMAP = !0),
r.REFLECTIONMAP_3D = s.isCube,
s.coordinatesMode) {
case io.EXPLICIT_MODE:
r.REFLECTIONMAP_EXPLICIT = !0;
break;
case io.PLANAR_MODE:
r.REFLECTIONMAP_PLANAR = !0;
break;
case io.PROJECTION_MODE:
r.REFLECTIONMAP_PROJECTION = !0;
break;
case io.SKYBOX_MODE:
r.REFLECTIONMAP_SKYBOX = !0;
break;
case io.SPHERICAL_MODE:
r.REFLECTIONMAP_SPHERICAL = !0;
break;
case io.EQUIRECTANGULAR_MODE:
r.REFLECTIONMAP_EQUIRECTANGULAR = !0;
break;
case io.FIXED_EQUIRECTANGULAR_MODE:
r.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !0;
break;
case io.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
r.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !0;
break;
case io.CUBIC_MODE:
case io.INVCUBIC_MODE:
default:
r.REFLECTIONMAP_CUBIC = !0
}
this.reflectionFresnel ? (r.REFLECTIONFRESNEL = !0,
r.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) : (r.REFLECTIONFRESNEL = !1,
r.REFLECTIONFALLOFF = !1)
} else
r.REFLECTION = !1,
r.REFLECTIONFRESNEL = !1,
r.REFLECTIONFALLOFF = !1,
r.REFLECTIONBLUR = !1,
r.REFLECTIONMAP_3D = !1,
r.REFLECTIONMAP_SPHERICAL = !1,
r.REFLECTIONMAP_PLANAR = !1,
r.REFLECTIONMAP_CUBIC = !1,
r.REFLECTIONMAP_PROJECTION = !1,
r.REFLECTIONMAP_SKYBOX = !1,
r.REFLECTIONMAP_EXPLICIT = !1,
r.REFLECTIONMAP_EQUIRECTANGULAR = !1,
r.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1,
r.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1,
r.INVERTCUBICMAP = !1,
r.REFLECTIONMAP_OPPOSITEZ = !1,
r.LODINREFLECTIONALPHA = !1,
r.GAMMAREFLECTION = !1,
r.RGBDREFLECTION = !1
}
r.PREMULTIPLYALPHA = this.alphaMode === a.ALPHA_PREMULTIPLIED || this.alphaMode === a.ALPHA_PREMULTIPLIED_PORTERDUFF,
r.USERGBCOLOR = this._useRGBColor,
r.NOISE = this._enableNoise
}
if (r._areLightsDirty && (r.USEHIGHLIGHTANDSHADOWCOLORS = !this._useRGBColor && (0 !== this._primaryColorShadowLevel || 0 !== this._primaryColorHighlightLevel),
r.BACKMAT_SHADOWONLY = this._shadowOnly),
r._areImageProcessingDirty && this._imageProcessingConfiguration) {
if (!this._imageProcessingConfiguration.isReady())
return !1;
this._imageProcessingConfiguration.prepareDefines(r)
}
if (Mr.PrepareDefinesForMisc(e, n, !1, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(e), r),
Mr.PrepareDefinesForFrameBoundValues(n, o, r, i, null, t.getRenderingMesh().hasThinInstances),
Mr.PrepareDefinesForAttributes(e, r, !1, !0, !1) && e && (n.getEngine().getCaps().standardDerivatives || e.isVerticesDataPresent(Bi.NormalKind) || (e.createNormals(!0),
K.Warn("BackgroundMaterial: Normals have been created for the mesh: " + e.name))),
r.isDirty) {
r.markAsProcessed(),
n.resetCachedMaterial();
var l = new ys;
r.FOG && l.addFallback(0, "FOG"),
r.POINTSIZE && l.addFallback(1, "POINTSIZE"),
r.MULTIVIEW && l.addFallback(0, "MULTIVIEW"),
Mr.HandleFallbacksForShadows(r, l, this._maxSimultaneousLights);
var c = [Bi.PositionKind];
r.NORMAL && c.push(Bi.NormalKind),
r.UV1 && c.push(Bi.UVKind),
r.UV2 && c.push(Bi.UV2Kind),
Mr.PrepareAttributesForBones(c, e, r, l),
Mr.PrepareAttributesForInstances(c, r);
var u = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vFogInfos", "vFogColor", "pointSize", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "mBones", "vPrimaryColor", "vPrimaryColorShadow", "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos", "fFovMultiplier", "shadowLevel", "alpha", "vBackgroundCenter", "vReflectionControl", "vDiffuseInfos", "diffuseMatrix"]
, h = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"]
, d = ["Material", "Scene"];
Ri && (Ri.PrepareUniforms(u, r),
Ri.PrepareSamplers(h, r)),
Mr.PrepareUniformsAndSamplersList({
uniformsNames: u,
uniformBuffersNames: d,
samplers: h,
defines: r,
maxSimultaneousLights: this._maxSimultaneousLights
});
var p = r.toString()
, f = n.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, r, this._materialContext),
this.buildUniformLayout()
}
return !(!t.effect || !t.effect.isReady() || (r._renderId = n.getRenderId(),
t.effect._wasPreviouslyReady = !0,
0))
}
,
t.prototype._computePrimaryColorFromPerceptualColor = function() {
this.__perceptualColor && (this._primaryColor.copyFrom(this.__perceptualColor),
this._primaryColor.toLinearSpaceToRef(this._primaryColor),
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 n = this.getScene()
, r = i.materialDefines;
if (r) {
var o = i.effect;
if (o) {
this._activeEffect = o,
this.bindOnlyWorldMatrix(e),
Mr.BindBonesParameters(t, this._activeEffect);
var a = this._mustRebind(n, 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 || (n.texturesEnabled && (this._diffuseTexture && vs.DiffuseTextureEnabled && (this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level),
Mr.BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse")),
s && vs.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),
r.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),
n.texturesEnabled && (this._diffuseTexture && vs.DiffuseTextureEnabled && this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture),
s && vs.ReflectionTextureEnabled && (r.REFLECTIONBLUR && r.TEXTURELODSUPPORT ? this._uniformBuffer.setTexture("reflectionSampler", s) : r.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),
r.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)))),
Mr.BindClipPlane(this._activeEffect, n),
n.bindEyePosition(o)
} else
n.getEngine()._features.needToAlwaysBindUniformBuffers && (this._uniformBuffer.bindToEffect(o, "Material"),
this._needToBindSceneUbo = !0);
!a && this.isFrozen || (n.lightsEnabled && Mr.BindLights(n, t, this._activeEffect, r, this._maxSimultaneousLights),
this.bindView(o),
Mr.BindFogParameters(n, 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 Ge.Clone((function() {
return new t(e,i.getScene())
}
), this)
}
,
t.prototype.serialize = function() {
var e = Ge.Serialize(this);
return e.customType = "BABYLON.BackgroundMaterial",
e
}
,
t.prototype.getClassName = function() {
return "BackgroundMaterial"
}
,
t.Parse = function(e, i, n) {
return Ge.Parse((function() {
return new t(e.name,i)
}
), e, i, n)
}
,
t.StandardReflectance0 = .05,
t.StandardReflectance90 = .5,
k([Me()], t.prototype, "_primaryColor", void 0),
k([Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "primaryColor", void 0),
k([Me()], t.prototype, "__perceptualColor", void 0),
k([Ce()], t.prototype, "_primaryColorShadowLevel", void 0),
k([Ce()], t.prototype, "_primaryColorHighlightLevel", void 0),
k([Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "primaryColorHighlightLevel", null),
k([Pe()], t.prototype, "_reflectionTexture", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionTexture", void 0),
k([Ce()], t.prototype, "_reflectionBlur", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionBlur", void 0),
k([Pe()], t.prototype, "_diffuseTexture", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "diffuseTexture", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "shadowLights", void 0),
k([Ce()], t.prototype, "_shadowLevel", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "shadowLevel", void 0),
k([De()], t.prototype, "_sceneCenter", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "sceneCenter", void 0),
k([Ce()], t.prototype, "_opacityFresnel", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "opacityFresnel", void 0),
k([Ce()], t.prototype, "_reflectionFresnel", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionFresnel", void 0),
k([Ce()], t.prototype, "_reflectionFalloffDistance", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionFalloffDistance", void 0),
k([Ce()], t.prototype, "_reflectionAmount", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionAmount", void 0),
k([Ce()], t.prototype, "_reflectionReflectance0", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionReflectance0", void 0),
k([Ce()], t.prototype, "_reflectionReflectance90", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionReflectance90", void 0),
k([Ce()], t.prototype, "_useRGBColor", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRGBColor", void 0),
k([Ce()], t.prototype, "_enableNoise", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "enableNoise", void 0),
k([Ce()], t.prototype, "_maxSimultaneousLights", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "maxSimultaneousLights", void 0),
k([Ce()], t.prototype, "_shadowOnly", void 0),
k([Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "shadowOnly", void 0),
k([we()], t.prototype, "_imageProcessingConfiguration", void 0),
t
}(gs);
y("BABYLON.BackgroundMaterial", Vd);
var kd = function() {
function e(t, i) {
var n = this;
this._errorHandler = function(e, t) {
n.onErrorObservable.notifyObservers({
message: e,
exception: t
})
}
,
this._options = V(V({}, e._GetDefaultOptions()), t),
this._scene = i,
this.onErrorObservable = new h,
this._setupBackground(),
this._setupImageProcessing()
}
return e._GetDefaultOptions = function() {
return {
createGround: !0,
groundSize: 15,
groundTexture: this._GroundTextureCDNUrl,
groundColor: new D(.2,.2,.3).toLinearSpace().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 D(.2,.2,.3).toLinearSpace().scale(3),
backgroundYRotation: 0,
sizeAuto: !0,
rootPosition: x.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 = V(V({}, 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 N(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 Zr)
this._scene.environmentTexture = this._options.environmentTexture;
else {
var e = Bd.CreateFromPrefilteredData(this._options.environmentTexture, this._scene);
this._scene.environmentTexture = e
}
}
,
e.prototype._setupBackground = function() {
this._rootMesh || (this._rootMesh = new Vr("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
, n = this._options.rootPosition;
if (!this._scene.meshes || 1 === this._scene.meshes.length)
return {
groundSize: t,
skyboxSize: i,
rootPosition: n
};
var r = this._scene.getWorldExtends((function(t) {
return t !== e._ground && t !== e._rootMesh && t !== e._skybox
}
))
, o = r.max.subtract(r.min);
if (this._options.sizeAuto) {
this._scene.activeCamera instanceof _a && 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,
(n = r.min.add(o.scale(.5))).y = r.min.y - this._options.groundYBias
}
return {
groundSize: t,
skyboxSize: i,
rootPosition: n
}
}
,
e.prototype._setupGround = function(e) {
var t = this;
this._ground && !this._ground.isDisposed() || (this._ground = vo("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 Vd("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 Zr ? this._groundMaterial.diffuseTexture = this._options.groundTexture : (this._groundTexture = new io(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 = io.CLAMP_ADDRESSMODE;
if (!this._groundMirror && (this._groundMirror = new wd("BackgroundPlaneMirrorTexture",{
ratio: this._options.groundMirrorSizeRatio
},this._scene,!1,this._options.groundMirrorTextureType,io.BILINEAR_SAMPLINGMODE,!0),
this._groundMirror.mirrorPlane = new hn(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 n = this._scene.meshes[i];
n !== this._ground && n !== this._skybox && n !== this._rootMesh && this._groundMirror.renderList.push(n)
}
var r = this._options.groundColor.toGammaSpace();
this._groundMirror.clearColor = new N(r.r,r.g,r.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 = Ml("BackgroundSkybox", {
size: e.skyboxSize,
sideOrientation: Vr.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 Vd("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 Zr ? this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture : (this._skyboxTexture = new Bd(this._options.skyboxTexture,this._scene,void 0,void 0,void 0,void 0,this._errorHandler),
this._skyboxTexture.coordinatesMode = io.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
}()
, Gd = function(e) {
function t(i, n, r, 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 h,
s.onLoadObservable = new h,
o = s.getScene(),
i = i || "textureDome",
r.resolution = 0 | Math.abs(r.resolution) || 32,
r.clickToPlay = Boolean(r.clickToPlay),
r.autoPlay = void 0 === r.autoPlay || Boolean(r.autoPlay),
r.loop = void 0 === r.loop || Boolean(r.loop),
r.size = Math.abs(r.size) || (o.activeCamera ? .48 * o.activeCamera.maxZ : 1e3),
void 0 === r.useDirectMapping ? s._useDirectMapping = !0 : s._useDirectMapping = r.useDirectMapping,
void 0 === r.faceForward && (r.faceForward = !0),
s._setReady(!1),
r.mesh ? s._mesh = r.mesh : s._mesh = Dl(i + "_mesh", {
segments: r.resolution,
diameter: r.size,
updatable: !1,
sideOrientation: Vr.BACKSIDE
}, o);
var l = s._material = new Vd(i + "_material",o);
l.useEquirectangularFOV = !0,
l.fovMultiplier = 1,
l.opacityFresnel = !1;
var c = s._initTexture(n, o, r);
if (s.texture = c,
s._mesh.material = l,
s._mesh.parent = s,
s._halfDomeMask = Dl("", {
slice: .5,
diameter: .98 * r.size,
segments: 2 * r.resolution,
sideOrientation: Vr.BACKSIDE
}, o),
s._halfDomeMask.rotate(vn.X, -Math.PI / 2),
s._halfDomeMask.parent = s._mesh,
s._halfDome = !!r.halfDomeMode,
s._halfDomeMask.setEnabled(s._halfDome),
s._crossEye = !!r.crossEyeMode,
s._texture.anisotropicFilteringLevel = 1,
s._texture.onLoadObservable.addOnce((function() {
s._setReady(!0)
}
)),
r.faceForward && o.activeCamera) {
var u = o.activeCamera
, d = x.Forward()
, p = x.TransformNormal(d, u.getViewMatrix());
p.normalize(),
s.rotation.y = Math.acos(x.Dot(d, p))
}
return s._changeTextureMode(s._textureMode),
s
}
return U(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 = io.CLAMP_ADDRESSMODE,
this._texture.wrapV = io.CLAMP_ADDRESSMODE,
this._material.diffuseTexture = this._texture) : (this._texture.coordinatesMode = io.FIXED_EQUIRECTANGULAR_MIRRORED_MODE,
this._texture.wrapV = io.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 n = this._halfDome ? 0 : .5
, r = this._halfDome ? -.5 : 0;
this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add((function(e) {
var t = e.isRightCamera;
i._crossEye && (t = !t),
i._texture.uOffset = t ? n : r
}
));
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
}(yr)
, zd = function(e) {
function t() {
return null !== e && e.apply(this, arguments) || this
}
return U(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 n = this;
return new io(e,t,!i.generateMipMaps,!this._useDirectMapping,void 0,(function() {
n.onLoadObservable.notifyObservers()
}
),(function(e, t) {
n.onLoadErrorObservable.notifyObservers(e || "Unknown error occured"),
n.onError && n.onError(e, t)
}
))
}
,
t.MODE_MONOSCOPIC = Gd.MODE_MONOSCOPIC,
t.MODE_TOPBOTTOM = Gd.MODE_TOPBOTTOM,
t.MODE_SIDEBYSIDE = Gd.MODE_SIDEBYSIDE,
t
}(Gd)
, Wd = 0
, Hd = function(e) {
if (!e.environmentBRDFTexture) {
var t = e.useDelayedTextureLoading;
e.useDelayedTextureLoading = !1;
var i = e._blockEntityCollection;
e._blockEntityCollection = !1;
var n = io.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" + Wd++, e, !0, !1, io.BILINEAR_SAMPLINGMODE);
e._blockEntityCollection = i;
var r = e.getEngine().getLoadedTexturesCache()
, o = r.indexOf(n.getInternalTexture());
-1 !== o && r.splice(o, 1),
n.isRGBD = !0,
n.wrapU = io.CLAMP_ADDRESSMODE,
n.wrapV = io.CLAMP_ADDRESSMODE,
e.environmentBRDFTexture = n,
e.useDelayedTextureLoading = t,
Lc.ExpandRGBDTexture(n);
var a = e.getEngine().onContextRestoredObservable.add((function() {
n.isRGBD = !0;
var e = function() {
n.isReady() ? Lc.ExpandRGBDTexture(n) : gi.SetImmediate(e)
};
e()
}
));
e.onDisposeObservable.add((function() {
e.getEngine().onContextRestoredObservable.remove(a)
}
))
}
return e.environmentBRDFTexture
}
, Xd = {
GetEnvironmentBRDFTexture: Hd
}
, jd = 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 U(t, e),
t
}(Si)
, Yd = function(e) {
function t(i, n) {
void 0 === n && (n = !0);
var r = e.call(this, i, "PBRBRDF", 90, new jd, n) || this;
return r._useEnergyConservation = t.DEFAULT_USE_ENERGY_CONSERVATION,
r.useEnergyConservation = t.DEFAULT_USE_ENERGY_CONSERVATION,
r._useSmithVisibilityHeightCorrelated = t.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,
r.useSmithVisibilityHeightCorrelated = t.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,
r._useSphericalHarmonics = t.DEFAULT_USE_SPHERICAL_HARMONICS,
r.useSphericalHarmonics = t.DEFAULT_USE_SPHERICAL_HARMONICS,
r._useSpecularGlossinessInputEnergyConservation = t.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,
r.useSpecularGlossinessInputEnergyConservation = t.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,
r._internalMarkAllSubMeshesAsMiscDirty = i._dirtyCallbacks[a.MATERIAL_MiscDirtyFlag],
r._enable(!0),
r
}
return U(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,
k([Ce(), Re("_markAllSubMeshesAsMiscDirty")], t.prototype, "useEnergyConservation", void 0),
k([Ce(), Re("_markAllSubMeshesAsMiscDirty")], t.prototype, "useSmithVisibilityHeightCorrelated", void 0),
k([Ce(), Re("_markAllSubMeshesAsMiscDirty")], t.prototype, "useSphericalHarmonics", void 0),
k([Ce(), Re("_markAllSubMeshesAsMiscDirty")], t.prototype, "useSpecularGlossinessInputEnergyConservation", void 0),
t
}(Rs);
Pt.IncludesShadersStore.pbrFragmentDeclaration = "uniform vec4 vEyePosition;\nuniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\nuniform vec4 vLightingIntensity;\nuniform vec4 vReflectivityColor;\nuniform vec4 vMetallicReflectanceFactors;\nuniform vec3 vEmissiveColor;\nuniform float visibility;\nuniform vec3 vAmbientColor;\n#ifdef ALBEDO\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform 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;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize; \n#endif\n#endif\n#if defined(SS_REFRACTION) && defined(SS_USE_LOCAL_REFRACTIONMAP_CUBIC)\nuniform vec3 vRefractionPosition;\nuniform vec3 vRefractionSize; \n#endif\n#ifdef CLEARCOAT\nuniform vec2 vClearCoatParams;\nuniform 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;\nuniform vec2 vClearCoatTangentSpaceParams;\nuniform mat4 clearCoatBumpMatrix;\n#endif\n#ifdef CLEARCOAT_TINT\nuniform vec4 vClearCoatTintParams;\nuniform float clearCoatColorAtDistance;\n#ifdef CLEARCOAT_TINT_TEXTURE\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\n#endif\n#endif\n#endif\n#ifdef ANISOTROPIC\nuniform vec3 vAnisotropy;\n#ifdef ANISOTROPIC_TEXTURE\nuniform vec2 vAnisotropyInfos;\nuniform 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;\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\n#ifdef REALTIME_FILTERING\nuniform vec2 vRefractionFilteringInfo;\n#endif\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nuniform vec2 vThicknessInfos;\nuniform mat4 thicknessMatrix;\n#endif\n#ifdef SS_REFRACTIONINTENSITY_TEXTURE\nuniform vec2 vRefractionIntensityInfos;\nuniform mat4 refractionIntensityMatrix;\n#endif\n#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE\nuniform vec2 vTranslucencyIntensityInfos;\nuniform mat4 translucencyIntensityMatrix;\n#endif\nuniform vec2 vThicknessParam;\nuniform vec3 vDiffusionDistance;\nuniform vec4 vTintColor;\nuniform 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#ifdef USESPHERICALFROMREFLECTIONMAP\n#ifdef SPHERICAL_HARMONICS\nuniform vec3 vSphericalL00;\nuniform vec3 vSphericalL1_1;\nuniform vec3 vSphericalL10;\nuniform vec3 vSphericalL11;\nuniform vec3 vSphericalL2_2;\nuniform vec3 vSphericalL2_1;\nuniform vec3 vSphericalL20;\nuniform vec3 vSphericalL21;\nuniform vec3 vSphericalL22;\n#else\nuniform vec3 vSphericalX;\nuniform vec3 vSphericalY;\nuniform vec3 vSphericalZ;\nuniform vec3 vSphericalXX_ZZ;\nuniform vec3 vSphericalYY_ZZ;\nuniform vec3 vSphericalZZ;\nuniform vec3 vSphericalXY;\nuniform vec3 vSphericalYZ;\nuniform vec3 vSphericalZX;\n#endif\n#endif\n#define ADDITIONAL_FRAGMENT_DECLARATION\n";
Pt.IncludesShadersStore.pbrUboDeclaration = "layout(std140,column_major) uniform;\nuniform Material {\nvec2 vAlbedoInfos;\nvec4 vAmbientInfos;\nvec2 vOpacityInfos;\nvec2 vEmissiveInfos;\nvec2 vLightmapInfos;\nvec3 vReflectivityInfos;\nvec2 vMicroSurfaceSamplerInfos;\nvec2 vReflectionInfos;\nvec2 vReflectionFilteringInfo;\nvec3 vReflectionPosition;\nvec3 vReflectionSize;\nvec3 vBumpInfos;\nmat4 albedoMatrix;\nmat4 ambientMatrix;\nmat4 opacityMatrix;\nmat4 emissiveMatrix;\nmat4 lightmapMatrix;\nmat4 reflectivityMatrix;\nmat4 microSurfaceSamplerMatrix;\nmat4 bumpMatrix;\nvec2 vTangentSpaceParams;\nmat4 reflectionMatrix;\nvec3 vReflectionColor;\nvec4 vAlbedoColor;\nvec4 vLightingIntensity;\nvec3 vReflectionMicrosurfaceInfos;\nfloat pointSize;\nvec4 vReflectivityColor;\nvec3 vEmissiveColor;\nvec3 vAmbientColor;\nvec2 vDebugMode;\nvec4 vMetallicReflectanceFactors;\nvec2 vMetallicReflectanceInfos;\nmat4 metallicReflectanceMatrix;\nvec2 vReflectanceInfos;\nmat4 reflectanceMatrix;\nvec3 vSphericalL00;\nvec3 vSphericalL1_1;\nvec3 vSphericalL10;\nvec3 vSphericalL11;\nvec3 vSphericalL2_2;\nvec3 vSphericalL2_1;\nvec3 vSphericalL20;\nvec3 vSphericalL21;\nvec3 vSphericalL22;\nvec3 vSphericalX;\nvec3 vSphericalY;\nvec3 vSphericalZ;\nvec3 vSphericalXX_ZZ;\nvec3 vSphericalYY_ZZ;\nvec3 vSphericalZZ;\nvec3 vSphericalXY;\nvec3 vSphericalYZ;\nvec3 vSphericalZX;\n#define ADDITIONAL_UBO_DECLARATION\n};\n#include\n#include\n";
Pt.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)\nvarying vec4 vColor;\n#endif\n";
Pt.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";
Pt.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#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 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;\nuniform 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;\nuniform 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;\nuniform 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;\nuniform 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";
Pt.IncludesShadersStore.subSurfaceScatteringFunctions = "bool testLightingForSSS(float diffusionProfile)\n{\nreturn diffusionProfile<1.;\n}";
Pt.IncludesShadersStore.importanceSampling = "vec3 hemisphereCosSample(vec2 u) {\nfloat phi=2.*PI*u.x;\nfloat cosTheta2=1.-u.y;\nfloat cosTheta=sqrt(cosTheta2);\nfloat sinTheta=sqrt(1.-cosTheta2);\nreturn vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);\n}\nvec3 hemisphereImportanceSampleDggx(vec2 u,float a) {\nfloat phi=2.*PI*u.x;\nfloat cosTheta2=(1.-u.y)/(1.+(a+1.)*((a-1.)*u.y));\nfloat cosTheta=sqrt(cosTheta2);\nfloat sinTheta=sqrt(1.-cosTheta2);\nreturn vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);\n}\nvec3 hemisphereImportanceSampleDCharlie(vec2 u,float a) { \nfloat phi=2.*PI*u.x;\nfloat sinTheta=pow(u.y,a/(2.*a+1.));\nfloat cosTheta=sqrt(1.-sinTheta*sinTheta);\nreturn vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);\n}";
Pt.IncludesShadersStore.pbrHelperFunctions = "#define RECIPROCAL_PI2 0.15915494\n#define RECIPROCAL_PI 0.31830988618\n#define MINIMUMVARIANCE 0.0005\nfloat convertRoughnessToAverageSlope(float roughness)\n{\nreturn square(roughness)+MINIMUMVARIANCE;\n}\nfloat fresnelGrazingReflectance(float reflectance0) {\nfloat reflectance90=saturate(reflectance0*25.0);\nreturn reflectance90;\n}\nvec2 getAARoughnessFactors(vec3 normalVector) {\n#ifdef SPECULARAA\nvec3 nDfdx=dFdx(normalVector.xyz);\nvec3 nDfdy=dFdy(normalVector.xyz);\nfloat slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));\nfloat geometricRoughnessFactor=pow(saturate(slopeSquare),0.333);\nfloat geometricAlphaGFactor=sqrt(slopeSquare);\ngeometricAlphaGFactor*=0.75;\nreturn vec2(geometricRoughnessFactor,geometricAlphaGFactor);\n#else\nreturn vec2(0.);\n#endif\n}\n#ifdef ANISOTROPIC\nvec2 getAnisotropicRoughness(float alphaG,float anisotropy) {\nfloat alphaT=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);\nfloat alphaB=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);\nreturn vec2(alphaT,alphaB);\n}\nvec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy) {\nvec3 anisotropicFrameDirection=anisotropy>=0.0 ? B : T;\nvec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),V);\nvec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection);\nvec3 anisotropicNormal=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));\nreturn anisotropicNormal;\n}\n#endif\n#if defined(CLEARCOAT) || defined(SS_REFRACTION)\nvec3 cocaLambert(vec3 alpha,float distance) {\nreturn exp(-alpha*distance);\n}\nvec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) {\nreturn cocaLambert(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));\n}\nvec3 computeColorAtDistanceInMedia(vec3 color,float distance) {\nreturn -log(color)/distance;\n}\nvec3 computeClearCoatAbsorption(float NdotVRefract,float NdotLRefract,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\nvec3 clearCoatAbsorption=mix(vec3(1.0),\ncocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),\nclearCoatIntensity);\nreturn clearCoatAbsorption;\n}\n#endif\n#ifdef MICROSURFACEAUTOMATIC\nfloat computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)\n{\nconst float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;\nfloat reflectivityLuminance=getLuminance(reflectivityColor);\nfloat reflectivityLuma=sqrt(reflectivityLuminance);\nmicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;\nreturn microSurface;\n}\n#endif\n";
Pt.IncludesShadersStore.harmonicsFunctions = "#ifdef USESPHERICALFROMREFLECTIONMAP\n#ifdef SPHERICAL_HARMONICS\nvec3 computeEnvironmentIrradiance(vec3 normal) {\nreturn 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}\n#else\nvec3 computeEnvironmentIrradiance(vec3 normal) {\nfloat Nx=normal.x;\nfloat Ny=normal.y;\nfloat Nz=normal.z;\nvec3 C1=vSphericalZZ.rgb;\nvec3 Cx=vSphericalX.rgb;\nvec3 Cy=vSphericalY.rgb;\nvec3 Cz=vSphericalZ.rgb;\nvec3 Cxx_zz=vSphericalXX_ZZ.rgb;\nvec3 Cyy_zz=vSphericalYY_ZZ.rgb;\nvec3 Cxy=vSphericalXY.rgb;\nvec3 Cyz=vSphericalYZ.rgb;\nvec3 Czx=vSphericalZX.rgb;\nvec3 a1=Cyy_zz*Ny+Cy;\nvec3 a2=Cyz*Nz+a1;\nvec3 b1=Czx*Nz+Cx;\nvec3 b2=Cxy*Ny+b1;\nvec3 b3=Cxx_zz*Nx+b2;\nvec3 t1=Cz *Nz+C1;\nvec3 t2=a2 *Ny+t1;\nvec3 t3=b3 *Nx+t2;\nreturn t3;\n}\n#endif\n#endif\n";
Pt.IncludesShadersStore.pbrDirectLightingSetupFunctions = "struct preLightingInfo\n{\nvec3 lightOffset;\nfloat lightDistanceSquared;\nfloat lightDistance;\nfloat attenuation;\nvec3 L;\nvec3 H;\nfloat NdotV;\nfloat NdotLUnclamped;\nfloat NdotL;\nfloat VdotH;\nfloat roughness;\n};\npreLightingInfo computePointAndSpotPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\nresult.lightDistance=sqrt(result.lightDistanceSquared);\nresult.L=normalize(result.lightOffset);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\nresult.NdotLUnclamped=dot(N,result.L);\nresult.NdotL=saturateEps(result.NdotLUnclamped);\nreturn result;\n}\npreLightingInfo computeDirectionalPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\nresult.lightDistance=length(-lightData.xyz);\nresult.L=normalize(-lightData.xyz);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\nresult.NdotLUnclamped=dot(N,result.L);\nresult.NdotL=saturateEps(result.NdotLUnclamped);\nreturn result;\n}\npreLightingInfo computeHemisphericPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\nresult.NdotL=dot(N,lightData.xyz)*0.5+0.5;\nresult.NdotL=saturateEps(result.NdotL);\nresult.NdotLUnclamped=result.NdotL;\n#ifdef SPECULARTERM\nresult.L=normalize(lightData.xyz);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\n#endif\nreturn result;\n}";
Pt.IncludesShadersStore.pbrDirectLightingFalloffFunctions = "float computeDistanceLightFalloff_Standard(vec3 lightOffset,float range)\n{\nreturn max(0.,1.0-length(lightOffset)/range);\n}\nfloat computeDistanceLightFalloff_Physical(float lightDistanceSquared)\n{\nreturn 1.0/maxEps(lightDistanceSquared);\n}\nfloat computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)\n{\nfloat lightDistanceFalloff=1.0/maxEps(lightDistanceSquared);\nfloat factor=lightDistanceSquared*inverseSquaredRange;\nfloat attenuation=saturate(1.0-factor*factor);\nattenuation*=attenuation;\nlightDistanceFalloff*=attenuation;\nreturn lightDistanceFalloff;\n}\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{\nfloat falloff=0.0;\nfloat cosAngle=maxEps(dot(-lightDirection,directionToLightCenterW));\nif (cosAngle>=cosHalfAngle)\n{\nfalloff=max(0.,pow(cosAngle,exponent));\n}\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle)\n{\nconst float kMinusLog2ConeAngleIntensityRatio=6.64385618977; \nfloat concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);\nvec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);\nfloat falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset)\n{\nfloat cd=dot(-lightDirection,directionToLightCenterW);\nfloat falloff=saturate(cd*lightAngleScale+lightAngleOffset);\nfalloff*=falloff;\nreturn falloff;\n}\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}";
Pt.IncludesShadersStore.pbrBRDFFunctions = "#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n#ifdef MS_BRDF_ENERGY_CONSERVATION\nvec3 getEnergyConservationFactor(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {\nreturn 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);\n}\n#endif\n#ifdef ENVIRONMENTBRDF\nvec3 getBRDFLookup(float NdotV,float perceptualRoughness) {\nvec2 UV=vec2(NdotV,perceptualRoughness);\nvec4 brdfLookup=texture2D(environmentBrdfSampler,UV);\n#ifdef ENVIRONMENTBRDF_RGBD\nbrdfLookup.rgb=fromRGBD(brdfLookup.rgba);\n#endif\nreturn brdfLookup.rgb;\n}\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;\n}\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}\n#endif\n/* NOT USED\n#if defined(SHEEN) && defined(SHEEN_SOFTER)\nfloat getBRDFLookupCharlieSheen(float NdotV,float perceptualRoughness)\n{\nfloat c=1.0-NdotV;\nfloat c3=c*c*c;\nreturn 0.65584461*c3+1.0/(4.16526551+exp(-7.97291361*perceptualRoughness+6.33516894));\n}\n#endif\n*/\n#if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL)\nvec3 getReflectanceFromAnalyticalBRDFLookup_Jones(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));\n}\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) {\nvec3 sheenEnvironmentReflectance=reflectance0*environmentBrdf.b;\nreturn sheenEnvironmentReflectance;\n}\n#endif\nvec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);\n}\nfloat fresnelSchlickGGX(float VdotH,float reflectance0,float reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);\n}\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);\nvec3 t=(vClearCoatRefractionParams.z+vClearCoatRefractionParams.w*s)/(vClearCoatRefractionParams.w+vClearCoatRefractionParams.z*s);\nreturn t*t;\n#endif\n}\n#endif\nfloat normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)\n{\nfloat a2=square(alphaG);\nfloat d=NdotH*NdotH*(a2-1.0)+1.0;\nreturn a2/(PI*d*d);\n}\n#ifdef SHEEN\nfloat normalDistributionFunction_CharlieSheen(float NdotH,float alphaG)\n{\nfloat invR=1./alphaG;\nfloat cos2h=NdotH*NdotH;\nfloat sin2h=1.-cos2h;\nreturn (2.+invR)*pow(sin2h,invR*.5)/(2.*PI);\n}\n#endif\n#ifdef ANISOTROPIC\nfloat normalDistributionFunction_BurleyGGX_Anisotropic(float NdotH,float TdotH,float BdotH,const vec2 alphaTB) {\nfloat a2=alphaTB.x*alphaTB.y;\nvec3 v=vec3(alphaTB.y*TdotH,alphaTB.x *BdotH,a2*NdotH);\nfloat v2=dot(v,v);\nfloat w2=a2/v2;\nreturn a2*w2*w2*RECIPROCAL_PI;\n}\n#endif\n#ifdef BRDF_V_HEIGHT_CORRELATED\nfloat smithVisibility_GGXCorrelated(float NdotL,float NdotV,float alphaG) {\n#ifdef MOBILE\nfloat GGXV=NdotL*(NdotV*(1.0-alphaG)+alphaG);\nfloat GGXL=NdotV*(NdotL*(1.0-alphaG)+alphaG);\nreturn 0.5/(GGXV+GGXL);\n#else\nfloat a2=alphaG*alphaG;\nfloat GGXV=NdotL*sqrt(NdotV*(NdotV-a2*NdotV)+a2);\nfloat GGXL=NdotV*sqrt(NdotL*(NdotL-a2*NdotL)+a2);\nreturn 0.5/(GGXV+GGXL);\n#endif\n}\n#else\nfloat smithVisibilityG1_TrowbridgeReitzGGXFast(float dot,float alphaG)\n{\n#ifdef MOBILE\nreturn 1.0/(dot+alphaG+(1.0-alphaG)*dot ));\n#else\nfloat alphaSquared=alphaG*alphaG;\nreturn 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot));\n#endif\n}\nfloat smithVisibility_TrowbridgeReitzGGXFast(float NdotL,float NdotV,float alphaG)\n{\nfloat visibility=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG);\nreturn visibility;\n}\n#endif\n#ifdef ANISOTROPIC\nfloat smithVisibility_GGXCorrelated_Anisotropic(float NdotL,float NdotV,float TdotV,float BdotV,float TdotL,float BdotL,const vec2 alphaTB) {\nfloat lambdaV=NdotL*length(vec3(alphaTB.x*TdotV,alphaTB.y*BdotV,NdotV));\nfloat lambdaL=NdotV*length(vec3(alphaTB.x*TdotL,alphaTB.y*BdotL,NdotL));\nfloat v=0.5/(lambdaV+lambdaL);\nreturn v;\n}\n#endif\n#ifdef CLEARCOAT\nfloat visibility_Kelemen(float VdotH) {\nreturn 0.25/(VdotH*VdotH); \n}\n#endif\n#ifdef SHEEN\nfloat visibility_Ashikhmin(float NdotL,float NdotV)\n{\nreturn 1./(4.*(NdotL+NdotV-NdotL*NdotV));\n}\n/* NOT USED\n#ifdef SHEEN_SOFTER\nfloat l(float x,float alphaG)\n{\nfloat oneMinusAlphaSq=(1.0-alphaG)*(1.0-alphaG);\nfloat a=mix(21.5473,25.3245,oneMinusAlphaSq);\nfloat b=mix(3.82987,3.32435,oneMinusAlphaSq);\nfloat c=mix(0.19823,0.16801,oneMinusAlphaSq);\nfloat d=mix(-1.97760,-1.27393,oneMinusAlphaSq);\nfloat e=mix(-4.32054,-4.85967,oneMinusAlphaSq);\nreturn a/(1.0+b*pow(x,c))+d*x+e;\n}\nfloat lambdaSheen(float cosTheta,float alphaG)\n{\nreturn abs(cosTheta)<0.5 ? exp(l(cosTheta,alphaG)) : exp(2.0*l(0.5,alphaG)-l(1.0-cosTheta,alphaG));\n}\nfloat visibility_CharlieSheen(float NdotL,float NdotV,float alphaG)\n{\nfloat G=1.0/(1.0+lambdaSheen(NdotV,alphaG)+lambdaSheen(NdotL,alphaG));\nreturn G/(4.0*NdotV*NdotL);\n}\n#endif\n*/\n#endif\nfloat diffuseBRDF_Burley(float NdotL,float NdotV,float VdotH,float roughness) {\nfloat diffuseFresnelNV=pow5(saturateEps(1.0-NdotL));\nfloat diffuseFresnelNL=pow5(saturateEps(1.0-NdotV));\nfloat diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;\nfloat fresnel =\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);\nreturn fresnel/PI;\n}\n#ifdef SS_TRANSLUCENCY\nvec3 transmittanceBRDF_Burley(const vec3 tintColor,const vec3 diffusionDistance,float thickness) {\nvec3 S=1./maxEps(diffusionDistance);\nvec3 temp=exp((-0.333333333*thickness)*S);\nreturn tintColor.rgb*0.25*(temp*temp*temp+3.0*temp);\n}\nfloat computeWrappedDiffuseNdotL(float NdotL,float w) {\nfloat t=1.0+w;\nfloat invt2=1.0/square(t);\nreturn saturate((NdotL+w)*invt2);\n}\n#endif\n";
Pt.IncludesShadersStore.hdrFilteringFunctions = "#ifdef NUM_SAMPLES\n#if NUM_SAMPLES>0\n#if defined(WEBGL2) || defined(WEBGPU)\nfloat radicalInverse_VdC(uint bits) \n{\nbits=(bits<<16u) | (bits>>16u);\nbits=((bits & 0x55555555u)<<1u) | ((bits & 0xAAAAAAAAu)>>1u);\nbits=((bits & 0x33333333u)<<2u) | ((bits & 0xCCCCCCCCu)>>2u);\nbits=((bits & 0x0F0F0F0Fu)<<4u) | ((bits & 0xF0F0F0F0u)>>4u);\nbits=((bits & 0x00FF00FFu)<<8u) | ((bits & 0xFF00FF00u)>>8u);\nreturn float(bits)*2.3283064365386963e-10; \n}\nvec2 hammersley(uint i,uint N)\n{\nreturn vec2(float(i)/float(N),radicalInverse_VdC(i));\n}\n#else\nfloat vanDerCorpus(int n,int base)\n{\nfloat invBase=1.0/float(base);\nfloat denom =1.0;\nfloat result =0.0;\nfor(int i=0; i<32; ++i)\n{\nif(n>0)\n{\ndenom =mod(float(n),2.0);\nresult+=denom*invBase;\ninvBase=invBase/2.0;\nn =int(float(n)/2.0);\n}\n}\nreturn result;\n}\nvec2 hammersley(int i,int N)\n{\nreturn vec2(float(i)/float(N),vanDerCorpus(i,2));\n}\n#endif\nfloat log4(float x) {\nreturn log2(x)/2.;\n}\nconst float NUM_SAMPLES_FLOAT=float(NUM_SAMPLES);\nconst float NUM_SAMPLES_FLOAT_INVERSED=1./NUM_SAMPLES_FLOAT;\nconst float K=4.;\n#define inline\nvec3 irradiance(samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)\n{\nvec3 n=normalize(inputN);\nvec3 result=vec3(0.0);\nvec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);\ntangent=normalize(cross(tangent,n));\nvec3 bitangent=cross(n,tangent);\nmat3 tbn=mat3(tangent,bitangent,n);\nfloat maxLevel=filteringInfo.y;\nfloat dim0=filteringInfo.x;\nfloat omegaP=(4.*PI)/(6.*dim0*dim0);\n#if defined(WEBGL2) || defined(WEBGPU)\nfor(uint i=0u; i0.) {\nfloat pdf_inversed=PI/NoL;\nfloat omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;\nfloat l=log4(omegaS)-log4(omegaP)+log4(K);\nfloat mipLevel=clamp(l,0.0,maxLevel);\nvec3 c=textureCubeLodEXT(inputTexture,tbn*Ls,mipLevel).rgb;\n#ifdef GAMMA_INPUT\nc=toLinearSpace(c);\n#endif\nresult+=c;\n}\n}\nresult=result*NUM_SAMPLES_FLOAT_INVERSED;\nreturn result;\n}\n#define inline\nvec3 radiance(float alphaG,samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)\n{\nvec3 n=normalize(inputN);\nif (alphaG==0.) {\nvec3 c=textureCube(inputTexture,n).rgb;\n#ifdef GAMMA_INPUT\nc=toLinearSpace(c);\n#endif\nreturn c;\n} else {\nvec3 result=vec3(0.);\nvec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);\ntangent=normalize(cross(tangent,n));\nvec3 bitangent=cross(n,tangent);\nmat3 tbn=mat3(tangent,bitangent,n);\nfloat maxLevel=filteringInfo.y;\nfloat dim0=filteringInfo.x;\nfloat omegaP=(4.*PI)/(6.*dim0*dim0);\nfloat weight=0.;\n#if defined(WEBGL2) || defined(WEBGPU)\nfor(uint i=0u; i0.) {\nfloat pdf_inversed=4./normalDistributionFunction_TrowbridgeReitzGGX(NoH,alphaG);\nfloat omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;\nfloat l=log4(omegaS)-log4(omegaP)+log4(K);\nfloat mipLevel=clamp(float(l),0.0,maxLevel);\nweight+=NoL;\nvec3 c=textureCubeLodEXT(inputTexture,tbn*L,mipLevel).rgb;\n#ifdef GAMMA_INPUT\nc=toLinearSpace(c);\n#endif\nresult+=c*NoL;\n}\n}\nresult=result/weight;\nreturn result;\n}\n}\n#endif\n#endif\n";
Pt.IncludesShadersStore.pbrDirectLightingFunctions = "#define CLEARCOATREFLECTANCE90 1.0\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef CLEARCOAT\nvec4 clearCoat;\n#endif\n#ifdef SHEEN\nvec3 sheen;\n#endif\n};\nfloat adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance) {\n#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)\nfloat lightRoughness=lightRadius/lightDistance;\nfloat totalRoughness=saturate(lightRoughness+roughness);\nreturn totalRoughness;\n#else\nreturn roughness;\n#endif\n}\nvec3 computeHemisphericDiffuseLighting(preLightingInfo info,vec3 lightColor,vec3 groundColor) {\nreturn mix(groundColor,lightColor,info.NdotL);\n}\nvec3 computeDiffuseLighting(preLightingInfo info,vec3 lightColor) {\nfloat diffuseTerm=diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness);\nreturn diffuseTerm*info.attenuation*info.NdotL*lightColor;\n}\n#define inline\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\nstrq/=strq.w;\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\nreturn toLinearSpace(textureColor);\n}\n#ifdef SS_TRANSLUCENCY\nvec3 computeDiffuseAndTransmittedLighting(preLightingInfo info,vec3 lightColor,vec3 transmittance) {\nfloat NdotL=absEps(info.NdotLUnclamped);\nfloat wrapNdotL=computeWrappedDiffuseNdotL(NdotL,0.02);\nfloat trAdapt=step(0.,info.NdotLUnclamped);\nvec3 transmittanceNdotL=mix(transmittance*wrapNdotL,vec3(wrapNdotL),trAdapt);\nfloat diffuseTerm=diffuseBRDF_Burley(NdotL,info.NdotV,info.VdotH,info.roughness);\nreturn diffuseTerm*transmittanceNdotL*info.attenuation*lightColor;\n}\n#endif\n#ifdef SPECULARTERM\nvec3 computeSpecularLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat roughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nvec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\n#ifdef BRDF_V_HEIGHT_CORRELATED\nfloat smithVisibility=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG);\n#else\nfloat smithVisibility=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG);\n#endif\nvec3 specTerm=fresnel*distribution*smithVisibility;\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n#ifdef ANISOTROPIC\nvec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat TdotH=dot(T,info.H);\nfloat BdotH=dot(B,info.H);\nfloat TdotV=dot(T,V);\nfloat BdotV=dot(B,V);\nfloat TdotL=dot(T,info.L);\nfloat BdotL=dot(B,info.L);\nfloat alphaG=convertRoughnessToAverageSlope(info.roughness);\nvec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy);\nalphaTB=max(alphaTB,square(geometricRoughnessFactor));\nvec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);\nfloat distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);\nfloat smithVisibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);\nvec3 specTerm=fresnel*distribution*smithVisibility;\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n#ifdef CLEARCOAT\nvec4 computeClearCoatLighting(preLightingInfo info,vec3 Ncc,float geometricRoughnessFactor,float clearCoatIntensity,vec3 lightColor) {\nfloat NccdotL=saturateEps(dot(Ncc,info.L));\nfloat NccdotH=saturateEps(dot(Ncc,info.H));\nfloat clearCoatRoughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(clearCoatRoughness);\nfloat fresnel=fresnelSchlickGGX(info.VdotH,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);\nfresnel*=clearCoatIntensity;\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG);\nfloat kelemenVisibility=visibility_Kelemen(info.VdotH);\nfloat clearCoatTerm=fresnel*distribution*kelemenVisibility;\nreturn vec4(\nclearCoatTerm*info.attenuation*NccdotL*lightColor,\n1.0-fresnel\n);\n}\nvec3 computeClearCoatLightingAbsorption(float NdotVRefract,vec3 L,vec3 Ncc,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\nvec3 LRefract=-refract(L,Ncc,vClearCoatRefractionParams.y);\nfloat NdotLRefract=saturateEps(dot(Ncc,LRefract));\nvec3 absorption=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);\nreturn absorption;\n}\n#endif\n#ifdef SHEEN\nvec3 computeSheenLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat roughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nfloat fresnel=1.;\nfloat distribution=normalDistributionFunction_CharlieSheen(NdotH,alphaG);\n/*#ifdef SHEEN_SOFTER\nfloat visibility=visibility_CharlieSheen(info.NdotL,info.NdotV,alphaG);\n#else */\nfloat visibility=visibility_Ashikhmin(info.NdotL,info.NdotV);\n/* #endif */\nfloat sheenTerm=fresnel*distribution*visibility;\nreturn sheenTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n";
Pt.IncludesShadersStore.pbrIBLFunctions = "#if defined(REFLECTION) || defined(SS_REFRACTION)\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float microsurfaceAverageSlope) {\nfloat microsurfaceAverageSlopeTexels=cubeMapDimensionPixels*microsurfaceAverageSlope;\nfloat lod=log2(microsurfaceAverageSlopeTexels);\nreturn lod;\n}\nfloat getLinearLodFromRoughness(float cubeMapDimensionPixels,float roughness) {\nfloat lod=log2(cubeMapDimensionPixels)*roughness;\nreturn lod;\n}\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION)\nfloat environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {\nfloat temp=NdotVUnclamped+ambientOcclusion;\nreturn saturate(square(temp)-1.0+ambientOcclusion);\n}\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION)\nfloat environmentHorizonOcclusion(vec3 view,vec3 normal,vec3 geometricNormal) {\nvec3 reflection=reflect(view,normal);\nfloat temp=saturate(1.0+1.1*dot(reflection,geometricNormal));\nreturn square(temp);\n}\n#endif\n#if defined(LODINREFLECTIONALPHA) || defined(SS_LODINREFRACTIONALPHA)\n#define UNPACK_LOD(x) (1.0-x)*255.0\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {\nfloat microsurfaceAverageSlope=alphaG;\nmicrosurfaceAverageSlope*=sqrt(abs(NdotV));\nreturn getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);\n}\n#endif\n";
Pt.IncludesShadersStore.pbrBlockAlbedoOpacity = "struct albedoOpacityOutParams\n{\nvec3 surfaceAlbedo;\nfloat alpha;\n};\n#define pbr_inline\nvoid albedoOpacityBlock(\nin vec4 vAlbedoColor,\n#ifdef ALBEDO\nin vec4 albedoTexture,\nin vec2 albedoInfos,\n#endif\n#ifdef OPACITY\nin vec4 opacityMap,\nin vec2 vOpacityInfos,\n#endif\n#ifdef DETAIL\nin vec4 detailColor,\nin vec4 vDetailInfos,\n#endif\nout albedoOpacityOutParams outParams\n)\n{\nvec3 surfaceAlbedo=vAlbedoColor.rgb;\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\n#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)\nalpha*=albedoTexture.a;\n#endif\n#ifdef GAMMAALBEDO\nsurfaceAlbedo*=toLinearSpace(albedoTexture.rgb);\n#else\nsurfaceAlbedo*=albedoTexture.rgb;\n#endif\nsurfaceAlbedo*=albedoInfos.y;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nsurfaceAlbedo*=vColor.rgb;\n#endif\n#ifdef DETAIL\nfloat detailAlbedo=2.0*mix(0.5,detailColor.r,vDetailInfos.y);\nsurfaceAlbedo.rgb=surfaceAlbedo.rgb*detailAlbedo*detailAlbedo; \n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALBEDO\n#ifdef OPACITY\n#ifdef OPACITYRGB\nalpha=getLuminance(opacityMap.rgb);\n#else\nalpha*=opacityMap.a;\n#endif\nalpha*=vOpacityInfos.y;\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#if !defined(SS_LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)\n#ifdef ALPHATEST\nif (alpha 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, n, r;
e && (null === (t = this._texture) || void 0 === t || t.dispose(),
null === (i = this._textureRoughness) || void 0 === i || i.dispose(),
null === (n = this._bumpTexture) || void 0 === n || n.dispose(),
null === (r = this._tintTexture) || void 0 === r || r.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,
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isEnabled", void 0),
k([Ce()], t.prototype, "intensity", void 0),
k([Ce()], t.prototype, "roughness", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "indexOfRefraction", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "texture", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRoughnessFromMainTexture", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "textureRoughness", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "remapF0OnInterfaceChange", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "bumpTexture", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isTintEnabled", void 0),
k([Me()], t.prototype, "tintColor", void 0),
k([Ce()], t.prototype, "tintColorAtDistance", void 0),
k([Ce()], t.prototype, "tintThickness", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "tintTexture", void 0),
t
}(Rs)
, qd = 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.MAINUV1 = !1,
t
}
return U(t, e),
t
}(Si)
, Zd = function(e) {
function t(t, i) {
void 0 === i && (i = !0);
var n = e.call(this, t, "PBRAnisotropic", 110, new qd, i) || this;
return n._isEnabled = !1,
n.isEnabled = !1,
n.intensity = 1,
n.direction = new A(1,0),
n._texture = null,
n.texture = null,
n._internalMarkAllSubMeshesAsTexturesDirty = t._dirtyCallbacks[a.MATERIAL_TextureDirtyFlag],
n
}
return U(t, e),
t.prototype._markAllSubMeshesAsTexturesDirty = function() {
this._enable(this._isEnabled),
this._internalMarkAllSubMeshesAsTexturesDirty()
}
,
t.prototype.isReadyForSubMesh = function(e, t) {
return !this._isEnabled || !(e._areTexturesDirty && t.texturesEnabled && this._texture && vs.AnisotropicTextureEnabled && !this._texture.isReadyOrNotBlocking())
}
,
t.prototype.prepareDefines = function(e, t, i) {
this._isEnabled ? (e.ANISOTROPIC = this._isEnabled,
this._isEnabled && !i.isVerticesDataPresent(Bi.TangentKind) && (e._needUVs = !0,
e.MAINUV1 = !0),
e._areTexturesDirty && t.texturesEnabled && (this._texture && vs.AnisotropicTextureEnabled ? Mr.PrepareDefinesForMergedUV(this._texture, e, "ANISOTROPIC_TEXTURE") : e.ANISOTROPIC_TEXTURE = !1)) : (e.ANISOTROPIC = !1,
e.ANISOTROPIC_TEXTURE = !1)
}
,
t.prototype.bindForSubMesh = function(e, t) {
if (this._isEnabled) {
var i = this._material.isFrozen;
e.useUbo && i && e.isSync || (this._texture && vs.AnisotropicTextureEnabled && (e.updateFloat2("vAnisotropyInfos", this._texture.coordinatesIndex, this._texture.level),
Mr.BindTextureMatrix(this._texture, e, "anisotropy")),
e.updateFloat3("vAnisotropy", this.direction.x, this.direction.y, this.intensity)),
t.texturesEnabled && this._texture && vs.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"
}]
}
}
,
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isEnabled", void 0),
k([Ce()], t.prototype, "intensity", void 0),
k([Oe()], t.prototype, "direction", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "texture", void 0),
t
}(Rs)
, Jd = 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 U(t, e),
t
}(Si)
, $d = function(e) {
function t(t, i) {
void 0 === i && (i = !0);
var n = e.call(this, t, "Sheen", 120, new Jd, i) || this;
return n._isEnabled = !1,
n.isEnabled = !1,
n._linkSheenWithAlbedo = !1,
n.linkSheenWithAlbedo = !1,
n.intensity = 1,
n.color = D.White(),
n._texture = null,
n.texture = null,
n._useRoughnessFromMainTexture = !0,
n.useRoughnessFromMainTexture = !0,
n._roughness = null,
n.roughness = null,
n._textureRoughness = null,
n.textureRoughness = null,
n._albedoScaling = !1,
n.albedoScaling = !1,
n._internalMarkAllSubMeshesAsTexturesDirty = t._dirtyCallbacks[a.MATERIAL_TextureDirtyFlag],
n
}
return U(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 && vs.SheenTextureEnabled && !this._texture.isReadyOrNotBlocking())
return !1;
if (this._textureRoughness && vs.SheenTextureEnabled && !this._textureRoughness.isReadyOrNotBlocking())
return !1
}
return !0
}
,
t.prototype.prepareDefines = 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 && vs.SheenTextureEnabled ? (Mr.PrepareDefinesForMergedUV(this._texture, e, "SHEEN_TEXTURE"),
e.SHEEN_GAMMATEXTURE = this._texture.gammaSpace) : e.SHEEN_TEXTURE = !1,
this._textureRoughness && vs.SheenTextureEnabled ? Mr.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)
}
,
t.prototype.bindForSubMesh = function(e, t, i, n) {
var r, o, a, s, l, c, u, h;
if (this._isEnabled) {
var d = n.materialDefines
, p = this._material.isFrozen
, f = d.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL;
e.useUbo && p && e.isSync || (f && vs.SheenTextureEnabled ? (e.updateFloat4("vSheenInfos", this._texture.coordinatesIndex, this._texture.level, -1, -1),
Mr.BindTextureMatrix(this._texture, e, "sheen")) : (this._texture || this._textureRoughness) && vs.SheenTextureEnabled && (e.updateFloat4("vSheenInfos", null !== (o = null === (r = this._texture) || void 0 === r ? void 0 : r.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 && Mr.BindTextureMatrix(this._texture, e, "sheen"),
!this._textureRoughness || f || d.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE || Mr.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 && vs.SheenTextureEnabled && e.setTexture("sheenSampler", this._texture),
this._textureRoughness && !f && !d.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE && vs.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"
}]
}
}
,
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isEnabled", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "linkSheenWithAlbedo", void 0),
k([Ce()], t.prototype, "intensity", void 0),
k([Me()], t.prototype, "color", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "texture", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRoughnessFromMainTexture", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "roughness", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "textureRoughness", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "albedoScaling", void 0),
t
}(Rs)
, ep = 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 U(t, e),
t
}(Si)
, tp = function(e) {
function t(t, i) {
void 0 === i && (i = !0);
var n = e.call(this, t, "PBRSubSurface", 130, new ep, i) || this;
return n._isRefractionEnabled = !1,
n.isRefractionEnabled = !1,
n._isTranslucencyEnabled = !1,
n.isTranslucencyEnabled = !1,
n._isScatteringEnabled = !1,
n.isScatteringEnabled = !1,
n._scatteringDiffusionProfileIndex = 0,
n.refractionIntensity = 1,
n.translucencyIntensity = 1,
n.useAlbedoToTintRefraction = !1,
n.useAlbedoToTintTranslucency = !1,
n._thicknessTexture = null,
n.thicknessTexture = null,
n._refractionTexture = null,
n.refractionTexture = null,
n._indexOfRefraction = 1.5,
n.indexOfRefraction = 1.5,
n._volumeIndexOfRefraction = -1,
n._invertRefractionY = !1,
n.invertRefractionY = !1,
n._linkRefractionWithTransparency = !1,
n.linkRefractionWithTransparency = !1,
n.minimumThickness = 0,
n.maximumThickness = 1,
n.useThicknessAsDepth = !1,
n.tintColor = D.White(),
n.tintColorAtDistance = 1,
n.diffusionDistance = D.White(),
n._useMaskFromThicknessTexture = !1,
n.useMaskFromThicknessTexture = !1,
n._refractionIntensityTexture = null,
n.refractionIntensityTexture = null,
n._translucencyIntensityTexture = null,
n.translucencyIntensityTexture = null,
n._useGltfStyleTextures = !1,
n.useGltfStyleTextures = !1,
n._scene = t.getScene(),
n.registerForExtraEvents = !0,
n._internalMarkAllSubMeshesAsTexturesDirty = t._dirtyCallbacks[a.MATERIAL_TextureDirtyFlag],
n._internalMarkScenePrePassDirty = t._dirtyCallbacks[a.MATERIAL_PrePassDirtyFlag],
n
}
return U(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 && vs.ThicknessTextureEnabled && !this._thicknessTexture.isReadyOrNotBlocking())
return !1;
var i = this._getRefractionTexture(t);
if (i && vs.RefractionTextureEnabled && !i.isReadyOrNotBlocking())
return !1
}
return !0
}
,
t.prototype.prepareDefines = function(e, t) {
if (!this._isRefractionEnabled && !this._isTranslucencyEnabled && !this._isScatteringEnabled)
return e.SUBSURFACE = !1,
e.SS_TRANSLUCENCY = !1,
e.SS_SCATTERING = !1,
void (e.SS_REFRACTION = !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
, n = !!this._thicknessTexture && !!this._translucencyIntensityTexture && this._translucencyIntensityTexture.checkTransformsAreIdentical(this._thicknessTexture) && this._translucencyIntensityTexture._texture === this._thicknessTexture._texture
, r = (i || !this._refractionIntensityTexture) && (n || !this._translucencyIntensityTexture);
if (e._areTexturesDirty && t.texturesEnabled && (this._thicknessTexture && vs.ThicknessTextureEnabled && Mr.PrepareDefinesForMergedUV(this._thicknessTexture, e, "SS_THICKNESSANDMASK_TEXTURE"),
this._refractionIntensityTexture && vs.RefractionIntensityTextureEnabled && !r && Mr.PrepareDefinesForMergedUV(this._refractionIntensityTexture, e, "SS_REFRACTIONINTENSITY_TEXTURE"),
this._translucencyIntensityTexture && vs.TranslucencyIntensityTextureEnabled && !r && Mr.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) && r,
e.SS_USE_GLTF_TEXTURES = this._useGltfStyleTextures,
e.SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE = (this._useMaskFromThicknessTexture || !!this._refractionIntensityTexture) && r,
e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE = (this._useMaskFromThicknessTexture || !!this._translucencyIntensityTexture) && r,
this._isRefractionEnabled && t.texturesEnabled) {
var o = this._getRefractionTexture(t);
o && vs.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 = 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, n) {
if (this._isRefractionEnabled || this._isTranslucencyEnabled || this._isScatteringEnabled) {
n.getRenderingMesh().getWorldMatrix().decompose(I.Vector3[0]);
var r = Math.max(Math.abs(I.Vector3[0].x), Math.abs(I.Vector3[0].y), Math.abs(I.Vector3[0].z));
e.updateFloat2("vThicknessParam", this.minimumThickness * r, (this.maximumThickness - this.minimumThickness) * r)
}
}
,
t.prototype.bindForSubMesh = function(e, t, i, n) {
if (this._isRefractionEnabled || this._isTranslucencyEnabled || this._isScatteringEnabled) {
var r = n.materialDefines
, o = this._material.isFrozen
, a = this._material.realTimeFiltering
, s = r.LODBASEDMICROSFURACE
, l = this._getRefractionTexture(t);
if (!e.useUbo || !o || !e.isSync) {
if (this._thicknessTexture && vs.ThicknessTextureEnabled && (e.updateFloat2("vThicknessInfos", this._thicknessTexture.coordinatesIndex, this._thicknessTexture.level),
Mr.BindTextureMatrix(this._thicknessTexture, e, "thickness")),
this._refractionIntensityTexture && vs.RefractionIntensityTextureEnabled && r.SS_REFRACTIONINTENSITY_TEXTURE && (e.updateFloat2("vRefractionIntensityInfos", this._refractionIntensityTexture.coordinatesIndex, this._refractionIntensityTexture.level),
Mr.BindTextureMatrix(this._refractionIntensityTexture, e, "refractionIntensity")),
this._translucencyIntensityTexture && vs.TranslucencyIntensityTextureEnabled && r.SS_TRANSLUCENCYINTENSITY_TEXTURE && (e.updateFloat2("vTranslucencyIntensityInfos", this._translucencyIntensityTexture.coordinatesIndex, this._translucencyIntensityTexture.level),
Mr.BindTextureMatrix(this._translucencyIntensityTexture, e, "translucencyIntensity")),
l && vs.RefractionTextureEnabled) {
e.updateMatrix("refractionMatrix", l.getReflectionTextureMatrix());
var c = 1;
l.isCube || l.depth && (c = l.depth);
var u = l.getSize().width
, h = this.volumeIndexOfRefraction;
if (e.updateFloat4("vRefractionInfos", l.level, 1 / h, c, this._invertRefractionY ? -1 : 1),
e.updateFloat4("vRefractionMicrosurfaceInfos", u, l.lodGenerationScale, l.lodGenerationOffset, 1 / this.indexOfRefraction),
a && e.updateFloat2("vRefractionFilteringInfo", u, d.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 && vs.ThicknessTextureEnabled && e.setTexture("thicknessSampler", this._thicknessTexture),
this._refractionIntensityTexture && vs.RefractionIntensityTextureEnabled && r.SS_REFRACTIONINTENSITY_TEXTURE && e.setTexture("refractionIntensitySampler", this._refractionIntensityTexture),
this._translucencyIntensityTexture && vs.TranslucencyIntensityTextureEnabled && r.SS_TRANSLUCENCYINTENSITY_TEXTURE && e.setTexture("translucencyIntensitySampler", this._translucencyIntensityTexture),
l && vs.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) {
vs.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 !!(vs.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"
}]
}
}
,
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isRefractionEnabled", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isTranslucencyEnabled", void 0),
k([Ce(), Re("_markScenePrePassDirty")], t.prototype, "isScatteringEnabled", void 0),
k([Ce()], t.prototype, "_scatteringDiffusionProfileIndex", void 0),
k([Ce()], t.prototype, "refractionIntensity", void 0),
k([Ce()], t.prototype, "translucencyIntensity", void 0),
k([Ce()], t.prototype, "useAlbedoToTintRefraction", void 0),
k([Ce()], t.prototype, "useAlbedoToTintTranslucency", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "thicknessTexture", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "refractionTexture", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "indexOfRefraction", void 0),
k([Ce()], t.prototype, "_volumeIndexOfRefraction", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "volumeIndexOfRefraction", null),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertRefractionY", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "linkRefractionWithTransparency", void 0),
k([Ce()], t.prototype, "minimumThickness", void 0),
k([Ce()], t.prototype, "maximumThickness", void 0),
k([Ce()], t.prototype, "useThicknessAsDepth", void 0),
k([Me()], t.prototype, "tintColor", void 0),
k([Ce()], t.prototype, "tintColorAtDistance", void 0),
k([Me()], t.prototype, "diffusionDistance", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useMaskFromThicknessTexture", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "refractionIntensityTexture", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "translucencyIntensityTexture", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useGltfStyleTextures", void 0),
t
}(Rs)
, ip = {
effect: null,
subMesh: null
}
, np = 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.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.FORCENORMALFORWARD = !1,
i.SPECULARAA = !1,
i.UNLIT = !1,
i.DEBUGMODE = 0,
i.rebuild(),
i
}
return U(t, e),
t.prototype.reset = function() {
e.prototype.reset.call(this),
this.ALPHATESTVALUE = "0.5",
this.PBR = !0,
this.NORMALXYSCALE = !0
}
,
t
}(Si)
, rp = function(e) {
function t(i, n) {
var r = e.call(this, i, n) || this;
return r._directIntensity = 1,
r._emissiveIntensity = 1,
r._environmentIntensity = 1,
r._specularIntensity = 1,
r._lightingInfos = new R(r._directIntensity,r._emissiveIntensity,r._environmentIntensity,r._specularIntensity),
r._disableBumpMap = !1,
r._albedoTexture = null,
r._ambientTexture = null,
r._ambientTextureStrength = 1,
r._ambientTextureImpactOnAnalyticalLights = t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,
r._opacityTexture = null,
r._reflectionTexture = null,
r._emissiveTexture = null,
r._reflectivityTexture = null,
r._metallicTexture = null,
r._metallic = null,
r._roughness = null,
r._metallicF0Factor = 1,
r._metallicReflectanceColor = D.White(),
r._useOnlyMetallicFromMetallicReflectanceTexture = !1,
r._metallicReflectanceTexture = null,
r._reflectanceTexture = null,
r._microSurfaceTexture = null,
r._bumpTexture = null,
r._lightmapTexture = null,
r._ambientColor = new D(0,0,0),
r._albedoColor = new D(1,1,1),
r._reflectivityColor = new D(1,1,1),
r._reflectionColor = new D(1,1,1),
r._emissiveColor = new D(0,0,0),
r._microSurface = .9,
r._useLightmapAsShadowmap = !1,
r._useHorizonOcclusion = !0,
r._useRadianceOcclusion = !0,
r._useAlphaFromAlbedoTexture = !1,
r._useSpecularOverAlpha = !0,
r._useMicroSurfaceFromReflectivityMapAlpha = !1,
r._useRoughnessFromMetallicTextureAlpha = !0,
r._useRoughnessFromMetallicTextureGreen = !1,
r._useMetallnessFromMetallicTextureBlue = !1,
r._useAmbientOcclusionFromMetallicTextureRed = !1,
r._useAmbientInGrayScale = !1,
r._useAutoMicroSurfaceFromReflectivityMap = !1,
r._lightFalloff = t.LIGHTFALLOFF_PHYSICAL,
r._useRadianceOverAlpha = !0,
r._useObjectSpaceNormalMap = !1,
r._useParallax = !1,
r._useParallaxOcclusion = !1,
r._parallaxScaleBias = .05,
r._disableLighting = !1,
r._maxSimultaneousLights = 4,
r._invertNormalMapX = !1,
r._invertNormalMapY = !1,
r._twoSidedLighting = !1,
r._alphaCutOff = .4,
r._forceAlphaTest = !1,
r._useAlphaFresnel = !1,
r._useLinearAlphaFresnel = !1,
r._environmentBRDFTexture = null,
r._forceIrradianceInFragment = !1,
r._realTimeFiltering = !1,
r._realTimeFilteringQuality = a.TEXTURE_FILTERING_QUALITY_LOW,
r._forceNormalForward = !1,
r._enableSpecularAntiAliasing = !1,
r._imageProcessingObserver = null,
r._renderTargets = new bi(16),
r._globalAmbientColor = new D(0,0,0),
r._useLogarithmicDepth = !1,
r._unlit = !1,
r._debugMode = 0,
r.debugMode = 0,
r._debugLimit = -1,
r._debugFactor = 1,
r._cacheHasRenderTargetTextures = !1,
r.brdf = new Yd(r),
r.clearCoat = new Qd(r),
r.anisotropy = new Zd(r),
r.sheen = new $d(r),
r.subSurface = new tp(r),
r.detailMap = new Ps(r),
r._attachImageProcessingConfiguration(null),
r.getRenderTargetTextures = function() {
return r._renderTargets.reset(),
vs.ReflectionTextureEnabled && r._reflectionTexture && r._reflectionTexture.isRenderTarget && r._renderTargets.push(r._reflectionTexture),
r._eventInfo.renderTargets = r._renderTargets,
r._callbackPluginEventFillRenderTargetTextures(r._eventInfo),
r._renderTargets
}
,
r._environmentBRDFTexture = Hd(r.getScene()),
r.prePassConfiguration = new ms,
r
}
return U(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 !!(vs.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) {
if (this._uniformBufferLayoutBuilt || this.buildUniformLayout(),
t.effect && this.isFrozen && t.effect._wasPreviouslyReady)
return !0;
t.materialDefines || (this._callbackPluginEventGeneric(Ar.GetDefineNames, this._eventInfo),
t.materialDefines = new np(this._eventInfo.defineNames));
var n = t.materialDefines;
if (this._isReadyForSubMesh(t))
return !0;
var r = this.getScene()
, o = r.getEngine();
if (n._areTexturesDirty && (this._eventInfo.hasRenderTargetTextures = !1,
this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),
this._cacheHasRenderTargetTextures = this._eventInfo.hasRenderTargetTextures,
r.texturesEnabled)) {
if (this._albedoTexture && vs.DiffuseTextureEnabled && !this._albedoTexture.isReadyOrNotBlocking())
return !1;
if (this._ambientTexture && vs.AmbientTextureEnabled && !this._ambientTexture.isReadyOrNotBlocking())
return !1;
if (this._opacityTexture && vs.OpacityTextureEnabled && !this._opacityTexture.isReadyOrNotBlocking())
return !1;
var a = this._getReflectionTexture();
if (a && vs.ReflectionTextureEnabled) {
if (!a.isReadyOrNotBlocking())
return !1;
if (a.irradianceTexture && !a.irradianceTexture.isReadyOrNotBlocking())
return !1
}
if (this._lightmapTexture && vs.LightmapTextureEnabled && !this._lightmapTexture.isReadyOrNotBlocking())
return !1;
if (this._emissiveTexture && vs.EmissiveTextureEnabled && !this._emissiveTexture.isReadyOrNotBlocking())
return !1;
if (vs.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 (o.getCaps().standardDerivatives && this._bumpTexture && vs.BumpTextureEnabled && !this._disableBumpMap && !this._bumpTexture.isReady())
return !1;
if (this._environmentBRDFTexture && vs.ReflectionTextureEnabled && !this._environmentBRDFTexture.isReady())
return !1
}
if (this._eventInfo.isReadyForSubMesh = !0,
this._eventInfo.defines = n,
this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),
!this._eventInfo.isReadyForSubMesh)
return !1;
if (n._areImageProcessingDirty && this._imageProcessingConfiguration && !this._imageProcessingConfiguration.isReady())
return !1;
o.getCaps().standardDerivatives || e.isVerticesDataPresent(Bi.NormalKind) || (e.createNormals(!0),
K.Warn("PBRMaterial: Normals have been created for the mesh: " + e.name));
var s = t.effect
, l = n._areLightsDisposed
, c = this._prepareEffect(e, n, this.onCompiled, this.onError, i, null, t.getRenderingMesh().hasThinInstances);
if (c)
if (this._onEffectCreatedObservable && (ip.effect = c,
ip.subMesh = t,
this._onEffectCreatedObservable.notifyObservers(ip)),
this.allowShaderHotSwapping && s && !c.isReady()) {
if (c = s,
n.markAsUnprocessed(),
l)
return n._areLightsDisposed = !0,
!1
} else
r.resetCachedMaterial(),
t.setEffect(c, n, this._materialContext);
return !(!t.effect || !t.effect.isReady() || (n._renderId = r.getRenderId(),
t.effect._wasPreviouslyReady = !0,
0))
}
,
t.prototype.isMetallicWorkflow = function() {
return !(null == this._metallic && null == this._roughness && !this._metallicTexture)
}
,
t.prototype._prepareEffect = function(e, t, i, n, r, o, s) {
if (void 0 === i && (i = null),
void 0 === n && (n = null),
void 0 === r && (r = null),
void 0 === o && (o = null),
this._prepareDefines(e, t, r, o, s),
!t.isDirty)
return null;
t.markAsProcessed();
var l = this.getScene().getEngine()
, c = new ys
, 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 = Mr.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 = [Bi.PositionKind];
t.NORMAL && h.push(Bi.NormalKind),
t.TANGENT && h.push(Bi.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(Bi.ColorKind),
Mr.PrepareAttributesForBones(h, e, t, c),
Mr.PrepareAttributesForInstances(h, t),
Mr.PrepareAttributesForMorphTargets(h, e, t),
Mr.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", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "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"];
this._eventInfo.fallbacks = c,
this._eventInfo.fallbackRank = u,
this._eventInfo.defines = t,
this._eventInfo.uniforms = f,
this._eventInfo.samplers = _,
this._eventInfo.uniformBuffersNames = m,
this._eventInfo.customCode = void 0,
this._callbackPluginEventGeneric(Ar.PrepareEffect, this._eventInfo),
ms.AddUniforms(f),
ms.AddSamplers(_),
Ri && (Ri.PrepareUniforms(f, t),
Ri.PrepareSamplers(_, t)),
Mr.PrepareUniformsAndSamplersList({
uniformsNames: f,
uniformBuffersNames: m,
samplers: _,
defines: t,
maxSimultaneousLights: this._maxSimultaneousLights
});
var g = {};
this.customShaderNameResolve && (p = this.customShaderNameResolve(p, f, m, _, t, h, g));
var v = t.toString();
return l.createEffect(p, {
attributes: h,
uniformsNames: f,
uniformBuffersNames: m,
samplers: _,
defines: v,
fallbacks: c,
onCompiled: i,
onError: n,
indexParameters: {
maxSimultaneousLights: this._maxSimultaneousLights,
maxSimultaneousMorphTargets: t.NUM_MORPH_INFLUENCERS
},
processFinalCode: g.processFinalCode,
processCodeAfterIncludes: this._eventInfo.customCode,
multiTarget: t.PREPASS
}, l)
}
,
t.prototype._prepareDefines = function(e, i, n, r, o) {
var s;
void 0 === n && (n = null),
void 0 === r && (r = null),
void 0 === o && (o = !1);
var l = this.getScene()
, c = l.getEngine();
Mr.PrepareDefinesForLights(l, e, i, !0, this._maxSimultaneousLights, this._disableLighting),
i._needNormals = !0,
Mr.PrepareDefinesForMultiview(l, i);
var u = this.needAlphaBlendingForMesh(e) && this.getScene().useOrderIndependentTransparency;
if (Mr.PrepareDefinesForPrePass(l, i, this.canRenderToMRT && !u),
Mr.PrepareDefinesForOIT(l, i, u),
i.METALLICWORKFLOW = this.isMetallicWorkflow(),
i._areTexturesDirty) {
if (i._needUVs = !1,
l.texturesEnabled) {
l.getEngine().getCaps().textureLOD && (i.LODBASEDMICROSFURACE = !0),
this._albedoTexture && vs.DiffuseTextureEnabled ? (Mr.PrepareDefinesForMergedUV(this._albedoTexture, i, "ALBEDO"),
i.GAMMAALBEDO = this._albedoTexture.gammaSpace) : i.ALBEDO = !1,
this._ambientTexture && vs.AmbientTextureEnabled ? (Mr.PrepareDefinesForMergedUV(this._ambientTexture, i, "AMBIENT"),
i.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale) : i.AMBIENT = !1,
this._opacityTexture && vs.OpacityTextureEnabled ? (Mr.PrepareDefinesForMergedUV(this._opacityTexture, i, "OPACITY"),
i.OPACITYRGB = this._opacityTexture.getAlphaFromRGB) : i.OPACITY = !1;
var h = this._getReflectionTexture();
if (h && vs.ReflectionTextureEnabled) {
switch (i.REFLECTION = !0,
i.GAMMAREFLECTION = h.gammaSpace,
i.RGBDREFLECTION = h.isRGBD,
i.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !h.invertZ : h.invertZ,
i.LODINREFLECTIONALPHA = h.lodLevelInAlpha,
i.LINEARSPECULARREFLECTION = h.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,
h.coordinatesMode === io.INVCUBIC_MODE && (i.INVERTCUBICMAP = !0),
i.REFLECTIONMAP_3D = h.isCube,
i.REFLECTIONMAP_CUBIC = !1,
i.REFLECTIONMAP_EXPLICIT = !1,
i.REFLECTIONMAP_PLANAR = !1,
i.REFLECTIONMAP_PROJECTION = !1,
i.REFLECTIONMAP_SKYBOX = !1,
i.REFLECTIONMAP_SPHERICAL = !1,
i.REFLECTIONMAP_EQUIRECTANGULAR = !1,
i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1,
i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1,
h.coordinatesMode) {
case io.EXPLICIT_MODE:
i.REFLECTIONMAP_EXPLICIT = !0;
break;
case io.PLANAR_MODE:
i.REFLECTIONMAP_PLANAR = !0;
break;
case io.PROJECTION_MODE:
i.REFLECTIONMAP_PROJECTION = !0;
break;
case io.SKYBOX_MODE:
i.REFLECTIONMAP_SKYBOX = !0;
break;
case io.SPHERICAL_MODE:
i.REFLECTIONMAP_SPHERICAL = !0;
break;
case io.EQUIRECTANGULAR_MODE:
i.REFLECTIONMAP_EQUIRECTANGULAR = !0;
break;
case io.FIXED_EQUIRECTANGULAR_MODE:
i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !0;
break;
case io.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !0;
break;
case io.CUBIC_MODE:
case io.INVCUBIC_MODE:
default:
i.REFLECTIONMAP_CUBIC = !0,
i.USE_LOCAL_REFLECTIONMAP_CUBIC = !!h.boundingBoxSize
}
h.coordinatesMode !== io.SKYBOX_MODE && (h.irradianceTexture ? (i.USEIRRADIANCEMAP = !0,
i.USESPHERICALFROMREFLECTIONMAP = !1) : h.isCube && (i.USESPHERICALFROMREFLECTIONMAP = !0,
i.USEIRRADIANCEMAP = !1,
this._forceIrradianceInFragment || this.realTimeFiltering || l.getEngine().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 && vs.LightmapTextureEnabled ? (Mr.PrepareDefinesForMergedUV(this._lightmapTexture, i, "LIGHTMAP"),
i.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap,
i.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace,
i.RGBDLIGHTMAP = this._lightmapTexture.isRGBD) : i.LIGHTMAP = !1,
this._emissiveTexture && vs.EmissiveTextureEnabled ? (Mr.PrepareDefinesForMergedUV(this._emissiveTexture, i, "EMISSIVE"),
i.GAMMAEMISSIVE = this._emissiveTexture.gammaSpace) : i.EMISSIVE = !1,
vs.SpecularTextureEnabled) {
if (this._metallicTexture ? (Mr.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 ? (Mr.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 d = 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 && !d,
this._metallicReflectanceTexture ? (Mr.PrepareDefinesForMergedUV(this._metallicReflectanceTexture, i, "METALLIC_REFLECTANCE"),
i.METALLIC_REFLECTANCE_GAMMA = this._metallicReflectanceTexture.gammaSpace) : i.METALLIC_REFLECTANCE = !1,
this._reflectanceTexture && !d && (!this._metallicReflectanceTexture || this._metallicReflectanceTexture && this._useOnlyMetallicFromMetallicReflectanceTexture) ? (Mr.PrepareDefinesForMergedUV(this._reflectanceTexture, i, "REFLECTANCE"),
i.REFLECTANCE_GAMMA = this._reflectanceTexture.gammaSpace) : i.REFLECTANCE = !1
} else
i.METALLIC_REFLECTANCE = !1,
i.REFLECTANCE = !1;
this._microSurfaceTexture ? Mr.PrepareDefinesForMergedUV(this._microSurfaceTexture, i, "MICROSURFACEMAP") : i.MICROSURFACEMAP = !1
} else
i.REFLECTIVITY = !1,
i.MICROSURFACEMAP = !1;
l.getEngine().getCaps().standardDerivatives && this._bumpTexture && vs.BumpTextureEnabled && !this._disableBumpMap ? (Mr.PrepareDefinesForMergedUV(this._bumpTexture, i, "BUMP"),
this._useParallax && this._albedoTexture && vs.DiffuseTextureEnabled ? (i.PARALLAX = !0,
i.PARALLAXOCCLUSION = !!this._useParallaxOcclusion) : i.PARALLAX = !1,
i.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap) : i.BUMP = !1,
this._environmentBRDFTexture && vs.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 = l.getEngine().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 && (Mr.PrepareDefinesForMisc(e, l, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(e) || this._forceAlphaTest, i),
i.UNLIT = this._unlit || (this.pointsCloud || this.wireframe) && !e.isVerticesDataPresent(Bi.NormalKind),
i.DEBUGMODE = this._debugMode),
this._eventInfo.defines = i,
this._eventInfo.mesh = e,
this._callbackPluginEventPrepareDefines(this._eventInfo),
Mr.PrepareDefinesForFrameBoundValues(l, c, i, !!n, r, o),
Mr.PrepareDefinesForAttributes(e, i, !0, !0, !0, this._transparencyMode !== t.PBRMATERIAL_OPAQUE)
}
,
t.prototype.forceCompilation = function(e, t, i) {
var n = this
, r = V({
clipPlane: !1,
useInstances: !1
}, i);
this._uniformBufferLayoutBuilt || this.buildUniformLayout(),
this._callbackPluginEventGeneric(Ar.GetDefineNames, this._eventInfo);
var o = new np(this._eventInfo.defineNames)
, a = this._prepareEffect(e, o, void 0, void 0, r.useInstances, r.clipPlane, e.hasThinInstances);
this._onEffectCreatedObservable && (ip.effect = a,
ip.subMesh = null,
this._onEffectCreatedObservable.notifyObservers(ip)),
a.isReady() ? t && t(this) : a.onCompileObservable.add((function() {
t && t(n)
}
))
}
,
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 n, r, o, a, s = this.getScene(), l = i.materialDefines;
if (l) {
var c = i.effect;
if (c) {
this._activeEffect = c,
t.getMeshUniformBuffer().bindToEffect(c, "Mesh"),
t.transferToEffect(e);
var u = s.getEngine();
this._uniformBuffer.bindToEffect(c, "Material"),
this.prePassConfiguration.bindForSubMesh(this._activeEffect, s, t, e, this.isFrozen),
this._eventInfo.subMesh = i,
this._callbackPluginEventHardBindForSubMesh(this._eventInfo),
l.OBJECTSPACE_NORMALMAP && (e.toNormalMatrix(this._normalMatrix),
this.bindOnlyNormalMatrix(this._normalMatrix));
var h = this._mustRebind(s, c, t.visibility);
Mr.BindBonesParameters(t, this._activeEffect, this.prePassConfiguration);
var p = null
, f = this._uniformBuffer;
if (h) {
if (this.bindViewProjection(c),
p = this._getReflectionTexture(),
!f.useUbo || !this.isFrozen || !f.isSync) {
if (s.texturesEnabled) {
if (this._albedoTexture && vs.DiffuseTextureEnabled && (f.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level),
Mr.BindTextureMatrix(this._albedoTexture, f, "albedo")),
this._ambientTexture && vs.AmbientTextureEnabled && (f.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights),
Mr.BindTextureMatrix(this._ambientTexture, f, "ambient")),
this._opacityTexture && vs.OpacityTextureEnabled && (f.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level),
Mr.BindTextureMatrix(this._opacityTexture, f, "opacity")),
p && vs.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, d.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 && vs.EmissiveTextureEnabled && (f.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level),
Mr.BindTextureMatrix(this._emissiveTexture, f, "emissive")),
this._lightmapTexture && vs.LightmapTextureEnabled && (f.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level),
Mr.BindTextureMatrix(this._lightmapTexture, f, "lightmap")),
vs.SpecularTextureEnabled && (this._metallicTexture ? (f.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength),
Mr.BindTextureMatrix(this._metallicTexture, f, "reflectivity")) : this._reflectivityTexture && (f.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1),
Mr.BindTextureMatrix(this._reflectivityTexture, f, "reflectivity")),
this._metallicReflectanceTexture && (f.updateFloat2("vMetallicReflectanceInfos", this._metallicReflectanceTexture.coordinatesIndex, this._metallicReflectanceTexture.level),
Mr.BindTextureMatrix(this._metallicReflectanceTexture, f, "metallicReflectance")),
this._reflectanceTexture && l.REFLECTANCE && (f.updateFloat2("vReflectanceInfos", this._reflectanceTexture.coordinatesIndex, this._reflectanceTexture.level),
Mr.BindTextureMatrix(this._reflectanceTexture, f, "reflectance")),
this._microSurfaceTexture && (f.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level),
Mr.BindTextureMatrix(this._microSurfaceTexture, f, "microSurfaceSampler"))),
this._bumpTexture && u.getCaps().standardDerivatives && vs.BumpTextureEnabled && !this._disableBumpMap && (f.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias),
Mr.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) {
L.Color3[0].r = void 0 === this._metallic || null === this._metallic ? 1 : this._metallic,
L.Color3[0].g = void 0 === this._roughness || null === this._roughness ? 1 : this._roughness,
f.updateColor4("vReflectivityColor", L.Color3[0], 1);
var y = null !== (r = null === (n = this.subSurface) || void 0 === n ? void 0 : n._indexOfRefraction) && void 0 !== r ? r : 1.5
, b = Math.pow((y - 1) / (y + 1), 2);
this._metallicReflectanceColor.scaleToRef(b * this._metallicF0Factor, L.Color3[0]);
var T = this._metallicF0Factor;
f.updateColor4("vMetallicReflectanceFactors", L.Color3[0], T)
} else
f.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
f.updateColor3("vEmissiveColor", vs.EmissiveTextureEnabled ? this._emissiveColor : D.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 && vs.DiffuseTextureEnabled && f.setTexture("albedoSampler", this._albedoTexture),
this._ambientTexture && vs.AmbientTextureEnabled && f.setTexture("ambientSampler", this._ambientTexture),
this._opacityTexture && vs.OpacityTextureEnabled && f.setTexture("opacitySampler", this._opacityTexture),
p && vs.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 && vs.EmissiveTextureEnabled && f.setTexture("emissiveSampler", this._emissiveTexture),
this._lightmapTexture && vs.LightmapTextureEnabled && f.setTexture("lightmapSampler", this._lightmapTexture),
vs.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 && vs.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),
Mr.BindClipPlane(this._activeEffect, s),
this.bindEyePosition(c)
} else
s.getEngine()._features.needToAlwaysBindUniformBuffers && (this._needToBindSceneUbo = !0);
!h && this.isFrozen || (s.lightsEnabled && !this._disableLighting && Mr.BindLights(s, t, this._activeEffect, l, this._maxSimultaneousLights),
(s.fogEnabled && t.applyFog && s.fogMode !== mn.FOGMODE_NONE || p || t.receiveShadows) && this.bindView(c),
Mr.BindFogParameters(s, t, this._activeEffect, !0),
l.NUM_MORPH_INFLUENCERS && Mr.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),
Mr.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),
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._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) {
var t = this.getScene().enableSubSurfaceForPrePass();
return t && (t.enabled = !0),
!0
}
return !1
}
,
t.prototype.dispose = function(t, i) {
var n, r, o, a, s, l, c, u, h, d, p, f;
i && (this._environmentBRDFTexture && this.getScene().environmentBRDFTexture !== this._environmentBRDFTexture && this._environmentBRDFTexture.dispose(),
null === (n = this._albedoTexture) || void 0 === n || n.dispose(),
null === (r = this._ambientTexture) || void 0 === r || r.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 = Or.MATERIAL_OPAQUE,
t.PBRMATERIAL_ALPHATEST = Or.MATERIAL_ALPHATEST,
t.PBRMATERIAL_ALPHABLEND = Or.MATERIAL_ALPHABLEND,
t.PBRMATERIAL_ALPHATESTANDBLEND = Or.MATERIAL_ALPHATESTANDBLEND,
t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 0,
t.LIGHTFALLOFF_PHYSICAL = 0,
t.LIGHTFALLOFF_GLTF = 1,
t.LIGHTFALLOFF_STANDARD = 2,
k([we()], t.prototype, "_imageProcessingConfiguration", void 0),
k([Re("_markAllSubMeshesAsMiscDirty")], t.prototype, "debugMode", void 0),
k([Ce()], t.prototype, "useLogarithmicDepth", null),
t
}(gs)
, op = function(e) {
function t(i, n) {
var r = e.call(this, i, n) || this;
return r.directIntensity = 1,
r.emissiveIntensity = 1,
r.environmentIntensity = 1,
r.specularIntensity = 1,
r.disableBumpMap = !1,
r.ambientTextureStrength = 1,
r.ambientTextureImpactOnAnalyticalLights = t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,
r.metallicF0Factor = 1,
r.metallicReflectanceColor = D.White(),
r.useOnlyMetallicFromMetallicReflectanceTexture = !1,
r.ambientColor = new D(0,0,0),
r.albedoColor = new D(1,1,1),
r.reflectivityColor = new D(1,1,1),
r.reflectionColor = new D(1,1,1),
r.emissiveColor = new D(0,0,0),
r.microSurface = 1,
r.useLightmapAsShadowmap = !1,
r.useAlphaFromAlbedoTexture = !1,
r.forceAlphaTest = !1,
r.alphaCutOff = .4,
r.useSpecularOverAlpha = !0,
r.useMicroSurfaceFromReflectivityMapAlpha = !1,
r.useRoughnessFromMetallicTextureAlpha = !0,
r.useRoughnessFromMetallicTextureGreen = !1,
r.useMetallnessFromMetallicTextureBlue = !1,
r.useAmbientOcclusionFromMetallicTextureRed = !1,
r.useAmbientInGrayScale = !1,
r.useAutoMicroSurfaceFromReflectivityMap = !1,
r.useRadianceOverAlpha = !0,
r.useObjectSpaceNormalMap = !1,
r.useParallax = !1,
r.useParallaxOcclusion = !1,
r.parallaxScaleBias = .05,
r.disableLighting = !1,
r.forceIrradianceInFragment = !1,
r.maxSimultaneousLights = 4,
r.invertNormalMapX = !1,
r.invertNormalMapY = !1,
r.twoSidedLighting = !1,
r.useAlphaFresnel = !1,
r.useLinearAlphaFresnel = !1,
r.environmentBRDFTexture = null,
r.forceNormalForward = !1,
r.enableSpecularAntiAliasing = !1,
r.useHorizonOcclusion = !0,
r.useRadianceOcclusion = !0,
r.unlit = !1,
r._environmentBRDFTexture = Hd(r.getScene()),
r
}
return U(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 === rp.LIGHTFALLOFF_PHYSICAL
},
set: function(e) {
e !== this.usePhysicalLightFalloff && (this._markAllSubMeshesAsTexturesDirty(),
this._lightFalloff = e ? rp.LIGHTFALLOFF_PHYSICAL : rp.LIGHTFALLOFF_STANDARD)
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "useGLTFLightFalloff", {
get: function() {
return this._lightFalloff === rp.LIGHTFALLOFF_GLTF
},
set: function(e) {
e !== this.useGLTFLightFalloff && (this._markAllSubMeshesAsTexturesDirty(),
this._lightFalloff = e ? rp.LIGHTFALLOFF_GLTF : rp.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) {
var i = this
, n = Ge.Clone((function() {
return new t(e,i.getScene())
}
), this);
return n.id = e,
n.name = e,
this.stencil.copyTo(n.stencil),
this.clearCoat.copyTo(n.clearCoat),
this.anisotropy.copyTo(n.anisotropy),
this.brdf.copyTo(n.brdf),
this.sheen.copyTo(n.sheen),
this.subSurface.copyTo(n.subSurface),
n
}
,
t.prototype.serialize = function() {
var t = e.prototype.serialize.call(this);
return t.customType = "BABYLON.PBRMaterial",
t.clearCoat = this.clearCoat.serialize(),
t.anisotropy = this.anisotropy.serialize(),
t.brdf = this.brdf.serialize(),
t.sheen = this.sheen.serialize(),
t.subSurface = this.subSurface.serialize(),
t
}
,
t.Parse = function(e, i, n) {
var r = Ge.Parse((function() {
return new t(e.name,i)
}
), e, i, n);
return e.stencil && r.stencil.parse(e.stencil, i, n),
e.clearCoat && r.clearCoat.parse(e.clearCoat, i, n),
e.anisotropy && r.anisotropy.parse(e.anisotropy, i, n),
e.brdf && r.brdf.parse(e.brdf, i, n),
e.sheen && r.sheen.parse(e.sheen, i, n),
e.subSurface && r.subSurface.parse(e.subSurface, i, n),
r
}
,
t.PBRMATERIAL_OPAQUE = rp.PBRMATERIAL_OPAQUE,
t.PBRMATERIAL_ALPHATEST = rp.PBRMATERIAL_ALPHATEST,
t.PBRMATERIAL_ALPHABLEND = rp.PBRMATERIAL_ALPHABLEND,
t.PBRMATERIAL_ALPHATESTANDBLEND = rp.PBRMATERIAL_ALPHATESTANDBLEND,
t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = rp.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "directIntensity", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveIntensity", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "environmentIntensity", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "specularIntensity", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "disableBumpMap", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "albedoTexture", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientTexture", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientTextureStrength", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientTextureImpactOnAnalyticalLights", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "opacityTexture", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionTexture", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveTexture", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectivityTexture", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallicTexture", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallic", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "roughness", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallicF0Factor", void 0),
k([Me(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallicReflectanceColor", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useOnlyMetallicFromMetallicReflectanceTexture", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallicReflectanceTexture", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectanceTexture", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "microSurfaceTexture", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "bumpTexture", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", null)], t.prototype, "lightmapTexture", void 0),
k([Me("ambient"), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientColor", void 0),
k([Me("albedo"), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "albedoColor", void 0),
k([Me("reflectivity"), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectivityColor", void 0),
k([Me("reflection"), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionColor", void 0),
k([Me("emissive"), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveColor", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "microSurface", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useLightmapAsShadowmap", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "useAlphaFromAlbedoTexture", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "forceAlphaTest", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "alphaCutOff", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useSpecularOverAlpha", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useMicroSurfaceFromReflectivityMapAlpha", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRoughnessFromMetallicTextureAlpha", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRoughnessFromMetallicTextureGreen", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useMetallnessFromMetallicTextureBlue", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useAmbientOcclusionFromMetallicTextureRed", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useAmbientInGrayScale", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useAutoMicroSurfaceFromReflectivityMap", void 0),
k([Ce()], t.prototype, "usePhysicalLightFalloff", null),
k([Ce()], t.prototype, "useGLTFLightFalloff", null),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRadianceOverAlpha", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useObjectSpaceNormalMap", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useParallax", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useParallaxOcclusion", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "parallaxScaleBias", void 0),
k([Ce(), Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "disableLighting", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "forceIrradianceInFragment", void 0),
k([Ce(), Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "maxSimultaneousLights", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapX", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapY", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "twoSidedLighting", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useAlphaFresnel", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useLinearAlphaFresnel", void 0),
k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "environmentBRDFTexture", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "forceNormalForward", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "enableSpecularAntiAliasing", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useHorizonOcclusion", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRadianceOcclusion", void 0),
k([Ce(), Re("_markAllSubMeshesAsMiscDirty")], t.prototype, "unlit", void 0),
t
}(rp);
y("BABYLON.PBRMaterial", op);
var ap = 131072
, sp = 131072;
function lp(e) {
return e.charCodeAt(0) + (e.charCodeAt(1) << 8) + (e.charCodeAt(2) << 16) + (e.charCodeAt(3) << 24)
}
var cp = lp("DXT1")
, up = lp("DXT3")
, hp = lp("DXT5")
, dp = lp("DX10")
, pp = 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)
, n = 1;
t[2] & ap && (n = Math.max(1, t[7]));
var r = t[21]
, o = r === dp ? i[32] : 0
, s = a.TEXTURETYPE_UNSIGNED_INT;
switch (r) {
case 113:
s = a.TEXTURETYPE_HALF_FLOAT;
break;
case 116:
s = a.TEXTURETYPE_FLOAT;
break;
case dp:
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: n,
isFourCC: 4 == (4 & t[20]),
isRGB: 64 == (64 & t[20]),
isLuminance: (t[20] & sp) === sp,
isCube: 512 == (512 & t[28]),
isCompressed: r === cp || r === up || r === hp,
dxgiFormat: o,
textureType: s
}
}
,
e._GetHalfFloatAsFloatRGBAArrayBuffer = function(t, i, n, r, o, a) {
for (var s = new Float32Array(r), l = new Uint16Array(o,n), c = 0, u = 0; u < i; u++)
for (var h = 0; h < t; h++) {
var d = 4 * (h + u * t);
s[c] = Dc(l[d]),
s[c + 1] = Dc(l[d + 1]),
s[c + 2] = Dc(l[d + 2]),
e.StoreLODInAlphaChannel ? s[c + 3] = a : s[c + 3] = Dc(l[d + 3]),
c += 4
}
return s
}
,
e._GetHalfFloatRGBAArrayBuffer = function(t, i, n, r, o, a) {
if (e.StoreLODInAlphaChannel) {
for (var s = new Uint16Array(r), l = new Uint16Array(o,n), 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] = Oc(a),
c += 4
}
return s
}
return new Uint16Array(o,n,r)
}
,
e._GetFloatRGBAArrayBuffer = function(t, i, n, r, o, a) {
if (e.StoreLODInAlphaChannel) {
for (var s = new Float32Array(r), l = new Float32Array(o,n), 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,n,r)
}
,
e._GetFloatAsHalfFloatRGBAArrayBuffer = function(t, i, n, r, o, a) {
for (var s = new Uint16Array(r), l = new Float32Array(o,n), c = 0, u = 0; u < i; u++)
for (var h = 0; h < t; h++)
s[c] = Oc(l[c]),
s[c + 1] = Oc(l[c + 1]),
s[c + 2] = Oc(l[c + 2]),
e.StoreLODInAlphaChannel ? s[c + 3] = Oc(a) : s[c + 3] = Oc(l[c + 3]),
c += 4;
return s
}
,
e._GetFloatAsUIntRGBAArrayBuffer = function(t, i, n, r, o, a) {
for (var s = new Uint8Array(r), l = new Float32Array(o,n), c = 0, u = 0; u < i; u++)
for (var h = 0; h < t; h++) {
var p = 4 * (h + u * t);
s[c] = 255 * d.Clamp(l[p]),
s[c + 1] = 255 * d.Clamp(l[p + 1]),
s[c + 2] = 255 * d.Clamp(l[p + 2]),
e.StoreLODInAlphaChannel ? s[c + 3] = a : s[c + 3] = 255 * d.Clamp(l[p + 3]),
c += 4
}
return s
}
,
e._GetHalfFloatAsUIntRGBAArrayBuffer = function(t, i, n, r, o, a) {
for (var s = new Uint8Array(r), l = new Uint16Array(o,n), c = 0, u = 0; u < i; u++)
for (var h = 0; h < t; h++) {
var p = 4 * (h + u * t);
s[c] = 255 * d.Clamp(Dc(l[p])),
s[c + 1] = 255 * d.Clamp(Dc(l[p + 1])),
s[c + 2] = 255 * d.Clamp(Dc(l[p + 2])),
e.StoreLODInAlphaChannel ? s[c + 3] = a : s[c + 3] = 255 * d.Clamp(Dc(l[p + 3])),
c += 4
}
return s
}
,
e._GetRGBAArrayBuffer = function(e, t, i, n, r, o, a, s, l) {
for (var c = new Uint8Array(n), u = new Uint8Array(r,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, n, r, o, a, s) {
for (var l = new Uint8Array(n), c = new Uint8Array(r,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, n, r) {
for (var o = new Uint8Array(n), a = new Uint8Array(r,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, n, r, o, s, l, c, u) {
void 0 === l && (l = -1),
void 0 === u && (u = !0);
var h = null;
r.sphericalPolynomial && (h = new Array);
var d = !!t.getCaps().s3tc;
i.generateMipMaps = o;
var p, f, _, m, g, v, y, b = new Int32Array(n.buffer,n.byteOffset,31), T = 0, E = 0, S = 1;
if (542327876 === b[0])
if (r.isFourCC || r.isRGB || r.isLuminance)
if (!r.isCompressed || d) {
var A = b[22];
m = b[1] + 4;
var x, R = !1;
if (r.isFourCC)
switch (p = b[21]) {
case cp:
S = 8,
E = a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1;
break;
case up:
S = 16,
E = a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3;
break;
case hp:
S = 16,
E = a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5;
break;
case 113:
R = !0,
A = 64;
break;
case 116:
R = !0,
A = 128;
break;
case dp:
m += 20;
var C = !1;
switch (r.dxgiFormat) {
case 10:
R = !0,
A = 64,
C = !0;
break;
case 2:
R = !0,
A = 128,
C = !0;
break;
case 88:
r.isRGB = !0,
r.isFourCC = !1,
A = 32,
C = !0
}
if (C)
break;
default:
return void console.error("Unsupported FourCC code:", (x = p,
String.fromCharCode(255 & x, x >> 8 & 255, x >> 16 & 255, x >> 24 & 255)))
}
var P = e._ExtractLongWordOrder(b[23])
, M = e._ExtractLongWordOrder(b[24])
, I = e._ExtractLongWordOrder(b[25])
, O = e._ExtractLongWordOrder(b[26]);
R && (E = t._getRGBABufferInternalSizedFormat(r.textureType)),
v = 1,
b[2] & ap && !1 !== o && (v = Math.max(1, b[7]));
for (var D = c || 0, N = t.getCaps(), L = D; L < s; L++) {
for (f = b[4],
_ = b[3],
y = 0; y < v; ++y) {
if (-1 === l || l === y) {
var F = -1 === l ? y : 0;
if (!r.isCompressed && r.isFourCC) {
i.format = a.TEXTUREFORMAT_RGBA,
T = f * _ * 4;
var w = null;
if (t._badOS || t._badDesktopOS || !N.textureHalfFloat && !N.textureFloat)
128 === A ? (w = e._GetFloatAsUIntRGBAArrayBuffer(f, _, n.byteOffset + m, T, n.buffer, F),
h && 0 == F && h.push(e._GetFloatRGBAArrayBuffer(f, _, n.byteOffset + m, T, n.buffer, F))) : 64 === A && (w = e._GetHalfFloatAsUIntRGBAArrayBuffer(f, _, n.byteOffset + m, T, n.buffer, F),
h && 0 == F && h.push(e._GetHalfFloatAsFloatRGBAArrayBuffer(f, _, n.byteOffset + m, T, n.buffer, F))),
i.type = a.TEXTURETYPE_UNSIGNED_INT;
else {
var B = N.textureFloat && (u && N.textureFloatLinearFiltering || !u)
, U = N.textureHalfFloat && (u && N.textureHalfFloatLinearFiltering || !u)
, V = (128 === A || 64 === A && !U) && B ? a.TEXTURETYPE_FLOAT : (64 === A || 128 === A && !B) && U ? a.TEXTURETYPE_HALF_FLOAT : a.TEXTURETYPE_UNSIGNED_BYTE
, k = void 0
, G = null;
if (128 === A)
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, _, n.byteOffset + m, T, n.buffer, F),
h && 0 == F && h.push(G ? G(f, _, n.byteOffset + m, T, n.buffer, F) : w)
}
w && t._uploadDataToTextureDirectly(i, w, L, F)
} else if (r.isRGB)
i.type = a.TEXTURETYPE_UNSIGNED_INT,
24 === A ? (i.format = a.TEXTUREFORMAT_RGB,
T = f * _ * 3,
g = e._GetRGBArrayBuffer(f, _, n.byteOffset + m, T, n.buffer, P, M, I),
t._uploadDataToTextureDirectly(i, g, L, F)) : (i.format = a.TEXTUREFORMAT_RGBA,
T = f * _ * 4,
g = e._GetRGBAArrayBuffer(f, _, n.byteOffset + m, T, n.buffer, P, M, I, O),
t._uploadDataToTextureDirectly(i, g, L, F));
else if (r.isLuminance) {
var z = t._getUnpackAlignement()
, W = f;
T = Math.floor((f + z - 1) / z) * z * (_ - 1) + W,
g = e._GetLuminanceArrayBuffer(f, _, n.byteOffset + m, T, n.buffer),
i.format = a.TEXTUREFORMAT_LUMINANCE,
i.type = a.TEXTURETYPE_UNSIGNED_INT,
t._uploadDataToTextureDirectly(i, g, L, F)
} else
T = Math.max(4, f) / 4 * Math.max(4, _) / 4 * S,
g = new Uint8Array(n.buffer,n.byteOffset + m,T),
i.type = a.TEXTURETYPE_UNSIGNED_INT,
t._uploadCompressedDataToTextureDirectly(i, E, f, _, g, L, F)
}
m += A ? f * _ * (A / 8) : T,
f *= .5,
_ *= .5,
f = Math.max(1, f),
_ = Math.max(1, _)
}
if (void 0 !== c)
break
}
h && h.length > 0 ? r.sphericalPolynomial = wc.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
}) : r.sphericalPolynomial = void 0
} else
K.Error("Compressed textures are not supported on this platform.");
else
K.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
else
K.Error("Invalid magic number in DDS header")
}
,
e.StoreLODInAlphaChannel = !1,
e
}();
Ht.prototype.createPrefilteredCubeTexture = function(e, t, i, n, r, o, s, l, c) {
var u = this;
return void 0 === r && (r = 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 Pc,
o._source = At.CubePrefiltered,
u.getCaps().textureLOD)
r && r(o);
else {
var s = u._gl
, l = e.width;
if (l) {
for (var h = [], p = 0; p < 3; p++) {
var f = 1 - p / 2
, _ = n
, m = d.Log2(l) * i + n
, g = _ + (m - _) * f
, v = Math.round(Math.min(Math.max(g, 0), m))
, y = new Lt(u,At.Temp);
if (y.type = o.type,
y.format = o.format,
y.width = Math.pow(2, Math.max(d.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),
pp.UploadDDSLevels(u, y, T, b, !0, 6, v)
} else
K.Warn("DDS is the only prefiltered cube map supported so far.");
u._bindTextureDirectly(s.TEXTURE_CUBE_MAP, null);
var E = new Zr(t);
E.isCube = !0,
E._texture = y,
y.isReady = !0,
h.push(E)
}
o._lodTextureHigh = h[2],
o._lodTextureMid = h[1],
o._lodTextureLow = h[0],
r && r(o)
}
}
} else
r && r(null)
}
), o, s, l, c, i, n)
}
;
var fp = function() {
function e() {
this.supportCascades = !0
}
return e.prototype.canLoad = function(e) {
return oe(e, ".dds")
}
,
e.prototype.loadCubeData = function(e, t, i, n) {
var r, o = t.getEngine(), a = !1, s = 1e3;
if (Array.isArray(e))
for (var l = 0; l < e.length; l++) {
var c = e[l];
r = pp.GetDDSInfo(c),
t.width = r.width,
t.height = r.height,
a = (r.isRGB || r.isLuminance || r.mipmapCount > 1) && t.generateMipMaps,
o._unpackFlipY(r.isCompressed),
pp.UploadDDSLevels(o, t, c, r, a, 6, -1, l),
r.isFourCC || 1 !== r.mipmapCount ? s = r.mipmapCount - 1 : o.generateMipMapsForCubemap(t)
}
else
c = e,
r = pp.GetDDSInfo(c),
t.width = r.width,
t.height = r.height,
i && (r.sphericalPolynomial = new Pc),
a = (r.isRGB || r.isLuminance || r.mipmapCount > 1) && t.generateMipMaps,
o._unpackFlipY(r.isCompressed),
pp.UploadDDSLevels(o, t, c, r, a, 6),
r.isFourCC || 1 !== r.mipmapCount ? s = r.mipmapCount - 1 : o.generateMipMapsForCubemap(t, !1);
o._setCubeMapTextureParams(t, a, s),
t.isReady = !0,
t.onLoadedObservable.notifyObservers(t),
t.onLoadedObservable.clear(),
n && n({
isDDS: !0,
width: t.width,
info: r,
data: e,
texture: t
})
}
,
e.prototype.loadData = function(e, t, i) {
var n = pp.GetDDSInfo(e)
, r = (n.isRGB || n.isLuminance || n.mipmapCount > 1) && t.generateMipMaps && n.width >> n.mipmapCount - 1 == 1;
i(n.width, n.height, r, n.isFourCC, (function() {
pp.UploadDDSLevels(t.getEngine(), t, e, n, r, 1)
}
))
}
,
e
}();
vr._TextureLoaders.push(new fp);
var _p = function() {
function e() {
this.supportCascades = !1
}
return e.prototype.canLoad = function(e) {
return oe(e, ".env")
}
,
e.prototype.loadCubeData = function(e, t, i, n, r) {
if (!Array.isArray(e)) {
var o = Vc(e);
if (o) {
t.width = o.width,
t.height = o.width;
try {
Yc(t, o),
Hc(t, e, o).then((function() {
t.isReady = !0,
t.onLoadedObservable.notifyObservers(t),
t.onLoadedObservable.clear(),
n && n()
}
), (function(e) {
null == r || r("Can not upload environment levels", e)
}
))
} catch (e) {
null == r || r("Can not upload environment file", e)
}
} else
r && r("Can not parse the environment file", null)
}
}
,
e.prototype.loadData = function() {
throw ".env not supported in 2d."
}
,
e
}();
vr._TextureLoaders.push(new _p);
var mp = function() {
function e(t, i) {
if (this.data = t,
this.isInvalid = !1,
!e.IsValid(t))
return this.isInvalid = !0,
void K.Error("texture missing KTX identifier");
var n = Uint32Array.BYTES_PER_ELEMENT
, r = new DataView(this.data.buffer,this.data.byteOffset + 12,13 * n)
, o = 67305985 === r.getUint32(0, !0);
this.glType = r.getUint32(1 * n, o),
this.glTypeSize = r.getUint32(2 * n, o),
this.glFormat = r.getUint32(3 * n, o),
this.glInternalFormat = r.getUint32(4 * n, o),
this.glBaseInternalFormat = r.getUint32(5 * n, o),
this.pixelWidth = r.getUint32(6 * n, o),
this.pixelHeight = r.getUint32(7 * n, o),
this.pixelDepth = r.getUint32(8 * n, o),
this.numberOfArrayElements = r.getUint32(9 * n, o),
this.numberOfFaces = r.getUint32(10 * n, o),
this.numberOfMipmapLevels = r.getUint32(11 * n, o),
this.bytesOfKeyValueData = r.getUint32(12 * n, o),
0 === this.glType ? (this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels),
0 !== this.pixelHeight && 0 === this.pixelDepth ? 0 === this.numberOfArrayElements ? this.numberOfFaces === i ? this.loadType = e.COMPRESSED_2D : K.Error("number of faces expected" + i + ", but found " + this.numberOfFaces) : K.Error("texture arrays not currently supported") : K.Error("only 2D textures currently supported")) : K.Error("only compressed formats currently supported")
}
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 n = e.HEADER_LEN + this.bytesOfKeyValueData, r = 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 + n,1)[0];
n += 4;
for (var c = 0; c < this.numberOfFaces; c++) {
var u = new Uint8Array(this.data.buffer,this.data.byteOffset + n,l);
t.getEngine()._uploadCompressedDataToTextureDirectly(t, this.glInternalFormat, r, o, u, c, s),
n += l,
n += 3 - (l + 3) % 4
}
r = Math.max(1, .5 * r),
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
}()
, gp = 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 n = i[t];
if (n.idle)
return this._execute(n, e),
!0
}
return !1
}
,
e.prototype._execute = function(e, t) {
var i = this;
e.idle = !1,
e.workerPromise.then((function(n) {
t(n, (function() {
var t = i._pendingActions.shift();
t ? i._execute(e, t) : e.idle = !0
}
))
}
))
}
,
e
}()
, vp = function(e) {
function t(i, n, r) {
void 0 === r && (r = t.DefaultOptions);
var o = e.call(this, []) || this;
return o._maxWorkers = i,
o._createWorkerAsync = n,
o._options = r,
o
}
return U(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 n = this;
t.timeoutId && (clearTimeout(t.timeoutId),
delete t.timeoutId),
e.prototype._execute.call(this, t, (function(e, r) {
i(e, (function() {
r(),
t.idle && (t.timeoutId = setTimeout((function() {
t.workerPromise.then((function(e) {
e.terminate()
}
));
var e = n._workerInfos.indexOf(t);
-1 !== e && n._workerInfos.splice(e, 1)
}
), n._options.idleTimeElapsedBeforeRelease))
}
))
}
))
}
,
t.DefaultOptions = {
idleTimeElapsedBeforeRelease: 1e3
},
t
}(gp)
, yp = 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) {
e._WorkerPoolPromise || e._DecoderModulePromise || (t && "function" == typeof Worker ? e._WorkerPoolPromise = new Promise((function(i) {
var n = "(".concat(bp, ")()")
, r = URL.createObjectURL(new Blob([n],{
type: "application/javascript"
}));
i(new vp(t,(function() {
return new Promise((function(t, i) {
var n = new Worker(r)
, o = function(e) {
n.removeEventListener("error", o),
n.removeEventListener("message", a),
i(e)
}
, a = function(e) {
"init" === e.data.action && (n.removeEventListener("error", o),
n.removeEventListener("message", a),
t(n))
};
n.addEventListener("error", o),
n.addEventListener("message", a),
n.postMessage({
action: "init",
urls: e.URLConfig
})
}
))
}
)))
}
)) : "undefined" == typeof KTX2DECODER ? e._DecoderModulePromise = gi.LoadScriptAsync(e.URLConfig.jsDecoderModule).then((function() {
KTX2DECODER.MSCTranscoder.UseFromWorkerThread = !1,
KTX2DECODER.WASMMemoryManager.LoadBinariesFromCurrentThread = !0;
var t = e.URLConfig;
return null !== t.wasmUASTCToASTC && (KTX2DECODER.LiteTranscoder_UASTC_ASTC.WasmModuleURL = t.wasmUASTCToASTC),
null !== t.wasmUASTCToBC7 && (KTX2DECODER.LiteTranscoder_UASTC_BC7.WasmModuleURL = t.wasmUASTCToBC7),
null !== t.wasmUASTCToRGBA_UNORM && (KTX2DECODER.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL = t.wasmUASTCToRGBA_UNORM),
null !== t.wasmUASTCToRGBA_SRGB && (KTX2DECODER.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL = t.wasmUASTCToRGBA_SRGB),
null !== t.jsMSCTranscoder && (KTX2DECODER.MSCTranscoder.JSModuleURL = t.jsMSCTranscoder),
null !== t.wasmMSCTranscoder && (KTX2DECODER.MSCTranscoder.WasmModuleURL = t.wasmMSCTranscoder),
null !== t.wasmZSTDDecoder && (KTX2DECODER.ZSTDDecoder.WasmModuleURL = t.wasmZSTDDecoder),
new KTX2DECODER.KTX2Decoder
}
)) : (KTX2DECODER.MSCTranscoder.UseFromWorkerThread = !1,
KTX2DECODER.WASMMemoryManager.LoadBinariesFromCurrentThread = !0,
e._DecoderModulePromise = Promise.resolve(new KTX2DECODER.KTX2Decoder)))
}
,
e.prototype.uploadAsync = function(t, i, n) {
var r = 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(e) {
return new Promise((function(o, s) {
e.push((function(e, l) {
var c = function(t) {
e.removeEventListener("error", c),
e.removeEventListener("message", u),
s(t),
l()
}
, u = function(t) {
if ("decoded" === t.data.action) {
if (e.removeEventListener("error", c),
e.removeEventListener("message", u),
t.data.success)
try {
r._createTexture(t.data.decodedData, i, n),
o()
} catch (e) {
s({
message: e
})
}
else
s({
message: t.data.msg
});
l()
}
};
e.addEventListener("error", c),
e.addEventListener("message", u);
var h = new Uint8Array(t.byteLength);
h.set(new Uint8Array(t.buffer,t.byteOffset,t.byteLength)),
e.postMessage({
action: "decode",
data: h,
caps: a,
options: n
}, [h.buffer])
}
))
}
))
}
));
if (e._DecoderModulePromise)
return e._DecoderModulePromise.then((function(e) {
return new Promise((function(n, a) {
e.decode(t, o).then((function(e) {
r._createTexture(e, i),
n()
}
)).catch((function(e) {
a({
message: e
})
}
))
}
))
}
));
throw new Error("KTX2 decoder module is not available")
}
,
e.prototype._createTexture = function(e, t, i) {
if (this._engine._bindTextureDirectly(3553, t),
i && (i.transcodedFormat = e.transcodedFormat,
i.isInGammaSpace = e.isInGammaSpace,
i.hasAlpha = e.hasAlpha,
i.transcoderName = e.transcoderName),
32856 === e.transcodedFormat ? (t.type = a.TEXTURETYPE_UNSIGNED_BYTE,
t.format = a.TEXTUREFORMAT_RGBA) : t.format = e.transcodedFormat,
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 r = e.mipmaps[n];
if (!r || !r.data)
throw new Error("KTX2 container - could not transcode one of the image");
32856 === e.transcodedFormat ? (t.width = r.width,
t.height = r.height,
this._engine._uploadDataToTextureDirectly(t, r.data, 0, n, void 0, !0)) : this._engine._uploadCompressedDataToTextureDirectly(t, e.transcodedFormat, r.width, r.height, r.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,
jsMSCTranscoder: null,
wasmMSCTranscoder: null,
wasmZSTDDecoder: null
},
e.DefaultNumWorkers = e.GetDefaultNumWorkers(),
e
}();
function bp() {
var e;
onmessage = function(t) {
if (t.data)
switch (t.data.action) {
case "init":
var i = t.data.urls;
importScripts(i.jsDecoderModule),
null !== i.wasmUASTCToASTC && (KTX2DECODER.LiteTranscoder_UASTC_ASTC.WasmModuleURL = i.wasmUASTCToASTC),
null !== i.wasmUASTCToBC7 && (KTX2DECODER.LiteTranscoder_UASTC_BC7.WasmModuleURL = i.wasmUASTCToBC7),
null !== i.wasmUASTCToRGBA_UNORM && (KTX2DECODER.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL = i.wasmUASTCToRGBA_UNORM),
null !== i.wasmUASTCToRGBA_SRGB && (KTX2DECODER.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL = i.wasmUASTCToRGBA_SRGB),
null !== i.jsMSCTranscoder && (KTX2DECODER.MSCTranscoder.JSModuleURL = i.jsMSCTranscoder),
null !== i.wasmMSCTranscoder && (KTX2DECODER.MSCTranscoder.WasmModuleURL = i.wasmMSCTranscoder),
null !== i.wasmZSTDDecoder && (KTX2DECODER.ZSTDDecoder.WasmModuleURL = i.wasmZSTDDecoder),
e = new KTX2DECODER.KTX2Decoder,
postMessage({
action: "init"
});
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 n = e.mipmaps[i];
n && n.data && t.push(n.data.buffer)
}
postMessage({
action: "decoded",
success: !0,
decodedData: e
}, t)
}
)).catch((function(e) {
postMessage({
action: "decoded",
success: !1,
msg: e
})
}
))
}
}
}
var Tp = function() {
function e() {
this.supportCascades = !1
}
return e.prototype.canLoad = function(e, t) {
return oe(e, ".ktx") || oe(e, ".ktx2") || "image/ktx" === t || "image/ktx2" === t
}
,
e.prototype.loadCubeData = function(e, t, i, n) {
if (!Array.isArray(e)) {
t._invertVScale = !t.invertY;
var r = t.getEngine()
, o = new mp(e,6)
, a = o.numberOfMipmapLevels > 1 && t.generateMipMaps;
r._unpackFlipY(!0),
o.uploadLevels(t, t.generateMipMaps),
t.width = o.pixelWidth,
t.height = o.pixelHeight,
r._setCubeMapTextureParams(t, a, o.numberOfMipmapLevels - 1),
t.isReady = !0,
t.onLoadedObservable.notifyObservers(t),
t.onLoadedObservable.clear(),
n && n()
}
}
,
e.prototype.loadData = function(e, t, i, n) {
if (mp.IsValid(e)) {
t._invertVScale = !t.invertY;
var r = new mp(e,1);
i(r.pixelWidth, r.pixelHeight, t.generateMipMaps, !0, (function() {
r.uploadLevels(t, t.generateMipMaps)
}
), r.isInvalid)
} else
yp.IsValid(e) ? new yp(t.getEngine()).uploadAsync(e, t, n).then((function() {
i(t.width, t.height, t.generateMipMaps, !0, (function() {}
), !1)
}
), (function(e) {
K.Warn("Failed to load KTX2 texture data: ".concat(e.message)),
i(0, 0, !1, !1, (function() {}
), !0)
}
)) : (K.Error("texture missing KTX identifier"),
i(0, 0, !1, !1, (function() {}
), !0))
}
,
e
}();
vr._TextureLoaders.unshift(new Tp);
var Ep = function(e) {
function t(t, i, n) {
var r = e.call(this, t, x.Zero(), i) || this;
return r._xrSessionManager = n,
r._firstFrame = !1,
r._referenceQuaternion = C.Identity(),
r._referencedPosition = new x,
r._trackingState = Ls.NOT_TRACKING,
r.onBeforeCameraTeleport = new h,
r.onAfterCameraTeleport = new h,
r.onTrackingStateChanged = new h,
r.compensateOnFirstFrame = !0,
r._rotate180 = new C(0,1,0,0),
r.minZ = .1,
r.rotationQuaternion = new C,
r.cameraRigMode = Rr.RIG_MODE_CUSTOM,
r.updateUpVectorFromRotation = !0,
r._updateNumberOfRigCameras(1),
r.freezeProjectionMatrix(),
r._xrSessionManager.onXRSessionInit.add((function() {
r._referencedPosition.copyFromFloats(0, 0, 0),
r._referenceQuaternion.copyFromFloats(0, 0, 0, 1),
r._firstFrame = r.compensateOnFirstFrame
}
)),
r._xrSessionManager.onXRFrameObservable.add((function() {
r._firstFrame && r._updateFromXRSession(),
r._updateReferenceSpace(),
r._updateFromXRSession()
}
), void 0, !0),
r
}
return U(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 xr(0,0,.5,1),
this.rigCameras[0].outputRenderTarget = null,
this.rigCameras[1].viewport = new xr(.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,
C.FromEulerAnglesToRef(0, this.rotationQuaternion.toEulerAngles().y, 0, this.rotationQuaternion),
this._firstFrame = !0,
t && this._xrSessionManager.resetReferenceSpace())
}
,
t.prototype.getClassName = function() {
return "WebXRCamera"
}
,
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 ? Ls.TRACKING_LOST : Ls.TRACKING;
if (this._setTrackingState(i),
t.transform) {
var n = t.transform.orientation;
if (void 0 === t.transform.orientation.x)
return;
var r = t.transform.position;
this._referencedPosition.set(r.x, r.y, r.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 n, r = e.rigCameras[i];
r.isLeftCamera || r.isRightCamera || ("right" === t.eye ? r._isRightCamera = !0 : "left" === t.eye && (r._isLeftCamera = !0));
var o = t.transform.position
, a = t.transform.orientation;
r.parent = e.parent,
r.position.set(o.x, o.y, o.z),
r.rotationQuaternion.set(a.x, a.y, a.z, a.w),
e._scene.useRightHandedSystem ? r.rotationQuaternion.multiplyInPlace(e._rotate180) : (r.position.z *= -1,
r.rotationQuaternion.z *= -1,
r.rotationQuaternion.w *= -1),
P.FromFloat32ArrayToRefScaled(t.projectionMatrix, 0, 1, r._projectionMatrix),
e._scene.useRightHandedSystem || r._projectionMatrix.toggleProjectionMatrixHandInPlace(),
0 === i && e._projectionMatrix.copyFrom(r._projectionMatrix);
var s = e._xrSessionManager.getRenderTargetTextureForView(t);
e._renderingMultiview = (null === (n = null == s ? void 0 : s._texture) || void 0 === n ? void 0 : n.isMultiview) || !1,
e._renderingMultiview ? 0 == i && (e._xrSessionManager.trySetViewportForView(e.viewport, t),
e.outputRenderTarget = s) : (e._xrSessionManager.trySetViewportForView(r.viewport, t),
r.outputRenderTarget = s || e._xrSessionManager.getRenderTargetTextureForView(t))
}
))
} else
this._setTrackingState(Ls.NOT_TRACKING)
}
,
t.prototype._updateNumberOfRigCameras = function(e) {
for (void 0 === e && (e = 1); this.rigCameras.length < e; ) {
var t = new da("XR-RigCamera: " + this.rigCameras.length,x.Zero(),this.getScene());
t.minZ = .1,
t.rotationQuaternion = new C,
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 = I.Matrix[0]
, i = I.Matrix[1]
, n = I.Matrix[2];
P.ComposeToRef(t._ScaleReadOnly, this._referenceQuaternion, this._referencedPosition, e),
P.ComposeToRef(t._ScaleReadOnly, this.rotationQuaternion, this.position, i),
e.invert().multiplyToRef(i, n),
n.invert(),
this._scene.useRightHandedSystem || n.toggleModelMatrixHandInPlace(),
n.decompose(void 0, this._referenceQuaternion, this._referencedPosition);
var r = 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(r)
}
}
,
t._ScaleReadOnly = x.One(),
t
}(pa)
, Sp = 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.onInitialXRPoseSetObservable = new h,
this.onStateChangedObservable = new h,
this.state = Ns.NOT_IN_XR,
this.sessionManager = new Xs(e),
this.camera = new Ep("webxr",e,this.sessionManager),
this.featuresManager = new Oo(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(Ns.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, n) {
var r, o;
return void 0 === i && (i = this.sessionManager.getWebXRRenderTarget()),
void 0 === n && (n = {}),
G(this, void 0, void 0, (function() {
var a, s, l, c = this;
return z(this, (function(u) {
switch (u.label) {
case 0:
if (!this._supported)
throw "WebXR not supported in this browser or environment";
return this._setState(Ns.ENTERING_XR),
"viewer" !== t && "local" !== t && (n.optionalFeatures = n.optionalFeatures || [],
n.optionalFeatures.push(t)),
[4, this.featuresManager._extendXRSessionInitObject(n)];
case 1:
n = u.sent(),
"immersive-ar" === e && "unbounded" !== t && K.Warn("We recommend using 'unbounded' reference space type when using 'immersive-ar' session mode"),
u.label = 2;
case 2:
return u.trys.push([2, 6, , 7]),
[4, this.sessionManager.initializeSessionAsync(e, n)];
case 3:
return u.sent(),
[4, this.sessionManager.setReferenceSpaceTypeAsync(t)];
case 4:
return u.sent(),
[4, i.initializeXRLayerAsync(this.sessionManager.session)];
case 5:
return a = u.sent(),
s = {
depthFar: this.camera.maxZ,
depthNear: this.camera.minZ
},
this.featuresManager.getEnabledFeature(Io.LAYERS) || (s.baseLayer = a),
this.sessionManager.updateRenderState(s),
this.sessionManager.runXRRenderLoop(),
this._originalSceneAutoClear = this._scene.autoClear,
this._nonVRCamera = this._scene.activeCamera,
this._attachedToElement = !!(null === (r = this._nonVRCamera) || void 0 === r ? void 0 : r.inputs.attachedToElement),
null === (o = this._nonVRCamera) || void 0 === o || o.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.sessionManager.onXRSessionEnded.addOnce((function() {
c.state !== Ns.EXITING_XR && c._setState(Ns.EXITING_XR),
c.camera.rigCameras.forEach((function(e) {
e.outputRenderTarget = null
}
)),
c._scene.autoClear = c._originalSceneAutoClear,
c._scene.activeCamera = c._nonVRCamera,
c._attachedToElement && c._nonVRCamera && c._nonVRCamera.attachControl(!!c._nonVRCamera.inputs.noPreventDefault),
"immersive-ar" !== e && c.camera.compensateOnFirstFrame && (c._nonVRCamera.setPosition ? c._nonVRCamera.setPosition(c.camera.position) : c._nonVRCamera.position.copyFrom(c.camera.position)),
c._setState(Ns.NOT_IN_XR)
}
)),
this.sessionManager.onXRFrameObservable.addOnce((function() {
c._setState(Ns.IN_XR)
}
)),
[2, this.sessionManager];
case 6:
throw l = u.sent(),
console.log(l),
console.log(l.message),
this._setState(Ns.NOT_IN_XR),
l;
case 7:
return [2]
}
}
))
}
))
}
,
e.prototype.exitXRAsync = function() {
return this.state !== Ns.IN_XR ? Promise.resolve() : (this._setState(Ns.EXITING_XR),
this.sessionManager.exitXRAsync())
}
,
e.prototype.enableSpectatorMode = function() {
var e = this;
if (!this._spectatorMode) {
var t = function() {
e._spectatorCamera && (e._spectatorCamera.position.copyFrom(e.camera.rigCameras[0].globalPosition),
e._spectatorCamera.rotationQuaternion.copyFrom(e.camera.rigCameras[0].absoluteRotation))
}
, i = function() {
e.state === Ns.IN_XR ? (e._spectatorCamera = new Na("webxr-spectator",x.Zero(),e._scene),
e._spectatorCamera.rotationQuaternion = new C,
e._scene.activeCameras = [e.camera, e._spectatorCamera],
e.sessionManager.onXRFrameObservable.add(t),
e._scene.onAfterRenderCameraObservable.add((function(t) {
t === e.camera && (e._scene.getEngine().framebufferDimensionsObject = null)
}
))) : e.state === Ns.EXITING_XR && (e.sessionManager.onXRFrameObservable.removeCallback(t),
e._scene.activeCameras = null)
};
this._spectatorMode = !0,
this.onStateChangedObservable.add(i),
i()
}
}
,
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
}()
, Ap = function() {
function e(e, t, i, n) {
void 0 === i && (i = -1),
void 0 === n && (n = []),
this.id = e,
this.type = t,
this._buttonIndex = i,
this._axesIndices = n,
this._axes = {
x: 0,
y: 0
},
this._changes = {},
this._currentValue = 0,
this._hasChanges = !1,
this._pressed = !1,
this._touched = !1,
this.onAxisValueChangedObservable = new h,
this.onButtonStateChangedObservable = new h
}
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 n = e.buttons[this._buttonIndex];
if (!n)
return;
this._currentValue !== n.value && (this.changes.value = {
current: n.value,
previous: this._currentValue
},
t = !0,
this._currentValue = n.value),
this._touched !== n.touched && (this.changes.touched = {
current: n.touched,
previous: this._touched
},
t = !0,
this._touched = n.touched),
this._pressed !== n.pressed && (this.changes.pressed = {
current: n.pressed,
previous: this._pressed
},
t = !0,
this._pressed = n.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
}()
, xp = function() {
function e(e, t, i, n, r, o) {
void 0 === r && (r = !1);
var a = this;
this.scene = e,
this.layout = t,
this.gamepadObject = i,
this.handedness = n,
this._doNotLoadControllerMesh = r,
this._controllerCache = o,
this._initComponent = function(e) {
if (e) {
var t = a.layout.components[e]
, i = t.type
, n = t.gamepadIndices.button
, r = [];
void 0 !== t.gamepadIndices.xAxis && void 0 !== t.gamepadIndices.yAxis && r.push(t.gamepadIndices.xAxis, t.gamepadIndices.yAxis),
a.components[e] = new Ap(e,i,n,r)
}
}
,
this._modelReady = !1,
this.components = {},
this.disableAnimation = !1,
this.onModelLoadedObservable = new h,
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 G(this, void 0, void 0, (function() {
var e, t, i = this;
return z(this, (function(n) {
return e = !this._getModelLoadingConstraints(),
t = this._getGenericFilenameAndPath(),
e ? K.Warn("Falling back to generic models") : t = this._getFilenameAndPath(),
[2, new Promise((function(n, r) {
var o = function(t) {
e ? i._getGenericParentMesh(t) : i._setRootMesh(t),
i._processLoadedModel(t),
i._modelReady = !0,
i.onModelLoadedObservable.notifyObservers(i),
n(!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)
}
od.ImportMesh("", t.path, t.filename, i.scene, (function(e) {
i._controllerCache && i._controllerCache.push(V(V({}, t), {
meshes: e
})),
o(e)
}
), null, (function(e, n) {
K.Log(n),
K.Warn("Failed to retrieve controller model of type ".concat(i.profileId, " from the remote server: ").concat(t.path).concat(t.filename)),
r(n)
}
))
}
))]
}
))
}
))
}
,
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 n = i ? .5 * t + .5 : t;
C.SlerpToRef(e.minMesh.rotationQuaternion, e.maxMesh.rotationQuaternion, n, e.valueMesh.rotationQuaternion),
x.LerpToRef(e.minMesh.position, e.maxMesh.position, n, 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 Vr(this.profileId + " " + this.handedness,this.scene),
e.forEach((function(e) {
e.parent || (e.isPickable = !1,
e.setParent(t.rootMesh))
}
)),
this.rootMesh.rotationQuaternion = C.FromEulerAngles(0, Math.PI, 0)
}
,
e
}()
, Rp = function(e) {
function t(i, n, r) {
var o = e.call(this, i, Cp[r], n, r) || this;
return o.profileId = t.ProfileId,
o
}
return U(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 Vr(this.profileId + " " + this.handedness,this.scene),
e.forEach((function(e) {
e.isPickable = !1,
e.parent || e.setParent(t.rootMesh)
}
)),
this.rootMesh.rotationQuaternion = C.FromEulerAngles(0, Math.PI, 0)
}
,
t.prototype._updateModel = function() {}
,
t.ProfileId = "generic-trigger",
t
}(xp)
, Cp = {
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"
}
}
, Pp = function(e) {
function t(t, i, n, r, o) {
var a = e.call(this, t, n.layouts[i.handedness || "none"], i.gamepad, i.handedness, void 0, o) || this;
return a._repositoryUrl = r,
a.controllerCache = o,
a._buttonMeshMapping = {},
a._touchDots = {},
a.profileId = n.profileId,
a
}
return U(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 = od.IsPluginForExtensionAvailable(".glb");
return e || K.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(n) {
var r = i.visualResponses[n];
if ("transform" === r.valueNodeProperty)
t._buttonMeshMapping[e].states[n] = {
valueMesh: t._getChildByName(t.rootMesh, r.valueNodeName),
minMesh: t._getChildByName(t.rootMesh, r.minNodeName),
maxMesh: t._getChildByName(t.rootMesh, r.maxNodeName)
};
else {
var o = i.type === Ap.TOUCHPAD_TYPE && i.touchPointNodeName ? i.touchPointNodeName : r.valueNodeName;
if (t._buttonMeshMapping[e].states[n] = {
valueMesh: t._getChildByName(t.rootMesh, o)
},
i.type === Ap.TOUCHPAD_TYPE && !t._touchDots[n]) {
var a = Dl(n + "dot", {
diameter: .0015,
segments: 8
}, t.scene);
a.material = new Os(n + "mat",t.scene),
a.material.diffuseColor = D.Red(),
a.parent = t._buttonMeshMapping[e].states[n].valueMesh || null,
a.isVisible = !1,
t._touchDots[n] = a
}
}
}
))
}
))
}
,
t.prototype._setRootMesh = function(e) {
var t;
this.rootMesh = new Vr(this.profileId + "-" + this.handedness,this.scene),
this.rootMesh.isPickable = !1;
for (var i = 0; i < e.length; i++) {
var n = e[i];
n.isPickable = !1,
n.parent || (t = n)
}
t && t.setParent(this.rootMesh),
this.scene.useRightHandedSystem || this.rootMesh.rotate(vn.Y, Math.PI, Ji.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 n = t._buttonMeshMapping[e]
, r = t.layout.components[e];
Object.keys(r.visualResponses).forEach((function(e) {
var o = r.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(n.states[e], a, "button" !== o.componentProperty);
else {
var s = n.states[e].valueMesh;
s && (s.isVisible = i.touched || i.pressed),
t._touchDots[e] && (t._touchDots[e].isVisible = i.touched || i.pressed)
}
}
))
}
}
))
}
,
t
}(xp)
, Mp = []
, Ip = 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 n = this
, r = [];
i && r.push(i),
r.push.apply(r, e.profiles || []),
r.length && !r[0] && r.pop(),
e.gamepad && e.gamepad.id && e.gamepad.id === (e.gamepad.id.match(/oculus touch/gi) ? e.gamepad.id : void 0) && r.push("oculus-touch-v2");
var o = r.indexOf("windows-mixed-reality");
if (-1 !== o && r.splice(o, 0, "microsoft-mixed-reality"),
r.length || r.push("generic-trigger"),
this.UseOnlineRepository) {
var a = this.PrioritizeOnlineRepository ? this._LoadProfileFromRepository : this._LoadProfilesFromAvailableControllers
, s = this.PrioritizeOnlineRepository ? this._LoadProfilesFromAvailableControllers : this._LoadProfileFromRepository;
return a.call(this, r, e, t).catch((function() {
return s.call(n, r, e, t)
}
))
}
return this._LoadProfilesFromAvailableControllers(r, 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 = gi.LoadFileAsync(this.BaseRepositoryUrl + "/profiles/profilesList.json", !1).then((function(e) {
return JSON.parse(e.toString())
}
)),
this._ProfilesList
}
,
e.ClearControllerCache = function() {
Mp.forEach((function(e) {
e.meshes.forEach((function(e) {
e.dispose(!1, !0)
}
))
}
)),
Mp.length = 0
}
,
e._LoadProfileFromRepository = function(e, t, i) {
var n = this;
return Promise.resolve().then((function() {
return n._ProfilesList ? n._ProfilesList : n.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 n._ProfileLoadingPromises[e] || (n._ProfileLoadingPromises[e] = gi.LoadFileAsync("".concat(n.BaseRepositoryUrl, "/profiles/").concat(e, "/profile.json"), !1).then((function(e) {
return JSON.parse(e)
}
))),
n._ProfileLoadingPromises[e]
}
)).then((function(e) {
return new Pp(i,t,e,n.BaseRepositoryUrl,n.DisableControllerCache ? void 0 : Mp)
}
))
}
,
e._LoadProfilesFromAvailableControllers = function(e, t, i) {
for (var n = 0; n < e.length; ++n)
if (e[n])
for (var r = this.FindFallbackWithProfileId(e[n]), o = 0; o < r.length; ++o) {
var a = this._AvailableControllers[r[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
}();
Ip.RegisterController(Rp.ProfileId, (function(e, t) {
return new Rp(t,e.gamepad,e.handedness)
}
)),
Ip.DefaultFallbacks();
var Op, Dp, Np = 0, Lp = function() {
function e(e, t, i) {
void 0 === i && (i = {});
var n = this;
this._scene = e,
this.inputSource = t,
this._options = i,
this._tmpVector = new x,
this._disposed = !1,
this.onDisposeObservable = new h,
this.onMeshLoadedObservable = new h,
this.onMotionControllerInitObservable = new h,
this._uniqueId = "controller-".concat(Np++, "-").concat(t.targetRayMode, "-").concat(t.handedness),
this.pointer = new Sr("".concat(this._uniqueId, "-pointer"),e),
this.pointer.rotationQuaternion = new C,
this.inputSource.gripSpace && (this.grip = new Sr("".concat(this._uniqueId, "-grip"),this._scene),
this.grip.rotationQuaternion = new C),
this._tmpVector.set(0, 0, this._scene.useRightHandedSystem ? -1 : 1),
this.inputSource.gamepad && "tracked-pointer" === this.inputSource.targetRayMode && Ip.GetMotionControllerWithXRInput(t, e, this._options.forceControllerProfile).then((function(e) {
n.motionController = e,
n.onMotionControllerInitObservable.notifyObservers(e),
n._options.doNotLoadControllerMesh || n.motionController._doNotLoadControllerMesh || n.motionController.loadModel().then((function(e) {
var t;
e && n.motionController && n.motionController.rootMesh && (n._options.renderingGroupId && (n.motionController.rootMesh.renderingGroupId = n._options.renderingGroupId,
n.motionController.rootMesh.getChildMeshes(!1).forEach((function(e) {
return e.renderingGroupId = n._options.renderingGroupId
}
))),
n.onMeshLoadedObservable.notifyObservers(n.motionController.rootMesh),
n.motionController.rootMesh.parent = n.grip || n.pointer,
n.motionController.disableAnimation = !!n._options.disableMotionControllerAnimation),
n._disposed && (null === (t = n.motionController) || void 0 === t || t.dispose())
}
))
}
), (function() {
gi.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;
x.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 n = e.getPose(this.inputSource.targetRaySpace, t);
if (this._lastXRPose = n,
n) {
var r = n.transform.position;
this.pointer.position.set(r.x, r.y, r.z);
var o = n.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) {
r = a.transform.position;
var s = a.transform.orientation;
this.grip.position.set(r.x, r.y, r.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
}(), Fp = function() {
function e(e, t, i) {
void 0 === i && (i = {});
var n = this;
if (this.xrSessionManager = e,
this.xrCamera = t,
this._options = i,
this.controllers = [],
this.onControllerAddedObservable = new h,
this.onControllerRemovedObservable = new h,
this._onInputSourcesChange = function(e) {
n._addAndRemoveControllers(e.added, e.removed)
}
,
this._sessionEndedObserver = this.xrSessionManager.onXRSessionEnded.add((function() {
n._addAndRemoveControllers([], n.controllers.map((function(e) {
return e.inputSource
}
)))
}
)),
this._sessionInitObserver = this.xrSessionManager.onXRSessionInit.add((function(e) {
e.addEventListener("inputsourceschange", n._onInputSourcesChange)
}
)),
this._frameObserver = this.xrSessionManager.onXRFrameObservable.add((function(e) {
n.controllers.forEach((function(t) {
t.updateFromXRFrame(e, n.xrSessionManager.referenceSpace, n.xrCamera)
}
))
}
)),
this._options.customControllersRepositoryURL && (Ip.BaseRepositoryUrl = this._options.customControllersRepositoryURL),
Ip.UseOnlineRepository = !this._options.disableOnlineControllerRepository,
Ip.UseOnlineRepository)
try {
Ip.UpdateProfilesList().catch((function() {
Ip.UseOnlineRepository = !1
}
))
} catch (e) {
Ip.UseOnlineRepository = !1
}
}
return e.prototype._addAndRemoveControllers = function(e, t) {
for (var i = this, n = this.controllers.map((function(e) {
return e.inputSource
}
)), r = 0, o = e; r < o.length; r++) {
var a = o[r];
if (-1 === n.indexOf(a)) {
var s = new Lp(this.xrSessionManager.scene,a,V(V({}, 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(),
Ip.ClearControllerCache()
}
,
e
}(), wp = 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
}(), Bp = function(e) {
function t(i, n) {
var r = e.call(this, i) || this;
return r._options = n,
r._attachController = function(e) {
if (!r._controllers[e.uniqueId]) {
var i = r._generateNewMeshPair(e.pointer)
, n = i.laserPointer
, o = i.selectionMesh;
switch (r._controllers[e.uniqueId] = {
xrController: e,
laserPointer: n,
selectionMesh: o,
meshUnderPointer: null,
pick: null,
tmpRay: new _o(new x,new x),
disabledByNearInteraction: !1,
id: t._IdCounter++
},
r._attachedController ? !r._options.enablePointerSelectionOnAllControllers && r._options.preferredHandedness && e.inputSource.handedness === r._options.preferredHandedness && (r._attachedController = e.uniqueId) : r._options.enablePointerSelectionOnAllControllers || (r._attachedController = e.uniqueId),
e.inputSource.targetRayMode) {
case "tracked-pointer":
return r._attachTrackedPointerRayMode(e);
case "gaze":
return r._attachGazeMode(e);
case "screen":
return r._attachScreenRayMode(e)
}
}
}
,
r._controllers = {},
r._tmpVectorForPickCompare = new x,
r.disablePointerLighting = !0,
r.disableSelectionMeshLighting = !0,
r.displayLaserPointer = !0,
r.displaySelectionMesh = !0,
r.laserPointerPickedColor = new D(.9,.9,.9),
r.laserPointerDefaultColor = new D(.7,.7,.7),
r.selectionMeshDefaultColor = new D(.8,.8,.8),
r.selectionMeshPickedColor = new D(.3,.3,1),
r._identityMatrix = P.Identity(),
r._screenCoordinatesRef = x.Zero(),
r._viewportRef = new xr(0,0,0,0),
r._scene = r._xrSessionManager.scene,
r
}
return U(t, e),
t.prototype.attach = function() {
var i = 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) {
i._detachController(e.uniqueId)
}
)),
this._scene.constantlyUpdateMeshUnderPointer = !0,
this._options.gazeCamera) {
var n = this._options.gazeCamera
, r = this._generateNewMeshPair(n)
, o = r.laserPointer
, a = r.selectionMesh;
this._controllers.camera = {
webXRCamera: n,
laserPointer: o,
selectionMesh: a,
meshUnderPointer: null,
pick: null,
tmpRay: new _o(new x,new x),
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), n = 0; n < i.length; ++n)
if (this._controllers[i[n]].id === e)
return void (this._controllers[i[n]].disabledByNearInteraction = t)
}
,
t.prototype._onXRFrame = function(e) {
var t = this;
Object.keys(this._controllers).forEach((function(e) {
var i, n = t._controllers[e];
if (!t._options.enablePointerSelectionOnAllControllers && e !== t._attachedController || n.disabledByNearInteraction)
return n.selectionMesh.isVisible = !1,
n.laserPointer.isVisible = !1,
void (n.pick = null);
if (n.laserPointer.isVisible = t.displayLaserPointer,
n.xrController)
i = n.xrController.pointer.position,
n.xrController.getWorldPointerRayToRef(n.tmpRay);
else {
if (!n.webXRCamera)
return;
i = n.webXRCamera.position,
n.webXRCamera.getForwardRayToRef(n.tmpRay)
}
if (t._options.maxPointerDistance && (n.tmpRay.length = t._options.maxPointerDistance),
!t._options.disableScenePointerVectorUpdate && i) {
var r = t._xrSessionManager.scene
, o = t._options.xrInput.xrCamera;
o && (o.viewport.toGlobalToRef(r.getEngine().getRenderWidth(), r.getEngine().getRenderHeight(), t._viewportRef),
x.ProjectToRef(i, t._identityMatrix, r.getTransformMatrix(), t._viewportRef, t._screenCoordinatesRef),
"number" != typeof t._screenCoordinatesRef.x || "number" != typeof t._screenCoordinatesRef.y || isNaN(t._screenCoordinatesRef.x) || isNaN(t._screenCoordinatesRef.y) || (r.pointerX = t._screenCoordinatesRef.x,
r.pointerY = t._screenCoordinatesRef.y,
n.screenCoordinates = {
x: t._screenCoordinatesRef.x,
y: t._screenCoordinatesRef.y
}))
}
var a = null;
t._utilityLayerScene && (a = t._utilityLayerScene.pickWithRay(n.tmpRay, t._utilityLayerScene.pointerMovePredicate || t.raySelectionPredicate));
var s = t._scene.pickWithRay(n.tmpRay, t._scene.pointerMovePredicate || t.raySelectionPredicate);
a && a.hit ? s && s.hit ? a.distance < s.distance ? n.pick = a : n.pick = s : n.pick = a : n.pick = s,
n.pick && n.xrController && (n.pick.aimTransform = n.xrController.pointer,
n.pick.gripTransform = n.xrController.grip || null);
var l = n.pick;
if (l && l.pickedPoint && l.hit) {
t._updatePointerDistance(n.laserPointer, l.distance),
n.selectionMesh.position.copyFrom(l.pickedPoint),
n.selectionMesh.scaling.x = Math.sqrt(l.distance),
n.selectionMesh.scaling.y = Math.sqrt(l.distance),
n.selectionMesh.scaling.z = Math.sqrt(l.distance);
var c = t._convertNormalToDirectionOfRay(l.getNormal(!0), n.tmpRay);
if (n.selectionMesh.position.copyFrom(l.pickedPoint),
c) {
var u = x.Cross(vn.Y, c)
, h = x.Cross(c, u);
x.RotationFromAxisToRef(h, c, u, n.selectionMesh.rotation),
n.selectionMesh.position.addInPlace(c.scale(.001))
}
n.selectionMesh.isVisible = t.displaySelectionMesh,
n.meshUnderPointer = l.pickedMesh
} else
n.selectionMesh.isVisible = !1,
t._updatePointerDistance(n.laserPointer, 1),
n.meshUnderPointer = null
}
))
}
,
Object.defineProperty(t.prototype, "_utilityLayerScene", {
get: function() {
return this._options.customUtilityLayerScene || El.DefaultUtilityLayer.utilityLayerScene
},
enumerable: !1,
configurable: !0
}),
t.prototype._attachGazeMode = function(e) {
var t = this
, i = this._controllers[e && e.uniqueId || "camera"]
, n = this._options.timeToSelect || 3e3
, r = this._options.useUtilityLayer ? this._utilityLayerScene : this._scene
, o = new Ui
, a = qs("selection", {
diameter: .0525,
thickness: .015,
tessellation: 20
}, r);
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 > n / 10 && (a.isVisible = !0),
(s += t._scene.getEngine().getDeltaTime()) >= n)
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 / n;
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]
, n = !1
, r = {
pointerId: i.id,
pointerType: "xr"
};
i.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add((function() {
t._augmentPointerInit(r, i.id, i.screenCoordinates),
!i.pick || t._options.disablePointerUpOnTouchOut && n || (n ? t._scene.simulatePointerMove(i.pick, r) : (t._scene.simulatePointerDown(i.pick, r),
i.pointerDownTriggered = !0,
n = !0,
t._options.disablePointerUpOnTouchOut && t._scene.simulatePointerUp(i.pick, r)))
}
)),
e.onDisposeObservable.addOnce((function() {
t._augmentPointerInit(r, i.id, i.screenCoordinates),
t._xrSessionManager.runInXRFrame((function() {
i.pick && !i.finalPointerUpTriggered && n && !t._options.disablePointerUpOnTouchOut && (t._scene.simulatePointerUp(i.pick, r),
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 n = {
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(n, i.id, i.screenCoordinates),
t._scene.simulatePointerMove(i.pick, n))
}
)),
e.inputSource.gamepad) {
var r = function(r) {
t._options.overrideButtonId && (i.selectionComponent = r.getComponent(t._options.overrideButtonId)),
i.selectionComponent || (i.selectionComponent = r.getMainComponent()),
i.onButtonChangedObserver = i.selectionComponent.onButtonStateChangedObservable.add((function(r) {
if (r.changes.pressed) {
var o = r.changes.pressed.current;
i.pick ? (t._options.enablePointerSelectionOnAllControllers || e.uniqueId === t._attachedController) && (t._augmentPointerInit(n, i.id, i.screenCoordinates),
o ? (t._scene.simulatePointerDown(i.pick, n),
i.pointerDownTriggered = !0,
i.selectionMesh.material.emissiveColor = t.selectionMeshPickedColor,
i.laserPointer.material.emissiveColor = t.laserPointerPickedColor) : (t._scene.simulatePointerUp(i.pick, n),
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 ? r(e.motionController) : e.onMotionControllerInitObservable.add(r)
} else {
var o = function(e) {
t._augmentPointerInit(n, i.id, i.screenCoordinates),
i.xrController && e.inputSource === i.xrController.inputSource && i.pick && (t._scene.simulatePointerDown(i.pick, n),
i.pointerDownTriggered = !0,
i.selectionMesh.material.emissiveColor = t.selectionMeshPickedColor,
i.laserPointer.material.emissiveColor = t.laserPointerPickedColor)
}
, a = function(e) {
t._augmentPointerInit(n, i.id, i.screenCoordinates),
i.xrController && e.inputSource === i.xrController.inputSource && i.pick && (t._scene.simulatePointerUp(i.pick, n),
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(x.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 n = i.eventListeners && i.eventListeners[e];
n && t._xrSessionManager.session.removeEventListener(e, n)
}
)),
!i.finalPointerUpTriggered && i.pointerDownTriggered) {
var n = {
pointerId: i.id,
pointerType: "xr"
};
this._xrSessionManager.runInXRFrame((function() {
t._augmentPointerInit(n, i.id, i.screenCoordinates),
t._scene.simulatePointerUp(new Ui, n)
}
))
}
this._xrSessionManager.scene.onBeforeRenderObservable.addOnce((function() {
try {
if (i.selectionMesh.dispose(),
i.laserPointer.dispose(),
delete t._controllers[e],
t._attachedController === e) {
var n = Object.keys(t._controllers);
n.length ? t._attachedController = n[0] : t._attachedController = ""
}
} catch (e) {
gi.Warn("controller already detached.")
}
}
))
}
}
,
t.prototype._generateNewMeshPair = function(e) {
var t = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || El.DefaultUtilityLayer.utilityLayerScene : this._scene
, i = this._options.customLasterPointerMeshGenerator ? this._options.customLasterPointerMeshGenerator() : Ys("laserPointer", {
height: 1,
diameterTop: 2e-4,
diameterBottom: .004,
tessellation: 20,
subdivisions: 1
}, t);
i.parent = e;
var n = new Os("laserPointerMat",t);
n.emissiveColor = this.laserPointerDefaultColor,
n.alpha = .7,
i.material = n,
i.rotation.x = Math.PI / 2,
this._updatePointerDistance(i, 1),
i.isPickable = !1,
i.isVisible = !1;
var r = this._options.customSelectionMeshGenerator ? this._options.customSelectionMeshGenerator() : qs("gazeTracker", {
diameter: .0105,
thickness: .0075,
tessellation: 20
}, t);
r.bakeCurrentTransformIntoVertices(),
r.isPickable = !1,
r.isVisible = !1;
var o = new Os("targetMat",t);
return o.specularColor = D.Black(),
o.emissiveColor = this.selectionMeshDefaultColor,
o.backFaceCulling = !1,
r.material = o,
void 0 !== this._options.renderingGroupId && (i.renderingGroupId = this._options.renderingGroupId,
r.renderingGroupId = this._options.renderingGroupId),
{
laserPointer: i,
selectionMesh: r
}
}
,
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 n = .01 * (this._options.gazeModePointerMovedFactor || 1) * t.distance;
return this._tmpVectorForPickCompare.length() > n
}
,
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 = Io.POINTER_SELECTION,
t.Version = 1,
t
}(wp);
Oo.AddWebXRFeature(Bp.Name, (function(e, t) {
return function() {
return new Bp(e,t)
}
}
), Bp.Version, !0),
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"
}(Op || (Op = {})),
function(e) {
e[e.Vertex = 1] = "Vertex",
e[e.Fragment = 2] = "Fragment",
e[e.Neutral = 4] = "Neutral",
e[e.VertexAndFragment = 3] = "VertexAndFragment"
}(Dp || (Dp = {}));
var Up, Vp, kp = 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 === Dp.Fragment;
this.compilationString = "\r\n".concat(t ? "//Entry point\r\n" : "", "void main(void) {\r\n").concat(this.compilationString),
this._constantDeclaration && (this.compilationString = "\r\n".concat(t ? "//Constants\r\n" : "").concat(this._constantDeclaration, "\r\n").concat(this.compilationString));
var n = "";
for (var r in this.functions)
n += this.functions[r] + "\r\n";
for (var o in this.compilationString = "\r\n".concat(n, "\r\n").concat(this.compilationString),
!i && this._varyingTransfer && (this.compilationString = "".concat(this.compilationString, "\r\n").concat(this._varyingTransfer)),
this._injectAtEnd && (this.compilationString = "".concat(this.compilationString, "\r\n").concat(this._injectAtEnd)),
this.compilationString = "".concat(this.compilationString, "\r\n}"),
this.sharedData.varyingDeclaration && (this.compilationString = "\r\n".concat(t ? "//Varyings\r\n" : "").concat(this.sharedData.varyingDeclaration, "\r\n").concat(this.compilationString)),
this._samplerDeclaration && (this.compilationString = "\r\n".concat(t ? "//Samplers\r\n" : "").concat(this._samplerDeclaration, "\r\n").concat(this.compilationString)),
this._uniformDeclaration && (this.compilationString = "\r\n".concat(t ? "//Uniforms\r\n" : "").concat(this._uniformDeclaration, "\r\n").concat(this.compilationString)),
this._attributeDeclaration && !i && (this.compilationString = "\r\n".concat(t ? "//Attributes\r\n" : "").concat(this._attributeDeclaration, "\r\n").concat(this.compilationString)),
this.compilationString = "precision highp float;\r\n" + this.compilationString,
this.extensions) {
var a = this.extensions[o];
this.compilationString = "\r\n".concat(a, "\r\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, ";\r\n"),
this.samplers.push(e))
}
,
e.prototype._getGLType = function(e) {
switch (e) {
case Op.Float:
return "float";
case Op.Int:
return "int";
case Op.Vector2:
return "vec2";
case Op.Color3:
case Op.Vector3:
return "vec3";
case Op.Color4:
case Op.Vector4:
return "vec4";
case Op.Matrix:
return "mat4"
}
return ""
}
,
e.prototype._emitExtension = function(e, t, i) {
void 0 === i && (i = ""),
this.extensions[e] || (i && (t = "#if ".concat(i, "\r\n").concat(t, "\r\n#endif")),
this.extensions[e] = t)
}
,
e.prototype._emitFunction = function(e, t, i) {
this.functions[e] || (this.sharedData.emitComments && (t = i + "\r\n" + t),
this.functions[e] = t)
}
,
e.prototype._emitCodeFromInclude = function(e, t, i) {
if (i && i.repeatKey)
return "#include<".concat(e, ">[0..").concat(i.repeatKey, "]\r\n");
var n = Mt.IncludesShadersStore[e] + "\r\n";
if (this.sharedData.emitComments && (n = t + "\r\n" + n),
!i)
return n;
if (i.replaceStrings)
for (var r = 0; r < i.replaceStrings.length; r++) {
var o = i.replaceStrings[r];
n = n.replace(o.search, o.replace)
}
return n
}
,
e.prototype._emitFunctionFromInclude = function(e, t, i, n) {
void 0 === n && (n = "");
var r = e + n;
if (!this.functions[r]) {
if (!i || !(i.removeAttributes || i.removeUniforms || i.removeVaryings || i.removeIfDef || i.replaceStrings))
return i && i.repeatKey ? this.functions[r] = "#include<".concat(e, ">[0..").concat(i.repeatKey, "]\r\n") : this.functions[r] = "#include<".concat(e, ">\r\n"),
void (this.sharedData.emitComments && (this.functions[r] = t + "\r\n" + this.functions[r]));
if (this.functions[r] = Mt.IncludesShadersStore[e],
this.sharedData.emitComments && (this.functions[r] = t + "\r\n" + this.functions[r]),
i.removeIfDef && (this.functions[r] = this.functions[r].replace(/^\s*?#ifdef.+$/gm, ""),
this.functions[r] = this.functions[r].replace(/^\s*?#endif.*$/gm, ""),
this.functions[r] = this.functions[r].replace(/^\s*?#else.*$/gm, ""),
this.functions[r] = this.functions[r].replace(/^\s*?#elif.*$/gm, "")),
i.removeAttributes && (this.functions[r] = this.functions[r].replace(/^\s*?attribute.+$/gm, "")),
i.removeUniforms && (this.functions[r] = this.functions[r].replace(/^\s*?uniform.+$/gm, "")),
i.removeVaryings && (this.functions[r] = this.functions[r].replace(/^\s*?varying.+$/gm, "")),
i.replaceStrings)
for (var o = 0; o < i.replaceStrings.length; o++) {
var a = i.replaceStrings[o];
this.functions[r] = this.functions[r].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, n) {
return void 0 === i && (i = ""),
void 0 === n && (n = !1),
-1 === this.sharedData.varyings.indexOf(e) && (this.sharedData.varyings.push(e),
i && (ae(i, "defined(") ? this.sharedData.varyingDeclaration += "#if ".concat(i, "\r\n") : this.sharedData.varyingDeclaration += "".concat(n ? "#ifndef" : "#ifdef", " ").concat(i, "\r\n")),
this.sharedData.varyingDeclaration += "varying ".concat(t, " ").concat(e, ";\r\n"),
i && (this.sharedData.varyingDeclaration += "#endif\r\n"),
!0)
}
,
e.prototype._emitUniformFromString = function(e, t, i, n) {
void 0 === i && (i = ""),
void 0 === n && (n = !1),
-1 === this.uniforms.indexOf(e) && (this.uniforms.push(e),
i && (ae(i, "defined(") ? this._uniformDeclaration += "#if ".concat(i, "\r\n") : this._uniformDeclaration += "".concat(n ? "#ifndef" : "#ifdef", " ").concat(i, "\r\n")),
this._uniformDeclaration += "uniform ".concat(t, " ").concat(e, ";\r\n"),
i && (this._uniformDeclaration += "#endif\r\n"))
}
,
e.prototype._emitFloat = function(e) {
return e.toString() === e.toFixed(0) ? "".concat(e, ".0") : e.toString()
}
,
e
}(), Gp = 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.\r\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.\r\n");
for (var t = 0, i = this.checks.notConnectedNonOptionalInputs; t < i.length; t++) {
var n = i[t];
e += "input ".concat(n.name, " from block ").concat(n.ownerBlock.name, "[").concat(n.ownerBlock.getClassName(), "] is not connected and is not optional.\r\n")
}
if (e)
throw "Build of NodeMaterial failed:\r\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"
}(Up || (Up = {})),
function(e) {
e[e.Input = 0] = "Input",
e[e.Output = 1] = "Output"
}(Vp || (Vp = {}));
var zp = 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 = Op.Float,
this._enforceAssociatedVariableName = !1,
this.needDualDirectionValidation = !1,
this.acceptedConnectionPointTypes = new Array,
this.excludedConnectionPointTypes = new Array,
this.onConnectionObservable = new h,
this.isExposedOnFrame = !1,
this.exposedPortPosition = -1,
this._prioritizeVertex = !1,
this._target = Dp.VertexAndFragment,
this._ownerBlock = t,
this.name = e,
this._direction = i
}
return e.AreEquivalentTypes = function(e, t) {
switch (e) {
case Op.Vector3:
if (t === Op.Color3)
return !0;
break;
case Op.Vector4:
if (t === Op.Color4)
return !0;
break;
case Op.Color3:
if (t === Op.Vector3)
return !0;
break;
case Op.Color4:
if (t === Op.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 === Op.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 === Op.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 !== Dp.VertexAndFragment ? this._target : this._ownerBlock.target === Dp.Fragment ? Dp.Fragment : Dp.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 === Dp.Vertex)
return !0;
if ((i.ownerBlock.target === Dp.Neutral || i.ownerBlock.target === Dp.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 === Dp.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 === Dp.Vertex)
return !0;
if (i.target === Dp.Vertex)
return !0;
if ((i.ownerBlock.target === Dp.Neutral || i.ownerBlock.target === Dp.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 === Dp.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 === Dp.Fragment)
return !0;
if ((i.ownerBlock.target === Dp.Neutral || i.ownerBlock.target === Dp.VertexAndFragment) && i.ownerBlock.outputs.some((function(e) {
return e.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) === Up.Compatible
}
,
e.prototype.checkCompatibilityState = function(t) {
var i = this._ownerBlock
, n = t.ownerBlock;
if (i.target === Dp.Fragment) {
if (n.target === Dp.Vertex)
return Up.TargetIncompatible;
for (var r = 0, o = n.outputs; r < o.length; r++) {
var a = o[r];
if (a.ownerBlock.target != Dp.Neutral && a.isConnectedInVertexShader)
return Up.TargetIncompatible
}
}
if (this.type !== t.type && t.innerType !== Op.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) ? Up.Compatible : Up.TypeIncompatible;
if (t.excludedConnectionPointTypes && -1 !== t.excludedConnectionPointTypes.indexOf(this.type))
return Up.TypeIncompatible;
var s = n
, l = i;
return this.direction === Vp.Input && (s = i,
l = n),
s.isAnAncestorOf(l) ? Up.HierarchyIssue : Up.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.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
}()
, Wp = function() {
function e(e, t, i, n) {
void 0 === t && (t = Dp.Vertex),
void 0 === i && (i = !1),
void 0 === n && (n = !1),
this._isFinalMerger = !1,
this._isInput = !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 === Dp.Neutral,
this._isFinalMerger = i,
this._isInput = n,
this._name = e,
this.uniqueId = pn.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, "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.initialize = function(e) {}
,
e.prototype.bind = function(e, t, i, n) {}
,
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.registerInput = function(e, t, i, n, r) {
return void 0 === i && (i = !1),
(r = null != r ? r : new zp(e,this,Vp.Input)).type = t,
r.isOptional = i,
n && (r.target = n),
this._inputs.push(r),
this
}
,
e.prototype.registerOutput = function(e, t, i, n) {
return (n = null != n ? n : new zp(e,this,Vp.Output)).type = t,
i && (n.target = i),
this._outputs.push(n),
this
}
,
e.prototype.getFirstAvailableInput = function(e) {
void 0 === e && (e = null);
for (var t = 0, i = this._inputs; t < i.length; t++) {
var n = i[t];
if (!(n.connectedPoint || e && e.type !== n.type && n.type !== Op.AutoDetect))
return n
}
return null
}
,
e.prototype.getFirstAvailableOutput = function(e) {
void 0 === e && (e = null);
for (var t = 0, i = this._outputs; t < i.length; t++) {
var n = i[t];
if (!e || !e.target || e.target === Dp.Neutral || 0 != (e.target & n.target))
return n
}
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 n = i[t];
if (n.hasEndpoints)
for (var r = 0, o = n.endpoints; r < o.length; r++) {
var a = o[r];
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), n = !0; n; ) {
var r = t && t.input ? e.getInputByName(t.input) : e.getFirstAvailableInput(i);
if (i && r && i.canConnectTo(r))
i.connectTo(r),
n = !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, n) {}
,
e.prototype.provideFallbacks = function(e, t) {}
,
e.prototype.initializeDefines = function(e, t, i, n) {
void 0 === n && (n = !1)
}
,
e.prototype.prepareDefines = function(e, t, i, n, r) {
void 0 === n && (n = !1)
}
,
e.prototype.autoConfigure = function(e) {}
,
e.prototype.replaceRepeatableContent = function(e, t, i, n) {}
,
Object.defineProperty(e.prototype, "willBeGeneratedIntoVertexShaderFromFragmentShader", {
get: function() {
return !(this.isInput || this.isFinalMerger || this._outputs.some((function(e) {
return e.isDirectlyConnectedToVertexOutput
}
)) || this.target === Dp.Vertex || this.target !== Dp.VertexAndFragment && this.target !== Dp.Neutral || !this._outputs.some((function(e) {
return e.isConnectedInVertexShader
}
)))
},
enumerable: !1,
configurable: !0
}),
e.prototype.isReady = function(e, t, i, n) {
return void 0 === n && (n = !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, n) {
e.build(t, n);
var r = null != t._vertexState
, o = e._buildTarget === Dp.Vertex && e.target !== Dp.VertexAndFragment;
if (r && (0 == (e.target & e._buildTarget) || 0 == (e.target & i.target) || this.target !== Dp.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, ";\r\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.build = function(e, t) {
if (this._buildId === e.sharedData.buildId)
return !0;
if (!this.isInput)
for (var i = 0, n = this._outputs; i < n.length; i++)
(c = n[i]).associatedVariableName || (c.associatedVariableName = e._getFreeVariableName(c.name));
for (var r = 0, o = this._inputs; r < o.length; r++) {
var a = o[r];
if (a.connectedPoint) {
if (this.target !== Dp.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._buildId === e.sharedData.buildId)
return !0;
if (e.sharedData.verbose && console.log("".concat(e.target === Dp.Vertex ? "Vertex shader" : "Fragment shader", ": Building ").concat(this.name, " [").concat(this.getClassName(), "]")),
this.isFinalMerger)
switch (e.target) {
case Dp.Vertex:
e.sharedData.checks.emitVertex = !0;
break;
case Dp.Fragment:
e.sharedData.checks.emitFragment = !0
}
!this.isInput && e.sharedData.emitComments && (e.compilationString += "\r\n//".concat(this.name, "\r\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, ";\r\n").concat(e, ".visibleOnFrame = ").concat(this.visibleOnFrame, ";\r\n").concat(e, ".target = ").concat(this.target, ";\r\n")
}
,
e.prototype._dumpCode = function(e, t) {
var i;
t.push(this);
var n = this.name.replace(/[^A-Za-z_]+/g, "");
if (this._codeVariableName = n || "".concat(this.getClassName(), "_").concat(this.uniqueId),
-1 !== e.indexOf(this._codeVariableName)) {
var r = 0;
do {
r++,
this._codeVariableName = n + r
} while (-1 !== e.indexOf(this._codeVariableName))
}
e.push(this._codeVariableName),
i = "\r\n// ".concat(this.getClassName(), "\r\n"),
this.comments && (i += "// ".concat(this.comments, "\r\n")),
i += "var ".concat(this._codeVariableName, " = new BABYLON.").concat(this.getClassName(), '("').concat(this.name, '");\r\n'),
i += 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) && (i += 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) && (i += l._dumpCode(e, t))
}
return i
}
,
e.prototype._dumpCodeForOutputConnections = function(e) {
var t = "";
if (-1 !== e.indexOf(this))
return t;
e.push(this);
for (var i = 0, n = this.inputs; i < n.length; i++) {
var r = n[i];
if (r.isConnected) {
var o = r.connectedPoint
, a = o.ownerBlock;
t += a._dumpCodeForOutputConnections(e),
t += "".concat(a._codeVariableName, ".").concat(a._outputRename(o.name), ".connectTo(").concat(this._codeVariableName, ".").concat(this._inputRename(r.name), ");\r\n")
}
}
return t
}
,
e.prototype.clone = function(e, t) {
void 0 === t && (t = "");
var i = this.serialize()
, n = b(i.customType);
if (n) {
var r = new n;
return r._deserialize(i, e, t),
r
}
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 n = i[t];
e.inputs.push(n.serialize())
}
for (var r = 0, o = this.outputs; r < o.length; r++) {
var a = o[r];
e.outputs.push(a.serialize(!1))
}
return e
}
,
e.prototype._deserialize = function(e, t, i) {
var n;
this.name = e.name,
this.comments = e.comments,
this.visibleInInspector = !!e.visibleInInspector,
this.visibleOnFrame = !!e.visibleOnFrame,
this._target = null !== (n = e.target) && void 0 !== n ? n : this.target,
this._deserializePortDisplayNamesAndExposedOnFrame(e)
}
,
e.prototype._deserializePortDisplayNamesAndExposedOnFrame = function(e) {
var t = this
, i = e.inputs
, n = 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)
}
)),
n && n.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, n = this.outputs; i < n.length; i++)
n[i].dispose()
}
,
e
}()
, Hp = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.complementW = 1,
i.complementZ = 0,
i.target = Dp.Vertex,
i.registerInput("vector", Op.AutoDetect),
i.registerInput("transform", Op.Matrix),
i.registerOutput("output", Op.Vector4),
i.registerOutput("xyz", Op.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 U(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
, n = this.transform;
if (i.connectedPoint) {
if (0 === this.complementW) {
var r = "//".concat(this.name);
t._emitFunctionFromInclude("helperFunctions", r),
t.sharedData.blocksWithDefines.push(this);
var o = t._getFreeVariableName("".concat(n.associatedVariableName, "_NUS"));
switch (t.compilationString += "mat3 ".concat(o, " = mat3(").concat(n.associatedVariableName, ");\r\n"),
t.compilationString += "#ifdef NONUNIFORMSCALING\r\n",
t.compilationString += "".concat(o, " = transposeMat3(inverseMat3(").concat(o, "));\r\n"),
t.compilationString += "#endif\r\n",
i.connectedPoint.type) {
case Op.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), ");\r\n");
break;
case Op.Vector3:
case Op.Color3:
t.compilationString += this._declareOutput(this.output, t) + " = vec4(".concat(o, " * ").concat(i.associatedVariableName, ", ").concat(this._writeFloat(this.complementW), ");\r\n");
break;
default:
t.compilationString += this._declareOutput(this.output, t) + " = vec4(".concat(o, " * ").concat(i.associatedVariableName, ".xyz, ").concat(this._writeFloat(this.complementW), ");\r\n")
}
} else
switch (o = n.associatedVariableName,
i.connectedPoint.type) {
case Op.Vector2:
t.compilationString += this._declareOutput(this.output, t) + " = ".concat(o, " * vec4(").concat(i.associatedVariableName, ", ").concat(this._writeFloat(this.complementZ), ", ").concat(this._writeFloat(this.complementW), ");\r\n");
break;
case Op.Vector3:
case Op.Color3:
t.compilationString += this._declareOutput(this.output, t) + " = ".concat(o, " * vec4(").concat(i.associatedVariableName, ", ").concat(this._writeFloat(this.complementW), ");\r\n");
break;
default:
t.compilationString += this._declareOutput(this.output, t) + " = ".concat(o, " * ").concat(i.associatedVariableName, ";\r\n")
}
this.xyz.hasEndpoints && (t.compilationString += this._declareOutput(this.xyz, t) + " = ".concat(this.output.associatedVariableName, ".xyz;\r\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, n) {
e.prototype._deserialize.call(this, t, i, n),
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, ";\r\n") + "".concat(this._codeVariableName, ".complementW = ").concat(this.complementW, ";\r\n")
}
,
t
}(Wp);
y("BABYLON.TransformBlock", Hp);
var Xp, jp = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Vertex, !0) || this;
return i.registerInput("vector", Op.Vector4),
i
}
return U(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, ";\r\n"),
this._isLogarithmicDepthEnabled(t.sharedData.fragmentOutputNodes) && (t._emitUniformFromString("logarithmicDepthConstant", "float"),
t._emitVaryingFromString("vFragmentDepth", "float"),
t.compilationString += "vFragmentDepth = 1.0 + gl_Position.w;\r\n",
t.compilationString += "gl_Position.z = log2(max(0.000001, vFragmentDepth)) * logarithmicDepthConstant;\r\n"),
this
}
,
t
}(Wp);
function Yp(e, t, i, n) {
return void 0 === t && (t = Xp.Boolean),
void 0 === i && (i = "PROPERTIES"),
function(r, o) {
var a = r._propStore;
a || (a = [],
r._propStore = a),
a.push({
propertyName: o,
displayName: e,
type: t,
groupName: i,
options: null != n ? n : {}
})
}
}
y("BABYLON.VertexOutputBlock", jp),
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"
}(Xp || (Xp = {}));
var Kp, Qp, qp, Zp = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Fragment, !0) || this;
return i.convertToGammaSpace = !1,
i.convertToLinearSpace = !1,
i.useLogarithmicDepth = !1,
i.registerInput("rgba", Op.Color4, !0),
i.registerInput("rgb", Op.Color3, !0),
i.registerInput("a", Op.Float, !0),
i.rgb.acceptedConnectionPointTypes.push(Op.Float),
i
}
return U(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 && Mr.BindLogDepth(void 0, e, i.getScene())
}
,
t.prototype._buildBlock = function(t) {
e.prototype._buildBlock.call(this, t);
var i = this.rgba
, n = this.rgb
, r = this.a;
t.sharedData.hints.needAlphaBlending = i.isConnected || r.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)
r.isConnected ? t.compilationString += "gl_FragColor = vec4(".concat(i.associatedVariableName, ".rgb, ").concat(r.associatedVariableName, ");\r\n") : t.compilationString += "gl_FragColor = ".concat(i.associatedVariableName, ";\r\n");
else if (n.connectedPoint) {
var a = "1.0";
r.connectedPoint && (a = r.associatedVariableName),
n.connectedPoint.type === Op.Float ? t.compilationString += "gl_FragColor = vec4(".concat(n.associatedVariableName, ", ").concat(n.associatedVariableName, ", ").concat(n.associatedVariableName, ", ").concat(a, ");\r\n") : t.compilationString += "gl_FragColor = vec4(".concat(n.associatedVariableName, ", ").concat(a, ");\r\n")
} else
t.sharedData.checks.notConnectedNonOptionalInputs.push(i);
return t.compilationString += "#ifdef ".concat(this._linearDefineName, "\r\n"),
t.compilationString += "gl_FragColor = toLinearSpace(gl_FragColor);\r\n",
t.compilationString += "#endif\r\n",
t.compilationString += "#ifdef ".concat(this._gammaDefineName, "\r\n"),
t.compilationString += "gl_FragColor = toGammaSpace(gl_FragColor);\r\n",
t.compilationString += "#endif\r\n",
this.useLogarithmicDepth && (t.compilationString += "gl_FragDepthEXT = log2(vFragmentDepth) * logarithmicDepthConstant * 0.5;\r\n"),
this
}
,
t.prototype._dumpPropertiesCode = function() {
var t = e.prototype._dumpPropertiesCode.call(this);
return t += "".concat(this._codeVariableName, ".convertToGammaSpace = ").concat(this.convertToGammaSpace, ";\r\n"),
(t += "".concat(this._codeVariableName, ".convertToLinearSpace = ").concat(this.convertToLinearSpace, ";\r\n")) + "".concat(this._codeVariableName, ".useLogarithmicDepth = ").concat(this.useLogarithmicDepth, ";\r\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, n) {
var r;
e.prototype._deserialize.call(this, t, i, n),
this.convertToGammaSpace = t.convertToGammaSpace,
this.convertToLinearSpace = t.convertToLinearSpace,
this.useLogarithmicDepth = null !== (r = t.useLogarithmicDepth) && void 0 !== r && r
}
,
k([Yp("Convert to gamma space", Xp.Boolean, "PROPERTIES", {
notifiers: {
update: !0
}
})], t.prototype, "convertToGammaSpace", void 0),
k([Yp("Convert to linear space", Xp.Boolean, "PROPERTIES", {
notifiers: {
update: !0
}
})], t.prototype, "convertToLinearSpace", void 0),
k([Yp("Use logarithmic depth", Xp.Boolean, "PROPERTIES")], t.prototype, "useLogarithmicDepth", void 0),
t
}(Wp);
y("BABYLON.FragmentOutputBlock", Zp),
function(e) {
e[e.Uniform = 0] = "Uniform",
e[e.Attribute = 1] = "Attribute",
e[e.Varying = 2] = "Varying",
e[e.Undefined = 3] = "Undefined"
}(Kp || (Kp = {})),
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"
}(Qp || (Qp = {})),
function(e) {
e[e.None = 0] = "None",
e[e.Time = 1] = "Time"
}(qp || (qp = {}));
var Jp = {
position2d: "position",
particle_uv: "vUV",
particle_color: "vColor",
particle_texturemask: "textureMask",
particle_positionw: "vPositionW"
}
, $p = {
particle_uv: !0,
particle_color: !0,
particle_texturemask: !0,
particle_positionw: !0
}
, ef = {
particle_texturemask: !0
}
, tf = function(e) {
function t(t, i, n) {
void 0 === i && (i = Dp.Vertex),
void 0 === n && (n = Op.AutoDetect);
var r = e.call(this, t, i, !1, !0) || this;
return r._mode = Kp.Undefined,
r._animationType = qp.None,
r.min = 0,
r.max = 0,
r.isBoolean = !1,
r.matrixMode = 0,
r._systemValue = null,
r.isConstant = !1,
r.groupInInspector = "",
r.onValueChangedObservable = new h,
r.convertToGammaSpace = !1,
r.convertToLinearSpace = !1,
r._type = n,
r.setDefaultValue(),
r.registerOutput("output", n),
r
}
return U(t, e),
Object.defineProperty(t.prototype, "type", {
get: function() {
if (this._type === Op.AutoDetect) {
if (this.isUniform && null != this.value) {
if (!isNaN(this.value))
return this._type = Op.Float,
this._type;
switch (this.value.getClassName()) {
case "Vector2":
return this._type = Op.Vector2,
this._type;
case "Vector3":
return this._type = Op.Vector3,
this._type;
case "Vector4":
return this._type = Op.Vector4,
this._type;
case "Color3":
return this._type = Op.Color3,
this._type;
case "Color4":
return this._type = Op.Color4,
this._type;
case "Matrix":
return this._type = Op.Matrix,
this._type
}
}
if (this.isAttribute)
switch (this.name) {
case "position":
case "normal":
case "tangent":
case "particle_positionw":
return this._type = Op.Vector3,
this._type;
case "uv":
case "uv2":
case "uv3":
case "uv4":
case "uv5":
case "uv6":
case "position2d":
case "particle_uv":
return this._type = Op.Vector2,
this._type;
case "matricesIndices":
case "matricesWeights":
case "world0":
case "world1":
case "world2":
case "world3":
return this._type = Op.Vector4,
this._type;
case "color":
case "particle_color":
case "particle_texturemask":
return this._type = Op.Color4,
this._type
}
if (this.isSystemValue)
switch (this._systemValue) {
case Qp.World:
case Qp.WorldView:
case Qp.WorldViewProjection:
case Qp.View:
case Qp.ViewProjection:
case Qp.Projection:
return this._type = Op.Matrix,
this._type;
case Qp.CameraPosition:
return this._type = Op.Vector3,
this._type;
case Qp.FogColor:
return this._type = Op.Color3,
this._type;
case Qp.DeltaTime:
case Qp.MaterialAlpha:
return this._type = Op.Float,
this._type;
case Qp.CameraParameters:
return this._type = Op.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 = Kp.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 === Op.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 = Kp.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 = Kp.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 === Kp.Undefined
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "isUniform", {
get: function() {
return this._mode === Kp.Uniform
},
set: function(e) {
this._mode = e ? Kp.Uniform : Kp.Undefined,
this.associatedVariableName = ""
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "isAttribute", {
get: function() {
return this._mode === Kp.Attribute
},
set: function(e) {
this._mode = e ? Kp.Attribute : Kp.Undefined,
this.associatedVariableName = ""
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "isVarying", {
get: function() {
return this._mode === Kp.Varying
},
set: function(e) {
this._mode = e ? Kp.Varying : Kp.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 = Kp.Uniform,
this.associatedVariableName = "",
this._systemValue = e
},
enumerable: !1,
configurable: !0
}),
t.prototype.getClassName = function() {
return "InputBlock"
}
,
t.prototype.animate = function(e) {
this._animationType === qp.Time && this.type === Op.Float && (this.value += .01 * e.getAnimationRatio())
}
,
t.prototype._emitDefine = function(e) {
return "!" === e[0] ? "#ifndef ".concat(e.substring(1), "\r\n") : "#ifdef ".concat(e, "\r\n")
}
,
t.prototype.initialize = function() {
this.associatedVariableName = ""
}
,
t.prototype.setDefaultValue = function() {
switch (this.type) {
case Op.Float:
this.value = 0;
break;
case Op.Vector2:
this.value = A.Zero();
break;
case Op.Vector3:
this.value = x.Zero();
break;
case Op.Vector4:
this.value = R.Zero();
break;
case Op.Color3:
this.value = D.White();
break;
case Op.Color4:
this.value = new N(1,1,1,1);
break;
case Op.Matrix:
this.value = P.Identity()
}
}
,
t.prototype._emitConstant = function(e) {
switch (this.type) {
case Op.Float:
return "".concat(e._emitFloat(this.value));
case Op.Vector2:
return "vec2(".concat(this.value.x, ", ").concat(this.value.y, ")");
case Op.Vector3:
return "vec3(".concat(this.value.x, ", ").concat(this.value.y, ", ").concat(this.value.z, ")");
case Op.Vector4:
return "vec4(".concat(this.value.x, ", ").concat(this.value.y, ", ").concat(this.value.z, ", ").concat(this.value.w, ")");
case Op.Color3:
return L.Color3[0].set(this.value.r, this.value.g, this.value.b),
this.convertToGammaSpace && L.Color3[0].toGammaSpaceToRef(L.Color3[0]),
this.convertToLinearSpace && L.Color3[0].toLinearSpaceToRef(L.Color3[0]),
"vec3(".concat(L.Color3[0].r, ", ").concat(L.Color3[0].g, ", ").concat(L.Color3[0].b, ")");
case Op.Color4:
return L.Color4[0].set(this.value.r, this.value.g, this.value.b, this.value.a),
this.convertToGammaSpace && L.Color4[0].toGammaSpaceToRef(L.Color4[0]),
this.convertToLinearSpace && L.Color4[0].toLinearSpaceToRef(L.Color4[0]),
"vec4(".concat(L.Color4[0].r, ", ").concat(L.Color4[0].g, ", ").concat(L.Color4[0].b, ", ").concat(L.Color4[0].a, ")")
}
return ""
}
,
Object.defineProperty(t.prototype, "_noContextSwitch", {
get: function() {
return $p[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), ";\r\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, ";\r\n"),
t && (e._uniformDeclaration += "#endif\r\n");
var n = e.sharedData.hints;
if (null !== this._systemValue && void 0 !== this._systemValue)
switch (this._systemValue) {
case Qp.WorldView:
n.needWorldViewMatrix = !0;
break;
case Qp.WorldViewProjection:
n.needWorldViewProjectionMatrix = !0
}
else
this._animationType !== qp.None && e.sharedData.animatedInputs.push(this)
} else if (this.isAttribute) {
if (this.associatedVariableName = null !== (i = Jp[this.name]) && void 0 !== i ? i : this.name,
this.target === Dp.Vertex && e._vertexState)
return void ($p[this.name] ? ef[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),
$p[this.name] ? ef[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, ";\r\n"),
t && (e._attributeDeclaration += "#endif\r\n"))
}
}
,
t.prototype._transmitWorld = function(e, t, i, n) {
if (this._systemValue) {
var r = this.associatedVariableName;
switch (this._systemValue) {
case Qp.World:
e.setMatrix(r, t);
break;
case Qp.WorldView:
e.setMatrix(r, i);
break;
case Qp.WorldViewProjection:
e.setMatrix(r, n)
}
}
}
,
t.prototype._transmit = function(e, t, i) {
if (!this.isAttribute) {
var n = this.associatedVariableName;
if (this._systemValue)
switch (this._systemValue) {
case Qp.World:
case Qp.WorldView:
case Qp.WorldViewProjection:
return;
case Qp.View:
e.setMatrix(n, t.getViewMatrix());
break;
case Qp.Projection:
e.setMatrix(n, t.getProjectionMatrix());
break;
case Qp.ViewProjection:
e.setMatrix(n, t.getTransformMatrix());
break;
case Qp.CameraPosition:
t.bindEyePosition(e, n, !0);
break;
case Qp.FogColor:
e.setColor3(n, t.fogColor);
break;
case Qp.DeltaTime:
e.setFloat(n, t.deltaTime / 1e3);
break;
case Qp.CameraParameters:
t.activeCamera && e.setFloat4(n, t.getEngine().hasOriginBottomLeft ? -1 : 1, t.activeCamera.minZ, t.activeCamera.maxZ, 1 / t.activeCamera.maxZ);
break;
case Qp.MaterialAlpha:
e.setFloat(n, i.alpha)
}
else {
var r = this._valueCallback ? this._valueCallback() : this._storedValue;
if (null !== r)
switch (this.type) {
case Op.Float:
e.setFloat(n, r);
break;
case Op.Int:
e.setInt(n, r);
break;
case Op.Color3:
L.Color3[0].set(this.value.r, this.value.g, this.value.b),
this.convertToGammaSpace && L.Color3[0].toGammaSpaceToRef(L.Color3[0]),
this.convertToLinearSpace && L.Color3[0].toLinearSpaceToRef(L.Color3[0]),
e.setColor3(n, L.Color3[0]);
break;
case Op.Color4:
L.Color4[0].set(this.value.r, this.value.g, this.value.b, this.value.a),
this.convertToGammaSpace && L.Color4[0].toGammaSpaceToRef(L.Color4[0]),
this.convertToLinearSpace && L.Color4[0].toLinearSpaceToRef(L.Color4[0]),
e.setDirectColor4(n, L.Color4[0]);
break;
case Op.Vector2:
e.setVector2(n, r);
break;
case Op.Vector3:
e.setVector3(n, r);
break;
case Op.Vector4:
e.setVector4(n, r);
break;
case Op.Matrix:
e.setMatrix(n, r)
}
}
}
}
,
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, '");\r\n');
if (this.isSystemValue)
return e.prototype._dumpPropertiesCode.call(this) + "".concat(t, ".setAsSystemValue(BABYLON.NodeMaterialSystemValues.").concat(Qp[this._systemValue], ");\r\n");
if (this.isUniform) {
var i = []
, n = "";
switch (this.type) {
case Op.Float:
n = "".concat(this.value);
break;
case Op.Vector2:
n = "new BABYLON.Vector2(".concat(this.value.x, ", ").concat(this.value.y, ")");
break;
case Op.Vector3:
n = "new BABYLON.Vector3(".concat(this.value.x, ", ").concat(this.value.y, ", ").concat(this.value.z, ")");
break;
case Op.Vector4:
n = "new BABYLON.Vector4(".concat(this.value.x, ", ").concat(this.value.y, ", ").concat(this.value.z, ", ").concat(this.value.w, ")");
break;
case Op.Color3:
n = "new BABYLON.Color3(".concat(this.value.r, ", ").concat(this.value.g, ", ").concat(this.value.b, ")"),
this.convertToGammaSpace && (n += ".toGammaSpace()"),
this.convertToLinearSpace && (n += ".toLinearSpace()");
break;
case Op.Color4:
n = "new BABYLON.Color4(".concat(this.value.r, ", ").concat(this.value.g, ", ").concat(this.value.b, ", ").concat(this.value.a, ")"),
this.convertToGammaSpace && (n += ".toGammaSpace()"),
this.convertToLinearSpace && (n += ".toLinearSpace()");
break;
case Op.Matrix:
n = "BABYLON.Matrix.FromArray([".concat(this.value.m, "])")
}
return i.push("".concat(t, ".value = ").concat(n)),
this.type === Op.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(qp[this.animationType])),
i.push("".concat(t, ".isConstant = ").concat(this.isConstant)),
i.push(""),
e.prototype._dumpPropertiesCode.call(this) + i.join(";\r\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 === Kp.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, n) {
if (this._mode = t.mode,
e.prototype._deserialize.call(this, t, i, n),
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,
t.valueType)
if ("number" === t.valueType)
this._storedValue = t.value;
else {
var r = b(t.valueType);
r && (this._storedValue = r.FromArray(t.value))
}
}
,
t
}(Wp);
y("BABYLON.InputBlock", tf);
var nf = function(e) {
function t(t) {
var i = e.call(this, t, Dp.VertexAndFragment) || this;
return i._samplerName = "textureSampler",
i.convertToGammaSpace = !1,
i.convertToLinearSpace = !1,
i._isUnique = !1,
i.registerInput("uv", Op.Vector2, !1, Dp.VertexAndFragment),
i.registerOutput("rgba", Op.Color4, Dp.Neutral),
i.registerOutput("rgb", Op.Color3, Dp.Neutral),
i.registerOutput("r", Op.Float, Dp.Neutral),
i.registerOutput("g", Op.Float, Dp.Neutral),
i.registerOutput("b", Op.Float, Dp.Neutral),
i.registerOutput("a", Op.Float, Dp.Neutral),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector3),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
i._inputs[0]._prioritizeVertex = !1,
i
}
return U(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 ? Dp.VertexAndFragment : Dp.Fragment : Dp.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;\r\n"),
this._outputs.some((function(e) {
return e.isConnectedInVertexShader
}
))) {
this._writeTextureRead(e, !0);
for (var i = 0, n = this._outputs; i < n.length; i++) {
var r = n[i];
r.hasEndpoints && this._writeOutput(e, r, r.name, !0)
}
}
}
,
t.prototype._writeTextureRead = function(e, t) {
void 0 === t && (t = !1);
var i = this.uv;
if (t) {
if (e.target === Dp.Fragment)
return;
e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(i.associatedVariableName, ");\r\n")
} else
this.uv.ownerBlock.target !== Dp.Fragment ? e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(this._mainUVName, ");\r\n") : e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(i.associatedVariableName, ");\r\n")
}
,
t.prototype._writeOutput = function(e, t, i, n) {
if (void 0 === n && (n = !1),
n) {
if (e.target === Dp.Fragment)
return;
e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\r\n")
} else
this.uv.ownerBlock.target !== Dp.Fragment ? (e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\r\n"),
e.compilationString += "#ifdef ".concat(this._linearDefineName, "\r\n"),
e.compilationString += "".concat(t.associatedVariableName, " = toGammaSpace(").concat(t.associatedVariableName, ");\r\n"),
e.compilationString += "#endif\r\n",
e.compilationString += "#ifdef ".concat(this._gammaDefineName, "\r\n"),
e.compilationString += "".concat(t.associatedVariableName, " = toLinearSpace(").concat(t.associatedVariableName, ");\r\n"),
e.compilationString += "#endif\r\n") : e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\r\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 !== Dp.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 n = 0, r = this._outputs; n < r.length; n++) {
var o = r[n];
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, n) {
e.prototype._deserialize.call(this, t, i, n),
this.convertToGammaSpace = t.convertToGammaSpace,
this.convertToLinearSpace = !!t.convertToLinearSpace,
t.texture && (n = 0 === t.texture.url.indexOf("data:") ? "" : n,
this.texture = io.Parse(t.texture, i, n))
}
,
t
}(Wp);
y("BABYLON.CurrentScreenBlock", nf);
var rf = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Fragment) || this;
return i._samplerName = "diffuseSampler",
i.convertToGammaSpace = !1,
i.convertToLinearSpace = !1,
i._isUnique = !1,
i.registerInput("uv", Op.Vector2, !1, Dp.VertexAndFragment),
i.registerOutput("rgba", Op.Color4, Dp.Neutral),
i.registerOutput("rgb", Op.Color3, Dp.Neutral),
i.registerOutput("r", Op.Float, Dp.Neutral),
i.registerOutput("g", Op.Float, Dp.Neutral),
i.registerOutput("b", Op.Float, Dp.Neutral),
i.registerOutput("a", Op.Float, Dp.Neutral),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector3),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
i
}
return U(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 tf("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, ";\r\n"),
e.compilationString += "#ifdef ".concat(this._linearDefineName, "\r\n"),
e.compilationString += "".concat(t.associatedVariableName, " = toGammaSpace(").concat(t.associatedVariableName, ");\r\n"),
e.compilationString += "#endif\r\n",
e.compilationString += "#ifdef ".concat(this._gammaDefineName, "\r\n"),
e.compilationString += "".concat(t.associatedVariableName, " = toLinearSpace(").concat(t.associatedVariableName, ");\r\n"),
e.compilationString += "#endif\r\n"
}
,
t.prototype._buildBlock = function(t) {
if (e.prototype._buildBlock.call(this, t),
t.target !== Dp.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, ");\r\n");
for (var n = 0, r = this._outputs; n < r.length; n++) {
var o = r[n];
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, n) {
e.prototype._deserialize.call(this, t, i, n),
this.convertToGammaSpace = t.convertToGammaSpace,
this.convertToLinearSpace = !!t.convertToLinearSpace,
t.texture && (n = 0 === t.texture.url.indexOf("data:") ? "" : n,
this.texture = io.Parse(t.texture, i, n))
}
,
t
}(Wp);
y("BABYLON.ParticleTextureBlock", rf);
var of = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Fragment) || this;
return i._isUnique = !0,
i.registerInput("color", Op.Color4, !1, Dp.Fragment),
i.registerOutput("rampColor", Op.Color4, Dp.Fragment),
i
}
return U(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 !== Dp.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
}(Wp);
y("BABYLON.ParticleRampGradientBlock", of);
var af = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Fragment) || this;
return i._isUnique = !0,
i.registerInput("color", Op.Color4, !1, Dp.Fragment),
i.registerInput("alphaTexture", Op.Float, !1, Dp.Fragment),
i.registerInput("alphaColor", Op.Float, !1, Dp.Fragment),
i.registerOutput("blendColor", Op.Color4, Dp.Fragment),
i
}
return U(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 !== Dp.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
}(Wp);
y("BABYLON.ParticleBlendMultiplyBlock", af);
var sf = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.xSwizzle = "x",
i.ySwizzle = "y",
i.zSwizzle = "z",
i.wSwizzle = "w",
i.registerInput("xyzw ", Op.Vector4, !0),
i.registerInput("xyz ", Op.Vector3, !0),
i.registerInput("xy ", Op.Vector2, !0),
i.registerInput("zw ", Op.Vector2, !0),
i.registerInput("x", Op.Float, !0),
i.registerInput("y", Op.Float, !0),
i.registerInput("z", Op.Float, !0),
i.registerInput("w", Op.Float, !0),
i.registerOutput("xyzw", Op.Vector4),
i.registerOutput("xyz", Op.Vector3),
i.registerOutput("xy", Op.Vector2),
i.registerOutput("zw", Op.Vector2),
i
}
return U(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
, n = this.y
, r = 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), ";\r\n")),
h.hasEndpoints && (t.compilationString += this._declareOutput(h, t) + " = ".concat(c.associatedVariableName).concat(this._buildSwizzle(3), ";\r\n")),
d.hasEndpoints && (t.compilationString += this._declareOutput(d, t) + " = ".concat(c.associatedVariableName).concat(this._buildSwizzle(2), ";\r\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), ";\r\n")),
h.hasEndpoints && (t.compilationString += this._declareOutput(h, t) + " = ".concat(l.associatedVariableName).concat(this._buildSwizzle(3), ";\r\n")),
d.hasEndpoints && (t.compilationString += this._declareOutput(d, t) + " = ".concat(l.associatedVariableName).concat(this._buildSwizzle(2), ";\r\n"))) : a.isConnected ? (u.hasEndpoints && (s.isConnected ? t.compilationString += this._declareOutput(u, t) + " = vec4(".concat(a.associatedVariableName, ", ").concat(s.associatedVariableName, ")").concat(this._buildSwizzle(4), ";\r\n") : t.compilationString += this._declareOutput(u, t) + " = vec4(".concat(a.associatedVariableName, ", ").concat(r.isConnected ? this._writeVariable(r) : "0.0", ", ").concat(o.isConnected ? this._writeVariable(o) : "0.0", ")").concat(this._buildSwizzle(4), ";\r\n")),
h.hasEndpoints && (t.compilationString += this._declareOutput(h, t) + " = vec3(".concat(a.associatedVariableName, ", ").concat(r.isConnected ? this._writeVariable(r) : "0.0", ")").concat(this._buildSwizzle(3), ";\r\n")),
d.hasEndpoints && (t.compilationString += this._declareOutput(d, t) + " = ".concat(a.associatedVariableName).concat(this._buildSwizzle(2), ";\r\n")),
p.hasEndpoints && (s.isConnected ? t.compilationString += this._declareOutput(p, t) + " = ".concat(s.associatedVariableName).concat(this._buildSwizzle(2), ";\r\n") : t.compilationString += this._declareOutput(p, t) + " = vec2(".concat(r.isConnected ? this._writeVariable(r) : "0.0", ", ").concat(o.isConnected ? this._writeVariable(o) : "0.0", ")").concat(this._buildSwizzle(2), ";\r\n"))) : (u.hasEndpoints && (s.isConnected ? t.compilationString += this._declareOutput(u, t) + " = vec4(".concat(i.isConnected ? this._writeVariable(i) : "0.0", ", ").concat(n.isConnected ? this._writeVariable(n) : "0.0", ", ").concat(s.associatedVariableName, ")").concat(this._buildSwizzle(4), ";\r\n") : t.compilationString += this._declareOutput(u, t) + " = vec4(".concat(i.isConnected ? this._writeVariable(i) : "0.0", ", ").concat(n.isConnected ? this._writeVariable(n) : "0.0", ", ").concat(r.isConnected ? this._writeVariable(r) : "0.0", ", ").concat(o.isConnected ? this._writeVariable(o) : "0.0", ")").concat(this._buildSwizzle(4), ";\r\n")),
h.hasEndpoints && (t.compilationString += this._declareOutput(h, t) + " = vec3(".concat(i.isConnected ? this._writeVariable(i) : "0.0", ", ").concat(n.isConnected ? this._writeVariable(n) : "0.0", ", ").concat(r.isConnected ? this._writeVariable(r) : "0.0", ")").concat(this._buildSwizzle(3), ";\r\n")),
d.hasEndpoints && (t.compilationString += this._declareOutput(d, t) + " = vec2(".concat(i.isConnected ? this._writeVariable(i) : "0.0", ", ").concat(n.isConnected ? this._writeVariable(n) : "0.0", ")").concat(this._buildSwizzle(2), ";\r\n")),
p.hasEndpoints && (s.isConnected ? t.compilationString += this._declareOutput(p, t) + " = ".concat(s.associatedVariableName).concat(this._buildSwizzle(2), ";\r\n") : t.compilationString += this._declareOutput(p, t) + " = vec2(".concat(r.isConnected ? this._writeVariable(r) : "0.0", ", ").concat(o.isConnected ? this._writeVariable(o) : "0.0", ")").concat(this._buildSwizzle(2), ";\r\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, n) {
var r, o, a, s;
e.prototype._deserialize.call(this, t, i, n),
this.xSwizzle = null !== (r = t.xSwizzle) && void 0 !== r ? r : "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, '";\r\n'),
t += "".concat(this._codeVariableName, '.ySwizzle = "').concat(this.ySwizzle, '";\r\n'),
(t += "".concat(this._codeVariableName, '.zSwizzle = "').concat(this.zSwizzle, '";\r\n')) + "".concat(this._codeVariableName, '.wSwizzle = "').concat(this.wSwizzle, '";\r\n')
}
,
t
}(Wp);
y("BABYLON.VectorMergerBlock", sf);
var lf = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.sourceRange = new A(-1,1),
i.targetRange = new A(0,1),
i.registerInput("input", Op.AutoDetect),
i.registerInput("sourceMin", Op.Float, !0),
i.registerInput("sourceMax", Op.Float, !0),
i.registerInput("targetMin", Op.Float, !0),
i.registerInput("targetMax", Op.Float, !0),
i.registerOutput("output", Op.BasedOnInput),
i._outputs[0]._typeConnectionSource = i._inputs[0],
i
}
return U(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]
, n = this.sourceMin.isConnected ? this.sourceMin.associatedVariableName : this._writeFloat(this.sourceRange.x)
, r = 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(n, ") * (").concat(a, " - ").concat(o, ") / (").concat(r, " - ").concat(n, ");\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, ");\r\n") + "".concat(this._codeVariableName, ".targetRange = new BABYLON.Vector2(").concat(this.targetRange.x, ", ").concat(this.targetRange.y, ");\r\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, n) {
e.prototype._deserialize.call(this, t, i, n),
this.sourceRange = A.FromArray(t.sourceRange),
this.targetRange = A.FromArray(t.targetRange)
}
,
k([Yp("From", Xp.Vector2)], t.prototype, "sourceRange", void 0),
k([Yp("To", Xp.Vector2)], t.prototype, "targetRange", void 0),
t
}(Wp);
y("BABYLON.RemapBlock", lf);
var cf, uf = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("left", Op.AutoDetect),
i.registerInput("right", Op.AutoDetect),
i.registerOutput("output", Op.BasedOnInput),
i._outputs[0]._typeConnectionSource = i._inputs[0],
i._linkConnectionTypes(0, 1),
i
}
return U(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, ";\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.MultiplyBlock", uf),
function(e) {
e[e.Material = 0] = "Material",
e[e.PostProcess = 1] = "PostProcess",
e[e.Particle = 2] = "Particle",
e[e.ProceduralTexture = 3] = "ProceduralTexture"
}(cf || (cf = {}));
var hf = function() {
function e() {
this.direction1 = new x(0,1,0),
this.direction2 = new x(0,1,0),
this.minEmitBox = new x(-.5,-.5,-.5),
this.maxEmitBox = new x(.5,.5,.5)
}
return e.prototype.startDirectionFunction = function(e, t, i, n) {
var r = d.RandomRange(this.direction1.x, this.direction2.x)
, o = d.RandomRange(this.direction1.y, this.direction2.y)
, a = d.RandomRange(this.direction1.z, this.direction2.z);
if (n)
return t.x = r,
t.y = o,
void (t.z = a);
x.TransformNormalFromFloatsToRef(r, o, a, e, t)
}
,
e.prototype.startPositionFunction = function(e, t, i, n) {
var r = d.RandomRange(this.minEmitBox.x, this.maxEmitBox.x)
, o = d.RandomRange(this.minEmitBox.y, this.maxEmitBox.y)
, a = d.RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
if (n)
return t.x = r,
t.y = o,
void (t.z = a);
x.TransformCoordinatesFromFloatsToRef(r, o, a, e, t)
}
,
e.prototype.clone = function() {
var t = new e;
return fe.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) {
x.FromArrayToRef(e.direction1, 0, this.direction1),
x.FromArrayToRef(e.direction2, 0, this.direction2),
x.FromArrayToRef(e.minEmitBox, 0, this.minEmitBox),
x.FromArrayToRef(e.maxEmitBox, 0, this.maxEmitBox)
}
,
e
}()
, df = 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, n) {
n ? I.Vector3[0].copyFrom(i._localPosition).normalize() : i.position.subtractToRef(e.getTranslation(), I.Vector3[0]).normalize();
var r = d.RandomRange(0, this.directionRandomizer)
, o = d.RandomRange(0, this.directionRandomizer)
, a = d.RandomRange(0, this.directionRandomizer);
t.x = I.Vector3[0].x + r,
t.y = I.Vector3[0].y + o,
t.z = I.Vector3[0].z + a,
t.normalize()
}
,
e.prototype.startPositionFunction = function(e, t, i, n) {
var r, o = d.RandomRange(0, 2 * Math.PI);
r = this.emitFromSpawnPointOnly ? 1e-4 : 1 - (r = d.RandomRange(0, this.heightRange)) * r;
var a = this._radius - d.RandomRange(0, this._radius * this.radiusRange)
, s = (a *= r) * Math.sin(o)
, l = a * Math.cos(o)
, c = r * this._height;
if (n)
return t.x = s,
t.y = c,
void (t.z = l);
x.TransformCoordinatesFromFloatsToRef(s, c, l, e, t)
}
,
e.prototype.clone = function() {
var t = new e(this._radius,this._angle,this.directionRandomizer);
return fe.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
}()
, pf = function() {
function e(e, t, i, n) {
void 0 === e && (e = 1),
void 0 === t && (t = 1),
void 0 === i && (i = 1),
void 0 === n && (n = 0),
this.radius = e,
this.height = t,
this.radiusRange = i,
this.directionRandomizer = n,
this._tempVector = x.Zero()
}
return e.prototype.startDirectionFunction = function(e, t, i, n, r) {
i.position.subtractToRef(e.getTranslation(), this._tempVector),
this._tempVector.normalize(),
x.TransformNormalToRef(this._tempVector, r, this._tempVector);
var o = d.RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2)
, a = Math.atan2(this._tempVector.x, this._tempVector.z);
a += d.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(),
n ? t.copyFrom(this._tempVector) : x.TransformNormalFromFloatsToRef(this._tempVector.x, this._tempVector.y, this._tempVector.z, e, t)
}
,
e.prototype.startPositionFunction = function(e, t, i, n) {
var r = d.RandomRange(-this.height / 2, this.height / 2)
, o = d.RandomRange(0, 2 * Math.PI)
, a = d.RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1)
, s = Math.sqrt(a) * this.radius
, l = s * Math.cos(o)
, c = s * Math.sin(o);
n ? t.copyFromFloats(l, r, c) : x.TransformCoordinatesFromFloatsToRef(l, r, c, e, t)
}
,
e.prototype.clone = function() {
var t = new e(this.radius,this.directionRandomizer);
return fe.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
}()
, ff = function(e) {
function t(t, i, n, r, o) {
void 0 === t && (t = 1),
void 0 === i && (i = 1),
void 0 === n && (n = 1),
void 0 === r && (r = new x(0,1,0)),
void 0 === o && (o = new x(0,1,0));
var a = e.call(this, t, i, n) || this;
return a.direction1 = r,
a.direction2 = o,
a
}
return U(t, e),
t.prototype.startDirectionFunction = function(e, t) {
var i = d.RandomRange(this.direction1.x, this.direction2.x)
, n = d.RandomRange(this.direction1.y, this.direction2.y)
, r = d.RandomRange(this.direction1.z, this.direction2.z);
x.TransformNormalFromFloatsToRef(i, n, r, e, t)
}
,
t.prototype.clone = function() {
var e = new t(this.radius,this.height,this.radiusRange,this.direction1,this.direction2);
return fe.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
}(pf)
, _f = 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, n) {
var r = i.position.subtract(e.getTranslation()).normalize()
, o = d.RandomRange(0, this.directionRandomizer)
, a = d.RandomRange(0, this.directionRandomizer)
, s = d.RandomRange(0, this.directionRandomizer);
r.x += o,
r.y += a,
r.z += s,
r.normalize(),
n ? t.copyFrom(r) : x.TransformNormalFromFloatsToRef(r.x, r.y, r.z, e, t)
}
,
e.prototype.startPositionFunction = function(e, t, i, n) {
var r = this.radius - d.RandomRange(0, this.radius * this.radiusRange)
, o = d.RandomRange(0, 1)
, a = d.RandomRange(0, 2 * Math.PI)
, s = Math.acos(2 * o - 1)
, l = r * Math.cos(a) * Math.sin(s)
, c = r * Math.cos(s)
, u = r * Math.sin(a) * Math.sin(s);
n ? t.copyFromFloats(l, Math.abs(c), u) : x.TransformCoordinatesFromFloatsToRef(l, Math.abs(c), u, e, t)
}
,
e.prototype.clone = function() {
var t = new e(this.radius,this.directionRandomizer);
return fe.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
}()
, mf = function() {
function e() {
this.direction1 = new x(0,1,0),
this.direction2 = new x(0,1,0)
}
return e.prototype.startDirectionFunction = function(e, t, i, n) {
var r = d.RandomRange(this.direction1.x, this.direction2.x)
, o = d.RandomRange(this.direction1.y, this.direction2.y)
, a = d.RandomRange(this.direction1.z, this.direction2.z);
n ? t.copyFromFloats(r, o, a) : x.TransformNormalFromFloatsToRef(r, o, a, e, t)
}
,
e.prototype.startPositionFunction = function(e, t, i, n) {
n ? t.copyFromFloats(0, 0, 0) : x.TransformCoordinatesFromFloatsToRef(0, 0, 0, e, t)
}
,
e.prototype.clone = function() {
var t = new e;
return fe.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) {
x.FromArrayToRef(e.direction1, 0, this.direction1),
x.FromArrayToRef(e.direction2, 0, this.direction2)
}
,
e
}()
, gf = 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, n) {
var r = i.position.subtract(e.getTranslation()).normalize()
, o = d.RandomRange(0, this.directionRandomizer)
, a = d.RandomRange(0, this.directionRandomizer)
, s = d.RandomRange(0, this.directionRandomizer);
r.x += o,
r.y += a,
r.z += s,
r.normalize(),
n ? t.copyFrom(r) : x.TransformNormalFromFloatsToRef(r.x, r.y, r.z, e, t)
}
,
e.prototype.startPositionFunction = function(e, t, i, n) {
var r = this.radius - d.RandomRange(0, this.radius * this.radiusRange)
, o = d.RandomRange(0, 1)
, a = d.RandomRange(0, 2 * Math.PI)
, s = Math.acos(2 * o - 1)
, l = r * Math.cos(a) * Math.sin(s)
, c = r * Math.cos(s)
, u = r * Math.sin(a) * Math.sin(s);
n ? t.copyFromFloats(l, c, u) : x.TransformCoordinatesFromFloatsToRef(l, c, u, e, t)
}
,
e.prototype.clone = function() {
var t = new e(this.radius,this.directionRandomizer);
return fe.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
}()
, vf = function(e) {
function t(t, i, n) {
void 0 === t && (t = 1),
void 0 === i && (i = new x(0,1,0)),
void 0 === n && (n = new x(0,1,0));
var r = e.call(this, t) || this;
return r.direction1 = i,
r.direction2 = n,
r
}
return U(t, e),
t.prototype.startDirectionFunction = function(e, t) {
var i = d.RandomRange(this.direction1.x, this.direction2.x)
, n = d.RandomRange(this.direction1.y, this.direction2.y)
, r = d.RandomRange(this.direction1.z, this.direction2.z);
x.TransformNormalFromFloatsToRef(i, n, r, e, t)
}
,
t.prototype.clone = function() {
var e = new t(this.radius,this.direction1,this.direction2);
return fe.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
}(gf)
, yf = function() {
function e() {
this.particlePositionGenerator = function() {}
,
this.particleDestinationGenerator = function() {}
}
return e.prototype.startDirectionFunction = function(e, t, i, n) {
var r = I.Vector3[0];
if (this.particleDestinationGenerator) {
this.particleDestinationGenerator(-1, i, r);
var o = I.Vector3[1];
r.subtractToRef(i.position, o),
o.scaleToRef(1 / i.lifeTime, r)
} else
r.set(0, 0, 0);
n ? t.copyFrom(r) : x.TransformNormalToRef(r, e, t)
}
,
e.prototype.startPositionFunction = function(e, t, i, n) {
var r = I.Vector3[0];
this.particlePositionGenerator ? this.particlePositionGenerator(-1, i, r) : r.set(0, 0, 0),
n ? t.copyFrom(r) : x.TransformCoordinatesToRef(r, e, t)
}
,
e.prototype.clone = function() {
var t = new e;
return fe.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
}()
, bf = function() {
function e(e) {
void 0 === e && (e = null),
this._indices = null,
this._positions = null,
this._normals = null,
this._storedNormal = x.Zero(),
this._mesh = null,
this.direction1 = new x(0,1,0),
this.direction2 = new x(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(Bi.PositionKind),
this._normals = e.getVerticesData(Bi.NormalKind)) : (this._indices = null,
this._positions = null,
this._normals = null))
},
enumerable: !1,
configurable: !0
}),
e.prototype.startDirectionFunction = function(e, t, i, n) {
if (this.useMeshNormalsForDirection && this._normals)
x.TransformNormalToRef(this._storedNormal, e, t);
else {
var r = d.RandomRange(this.direction1.x, this.direction2.x)
, o = d.RandomRange(this.direction1.y, this.direction2.y)
, a = d.RandomRange(this.direction1.z, this.direction2.z);
n ? t.copyFromFloats(r, o, a) : x.TransformNormalFromFloatsToRef(r, o, a, e, t)
}
}
,
e.prototype.startPositionFunction = function(e, t, i, n) {
if (this._indices && this._positions) {
var r = 3 * Math.random() * (this._indices.length / 3) | 0
, o = Math.random()
, a = Math.random() * (1 - o)
, s = 1 - o - a
, l = this._indices[r]
, c = this._indices[r + 1]
, u = this._indices[r + 2]
, h = I.Vector3[0]
, d = I.Vector3[1]
, p = I.Vector3[2]
, f = I.Vector3[3];
x.FromArrayToRef(this._positions, 3 * l, h),
x.FromArrayToRef(this._positions, 3 * c, d),
x.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,
n ? t.copyFromFloats(f.x, f.y, f.z) : x.TransformCoordinatesFromFloatsToRef(f.x, f.y, f.z, e, t),
this.useMeshNormalsForDirection && this._normals && (x.FromArrayToRef(this._normals, 3 * l, h),
x.FromArrayToRef(this._normals, 3 * c, d),
x.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 fe.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) {
x.FromArrayToRef(e.direction1, 0, this.direction1),
x.FromArrayToRef(e.direction2, 0, this.direction2),
e.meshId && t && (this.mesh = t.getLastMeshById(e.meshId)),
this.useMeshNormalsForDirection = e.useMeshNormalsForDirection
}
,
e
}()
, Tf = function() {
function e(t) {
this.animations = [],
this.renderingGroupId = 0,
this.emitter = x.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._rootUrl = "",
this.noiseStrength = new x(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 x(0,0,0),
this.gravity = x.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 N(1,1,1,1),
this.color2 = new N(1,1,1,1),
this.colorDead = new N(0,0,0,1),
this.textureMask = new N(1,1,1,1),
this._isSubEmitter = !1,
this._billboardMode = a.PARTICLES_BILLBOARDMODE_ALL,
this._isBillboardBased = !0,
this._imageProcessingConfigurationDefines = new xi,
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
}),
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 : x.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 : x.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 : x.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 : x.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 n = 0, r = 0, o = t; r < o.length; r++) {
if (o[r].gradient === e) {
t.splice(n, 1);
break
}
n++
}
return i && i.dispose(),
this
}
,
e.prototype.createPointEmitter = function(e, t) {
var i = new mf;
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 _f(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 gf(e,t);
return this.particleEmitterType = i,
i
}
,
e.prototype.createDirectedSphereEmitter = function(e, t, i) {
void 0 === e && (e = 1),
void 0 === t && (t = new x(0,1,0)),
void 0 === i && (i = new x(0,1,0));
var n = new vf(e,t,i);
return this.particleEmitterType = n,
n
}
,
e.prototype.createCylinderEmitter = function(e, t, i, n) {
void 0 === e && (e = 1),
void 0 === t && (t = 1),
void 0 === i && (i = 1),
void 0 === n && (n = 0);
var r = new pf(e,t,i,n);
return this.particleEmitterType = r,
r
}
,
e.prototype.createDirectedCylinderEmitter = function(e, t, i, n, r) {
void 0 === e && (e = 1),
void 0 === t && (t = 1),
void 0 === i && (i = 1),
void 0 === n && (n = new x(0,1,0)),
void 0 === r && (r = new x(0,1,0));
var o = new ff(e,t,i,n,r);
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 df(e,t);
return this.particleEmitterType = i,
i
}
,
e.prototype.createBoxEmitter = function(e, t, i, n) {
var r = new hf;
return this.particleEmitterType = r,
this.direction1 = e,
this.direction2 = t,
this.minEmitBox = i,
this.maxEmitBox = n,
r
}
,
e.BLENDMODE_ONEONE = 0,
e.BLENDMODE_STANDARD = 1,
e.BLENDMODE_ADD = 2,
e.BLENDMODE_MULTIPLY = 3,
e.BLENDMODE_MULTIPLYADD = 4,
e
}()
, Ef = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("rgba", Op.Color4, !0),
i.registerInput("rgb ", Op.Color3, !0),
i.registerOutput("rgb", Op.Color3),
i.registerOutput("r", Op.Float),
i.registerOutput("g", Op.Float),
i.registerOutput("b", Op.Float),
i.registerOutput("a", Op.Float),
i.inputsAreExclusive = !0,
i
}
return U(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 n = this._outputs[0]
, r = this._outputs[1]
, o = this._outputs[2]
, a = this._outputs[3]
, s = this._outputs[4];
return n.hasEndpoints && (t.compilationString += this._declareOutput(n, t) + " = ".concat(i.associatedVariableName, ".rgb;\r\n")),
r.hasEndpoints && (t.compilationString += this._declareOutput(r, t) + " = ".concat(i.associatedVariableName, ".r;\r\n")),
o.hasEndpoints && (t.compilationString += this._declareOutput(o, t) + " = ".concat(i.associatedVariableName, ".g;\r\n")),
a.hasEndpoints && (t.compilationString += this._declareOutput(a, t) + " = ".concat(i.associatedVariableName, ".b;\r\n")),
s.hasEndpoints && (t.compilationString += this._declareOutput(s, t) + " = ".concat(i.associatedVariableName, ".a;\r\n")),
this
}
}
,
t
}(Wp);
y("BABYLON.ColorSplitterBlock", Ef);
var Sf = function() {
function e(e) {
this.name = Wi.NAME_PROCEDURALTEXTURE,
this.scene = e,
this.scene.proceduralTextures = new Array
}
return e.prototype.register = function() {
this.scene._beforeClearStage.registerStep(Wi.STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear)
}
,
e.prototype.rebuild = function() {}
,
e.prototype.dispose = function() {}
,
e.prototype._beforeClear = function() {
if (this.scene.proceduralTexturesEnabled) {
gi.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()
}
gi.EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0)
}
}
,
e
}();
Pt.ShadersStore.proceduralVertexShader = "attribute vec2 position;\nvarying vec2 vPosition;\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvPosition=position;\nvUV=position*madd+madd;\ngl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";
var Af, xf = function(e) {
function t(t, i, n, r, 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 u = e.call(this, null, r, !s) || this;
u.isEnabled = !0,
u.autoClear = !0,
u.onGeneratedObservable = new h,
u.onBeforeGenerationObservable = new h,
u.nodeMaterialSource = null,
u._textures = {},
u._currentRefreshId = -1,
u._frameId = -1,
u._refreshRate = 1,
u._vertexBuffers = {},
u._uniforms = new Array,
u._samplers = new Array,
u._floats = {},
u._ints = {},
u._floatsArrays = {},
u._colors3 = {},
u._colors4 = {},
u._vectors2 = {},
u._vectors3 = {},
u._matrices = {},
u._fallbackTextureUsed = !1,
u._cachedDefines = null,
u._contentUpdateId = -1,
u._rtWrapper = null;
var d = (r = u.getScene() || E.LastCreatedScene)._getComponent(Wi.NAME_PROCEDURALTEXTURE);
d || (d = new Sf(r),
r._addComponent(d)),
r.proceduralTextures.push(u),
u._fullEngine = r.getEngine(),
u.name = t,
u.isRenderTarget = !0,
u._size = i,
u._textureType = c,
u._generateMipMaps = s,
u._drawWrapper = new Gt(u._fullEngine),
u.setFragment(n),
u._fallbackTexture = o;
var p = u._createRtWrapper(l, i, s, c);
u._texture = p.texture;
var f = [];
return f.push(1, 1),
f.push(-1, 1),
f.push(-1, -1),
f.push(1, -1),
u._vertexBuffers[Bi.PositionKind] = new Bi(u._fullEngine,f,Bi.PositionKind,!1,!1,2),
u._createIndexBuffer(),
u
}
return U(t, e),
t.prototype._createRtWrapper = function(e, t, i, n) {
return e ? (this._rtWrapper = this._fullEngine.createRenderTargetCubeTexture(t, {
generateMipMaps: i,
generateDepthBuffer: !1,
generateStencilBuffer: !1,
type: n
}),
this.setFloat("face", 0)) : this._rtWrapper = this._fullEngine.createRenderTargetTexture(t, {
generateMipMaps: i,
generateDepthBuffer: !1,
generateStencilBuffer: !1,
type: n
}),
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[Bi.PositionKind];
e && e._rebuild(),
this._createIndexBuffer(),
this.refreshRate === ns.REFRESHRATE_RENDER_ONCE && (this.refreshRate = ns.REFRESHRATE_RENDER_ONCE)
}
,
t.prototype.reset = function() {
var e;
null === (e = this._drawWrapper.effect) || void 0 === e || e.dispose()
}
,
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 n = this._getDefines();
return !(!this._drawWrapper.effect || n !== 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 !== n && (this._cachedDefines = n,
this._drawWrapper.effect = i.createEffect(e, [Bi.PositionKind], this._uniforms, this._samplers, n, 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 n = this._createRtWrapper(i, e, t, this._textureType);
this._texture = n.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, n = this.getScene();
if (n) {
var r = this._fullEngine;
if (r.enableEffect(this._drawWrapper),
this.onBeforeGenerationObservable.notifyObservers(this),
r.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) {
if (null === (t = r._debugPushGroup) || void 0 === t || t.call(r, "procedural texture generation for ".concat(this.name), 1),
this.isCube)
for (var _ = 0; _ < 6; _++)
r.bindFramebuffer(this._rtWrapper, _, void 0, void 0, !0),
r.bindBuffers(this._vertexBuffers, this._indexBuffer, this._drawWrapper.effect),
this._drawWrapper.effect.setFloat("face", _),
this.autoClear && r.clear(n.clearColor, !0, !1, !1),
r.drawElementsType(Or.TriangleFillMode, 0, 6);
else
r.bindFramebuffer(this._rtWrapper, 0, void 0, void 0, !0),
r.bindBuffers(this._vertexBuffers, this._indexBuffer, this._drawWrapper.effect),
this.autoClear && r.clear(n.clearColor, !0, !1, !1),
r.drawElementsType(Or.TriangleFillMode, 0, 6);
r.unBindFramebuffer(this._rtWrapper, this.isCube),
this.isCube && r.generateMipMapsForCubemap(this._texture),
null === (i = r._debugPopGroup) || void 0 === i || i.call(r, 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 n = this._vertexBuffers[Bi.PositionKind];
n && (n.dispose(),
this._vertexBuffers[Bi.PositionKind] = null),
this._indexBuffer && this._fullEngine._releaseBuffer(this._indexBuffer) && (this._indexBuffer = null),
this.onGeneratedObservable.clear(),
this.onBeforeGenerationObservable.clear(),
e.prototype.dispose.call(this)
}
}
,
k([Ce()], t.prototype, "isEnabled", void 0),
k([Ce()], t.prototype, "autoClear", void 0),
k([Ce()], t.prototype, "_generateMipMaps", void 0),
k([Ce()], t.prototype, "_size", void 0),
k([Ce()], t.prototype, "refreshRate", null),
t
}(io);
y("BABYLON.ProceduralTexture", xf),
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"
}(Af || (Af = {}));
var Rf = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.operation = Af.Cos,
i.registerInput("input", Op.AutoDetect),
i.registerOutput("output", Op.BasedOnInput),
i._outputs[0]._typeConnectionSource = i._inputs[0],
i
}
return U(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]
, n = "";
switch (this.operation) {
case Af.Cos:
n = "cos";
break;
case Af.Sin:
n = "sin";
break;
case Af.Abs:
n = "abs";
break;
case Af.Exp:
n = "exp";
break;
case Af.Exp2:
n = "exp2";
break;
case Af.Round:
n = "round";
break;
case Af.Floor:
n = "floor";
break;
case Af.Ceiling:
n = "ceil";
break;
case Af.Sqrt:
n = "sqrt";
break;
case Af.Log:
n = "log";
break;
case Af.Tan:
n = "tan";
break;
case Af.ArcTan:
n = "atan";
break;
case Af.ArcCos:
n = "acos";
break;
case Af.ArcSin:
n = "asin";
break;
case Af.Fract:
n = "fract";
break;
case Af.Sign:
n = "sign";
break;
case Af.Radians:
n = "radians";
break;
case Af.Degrees:
n = "degrees"
}
return t.compilationString += this._declareOutput(i, t) + " = ".concat(n, "(").concat(this.input.associatedVariableName, ");\r\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, n) {
e.prototype._deserialize.call(this, t, i, n),
this.operation = t.operation
}
,
t.prototype._dumpPropertiesCode = function() {
return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".operation = BABYLON.TrigonometryBlockOperations.").concat(Af[this.operation], ";\r\n")
}
,
t
}(Wp);
y("BABYLON.TrigonometryBlock", Rf);
var Cf, Pf, Mf = {
effect: null,
subMesh: null
}, If = function(e) {
function t() {
var t = e.call(this) || this;
return t.NORMAL = !1,
t.TANGENT = !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.IMAGEPROCESSINGPOSTPROCESS = !1,
t.SKIPFINALCOLORCLAMP = !1,
t.BUMPDIRECTUV = 0,
t.rebuild(),
t
}
return U(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
}(Si), Of = function(e) {
function t(i, n, r) {
void 0 === r && (r = {});
var o = e.call(this, i, n || E.LastCreatedScene) || this;
return o._buildId = t._BuildIdGenerator++,
o._buildWasSuccessful = !1,
o._cachedWorldViewMatrix = new P,
o._cachedWorldViewProjectionMatrix = new P,
o._optimizers = new Array,
o._animationFrame = -1,
o.BJSNODEMATERIALEDITOR = o._getGlobalNodeMaterialEditor(),
o.editorData = null,
o.ignoreAlpha = !1,
o.maxSimultaneousLights = 4,
o.onBuildObservable = new h,
o._vertexOutputNodes = new Array,
o._fragmentOutputNodes = new Array,
o.attachedBlocks = new Array,
o._mode = cf.Material,
o.forceAlphaBlending = !1,
o._options = V({
emitComments: !1
}, r),
o._attachImageProcessingConfiguration(null),
o
}
return U(t, e),
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, n = this.attachedBlocks; i < n.length; i++) {
var r = n[i];
if (r.name === e) {
if (t)
return gi.Warn("More than one block was found with the name `" + e + "`"),
t;
t = r
}
}
return t
}
,
t.prototype.getBlockByPredicate = function(e) {
for (var t = 0, i = this.attachedBlocks; t < i.length; t++) {
var n = i[t];
if (e(n))
return n
}
return null
}
,
t.prototype.getInputBlockByPredicate = function(e) {
for (var t = 0, i = this.attachedBlocks; t < i.length; t++) {
var n = i[t];
if (n.isInput && e(n))
return n
}
return null
}
,
t.prototype.getInputBlocks = function() {
for (var e = [], t = 0, i = this.attachedBlocks; t < i.length; t++) {
var n = i[t];
n.isInput && e.push(n)
}
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 & Dp.Vertex) && this._addVertexOutputNode(e),
0 != (e.target & Dp.Fragment) && this._addFragmentOutputNode(e),
this
}
,
t.prototype.removeOutputNode = function(e) {
return null === e.target || (0 != (e.target & Dp.Vertex) && this._removeVertexOutputNode(e),
0 != (e.target & Dp.Fragment) && this._removeFragmentOutputNode(e)),
this
}
,
t.prototype._addVertexOutputNode = function(e) {
if (-1 === this._vertexOutputNodes.indexOf(e))
return e.target = Dp.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 = Dp.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._initializeBlock = function(e, t, i, n) {
if (void 0 === n && (n = !0),
e.initialize(t),
n && e.autoConfigure(this),
e._preparationId = this._buildId,
-1 === this.attachedBlocks.indexOf(e)) {
if (e.isUnique)
for (var r = e.getClassName(), o = 0, a = this.attachedBlocks; o < a.length; o++)
if (a[o].getClassName() === r)
throw "Cannot have multiple blocks of type ".concat(r, " 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 && ((h.target === Dp.VertexAndFragment || t.target === Dp.Fragment && h.target === Dp.Vertex && h._preparationId !== this._buildId) && i.push(h),
this._initializeBlock(h, t, i, n))
}
}
for (var d = 0, p = e.outputs; d < p.length; d++)
p[d].associatedVariableName = ""
}
,
t.prototype._resetDualBlocks = function(e, t) {
e.target === Dp.VertexAndFragment && (e.buildId = t);
for (var i = 0, n = e.inputs; i < n.length; i++) {
var r = n[i].connectedPoint;
if (r) {
var o = r.ownerBlock;
o !== e && this._resetDualBlocks(o, 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, n) {
void 0 === e && (e = !1),
void 0 === i && (i = !0),
void 0 === n && (n = !0),
this._buildWasSuccessful = !1;
var r = this.getScene().getEngine()
, o = this._mode === cf.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 kp,
this._vertexCompilationState.supportUniformBuffers = r.supportsUniformBuffers,
this._vertexCompilationState.target = Dp.Vertex,
this._fragmentCompilationState = new kp,
this._fragmentCompilationState.supportUniformBuffers = r.supportsUniformBuffers,
this._fragmentCompilationState.target = Dp.Fragment,
this._sharedData = new Gp,
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, n)
}
for (var h = 0, d = this._fragmentOutputNodes; h < d.length; h++) {
var p = d[h];
s.push(p),
this._initializeBlock(p, this._fragmentCompilationState, a, n)
}
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, A = E.subMeshes; S < A.length; S++) {
var x = A[S];
if (x.getMaterial() === this && x.materialDefines) {
var R = x.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
, n = t.TANGENT;
t.NORMAL = e.isVerticesDataPresent(Bi.NormalKind),
t.TANGENT = e.isVerticesDataPresent(Bi.TangentKind);
for (var r = !1, o = 1; o <= a.MAX_SUPPORTED_UV_SETS; ++o) {
var s = t["UV" + o];
t["UV" + o] = e.isVerticesDataPresent("uv".concat(1 === o ? "" : o)),
r = r || t["UV" + o] !== s
}
(i !== t.NORMAL || n !== t.TANGENT || r) && t.markAsAttributesDirty()
}
,
t.prototype.createPostProcess = function(e, t, i, n, r, 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 !== cf.PostProcess ? (console.log("Incompatible material mode"),
null) : this._createEffectForPostProcess(null, e, t, i, n, r, o, s)
}
,
t.prototype.createEffectForPostProcess = function(e) {
this._createEffectForPostProcess(e)
}
,
t.prototype._createEffectForPostProcess = function(e, t, i, n, r, o, s, l) {
var c = this;
void 0 === i && (i = 1),
void 0 === n && (n = 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 If
, d = new Sr(u + "PostProcess",this.getScene())
, p = this._buildId;
return this._processDefines(d, h),
Mt.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 Ba(this.name + "PostProcess",u,this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,i,t,n,r,o,h.toString(),s,u,{
maxSimultaneousLights: this.maxSimultaneousLights
},!1,l),
e.nodeMaterialSource = this,
e.onApplyObservable.add((function(t) {
p !== c._buildId && (delete Mt.ShadersStore[u + "VertexShader"],
delete Mt.ShadersStore[u + "PixelShader"],
u = c.name + c._buildId,
h.markAllAsDirty(),
p = c._buildId),
c._processDefines(d, h) && (Mt.RegisterShader(u, c._fragmentCompilationState._builtCompilationString, c._vertexCompilationState._builtCompilationString),
Xt.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 !== cf.ProceduralTexture)
return console.log("Incompatible material mode"),
null;
var n = this.name + this._buildId
, r = new xf(n,e,null,t)
, o = new Sr(n + "Procedural",this.getScene());
o.reservedDataStore = {
hidden: !0
};
var a = new If
, s = this._processDefines(o, a);
Mt.RegisterShader(n, this._fragmentCompilationState._builtCompilationString, this._vertexCompilationState._builtCompilationString);
var l = this.getScene().getEngine().createEffect({
vertexElement: n,
fragmentElement: n
}, [Bi.PositionKind], this._fragmentCompilationState.uniforms, this._fragmentCompilationState.samplers, a.toString(), null == s ? void 0 : s.fallbacks, void 0);
r.nodeMaterialSource = this,
r._setEffect(l);
var c = this._buildId;
return r.onBeforeGenerationObservable.add((function() {
c !== i._buildId && (delete Mt.ShadersStore[n + "VertexShader"],
delete Mt.ShadersStore[n + "PixelShader"],
n = i.name + i._buildId,
a.markAllAsDirty(),
c = i._buildId);
var e = i._processDefines(o, a);
e && (Mt.RegisterShader(n, i._fragmentCompilationState._builtCompilationString, i._vertexCompilationState._builtCompilationString),
Xt.SetImmediate((function() {
l = i.getScene().getEngine().createEffect({
vertexElement: n,
fragmentElement: n
}, [Bi.PositionKind], i._fragmentCompilationState.uniforms, i._fragmentCompilationState.samplers, a.toString(), null == e ? void 0 : e.fallbacks, void 0),
r._setEffect(l)
}
))),
i._checkInternals(l)
}
)),
r
}
,
t.prototype._createEffectForParticles = function(e, t, i, n, r, o, a, s) {
var l = this;
void 0 === s && (s = "");
var c = this.name + this._buildId + "_" + t;
o || (o = new If),
a || (a = this.getScene().getMeshByName(this.name + "Particle")) || ((a = new Sr(this.name + "Particle",this.getScene())).reservedDataStore = {
hidden: !0
});
var u = this._buildId
, h = []
, d = s;
if (!r) {
var p = this._processDefines(a, o);
Mt.RegisterShader(c, this._fragmentCompilationState._builtCompilationString),
e.fillDefines(h, t),
d = h.join("\n"),
r = this.getScene().getEngine().createEffectForParticles(c, this._fragmentCompilationState.uniforms, this._fragmentCompilationState.samplers, o.toString() + "\n" + d, null == p ? void 0 : p.fallbacks, i, n, e),
e.setCustomEffect(r, t)
}
r.onBindObservable.add((function(r) {
u !== l._buildId && (delete Mt.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 Mt.RegisterShader(c, l._fragmentCompilationState._builtCompilationString),
r = l.getScene().getEngine().createEffectForParticles(c, l._fragmentCompilationState.uniforms, l._fragmentCompilationState.samplers, o.toString() + "\n" + d, null == f ? void 0 : f.fallbacks, i, n, e),
e.setCustomEffect(r, t),
void l._createEffectForParticles(e, t, i, n, r, o, a, s);
l._checkInternals(r)
}
))
}
,
t.prototype._checkInternals = function(e) {
if (this._sharedData.animatedInputs) {
var t = this.getScene()
, i = t.getFrameId();
if (this._animationFrame !== i) {
for (var n = 0, r = this._sharedData.animatedInputs; n < r.length; n++)
r[n].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 === cf.Particle ? (this._createEffectForParticles(e, Tf.BLENDMODE_ONEONE, t, i),
this._createEffectForParticles(e, Tf.BLENDMODE_MULTIPLY, t, i)) : console.log("Incompatible material mode")
}
,
t.prototype._processDefines = function(e, t, i, n) {
var r = this;
void 0 === i && (i = !1);
var o = null;
if (this._sharedData.blocksWithDefines.forEach((function(n) {
n.initializeDefines(e, r, t, i)
}
)),
this._sharedData.blocksWithDefines.forEach((function(o) {
o.prepareDefines(e, r, t, i, n)
}
)),
t.isDirty) {
var a = t._areLightsDisposed;
t.markAsProcessed(),
this._vertexCompilationState.compilationString = this._vertexCompilationState._builtCompilationString,
this._fragmentCompilationState.compilationString = this._fragmentCompilationState._builtCompilationString,
this._sharedData.repeatableContentBlocks.forEach((function(i) {
i.replaceRepeatableContent(r._vertexCompilationState, r._fragmentCompilationState, e, t)
}
));
var s = [];
this._sharedData.dynamicUniformBlocks.forEach((function(e) {
e.updateUniformsAndSamples(r._vertexCompilationState, r, t, s)
}
));
var l = this._vertexCompilationState.uniforms;
this._fragmentCompilationState.uniforms.forEach((function(e) {
-1 === l.indexOf(e) && l.push(e)
}
));
var c = this._vertexCompilationState.samplers;
this._fragmentCompilationState.samplers.forEach((function(e) {
-1 === c.indexOf(e) && c.push(e)
}
));
var u = new ys;
this._sharedData.blocksWithFallbacks.forEach((function(t) {
t.provideFallbacks(e, u)
}
)),
o = {
lightDisposed: a,
uniformBuffers: s,
mergedUniforms: l,
mergedSamplers: c,
fallbacks: u
}
}
return o
}
,
t.prototype.isReadyForSubMesh = function(e, t, i) {
var n = this;
if (void 0 === i && (i = !1),
!this._buildWasSuccessful)
return !1;
var r = this.getScene();
if (this._sharedData.animatedInputs) {
var o = r.getFrameId();
if (this._animationFrame !== o) {
for (var a = 0, s = this._sharedData.animatedInputs; a < s.length; a++)
s[a].animate(r);
this._animationFrame = o
}
}
if (t.effect && this.isFrozen && t.effect._wasPreviouslyReady)
return !0;
t.materialDefines || (t.materialDefines = new If);
var l = t.materialDefines;
if (this._isReadyForSubMesh(t))
return !0;
var c = r.getEngine();
if (this._prepareDefinesForAttributes(e, l),
this._sharedData.blockingBlocks.some((function(t) {
return !t.isReady(e, n, 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 && (Mf.effect = p,
Mf.subMesh = t,
this._onEffectCreatedObservable.notifyObservers(Mf)),
this.allowShaderHotSwapping && h && !p.isReady()) {
if (p = h,
l.markAsUnprocessed(),
u.lightDisposed)
return l._areLightsDisposed = !0,
!1
} else
r.resetCachedMaterial(),
t.setEffect(p, l, this._materialContext)
}
return !(!t.effect || !t.effect.isReady() || (l._renderId = r.getRenderId(),
t.effect._wasPreviouslyReady = !0,
0))
}
,
Object.defineProperty(t.prototype, "compiledShaders", {
get: function() {
return "// Vertex shader\r\n".concat(this._vertexCompilationState.compilationString, "\r\n\r\n// Fragment shader\r\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 n = 0, r = this._sharedData.inputBlocks; n < r.length; n++)
r[n]._transmitWorld(this._activeEffect, e, this._cachedWorldViewMatrix, this._cachedWorldViewProjectionMatrix)
}
}
,
t.prototype.bindForSubMesh = function(e, t, i) {
var n = this.getScene()
, r = i.effect;
if (r) {
this._activeEffect = r,
this.bindOnlyWorldMatrix(e);
var o = this._mustRebind(n, r, t.visibility)
, a = this._sharedData;
if (o) {
for (var s = 0, l = a.bindableBlocks; s < l.length; s++)
l[s].bind(r, this, t, i);
for (var c = 0, u = a.forcedBindableBlocks; c < u.length; c++)
u[c].bind(r, this, t, i);
for (var h = 0, d = a.inputBlocks; h < d.length; h++)
d[h]._transmit(r, n, this)
} else if (!this.isFrozen)
for (var p = 0, f = a.forcedBindableBlocks; p < f.length; p++)
f[p].bind(r, 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.hasTexture = function(t) {
if (e.prototype.hasTexture.call(this, t))
return !0;
if (!this._sharedData)
return !1;
for (var i = 0, n = this._sharedData.textureBlocks; i < n.length; i++)
if (n[i].texture === t)
return !0;
return !1
}
,
t.prototype.dispose = function(t, i, n) {
if (i)
for (var r = 0, o = this.getTextureBlocks().filter((function(e) {
return e.texture
}
)).map((function(e) {
return e.texture
}
)); r < o.length; r++)
o[r].dispose();
for (var a = 0, s = this.attachedBlocks; a < s.length; a++)
s[a].dispose();
this.attachedBlocks = [],
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, n)
}
,
t.prototype._createNodeEditor = function() {
this.BJSNODEMATERIALEDITOR.NodeEditor.Show({
nodeMaterial: this
})
}
,
t.prototype.edit = function(e) {
var i = this;
return new Promise((function(n) {
if (i.BJSNODEMATERIALEDITOR = i.BJSNODEMATERIALEDITOR || i._getGlobalNodeMaterialEditor(),
void 0 === i.BJSNODEMATERIALEDITOR) {
var r = e && e.editorURL ? e.editorURL : t.EditorURL;
gi.LoadScript(r, (function() {
i.BJSNODEMATERIALEDITOR = i.BJSNODEMATERIALEDITOR || i._getGlobalNodeMaterialEditor(),
i._createNodeEditor(),
n()
}
))
} else
i._createNodeEditor(),
n()
}
))
}
,
t.prototype.clear = function() {
this._vertexOutputNodes = [],
this._fragmentOutputNodes = [],
this.attachedBlocks = []
}
,
t.prototype.setToDefault = function() {
this.clear(),
this.editorData = null;
var e = new tf("Position");
e.setAsAttribute("position");
var t = new tf("World");
t.setAsSystemValue(Qp.World);
var i = new Hp("WorldPos");
e.connectTo(i),
t.connectTo(i);
var n = new tf("ViewProjection");
n.setAsSystemValue(Qp.ViewProjection);
var r = new Hp("WorldPos * ViewProjectionTransform");
i.connectTo(r),
n.connectTo(r);
var o = new jp("VertexOutput");
r.connectTo(o);
var a = new tf("color");
a.value = new N(.8,.8,.8,1);
var s = new Zp("FragmentOutput");
a.connectTo(s),
this.addOutputNode(o),
this.addOutputNode(s),
this._mode = cf.Material
}
,
t.prototype.setToDefaultPostProcess = function() {
this.clear(),
this.editorData = null;
var e = new tf("Position");
e.setAsAttribute("position2d");
var t = new tf("Constant1");
t.isConstant = !0,
t.value = 1;
var i = new sf("Position3D");
e.connectTo(i),
t.connectTo(i, {
input: "w"
});
var n = new jp("VertexOutput");
i.connectTo(n);
var r = new tf("Scale");
r.visibleInInspector = !0,
r.value = new A(1,1);
var o = new lf("uv0");
e.connectTo(o);
var a = new uf("UV scale");
o.connectTo(a),
r.connectTo(a);
var s = new nf("CurrentScreen");
a.connectTo(s),
s.texture = new io("https://assets.babylonjs.com/nme/currentScreenPostProcess.png",this.getScene());
var l = new Zp("FragmentOutput");
s.connectTo(l, {
output: "rgba"
}),
this.addOutputNode(n),
this.addOutputNode(l),
this._mode = cf.PostProcess
}
,
t.prototype.setToDefaultProceduralTexture = function() {
this.clear(),
this.editorData = null;
var e = new tf("Position");
e.setAsAttribute("position2d");
var t = new tf("Constant1");
t.isConstant = !0,
t.value = 1;
var i = new sf("Position3D");
e.connectTo(i),
t.connectTo(i, {
input: "w"
});
var n = new jp("VertexOutput");
i.connectTo(n);
var r = new tf("Time");
r.value = 0,
r.min = 0,
r.max = 0,
r.isBoolean = !1,
r.matrixMode = 0,
r.animationType = qp.Time,
r.isConstant = !1;
var o = new tf("Color3");
o.value = new D(1,1,1),
o.isConstant = !1;
var a = new Zp("FragmentOutput")
, s = new sf("VectorMerger");
s.visibleInInspector = !1;
var l = new Rf("Cos");
l.operation = Af.Cos,
e.connectTo(s),
r.output.connectTo(l.input),
l.output.connectTo(s.z),
s.xyzOut.connectTo(a.rgb),
this.addOutputNode(n),
this.addOutputNode(a),
this._mode = cf.ProceduralTexture
}
,
t.prototype.setToDefaultParticle = function() {
this.clear(),
this.editorData = null;
var e = new tf("uv");
e.setAsAttribute("particle_uv");
var t = new rf("ParticleTexture");
e.connectTo(t);
var i = new tf("Color");
i.setAsAttribute("particle_color");
var n = new uf("Texture * Color");
t.connectTo(n),
i.connectTo(n);
var r = new of("ParticleRampGradient");
n.connectTo(r);
var o = new Ef("ColorSplitter");
i.connectTo(o);
var a = new af("ParticleBlendMultiply");
r.connectTo(a),
t.connectTo(a, {
output: "a"
}),
o.connectTo(a, {
output: "a"
});
var s = new Zp("FragmentOutput");
a.connectTo(s),
this.addOutputNode(s),
this._mode = cf.Particle
}
,
t.prototype.loadAsync = function(e, t) {
var i = this;
return void 0 === t && (t = ""),
this.getScene()._loadFileAsync(e).then((function(e) {
var n = JSON.parse(e);
i.loadFromSerialization(n, t)
}
))
}
,
t.prototype._gatherBlocks = function(e, t) {
if (-1 === t.indexOf(e)) {
t.push(e);
for (var i = 0, n = e.inputs; i < n.length; i++) {
var r = n[i].connectedPoint;
if (r) {
var o = r.ownerBlock;
o !== e && this._gatherBlocks(o, t)
}
}
}
}
,
t.prototype.generateCode = function() {
for (var e = [], t = [], i = ["const", "var", "let"], n = 0, r = this._vertexOutputNodes; n < r.length; n++) {
var o = r[n];
this._gatherBlocks(o, t)
}
for (var a = [], s = 0, l = this._fragmentOutputNodes; s < l.length; s++)
o = l[s],
this._gatherBlocks(o, a);
for (var c = 'var nodeMaterial = new BABYLON.NodeMaterial("'.concat(this.name || "node material", '");\r\n'), 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 += "\r\n// Connections\r\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 += "\r\n// Output nodes\r\n";
for (var v = 0, y = this._vertexOutputNodes; v < y.length; v++) {
var b = y[v];
c += "nodeMaterial.addOutputNode(".concat(b._codeVariableName, ");\r\n")
}
for (var T = 0, E = this._fragmentOutputNodes; T < E.length; T++)
b = E[T],
c += "nodeMaterial.addOutputNode(".concat(b._codeVariableName, ");\r\n");
return c + "nodeMaterial.build();\r\n"
}
,
t.prototype.serialize = function(e) {
var t = e ? {} : Ge.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 n = 0, r = this._vertexOutputNodes; n < r.length; n++) {
var o = r[n];
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 n = 0, r = e.outputs; n < r.length; n++)
for (var o = r[n], 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.loadFromSerialization = function(e, t, i) {
var n;
void 0 === t && (t = ""),
void 0 === i && (i = !1),
i || this.clear();
for (var r = {}, o = 0, a = e.blocks; o < a.length; o++) {
var s = b((c = a[o]).customType);
s && ((u = new s)._deserialize(c, this.getScene(), t),
r[c.id] = u,
this.attachedBlocks.push(u))
}
for (var l = 0; l < e.blocks.length; l++) {
var c, u;
(u = r[(c = e.blocks[l]).id]) && (u.inputs.length && !i || this._restoreConnections(u, e, r))
}
if (e.outputNodes)
for (var h = 0, d = e.outputNodes; h < d.length; h++) {
var p = d[h];
this.addOutputNode(r[p])
}
if (e.locations || e.editorData && e.editorData.locations) {
for (var f = e.locations || e.editorData.locations, _ = 0, m = f; _ < m.length; _++) {
var g = m[_];
r[g.blockId] && (g.blockId = r[g.blockId].uniqueId)
}
i && this.editorData && this.editorData.locations && f.concat(this.editorData.locations),
e.locations ? this.editorData = {
locations: f
} : (this.editorData = e.editorData,
this.editorData.locations = f);
var v = [];
for (var y in r)
v[y] = r[y].uniqueId;
this.editorData.map = v
}
this.comment = e.comment,
void 0 !== e.forceAlphaBlending && (this.forceAlphaBlending = e.forceAlphaBlending),
i || (this._mode = null !== (n = e.mode) && void 0 !== n ? n : cf.Material)
}
,
t.prototype.clone = function(e, i) {
var n = this;
void 0 === i && (i = !1);
var r = this.serialize()
, o = Ge.Clone((function() {
return new t(e,n.getScene(),n.options)
}
), this);
return o.id = e,
o.name = e,
o.loadFromSerialization(r),
o._buildId = this._buildId,
o.build(!1, !i),
o
}
,
t.Parse = function(e, i, n) {
void 0 === n && (n = "");
var r = Ge.Parse((function() {
return new t(e.name,i)
}
), e, i, n);
return r.loadFromSerialization(e, n),
r.build(),
r
}
,
t.ParseFromFileAsync = function(e, i, n, r) {
void 0 === r && (r = "");
var o = new t(e,n);
return new Promise((function(e, t) {
return o.loadAsync(i, r).then((function() {
o.build(),
e(o)
}
)).catch(t)
}
))
}
,
t.ParseFromSnippetAsync = function(e, i, n, r) {
var o = this;
return void 0 === n && (n = ""),
"_BLANK" === e ? Promise.resolve(this.CreateDefault("blank", i)) : new Promise((function(a, s) {
var l = new Ye;
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.nodeMaterial);
r || ((r = Ge.Parse((function() {
return new t(e,i)
}
), c, i, n)).uniqueId = i.getUniqueId()),
r.loadFromSerialization(c),
r.snippetId = e;
try {
r.build(),
a(r)
} catch (e) {
s(e)
}
} else
s("Unable to load the snippet " + e)
}
)),
l.open("GET", o.SnippetUrl + "/" + e.replace(/#/g, "/")),
l.send()
}
))
}
,
t.CreateDefault = function(e, i) {
var n = new t(e,i);
return n.setToDefault(),
n.build(),
n
}
,
t._BuildIdGenerator = 0,
t.EditorURL = "https://unpkg.com/babylonjs-node-editor@".concat(vr.Version, "/babylon.nodeEditor.js"),
t.SnippetUrl = "https://snippet.babylonjs.com",
t.IgnoreTexturesAtLoadTime = !1,
k([Ce()], t.prototype, "ignoreAlpha", void 0),
k([Ce()], t.prototype, "maxSimultaneousLights", void 0),
k([Ce("mode")], t.prototype, "_mode", void 0),
k([Ce("comment")], t.prototype, "comment", void 0),
k([Ce()], t.prototype, "forceAlphaBlending", void 0),
t
}(gs);
y("BABYLON.NodeMaterial", Of),
hr.prototype._projectOnTrianglesToRef = function(e, t, i, n, r, o) {
for (var a = I.Vector3[0], s = I.Vector3[1], l = 1 / 0, c = this.indexStart; c < this.indexStart + this.indexCount - (3 - n); c += n) {
var u = i[c]
, h = i[c + 1]
, d = i[c + 2];
if (r && 4294967295 === d)
c += 2;
else {
var p = t[u]
, f = t[h]
, _ = t[d];
if (p && f && _) {
var m = x.ProjectOnTriangleToRef(e, p, f, _, s);
m < l && (a.copyFrom(s),
l = m)
}
}
}
return o.copyFrom(a),
l
}
,
hr.prototype._projectOnUnIndexedTrianglesToRef = function(e, t, i, n) {
for (var r = I.Vector3[0], o = I.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 = x.ProjectOnTriangleToRef(e, l, c, u, o);
h < a && (r.copyFrom(o),
a = h)
}
return n.copyFrom(r),
a
}
,
hr.prototype.projectToRef = function(e, t, i, n) {
var r = this.getMaterial();
if (!r)
return -1;
var o = 3
, s = !1;
switch (r.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 r.fillMode === a.MATERIAL_LineListDrawMode ? -1 : !i.length && this._mesh._unIndexed ? this._projectOnUnIndexedTrianglesToRef(e, t, i, n) : this._projectOnTrianglesToRef(e, t, i, o, s, n)
}
,
function(e) {
e[e.DEHYDRATED = 0] = "DEHYDRATED",
e[e.HOVER = 1] = "HOVER",
e[e.TOUCH = 2] = "TOUCH"
}(Cf || (Cf = {})),
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"
}(Pf || (Pf = {}));
var Df = function(e) {
function t(i, n) {
var r = e.call(this, i) || this;
return r._options = n,
r._tmpRay = new _o(new x,new x),
r._attachController = function(e) {
if (!r._controllers[e.uniqueId]) {
var i = r._generateNewTouchPointMesh()
, n = i.touchCollisionMesh
, o = i.touchCollisionMeshFunction
, a = i.hydrateCollisionMeshFunction
, s = r._generateVisualCue();
switch (r._controllers[e.uniqueId] = {
xrController: e,
meshUnderPointer: null,
nearInteractionTargetMesh: null,
pick: null,
stalePick: null,
touchCollisionMesh: n,
touchCollisionMeshFunction: o,
hydrateCollisionMeshFunction: a,
currentAnimationState: Cf.DEHYDRATED,
grabRay: new _o(new x,new x),
hoverInteraction: !1,
nearInteraction: !1,
grabInteraction: !1,
id: t._IdCounter++,
pickedPointVisualCue: s
},
r._attachedController ? !r._options.enableNearInteractionOnAllControllers && r._options.preferredHandedness && e.inputSource.handedness === r._options.preferredHandedness && (r._attachedController = e.uniqueId) : r._options.enableNearInteractionOnAllControllers || (r._attachedController = e.uniqueId),
e.inputSource.targetRayMode) {
case "tracked-pointer":
return r._attachNearInteractionMode(e);
case "gaze":
case "screen":
return null
}
}
}
,
r._controllers = {},
r._farInteractionFeature = null,
r.selectionMeshDefaultColor = new D(.8,.8,.8),
r.selectionMeshPickedColor = new D(.3,.3,1),
r._hoverRadius = .1,
r._pickRadius = .02,
r._controllerPickRadius = .03,
r._nearGrabLengthScale = 5,
r._scene = r._xrSessionManager.scene,
void 0 === r._options.nearInteractionControllerMode && (r._options.nearInteractionControllerMode = Pf.CENTERED_IN_FRONT),
r._options.farInteractionFeature && (r._farInteractionFeature = r._options.farInteractionFeature),
r
}
return U(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 === Pf.CENTERED_IN_FRONT && !(null === (i = e.xrController) || void 0 === i ? void 0 : i.inputSource.hand)) {
if (t > e.currentAnimationState)
switch (e.currentAnimationState) {
case Cf.DEHYDRATED:
if (e.hydrateCollisionMeshFunction(!0),
t === Cf.HOVER)
break;
case Cf.HOVER:
if (e.touchCollisionMeshFunction(!0),
t === Cf.TOUCH)
break
}
else
switch (e.currentAnimationState) {
case Cf.TOUCH:
if (e.touchCollisionMeshFunction(!1),
t === Cf.HOVER)
break;
case Cf.HOVER:
if (e.hydrateCollisionMeshFunction(!1),
t === Cf.DEHYDRATED)
break
}
e.currentAnimationState = t
}
}
,
t.prototype._processTouchPoint = function(e, t, i) {
var n, r = this._controllers[e];
r.grabRay.origin.copyFrom(t),
i.toEulerAnglesToRef(I.Vector3[0]),
r.grabRay.direction.copyFrom(I.Vector3[0]),
this._options.nearInteractionControllerMode !== Pf.CENTERED_IN_FRONT || (null === (n = r.xrController) || void 0 === n ? void 0 : n.inputSource.hand) || (r.xrController.getWorldPointerRayToRef(this._tmpRay),
r.grabRay.origin.addInPlace(this._tmpRay.direction.scale(.05))),
r.grabRay.length = this._nearGrabLengthScale * this._hoverRadius,
r.touchCollisionMesh.position.copyFrom(r.grabRay.origin)
}
,
t.prototype._onXRFrame = function(e) {
var t = this;
Object.keys(this._controllers).forEach((function(i) {
var n, r = t._controllers[i], o = null === (n = r.xrController) || void 0 === n ? void 0 : n.inputSource.hand;
if ((t._options.enableNearInteractionOnAllControllers || i === t._attachedController) && r.xrController && (o || t._options.nearInteractionControllerMode && r.xrController.inputSource.gamepad)) {
if (r.hoverInteraction = !1,
r.nearInteraction = !1,
r.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;
I.Vector3[0].set(s.transform.position.x, s.transform.position.y, s.transform.position.z * l),
I.Quaternion[0].set(s.transform.orientation.x, s.transform.orientation.y, s.transform.orientation.z * l, s.transform.orientation.w * l),
t._processTouchPoint(i, I.Vector3[0], I.Quaternion[0])
}
}
} else if (r.xrController.inputSource.gamepad && t._options.nearInteractionControllerMode !== Pf.DISABLED) {
var c = r.xrController.pointer;
r.xrController.grip && t._options.nearInteractionControllerMode === Pf.CENTERED_ON_CONTROLLER && (c = r.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 Ui
, i = !1
, n = 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),
n && !i && (t = e),
t
};
if (!r.grabInteraction) {
var d = null
, p = null;
t._options.useUtilityLayer && t._utilityLayerScene && (p = t._pickWithSphere(r, t._hoverRadius, t._utilityLayerScene, (function(e) {
return t._nearInteractionPredicate(e)
}
)));
var f = u(t._pickWithSphere(r, t._hoverRadius, t._scene, (function(e) {
return t._nearInteractionPredicate(e)
}
)), p);
if (f && f.hit && (d = h(f)).hit && (r.hoverInteraction = !0),
r.hoverInteraction) {
var _ = null
, m = o ? t._pickRadius : t._controllerPickRadius;
t._options.useUtilityLayer && t._utilityLayerScene && (_ = t._pickWithSphere(r, m, t._utilityLayerScene, (function(e) {
return t._nearPickPredicate(e)
}
)));
var g = h(u(t._pickWithSphere(r, m, t._scene, (function(e) {
return t._nearPickPredicate(e)
}
)), _));
g.hit && (d = g,
r.nearInteraction = !0)
}
r.stalePick = r.pick,
r.pick = d,
r.pick && r.pick.pickedPoint && r.pick.hit ? (r.meshUnderPointer = r.pick.pickedMesh,
r.pickedPointVisualCue.position.copyFrom(r.pick.pickedPoint),
r.pickedPointVisualCue.isVisible = !0,
t._farInteractionFeature && t._farInteractionFeature.attached && t._farInteractionFeature._setPointerSelectionDisabledByPointerId(r.id, !0)) : (r.meshUnderPointer = null,
r.pickedPointVisualCue.isVisible = !1,
t._farInteractionFeature && t._farInteractionFeature.attached && t._farInteractionFeature._setPointerSelectionDisabledByPointerId(r.id, !1))
}
var v = Cf.DEHYDRATED;
r.grabInteraction || r.nearInteraction ? v = Cf.TOUCH : r.hoverInteraction && (v = Cf.HOVER),
t._handleTransitionAnimation(r, v)
}
} else
r.pick = null
}
))
}
,
Object.defineProperty(t.prototype, "_utilityLayerScene", {
get: function() {
return this._options.customUtilityLayerScene || El.DefaultUtilityLayer.utilityLayerScene
},
enumerable: !1,
configurable: !0
}),
t.prototype._generateVisualCue = function() {
var e = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || El.DefaultUtilityLayer.utilityLayerScene : this._scene
, t = Dl("nearInteraction", {
diameter: .0105
}, e);
t.bakeCurrentTransformIntoVertices(),
t.isPickable = !1,
t.isVisible = !1,
t.rotationQuaternion = C.Identity();
var i = new Os("targetMat",e);
return i.specularColor = D.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]
, n = {
pointerId: i.id,
pointerType: "xr"
};
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, n),
i.nearInteraction && i.pick && i.pick.hit ? i.nearInteractionTargetMesh || (t._scene.simulatePointerDown(i.pick, n),
i.nearInteractionTargetMesh = i.meshUnderPointer) : i.nearInteractionTargetMesh && i.stalePick && (t._scene.simulatePointerUp(i.stalePick, n),
i.nearInteractionTargetMesh = null))
}
));
var r = function(r) {
t._options.enableNearInteractionOnAllControllers || e.uniqueId === t._attachedController && t._isControllerReadyForNearInteraction(i.id) ? (i.pick && (i.pick.ray = i.grabRay),
r && i.pick && i.meshUnderPointer && t._nearGrabPredicate(i.meshUnderPointer) ? (i.grabInteraction = !0,
i.pickedPointVisualCue.isVisible = !1,
t._scene.simulatePointerDown(i.pick, n)) : !r && i.pick && i.grabInteraction && (t._scene.simulatePointerUp(i.pick, n),
i.grabInteraction = !1,
i.pickedPointVisualCue.isVisible = !0)) : !r || 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;
r(t)
}
}
)) : (i.selectionComponent = e.getMainComponent(),
i.onButtonChangedObserver = i.selectionComponent.onButtonStateChangedObservable.add((function(e) {
if (e.changes.pressed) {
var t = e.changes.pressed.current;
r(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, n))
}
, s = function(e) {
i.xrController && e.inputSource === i.xrController.inputSource && i.pick && t._isControllerReadyForNearInteraction(i.id) && (t._scene.simulatePointerUp(i.pick, n),
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 n = i.eventListeners && i.eventListeners[e];
n && t._xrSessionManager.session.removeEventListener(e, n)
}
)),
i.touchCollisionMesh.dispose(),
i.pickedPointVisualCue.dispose(),
this._xrSessionManager.runInXRFrame((function() {
var e = {
pointerId: i.id,
pointerType: "xr"
};
t._scene.simulatePointerUp(new Ui, e)
}
)),
delete this._controllers[e],
this._attachedController === e)) {
var n = Object.keys(this._controllers);
n.length ? this._attachedController = n[0] : this._attachedController = ""
}
}
,
t.prototype._generateNewTouchPointMesh = function() {
var e = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || El.DefaultUtilityLayer.utilityLayerScene : this._scene
, t = Dl("PickSphere", {
diameter: 1
}, e);
t.isVisible = !1,
this._options.motionControllerOrbMaterial ? t.material = this._options.motionControllerOrbMaterial : Of.ParseFromSnippetAsync("8RUNKL#3", e).then((function(e) {
t.material = e
}
));
var i = new Bn;
i.setEasingMode(Mn.EASINGMODE_EASEINOUT);
var n = new x(this._controllerPickRadius,this._controllerPickRadius,this._controllerPickRadius)
, r = this._controllerPickRadius * (4 / 3)
, o = new x(r,r,r)
, a = this._controllerPickRadius * (7 / 6)
, s = new x(a,a,a)
, l = .8 * this._controllerPickRadius
, c = new x(l,l,l)
, u = 1.5 * this._controllerPickRadius
, h = [{
frame: 0,
value: n
}, {
frame: 10,
value: new x(u,u,u)
}, {
frame: 18,
value: o
}]
, d = [{
frame: 0,
value: o
}, {
frame: 10,
value: c
}, {
frame: 18,
value: n
}]
, p = [{
frame: 0,
value: x.ZeroReadOnly
}, {
frame: 12,
value: s
}, {
frame: 15,
value: n
}]
, f = [{
frame: 0,
value: n
}, {
frame: 10,
value: x.ZeroReadOnly
}, {
frame: 15,
value: x.ZeroReadOnly
}]
, _ = new Qe("touch","scaling",60,Qe.ANIMATIONTYPE_VECTOR3,Qe.ANIMATIONLOOPMODE_CONSTANT)
, m = new Qe("release","scaling",60,Qe.ANIMATIONTYPE_VECTOR3,Qe.ANIMATIONLOOPMODE_CONSTANT)
, g = new Qe("hydrate","scaling",60,Qe.ANIMATIONTYPE_VECTOR3,Qe.ANIMATIONLOOPMODE_CONSTANT)
, v = new Qe("dehydrate","scaling",60,Qe.ANIMATIONTYPE_VECTOR3,Qe.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 n = i ? _ : m;
e.beginDirectAnimation(t, [n], 0, 18, !1, 1)
},
hydrateCollisionMeshFunction: function(i) {
var n = i ? g : v;
i && (t.isVisible = !0),
e.beginDirectAnimation(t, [n], 0, 15, !1, 1, (function() {
i || (t.isVisible = !1)
}
))
}
}
}
,
t.prototype._pickWithSphere = function(e, i, n, r) {
var o = new Ui;
if (o.distance = 1 / 0,
e.touchCollisionMesh && e.xrController)
for (var a = e.touchCollisionMesh.position, s = ir.CreateFromCenterAndRadius(a, i), l = 0; l < n.meshes.length; l++) {
var c = n.meshes[l];
if (r(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 n = e.subMeshes
, r = new Ui
, o = e.getBoundingInfo();
if (!e._generatePointsArray())
return r;
if (!e.subMeshes || !o)
return r;
if (!i && !ir.Intersects(o.boundingSphere, t))
return r;
var a, s, l, c = I.Vector3[0], u = I.Vector3[1], h = 1 / 0, d = I.Vector3[2], p = I.Matrix[0];
p.copyFrom(e.getWorldMatrix()),
p.invert(),
x.TransformCoordinatesToRef(t.center, p, d);
for (var f = 0; f < n.length; f++)
n[f].projectToRef(d, e._positions, e.getIndices(), u),
x.TransformCoordinatesToRef(u, e.getWorldMatrix(), u),
a = x.Distance(u, t.center),
l = x.Distance(u, e.getAbsolutePosition()),
-1 !== (s = x.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 && (r.hit = !0,
r.distance = h,
r.pickedMesh = e,
r.pickedPoint = c.clone()),
r
}
,
t._IdCounter = 200,
t.Name = Io.NEAR_INTERACTION,
t.Version = 1,
t
}(wp);
Oo.AddWebXRFeature(Df.Name, (function(e, t) {
return function() {
return new Df(e,t)
}
}
), Df.Version, !0);
var Nf, Lf = function() {
function e(e, t, i) {
this.element = e,
this.sessionMode = t,
this.referenceSpaceType = i
}
return e.prototype.update = function(e) {}
,
e
}(), Ff = function() {}, wf = function() {
function e(e, t) {
var i = this;
if (this._scene = e,
this.options = t,
this._activeButton = null,
this._buttons = [],
this.activeButtonChangedObservable = new h,
this._onSessionGranted = function(e) {
i._helper && i._enterXRWithButtonIndex(0)
}
,
this.overlay = document.createElement("div"),
this.overlay.classList.add("xr-button-overlay"),
this.overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;",
!t.ignoreSessionGrantedEvent && navigator.xr && navigator.xr.addEventListener("sessiongranted", this._onSessionGranted),
"undefined" != typeof window && window.location && "http:" === window.location.protocol && "localhost" !== window.location.hostname)
throw gi.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 {
var n = t.sessionMode || "immersive-vr"
, r = 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(n, " - ").concat(r),
this._buttons.push(new Lf(s,n,r)),
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 G(this, void 0, void 0, (function() {
var i, n = this;
return z(this, (function(r) {
switch (r.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 == Ns.NOT_IN_XR && n._updateButtons(null)
}
)),
[4, Promise.all(i)];
case 1:
return r.sent().forEach((function(e, t) {
e ? (n.overlay.appendChild(n._buttons[t].element),
n._buttons[t].element.onclick = n._enterXRWithButtonIndex.bind(n, t)) : gi.Warn('Session mode "'.concat(n._buttons[t].sessionMode, '" not supported in browser'))
}
)),
[2]
}
}
))
}
))
}
,
e.CreateAsync = function(t, i, n) {
return G(this, void 0, void 0, (function() {
var r;
return z(this, (function(o) {
switch (o.label) {
case 0:
return [4, (r = new e(t,n)).setHelperAsync(i, n.renderTarget || void 0)];
case 1:
return o.sent(),
[2, r]
}
}
))
}
))
}
,
e.prototype._enterXRWithButtonIndex = function(e) {
return void 0 === e && (e = 0),
G(this, void 0, void 0, (function() {
var t, i, n;
return z(this, (function(r) {
switch (r.label) {
case 0:
return this._helper.state != Ns.IN_XR ? [3, 2] : [4, this._helper.exitXRAsync()];
case 1:
return r.sent(),
this._updateButtons(null),
[3, 6];
case 2:
if (this._helper.state != Ns.NOT_IN_XR)
return [3, 6];
r.label = 3;
case 3:
return r.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 r.sent(),
this._updateButtons(this._buttons[e]),
[3, 6];
case 5:
return t = r.sent(),
this._updateButtons(null),
i = this._buttons[e].element,
n = i.title,
i.title = "Error entering XR session : " + n,
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 Bf(e) {
var t, i = 0, n = Date.now();
e.observableParameters = null !== (t = e.observableParameters) && void 0 !== t ? t : {};
var r = e.contextObservable.add((function(t) {
var o = Date.now()
, a = {
startTime: n,
currentTime: o,
deltaTime: i = o - n,
completeRate: i / e.timeout,
payload: t
};
e.onTick && e.onTick(a),
e.breakCondition && e.breakCondition() && (e.contextObservable.remove(r),
e.onAborted && e.onAborted(a)),
i >= e.timeout && (e.contextObservable.remove(r),
e.onEnded && e.onEnded(a))
}
), e.observableParameters.mask, e.observableParameters.insertFirst, e.observableParameters.scope);
return r
}
!function(e) {
e[e.INIT = 0] = "INIT",
e[e.STARTED = 1] = "STARTED",
e[e.ENDED = 2] = "ENDED"
}(Nf || (Nf = {}));
var Uf = function() {
function e(e) {
var t, i, n = this;
this.onEachCountObservable = new h,
this.onTimerAbortedObservable = new h,
this.onTimerEndedObservable = new h,
this.onStateChangedObservable = new h,
this._observer = null,
this._breakOnNextTick = !1,
this._tick = function(e) {
var t = Date.now();
n._timer = t - n._startTime;
var i = {
startTime: n._startTime,
currentTime: t,
deltaTime: n._timer,
completeRate: n._timer / n._timeToEnd,
payload: e
}
, r = n._breakOnNextTick || n._breakCondition(i);
r || n._timer >= n._timeToEnd ? n._stop(i, r) : n.onEachCountObservable.notifyObservers(i)
}
,
this._setState(Nf.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 === Nf.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(Nf.STARTED)
}
,
e.prototype.stop = function() {
this._state === Nf.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(Nf.ENDED),
t ? this.onTimerAbortedObservable.notifyObservers(e) : this.onTimerEndedObservable.notifyObservers(e)
}
,
e
}()
, Vf = function(e) {
function t(t, i) {
var n = e.call(this, t) || this;
return n._options = i,
n._controllers = {},
n._snappedToPoint = !1,
n._tmpRay = new _o(new x,new x),
n._tmpVector = new x,
n._tmpQuaternion = new C,
n.skipNextTeleportation = !1,
n.backwardsMovementEnabled = !0,
n.backwardsTeleportationDistance = .7,
n.parabolicCheckRadius = 5,
n.parabolicRayEnabled = !0,
n.straightRayEnabled = !0,
n.rotationAngle = Math.PI / 8,
n.onTargetMeshPositionUpdatedObservable = new h,
n.teleportationEnabled = !0,
n._rotationEnabled = !0,
n._attachController = function(e) {
if (!(n._controllers[e.uniqueId] || n._options.forceHandedness && e.inputSource.handedness !== n._options.forceHandedness)) {
n._controllers[e.uniqueId] = {
xrController: e,
teleportationState: {
forward: !1,
backwards: !1,
rotating: !1,
currentRotation: 0,
baseRotation: 0
}
};
var t = n._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(Ap.THUMBSTICK_TYPE) || e.motionController.getComponentOfType(Ap.TOUCHPAD_TYPE);
if (!i || n._options.useMainComponentOnly) {
var r = e.motionController.getMainComponent();
if (!r)
return;
t.teleportationComponent = r,
t.onButtonChangedObserver = r.onButtonStateChangedObservable.add((function() {
n.teleportationEnabled && r.changes.pressed && (r.changes.pressed.current ? (t.teleportationState.forward = !0,
n._currentTeleportationControllerId = t.xrController.uniqueId,
t.teleportationState.baseRotation = n._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,
t.teleportationState.currentRotation = 0,
Bf({
timeout: n._options.timeToTeleport || 3e3,
contextObservable: n._xrSessionManager.onXRFrameObservable,
breakCondition: function() {
return !r.pressed
},
onEnded: function() {
n._currentTeleportationControllerId === t.xrController.uniqueId && t.teleportationState.forward && n._teleportForward(e.uniqueId)
}
})) : (t.teleportationState.forward = !1,
n._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 && n.backwardsMovementEnabled && !n.snapPointsOnly && !t.teleportationState.backwards) {
t.teleportationState.backwards = !0,
n._tmpQuaternion.copyFrom(n._options.xrInput.xrCamera.rotationQuaternion),
n._tmpQuaternion.toEulerAnglesToRef(n._tmpVector),
n._tmpVector.x = 0,
n._tmpVector.z = 0,
C.FromEulerVectorToRef(n._tmpVector, n._tmpQuaternion),
n._tmpVector.set(0, 0, n.backwardsTeleportationDistance * (n._xrSessionManager.scene.useRightHandedSystem ? 1 : -1)),
n._tmpVector.rotateByQuaternionToRef(n._tmpQuaternion, n._tmpVector),
n._tmpVector.addInPlace(n._options.xrInput.xrCamera.position),
n._tmpRay.origin.copyFrom(n._tmpVector),
n._tmpRay.length = n._options.xrInput.xrCamera.realWorldHeight + .1,
n._tmpRay.direction.set(0, -1, 0);
var r = n._xrSessionManager.scene.pickWithRay(n._tmpRay, (function(e) {
return -1 !== n._floorMeshes.indexOf(e)
}
));
r && r.pickedPoint && (n._options.xrInput.xrCamera.position.x = r.pickedPoint.x,
n._options.xrInput.xrCamera.position.z = r.pickedPoint.z)
}
if (i.y < -.7 && !n._currentTeleportationControllerId && !t.teleportationState.rotating && n.teleportationEnabled && (t.teleportationState.forward = !0,
n._currentTeleportationControllerId = t.xrController.uniqueId,
t.teleportationState.baseRotation = n._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y),
i.x) {
if (t.teleportationState.forward)
n._currentTeleportationControllerId === t.xrController.uniqueId && (n.rotationEnabled ? setTimeout((function() {
t.teleportationState.currentRotation = Math.atan2(i.x, i.y * (n._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 = n.rotationAngle * (i.x > 0 ? 1 : -1) * (n._xrSessionManager.scene.useRightHandedSystem ? -1 : 1);
C.FromEulerAngles(0, o, 0).multiplyToRef(n._options.xrInput.xrCamera.rotationQuaternion, n._options.xrInput.xrCamera.rotationQuaternion)
}
} else
t.teleportationState.rotating = !1;
0 === i.x && 0 === i.y && t.teleportationState.forward && n._teleportForward(e.uniqueId)
}
))
}
};
e.motionController ? i() : e.onMotionControllerInitObservable.addOnce((function() {
i()
}
))
} else
n._xrSessionManager.scene.onPointerObservable.add((function(i) {
i.type === Xi.POINTERDOWN ? (t.teleportationState.forward = !0,
n._currentTeleportationControllerId = t.xrController.uniqueId,
t.teleportationState.baseRotation = n._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,
t.teleportationState.currentRotation = 0,
Bf({
timeout: n._options.timeToTeleport || 3e3,
contextObservable: n._xrSessionManager.onXRFrameObservable,
onEnded: function() {
n._currentTeleportationControllerId === t.xrController.uniqueId && t.teleportationState.forward && n._teleportForward(e.uniqueId)
}
})) : i.type === Xi.POINTERUP && (t.teleportationState.forward = !1,
n._currentTeleportationControllerId = "")
}
))
}
}
,
n._options.teleportationTargetMesh || n._createDefaultTargetMesh(),
n._floorMeshes = n._options.floorMeshes || [],
n._snapToPositions = n._options.snapPositions || [],
n._setTargetMeshVisibility(!1),
n
}
return U(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
, n = this._xrSessionManager.scene;
if (this.attach && i) {
var r = this._options.teleportationTargetMesh;
if (this._currentTeleportationControllerId) {
if (!r)
return;
r.rotationQuaternion = r.rotationQuaternion || new C;
var o = this._controllers[this._currentTeleportationControllerId];
if (o && o.teleportationState.forward) {
C.RotationYawPitchRollToRef(o.teleportationState.currentRotation + o.teleportationState.baseRotation, 0, 0, r.rotationQuaternion);
var a = !1;
if (o.xrController.getWorldPointerRayToRef(this._tmpRay),
this.straightRayEnabled) {
if ((s = n.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;
s && s.pickedPoint && (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 = n.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;
s && s.pickedPoint && (a = !0,
this._setTargetMeshPosition(s),
this._setTargetMeshVisibility(!0),
this._showParabolicPath(s))
}
this._setTargetMeshVisibility(a)
} else
this._setTargetMeshVisibility(!1)
} else
this._setTargetMeshVisibility(!1)
}
}
,
t.prototype._createDefaultTargetMesh = function() {
this._options.defaultTargetMeshOptions = this._options.defaultTargetMeshOptions || {};
var e = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || El.DefaultUtilityLayer.utilityLayerScene : this._xrSessionManager.scene
, t = il("teleportationTarget", {
width: 2,
height: 2,
subdivisions: 2
}, e);
t.isPickable = !1;
var i = new Ds("teleportationPlaneDynamicTexture",512,e,!0);
i.hasAlpha = !0;
var n = i.getContext();
n.beginPath(),
n.arc(256, 256, 200, 0, 2 * Math.PI, !1),
n.fillStyle = this._options.defaultTargetMeshOptions.teleportationFillColor || "#444444",
n.fill(),
n.lineWidth = 10,
n.strokeStyle = this._options.defaultTargetMeshOptions.teleportationBorderColor || "#FFFFFF",
n.stroke(),
n.closePath(),
i.update();
var r = new Os("teleportationPlaneMaterial",e);
r.diffuseTexture = i,
t.material = r;
var o = qs("torusTeleportation", {
diameter: .75,
thickness: .1,
tessellation: 20
}, e);
if (o.isPickable = !1,
o.parent = t,
!this._options.defaultTargetMeshOptions.disableAnimation) {
var a = new Qe("animationInnerCircle","position.y",30,Qe.ANIMATIONTYPE_FLOAT,Qe.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 kn;
l.setEasingMode(Mn.EASINGMODE_EASEINOUT),
a.setEasingFunction(l),
o.animations = [],
o.animations.push(a),
e.beginAnimation(o, 0, 60, !0)
}
var c = Ys("rotationCone", {
diameterTop: 0,
tessellation: 4
}, e);
if (c.isPickable = !1,
c.scaling.set(.5, .12, .2),
c.rotate(vn.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 Os("torusConsMat",e);
u.disableLighting = !!this._options.defaultTargetMeshOptions.disableLighting,
u.disableLighting ? u.emissiveColor = new D(.3,.3,1) : u.diffuseColor = new D(.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
}
,
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
, n = Number.MAX_VALUE;
if (this._snapToPositions.length) {
var r = t * t;
this._snapToPositions.forEach((function(t) {
var o = x.DistanceSquared(t, e);
o <= r && o < n && (n = 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) {
this._options.teleportationTargetMesh && this._options.teleportationTargetMesh.isVisible !== e && (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._showParabolicPath = function(e) {
if (e.pickedPoint) {
var t = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || El.DefaultUtilityLayer.utilityLayerScene : this._xrSessionManager.scene
, i = this._controllers[this._currentTeleportationControllerId]
, n = Pn.CreateQuadraticBezier(i.xrController.pointer.absolutePosition, e.ray.origin, e.pickedPoint, 25);
this._options.generateRayPathMesh ? this._quadraticBezierCurve = this._options.generateRayPathMesh(n.getPoints(), e) : this._quadraticBezierCurve = Jl("teleportation path line", {
points: n.getPoints(),
instance: this._quadraticBezierCurve,
updatable: !0
}, 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,
C.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 = Io.TELEPORTATION,
t.Version = 1,
t
}(wp);
Oo.AddWebXRFeature(Vf.Name, (function(e, t) {
return function() {
return new Vf(e,t)
}
}
), Vf.Version, !0);
var kf = function() {}
, Gf = function() {
function e() {}
return e.CreateAsync = function(t, i) {
void 0 === i && (i = {});
var n = new e;
if (t.onDisposeObservable.addOnce((function() {
n.dispose()
}
)),
!i.disableDefaultUI) {
var r = V({
renderTarget: n.renderTarget
}, i.uiOptions || {});
i.optionalFeatures && ("boolean" == typeof i.optionalFeatures ? r.optionalFeatures = ["hit-test", "anchors", "plane-detection", "hand-tracking"] : r.optionalFeatures = i.optionalFeatures),
n.enterExitUI = new wf(t,r)
}
return Sp.CreateAsync(t).then((function(e) {
if (n.baseExperience = e,
i.ignoreNativeCameraTransformation && (n.baseExperience.camera.compensateOnFirstFrame = !1),
n.input = new Fp(e.sessionManager,e.camera,V({
controllerOptions: {
renderingGroupId: i.renderingGroupId
}
}, i.inputOptions || {})),
!i.disablePointerSelection) {
var t = V(V({}, i.pointerSelectionOptions), {
xrInput: n.input,
renderingGroupId: i.renderingGroupId
});
n.pointerSelection = n.baseExperience.featuresManager.enableFeature(Bp.Name, i.useStablePlugins ? "stable" : "latest", t),
i.disableTeleportation || (n.teleportation = n.baseExperience.featuresManager.enableFeature(Vf.Name, i.useStablePlugins ? "stable" : "latest", {
floorMeshes: i.floorMeshes,
xrInput: n.input,
renderingGroupId: i.renderingGroupId
}),
n.teleportation.setSelectionFeature(n.pointerSelection))
}
return i.disableNearInteraction || (n.nearInteraction = n.baseExperience.featuresManager.enableFeature(Df.Name, i.useStablePlugins ? "stable" : "latest", {
xrInput: n.input,
farInteractionFeature: n.pointerSelection,
renderingGroupId: i.renderingGroupId,
useUtilityLayer: !0,
enableNearInteractionOnAllControllers: !0
})),
n.renderTarget = n.baseExperience.sessionManager.getWebXRRenderTarget(i.outputCanvasOptions),
i.disableDefaultUI ? void 0 : n.enterExitUI.setHelperAsync(n.baseExperience, n.renderTarget)
}
)).then((function() {
return n
}
)).catch((function(e) {
return K.Error("Error initializing XR"),
K.Error(e),
n
}
))
}
,
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
}()
, zf = !0;
function Wf(e) {
for (; e.firstChild; )
e.removeChild(e.firstChild);
e.srcObject = null,
e.src = "",
e.removeAttribute("src")
}
mn.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 ds("default light",x.Up(),this)
}
,
mn.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 n = this.getWorldExtends((function(e) {
return e.isVisible && e.isEnabled()
}
))
, r = n.max.subtract(n.min)
, o = n.min.add(r.scale(.5))
, a = void 0
, s = 1.5 * r.length();
if (isFinite(s) || (s = 1,
o.copyFromFloats(0, 0, 0)),
e) {
var l = new _a("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 pa("default camera",new x(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()
}
}
,
mn.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)
}
,
mn.prototype.createDefaultSkybox = function(e, t, i, n, r) {
if (void 0 === t && (t = !1),
void 0 === i && (i = 1e3),
void 0 === n && (n = 0),
void 0 === r && (r = !0),
!e)
return K.Warn("Can not create default skybox without environment texture."),
null;
r && e && (this.environmentTexture = e);
var o = Ml("hdrSkyBox", {
size: i
}, this);
if (t) {
var a = new op("skyBox",this);
a.backFaceCulling = !1,
a.reflectionTexture = e.clone(),
a.reflectionTexture && (a.reflectionTexture.coordinatesMode = io.SKYBOX_MODE),
a.microSurface = 1 - n,
a.disableLighting = !0,
a.twoSidedLighting = !0,
o.material = a
} else {
var s = new Os("skyBox",this);
s.backFaceCulling = !1,
s.reflectionTexture = e.clone(),
s.reflectionTexture && (s.reflectionTexture.coordinatesMode = io.SKYBOX_MODE),
s.disableLighting = !0,
o.material = s
}
return o.isPickable = !1,
o.infiniteDistance = !0,
o.ignoreCameraMaxZ = !0,
o
}
,
mn.prototype.createDefaultEnvironment = function(e) {
return kd ? new kd(e,this) : null
}
,
mn.prototype.createDefaultVRExperience = function(e) {
return void 0 === e && (e = {}),
new hl(this,e)
}
,
mn.prototype.createDefaultXRExperienceAsync = function(e) {
return void 0 === e && (e = {}),
Gf.CreateAsync(this, e).then((function(e) {
return e
}
))
}
;
var Hf = function(e) {
function t(t, i, n, r, o, a, s, l) {
void 0 === r && (r = !1),
void 0 === o && (o = !1),
void 0 === a && (a = io.TRILINEAR_SAMPLINGMODE),
void 0 === s && (s = {});
var c = e.call(this, null, n, !r, o) || this;
c._onUserActionRequestedObservable = null,
c._stillImageCaptured = !1,
c._displayingPosterTexture = !1,
c._frameId = -1,
c._currentSrc = null,
c._errorFound = !1,
c._createInternalTexture = function() {
if (null != c._texture) {
if (!c._displayingPosterTexture)
return;
c._texture.dispose(),
c._displayingPosterTexture = !1
}
if (!c._getEngine().needPOTTextures || gi.IsExponentOfTwo(c.video.videoWidth) && gi.IsExponentOfTwo(c.video.videoHeight) ? (c.wrapU = io.WRAP_ADDRESSMODE,
c.wrapV = io.WRAP_ADDRESSMODE) : (c.wrapU = io.CLAMP_ADDRESSMODE,
c.wrapV = io.CLAMP_ADDRESSMODE,
c._generateMipMaps = !1),
c._texture = c._getEngine().createDynamicTexture(c.video.videoWidth, c.video.videoHeight, c._generateMipMaps, c.samplingMode),
c.video.autoplay || c._settings.poster)
c._updateInternalTexture(),
c.onLoadObservable.hasObservers() && c.onLoadObservable.notifyObservers(c);
else {
var e = c.video.onplaying
, t = c.video.muted;
c.video.muted = !0,
c.video.onplaying = function() {
c.video.muted = t,
c.video.onplaying = e,
c._updateInternalTexture(),
c._errorFound || c.video.pause(),
c.onLoadObservable.hasObservers() && c.onLoadObservable.notifyObservers(c)
}
,
c._handlePlay()
}
}
,
c._reset = function() {
null != c._texture && (c._displayingPosterTexture || (c._texture.dispose(),
c._texture = null))
}
,
c._updateInternalTexture = function() {
if (null != c._texture && !(c.video.readyState < c.video.HAVE_CURRENT_DATA || c._displayingPosterTexture)) {
var e = c.getScene().getFrameId();
c._frameId !== e && (c._frameId = e,
c._getEngine().updateVideoTexture(c._texture, c.video, c._invertY))
}
}
,
c._settings = V({
autoPlay: !0,
loop: !0,
autoUpdateTexture: !0
}, s),
c._onError = l,
c._generateMipMaps = r,
c._initialSamplingMode = a,
c.autoUpdateTexture = c._settings.autoUpdateTexture,
c._currentSrc = i,
c.name = t || c._getName(i),
c.video = c._getVideo(i),
s.poster && (c.video.poster = s.poster),
void 0 !== s.autoPlay && (c.video.autoplay = s.autoPlay),
void 0 !== s.loop && (c.video.loop = s.loop),
void 0 !== s.muted && (c.video.muted = s.muted),
c.video.setAttribute("playsinline", ""),
c.video.addEventListener("paused", c._updateInternalTexture),
c.video.addEventListener("seeked", c._updateInternalTexture),
c.video.addEventListener("emptied", c._reset),
c._createInternalTextureOnEvent = s.poster && !s.autoPlay ? "play" : "canplay",
c.video.addEventListener(c._createInternalTextureOnEvent, c._createInternalTexture),
s.autoPlay && c._handlePlay();
var u = c.video.readyState >= c.video.HAVE_CURRENT_DATA;
return !s.poster || s.autoPlay && u ? u && c._createInternalTexture() : (c._texture = c._getEngine().createTexture(s.poster, !1, !c.invertY, n),
c._displayingPosterTexture = !0),
c
}
return U(t, e),
Object.defineProperty(t.prototype, "onUserActionRequestedObservable", {
get: function() {
return this._onUserActionRequestedObservable || (this._onUserActionRequestedObservable = new h),
this._onUserActionRequestedObservable
},
enumerable: !1,
configurable: !0
}),
t.prototype._processError = function(e) {
this._errorFound = !0,
this._onError ? this._onError(null == e ? void 0 : e.message) : K.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 K.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 gi.SetCorsBehavior(e.currentSrc, e),
e;
var t = document.createElement("video");
return "string" == typeof e ? (gi.SetCorsBehavior(e, t),
t.src = e) : (gi.SetCorsBehavior(e[0], t),
e.forEach((function(e) {
var i = document.createElement("source");
i.src = e,
t.appendChild(i)
}
))),
this.onDisposeObservable.addOnce((function() {
Wf(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() {
e.prototype.dispose.call(this),
this._currentSrc = null,
this._onUserActionRequestedObservable && (this._onUserActionRequestedObservable.clear(),
this._onUserActionRequestedObservable = null),
this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture),
this.video.removeEventListener("paused", this._updateInternalTexture),
this.video.removeEventListener("seeked", this._updateInternalTexture),
this.video.removeEventListener("emptied", this._reset),
this.video.pause()
}
,
t.CreateFromStreamAsync = function(e, i, n, r) {
void 0 === r && (r = !0);
var o = e.getEngine().createVideoElement(n);
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,
void 0 !== o.mozSrcObject ? o.mozSrcObject = i : "object" == typeof o.srcObject ? o.srcObject = i : (window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL,
o.src = window.URL && window.URL.createObjectURL(i)),
new Promise((function(i) {
var n = function() {
var a = new t("video",o,e,!0,r);
e.getEngine()._badOS && a.onDisposeObservable.addOnce((function() {
o.remove()
}
)),
a.onDisposeObservable.addOnce((function() {
Wf(o)
}
)),
i(a),
o.removeEventListener("playing", n)
};
o.addEventListener("playing", n),
o.play()
}
))
}
,
t.CreateFromWebCamAsync = function(e, t, i, n) {
var r, o = this;
if (void 0 === i && (i = !1),
void 0 === n && (n = !0),
t && t.deviceId && (r = {
exact: t.deviceId
}),
navigator.mediaDevices)
return navigator.mediaDevices.getUserMedia({
video: t,
audio: i
}).then((function(i) {
return o.CreateFromStreamAsync(e, i, t, n)
}
));
var a = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
return a && a({
video: {
deviceId: r,
width: {
min: t && t.minWidth || 256,
max: t && t.maxWidth || 640
},
height: {
min: t && t.minHeight || 256,
max: t && t.maxHeight || 480
}
},
audio: i
}, (function(i) {
return o.CreateFromStreamAsync(e, i, t, n)
}
), (function(e) {
K.Error(e.name)
}
)),
Promise.reject("No support for userMedia on this device")
}
,
t.CreateFromWebCam = function(e, t, i, n, r) {
void 0 === n && (n = !1),
void 0 === r && (r = !0),
this.CreateFromWebCamAsync(e, i, n, r).then((function(e) {
t && t(e)
}
)).catch((function(e) {
K.Error(e.name)
}
))
}
,
t
}(io)
, Xf = function(e) {
function t() {
return null !== e && e.apply(this, arguments) || this
}
return U(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 n = this
, r = {
loop: i.loop,
autoPlay: i.autoPlay,
autoUpdateTexture: !0,
poster: i.poster
}
, o = new Hf((this.name || "videoDome") + "_texture",e,t,i.generateMipMaps,this._useDirectMapping,io.TRILINEAR_SAMPLINGMODE,r);
return i.clickToPlay && (this._pointerObserver = t.onPointerObservable.add((function(e) {
e.type !== Xi.POINTERUP && n._texture.video.play()
}
))),
this._textureObserver = o.onLoadObservable.add((function() {
n.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 = Gd.MODE_MONOSCOPIC,
t.MODE_TOPBOTTOM = Gd.MODE_TOPBOTTOM,
t.MODE_SIDEBYSIDE = Gd.MODE_SIDEBYSIDE,
t
}(Gd)
, jf = function() {
function e(e) {
this.engine = e,
this._captureGPUFrameTime = !1,
this._captureShaderCompilationTime = !1,
this._shaderCompilationTime = new un,
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
}()
, Yf = function() {
function e(e) {
var t = this;
this.scene = e,
this._captureActiveMeshesEvaluationTime = !1,
this._activeMeshesEvaluationTime = new un,
this._captureRenderTargetsRenderTime = !1,
this._renderTargetsRenderTime = new un,
this._registerBeforeRenderTime = new un,
this._onBeforeRegisterBeforeRenderObserver = null,
this._onAfterRegisterBeforeRenderObserver = null,
this._RTT1Time = new un,
this._onBeforeRTT1Observer = null,
this._onAfterRTT1Observer = null,
this._registerAfterRenderTime = new un,
this._onBeforeRegisterAfterRenderObserver = null,
this._onAfterRegisterAfterRenderObserver = null,
this._captureFrameTime = !1,
this._frameTime = new un,
this._captureRenderTime = !1,
this._renderTime = new un,
this._captureInterFrameTime = !1,
this._interFrameTime = new un,
this._captureParticlesRenderTime = !1,
this._particlesRenderTime = new un,
this._captureSpritesRenderTime = !1,
this._spritesRenderTime = new un,
this._capturePhysicsTime = !1,
this._physicsTime = new un,
this._captureAnimationsTime = !1,
this._animationsTime = new un,
this._captureCameraRenderTime = !1,
this._cameraRenderTime = new un,
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 && (gi.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.scene.getEngine()._drawCalls.fetchNewFrame()
}
)),
this._onAfterRenderObserver = e.onAfterRenderObservable.add((function() {
t._captureFrameTime && (gi.EndPerformanceCounter("Scene rendering"),
t._frameTime.endMonitoring()),
t._captureRenderTime && t._renderTime.endMonitoring(!1),
t._captureInterFrameTime && t._interFrameTime.beginMonitoring()
}
)),
this._onBeforeRegisterBeforeRenderObserver = e.onBeforeRunRegisterBeforeRenderObservable.add(function() {
t._registerBeforeRenderTime.beginMonitoring()
}),
this._onAfterRegisterBeforeRenderObserver = e.onAfterRunRegisterBeforeRenderObservable.add(function() {
t._registerBeforeRenderTime.endMonitoring()
}),
this._onBeforeRegisterAfterRenderObserver = e.onBeforeRunRegisterAfterRenderObservable.add(function() {
t._registerAfterRenderTime.beginMonitoring()
}),
this._onAfterRegisterAfterRenderObserver = e.onAfterRunRegisterAfterRenderObservable.add(function() {
t._registerAfterRenderTime.endMonitoring()
}),
this._onBeforeRTT1Observer = e.onBeforeRTT1Observable.add(function() {
t._RTT1Time.beginMonitoring()
}),
this._onAfterRTT1Observer = e.onAfterRTT1Observable.add(function() {
t._RTT1Time.endMonitoring()
})
}
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() {
gi.StartPerformanceCounter("Active meshes evaluation"),
t._activeMeshesEvaluationTime.beginMonitoring()
}
)),
this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add((function() {
gi.EndPerformanceCounter("Active meshes evaluation"),
t._activeMeshesEvaluationTime.endMonitoring()
}
))) : (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, "registerBeforeTimeCounter", {
get: function() {
return this._registerBeforeRenderTime
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "getRTT1TimeCounter", {
get: function() {
return this._RTT1Time
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(e.prototype, "registerAfterTimeCounter", {
get: function() {
return this._registerAfterRenderTime
},
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() {
gi.StartPerformanceCounter("Render targets rendering"),
t._renderTargetsRenderTime.beginMonitoring()
}
)),
this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add((function() {
gi.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() {
gi.StartPerformanceCounter("Particles"),
t._particlesRenderTime.beginMonitoring()
}
)),
this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add((function() {
gi.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() {
gi.StartPerformanceCounter("Sprites"),
t._spritesRenderTime.beginMonitoring()
}
)),
this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add((function() {
gi.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() {
gi.StartPerformanceCounter("Physics"),
t._physicsTime.beginMonitoring()
}
)),
this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add((function() {
gi.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(),
gi.StartPerformanceCounter("Main render")
}
)),
this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add((function() {
t._renderTime.endMonitoring(!1),
gi.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(),
gi.StartPerformanceCounter("Rendering camera ".concat(e.name))
}
)),
this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add((function(e) {
t._cameraRenderTime.endMonitoring(!1),
gi.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.onBeforeRunRegisterBeforeRenderObservable.remove(this._onBeforeRegisterBeforeRenderObserver),
this._onBeforeRegisterBeforeRenderObserver = null,
this.scene.onAfterRunRegisterBeforeRenderObservable.remove(this._onAfterRegisterBeforeRenderObserver),
this._onAfterRegisterBeforeRenderObserver = null,
this.scene.onBeforeRunRegisterAfterRenderObservable.remove(this._onBeforeRegisterAfterRenderObserver),
this._onBeforeRegisterAfterRenderObserver = null,
this.scene.onAfterRunRegisterAfterRenderObservable.remove(this._onAfterRegisterAfterRenderObserver),
this._onAfterRegisterAfterRenderObserver = null,
this.scene.onBeforeRTT1Observable.remove(this._onBeforeRTT1Observer),
this._onBeforeRTT1Observer = null,
this.scene.onAfterRTT1Observable.remove(this._onAfterRTT1Observer),
this._onAfterRTT1Observer = null,
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
}();
Pt.ShadersStore.glowMapGenerationPixelShader = "#if defined(DIFFUSE_ISLINEAR) || defined(EMISSIVE_ISLINEAR)\n#include\n#endif\n#ifdef DIFFUSE\nvarying vec2 vUVDiffuse;\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef OPACITY\nvarying vec2 vUVOpacity;\nuniform sampler2D opacitySampler;\nuniform float opacityIntensity;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef VERTEXALPHA\nvarying vec4 vColor;\n#endif\nuniform vec4 glowColor;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\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(Bi.MatricesIndicesExtraKind),
c.push(Bi.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"),
Mr.PrepareAttributesForMorphTargetsInfluencers(c, o, y)),
t && (l.push("#define INSTANCES"),
Mr.PushAttributesForInstances(c),
e.getRenderingMesh().hasThinInstances && l.push("#define THIN_INSTANCES")),
this._addCustomEffectDefines(l);
var b = e._getDrawWrapper(void 0, !0)
, T = b.defines
, E = l.join("\n");
return T !== E && b.setEffect(this._engine.createEffect("glowMapGeneration", c, ["world", "mBones", "viewProjection", "glowColor", "morphTargetInfluences", "boneTextureWidth", "diffuseMatrix", "emissiveMatrix", "opacityMatrix", "opacityIntensity", "morphTargetTextureInfo", "morphTargetTextureIndices"], ["diffuseSampler", "emissiveSampler", "opacitySampler", "boneSampler", "morphTargets"], E, m, void 0, void 0, {
maxSimultaneousMorphTargets: y
}), E),
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()
, n = !0;
for (e = 0; e < i; ++e)
(o = this._mergeDrawWrapper[e]) || (o = this._mergeDrawWrapper[e] = new Gt(this._engine)).setEffect(this._createMergeEffect()),
n = n && o.effect.isReady();
if (n) {
this.onBeforeComposeObservable.notifyObservers(this);
var r = 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(r),
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, n;
if (void 0 === t && (t = !1),
this.shouldRender()) {
var r = 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,
r && this._canRenderMesh(s, r)) {
var h = null !== (i = s.overrideMaterialSideOrientation) && void 0 !== i ? i : r.sideOrientation;
l._getWorldMatrixDeterminant() < 0 && (h = h === Or.ClockWiseSideOrientation ? Or.CounterClockWiseSideOrientation : Or.ClockWiseSideOrientation);
var d = h === Or.ClockWiseSideOrientation;
u.setState(r.backFaceCulling, r.zOffset, void 0, d, r.cullBackFaces, void 0, r.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, r),
this.onBeforeRenderMeshToEffect.notifyObservers(o),
this._useMeshMaterial(s))
s.render(e, f, a || void 0);
else if (this._isReady(e, f, this._emissiveTextureAndColor.texture)) {
var _ = null === (n = l._internalAbstractMeshDataInfo._materialForRenderPass) || void 0 === n ? void 0 : n[u.currentRenderPassId]
, m = e._getDrawWrapper();
if (!m && _ && (m = _._getDrawWrapper()),
!m)
return;
var g = m.effect;
if (u.enableEffect(m),
!f) {
var v = c.forcePointsCloud ? Or.PointFillMode : c.forceWireframe ? Or.WireFrameFillMode : r.fillMode;
s._bind(e, g, v)
}
if (_ ? _.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 y = r.needAlphaTesting()
, b = r.getAlphaTestTexture()
, T = b && b.hasAlpha && (r.useAlphaFromDiffuseTexture || r._useAlphaFromAlbedoTexture);
b && (y || T) && (g.setTexture("diffuseSampler", b),
(E = b.getTextureMatrix()) && g.setMatrix("diffuseMatrix", E));
var E, S = r.opacityTexture;
if (S && (g.setTexture("opacitySampler", S),
g.setFloat("opacityIntensity", S.level),
(E = S.getTextureMatrix()) && g.setMatrix("opacityMatrix", E)),
this._emissiveTextureAndColor.texture && (g.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture),
g.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix())),
s.useBones && s.computeBonesUsingShaders && s.skeleton) {
var A = s.skeleton;
if (A.isUsingTextureForMatrices) {
var x = A.getTransformMatrixTexture(s);
if (!x)
return;
g.setTexture("boneSampler", x),
g.setFloat("boneTextureWidth", 4 * (A.bones.length + 1))
} else
g.setMatrices("mBones", A.getTransformMatrices(s))
}
Mr.BindMorphTargetParameters(s, g),
s.morphTargetManager && s.morphTargetManager.isUsingTextureForTargets && s.morphTargetManager._bind(g),
t && u.setAlphaMode(r.alphaMode)
}
s._processRendering(l, e, g, r.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[Bi.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[Bi.PositionKind];
e && (e.dispose(),
this._vertexBuffers[Bi.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 n = this._scene.effectLayers.indexOf(this, 0);
n > -1 && this._scene.effectLayers.splice(n, 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 gi.Instantiate(e.customType).Parse(e, t, i)
}
,
e._SceneComponentInitialization = function(e) {
throw be("EffectLayerSceneComponent")
}
,
k([Ce()], e.prototype, "name", void 0),
k([Fe()], e.prototype, "neutralColor", void 0),
k([Ce()], e.prototype, "isEnabled", void 0),
k([Ve()], e.prototype, "camera", null),
k([Ce()], e.prototype, "renderingGroupId", null),
k([Ce()], e.prototype, "disableBoundingBoxesFromEffectLayer", void 0),
e
}();
o.AddParser(Wi.NAME_EFFECTLAYER, (function(e, t, i, n) {
if (e.effectLayers) {
i.effectLayers || (i.effectLayers = new Array);
for (var r = 0; r < e.effectLayers.length; r++) {
var o = Kf.Parse(e.effectLayers[r], t, n);
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 Qf = function() {
function e(e) {
this.name = Wi.NAME_EFFECTLAYER,
this._renderEffects = !1,
this._needStencil = !1,
this._previousStencilState = !1,
this.scene = e || E.LastCreatedScene,
this.scene && (this._engine = this.scene.getEngine(),
this.scene.effectLayers = new Array)
}
return e.prototype.register = function() {
this.scene._isReadyForMeshStage.registerStep(Wi.STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh),
this.scene._cameraDrawRenderTargetStage.registerStep(Wi.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture),
this.scene._beforeCameraDrawStage.registerStep(Wi.STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil),
this.scene._afterRenderingGroupDrawStage.registerStep(Wi.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup),
this.scene._afterCameraDrawStage.registerStep(Wi.STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack),
this.scene._afterCameraDrawStage.registerStep(Wi.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 n = i[t];
n.serialize && e.effectLayers.push(n.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, n = 0, r = this.scene.effectLayers; n < r.length; n++) {
var o = r[n];
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 n = 0, r = i; n < r.length; n++) {
var o = r[n];
if (o.shouldRender() && (!o.camera || o.camera.cameraRigMode === Rr.RIG_MODE_NONE && e === o.camera || o.camera.cameraRigMode !== Rr.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 n = t[i];
n.renderingGroupId === e && n.shouldRender() && n.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
}();
Kf._SceneComponentInitialization = function(e) {
var t = e._getComponent(Wi.NAME_EFFECTLAYER);
t || (t = new Qf(e),
e._addComponent(t))
}
;
Pt.ShadersStore.glowMapMergePixelShader = "varying vec2 vUV;\nuniform 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);\nbaseColor*=offset;\n#else\nbaseColor.a=abs(offset-baseColor.a);\n#ifdef STROKE\nfloat alpha=smoothstep(.0,.1,baseColor.a);\nbaseColor.a=alpha;\nbaseColor.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}";
Pt.ShadersStore.glowMapMergeVertexShader = "attribute vec2 position;\nvarying vec2 vUV;\nconst 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;\ngl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}",
o.prototype.getGlowLayerByName = function(e) {
for (var t = 0; t < this.effectLayers.length; t++)
if (this.effectLayers[t].name === e && this.effectLayers[t].getEffectName() === qf.EffectName)
return this.effectLayers[t];
return null
}
;
var qf = function(e) {
function t(i, n, r) {
var o = e.call(this, i, n) || this;
return o._intensity = 1,
o._includedOnlyMeshes = [],
o._excludedMeshes = [],
o._meshesUsingTheirOwnMaterials = [],
o.neutralColor = new N(0,0,0,1),
o._options = V({
mainTextureRatio: t.DefaultTextureRatio,
blurKernelSize: 32,
mainTextureFixedSize: void 0,
camera: null,
mainTextureSamples: 1,
renderingGroupId: -1,
ldrMerge: !1,
alphaBlendingMode: a.ALPHA_ADD
}, r),
o._init({
alphaBlendingMode: o._options.alphaBlendingMode,
camera: o._options.camera,
mainTextureFixedSize: o._options.mainTextureFixedSize,
mainTextureRatio: o._options.mainTextureRatio,
renderingGroupId: o._options.renderingGroupId
}),
o
}
return U(t, e),
Object.defineProperty(t.prototype, "blurKernelSize", {
get: function() {
return this._horizontalBlurPostprocess1.kernel
},
set: function(e) {
this._horizontalBlurPostprocess1.kernel = e,
this._verticalBlurPostprocess1.kernel = e,
this._horizontalBlurPostprocess2.kernel = e,
this._verticalBlurPostprocess2.kernel = e
},
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", [Bi.PositionKind], ["offset"], ["textureSampler", "textureSampler2"], e)
}
,
t.prototype._createTextureAndPostProcesses = function() {
var e = this
, t = this._mainTextureDesiredSize.width
, i = this._mainTextureDesiredSize.height;
t = this._engine.needPOTTextures ? vr.GetExponentOfTwo(t, this._maxSize) : t,
i = this._engine.needPOTTextures ? vr.GetExponentOfTwo(i, this._maxSize) : i;
var n;
n = this._engine.getCaps().textureHalfFloatRender ? a.TEXTURETYPE_HALF_FLOAT : a.TEXTURETYPE_UNSIGNED_INT,
this._blurTexture1 = new ns("GlowLayerBlurRTT",{
width: t,
height: i
},this._scene,!1,!0,n),
this._blurTexture1.wrapU = io.CLAMP_ADDRESSMODE,
this._blurTexture1.wrapV = io.CLAMP_ADDRESSMODE,
this._blurTexture1.updateSamplingMode(io.BILINEAR_SAMPLINGMODE),
this._blurTexture1.renderParticles = !1,
this._blurTexture1.ignoreCameraViewport = !0;
var r = Math.floor(t / 2)
, o = Math.floor(i / 2);
this._blurTexture2 = new ns("GlowLayerBlurRTT2",{
width: r,
height: o
},this._scene,!1,!0,n),
this._blurTexture2.wrapU = io.CLAMP_ADDRESSMODE,
this._blurTexture2.wrapV = io.CLAMP_ADDRESSMODE,
this._blurTexture2.updateSamplingMode(io.BILINEAR_SAMPLINGMODE),
this._blurTexture2.renderParticles = !1,
this._blurTexture2.ignoreCameraViewport = !0,
this._textures = [this._blurTexture1, this._blurTexture2],
this._horizontalBlurPostprocess1 = new Fd("GlowLayerHBP1",new A(1,0),this._options.blurKernelSize / 2,{
width: t,
height: i
},null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),
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 Fd("GlowLayerVBP1",new A(0,1),this._options.blurKernelSize / 2,{
width: t,
height: i
},null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),
this._horizontalBlurPostprocess2 = new Fd("GlowLayerHBP2",new A(1,0),this._options.blurKernelSize / 2,{
width: r,
height: o
},null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),
this._horizontalBlurPostprocess2.width = r,
this._horizontalBlurPostprocess2.height = o,
this._horizontalBlurPostprocess2.externalTextureSamplerBinding = !0,
this._horizontalBlurPostprocess2.onApplyObservable.add((function(t) {
t.setTexture("textureSampler", e._blurTexture1)
}
)),
this._verticalBlurPostprocess2 = new Fd("GlowLayerVBP2",new A(0,1),this._options.blurKernelSize / 2,{
width: r,
height: o
},null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),
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.isReady = function(t, i) {
var n = t.getMaterial()
, r = t.getRenderingMesh();
if (!n || !r)
return !1;
var o = n.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(Or.TriangleFillMode, 0, 6),
t.setStencilBuffer(i)
}
,
t.prototype._setEmissiveTextureAndColor = function(e, t, i) {
var n, r = 1;
this.customEmissiveTextureSelector ? this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(e, t, i) : i ? (this._emissiveTextureAndColor.texture = i.emissiveTexture,
this._emissiveTextureAndColor.texture && (r = this._emissiveTextureAndColor.texture.level)) : this._emissiveTextureAndColor.texture = null,
this.customEmissiveColorSelector ? this.customEmissiveColorSelector(e, t, i, this._emissiveTextureAndColor.color) : i.emissiveColor ? (r *= null !== (n = i.emissiveIntensity) && void 0 !== n ? n : 1,
this._emissiveTextureAndColor.color.set(i.emissiveColor.r * r, i.emissiveColor.g * r, i.emissiveColor.b * r, 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 = Ge.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, n) {
var r, o = Ge.Parse((function() {
return new t(e.name,i,e.options)
}
), e, i, n);
for (r = 0; r < e.excludedMeshes.length; r++)
(a = i.getMeshById(e.excludedMeshes[r])) && o.addExcludedMesh(a);
for (r = 0; r < e.includedMeshes.length; r++) {
var a;
(a = i.getMeshById(e.includedMeshes[r])) && o.addIncludedOnlyMesh(a)
}
return o
}
,
t.EffectName = "GlowLayer",
t.DefaultBlurKernelSize = 32,
t.DefaultTextureRatio = .5,
k([Ce()], t.prototype, "blurKernelSize", null),
k([Ce()], t.prototype, "intensity", null),
k([Ce("options")], t.prototype, "_options", void 0),
t
}(Kf);
y("BABYLON.GlowLayer", qf);
Pt.ShadersStore.glowBlurPostProcessPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 screenSize;\nuniform vec2 direction;\nuniform float blurWidth;\nfloat getLuminance(vec3 color)\n{\nreturn dot(color,vec3(0.2126,0.7152,0.0722));\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nfloat weights[7];\nweights[0]=0.05;\nweights[1]=0.1;\nweights[2]=0.2;\nweights[3]=0.3;\nweights[4]=0.2;\nweights[5]=0.1;\nweights[6]=0.05;\nvec2 texelSize=vec2(1.0/screenSize.x,1.0/screenSize.y);\nvec2 texelStep=texelSize*direction*blurWidth;\nvec2 start=vUV-3.0*texelStep;\nvec4 baseColor=vec4(0.,0.,0.,0.);\nvec2 texelOffset=vec2(0.,0.);\nfor (int i=0; i<7; i++)\n{\nvec4 texel=texture2D(textureSampler,start+texelOffset);\nbaseColor.a+=texel.a*weights[i];\nfloat luminance=getLuminance(baseColor.rgb);\nfloat luminanceTexel=getLuminance(texel.rgb);\nfloat choice=step(luminanceTexel,luminance);\nbaseColor.rgb=choice*baseColor.rgb+(1.0-choice)*texel.rgb;\ntexelOffset+=texelStep;\n}\ngl_FragColor=baseColor;\n}",
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() === Jf.EffectName)
return this.effectLayers[i];
return null
}
;
var Zf = function(e) {
function t(t, i, n, r, o, a, s, l) {
void 0 === a && (a = io.BILINEAR_SAMPLINGMODE);
var c = e.call(this, t, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, r, o, a, s, l) || this;
return c.direction = i,
c.kernel = n,
c.onApplyObservable.add((function(e) {
e.setFloat2("screenSize", c.width, c.height),
e.setVector2("direction", c.direction),
e.setFloat("blurWidth", c.kernel)
}
)),
c
}
return U(t, e),
t
}(Ba)
, Jf = function(e) {
function t(i, n, r) {
var o = e.call(this, i, n) || this;
return o.name = i,
o.innerGlow = !0,
o.outerGlow = !0,
o.onBeforeBlurObservable = new h,
o.onAfterBlurObservable = new h,
o._instanceGlowingMeshStencilReference = t.GlowingMeshStencilReference++,
o._meshes = {},
o._excludedMeshes = {},
o.neutralColor = t.NeutralColor,
o._engine.isStencilEnable || K.Warn("Rendering the Highlight Layer requires the stencil to be active on the canvas. var engine = new Engine(canvas, antialias, { stencil: true }"),
o._options = V({
mainTextureRatio: .5,
blurTextureSizeRatio: .5,
blurHorizontalSize: 1,
blurVerticalSize: 1,
alphaBlendingMode: a.ALPHA_COMBINE,
camera: null,
renderingGroupId: -1
}, r),
o._init({
alphaBlendingMode: o._options.alphaBlendingMode,
camera: o._options.camera,
mainTextureFixedSize: o._options.mainTextureFixedSize,
mainTextureRatio: o._options.mainTextureRatio,
renderingGroupId: o._options.renderingGroupId
}),
o._shouldRender = !1,
o
}
return U(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", [Bi.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 ? vr.GetExponentOfTwo(t, this._maxSize) : t,
i = this._engine.needPOTTextures ? vr.GetExponentOfTwo(i, this._maxSize) : i;
var n;
n = this._engine.getCaps().textureHalfFloatRender ? a.TEXTURETYPE_HALF_FLOAT : a.TEXTURETYPE_UNSIGNED_INT,
this._blurTexture = new ns("HighlightLayerBlurRTT",{
width: t,
height: i
},this._scene,!1,!0,n),
this._blurTexture.wrapU = io.CLAMP_ADDRESSMODE,
this._blurTexture.wrapV = io.CLAMP_ADDRESSMODE,
this._blurTexture.anisotropicFilteringLevel = 16,
this._blurTexture.updateSamplingMode(io.TRILINEAR_SAMPLINGMODE),
this._blurTexture.renderParticles = !1,
this._blurTexture.ignoreCameraViewport = !0,
this._textures = [this._blurTexture],
this._options.alphaBlendingMode === a.ALPHA_COMBINE ? (this._downSamplePostprocess = new Ua("HighlightLayerPPP",this._options.blurTextureSizeRatio,null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),
this._downSamplePostprocess.externalTextureSamplerBinding = !0,
this._downSamplePostprocess.onApplyObservable.add((function(t) {
t.setTexture("textureSampler", e._mainTexture)
}
)),
this._horizontalBlurPostprocess = new Zf("HighlightLayerHBP",new A(1,0),this._options.blurHorizontalSize,1,null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),
this._horizontalBlurPostprocess.onApplyObservable.add((function(e) {
e.setFloat2("screenSize", t, i)
}
)),
this._verticalBlurPostprocess = new Zf("HighlightLayerVBP",new A(0,1),this._options.blurVerticalSize,1,null,io.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 Fd("HighlightLayerHBP",new A(1,0),this._options.blurHorizontalSize / 2,{
width: t,
height: i
},null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),
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 Fd("HighlightLayerVBP",new A(0,1),this._options.blurVerticalSize / 2,{
width: t,
height: i
},null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),
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 n = t.getMaterial()
, r = t.getRenderingMesh();
if (!n || !r || !this._meshes)
return !1;
var o = null
, a = this._meshes[r.uniqueId];
return a && a.glowEmissiveOnly && n && (o = n.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(Or.TriangleFillMode, 0, 6)),
this.innerGlow && 1 === t && (e.setFloat("offset", 1),
i.setStencilFunction(a.EQUAL),
i.drawElementsType(Or.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 n = this._meshes[e.uniqueId];
n ? this._emissiveTextureAndColor.color.set(n.color.r, n.color.g, n.color.b, 1) : this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a),
n && n.glowEmissiveOnly && i ? (this._emissiveTextureAndColor.texture = i.emissiveTexture,
this._emissiveTextureAndColor.color.set(1, 1, 1, 1)) : this._emissiveTextureAndColor.texture = null
}
,
t.prototype.addExcludedMesh = function(e) {
this._excludedMeshes && (this._excludedMeshes[e.uniqueId] || (this._excludedMeshes[e.uniqueId] = {
mesh: e,
beforeBind: e.onBeforeBindObservable.add((function(e) {
e.getEngine().setStencilBuffer(!1)
}
)),
afterRender: e.onAfterRenderObservable.add((function(e) {
e.getEngine().setStencilBuffer(!0)
}
))
}))
}
,
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 n = this;
if (void 0 === i && (i = !1),
this._meshes) {
var r = this._meshes[e.uniqueId];
r ? r.color = t : (this._meshes[e.uniqueId] = {
mesh: e,
color: t,
observerHighlight: e.onBeforeBindObservable.add((function(e) {
n.isEnabled && (n._excludedMeshes && n._excludedMeshes[e.uniqueId] ? n._defaultStencilReference(e) : e.getScene().getEngine().setStencilFunctionReference(n._instanceGlowingMeshStencilReference))
}
)),
observerDefault: e.onAfterRenderObservable.add((function(e) {
n.isEnabled && n._defaultStencilReference(e)
}
)),
glowEmissiveOnly: i
},
e.onDisposeObservable.add((function() {
n._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 = Ge.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 n in this._excludedMeshes) {
var r = this._excludedMeshes[n];
r && e.excludedMeshes.push(r.mesh.id)
}
return e
}
,
t.Parse = function(e, i, n) {
var r, o = Ge.Parse((function() {
return new t(e.name,i,e.options)
}
), e, i, n);
for (r = 0; r < e.excludedMeshes.length; r++)
(a = i.getMeshById(e.excludedMeshes[r])) && o.addExcludedMesh(a);
for (r = 0; r < e.meshes.length; r++) {
var a, s = e.meshes[r];
(a = i.getMeshById(s.meshId)) && o.addMesh(a, D.FromArray(s.color), s.glowEmissiveOnly)
}
return o
}
,
t.EffectName = "HighlightLayer",
t.NeutralColor = new N(0,0,0,0),
t.GlowingMeshStencilReference = 2,
t.NormalMeshStencilReference = 1,
k([Ce()], t.prototype, "innerGlow", void 0),
k([Ce()], t.prototype, "outerGlow", void 0),
k([Ce()], t.prototype, "blurHorizontalSize", null),
k([Ce()], t.prototype, "blurVerticalSize", null),
k([Ce("options")], t.prototype, "_options", void 0),
t
}(Kf);
y("BABYLON.HighlightLayer", Jf);
var $f = function() {
function e(e) {
this.name = Wi.NAME_LAYER,
this.scene = e || E.LastCreatedScene,
this.scene && (this._engine = this.scene.getEngine(),
this.scene.layers = new Array)
}
return e.prototype.register = function() {
this.scene._beforeCameraDrawStage.registerStep(Wi.STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground),
this.scene._afterCameraDrawStage.registerStep(Wi.STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForeground),
this.scene._beforeRenderTargetDrawStage.registerStep(Wi.STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground),
this.scene._afterRenderTargetDrawStage.registerStep(Wi.STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForeground)
}
,
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, n = t; i < n.length; i++) {
var r = n[i];
e(r) && r.render()
}
this._engine.setDepthBuffer(!0)
}
}
,
e.prototype._drawCameraPredicate = function(e, t, i) {
return !e.renderOnlyInRenderTargetTextures && e.isBackground === t && 0 != (e.layerMask & i)
}
,
e.prototype._drawCameraBackground = function(e) {
var t = this;
this._draw((function(i) {
return t._drawCameraPredicate(i, !0, e.layerMask)
}
))
}
,
e.prototype._drawCameraForeground = function(e) {
var t = this;
this._draw((function(i) {
return t._drawCameraPredicate(i, !1, e.layerMask)
}
))
}
,
e.prototype._drawRenderTargetPredicate = function(e, t, i, n) {
return e.renderTargetTextures.length > 0 && e.isBackground === t && e.renderTargetTextures.indexOf(n) > -1 && 0 != (e.layerMask & i)
}
,
e.prototype._drawRenderTargetBackground = function(e) {
var t = this;
this._draw((function(i) {
return t._drawRenderTargetPredicate(i, !0, t.scene.activeCamera.layerMask, e)
}
))
}
,
e.prototype._drawRenderTargetForeground = function(e) {
var t = this;
this._draw((function(i) {
return t._drawRenderTargetPredicate(i, !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 n = i.scene.layers.indexOf(e);
-1 !== n && i.scene.layers.splice(n, 1),
t && e.dispose()
}
))
}
,
e
}();
Pt.ShadersStore.layerPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform 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}";
Pt.ShadersStore.layerVertexShader = "attribute vec2 position;\nuniform vec2 scale;\nuniform vec2 offset;\nuniform mat4 textureMatrix;\nvarying vec2 vUV;\nconst 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;\nvUV=vec2(textureMatrix*vec4(shiftedPosition*madd+madd,1.0,0.0));\ngl_Position=vec4(shiftedPosition,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";
var e_ = function() {
function e(e, t, i, n, r) {
this.name = e,
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 h,
this.onBeforeRenderObservable = new h,
this.onAfterRenderObservable = new h,
this.texture = t ? new io(t,i,!0) : null,
this.isBackground = void 0 === n || n,
this.color = void 0 === r ? new N(1,1,1,1) : r,
this._scene = i || E.LastCreatedScene;
var o = this._scene._getComponent(Wi.NAME_LAYER);
o || (o = new $f(this._scene),
this._scene._addComponent(o)),
this._scene.layers.push(this);
var s = this._scene.getEngine();
this._drawWrapper = new Gt(s);
var l = [];
l.push(1, 1),
l.push(-1, 1),
l.push(-1, -1),
l.push(1, -1);
var c = new Bi(s,l,Bi.PositionKind,!1,!1,2);
this._vertexBuffers[Bi.PositionKind] = c,
this._createIndexBuffer()
}
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, "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[Bi.PositionKind];
e && e._rebuild(),
this._createIndexBuffer()
}
,
e.prototype.render = function() {
if (this.isEnabled) {
var e = this._scene.getEngine()
, t = "";
this.alphaTest && (t = "#define ALPHATEST"),
this.texture && !this.texture.gammaSpace && (t += "\r\n#define LINEAR"),
this._previousDefines !== t && (this._previousDefines = t,
this._drawWrapper.effect = e.createEffect("layer", [Bi.PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], t));
var i = this._drawWrapper.effect;
i && i.isReady() && this.texture && this.texture.isReady() && (this.onBeforeRenderObservable.notifyObservers(this),
e.enableEffect(this._drawWrapper),
e.setState(!1),
i.setTexture("textureSampler", this.texture),
i.setMatrix("textureMatrix", this.texture.getTextureMatrix()),
i.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a),
i.setVector2("offset", this.offset),
i.setVector2("scale", this.scale),
e.bindBuffers(this._vertexBuffers, this._indexBuffer, i),
this.alphaTest ? e.drawElementsType(Or.TriangleFillMode, 0, 6) : (e.setAlphaMode(this.alphaBlendingMode),
e.drawElementsType(Or.TriangleFillMode, 0, 6),
e.setAlphaMode(a.ALPHA_DISABLE)),
this.onAfterRenderObservable.notifyObservers(this))
}
}
,
e.prototype.dispose = function() {
var e = this._vertexBuffers[Bi.PositionKind];
e && (e.dispose(),
this._vertexBuffers[Bi.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
}()
, t_ = function() {
function e(e, t, i, n, r) {
this.size = e,
this.position = t,
this.alphaMode = a.ALPHA_ONEONE,
this.color = i || new D(1,1,1),
this.texture = n ? new io(n,r.getScene(),!0) : null,
this._system = r;
var o = r.scene.getEngine();
this._drawWrapper = new Gt(o),
this._drawWrapper.effect = o.createEffect("lensFlare", [Bi.PositionKind], ["color", "viewportMatrix"], ["textureSampler"], ""),
r.lensFlares.push(this)
}
return e.AddFlare = function(t, i, n, r, o) {
return new e(t,i,n,r,o)
}
,
e.prototype.dispose = function() {
this.texture && this.texture.dispose();
var e = this._system.lensFlares.indexOf(this);
this._system.lensFlares.splice(e, 1)
}
,
e
}();
Pt.ShadersStore.lensFlarePixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec4 color;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec4 baseColor=texture2D(textureSampler,vUV);\ngl_FragColor=baseColor*color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
Pt.ShadersStore.lensFlareVertexShader = "attribute vec2 position;\nuniform mat4 viewportMatrix;\nvarying vec2 vUV;\nconst 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;\ngl_Position=viewportMatrix*vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";
var i_ = function() {
function e(t, i, n) {
this.name = t,
this.lensFlares = new Array,
this.borderLimit = 300,
this.viewportBorder = 0,
this.layerMask = 268435455,
this._vertexBuffers = {},
this._isEnabled = !0,
this._scene = n || E.LastCreatedScene,
e._SceneComponentInitialization(this._scene),
this._emitter = i,
this.id = t,
n.lensFlareSystems.push(this),
this.meshesSelectionPredicate = function(e) {
return n.activeCamera && e.material && e.isVisible && e.isEnabled() && e.isBlocker && 0 != (e.layerMask & n.activeCamera.layerMask)
}
;
var r = n.getEngine()
, o = [];
o.push(1, 1),
o.push(-1, 1),
o.push(-1, -1),
o.push(1, -1),
this._vertexBuffers[Bi.PositionKind] = new Bi(r,o,Bi.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 = x.Project(t, P.Identity(), this._scene.getTransformMatrix(), e),
this._positionX = t.x,
this._positionY = t.y,
t = x.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 _o(this._scene.activeCamera.globalPosition,e)
, n = this._scene.pickWithRay(i, this.meshesSelectionPredicate, !0);
return !n || !n.hit || n.distance > t
}
,
e.prototype.render = function() {
if (!this._scene.activeCamera)
return !1;
var e, t, i = this._scene.getEngine(), n = this._scene.activeCamera.viewport.toGlobal(i.getRenderWidth(!0), i.getRenderHeight(!0));
if (!this.computeEffectivePosition(n))
return !1;
if (!this._isVisible())
return !1;
var r = (e = this._positionX < this.borderLimit + n.x ? this.borderLimit + n.x - this._positionX : this._positionX > n.x + n.width - this.borderLimit ? this._positionX - n.x - n.width + this.borderLimit : 0) > (t = this._positionY < this.borderLimit + n.y ? this.borderLimit + n.y - this._positionY : this._positionY > n.y + n.height - this.borderLimit ? this._positionY - n.y - n.height + this.borderLimit : 0) ? e : t;
(r -= this.viewportBorder) > this.borderLimit && (r = this.borderLimit);
var o = 1 - d.Clamp(r / this.borderLimit, 0, 1);
if (o < 0)
return !1;
o > 1 && (o = 1),
this.viewportBorder > 0 && (n.x += this.viewportBorder,
n.y += this.viewportBorder,
n.width -= 2 * this.viewportBorder,
n.height -= 2 * this.viewportBorder,
this._positionX -= this.viewportBorder,
this._positionY -= this.viewportBorder);
var s = n.x + n.width / 2
, l = n.y + n.height / 2
, c = s - this._positionX
, u = l - this._positionY;
i.setState(!1),
i.setDepthBuffer(!1);
for (var h = 0; h < this.lensFlares.length; h++) {
var p = this.lensFlares[h];
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 / (n.width + 2 * n.x) * 2 - 1
, y = 1 - _ / (n.height + 2 * n.y) * 2
, b = P.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(Or.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[Bi.PositionKind];
for (e && (e.dispose(),
this._vertexBuffers[Bi.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, n) {
var r = i.getLastEntryById(t.emitterId)
, o = t.name || "lensFlareSystem#" + t.emitterId
, a = new e(o,r,i);
a.id = t.id || o,
a.borderLimit = t.borderLimit;
for (var s = 0; s < t.flares.length; s++) {
var l = t.flares[s];
t_.AddFlare(l.size, l.position, D.FromArray(l.color), l.textureName ? n + 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: gi.GetFilename(i.texture ? i.texture.name : "")
})
}
return e
}
,
e._SceneComponentInitialization = function(e) {
throw be("LensFlareSystemSceneComponent")
}
,
e
}();
o.AddParser(Wi.NAME_LENSFLARESYSTEM, (function(e, t, i, n) {
if (void 0 !== e.lensFlareSystems && null !== e.lensFlareSystems) {
i.lensFlareSystems || (i.lensFlareSystems = new Array);
for (var r = 0, o = e.lensFlareSystems.length; r < o; r++) {
var a = e.lensFlareSystems[r]
, s = i_.Parse(a, t, n);
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 n_ = function() {
function e(e) {
this.name = Wi.NAME_LENSFLARESYSTEM,
this.scene = e,
e.lensFlareSystems = new Array
}
return e.prototype.register = function() {
this.scene._afterCameraDrawStage.registerStep(Wi.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 n = i[t];
e.lensFlareSystems.push(n.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;
gi.StartPerformanceCounter("Lens flares", t.length > 0);
for (var i = 0, n = t; i < n.length; i++) {
var r = n[i];
0 != (e.layerMask & r.layerMask) && r.render()
}
gi.EndPerformanceCounter("Lens flares", t.length > 0)
}
}
,
e
}();
i_._SceneComponentInitialization = function(e) {
var t = e._getComponent(Wi.NAME_LENSFLARESYSTEM);
t || (t = new n_(e),
e._addComponent(t))
}
;
Pt.IncludesShadersStore.bayerDitherFunctions = "float bayerDither2(vec2 _P) {\nreturn mod(2.0*_P.y+_P.x+1.0,4.0);\n}\nfloat bayerDither4(vec2 _P) {\nvec2 P1=mod(_P,2.0); \nvec2 P2=floor(0.5*mod(_P,4.0)); \nreturn 4.0*bayerDither2(P1)+bayerDither2(P2);\n}\nfloat bayerDither8(vec2 _P) {\nvec2 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}\n";
Pt.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;\nvarying vec3 vPositionWSM;\n#endif\nuniform vec3 biasAndScaleSM;\nuniform vec2 depthValuesSM;\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1\nvarying float zSM;\n#endif\n";
Pt.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;";
Pt.ShadersStore.shadowMapPixelShader = "#include\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\n#include\n#ifdef ALPHATEST\nfloat alphaFromAlphaTexture=texture2D(diffuseSampler,vUV).a;\nif (alphaFromAlphaTexture<0.4)\ndiscard;\n#endif\n#if SM_SOFTTRANSPARENTSHADOW==1\n#ifdef ALPHATEST\nif ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=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}";
Pt.IncludesShadersStore.sceneVertexDeclaration = "uniform mat4 viewProjection;\n#ifdef MULTIVIEW\nuniform mat4 viewProjectionR;\n#endif\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec4 vEyePosition;\n";
Pt.IncludesShadersStore.meshVertexDeclaration = "uniform mat4 world;\nuniform float visibility;\n";
Pt.IncludesShadersStore.shadowMapVertexDeclaration = "#include\n#include\n";
Pt.IncludesShadersStore.shadowMapUboDeclaration = "layout(std140,column_major) uniform;\n#include\n#include\n";
Pt.IncludesShadersStore.shadowMapVertexExtraDeclaration = "#if SM_NORMALBIAS==1\nuniform vec3 lightDataSM;\n#endif\nuniform vec3 biasAndScaleSM;\nuniform vec2 depthValuesSM;\nvarying 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";
Pt.IncludesShadersStore.shadowMapVertexNormalBias = "#if SM_NORMALBIAS==1\n#if SM_DIRECTIONINLIGHTDATA==1\nvec3 worldLightDirSM=normalize(-lightDataSM.xyz);\n#else\nvec3 directionToLightSM=lightDataSM.xyz-worldPos.xyz;\nvec3 worldLightDirSM=normalize(directionToLightSM);\n#endif\nfloat ndlSM=dot(vNormalW,worldLightDirSM);\nfloat sinNLSM=sqrt(1.0-ndlSM*ndlSM);\nfloat normalBiasSM=biasAndScaleSM.y*sinNLSM;\nworldPos.xyz-=vNormalW*normalBiasSM;\n#endif\n";
Pt.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;\ngl_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";
Pt.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;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#endif\n#include\n#include<__decl__shadowMapVertex>\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform 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{\nvec3 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]));\nvNormalW=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 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}";
Pt.ShadersStore.depthBoxBlurPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 screenSize;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec4 colorDepth=vec4(0.0);\nfor (int x=-OFFSET; x<=OFFSET; x++)\nfor (int y=-OFFSET; y<=OFFSET; y++)\ncolorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize);\ngl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1)));\n}";
Pt.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow = "#if SM_SOFTTRANSPARENTSHADOW==1\nif ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alpha) discard;\n#endif\n";
var r_ = function() {
function e(t, i, n) {
this.onBeforeShadowMapRenderObservable = new h,
this.onAfterShadowMapRenderObservable = new h,
this.onBeforeShadowMapRenderMeshObservable = new h,
this.onAfterShadowMapRenderMeshObservable = new h,
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.frustumEdgeFalloff = 0,
this.forceBackFacesOnly = !1,
this._lightDirection = x.Zero(),
this._viewMatrix = P.Zero(),
this._projectionMatrix = P.Zero(),
this._transformMatrix = P.Zero(),
this._cachedPosition = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
this._cachedDirection = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
this._currentFaceIndex = 0,
this._currentFaceIndexCache = 0,
this._defaultTextureMatrix = P.Identity(),
this._mapSize = t,
this._light = i,
this._scene = i.getScene(),
i._shadowGenerator = 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 r = this._scene.getEngine().getCaps();
n ? r.textureFloatRender && r.textureFloatLinearFiltering ? this._textureType = a.TEXTURETYPE_FLOAT : r.textureHalfFloatRender && r.textureHalfFloatLinearFiltering ? this._textureType = a.TEXTURETYPE_HALF_FLOAT : this._textureType = a.TEXTURETYPE_UNSIGNED_INT : r.textureHalfFloatRender && r.textureHalfFloatLinearFiltering ? this._textureType = a.TEXTURETYPE_HALF_FLOAT : r.textureFloatRender && r.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, n = e.getChildMeshes(); i < n.length; i++) {
var r = n[i];
-1 === this._shadowMap.renderList.indexOf(r) && this._shadowMap.renderList.push(r)
}
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 n = 0, r = e.getChildren(); n < r.length; n++) {
var o = r[n];
this.removeShadowCaster(o)
}
return this
}
,
e.prototype.getLight = function() {
return this._light
}
,
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 ns(this._light.name + "_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube(),void 0,!1,!1),
this._shadowMap.createDepthStencilTexture(e.useReverseDepthBuffer ? a.GREATER : a.LESS, !0)) : this._shadowMap = new ns(this._light.name + "_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube())
}
,
e.prototype._initializeShadowMap = function() {
var t = this;
if (this._createTargetRenderTexture(),
null !== this._shadowMap) {
this._shadowMap.wrapU = io.CLAMP_ADDRESSMODE,
this._shadowMap.wrapV = io.CLAMP_ADDRESSMODE,
this._shadowMap.anisotropicFilteringLevel = 1,
this._shadowMap.updateSamplingMode(io.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(n) {
t._sceneUBOs && t._scene.setSceneUniformBuffer(t._sceneUBOs[0]),
t._currentFaceIndex = n,
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 n, r;
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 === (r = i._debugPopGroup) || void 0 === r || r.call(i, 1))
} else
null === (n = i._debugPopGroup) || void 0 === n || n.call(i, 1)
}
));
var n = new N(0,0,0,0)
, r = new N(1,1,1,1);
this._shadowMap.onClearObservable.add((function(i) {
t._filter === e.FILTER_PCF ? i.clear(r, !1, !0, !1) : t.useExponentialShadowMap || t.useBlurExponentialShadowMap ? i.clear(n, !0, !0, !1) : i.clear(r, !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 = zi.MIN_RENDERINGGROUPS; o < zi.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 ns(this._light.name + "_shadowMap2",i,this._scene,!1,!0,this._textureType,void 0,void 0,!1),
this._shadowMap2.wrapU = io.CLAMP_ADDRESSMODE,
this._shadowMap2.wrapV = io.CLAMP_ADDRESSMODE,
this._shadowMap2.updateSamplingMode(io.BILINEAR_SAMPLINGMODE)),
this.useKernelBlur ? (this._kernelBlurXPostprocess = new Fd(this._light.name + "KernelBlurX",new A(1,0),this.blurKernel,1,null,io.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 Fd(this._light.name + "KernelBlurY",new A(0,1),this.blurKernel,1,null,io.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 Ba(this._light.name + "DepthBoxBlur","depthBoxBlur",["screenSize", "boxOffset"],[],1,null,io.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, n) {
var r;
if (n.length)
for (r = 0; r < n.length; r++)
this._renderSubMeshForShadowMap(n.data[r]);
for (r = 0; r < e.length; r++)
this._renderSubMeshForShadowMap(e.data[r]);
for (r = 0; r < t.length; r++)
this._renderSubMeshForShadowMap(t.data[r]);
if (this._transparencyShadow)
for (r = 0; r < i.length; r++)
this._renderSubMeshForShadowMap(i.data[r], !0);
else
for (r = 0; r < i.length; r++)
i.data[r].getEffectiveMesh()._internalAbstractMeshDataInfo._isActiveIntermediate = !1
}
,
e.prototype._bindCustomEffectForRenderSubMeshForShadowMap = function(e, t, i) {
t.setMatrix("viewProjection", this.getTransformMatrix())
}
,
e.prototype._renderSubMeshForShadowMap = function(e, t) {
var i, n;
void 0 === t && (t = !1);
var r = 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 = r.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 = r._getInstancesRenderList(e._id, !!e.getReplacementMesh());
if (!p.mustReturn) {
var f = l.getCaps().instancedArrays && (null !== p.visibleInstances[e._id] && void 0 !== p.visibleInstances[e._id] || r.hasThinInstances);
if (!this.customAllowRendering || this.customAllowRendering(e))
if (this.isReady(e, f, t)) {
e._renderId = s.getRenderId();
var _ = c.shadowDepthWrapper
, m = null !== (n = null == _ ? void 0 : _.getEffect(e, this, l.currentRenderPassId)) && void 0 !== n ? n : e._getDrawWrapper()
, g = Gt.GetEffect(m);
if (l.enableEffect(m),
f || r._bind(e, g, c.fillMode),
this.getTransformMatrix(),
g.setFloat3("biasAndScaleSM", this.bias, this.normalBias, this.depthScale),
this.getLight().getTypeID() === Cr.LIGHTTYPEID_DIRECTIONALLIGHT ? g.setVector3("lightDataSM", this._cachedDirection) : g.setVector3("lightDataSM", this._cachedPosition),
s.activeCamera && g.setFloat2("depthValuesSM", this.getLight().getDepthMinZ(s.activeCamera), this.getLight().getDepthMinZ(s.activeCamera) + this.getLight().getDepthMaxZ(s.activeCamera)),
t && this.enableSoftTransparentShadow && g.setFloat("softTransparentShadowSM", o.visibility * c.alpha),
_)
e._setMainDrawWrapperOverride(m),
_.standalone ? _.baseMaterial.bindForSubMesh(o.getWorldMatrix(), r, e) : c.bindForSubMesh(o.getWorldMatrix(), r, e),
e._setMainDrawWrapperOverride(null);
else {
if (c && c.needAlphaTesting()) {
var v = c.getAlphaTestTexture();
v && (g.setTexture("diffuseSampler", v),
g.setMatrix("diffuseMatrix", v.getTextureMatrix() || this._defaultTextureMatrix))
}
if (r.useBones && r.computeBonesUsingShaders && r.skeleton) {
var y = r.skeleton;
if (y.isUsingTextureForMatrices) {
var b = y.getTransformMatrixTexture(r);
if (!b)
return;
g.setTexture("boneSampler", b),
g.setFloat("boneTextureWidth", 4 * (y.bones.length + 1))
} else
g.setMatrices("mBones", y.getTransformMatrices(r))
}
Mr.BindMorphTargetParameters(r, g),
r.morphTargetManager && r.morphTargetManager.isUsingTextureForTargets && r.morphTargetManager._bind(g),
Mr.BindClipPlane(g, s)
}
this._useUBO || _ || this._bindCustomEffectForRenderSubMeshForShadowMap(e, g, o),
Mr.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(r),
this.onBeforeShadowMapRenderObservable.notifyObservers(g),
r._processRendering(o, e, g, c.fillMode, p, f, (function(e, t) {
o === r || e ? (o.getMeshUniformBuffer().bindToEffect(g, "Mesh"),
o.transferToEffect(e ? t : T)) : (r.getMeshUniformBuffer().bindToEffect(g, "Mesh"),
r.transferToEffect(t))
}
)),
this.forceBackFacesOnly && l.setState(!0, 0, !1, !1, c.cullBackFaces),
this.onAfterShadowMapRenderObservable.notifyObservers(g),
this.onAfterShadowMapRenderMeshObservable.notifyObservers(r)
} 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(io.NEAREST_SAMPLINGMODE) : this._shadowMap.updateSamplingMode(io.BILINEAR_SAMPLINGMODE))
}
,
e.prototype.forceCompilation = function(e, t) {
var i = this
, n = V({
useInstances: !1
}, t)
, r = this.getShadowMap();
if (r) {
var o = r.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, r;
if (i._scene && i._scene.getEngine()) {
for (; i.isReady(a[u], n.useInstances, null !== (r = null === (t = a[u].getMaterial()) || void 0 === t ? void 0 : t.needAlphaBlendingForMesh(a[u].getMesh())) && void 0 !== r && r); )
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, n) {
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 r = e.getMesh();
return i.push("#define SM_NORMALBIAS " + (this.normalBias && r.isVerticesDataPresent(Bi.NormalKind) ? "1" : "0")),
i.push("#define SM_DIRECTIONINLIGHTDATA " + (this.getLight().getTypeID() === Cr.LIGHTTYPEID_DIRECTIONALLIGHT ? "1" : "0")),
i.push("#define SM_USEDISTANCE " + (this._light.needCube() ? "1" : "0")),
i.push("#define SM_SOFTTRANSPARENTSHADOW " + (this.enableSoftTransparentShadow && n ? "1" : "0")),
this._isReadyCustomDefines(i, e, t),
i
}
,
e.prototype.isReady = function(e, t, i) {
var n = e.getMaterial()
, r = null == n ? void 0 : n.shadowDepthWrapper
, o = [];
if (this._prepareShadowDefines(e, t, o, i),
r) {
if (!r.isReadyForSubMesh(e, o, this, t, this._scene.getEngine().currentRenderPassId))
return !1
} else {
var a = e._getDrawWrapper(void 0, !0)
, s = a.effect
, l = a.defines
, c = [Bi.PositionKind]
, u = e.getMesh();
if (this.normalBias && u.isVerticesDataPresent(Bi.NormalKind) && (c.push(Bi.NormalKind),
o.push("#define NORMAL"),
u.nonUniformScaling && o.push("#define NONUNIFORMSCALING")),
n && n.needAlphaTesting()) {
var h = n.getAlphaTestTexture();
if (h) {
if (!h.isReady())
return !1;
o.push("#define ALPHATEST"),
u.isVerticesDataPresent(Bi.UVKind) && (c.push(Bi.UVKind),
o.push("#define UV1")),
u.isVerticesDataPresent(Bi.UV2Kind) && 1 === h.coordinatesIndex && (c.push(Bi.UV2Kind),
o.push("#define UV2"))
}
}
var d = new ys;
if (u.useBones && u.computeBonesUsingShaders && u.skeleton) {
c.push(Bi.MatricesIndicesKind),
c.push(Bi.MatricesWeightsKind),
u.numBoneInfluencers > 4 && (c.push(Bi.MatricesIndicesExtraKind),
c.push(Bi.MatricesWeightsExtraKind));
var p = u.skeleton;
o.push("#define NUM_BONE_INFLUENCERS " + u.numBoneInfluencers),
u.numBoneInfluencers > 0 && d.addCPUSkinningFallback(0, u),
p.isUsingTextureForMatrices ? o.push("#define BONETEXTURE") : o.push("#define BonesPerMesh " + (p.bones.length + 1))
} else
o.push("#define NUM_BONE_INFLUENCERS 0");
var f = u.morphTargetManager
, _ = 0;
f && f.numInfluencers > 0 && (o.push("#define MORPHTARGETS"),
_ = f.numInfluencers,
o.push("#define NUM_MORPH_INFLUENCERS " + _),
f.isUsingTextureForTargets && o.push("#define MORPHTARGETS_TEXTURE"),
Mr.PrepareAttributesForMorphTargetsInfluencers(c, u, _));
var m = this._scene;
if (m.clipPlane && o.push("#define CLIPPLANE"),
m.clipPlane2 && o.push("#define CLIPPLANE2"),
m.clipPlane3 && o.push("#define CLIPPLANE3"),
m.clipPlane4 && o.push("#define CLIPPLANE4"),
m.clipPlane5 && o.push("#define CLIPPLANE5"),
m.clipPlane6 && o.push("#define CLIPPLANE6"),
t && (o.push("#define INSTANCES"),
Mr.PushAttributesForInstances(c),
e.getRenderingMesh().hasThinInstances && o.push("#define THIN_INSTANCES")),
this.customShaderOptions && this.customShaderOptions.defines)
for (var g = 0, v = this.customShaderOptions.defines; g < v.length; g++) {
var y = v[g];
-1 === o.indexOf(y) && o.push(y)
}
var b = o.join("\n");
if (l !== b) {
l = b;
var T = "shadowMap"
, E = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightDataSM", "depthValuesSM", "biasAndScaleSM", "morphTargetInfluences", "boneTextureWidth", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "softTransparentShadowSM", "morphTargetTextureInfo", "morphTargetTextureIndices"]
, S = ["diffuseSampler", "boneSampler", "morphTargets"];
if (this.customShaderOptions) {
if (T = this.customShaderOptions.shaderName,
this.customShaderOptions.attributes)
for (var A = 0, x = this.customShaderOptions.attributes; A < x.length; A++) {
var R = x[A];
-1 === c.indexOf(R) && c.push(R)
}
if (this.customShaderOptions.uniforms)
for (var C = 0, P = this.customShaderOptions.uniforms; C < P.length; C++) {
var M = P[C];
-1 === E.indexOf(M) && E.push(M)
}
if (this.customShaderOptions.samplers)
for (var I = 0, O = this.customShaderOptions.samplers; I < O.length; I++) {
var D = O[I];
-1 === S.indexOf(D) && S.push(D)
}
}
var N = this._scene.getEngine();
s = N.createEffect(T, {
attributes: c,
uniformsNames: E,
uniformBuffersNames: ["Scene", "Mesh"],
samplers: S,
defines: b,
fallbacks: d,
onCompiled: null,
onError: null,
indexParameters: {
maxSimultaneousMorphTargets: _
}
}, N),
a.setEffect(s, l)
}
if (!s.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 n = this._scene
, r = this._light;
n.shadowsEnabled && r.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),
r.needCube() && (t["SHADOWCUBE" + i] = !0))
}
,
e.prototype.bindShadowLight = function(t, i) {
var n = this._light
, r = this._scene;
if (r.shadowsEnabled && n.shadowEnabled) {
var o = r.activeCamera;
if (o) {
var a = this.getShadowMap();
a && (n.needCube() || i.setMatrix("lightMatrix" + t, this.getTransformMatrix()),
this._filter === e.FILTER_PCF ? (i.setDepthStencilTexture("shadowSampler" + t, this.getShadowMapForRendering()),
n._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), a.getSize().width, 1 / a.getSize().width, this.frustumEdgeFalloff, t)) : this._filter === e.FILTER_PCSS ? (i.setDepthStencilTexture("shadowSampler" + t, this.getShadowMapForRendering()),
i.setTexture("depthSampler" + t, this.getShadowMapForRendering()),
n._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / a.getSize().width, this._contactHardeningLightSizeUVRatio * a.getSize().width, this.frustumEdgeFalloff, t)) : (i.setTexture("shadowSampler" + t, this.getShadowMapForRendering()),
n._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / a.getSize().width, this.depthScale, this.frustumEdgeFalloff, t)),
n._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(o), this.getLight().getDepthMinZ(o) + this.getLight().getDepthMaxZ(o), 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),
x.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection),
1 === Math.abs(x.Dot(this._lightDirection, x.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),
P.LookAtLHToRef(t, t.add(this._lightDirection), x.Up(), this._viewMatrix);
var i = this.getShadowMap();
if (i) {
var n = i.renderList;
n && this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, n)
}
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, n = t; i < n.length; i++) {
var r = n[i];
this._shadowMap.renderList.push(r)
}
} 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() {
this._disposeRTTandPostProcesses(),
this._disposeSceneUBOs(),
this._light && (this._light._shadowGenerator = null,
this._light._markMeshesAsLightDirty()),
this.onBeforeShadowMapRenderMeshObservable.clear(),
this.onBeforeShadowMapRenderObservable.clear(),
this.onAfterShadowMapRenderMeshObservable.clear(),
this.onAfterShadowMapRenderObservable.clear()
}
,
e.prototype.serialize = function() {
var e = {}
, t = this.getShadowMap();
if (!t)
return e;
if (e.className = this.getClassName(),
e.lightId = this._light.id,
e.id = this.id,
e.mapSize = t.getRenderSize(),
e.forceBackFacesOnly = this.forceBackFacesOnly,
e.darkness = this.getDarkness(),
e.transparencyShadow = this._transparencyShadow,
e.frustumEdgeFalloff = this.frustumEdgeFalloff,
e.bias = this.bias,
e.normalBias = this.normalBias,
e.usePercentageCloserFiltering = this.usePercentageCloserFiltering,
e.useContactHardeningShadow = this.useContactHardeningShadow,
e.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio,
e.filteringQuality = this.filteringQuality,
e.useExponentialShadowMap = this.useExponentialShadowMap,
e.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap,
e.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap,
e.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap,
e.usePoissonSampling = this.usePoissonSampling,
e.depthScale = this.depthScale,
e.blurBoxOffset = this.blurBoxOffset,
e.blurKernel = this.blurKernel,
e.blurScale = this.blurScale,
e.useKernelBlur = this.useKernelBlur,
e.renderList = [],
t.renderList)
for (var i = 0; i < t.renderList.length; i++) {
var n = t.renderList[i];
e.renderList.push(n.id)
}
return e
}
,
e.Parse = function(t, i, n) {
for (var r = i.getLightById(t.lightId), o = n ? n(t.mapSize, r) : new e(t.mapSize,r), a = o.getShadowMap(), s = 0; s < t.renderList.length; s++)
i.getMeshesById(t.renderList[s]).forEach((function(e) {
a && (a.renderList || (a.renderList = []),
a.renderList.push(e))
}
));
return void 0 !== t.id && (o.id = t.id),
o.forceBackFacesOnly = !!t.forceBackFacesOnly,
void 0 !== t.darkness && o.setDarkness(t.darkness),
t.transparencyShadow && o.setTransparencyShadow(!0),
void 0 !== t.frustumEdgeFalloff && (o.frustumEdgeFalloff = t.frustumEdgeFalloff),
void 0 !== t.bias && (o.bias = t.bias),
void 0 !== t.normalBias && (o.normalBias = t.normalBias),
t.usePercentageCloserFiltering ? o.usePercentageCloserFiltering = !0 : t.useContactHardeningShadow ? o.useContactHardeningShadow = !0 : t.usePoissonSampling ? o.usePoissonSampling = !0 : t.useExponentialShadowMap ? o.useExponentialShadowMap = !0 : t.useBlurExponentialShadowMap ? o.useBlurExponentialShadowMap = !0 : t.useCloseExponentialShadowMap ? o.useCloseExponentialShadowMap = !0 : t.useBlurCloseExponentialShadowMap ? o.useBlurCloseExponentialShadowMap = !0 : t.useVarianceShadowMap ? o.useExponentialShadowMap = !0 : t.useBlurVarianceShadowMap && (o.useBlurExponentialShadowMap = !0),
void 0 !== t.contactHardeningLightSizeUVRatio && (o.contactHardeningLightSizeUVRatio = t.contactHardeningLightSizeUVRatio),
void 0 !== t.filteringQuality && (o.filteringQuality = t.filteringQuality),
t.depthScale && (o.depthScale = t.depthScale),
t.blurScale && (o.blurScale = t.blurScale),
t.blurBoxOffset && (o.blurBoxOffset = t.blurBoxOffset),
t.useKernelBlur && (o.useKernelBlur = t.useKernelBlur),
t.blurKernel && (o.blurKernel = t.blurKernel),
o
}
,
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._SceneComponentInitialization = function(e) {
throw be("ShadowGeneratorSceneComponent")
}
,
e
}();
Pt.ShadersStore.depthPixelShader = "#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nvarying float vDepthMetric;\n#ifdef PACKED\n#include\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\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}";
Pt.ShadersStore.depthVertexShader = "attribute vec3 position;\n#include\n#include\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\nuniform mat4 viewProjection;\nuniform vec2 depthValues;\n#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\nvarying float vDepthMetric;\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{\nvec3 positionUpdated=position;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\n#include\n#include\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\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#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 o_ = function() {
function e(t, i, n, r, o) {
void 0 === i && (i = a.TEXTURETYPE_FLOAT),
void 0 === n && (n = null),
void 0 === r && (r = !1),
void 0 === o && (o = io.TRILINEAR_SAMPLINGMODE);
var s = this;
this.enabled = !0,
this.forceDepthWriteTransparentMeshes = !1,
this.useOnlyInActiveCamera = !1,
this._scene = t,
this._storeNonLinearDepth = r,
this.isPacked = i === a.TEXTURETYPE_UNSIGNED_BYTE,
this.isPacked ? this._clearColor = new N(1,1,1,1) : this._clearColor = new N(1,0,0,1),
e._SceneComponentInitialization(this._scene);
var l = t.getEngine();
this._camera = n,
o !== io.NEAREST_SAMPLINGMODE && (i !== a.TEXTURETYPE_FLOAT || l._caps.textureFloatLinearFiltering || (o = io.NEAREST_SAMPLINGMODE),
i !== a.TEXTURETYPE_HALF_FLOAT || l._caps.textureHalfFloatLinearFiltering || (o = io.NEAREST_SAMPLINGMODE));
var c = this.isPacked || !l._features.supportExtendedTextureFormats ? a.TEXTUREFORMAT_RGBA : a.TEXTUREFORMAT_R;
this._depthMap = new ns("DepthRenderer",{
width: l.getRenderWidth(),
height: l.getRenderHeight()
},this._scene,!1,!0,i,!1,o,void 0,void 0,void 0,c),
this._depthMap.wrapU = io.CLAMP_ADDRESSMODE,
this._depthMap.wrapV = io.CLAMP_ADDRESSMODE,
this._depthMap.refreshRate = 1,
this._depthMap.renderParticles = !1,
this._depthMap.renderList = null,
this._depthMap.activeCamera = this._camera,
this._depthMap.ignoreCameraViewport = !0,
this._depthMap.useCameraPostProcesses = !1,
this._depthMap.onClearObservable.add((function(e) {
e.clear(s._clearColor, !0, !0, !0)
}
)),
this._depthMap.onBeforeBindObservable.add((function() {
var e;
null === (e = l._debugPushGroup) || void 0 === e || e.call(l, "depth renderer", 1)
}
)),
this._depthMap.onAfterUnbindObservable.add((function() {
var e;
null === (e = l._debugPopGroup) || void 0 === e || e.call(l, 1)
}
)),
this._depthMap.customIsReadyFunction = function(e, t) {
if (!e.isReady(!1))
return !1;
if (0 === t && e.subMeshes)
for (var i = 0; i < e.subMeshes.length; ++i) {
var n = e.subMeshes[i]
, r = n.getRenderingMesh()
, o = r._getInstancesRenderList(n._id, !!n.getReplacementMesh())
, a = l.getCaps().instancedArrays && (null !== o.visibleInstances[n._id] && void 0 !== o.visibleInstances[n._id] || r.hasThinInstances);
if (!s.isReady(n, a))
return !1
}
return !0
}
;
var u = function(e) {
var t, i, n = e.getRenderingMesh(), r = e.getEffectiveMesh(), o = s._scene, l = o.getEngine(), c = e.getMaterial();
if (r._internalAbstractMeshDataInfo._isActiveIntermediate = !1,
c && !r.infiniteDistance && !c.disableDepthWrite && 0 !== e.verticesCount && e._renderId !== o.getRenderId()) {
var u = r._getWorldMatrixDeterminant() < 0
, h = null !== (t = n.overrideMaterialSideOrientation) && void 0 !== t ? t : c.sideOrientation;
u && (h = h === a.MATERIAL_ClockWiseSideOrientation ? a.MATERIAL_CounterClockWiseSideOrientation : a.MATERIAL_ClockWiseSideOrientation);
var d = h === a.MATERIAL_ClockWiseSideOrientation;
l.setState(c.backFaceCulling, 0, !1, 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)
, _ = s._camera || o.activeCamera;
if (s.isReady(e, f) && _) {
e._renderId = o.getRenderId();
var m = null === (i = r._internalAbstractMeshDataInfo._materialForRenderPass) || void 0 === i ? void 0 : i[l.currentRenderPassId]
, g = e._getDrawWrapper();
!g && m && (g = m._getDrawWrapper());
var v = _.mode === Rr.ORTHOGRAPHIC_CAMERA;
if (!g)
return;
var y = g.effect;
l.enableEffect(g),
f || n._bind(e, y, c.fillMode),
m ? m.bindForSubMesh(r.getWorldMatrix(), r, e) : (y.setMatrix("viewProjection", o.getTransformMatrix()),
y.setMatrix("world", r.getWorldMatrix()));
var b = void 0
, T = void 0;
if (v ? (b = !l.useReverseDepthBuffer && l.isNDCHalfZRange ? 0 : 1,
T = l.useReverseDepthBuffer && l.isNDCHalfZRange ? 0 : 1) : (b = l.useReverseDepthBuffer && l.isNDCHalfZRange ? _.minZ : l.isNDCHalfZRange ? 0 : _.minZ,
T = l.useReverseDepthBuffer && l.isNDCHalfZRange ? 0 : _.maxZ),
y.setFloat2("depthValues", b, b + T),
!m) {
if (c && c.needAlphaTesting()) {
var E = c.getAlphaTestTexture();
E && (y.setTexture("diffuseSampler", E),
y.setMatrix("diffuseMatrix", E.getTextureMatrix()))
}
if (n.useBones && n.computeBonesUsingShaders && n.skeleton) {
var S = n.skeleton;
if (S.isUsingTextureForMatrices) {
var A = S.getTransformMatrixTexture(n);
if (!A)
return;
y.setTexture("boneSampler", A),
y.setFloat("boneTextureWidth", 4 * (S.bones.length + 1))
} else
y.setMatrices("mBones", S.getTransformMatrices(n))
}
Mr.BindMorphTargetParameters(n, y),
n.morphTargetManager && n.morphTargetManager.isUsingTextureForTargets && n.morphTargetManager._bind(y)
}
n._processRendering(r, e, y, c.fillMode, p, f, (function(e, t) {
return y.setMatrix("world", t)
}
))
}
}
}
};
this._depthMap.customRenderFunction = function(e, t, i, n) {
var r;
if (n.length)
for (r = 0; r < n.length; r++)
u(n.data[r]);
for (r = 0; r < e.length; r++)
u(e.data[r]);
for (r = 0; r < t.length; r++)
u(t.data[r]);
if (s.forceDepthWriteTransparentMeshes)
for (r = 0; r < i.length; r++)
u(i.data[r]);
else
for (r = 0; r < i.length; r++)
i.data[r].getEffectiveMesh()._internalAbstractMeshDataInfo._isActiveIntermediate = !1
}
}
return e.prototype.setMaterialForRendering = function(e, t) {
this._depthMap.setMaterialForRendering(e, t)
}
,
e.prototype.isReady = function(e, t) {
var i, n = this._scene.getEngine(), r = e.getMesh(), o = null === (i = r._internalAbstractMeshDataInfo._materialForRenderPass) || void 0 === i ? void 0 : i[n.currentRenderPassId];
if (o)
return o.isReadyForSubMesh(r, e, t);
var a = e.getMaterial();
if (!a || a.disableDepthWrite)
return !1;
var s = []
, l = [Bi.PositionKind];
if (a && a.needAlphaTesting() && a.getAlphaTestTexture() && (s.push("#define ALPHATEST"),
r.isVerticesDataPresent(Bi.UVKind) && (l.push(Bi.UVKind),
s.push("#define UV1")),
r.isVerticesDataPresent(Bi.UV2Kind) && (l.push(Bi.UV2Kind),
s.push("#define UV2"))),
r.useBones && r.computeBonesUsingShaders) {
l.push(Bi.MatricesIndicesKind),
l.push(Bi.MatricesWeightsKind),
r.numBoneInfluencers > 4 && (l.push(Bi.MatricesIndicesExtraKind),
l.push(Bi.MatricesWeightsExtraKind)),
s.push("#define NUM_BONE_INFLUENCERS " + r.numBoneInfluencers),
s.push("#define BonesPerMesh " + (r.skeleton ? r.skeleton.bones.length + 1 : 0));
var c = e.getRenderingMesh().skeleton;
(null == c ? void 0 : c.isUsingTextureForMatrices) && s.push("#define BONETEXTURE")
} else
s.push("#define NUM_BONE_INFLUENCERS 0");
var u = r.morphTargetManager
, h = 0;
u && u.numInfluencers > 0 && (h = u.numInfluencers,
s.push("#define MORPHTARGETS"),
s.push("#define NUM_MORPH_INFLUENCERS " + h),
u.isUsingTextureForTargets && s.push("#define MORPHTARGETS_TEXTURE"),
Mr.PrepareAttributesForMorphTargetsInfluencers(l, r, h)),
t && (s.push("#define INSTANCES"),
Mr.PushAttributesForInstances(l),
e.getRenderingMesh().hasThinInstances && s.push("#define THIN_INSTANCES")),
this._storeNonLinearDepth && s.push("#define NONLINEARDEPTH"),
this.isPacked && s.push("#define PACKED");
var d = e._getDrawWrapper(void 0, !0)
, p = d.defines
, f = s.join("\n");
return p !== f && d.setEffect(n.createEffect("depth", l, ["world", "mBones", "boneTextureWidth", "viewProjection", "diffuseMatrix", "depthValues", "morphTargetInfluences", "morphTargetTextureInfo", "morphTargetTextureIndices"], ["diffuseSampler", "morphTargets", "boneSampler"], f, void 0, void 0, void 0, {
maxSimultaneousMorphTargets: h
}), f),
d.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, n = e; i < n.length; i++)
t = n[i],
delete this._scene._depthRenderer[t]
}
}
,
e._SceneComponentInitialization = function(e) {
throw be("DepthRendererSceneComponent")
}
,
e
}();
Pt.ShadersStore.minmaxReduxPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\n#if defined(INITIAL)\nuniform sampler2D sourceTexture;\nuniform vec2 texSize;\nvoid main(void)\n{\nivec2 coord=ivec2(vUV*(texSize-1.0));\nfloat f1=texelFetch(sourceTexture,coord,0).r;\nfloat f2=texelFetch(sourceTexture,coord+ivec2(1,0),0).r;\nfloat f3=texelFetch(sourceTexture,coord+ivec2(1,1),0).r;\nfloat f4=texelFetch(sourceTexture,coord+ivec2(0,1),0).r;\nfloat 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}\n#elif defined(MAIN)\nuniform vec2 texSize;\nvoid main(void)\n{\nivec2 coord=ivec2(vUV*(texSize-1.0));\nvec2 f1=texelFetch(textureSampler,coord,0).rg;\nvec2 f2=texelFetch(textureSampler,coord+ivec2(1,0),0).rg;\nvec2 f3=texelFetch(textureSampler,coord+ivec2(1,1),0).rg;\nvec2 f4=texelFetch(textureSampler,coord+ivec2(0,1),0).rg;\nfloat minz=min(min(min(f1.x,f2.x),f3.x),f4.x);\nfloat maxz=max(max(max(f1.y,f2.y),f3.y),f4.y);\nglFragColor=vec4(minz,maxz,0.,0.);\n}\n#elif defined(ONEBEFORELAST)\nuniform ivec2 texSize;\nvoid main(void)\n{\nivec2 coord=ivec2(vUV*vec2(texSize-1));\nvec2 f1=texelFetch(textureSampler,coord % texSize,0).rg;\nvec2 f2=texelFetch(textureSampler,(coord+ivec2(1,0)) % texSize,0).rg;\nvec2 f3=texelFetch(textureSampler,(coord+ivec2(1,1)) % texSize,0).rg;\nvec2 f4=texelFetch(textureSampler,(coord+ivec2(0,1)) % texSize,0).rg;\nfloat minz=min(f1.x,f2.x);\nfloat maxz=max(f1.y,f2.y);\nglFragColor=vec4(minz,maxz,0.,0.);\n}\n#elif defined(LAST)\nvoid main(void)\n{\nglFragColor=vec4(0.);\nif (true) { \ndiscard;\n}\n}\n#endif\n";
var a_ = function() {
function e(e) {
var t = this;
this.onAfterReductionPerformed = new h,
this._forceFullscreenViewport = !0,
this._activated = !1,
this._camera = e,
this._postProcessManager = new Vi(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, n) {
var r = this;
if (void 0 === i && (i = a.TEXTURETYPE_HALF_FLOAT),
void 0 === n && (n = !0),
e !== this._sourceTexture) {
this.dispose(!1),
this._sourceTexture = e,
this._reductionSteps = [],
this._forceFullscreenViewport = n;
var o = this._camera.getScene()
, s = new Ba("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 = n;
var l = this._sourceTexture.getRenderWidth()
, c = this._sourceTexture.getRenderHeight();
s.onApply = function(e, t) {
return function(i) {
i.setTexture("sourceTexture", r._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 Ba("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 = n,
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 n = new Float32Array(4 * e * t)
, a = {
min: 0,
max: 0
};
return function() {
o.getEngine()._readTexturePixels(i.inputTexture.texture, e, t, -1, 0, n, !1),
a.min = n[0],
a.max = n[1],
r.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, n = e._camera.getScene().getEngine();
null === (t = n._debugPushGroup) || void 0 === t || t.call(n, "min max reduction", 1),
e._reductionSteps[0].activate(e._camera),
e._postProcessManager.directRender(e._reductionSteps, e._reductionSteps[0].inputTexture, e._forceFullscreenViewport),
n.unBindFramebuffer(e._reductionSteps[0].inputTexture, !1),
null === (i = n._debugPopGroup) || void 0 === i || i.call(n, 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
}()
, s_ = function(e) {
function t(t) {
return e.call(this, t) || this
}
return U(t, e),
Object.defineProperty(t.prototype, "depthRenderer", {
get: function() {
return this._depthRenderer
},
enumerable: !1,
configurable: !0
}),
t.prototype.setDepthRenderer = function(t, i, n) {
void 0 === t && (t = null),
void 0 === i && (i = a.TEXTURETYPE_HALF_FLOAT),
void 0 === n && (n = !0);
var r = this._camera.getScene();
this._depthRenderer && (delete r._depthRenderer[this._depthRendererId],
this._depthRenderer.dispose(),
this._depthRenderer = null),
null === t && (r._depthRenderer || (r._depthRenderer = {}),
(t = this._depthRenderer = new o_(r,i,this._camera,!1,a.TEXTURE_NEAREST_SAMPLINGMODE)).enabled = !1,
this._depthRendererId = "minmax" + this._camera.id,
r._depthRenderer[this._depthRendererId] = t),
e.prototype.setSourceTexture.call(this, t.getDepthMap(), !0, i, n)
}
,
t.prototype.setSourceTexture = function(t, i, n, r) {
void 0 === n && (n = a.TEXTURETYPE_HALF_FLOAT),
void 0 === r && (r = !0),
e.prototype.setSourceTexture.call(this, t, i, n, r)
}
,
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
}(a_)
, l_ = x.Up()
, c_ = x.Zero()
, u_ = new x
, h_ = new x
, d_ = new P
, p_ = function(e) {
function t(i, n, r) {
var o = this;
return t.IsSupported ? ((o = e.call(this, i, n, r) || this).usePercentageCloserFiltering = !0,
o) : (K.Error("CascadedShadowMap is not supported by the current engine."),
o)
}
return U(t, e),
t.prototype._validateFilter = function(e) {
return e === r_.FILTER_NONE || e === r_.FILTER_PCF || e === r_.FILTER_PCSS ? e : (console.error('Unsupported filter "' + e + '"!'),
r_.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 (r = e[t]) {
var i = r.getBoundingInfo().boundingBox;
this._scbiMin.minimizeInPlace(i.minimumWorld),
this._scbiMax.maximizeInPlace(i.maximumWorld)
}
var n = this._scene.meshes;
for (t = 0; t < n.length; t++) {
var r;
(r = n[t]) && r.isVisible && r.isEnabled && r.receiveShadows && (i = r.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._scene && this._scene.activeCamera ? this._shadowMaxZ : 0
},
set: function(e) {
this._scene && this._scene.activeCamera ? this._shadowMaxZ === e || e < this._scene.activeCamera.minZ || e > this._scene.activeCamera.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._scene.activeCamera;
if (i) {
if (this._autoCalcDepthBounds = e,
!e)
return this._depthReducer && this._depthReducer.deactivate(),
void this.setMinMaxDistance(0, 1);
this._depthReducer || (this._depthReducer = new s_(i),
this._depthReducer.onAfterReductionPerformed.add((function(e) {
var i = e.min
, n = e.max;
i >= n && (i = 0,
n = 1),
i == t._minDistance && n == t._maxDistance || t.setMinMaxDistance(i, n)
}
)),
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._scene.activeCamera;
if (e) {
for (var t = e.minZ, i = e.maxZ, n = i - t, r = this._minDistance, o = t + r * n, a = t + (this._shadowMaxZ < i && this._shadowMaxZ >= t ? Math.min((this._shadowMaxZ - t) / (i - t), this._maxDistance) : this._maxDistance) * n, 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 ? r : this._cascades[c - 1].breakDistance,
this._cascades[c].breakDistance = (p - t) / n,
this._viewSpaceFrustumsZ[c] = p,
this._frustumLengths[c] = (this._cascades[c].breakDistance - this._cascades[c].prevBreakDistance) * n
}
this._breaksAreDirty = !1
}
}
,
t.prototype._computeMatrices = function() {
var e = this._scene;
if (e.activeCamera) {
x.NormalizeToRef(this._light.getShadowDirection(0), this._lightDirection),
1 === Math.abs(x.Dot(this._lightDirection, x.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], u_),
this._frustumCenter[i].addToRef(this._lightDirection.scale(this._cascadeMinExtents[i].z), this._shadowCameraPos[i]),
P.LookAtLHToRef(this._shadowCameraPos[i], this._frustumCenter[i], l_, this._viewMatrices[i]);
var n = 0
, r = u_.z
, o = this._shadowCastersBoundingInfo;
o.update(this._viewMatrices[i]),
r = Math.min(r, o.boundingBox.maximumWorld.z),
n = this._depthClamp && this.filter !== r_.FILTER_PCSS ? Math.max(n, o.boundingBox.minimumWorld.z) : Math.min(n, o.boundingBox.minimumWorld.z),
P.OrthoOffCenterLHToRef(this._cascadeMinExtents[i].x, this._cascadeMaxExtents[i].x, this._cascadeMinExtents[i].y, this._cascadeMaxExtents[i].y, t ? r : n, t ? n : r, this._projectionMatrices[i], e.getEngine().isNDCHalfZRange),
this._cascadeMinExtents[i].z = n,
this._cascadeMaxExtents[i].z = r,
this._viewMatrices[i].multiplyToRef(this._projectionMatrices[i], this._transformMatrices[i]),
x.TransformCoordinatesToRef(c_, this._transformMatrices[i], u_),
u_.scaleInPlace(this._mapSize / 2),
h_.copyFromFloats(Math.round(u_.x), Math.round(u_.y), Math.round(u_.z)),
h_.subtractInPlace(u_).scaleInPlace(2 / this._mapSize),
P.TranslationToRef(h_.x, h_.y, 0, d_),
this._projectionMatrices[i].multiplyToRef(d_, 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) {
if (this._scene.activeCamera) {
var i = this._cascades[e].prevBreakDistance
, n = this._cascades[e].breakDistance
, r = this._scene.getEngine().isNDCHalfZRange;
this._scene.activeCamera.getViewMatrix();
for (var o = P.Invert(this._scene.activeCamera.getTransformationMatrix()), a = this._scene.getEngine().useReverseDepthBuffer ? 4 : 0, s = 0; s < t._FrustumCornersNDCSpace.length; ++s)
u_.copyFrom(t._FrustumCornersNDCSpace[(s + a) % t._FrustumCornersNDCSpace.length]),
r && -1 === u_.z && (u_.z = 0),
x.TransformCoordinatesToRef(u_, o, this._frustumCornersWorldSpace[e][s]);
for (s = 0; s < t._FrustumCornersNDCSpace.length / 2; ++s)
u_.copyFrom(this._frustumCornersWorldSpace[e][s + 4]).subtractInPlace(this._frustumCornersWorldSpace[e][s]),
h_.copyFrom(u_).scaleInPlace(i),
u_.scaleInPlace(n),
u_.addInPlace(this._frustumCornersWorldSpace[e][s]),
this._frustumCornersWorldSpace[e][s + 4].copyFrom(u_),
this._frustumCornersWorldSpace[e][s].addInPlace(h_)
}
}
,
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._scene.activeCamera) {
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 n = this._frustumCornersWorldSpace[e][t].subtractToRef(this._frustumCenter[e], u_).length();
i = Math.max(i, n)
}
i = Math.ceil(16 * i) / 16,
this._cascadeMaxExtents[e].copyFromFloats(i, i, i),
this._cascadeMinExtents[e].copyFromFloats(-i, -i, -i)
} else {
var r = this._frustumCenter[e];
for (this._frustumCenter[e].addToRef(this._lightDirection, u_),
P.LookAtLHToRef(r, u_, l_, d_),
t = 0; t < this._frustumCornersWorldSpace[e].length; ++t)
x.TransformCoordinatesToRef(this._frustumCornersWorldSpace[e][t], d_, u_),
this._cascadeMinExtents[e].minimizeInPlace(u_),
this._cascadeMaxExtents[e].maximizeInPlace(u_)
}
}
}
,
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 = E.LastCreatedEngine;
return !!e && e._features.supportCSM
},
enumerable: !1,
configurable: !0
}),
t.prototype._initializeGenerator = function() {
var i, n, r, 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 !== (n = this._numCascades) && void 0 !== n ? n : t.DEFAULT_CASCADES_COUNT,
this.stabilizeCascades = null !== (r = this.stabilizeCascades) && void 0 !== r && r,
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 x(0,0,0),
this._scbiMax = null !== (l = this._scbiMax) && void 0 !== l ? l : new x(0,0,0),
this._shadowCastersBoundingInfo = null !== (c = this._shadowCastersBoundingInfo) && void 0 !== c ? c : new sr(new x(0,0,0),new x(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._scene.activeCamera) || 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 ns(this._light.name + "_CSMShadowMap",t,this._scene,!1,!0,this._textureType,!1,void 0,!1,!1,void 0),
this._shadowMap.createDepthStencilTexture(e.useReverseDepthBuffer ? a.GREATER : a.LESS, !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 n = 0; n < this._numCascades; ++n) {
this._cascades[n] = {
prevBreakDistance: 0,
breakDistance: 0
},
this._viewMatrices[n] = P.Zero(),
this._projectionMatrices[n] = P.Zero(),
this._transformMatrices[n] = P.Zero(),
this._cascadeMinExtents[n] = new x,
this._cascadeMaxExtents[n] = new x,
this._frustumCenter[n] = new x,
this._shadowCameraPos[n] = new x,
this._frustumCornersWorldSpace[n] = new Array(t._FrustumCornersNDCSpace.length);
for (var r = 0; r < t._FrustumCornersNDCSpace.length; ++r)
this._frustumCornersWorldSpace[n][r] = new x
}
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 === r_.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 !== r_.FILTER_PCSS ? "1" : "0"))
}
,
t.prototype.prepareDefines = function(t, i) {
e.prototype.prepareDefines.call(this, t, i);
var n = this._scene
, r = this._light;
if (n.shadowsEnabled && r.shadowEnabled) {
t["SHADOWCSM" + i] = !0,
t["SHADOWCSMDEBUG" + i] = this.debug,
t["SHADOWCSMNUM_CASCADES" + i] = this.numCascades,
t["SHADOWCSM_RIGHTHANDED" + i] = n.useRightHandedSystem;
var o = n.activeCamera;
o && this._shadowMaxZ < o.maxZ && (t["SHADOWCSMUSESHADOWMAXZ" + i] = !0),
0 === this.cascadeBlendPercentage && (t["SHADOWCSMNOBLEND" + i] = !0)
}
}
,
t.prototype.bindShadowLight = function(e, t) {
var i = this._light
, n = this._scene;
if (n.shadowsEnabled && i.shadowEnabled) {
var r = n.activeCamera;
if (r) {
var o = this.getShadowMap();
if (o) {
var a = o.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 === r_.FILTER_PCF)
t.setDepthStencilTexture("shadowSampler" + e, o),
i._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), a, 1 / a, this.frustumEdgeFalloff, e);
else if (this._filter === r_.FILTER_PCSS) {
for (var s = 0; s < this._numCascades; ++s)
this._lightSizeUVCorrection[2 * s + 0] = 0 === s ? 1 : (this._cascadeMaxExtents[0].x - this._cascadeMinExtents[0].x) / (this._cascadeMaxExtents[s].x - this._cascadeMinExtents[s].x),
this._lightSizeUVCorrection[2 * s + 1] = 0 === s ? 1 : (this._cascadeMaxExtents[0].y - this._cascadeMinExtents[0].y) / (this._cascadeMaxExtents[s].y - this._cascadeMinExtents[s].y),
this._depthCorrection[s] = 0 === s ? 1 : (this._cascadeMaxExtents[s].z - this._cascadeMinExtents[s].z) / (this._cascadeMaxExtents[0].z - this._cascadeMinExtents[0].z);
t.setDepthStencilTexture("shadowSampler" + e, o),
t.setTexture("depthSampler" + e, o),
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 / a, this._contactHardeningLightSizeUVRatio * a, this.frustumEdgeFalloff, e)
} else
t.setTexture("shadowSampler" + e, o),
i._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), a, 1 / a, 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 n = 0; n < i.renderList.length; n++) {
var r = i.renderList[n];
t.renderList.push(r.id)
}
return t
}
,
t.Parse = function(e, i) {
var n = r_.Parse(e, i, (function(e, i) {
return new t(e,i)
}
));
return void 0 !== e.numCascades && (n.numCascades = e.numCascades),
void 0 !== e.debug && (n.debug = e.debug),
void 0 !== e.stabilizeCascades && (n.stabilizeCascades = e.stabilizeCascades),
void 0 !== e.lambda && (n.lambda = e.lambda),
void 0 !== e.cascadeBlendPercentage && (n.cascadeBlendPercentage = e.cascadeBlendPercentage),
void 0 !== e.depthClamp && (n.depthClamp = e.depthClamp),
void 0 !== e.autoCalcDepthBounds && (n.autoCalcDepthBounds = e.autoCalcDepthBounds),
void 0 !== e.shadowMaxZ && (n.shadowMaxZ = e.shadowMaxZ),
void 0 !== e.penumbraDarkness && (n.penumbraDarkness = e.penumbraDarkness),
void 0 !== e.freezeShadowCastersBoundingInfo && (n.freezeShadowCastersBoundingInfo = e.freezeShadowCastersBoundingInfo),
void 0 !== e.minDistance && void 0 !== e.maxDistance && n.setMinMaxDistance(e.minDistance, e.maxDistance),
n
}
,
t._FrustumCornersNDCSpace = [new x(-1,1,-1), new x(1,1,-1), new x(1,-1,-1), new x(-1,-1,-1), new x(-1,1,1), new x(1,1,1), new x(1,-1,1), new x(-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 be("ShadowGeneratorSceneComponent")
}
,
t
}(r_);
o.AddParser(Wi.NAME_SHADOWGENERATOR, (function(e, t) {
if (void 0 !== e.shadowGenerators && null !== e.shadowGenerators)
for (var i = 0, n = e.shadowGenerators.length; i < n; i++) {
var r = e.shadowGenerators[i];
r.className === p_.CLASSNAME ? p_.Parse(r, t) : r_.Parse(r, t)
}
}
));
var f_ = function() {
function e(e) {
this.name = Wi.NAME_SHADOWGENERATOR,
this.scene = e
}
return e.prototype.register = function() {
this.scene._gatherRenderTargetsStage.registerStep(Wi.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 n = i[t].getShadowGenerator();
n && e.shadowGenerators.push(n.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 n = t.lights[i]
, r = n.getShadowGenerator();
if (n.isEnabled() && n.shadowEnabled && r) {
var o = r.getShadowMap();
-1 !== t.textures.indexOf(o) && e.push(o)
}
}
}
,
e
}();
r_._SceneComponentInitialization = function(e) {
var t = e._getComponent(Wi.NAME_SHADOWGENERATOR);
t || (t = new f_(e),
e._addComponent(t))
}
,
Xe.AddNodeConstructor("Light_Type_0", (function(e, t) {
return function() {
return new __(e,x.Zero(),t)
}
}
));
var __ = function(e) {
function t(t, i, n) {
var r = e.call(this, t, n) || this;
return r._shadowAngle = Math.PI / 2,
r.position = i,
r
}
return U(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();
this._direction = e,
this.needCube() !== t && this._shadowGenerator && this._shadowGenerator.recreateShadowMap()
},
enumerable: !1,
configurable: !0
}),
t.prototype.getClassName = function() {
return "PointLight"
}
,
t.prototype.getTypeID = function() {
return Cr.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 x(1,0,0);
case 1:
return new x(-1,0,0);
case 2:
return new x(0,-1,0);
case 3:
return new x(0,1,0);
case 4:
return new x(0,0,1);
case 5:
return new x(0,0,-1)
}
return x.Zero()
}
,
t.prototype._setDefaultShadowProjectionMatrix = function(e, t, i) {
var n = this.getScene().activeCamera;
if (n) {
var r = void 0 !== this.shadowMinZ ? this.shadowMinZ : n.minZ
, o = void 0 !== this.shadowMaxZ ? this.shadowMaxZ : n.maxZ
, a = this.getScene().getEngine().useReverseDepthBuffer;
P.PerspectiveFovLHToRef(this.shadowAngle, 1, a ? o : r, a ? r : 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
}
,
k([Ce()], t.prototype, "shadowAngle", null),
t
}(xd)
, m_ = function() {
function e(e, t, i) {
void 0 === t && (t = ""),
void 0 === i && (i = "black");
var n = this;
this._renderingCanvas = e,
this._loadingText = t,
this._loadingDivBackgroundColor = i,
this._resizeLoadingUI = function() {
var e = n._renderingCanvas.getBoundingClientRect()
, t = window.getComputedStyle(n._renderingCanvas).position;
n._loadingDiv && (n._loadingDiv.style.position = "fixed" === t ? "fixed" : "absolute",
n._loadingDiv.style.left = e.left + "px",
n._loadingDiv.style.top = e.top + "px",
n._loadingDiv.style.width = e.width + "px",
n._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 n = document.createElement("div");
n.style.width = "300px",
n.style.gridColumn = "1",
n.style.gridRow = "1",
n.style.top = "50%",
n.style.left = "50%",
n.style.transform = "translate(-50%, -50%)",
n.style.position = "absolute";
var r = new Image;
if (e.DefaultSpinnerUrl ? r.src = e.DefaultSpinnerUrl : r.src = t ? "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzOTIgMzkyIj48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2UwNjg0Yjt9LmNscy0ye2ZpbGw6bm9uZTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPlNwaW5uZXJJY29uPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iU3Bpbm5lciI+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNNDAuMjEsMTI2LjQzYzMuNy03LjMxLDcuNjctMTQuNDQsMTItMjEuMzJsMy4zNi01LjEsMy41Mi01YzEuMjMtMS42MywyLjQxLTMuMjksMy42NS00LjkxczIuNTMtMy4yMSwzLjgyLTQuNzlBMTg1LjIsMTg1LjIsMCwwLDEsODMuNCw2Ny40M2EyMDgsMjA4LDAsMCwxLDE5LTE1LjY2YzMuMzUtMi40MSw2Ljc0LTQuNzgsMTAuMjUtN3M3LjExLTQuMjgsMTAuNzUtNi4zMmM3LjI5LTQsMTQuNzMtOCwyMi41My0xMS40OSwzLjktMS43Miw3Ljg4LTMuMywxMi00LjY0YTEwNC4yMiwxMDQuMjIsMCwwLDEsMTIuNDQtMy4yMyw2Mi40NCw2Mi40NCwwLDAsMSwxMi43OC0xLjM5QTI1LjkyLDI1LjkyLDAsMCwxLDE5NiwyMS40NGE2LjU1LDYuNTUsMCwwLDEsMi4wNSw5LDYuNjYsNi42NiwwLDAsMS0xLjY0LDEuNzhsLS40MS4yOWEyMi4wNywyMi4wNywwLDAsMS01Ljc4LDMsMzAuNDIsMzAuNDIsMCwwLDEtNS42NywxLjYyLDM3LjgyLDM3LjgyLDAsMCwxLTUuNjkuNzFjLTEsMC0xLjkuMTgtMi44NS4yNmwtMi44NS4yNHEtNS43Mi41MS0xMS40OCwxLjFjLTMuODQuNC03LjcxLjgyLTExLjU4LDEuNGExMTIuMzQsMTEyLjM0LDAsMCwwLTIyLjk0LDUuNjFjLTMuNzIsMS4zNS03LjM0LDMtMTAuOTQsNC42NHMtNy4xNCwzLjUxLTEwLjYsNS41MUExNTEuNiwxNTEuNiwwLDAsMCw2OC41Niw4N0M2Ny4yMyw4OC40OCw2Niw5MCw2NC42NCw5MS41NnMtMi41MSwzLjE1LTMuNzUsNC43M2wtMy41NCw0LjljLTEuMTMsMS42Ni0yLjIzLDMuMzUtMy4zMyw1YTEyNywxMjcsMCwwLDAtMTAuOTMsMjEuNDksMS41OCwxLjU4LDAsMSwxLTMtMS4xNVM0MC4xOSwxMjYuNDcsNDAuMjEsMTI2LjQzWiIvPjxyZWN0IGNsYXNzPSJjbHMtMiIgd2lkdGg9IjM5MiIgaGVpZ2h0PSIzOTIiLz48L2c+PC9nPjwvc3ZnPg==" : "https://cdn.babylonjs.com/Assets/loadingIcon.png",
r.style.animation = "spin1 0.75s infinite linear",
r.style.webkitAnimation = "spin1 0.75s infinite linear",
r.style.transformOrigin = "50% 50%",
r.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)"),
r.style.width = "".concat(a.w, "vh"),
r.style.height = "".concat(a.h, "vh"),
r.style.left = "calc(50% - ".concat(a.w / 2, "vh)"),
r.style.top = "calc(50% - ".concat(a.h / 2, "vh)")
}
n.appendChild(r),
this._loadingDiv.appendChild(i),
this._loadingDiv.appendChild(n),
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._loadingDiv && (e._loadingDiv.parentElement && e._loadingDiv.parentElement.removeChild(e._loadingDiv),
e._loadingDiv = null),
e._style && (e._style.parentElement && e._style.parentElement.removeChild(e._style),
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
}();
vr.DefaultLoadingScreenFactory = function(e) {
return new m_(e)
}
;
var g_ = function() {
function e() {}
return e.ConvertPanoramaToCubemap = function(e, t, i, n) {
if (!e)
throw "ConvertPanoramaToCubemap: input cannot be null";
if (e.length != t * i * 3)
throw "ConvertPanoramaToCubemap: input size is wrong";
return {
front: this.CreateCubemapTexture(n, this.FACE_FRONT, e, t, i),
back: this.CreateCubemapTexture(n, this.FACE_BACK, e, t, i),
left: this.CreateCubemapTexture(n, this.FACE_LEFT, e, t, i),
right: this.CreateCubemapTexture(n, this.FACE_RIGHT, e, t, i),
up: this.CreateCubemapTexture(n, this.FACE_UP, e, t, i),
down: this.CreateCubemapTexture(n, this.FACE_DOWN, e, t, i),
size: n,
type: a.TEXTURETYPE_FLOAT,
format: a.TEXTUREFORMAT_RGB,
gammaSpace: !1
}
}
,
e.CreateCubemapTexture = function(e, t, i, n, r) {
for (var o = new ArrayBuffer(e * e * 4 * 3), a = new Float32Array(o), s = t[1].subtract(t[0]).scale(1 / e), l = t[3].subtract(t[2]).scale(1 / e), c = 1 / e, u = 0, h = 0; h < e; h++) {
for (var d = t[0], p = t[2], f = 0; f < e; f++) {
var _ = p.subtract(d).scale(u).add(d);
_.normalize();
var m = this.CalcProjectionSpherical(_, i, n, r);
a[h * e * 3 + 3 * f + 0] = m.r,
a[h * e * 3 + 3 * f + 1] = m.g,
a[h * e * 3 + 3 * f + 2] = m.b,
d = d.add(s),
p = p.add(l)
}
u += c
}
return a
}
,
e.CalcProjectionSpherical = function(e, t, i, n) {
for (var r = Math.atan2(e.z, e.x), o = Math.acos(e.y); r < -Math.PI; )
r += 2 * Math.PI;
for (; r > Math.PI; )
r -= 2 * Math.PI;
var a = r / 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 * n);
c < 0 ? c = 0 : c >= n && (c = n - 1);
var u = n - 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 x(-1,-1,-1), new x(1,-1,-1), new x(-1,1,-1), new x(1,1,-1)],
e.FACE_RIGHT = [new x(1,-1,1), new x(-1,-1,1), new x(1,1,1), new x(-1,1,1)],
e.FACE_FRONT = [new x(1,-1,-1), new x(1,-1,1), new x(1,1,-1), new x(1,1,1)],
e.FACE_BACK = [new x(-1,-1,1), new x(-1,-1,-1), new x(-1,1,1), new x(-1,1,-1)],
e.FACE_DOWN = [new x(1,1,-1), new x(1,1,1), new x(-1,1,-1), new x(-1,1,1)],
e.FACE_UP = [new x(-1,-1,-1), new x(-1,-1,1), new x(1,-1,-1), new x(1,-1,1)],
e
}()
, v_ = 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, n, r, o) {
r > 0 ? (r = this._Ldexp(1, r - 136),
e[o + 0] = t * r,
e[o + 1] = i * r,
e[o + 2] = n * r) : (e[o + 0] = 0,
e[o + 1] = 0,
e[o + 2] = 0)
}
,
e._ReadStringLine = function(e, t) {
for (var i = "", n = "", r = t; r < e.length - t && "\n" != (n = String.fromCharCode(e[r])); r++)
i += n;
return i
}
,
e.RGBE_ReadHeader = function(e) {
var t, i, n = this._ReadStringLine(e, 0);
if ("#" != n[0] || "?" != n[1])
throw "Bad HDR Format.";
var r = !1
, o = !1
, a = 0;
do {
a += n.length + 1,
"FORMAT=32-bit_rle_rgbe" == (n = this._ReadStringLine(e, a)) ? o = !0 : 0 == n.length && (r = !0)
} while (!r);
if (!o)
throw "HDR Bad header format, unsupported FORMAT";
a += n.length + 1,
n = this._ReadStringLine(e, a);
var s = /^-Y (.*) \+X (.*)$/g.exec(n);
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 += n.length + 1
}
}
,
e.GetCubeMapTextureData = function(e, t) {
var i = new Uint8Array(e)
, n = this.RGBE_ReadHeader(i)
, r = this.RGBE_ReadPixels(i, n);
return g_.ConvertPanoramaToCubemap(r, n.width, n.height, t)
}
,
e.RGBE_ReadPixels = function(e, t) {
return this._RGBEReadPixelsRLE(e, t)
}
,
e._RGBEReadPixelsRLE = function(e, t) {
for (var i, n, r, 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++],
n = e[c++],
r = e[c++],
o = e[c++],
2 != i || 2 != n || 128 & r || t.width < 8 || t.width > 32767)
return this._RGBEReadPixelsNOTRLE(e, t);
if ((r << 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++],
n = 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++] = n
} else {
if (0 == (a = i) || a > h - u)
throw "HDR Bad Format, bad scanline data (non-run)";
if (f[u++] = n,
--a > 0)
for (var g = 0; g < a; g++)
f[u++] = e[c++]
}
for (d = 0; d < l; d++)
i = f[d],
n = f[d + l],
r = f[d + 2 * l],
o = f[d + 3 * l],
this._Rgbe2float(m, i, n, r, o, (t.height - s) * l * 3 + 3 * d);
s--
}
return m
}
,
e._RGBEReadPixelsNOTRLE = function(e, t) {
for (var i, n, r, 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++],
n = e[c++],
r = e[c++],
o = e[c++],
this._Rgbe2float(h, i, n, r, o, (t.height - s) * l * 3 + 3 * a);
s--
}
return h
}
,
e
}()
, y_ = function() {
function e(t, i) {
var n;
void 0 === i && (i = e._DefaultOptions);
var r = this;
this._engine = t,
this._fullscreenViewport = new xr(0,0,1,1),
i = V(V({}, e._DefaultOptions), i),
this._vertexBuffers = ((n = {})[Bi.PositionKind] = new Bi(t,i.positions,Bi.PositionKind,!1,!1,2),
n),
this._indexBuffer = t.createIndexBuffer(i.indices),
this._onContextRestoredObserver = t.onContextRestoredObservable.add((function() {
for (var e in r._indexBuffer = t.createIndexBuffer(i.indices),
r._vertexBuffers)
r._vertexBuffers[e]._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.depthCullingState.depthTest = !1,
this._engine.stencilState.stencilTest = !1,
this._engine.enableEffect(e._drawWrapper),
this.bindBuffers(e.effect),
e.onApplyObservable.notifyObservers({})
}
,
e.prototype.restoreStates = function() {
this._engine.depthCullingState.depthTest = !0,
this._engine.stencilState.stencilTest = !0
}
,
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.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[Bi.PositionKind];
e && (e.dispose(),
delete this._vertexBuffers[Bi.PositionKind]),
this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer),
this._onContextRestoredObserver && (this._engine.onContextRestoredObservable.remove(this._onContextRestoredObserver),
this._onContextRestoredObserver = null)
}
,
e._DefaultOptions = {
positions: [1, 1, -1, 1, -1, -1, 1, -1],
indices: [0, 1, 2, 0, 2, 3]
},
e
}()
, b_ = function() {
function e(e) {
var t, i = this;
this.onApplyObservable = new h;
var n = e.uniformNames || [];
e.vertexShader ? t = {
fragmentSource: e.fragmentShader,
vertexSource: e.vertexShader,
spectorName: e.name || "effectWrapper"
} : (n.push("scale"),
t = {
fragmentSource: e.fragmentShader,
vertex: "postprocess",
spectorName: e.name || "effectWrapper"
},
this.onApplyObservable.add((function() {
i.effect.setFloat2("scale", 1, 1)
}
)));
var r = e.defines ? e.defines.join("\n") : "";
this._drawWrapper = new Gt(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"], n, e.samplerNames, r, void 0, e.onCompiled, void 0, void 0, e.shaderLanguage)) : (this.effect = new Mt(t,e.attributeNames || ["position"],n,e.samplerNames,e.engine,r,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
}();
Pt.ShadersStore.hdrFilteringVertexShader = "attribute vec2 position;\nvarying vec3 direction;\nuniform vec3 up;\nuniform vec3 right;\nuniform vec3 front;\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nmat3 view=mat3(up,right,front);\ndirection=view*vec3(position,1.0);\ngl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";
Pt.ShadersStore.hdrFilteringPixelShader = "#include\n#include\n#include\n#include\nuniform float alphaG;\nuniform samplerCube inputTexture;\nuniform vec2 vFilteringInfo;\nuniform float hdrScale;\nvarying vec3 direction;\nvoid main() {\nvec3 color=radiance(alphaG,inputTexture,direction,vFilteringInfo);\ngl_FragColor=vec4(color*hdrScale,1.0);\n}";
var T_ = 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.hdrScale || 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 = d.ILog2(t) + 1
, n = this._effectWrapper.effect
, r = this._createRenderTarget(t);
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 x(0,0,-1), new x(0,-1,0), new x(1,0,0)], [new x(0,0,1), new x(0,-1,0), new x(-1,0,0)], [new x(1,0,0), new x(0,0,1), new x(0,1,0)], [new x(1,0,0), new x(0,0,-1), new x(0,-1,0)], [new x(1,0,0), new x(0,-1,0), new x(0,0,1)], [new x(-1,0,0), new x(0,-1,0), new x(0,0,-1)]];
n.setFloat("hdrScale", this.hdrScale),
n.setFloat2("vFilteringInfo", e.getSize().width, i),
n.setTexture("inputTexture", e);
for (var l = 0; l < 6; l++) {
n.setVector3("up", s[l][0]),
n.setVector3("right", s[l][1]),
n.setVector3("front", s[l][2]);
for (var c = 0; c < i; c++) {
this._engine.bindFramebuffer(r, 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),
n.setFloat("alphaG", u),
this._effectRenderer.draw()
}
}
return this._effectRenderer.restoreStates(),
this._engine.restoreDefaultFramebuffer(),
this._engine._releaseTexture(e._texture),
r._swapAndDie(e._texture),
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 b_({
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(n) {
i._effectRenderer = new y_(i._engine),
i._effectWrapper = i._createEffect(e),
i._effectWrapper.effect.executeWhenCompiled((function() {
i._prefilterInternal(e),
i._effectRenderer.dispose(),
i._effectWrapper.dispose(),
n(),
t && t()
}
))
}
)) : (K.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
}()
, E_ = function(e) {
function t(t, i, n, r, o, s, l, c, u) {
void 0 === r && (r = !1),
void 0 === o && (o = !0),
void 0 === s && (s = !1),
void 0 === l && (l = !1),
void 0 === c && (c = null),
void 0 === u && (u = null);
var d, p = this;
return (p = e.call(this, i) || this)._generateHarmonics = !0,
p._onError = null,
p._isBlocking = !0,
p._rotationY = 0,
p.boundingBoxPosition = x.Zero(),
p.onLoadObservable = new h,
t ? (p._coordinatesMode = io.CUBIC_MODE,
p.name = t,
p.url = t,
p.hasAlpha = !1,
p.isCube = !0,
p._textureMatrix = P.Identity(),
p._prefilterOnLoad = l,
p._onLoad = function() {
p.onLoadObservable.notifyObservers(p),
c && c()
}
,
p._onError = u,
p.gammaSpace = s,
p._noMipmap = r,
p._size = n,
p._generateHarmonics = o,
p._texture = p._getFromCache(t, p._noMipmap),
p._texture ? p._texture.isReady ? gi.SetImmediate((function() {
return p._onLoad()
}
)) : p._texture.onLoadedObservable.add(p._onLoad) : (null === (d = p.getScene()) || void 0 === d ? void 0 : d.useDelayedTextureLoading) ? p.delayLoadState = a.DELAYLOADSTATE_NOTLOADED : p._loadTexture(),
p) : p
}
return U(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(P.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()
, n = i.getCaps()
, r = a.TEXTURETYPE_UNSIGNED_BYTE;
if (n.textureFloat && n.textureFloatLinearFiltering ? r = a.TEXTURETYPE_FLOAT : n.textureHalfFloat && n.textureHalfFloatLinearFiltering && (r = a.TEXTURETYPE_HALF_FLOAT),
i._features.allowTexturePrefiltering && this._prefilterOnLoad) {
var o = this._onLoad
, s = new T_(i);
this._onLoad = function() {
s.prefilter(e, o)
}
}
this._texture = i.createRawCubeTextureFromUrl(this.url, this.getScene(), this._size, a.TEXTUREFORMAT_RGB, r, this._noMipmap, (function(i) {
e.lodGenerationOffset = 0,
e.lodGenerationScale = .8;
var n = v_.GetCubeMapTextureData(i, e._size);
if (e._generateHarmonics) {
var o = wc.ConvertCubeMapToSphericalPolynomial(n);
e.sphericalPolynomial = o
}
for (var s = [], l = null, c = null, u = 0; u < 6; u++) {
r === a.TEXTURETYPE_HALF_FLOAT ? c = new Uint16Array(e._size * e._size * 3) : r === a.TEXTURETYPE_UNSIGNED_BYTE && (l = new Uint8Array(e._size * e._size * 3));
var h = n[t._FacesMapping[u]];
if (e.gammaSpace || c || l)
for (var d = 0; d < e._size * e._size; d++)
if (e.gammaSpace && (h[3 * d + 0] = Math.pow(h[3 * d + 0], p),
h[3 * d + 1] = Math.pow(h[3 * d + 1], p),
h[3 * d + 2] = Math.pow(h[3 * d + 2], p)),
c && (c[3 * d + 0] = Oc(h[3 * d + 0]),
c[3 * d + 1] = Oc(h[3 * d + 1]),
c[3 * d + 2] = Oc(h[3 * d + 2])),
l) {
var f = Math.max(255 * h[3 * d + 0], 0)
, _ = Math.max(255 * h[3 * d + 1], 0)
, m = Math.max(255 * h[3 * d + 2], 0)
, g = Math.max(Math.max(f, _), m);
if (g > 255) {
var v = 255 / g;
f *= v,
_ *= v,
m *= v
}
l[3 * d + 0] = f,
l[3 * d + 1] = _,
l[3 * d + 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, n) {
var r = null;
return e.name && !e.isRenderTarget && ((r = new t(n + e.name,i,e.size,e.noMipmap,e.generateHarmonics,e.useInGammaSpace)).name = e.name,
r.hasAlpha = e.hasAlpha,
r.level = e.level,
r.coordinatesMode = e.coordinatesMode,
r.isBlocking = e.isBlocking),
r && (e.boundingBoxPosition && (r.boundingBoxPosition = x.FromArray(e.boundingBoxPosition)),
e.boundingBoxSize && (r.boundingBoxSize = x.FromArray(e.boundingBoxSize)),
e.rotationY && (r.rotationY = e.rotationY)),
r
}
,
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
}(Zr);
y("BABYLON.HDRCubeTexture", E_);
var S_ = 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 h,
this._onDataLayoutChanged = new h,
this._animationPropertiesOverride = null,
this._scene = i || E.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 = Ge.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())),
Ge.AppendSerializedAnimations(this, e),
e
}
,
e.prototype.getClassName = function() {
return "MorphTarget"
}
,
e.Parse = function(t, i) {
var n = new e(t.name,t.influence);
if (n.setPositions(t.positions),
null != t.id && (n.id = t.id),
t.normals && n.setNormals(t.normals),
t.tangents && n.setTangents(t.tangents),
t.uvs && n.setUVs(t.uvs),
t.animations) {
for (var r = 0; r < t.animations.length; r++) {
var o = t.animations[r]
, a = b("BABYLON.Animation");
a && n.animations.push(a.Parse(o))
}
t.autoAnimate && i && i.beginAnimation(n, t.autoAnimateFrom, t.autoAnimateTo, t.autoAnimateLoop, t.autoAnimateSpeed || 1)
}
return n
}
,
e.FromMesh = function(t, i, n) {
i || (i = t.name);
var r = new e(i,n,t.getScene());
return r.setPositions(t.getVerticesData(Bi.PositionKind)),
t.isVerticesDataPresent(Bi.NormalKind) && r.setNormals(t.getVerticesData(Bi.NormalKind)),
t.isVerticesDataPresent(Bi.TangentKind) && r.setTangents(t.getVerticesData(Bi.TangentKind)),
t.isVerticesDataPresent(Bi.UVKind) && r.setUVs(t.getVerticesData(Bi.UVKind)),
r
}
,
k([Ce()], e.prototype, "id", void 0),
e
}()
, A_ = function(e) {
function t(t, i, n, r, o, s, l, c, u, h) {
void 0 === l && (l = !0),
void 0 === c && (c = !1),
void 0 === u && (u = io.TRILINEAR_SAMPLINGMODE),
void 0 === h && (h = a.TEXTURETYPE_UNSIGNED_INT);
var d = e.call(this, null, s, !l, c) || this;
return d.format = o,
d._texture = s.getEngine().createRawTexture2DArray(t, i, n, r, o, l, c, u, null, h),
d._depth = r,
d.is2DArray = !0,
d
}
return U(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, n, r, 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,n,r,a.TEXTUREFORMAT_RGBA,o,s,l,c,u)
}
,
t
}(io)
, x_ = 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 bi(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 = E.LastCreatedScene),
this._scene = e,
this._scene) {
this._scene.morphTargetManagers.push(this),
this._uniqueId = this._scene.getUniqueId();
var t = this._scene.getEngine().getCaps();
this._canUseTextureForTargets = t.canUseGLVertexID && t.textureFloat && t.maxVertexTextureImageUnits > 0
}
}
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() {
return e.EnableTextureStorage && this.useTextureToStoreTargets && this._canUseTextureForTargets
},
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))
}
,
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, n = this._targets; i < n.length; i++) {
var r = n[i];
t.addTarget(r.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 n = i[t];
e.targets.push(n.serialize())
}
return e
}
,
e.prototype._syncActiveTargets = function(e) {
if (!this.areUpdatesFrozen) {
var t = 0;
this._activeTargets.reset(),
this._supportsNormals = !0,
this._supportsTangents = !0,
this._supportsUVs = !0,
this._vertexCount = 0,
this._morphTargetTextureIndices && this._morphTargetTextureIndices.length === this._targets.length || (this._morphTargetTextureIndices = new Float32Array(this._targets.length));
for (var i = -1, n = 0, r = this._targets; n < r.length; n++) {
var o = r[n];
if (i++,
0 !== o.influence || !this.optimizeInfluencers) {
this._activeTargets.push(o),
this._morphTargetTextureIndices[t] = i,
this._tempInfluences[t++] = o.influence,
this._supportsNormals = this._supportsNormals && o.hasNormals,
this._supportsTangents = this._supportsTangents && o.hasTangents,
this._supportsUVs = this._supportsUVs && o.hasUVs;
var a = o.getPositions();
if (a) {
var s = a.length / 3;
if (0 === this._vertexCount)
this._vertexCount = s;
else if (this._vertexCount !== s)
return void K.Error("Incompatible target. Targets must all have the same vertices count.")
}
}
}
this._influences && this._influences.length === t || (this._influences = new Float32Array(t));
for (var l = 0; l < t; l++)
this._influences[l] = this._tempInfluences[l];
e && 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 n = this._targets.length, r = new Float32Array(n * this._textureWidth * this._textureHeight * 4), o = 0, s = 0; s < n; s++) {
var l = this._targets[s]
, c = l.getPositions()
, u = l.getNormals()
, h = l.getUVs()
, d = l.getTangents();
if (!c)
return void (0 === s && K.Error("Invalid morph target. Target must have positions."));
o = s * this._textureWidth * this._textureHeight * 4;
for (var p = 0; p < this._vertexCount; p++)
r[o] = c[3 * p],
r[o + 1] = c[3 * p + 1],
r[o + 2] = c[3 * p + 2],
o += 4,
u && (r[o] = u[3 * p],
r[o + 1] = u[3 * p + 1],
r[o + 2] = u[3 * p + 2],
o += 4),
h && (r[o] = h[2 * p],
r[o + 1] = h[2 * p + 1],
o += 4),
d && (r[o] = d[3 * p],
r[o + 1] = d[3 * p + 1],
r[o + 2] = d[3 * p + 2],
o += 4)
}
this._targetStoreTexture = A_.CreateRGBATexture(r, this._textureWidth, this._textureHeight, n, 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 && (this._scene.removeMorphTargetManager(this),
this._parentContainer)) {
var e = this._parentContainer.morphTargetManagers.indexOf(this);
e > -1 && this._parentContainer.morphTargetManagers.splice(e, 1),
this._parentContainer = null
}
}
,
e.Parse = function(t, i) {
var n = new e(i);
n._uniqueId = t.id;
for (var r = 0, o = t.targets; r < o.length; r++) {
var a = o[r];
n.addTarget(S_.Parse(a, i))
}
return n
}
,
e.EnableTextureStorage = !0,
e
}()
, R_ = 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 x(0,-9.807,0),
this.setGravity(t),
this.setTimeStep()
}
return e.DefaultPluginFactory = function() {
throw be("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 n = {
mainImpostor: e,
connectedImpostor: t,
joint: i
};
i.physicsPlugin = this._physicsPlugin,
this._joints.push(n),
this._physicsPlugin.generateJoint(n)
}
,
e.prototype.removeJoint = function(e, t, i) {
var n = this._joints.filter((function(n) {
return n.connectedImpostor === t && n.joint === i && n.mainImpostor === e
}
));
n.length && this._physicsPlugin.removeJoint(n[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.Epsilon = .001,
e
}()
, C_ = function() {
function e() {
this._hasHit = !1,
this._hitDistance = 0,
this._hitNormalWorld = x.Zero(),
this._hitPointWorld = x.Zero(),
this._rayFromWorld = x.Zero(),
this._rayToWorld = x.Zero()
}
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
}),
e.prototype.setHitData = function(e, t) {
this._hasHit = !0,
this._hitNormalWorld = new x(e.x,e.y,e.z),
this._hitPointWorld = new x(t.x,t.y,t.z)
}
,
e.prototype.setHitDistance = function(e) {
this._hitDistance = e
}
,
e.prototype.calculateHitDistance = function() {
this._hitDistance = x.Distance(this._rayFromWorld, this._hitPointWorld)
}
,
e.prototype.reset = function(e, t) {
void 0 === e && (e = x.Zero()),
void 0 === t && (t = x.Zero()),
this._rayFromWorld = e,
this._rayToWorld = t,
this._hasHit = !1,
this._hitDistance = 0,
this._hitNormalWorld = x.Zero(),
this._hitPointWorld = x.Zero()
}
,
e
}()
, P_ = 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._physicsBodysToRemoveAfterStep = new Array,
this._firstFrame = !0,
this._tmpQuaternion = new C,
this._minus90X = new C(-.7071067811865475,0,0,.7071067811865475),
this._plus90X = new C(.7071067811865475,0,0,.7071067811865475),
this._tmpPosition = x.Zero(),
this._tmpDeltaPosition = x.Zero(),
this._tmpUnityRotation = new C,
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 C_) : K.Error("CannonJS is not available. Please make sure you included the js file.")
}
return 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, n = t; i < n.length; i++) {
var r = n[i];
r.type != Vl.HeightmapImpostor && r.type !== Vl.PlaneImpostor && r.beforeStep()
}
}
this.world.step(this._useDeltaForWorldStep ? e : this._fixedTimeStep),
this._removeMarkedPhysicsBodiesFromWorld()
}
,
e.prototype._removeMarkedPhysicsBodiesFromWorld = function() {
var e = this;
this._physicsBodysToRemoveAfterStep.length > 0 && (this._physicsBodysToRemoveAfterStep.forEach((function(t) {
"function" == typeof e.world.removeBody ? e.world.removeBody(t) : e.world.remove(t)
}
)),
this._physicsBodysToRemoveAfterStep = [])
}
,
e.prototype.applyImpulse = function(e, t, i) {
var n = new this.BJSCANNON.Vec3(i.x,i.y,i.z)
, r = new this.BJSCANNON.Vec3(t.x,t.y,t.z);
e.physicsBody.applyImpulse(r, n)
}
,
e.prototype.applyForce = function(e, t, i) {
var n = new this.BJSCANNON.Vec3(i.x,i.y,i.z)
, r = new this.BJSCANNON.Vec3(t.x,t.y,t.z);
e.physicsBody.applyForce(r, n)
}
,
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 K.Warn("It was not possible to create a physics body for this object.");
var i = e.physicsBody;
i && this.removePhysicsBody(e);
var n = this._addMaterial("mat-" + e.uniqueId, e.getParam("friction"), e.getParam("restitution"))
, r = {
mass: e.getParam("mass"),
material: n
}
, o = e.getParam("nativeOptions");
for (var a in o)
Object.prototype.hasOwnProperty.call(o, a) && (r[a] = o[a]);
e.physicsBody = new this.BJSCANNON.Body(r),
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 n = i[t];
e.physicsBody[t].set(n.x, n.y, n.z)
}
)),
this._processChildMeshes(e)
}
this._updatePhysicsBodyTransformation(e)
}
}
,
e.prototype._processChildMeshes = function(e) {
var t = this
, i = e.object.getChildMeshes ? e.object.getChildMeshes(!0) : []
, n = e.object.rotationQuaternion;
if (n ? n.conjugateToRef(this._tmpQuaternion) : this._tmpQuaternion.set(0, 0, 0, 1),
i.length) {
var r = function(i) {
if (i.rotationQuaternion) {
var n = i.getPhysicsImpostor();
if (n && n.parent !== e && i.parent) {
var o = i.getAbsolutePosition().subtract(i.parent.getAbsolutePosition())
, a = i.rotationQuaternion.multiply(t._tmpQuaternion);
n.physicsBody && (t.removePhysicsBody(n),
n.physicsBody = null),
n.parent = e,
n.resetUpdateFlags(),
e.physicsBody.addShape(t._createShape(n), 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 += n.getParam("mass")
}
i.getChildMeshes(!0).filter((function(e) {
return !!e.physicsImpostor
}
)).forEach(r)
}
};
i.filter((function(e) {
return !!e.physicsImpostor
}
)).forEach(r)
}
}
,
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._physicsBodysToRemoveAfterStep.indexOf(e.physicsBody) && this._physicsBodysToRemoveAfterStep.push(e.physicsBody)
}
,
e.prototype.generateJoint = function(e) {
var t = e.mainImpostor.physicsBody
, i = e.connectedImpostor.physicsBody;
if (t && i) {
var n, r = e.joint.jointData, o = {
pivotA: r.mainPivot ? (new this.BJSCANNON.Vec3).set(r.mainPivot.x, r.mainPivot.y, r.mainPivot.z) : null,
pivotB: r.connectedPivot ? (new this.BJSCANNON.Vec3).set(r.connectedPivot.x, r.connectedPivot.y, r.connectedPivot.z) : null,
axisA: r.mainAxis ? (new this.BJSCANNON.Vec3).set(r.mainAxis.x, r.mainAxis.y, r.mainAxis.z) : null,
axisB: r.connectedAxis ? (new this.BJSCANNON.Vec3).set(r.connectedAxis.x, r.connectedAxis.y, r.connectedAxis.z) : null,
maxForce: r.nativeParams.maxForce,
collideConnected: !!r.collision
};
switch (e.joint.type) {
case Ll.HingeJoint:
case Ll.Hinge2Joint:
n = new this.BJSCANNON.HingeConstraint(t,i,o);
break;
case Ll.DistanceJoint:
n = new this.BJSCANNON.DistanceConstraint(t,i,r.maxDistance || 2);
break;
case Ll.SpringJoint:
var a = r;
n = new this.BJSCANNON.Spring(t,i,{
restLength: a.length,
stiffness: a.stiffness,
damping: a.damping,
localAnchorA: o.pivotA,
localAnchorB: o.pivotB
});
break;
case Ll.LockJoint:
n = new this.BJSCANNON.LockConstraint(t,i,o);
break;
case Ll.PointToPointJoint:
case Ll.BallAndSocketJoint:
default:
n = new this.BJSCANNON.PointToPointConstraint(t,o.pivotA,i,o.pivotB,o.maxForce)
}
n.collideConnected = !!r.collision,
e.joint.physicsJoint = n,
e.joint.type !== Ll.SpringJoint ? this.world.addConstraint(n) : (e.joint.jointData.forceApplicationCallback = e.joint.jointData.forceApplicationCallback || function() {
n.applyForce()
}
,
e.mainImpostor.registerAfterPhysicsStep(e.joint.jointData.forceApplicationCallback))
}
}
,
e.prototype.removeJoint = function(e) {
e.joint.type !== Ll.SpringJoint ? this.world.removeConstraint(e.joint.physicsJoint) : e.mainImpostor.unregisterAfterPhysicsStep(e.joint.jointData.forceApplicationCallback)
}
,
e.prototype._addMaterial = function(e, t, i) {
var n, r;
for (n = 0; n < this._physicsMaterials.length; n++)
if ((r = this._physicsMaterials[n]).friction === t && r.restitution === i)
return r;
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 < R_.Epsilon ? R_.Epsilon : e
}
,
e.prototype._createShape = function(e) {
var t, i = e.object, n = e.getObjectExtendSize();
switch (e.type) {
case Vl.SphereImpostor:
var r = n.x
, o = n.y
, a = n.z;
t = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(r), this._checkWithEpsilon(o), this._checkWithEpsilon(a)) / 2);
break;
case Vl.CylinderImpostor:
var s = e.getParam("nativeOptions");
s || (s = {});
var l = void 0 !== s.radiusTop ? s.radiusTop : this._checkWithEpsilon(n.x) / 2
, c = void 0 !== s.radiusBottom ? s.radiusBottom : this._checkWithEpsilon(n.x) / 2
, u = void 0 !== s.height ? s.height : this._checkWithEpsilon(n.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 Vl.BoxImpostor:
var f = n.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 Vl.PlaneImpostor:
K.Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead"),
t = new this.BJSCANNON.Plane;
break;
case Vl.MeshImpostor:
var _ = i.getVerticesData ? i.getVerticesData(Bi.PositionKind) : []
, m = i.getIndices ? i.getIndices() : [];
if (!_)
return void K.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)
x.TransformCoordinates(x.FromArray(_, E), b).toArray(T, E);
K.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 Vl.HeightmapImpostor:
var S = i.position.clone()
, A = i.rotation && i.rotation.clone()
, R = 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),
A && i.rotation && i.rotation.copyFrom(A),
R && i.rotationQuaternion && i.rotationQuaternion.copyFrom(R),
i.computeWorldMatrix(!0);
break;
case Vl.ParticleImpostor:
t = new this.BJSCANNON.Particle;
break;
case Vl.NoImpostor:
t = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0,0,0))
}
return t
}
,
e.prototype._createHeightmap = function(e, t) {
var i, n = e.getVerticesData(Bi.PositionKind), r = e.computeWorldMatrix(!0), o = new Array;
for (i = 0; i < n.length; i += 3)
x.TransformCoordinates(x.FromArray(n, i), r).toArray(o, i);
n = o;
for (var a = new Array, s = t || ~~(Math.sqrt(n.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 < n.length; d += 3) {
var p = Math.round(n[d + 0] / h + s / 2)
, f = Math.round(-1 * (n[d + 1] / h - s / 2))
, _ = -n[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 n = t.rotationQuaternion;
if (n) {
if (e.type !== Vl.PlaneImpostor && e.type !== Vl.HeightmapImpostor || (n = n.multiply(this._minus90X),
e.setDeltaRotation(this._plus90X)),
e.type === Vl.HeightmapImpostor) {
var r = t
, o = r.getBoundingInfo()
, a = r.rotationQuaternion;
r.rotationQuaternion = this._tmpUnityRotation,
r.computeWorldMatrix(!0);
var s = i.clone()
, l = r.getPivotMatrix();
l = l ? l.clone() : P.Identity();
var c = P.Translation(o.boundingBox.extendSizeWorld.x, 0, -o.boundingBox.extendSizeWorld.z);
r.setPreTransformMatrix(c),
r.computeWorldMatrix(!0);
var u = (o = r.getBoundingInfo()).boundingBox.centerWorld.subtract(i).subtract(r.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,
r.rotationQuaternion = a,
r.setPreTransformMatrix(l),
r.computeWorldMatrix(!0)
} else
e.type === Vl.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(n.x, n.y, n.z, n.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 x(t.x,t.y,t.z) : null
}
,
e.prototype.getAngularVelocity = function(e) {
var t = e.physicsBody.angularVelocity;
return t ? new x(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, n) {
n || (e.physicsJoint.enableMotor(),
e.physicsJoint.setMotorSpeed(t),
i && this.setLimit(e, i))
}
,
e.prototype.setLimit = function(e, t, i) {
e.physicsJoint.motorEquation.maxForce = t,
e.physicsJoint.motorEquation.minForce = 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.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, n, r) {
if (r = r || 10,
0 === (n = n || 0))
this.internalStep(i),
this.time += i;
else {
var o = Math.floor((this.time + n) / i) - Math.floor(this.time / i);
o = Math.min(o, r) || 1;
for (var a = performance.now(), s = 0; s !== o && (this.internalStep(i),
!(performance.now() - a > 1e3 * i)); s++)
;
this.time += n;
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._cannonRaycastResult.reset(),
this.world.raycastClosest(e, t, {}, this._cannonRaycastResult),
this._raycastResult.reset(e, t),
this._cannonRaycastResult.hasHit && (this._raycastResult.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
}),
this._raycastResult.setHitDistance(this._cannonRaycastResult.distance)),
this._raycastResult
}
,
e
}();
R_.DefaultPluginFactory = function() {
return new P_
}
;
var M_ = 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 = x.Zero(),
this.BJSOIMO = i,
this.world = new this.BJSOIMO.World({
iterations: t
}),
this.world.clear(),
this._raycastResult = new C_
}
return 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 n = this.world.contacts; null !== n; )
if (!n.touching || n.body1.sleeping || n.body2.sleeping) {
var r = this._tmpImpostorsArray[+n.body1.name]
, o = this._tmpImpostorsArray[+n.body2.name];
r && o ? (r.onCollide({
body: o.physicsBody,
point: null
}),
o.onCollide({
body: r.physicsBody,
point: null
}),
n = n.next) : n = n.next
} else
n = n.next
}
,
e.prototype.applyImpulse = function(e, t, i) {
var n = e.physicsBody.mass;
e.physicsBody.applyImpulse(i.scale(this.world.invScale), t.scale(this.world.invScale * n))
}
,
e.prototype.applyForce = function(e, t, i) {
K.Warn("Oimo doesn't support applying force. Using impule 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
}
, n = [e];
(a = e.object).getChildMeshes && a.getChildMeshes().forEach((function(e) {
e.physicsImpostor && n.push(e.physicsImpostor)
}
));
var r = function(e) {
return Math.max(e, R_.Epsilon)
}
, o = new C;
n.forEach((function(n) {
if (n.object.rotationQuaternion) {
var a = n.object.rotationQuaternion;
o.copyFrom(a),
n.object.rotationQuaternion.set(0, 0, 0, 1),
n.object.computeWorldMatrix(!0);
var s = o.toEulerAngles()
, l = n.getObjectExtendSize()
, c = 57.29577951308232;
if (n === 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 = n.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 (n.object.rotationQuaternion.copyFrom(o),
n.type) {
case Vl.ParticleImpostor:
K.Warn("No Particle support in OIMO.js. using SphereImpostor instead");
case Vl.SphereImpostor:
var d = l.x
, p = l.y
, f = l.z
, _ = Math.max(r(d), r(p), r(f)) / 2;
i.type.push("sphere"),
i.size.push(_),
i.size.push(_),
i.size.push(_);
break;
case Vl.CylinderImpostor:
var m = r(l.x) / 2
, g = r(l.y);
i.type.push("cylinder"),
i.size.push(m),
i.size.push(g),
i.size.push(g);
break;
case Vl.PlaneImpostor:
case Vl.BoxImpostor:
default:
m = r(l.x),
g = r(l.y);
var v = r(l.z);
i.type.push("box"),
i.size.push(m),
i.size.push(g),
i.size.push(v)
}
n.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 n, r = e.joint.jointData, o = r.nativeParams || {}, a = {
body1: t,
body2: i,
axe1: o.axe1 || (r.mainAxis ? r.mainAxis.asArray() : null),
axe2: o.axe2 || (r.connectedAxis ? r.connectedAxis.asArray() : null),
pos1: o.pos1 || (r.mainPivot ? r.mainPivot.asArray() : null),
pos2: o.pos2 || (r.connectedPivot ? r.connectedPivot.asArray() : null),
min: o.min,
max: o.max,
collision: o.collision || r.collision,
spring: o.spring,
world: this.world
};
switch (e.joint.type) {
case Ll.BallAndSocketJoint:
n = "jointBall";
break;
case Ll.SpringJoint:
K.Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
var s = r;
a.min = s.length || a.min,
a.max = Math.max(a.min, a.max);
case Ll.DistanceJoint:
n = "jointDistance",
a.max = r.maxDistance;
break;
case Ll.PrismaticJoint:
n = "jointPrisme";
break;
case Ll.SliderJoint:
n = "jointSlide";
break;
case Ll.WheelJoint:
n = "jointWheel";
break;
case Ll.HingeJoint:
default:
n = "jointHinge"
}
a.type = n,
e.joint.physicsJoint = this.world.add(a)
}
}
,
e.prototype.removeJoint = function(e) {
try {
this.world.removeJoint(e.joint.physicsJoint)
} catch (e) {
K.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 n = e.physicsBody.getQuaternion();
e.object.rotationQuaternion.set(n.x, n.y, n.z, n.w)
}
}
}
,
e.prototype.setPhysicsBodyTransformation = function(e, t, i) {
var n = e.physicsBody;
e.physicsBody.shapes.next || (n.position.set(t.x, t.y, t.z),
n.orientation.set(i.x, i.y, i.z, i.w),
n.syncShapes(),
n.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 x(t.x,t.y,t.z) : null
}
,
e.prototype.getAngularVelocity = function(e) {
var t = e.physicsBody.angularVelocity;
return t ? new x(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, n) {
void 0 !== i ? K.Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter") : i = 1e6,
t *= -1;
var r = n ? e.physicsJoint.rotationalLimitMotor2 : e.physicsJoint.rotationalLimitMotor1 || e.physicsJoint.rotationalLimitMotor || e.physicsJoint.limitMotor;
r && r.setMotor(t, i)
}
,
e.prototype.setLimit = function(e, t, i, n) {
var r = n ? e.physicsJoint.rotationalLimitMotor2 : e.physicsJoint.rotationalLimitMotor1 || e.physicsJoint.rotationalLimitMotor || e.physicsJoint.limitMotor;
r && r.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.s)
}
,
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 K.Warn("raycast is not currently supported by the Oimo physics plugin"),
this._raycastResult.reset(e, t),
this._raycastResult
}
,
e
}()
, I_ = function() {
function e(e, t, i) {
void 0 === e && (e = !0),
void 0 === t && (t = Ammo),
void 0 === i && (i = null);
var n = this;
this._useDeltaForWorldStep = e,
this.bjsAMMO = {},
this.name = "AmmoJSPlugin",
this._timeStep = 1 / 60,
this._fixedTimeStep = 1 / 60,
this._maxSteps = 5,
this._tmpQuaternion = new C,
this._tmpContactCallbackResult = !1,
this._tmpContactPoint = new x,
this._tmpVec3 = new x,
this._tmpMatrix = new P,
"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 = n.bjsAMMO.wrapPointer(e, n.bjsAMMO.btManifoldPoint)).getPositionWorldOnA();
n._tmpContactPoint.x = t.x(),
n._tmpContactPoint.y = t.y(),
n._tmpContactPoint.z = t.z(),
n._tmpContactCallbackResult = !0
}
,
this._raycastResult = new C_,
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)) : K.Error("AmmoJS is not available. Please make sure you included the js file.")) : K.Error("AmmoJS is not ready. Please make sure you await Ammo() before using the plugin.")
}
return 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, n = t; i < n.length; i++) {
var r = n[i];
r.soft || r.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
}),
d.onCollide({
body: s.physicsBody,
point: this._tmpContactPoint
}))
}
}
}
,
e.prototype._afterSoftStep = function(e) {
e.type === Vl.RopeImpostor ? this._ropeStep(e) : this._softbodyOrClothStep(e)
}
,
e.prototype._ropeStep = function(e) {
for (var t, i, n, r, 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(),
n = t.y(),
r = t.z(),
s.push(new x(i,n,r));
var c = e.object
, u = e.getParam("shape");
e._isFromLine ? e.object = Jl("lines", {
points: s,
instance: c
}) : e.object = oc("ext", {
shape: u,
path: s,
instance: c
})
}
,
e.prototype._softbodyOrClothStep = function(e) {
var t = e.type === Vl.ClothImpostor ? 1 : -1
, i = e.object
, n = i.getVerticesData(Bi.PositionKind);
n || (n = []);
var r = i.getVerticesData(Bi.NormalKind);
r || (r = []);
for (var o, a, s, l, c, u, h, d, p = n.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,
n[3 * _] = s,
n[3 * _ + 1] = l,
n[3 * _ + 2] = c,
r[3 * _] = u,
r[3 * _ + 1] = h,
r[3 * _ + 2] = d
}
var g = new $n;
g.positions = n,
g.normals = r,
g.uvs = i.getVerticesData(Bi.UVKind),
g.colors = i.getVerticesData(Bi.ColorKind),
i && i.getIndices && (g.indices = i.getIndices()),
g.applyToMesh(i)
}
,
e.prototype.applyImpulse = function(e, t, i) {
if (e.soft)
K.Warn("Cannot be applied to a soft body");
else {
e.physicsBody.activate();
var n = this._tmpAmmoVectorA
, r = this._tmpAmmoVectorB;
e.object && e.object.getWorldMatrix && i.subtractInPlace(e.object.getWorldMatrix().getTranslation()),
n.setValue(i.x, i.y, i.z),
r.setValue(t.x, t.y, t.z),
e.physicsBody.applyImpulse(r, n)
}
}
,
e.prototype.applyForce = function(e, t, i) {
if (e.soft)
K.Warn("Cannot be applied to a soft body");
else {
e.physicsBody.activate();
var n = this._tmpAmmoVectorA
, r = this._tmpAmmoVectorB;
if (e.object && e.object.getWorldMatrix) {
var o = e.object.getWorldMatrix().getTranslation();
n.setValue(i.x - o.x, i.y - o.y, i.z - o.z)
} else
n.setValue(i.x, i.y, i.z);
r.setValue(t.x, t.y, t.z),
e.physicsBody.applyForce(r, n)
}
}
,
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)
, n = t.getParam("mass");
if (t._pluginData.mass = n,
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 === Vl.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 r = new this.bjsAMMO.btVector3(0,0,0)
, o = new this.bjsAMMO.btTransform;
t.object.computeWorldMatrix(!0),
o.setIdentity(),
0 !== n && i.calculateLocalInertia(n, r),
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(n,a,i,r)
, l = new this.bjsAMMO.btRigidBody(s);
if (0 === n && (l.setCollisionFlags(l.getCollisionFlags() | e._KINEMATIC_FLAG),
l.setActivationState(e._DISABLE_DEACTIVATION_FLAG)),
t.type != Vl.NoImpostor || i.getChildShape || l.setCollisionFlags(l.getCollisionFlags() | e._DISABLE_COLLISION_FLAG),
t.type !== Vl.MeshImpostor && t.type !== Vl.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, r, 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 n, r = e.joint.jointData;
switch (r.mainPivot || (r.mainPivot = new x(0,0,0)),
r.connectedPivot || (r.connectedPivot = new x(0,0,0)),
e.joint.type) {
case Ll.DistanceJoint:
var o = r.maxDistance;
o && (r.mainPivot = new x(0,-o / 2,0),
r.connectedPivot = new x(0,o / 2,0)),
n = new this.bjsAMMO.btPoint2PointConstraint(t,i,new this.bjsAMMO.btVector3(r.mainPivot.x,r.mainPivot.y,r.mainPivot.z),new this.bjsAMMO.btVector3(r.connectedPivot.x,r.connectedPivot.y,r.connectedPivot.z));
break;
case Ll.HingeJoint:
r.mainAxis || (r.mainAxis = new x(0,0,0)),
r.connectedAxis || (r.connectedAxis = new x(0,0,0));
var a = new this.bjsAMMO.btVector3(r.mainAxis.x,r.mainAxis.y,r.mainAxis.z)
, s = new this.bjsAMMO.btVector3(r.connectedAxis.x,r.connectedAxis.y,r.connectedAxis.z);
n = new this.bjsAMMO.btHingeConstraint(t,i,new this.bjsAMMO.btVector3(r.mainPivot.x,r.mainPivot.y,r.mainPivot.z),new this.bjsAMMO.btVector3(r.connectedPivot.x,r.connectedPivot.y,r.connectedPivot.z),a,s);
break;
case Ll.BallAndSocketJoint:
n = new this.bjsAMMO.btPoint2PointConstraint(t,i,new this.bjsAMMO.btVector3(r.mainPivot.x,r.mainPivot.y,r.mainPivot.z),new this.bjsAMMO.btVector3(r.connectedPivot.x,r.connectedPivot.y,r.connectedPivot.z));
break;
default:
K.Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint"),
n = new this.bjsAMMO.btPoint2PointConstraint(t,i,new this.bjsAMMO.btVector3(r.mainPivot.x,r.mainPivot.y,r.mainPivot.z),new this.bjsAMMO.btVector3(r.connectedPivot.x,r.connectedPivot.y,r.connectedPivot.z))
}
this.world.addConstraint(n, !e.joint.jointData.collision),
e.joint.physicsJoint = n
}
}
,
e.prototype.removeJoint = function(e) {
this.world && this.world.removeConstraint(e.joint.physicsJoint)
}
,
e.prototype._addMeshVerts = function(e, t, i) {
var n = this
, r = 0;
if (i && i.getIndices && i.getWorldMatrix && i.getChildMeshes) {
var o = i.getIndices();
o || (o = []);
var a = i.getVerticesData(Bi.PositionKind);
a || (a = []);
var s = void 0;
if (t && t !== i) {
var l;
l = t.rotationQuaternion ? t.rotationQuaternion : t.rotation ? C.FromEulerAngles(t.rotation.x, t.rotation.y, t.rotation.z) : C.Identity(),
P.Compose(x.One(), l, t.position).invertToRef(this._tmpMatrix),
s = i.computeWorldMatrix(!1).multiply(this._tmpMatrix)
} else
P.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 x(a[3 * o[3 * u + d] + 0],a[3 * o[3 * u + d] + 1],a[3 * o[3 * u + d] + 2]);
p = x.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]),
r++
}
i.getChildMeshes().forEach((function(i) {
r += n._addMeshVerts(e, t, i)
}
))
}
return r
}
,
e.prototype._softVertexData = function(e) {
var t = e.object;
if (t && t.getIndices && t.getWorldMatrix && t.getChildMeshes) {
var i = t.getIndices();
i || (i = []);
var n = t.getVerticesData(Bi.PositionKind);
n || (n = []);
var r = t.getVerticesData(Bi.NormalKind);
r || (r = []),
t.computeWorldMatrix(!1);
for (var o = [], a = [], s = 0; s < n.length; s += 3) {
var l = new x(n[s],n[s + 1],n[s + 2])
, c = new x(r[s],r[s + 1],r[s + 2]);
l = x.TransformCoordinates(l, t.getWorldMatrix()),
c = x.TransformNormal(c, t.getWorldMatrix()),
o.push(l.x, l.y, l.z),
a.push(c.x, c.y, c.z)
}
var u = new $n;
return u.positions = o,
u.normals = a,
u.uvs = t.getVerticesData(Bi.UVKind),
u.colors = t.getVerticesData(Bi.ColorKind),
t && t.getIndices && (u.indices = t.getIndices()),
u.applyToMesh(t),
t.position = x.Zero(),
t.rotationQuaternion = null,
t.rotation = x.Zero(),
t.computeWorldMatrix(!0),
u
}
return $n.ExtractFromMesh(t)
}
,
e.prototype._createSoftbody = function(e) {
var t = e.object;
if (t && t.getIndices) {
var i = t.getIndices();
i || (i = []);
var n = this._softVertexData(e)
, r = n.positions
, o = n.normals;
if (null === r || null === o)
return new this.bjsAMMO.btCompoundShape;
for (var a = [], s = [], l = 0; l < r.length; l += 3) {
var c = new x(r[l],r[l + 1],r[l + 2])
, u = new x(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 = r.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 n = this._softVertexData(e)
, r = n.positions
, o = n.normals;
if (null === r || null === o)
return new this.bjsAMMO.btCompoundShape;
var a = r.length
, s = Math.sqrt(a / 3);
e.segments = s;
var l = s - 1;
return this._tmpAmmoVectorA.setValue(r[0], r[1], r[2]),
this._tmpAmmoVectorB.setValue(r[3 * l], r[3 * l + 1], r[3 * l + 2]),
this._tmpAmmoVectorD.setValue(r[a - 3], r[a - 2], r[a - 1]),
this._tmpAmmoVectorC.setValue(r[a - 3 - 3 * l], r[a - 2 - 3 * l], r[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, n = this._softVertexData(e), r = n.positions, o = n.normals;
if (null === r || null === o)
return new this.bjsAMMO.btCompoundShape;
if (n.applyToMesh(e.object, !0),
e._isFromLine = !0,
0 === o.map((function(e) {
return e * e
}
)).reduce((function(e, t) {
return e + t
}
)))
i = (t = r.length) / 3 - 1,
this._tmpAmmoVectorA.setValue(r[0], r[1], r[2]),
this._tmpAmmoVectorB.setValue(r[t - 3], r[t - 2], r[t - 1]);
else {
e._isFromLine = !1;
var a = e.getParam("path");
if (null === e.getParam("shape"))
return K.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 n = this
, r = 0;
if (i && i.getIndices && i.getWorldMatrix && i.getChildMeshes) {
var o = i.getIndices();
o || (o = []);
var a = i.getVerticesData(Bi.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 x(a[3 * o[3 * l + u] + 0],a[3 * o[3 * l + u] + 1],a[3 * o[3 * l + u] + 2]);
P.ScalingToRef(i.scaling.x, i.scaling.y, i.scaling.z, this._tmpMatrix),
h = x.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),
r++
}
i.getChildMeshes().forEach((function(i) {
r += n._addHullVerts(e, t, i)
}
))
}
return r
}
,
e.prototype._createShape = function(e, t) {
var i = this;
void 0 === t && (t = !1);
var n, r = e.object, o = e.getObjectExtendSize();
if (!t) {
var a = e.object.getChildMeshes ? e.object.getChildMeshes(!0) : [];
n = new this.bjsAMMO.btCompoundShape;
var s = 0;
if (a.forEach((function(e) {
var t = e.getPhysicsImpostor();
if (t) {
if (t.type == Vl.MeshImpostor)
throw "A child MeshImpostor is not supported. Only primitive impostors are supported as children (eg. box or sphere)";
var r = i._createShape(t)
, o = e.parent.getWorldMatrix().clone()
, a = new x;
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),
n.addChildShape(i._tmpAmmoTransform, r),
t.dispose(),
s++
}
}
)),
s > 0) {
if (e.type != Vl.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),
n.addChildShape(this._tmpAmmoTransform, l))
}
return n
}
this.bjsAMMO.destroy(n),
n = null
}
switch (e.type) {
case Vl.SphereImpostor:
if (d.WithinEpsilon(o.x, o.y, 1e-4) && d.WithinEpsilon(o.x, o.z, 1e-4))
n = new this.bjsAMMO.btSphereShape(o.x / 2);
else {
var c = [new this.bjsAMMO.btVector3(0,0,0)];
(n = new this.bjsAMMO.btMultiSphereShape(c,[1],1)).setLocalScaling(new this.bjsAMMO.btVector3(o.x / 2,o.y / 2,o.z / 2))
}
break;
case Vl.CapsuleImpostor:
var u = o.x / 2;
n = new this.bjsAMMO.btCapsuleShape(u,o.y - 2 * u);
break;
case Vl.CylinderImpostor:
this._tmpAmmoVectorA.setValue(o.x / 2, o.y / 2, o.z / 2),
n = new this.bjsAMMO.btCylinderShape(this._tmpAmmoVectorA);
break;
case Vl.PlaneImpostor:
case Vl.BoxImpostor:
this._tmpAmmoVectorA.setValue(o.x / 2, o.y / 2, o.z / 2),
n = new this.bjsAMMO.btBoxShape(this._tmpAmmoVectorA);
break;
case Vl.MeshImpostor:
if (0 == e.getParam("mass")) {
if (this.onCreateCustomMeshImpostor)
n = this.onCreateCustomMeshImpostor(e);
else {
var h = new this.bjsAMMO.btTriangleMesh;
e._pluginData.toDispose.push(h);
var p = this._addMeshVerts(h, r, r);
n = 0 == p ? new this.bjsAMMO.btCompoundShape : new this.bjsAMMO.btBvhTriangleMeshShape(h)
}
break
}
case Vl.ConvexHullImpostor:
if (this.onCreateCustomConvexHullImpostor)
n = this.onCreateCustomConvexHullImpostor(e);
else {
var f = new this.bjsAMMO.btConvexHullShape;
0 == (p = this._addHullVerts(f, r, r)) ? (e._pluginData.toDispose.push(f),
n = new this.bjsAMMO.btCompoundShape) : n = f
}
break;
case Vl.NoImpostor:
n = new this.bjsAMMO.btSphereShape(o.x / 2);
break;
case Vl.CustomImpostor:
n = this._createCustom(e);
break;
case Vl.SoftbodyImpostor:
n = this._createSoftbody(e);
break;
case Vl.ClothImpostor:
n = this._createCloth(e);
break;
case Vl.RopeImpostor:
n = this._createRope(e);
break;
default:
K.Warn("The impostor type is not currently supported by the ammo plugin.")
}
return n
}
,
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 n = e.physicsBody.getWorldTransform();
if (Math.abs(n.getOrigin().x() - t.x) > m || Math.abs(n.getOrigin().y() - t.y) > m || Math.abs(n.getOrigin().z() - t.z) > m || Math.abs(n.getRotation().x() - i.x) > m || Math.abs(n.getRotation().y() - i.y) > m || Math.abs(n.getRotation().z() - i.z) > m || Math.abs(n.getRotation().w() - i.w) > m)
if (this._tmpAmmoVectorA.setValue(t.x, t.y, t.z),
n.setOrigin(this._tmpAmmoVectorA),
this._tmpAmmoQuaternion.setValue(i.x, i.y, i.z, i.w),
n.setRotation(this._tmpAmmoQuaternion),
e.physicsBody.setWorldTransform(n),
0 == e.mass) {
var r = e.physicsBody.getMotionState();
r && r.setWorldTransform(n)
} 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 x(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 x(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 : (K.Warn("Pressure is not a property of a rigid body"),
0)
}
,
e.prototype.setBodyPressure = function(e, t) {
e.soft ? e.type === Vl.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) : K.Warn("Pressure can only be applied to a softbody")
}
,
e.prototype.getBodyStiffness = function(e) {
return e.soft ? e._pluginData.stiffness || 0 : (K.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) : K.Warn("Stiffness cannot be applied to a rigid body")
}
,
e.prototype.getBodyVelocityIterations = function(e) {
return e.soft ? e._pluginData.velocityIterations || 0 : (K.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) : K.Warn("Velocity iterations cannot be applied to a rigid body")
}
,
e.prototype.getBodyPositionIterations = function(e) {
return e.soft ? e._pluginData.positionIterations || 0 : (K.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) : K.Warn("Position iterations cannot be applied to a rigid body")
}
,
e.prototype.appendAnchor = function(e, t, i, n, r, o) {
void 0 === r && (r = 1),
void 0 === o && (o = !1);
var a = e.segments
, s = Math.round((a - 1) * i) + a * (a - 1 - Math.round((a - 1) * n));
e.physicsBody.appendAnchor(s, t.physicsBody, o, r)
}
,
e.prototype.appendHook = function(e, t, i, n, r) {
void 0 === n && (n = 1),
void 0 === r && (r = !1);
var o = Math.round(e.segments * i);
e.physicsBody.appendAnchor(o, t.physicsBody, r, n)
}
,
e.prototype.sleepBody = function(e) {
e.physicsBody.forceActivationState(0)
}
,
e.prototype.wakeUpBody = function(e) {
e.physicsBody.activate()
}
,
e.prototype.updateDistanceJoint = function() {
K.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() {
K.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.getObjectExtendSize().x / 2
}
,
e.prototype.getBoxSizeToRef = function(e, t) {
var i = e.getObjectExtendSize();
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) {
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 i = new this.bjsAMMO.ClosestRayResultCallback(this._tmpAmmoVectorRCA,this._tmpAmmoVectorRCB);
return this.world.rayTest(this._tmpAmmoVectorRCA, this._tmpAmmoVectorRCB, i),
this._raycastResult.reset(e, t),
i.hasHit() && (this._raycastResult.setHitData({
x: i.get_m_hitNormalWorld().x(),
y: i.get_m_hitNormalWorld().y(),
z: i.get_m_hitNormalWorld().z()
}, {
x: i.get_m_hitPointWorld().x(),
y: i.get_m_hitPointWorld().y(),
z: i.get_m_hitPointWorld().z()
}),
this._raycastResult.calculateHitDistance()),
this.bjsAMMO.destroy(i),
this.bjsAMMO.destroy(this._tmpAmmoVectorRCA),
this.bjsAMMO.destroy(this._tmpAmmoVectorRCB),
this._raycastResult
}
,
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 O_ = function() {
function e(e, t, i, n, r, o) {
void 0 === n && (n = !0),
void 0 === r && (r = !1),
void 0 === o && (o = !1);
var s = this;
if (this.name = e,
this._viewMatrix = P.Identity(),
this._target = x.Zero(),
this._add = x.Zero(),
this._invertYAxis = !1,
this.position = x.Zero(),
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 (r) {
var u = this._scene.getEngine().getCaps();
u.textureHalfFloatRender ? c = a.TEXTURETYPE_HALF_FLOAT : u.textureFloatRender && (c = a.TEXTURETYPE_FLOAT)
}
this._renderTargetTexture = new ns(e,t,i,n,!0,c,!0),
this._renderTargetTexture.gammaSpace = !o;
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 ? P.LookAtRHToRef : P.LookAtLHToRef
, n = i.useRightHandedSystem ? P.PerspectiveFovRH : P.PerspectiveFovLH;
t(s.position, s._target, x.Up(), s._viewMatrix),
i.activeCamera && (s._projectionMatrix = n(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, n;
s._currentSceneUBO = i.getSceneUniformBuffer(),
null === (n = (t = i.getEngine())._debugPushGroup) || void 0 === n || n.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, n = this._sceneUBOs; i < n.length; i++)
n[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 = Ge.Serialize(this, this._renderTargetTexture.serialize());
return e.isReflectionProbe = !0,
e
}
,
e.Parse = function(t, i, n) {
var r = null;
if (i.reflectionProbes)
for (var o = 0; o < i.reflectionProbes.length; o++) {
var a = i.reflectionProbes[o];
if (a.name === t.name) {
r = a;
break
}
}
return (r = Ge.Parse((function() {
return r || new e(t.name,t.renderTargetSize,i,t._generateMipMaps)
}
), t, i, n)).cubeTexture._waitingRenderList = t.renderList,
t._attachedMesh && r.attachToMesh(i.getMeshById(t._attachedMesh)),
r
}
,
k([Ne()], e.prototype, "_attachedMesh", void 0),
k([De()], e.prototype, "position", void 0),
e
}()
, D_ = !0
, N_ = function() {
function e() {}
return e.LoaderInjectedPhysicsEngine = void 0,
e
}()
, L_ = {}
, F_ = {}
, w_ = function(e, t, i, n) {
if (!t.materials)
return null;
for (var r = 0, o = t.materials.length; r < o; r++) {
var a = t.materials[r];
if (e(a))
return Or.Parse(a, i, n)
}
return null
}
, B_ = function(e, t) {
return e + " of " + (t ? t.file + " from " + t.name + " version: " + t.version + ", exporter version: " + t.exporter_version : "unknown")
}
, U_ = function(e, t) {
var i = t;
if (t._waitingData.lods) {
if (t._waitingData.lods.ids && t._waitingData.lods.ids.length > 0) {
var n = t._waitingData.lods.ids
, r = i.isEnabled(!1);
if (t._waitingData.lods.distances) {
var o = t._waitingData.lods.distances;
if (o.length >= n.length) {
var a = o.length > n.length ? o[o.length - 1] : 0;
i.setEnabled(!1);
for (var s = 0; s < n.length; s++) {
var l = n[s]
, c = e.getMeshById(l);
null != c && i.addLODLevel(o[s], c)
}
a > 0 && i.addLODLevel(a, null),
!0 === r && i.setEnabled(!0)
} else
gi.Warn("Invalid level of detail distances for " + t.name)
}
}
t._waitingData.lods = null
}
}
, V_ = function(e, t) {
return "number" != typeof e ? t.getLastEntryById(e) : L_[e]
}
, k_ = function(e, t) {
return "number" != typeof e ? t.getLastMaterialById(e, !0) : F_[e]
}
, G_ = function(e, t, i, n, r) {
void 0 === r && (r = !1);
var a = new zr(e)
, s = "importScene has failed JSON parse";
try {
var l = JSON.parse(t);
s = "";
var c = od.loggingLevel === od.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 E_((l.environmentTexture.match(/https?:\/\//g) ? "" : i) + l.environmentTexture,e,p,!0,!d);
l.environmentTextureRotationY && (f.rotationY = l.environmentTextureRotationY),
e.environmentTexture = f
} else if (oe(l.environmentTexture, ".env")) {
var _ = new Bd((l.environmentTexture.match(/https?:\/\//g) ? "" : i) + l.environmentTexture,e);
l.environmentTextureRotationY && (_.rotationY = l.environmentTextureRotationY),
e.environmentTexture = _
} else {
var m = Bd.CreateFromPrefilteredData((l.environmentTexture.match(/https?:\/\//g) ? "" : i) + l.environmentTexture, e);
l.environmentTextureRotationY && (m.rotationY = l.environmentTextureRotationY),
e.environmentTexture = m
}
if (!0 === l.createDefaultSkybox) {
var g = void 0 !== e.activeCamera && null !== e.activeCamera ? (e.activeCamera.maxZ - e.activeCamera.minZ) / 2 : 1e3
, v = l.skyboxBlurLevel || 0;
e.createDefaultSkybox(e.environmentTexture, d, g, v)
}
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 y = l.lights[u];
(ie = Cr.Parse(y, e)) && (L_[y.uniqueId] = ie,
a.lights.push(ie),
ie._parentContainer = a,
s += 0 === u ? "\n\tLights:" : "",
s += "\n\t\t" + ie.toString(c))
}
if (void 0 !== l.reflectionProbes && null !== l.reflectionProbes)
for (u = 0,
h = l.reflectionProbes.length; u < h; u++) {
var T = l.reflectionProbes[u]
, E = O_.Parse(T, e, i);
E && (a.reflectionProbes.push(E),
E._parentContainer = a,
s += 0 === u ? "\n\tReflection Probes:" : "",
s += "\n\t\t" + E.toString(c))
}
if (void 0 !== l.animations && null !== l.animations)
for (u = 0,
h = l.animations.length; u < h; u++) {
var S = l.animations[u]
, A = b("BABYLON.Animation");
if (A) {
var x = A.Parse(S);
e.animations.push(x),
a.animations.push(x),
s += 0 === u ? "\n\tAnimations:" : "",
s += "\n\t\t" + x.toString(c)
}
}
if (void 0 !== l.materials && null !== l.materials)
for (u = 0,
h = l.materials.length; u < h; u++) {
var R = l.materials[u]
, C = Or.Parse(R, e, i);
C && (F_[R.uniqueId || R.id] = C,
a.materials.push(C),
C._parentContainer = a,
s += 0 === u ? "\n\tMaterials:" : "",
s += "\n\t\t" + C.toString(c),
C.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 P = l.multiMaterials[u]
, M = Dr.ParseMultiMaterial(P, e);
F_[P.uniqueId || P.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 I = 0, O = l.morphTargetManagers; I < O.length; I++) {
var D = O[I]
, N = x_.Parse(D, e);
a.morphTargetManagers.push(N),
N._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]
, F = Fo.Parse(L, e);
a.skeletons.push(F),
F._parentContainer = a,
s += 0 === u ? "\n\tSkeletons:" : "",
s += "\n\t\t" + F.toString(c)
}
var w = l.geometries;
if (null != w) {
var B = new Array
, U = w.vertexData;
if (null != U)
for (u = 0,
h = U.length; u < h; u++) {
var V = U[u];
B.push(fr.Parse(V, e, i))
}
B.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 k = l.transformNodes[u]
, G = yr.Parse(k, e, i);
L_[k.uniqueId] = G,
a.transformNodes.push(G),
G._parentContainer = a
}
if (void 0 !== l.meshes && null !== l.meshes)
for (u = 0,
h = l.meshes.length; u < h; u++) {
var z = l.meshes[u]
, W = Vr.Parse(z, e, i);
if (L_[z.uniqueId] = W,
a.meshes.push(W),
W._parentContainer = a,
W.hasInstances)
for (var H = 0, X = W.instances; H < X.length; H++) {
var j = X[H];
a.meshes.push(j),
j._parentContainer = a
}
s += 0 === u ? "\n\tMeshes:" : "",
s += "\n\t\t" + W.toString(c)
}
if (void 0 !== l.cameras && null !== l.cameras)
for (u = 0,
h = l.cameras.length; u < h; u++) {
var Y = l.cameras[u]
, Q = Rr.Parse(Y, e);
L_[Y.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 = Ba.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]
, $ = Hn.Parse(J, e);
a.animationGroups.push($),
$._parentContainer = a,
s += 0 === u ? "\n\tAnimationGroups:" : "",
s += "\n\t\t" + $.toString(c)
}
for (u = 0,
h = e.cameras.length; u < h; u++)
null !== (Q = e.cameras[u])._waitingParentId && (Q.parent = V_(Q._waitingParentId, e),
Q._waitingParentId = null);
for (u = 0,
h = e.lights.length; u < h; u++)
(ie = e.lights[u]) && null !== ie._waitingParentId && (ie.parent = V_(ie._waitingParentId, e),
ie._waitingParentId = null);
for (u = 0,
h = e.transformNodes.length; u < h; u++) {
var ee = e.transformNodes[u];
null !== ee._waitingParentId && (ee.parent = V_(ee._waitingParentId, e),
ee._waitingParentId = null)
}
for (u = 0,
h = e.meshes.length; u < h; u++)
null !== (W = e.meshes[u])._waitingParentId && (W.parent = V_(W._waitingParentId, e),
W._waitingParentId = null),
W._waitingData.lods && U_(e, W);
for (e.multiMaterials.forEach((function(t) {
t._waitingSubMaterialsUniqueIds.forEach((function(i) {
t.subMaterials.push(k_(i, e))
}
)),
t._waitingSubMaterialsUniqueIds = []
}
)),
e.meshes.forEach((function(t) {
null !== t._waitingMaterialId && (t.material = k_(t._waitingMaterialId, e),
t._waitingMaterialId = null)
}
)),
u = 0,
h = e.skeletons.length; u < h; u++)
(F = e.skeletons[u])._hasWaitingData && (null != F.bones && F.bones.forEach((function(t) {
if (t._waitingTransformNodeId) {
var i = e.getLastEntryById(t._waitingTransformNodeId);
i && t.linkTransformNode(i),
t._waitingTransformNodeId = null
}
}
)),
F._hasWaitingData = null);
for (u = 0,
h = e.meshes.length; u < h; u++) {
var te = e.meshes[u];
te._waitingData.freezeWorldMatrix ? (te.freezeWorldMatrix(),
te._waitingData.freezeWorldMatrix = null) : te.computeWorldMatrix(!0)
}
for (u = 0,
h = e.lights.length; u < h; u++) {
var ie;
if ((ie = e.lights[u])._excludedMeshesIds.length > 0) {
for (var ne = 0; ne < ie._excludedMeshesIds.length; ne++) {
var re = e.getMeshById(ie._excludedMeshesIds[ne]);
re && ie.excludedMeshes.push(re)
}
ie._excludedMeshesIds = []
}
if (ie._includedOnlyMeshesIds.length > 0) {
for (var ae = 0; ae < ie._includedOnlyMeshesIds.length; ae++) {
var se = e.getMeshById(ie._includedOnlyMeshesIds[ae]);
se && ie.includedOnlyMeshes.push(se)
}
ie._includedOnlyMeshesIds = []
}
}
for (o.Parse(l, e, a, i),
u = 0,
h = e.meshes.length; u < h; u++)
(W = e.meshes[u])._waitingData.actions && (_e.Parse(W._waitingData.actions, W, e),
W._waitingData.actions = null);
void 0 !== l.actions && null !== l.actions && _e.Parse(l.actions, null, e)
} catch (e) {
var le = B_("loadAssets", l ? l.producer : "Unknown") + s;
if (!n)
throw K.Log(le),
e;
n(le, e)
} finally {
L_ = {},
r || a.removeAllFromScene(),
null !== s && od.loggingLevel !== od.NO_LOGGING && K.Log(B_("loadAssets", l ? l.producer : "Unknown") + (od.loggingLevel !== od.MINIMAL_LOGGING ? s : ""))
}
return a
};
od.RegisterPlugin({
name: "babylon.js",
extensions: ".babylon",
canDirectLoad: function(e) {
return -1 !== e.indexOf("babylon")
},
importMesh: function(e, t, i, n, r, a, s, l) {
var c, u = "importMesh has failed JSON parse";
try {
var h = JSON.parse(i);
u = "";
var d = od.loggingLevel === od.DETAILED_LOGGING;
e ? Array.isArray(e) || (e = [e]) : e = null;
var p = new Array
, f = [];
if (void 0 !== h.transformNodes && null !== h.transformNodes)
for (var _ = 0, m = h.transformNodes.length; _ < m; _++) {
var g = h.transformNodes[_];
f.push(yr.Parse(g, t, n))
}
if (void 0 !== h.meshes && null !== h.meshes) {
var v = []
, y = []
, b = []
, T = []
, E = function(i, o) {
var a = h.meshes[i];
if (null === e || function(e, t, i) {
for (var n in t)
if (e.name === t[n])
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 && fr.Parse(i, t, n),
l = !0)
}
))
}
)),
!1 === l && K.Warn("Geometry not found for mesh " + a.id)
}
if (a.materialUniqueId || a.materialId) {
var c = a.materialUniqueId ? b : y
, f = -1 !== c.indexOf(a.materialUniqueId || a.materialId);
if (!1 === f && void 0 !== h.multiMaterials && null !== h.multiMaterials)
for (var _ = function(e, i) {
c.push(e);
var r = w_(i, h, t, n);
r && (u += "\n\tMaterial " + r.toString(d))
}, m = 0, g = h.multiMaterials.length; m < g; m++) {
var E = h.multiMaterials[m];
if (a.materialUniqueId && E.uniqueId === a.materialUniqueId || E.id === a.materialId) {
E.materialsUniqueIds ? E.materialsUniqueIds.forEach((function(e) {
return _(e, (function(t) {
return t.uniqueId === e
}
))
}
)) : E.materials.forEach((function(e) {
return _(e, (function(t) {
return t.id === e
}
))
}
)),
c.push(E.uniqueId || E.id);
var S = Dr.ParseMultiMaterial(E, t);
F_[E.uniqueId || E.id] = S,
S && (f = !0,
u += "\n\tMulti-Material " + S.toString(d));
break
}
}
if (!1 === f) {
c.push(a.materialUniqueId || a.materialId);
var A = w_((function(e) {
return a.MaterialUniqueId && e.uniqueId === a.materialUniqueId || e.id === a.materialId
}
), h, t, n);
A ? u += "\n\tMaterial " + A.toString(d) : K.Warn("Material not found for mesh " + a.id)
}
}
if (a.skeletonId > -1 && void 0 !== h.skeletons && null !== h.skeletons && !(v.indexOf(a.skeletonId) > -1))
for (var x = 0, R = h.skeletons.length; x < R; x++) {
var C = h.skeletons[x];
if (C.id === a.skeletonId) {
var P = Fo.Parse(C, t);
s.push(P),
v.push(C.id),
u += "\n\tSkeleton " + P.toString(d)
}
}
if (a.morphTargetManagerId > -1 && void 0 !== h.morphTargetManagers && null !== h.morphTargetManagers && !(T.indexOf(a.morphTargetManagerId) > -1))
for (var M = 0, I = h.morphTargetManagers.length; M < I; M++) {
var O = h.morphTargetManagers[M];
if (O.id === a.morphTargetManagerId) {
var D = x_.Parse(O, t);
T.push(D.uniqueId),
u += "\nMorph target " + D.toString()
}
}
var N = Vr.Parse(a, t, n);
r.push(N),
u += "\n\tMesh " + N.toString(d)
}
};
for (_ = 0,
m = h.meshes.length; _ < m; _++)
E(_);
for (t.multiMaterials.forEach((function(e) {
e._waitingSubMaterialsUniqueIds.forEach((function(i) {
e.subMaterials.push(k_(i, t))
}
)),
e._waitingSubMaterialsUniqueIds = []
}
)),
t.meshes.forEach((function(e) {
null !== e._waitingMaterialId && (e.material = k_(e._waitingMaterialId, t),
e._waitingMaterialId = null)
}
)),
_ = 0,
m = t.transformNodes.length; _ < m; _++)
null !== (C = t.transformNodes[_])._waitingParentId && (C.parent = t.getLastEntryById(C._waitingParentId),
C._waitingParentId = null);
var S = void 0;
for (_ = 0,
m = t.meshes.length; _ < m; _++) {
if ((S = t.meshes[_])._waitingParentId) {
if (S.parent = t.getLastEntryById(S._waitingParentId),
"TransformNode" === (null === (c = S.parent) || void 0 === c ? void 0 : c.getClassName())) {
var A = f.indexOf(S.parent);
A > -1 && f.splice(A, 1)
}
S._waitingParentId = null
}
S._waitingData.lods && U_(t, S)
}
for (var x = 0, R = f; x < R.length; x++) {
var C;
(C = R[x]).dispose()
}
for (_ = 0,
m = t.skeletons.length; _ < m; _++) {
var P = t.skeletons[_];
P._hasWaitingData && (null != P.bones && P.bones.forEach((function(e) {
if (e._waitingTransformNodeId) {
var i = t.getLastEntryById(e._waitingTransformNodeId);
i && e.linkTransformNode(i),
e._waitingTransformNodeId = null
}
}
)),
P._hasWaitingData = null)
}
for (_ = 0,
m = t.meshes.length; _ < m; _++)
(S = t.meshes[_])._waitingData.freezeWorldMatrix ? (S.freezeWorldMatrix(),
S._waitingData.freezeWorldMatrix = null) : S.computeWorldMatrix(!0)
}
if (void 0 !== h.particleSystems && null !== h.particleSystems) {
var M = o.GetIndividualParser(Wi.NAME_PARTICLESYSTEM);
if (M)
for (_ = 0,
m = h.particleSystems.length; _ < m; _++) {
var I = h.particleSystems[_];
-1 !== p.indexOf(I.emitterId) && a.push(M(I, t, n))
}
}
return !0
} catch (e) {
var O = B_("importMesh", h ? h.producer : "Unknown") + u;
if (!l)
throw K.Log(O),
e;
l(O, e)
} finally {
null !== u && od.loggingLevel !== od.NO_LOGGING && K.Log(B_("importMesh", h ? h.producer : "Unknown") + (od.loggingLevel !== od.MINIMAL_LOGGING ? u : ""))
}
return !1
},
load: function(e, t, i, n) {
var r = "importScene has failed JSON parse";
try {
var o = JSON.parse(t);
if (r = "",
void 0 !== o.useDelayedTextureLoading && null !== o.useDelayedTextureLoading && (e.useDelayedTextureLoading = o.useDelayedTextureLoading && !od.ForceFullSceneLoadingForIncremental),
void 0 !== o.autoClear && null !== o.autoClear && (e.autoClear = o.autoClear),
void 0 !== o.clearColor && null !== o.clearColor && (e.clearColor = N.FromArray(o.clearColor)),
void 0 !== o.ambientColor && null !== o.ambientColor && (e.ambientColor = D.FromArray(o.ambientColor)),
void 0 !== o.gravity && null !== o.gravity && (e.gravity = x.FromArray(o.gravity)),
void 0 !== o.useRightHandedSystem && (e.useRightHandedSystem = !!o.useRightHandedSystem),
o.fogMode && 0 !== o.fogMode)
switch (e.fogMode = o.fogMode,
e.fogColor = D.FromArray(o.fogColor),
e.fogStart = o.fogStart,
e.fogEnd = o.fogEnd,
e.fogDensity = o.fogDensity,
r += "\tFog mode for scene: ",
e.fogMode) {
case 1:
r += "exp\n";
break;
case 2:
r += "exp2\n";
break;
case 3:
r += "linear\n"
}
if (o.physicsEnabled) {
var a = void 0;
"cannon" === o.physicsEngine ? a = new P_(void 0,void 0,N_.LoaderInjectedPhysicsEngine) : "oimo" === o.physicsEngine ? a = new M_(void 0,N_.LoaderInjectedPhysicsEngine) : "ammo" === o.physicsEngine && (a = new I_(void 0,N_.LoaderInjectedPhysicsEngine,void 0)),
r = "\tPhysics engine " + (o.physicsEngine ? o.physicsEngine : "oimo") + " enabled\n";
var s = o.physicsGravity ? x.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),
!!G_(e, t, i, n, !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 = B_("importScene", o ? o.producer : "Unknown") + r;
if (!n)
throw K.Log(l),
e;
n(l, e)
} finally {
null !== r && od.loggingLevel !== od.NO_LOGGING && K.Log(B_("importScene", o ? o.producer : "Unknown") + (od.loggingLevel !== od.MINIMAL_LOGGING ? r : ""))
}
return !1
},
loadAssetContainer: function(e, t, i, n) {
return G_(e, t, i, n)
}
});
var z_ = 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 || D.White(),
this.rightColor = e.rightColor || D.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,
vr.MarkAllMaterialsAsDirty(a.MATERIAL_FresnelDirtyFlag | a.MATERIAL_MiscDirtyFlag))
},
enumerable: !1,
configurable: !0
}),
e.prototype.clone = function() {
var t = new e;
return fe.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: D.FromArray(t.leftColor),
rightColor: D.FromArray(t.rightColor),
bias: t.bias,
power: t.power || 1
})
}
,
e
}();
Ge._FresnelParametersParser = z_.Parse;
var W_ = function(e) {
function t(t, i) {
var n = e.call(this, t, i, "color", {
attributes: ["position"],
uniforms: ["world", "viewProjection", "color"]
}) || this;
return n.disableColorWrite = !0,
n.forceDepthWrite = !0,
n.setColor4("color", new N(0,0,0,1)),
n
}
return U(t, e),
t
}(jl)
, H_ = function(e) {
function t(t, i) {
var n = e.call(this, t, i) || this;
return n.maxSimultaneousLights = 4,
n.disableLighting = !1,
n.invertNormalMapX = !1,
n.invertNormalMapY = !1,
n.emissiveColor = new D(0,0,0),
n.occlusionStrength = 1,
n.useLightmapAsShadowmap = !1,
n._useAlphaFromAlbedoTexture = !0,
n._useAmbientInGrayScale = !0,
n
}
return U(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"
}
,
k([Ce(), Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "maxSimultaneousLights", void 0),
k([Ce(), Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "disableLighting", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", "_reflectionTexture")], t.prototype, "environmentTexture", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapX", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapY", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", "_bumpTexture")], t.prototype, "normalTexture", void 0),
k([Me("emissive"), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveColor", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveTexture", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty", "_ambientTextureStrength")], t.prototype, "occlusionStrength", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", "_ambientTexture")], t.prototype, "occlusionTexture", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty", "_alphaCutOff")], t.prototype, "alphaCutOff", void 0),
k([Ce()], t.prototype, "doubleSided", null),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", null)], t.prototype, "lightmapTexture", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useLightmapAsShadowmap", void 0),
t
}(rp)
, X_ = function(e) {
function t(t, i) {
var n = e.call(this, t, i) || this;
return n._useRoughnessFromMetallicTextureAlpha = !1,
n._useRoughnessFromMetallicTextureGreen = !0,
n._useMetallnessFromMetallicTextureBlue = !0,
n.metallic = 1,
n.roughness = 1,
n
}
return U(t, e),
t.prototype.getClassName = function() {
return "PBRMetallicRoughnessMaterial"
}
,
t.prototype.clone = function(e) {
var i = this
, n = Ge.Clone((function() {
return new t(e,i.getScene())
}
), this);
return n.id = e,
n.name = e,
this.clearCoat.copyTo(n.clearCoat),
this.anisotropy.copyTo(n.anisotropy),
this.brdf.copyTo(n.brdf),
this.sheen.copyTo(n.sheen),
this.subSurface.copyTo(n.subSurface),
n
}
,
t.prototype.serialize = function() {
var e = Ge.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
}
,
t.Parse = function(e, i, n) {
var r = Ge.Parse((function() {
return new t(e.name,i)
}
), e, i, n);
return e.clearCoat && r.clearCoat.parse(e.clearCoat, i, n),
e.anisotropy && r.anisotropy.parse(e.anisotropy, i, n),
e.brdf && r.brdf.parse(e.brdf, i, n),
e.sheen && r.sheen.parse(e.sheen, i, n),
e.subSurface && r.subSurface.parse(e.subSurface, i, n),
r
}
,
k([Me(), Re("_markAllSubMeshesAsTexturesDirty", "_albedoColor")], t.prototype, "baseColor", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")], t.prototype, "baseTexture", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallic", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "roughness", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", "_metallicTexture")], t.prototype, "metallicRoughnessTexture", void 0),
t
}(H_);
y("BABYLON.PBRMetallicRoughnessMaterial", X_);
var j_ = function(e) {
function t(t, i) {
var n = e.call(this, t, i) || this;
return n._useMicroSurfaceFromReflectivityMapAlpha = !0,
n
}
return U(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
, n = Ge.Clone((function() {
return new t(e,i.getScene())
}
), this);
return n.id = e,
n.name = e,
this.clearCoat.copyTo(n.clearCoat),
this.anisotropy.copyTo(n.anisotropy),
this.brdf.copyTo(n.brdf),
this.sheen.copyTo(n.sheen),
this.subSurface.copyTo(n.subSurface),
n
}
,
t.prototype.serialize = function() {
var e = Ge.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
}
,
t.Parse = function(e, i, n) {
var r = Ge.Parse((function() {
return new t(e.name,i)
}
), e, i, n);
return e.clearCoat && r.clearCoat.parse(e.clearCoat, i, n),
e.anisotropy && r.anisotropy.parse(e.anisotropy, i, n),
e.brdf && r.brdf.parse(e.brdf, i, n),
e.sheen && r.sheen.parse(e.sheen, i, n),
e.subSurface && r.subSurface.parse(e.subSurface, i, n),
r
}
,
k([Me("diffuse"), Re("_markAllSubMeshesAsTexturesDirty", "_albedoColor")], t.prototype, "diffuseColor", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")], t.prototype, "diffuseTexture", void 0),
k([Me("specular"), Re("_markAllSubMeshesAsTexturesDirty", "_reflectivityColor")], t.prototype, "specularColor", void 0),
k([Ce(), Re("_markAllSubMeshesAsTexturesDirty", "_microSurface")], t.prototype, "glossiness", void 0),
k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", "_reflectivityTexture")], t.prototype, "specularGlossinessTexture", void 0),
t
}(H_);
y("BABYLON.PBRSpecularGlossinessMaterial", j_);
var Y_ = function(e) {
function t(t, i, n) {
void 0 === n && (n = null);
var r = e.call(this, i) || this;
if (!t)
return r;
if (r._textureMatrix = P.Identity(),
r.name = t,
r.url = t,
r._onLoad = n,
r._texture = r._getFromCache(t, !0),
r._texture)
r._triggerOnLoad();
else {
var o = r.getScene();
o && o.useDelayedTextureLoading ? r.delayLoadState = a.DELAYLOADSTATE_NOTLOADED : r._loadTexture()
}
return r
}
return U(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, n = this._getEngine();
e = n._features.support3DTextures ? n.createRawTexture3D(null, 1, 1, 1, a.TEXTUREFORMAT_RGBA, !1, !1, a.TEXTURE_BILINEAR_SAMPLINGMODE, null, a.TEXTURETYPE_UNSIGNED_INT) : n.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 = n._features.support3DTextures,
this.wrapU = a.TEXTURE_CLAMP_ADDRESSMODE,
this.wrapV = a.TEXTURE_CLAMP_ADDRESSMODE,
this.wrapR = a.TEXTURE_CLAMP_ADDRESSMODE,
this.anisotropicFilteringLevel = 1;
var r = function(r) {
if ("string" == typeof r) {
for (var o, s = null, l = null, c = r.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),
n.updateRawTexture3D(e, s, a.TEXTUREFORMAT_RGBA, !1)) : (e.updateSize(u * u, u),
n.updateRawTexture(e, s, a.TEXTUREFORMAT_RGBA, !1)),
e.isReady = !0,
i._triggerOnLoad()
}
}
, o = this.getScene();
return o ? o._loadFile(this.url, r) : n._loadFile(this.url, r),
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 n = null;
return e.name && !e.isRenderTarget && ((n = new t(e.name,i)).name = e.name,
n.level = e.level),
n
}
,
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
}(Zr);
y("BABYLON.ColorGradingTexture", Y_);
var K_ = function(e) {
function t(t, i, n, r, o, s, l) {
void 0 === r && (r = !1),
void 0 === o && (o = !0),
void 0 === s && (s = null),
void 0 === l && (l = null);
var c = e.call(this, i) || this;
if (c._onLoad = null,
c._onError = null,
!t)
throw new Error("Image url is not set");
return c._coordinatesMode = io.CUBIC_MODE,
c.name = t,
c.url = t,
c._size = n,
c._noMipmap = r,
c.gammaSpace = o,
c._onLoad = s,
c._onError = l,
c.hasAlpha = !1,
c.isCube = !0,
c._texture = c._getFromCache(t, c._noMipmap),
c._texture ? s && (c._texture.isReady ? gi.SetImmediate((function() {
return s()
}
)) : c._texture.onLoadedObservable.add(s)) : i.useDelayedTextureLoading ? c.delayLoadState = a.DELAYLOADSTATE_NOTLOADED : c._loadImage(c._loadTexture.bind(c), c._onError),
c
}
return U(t, e),
t.prototype._loadImage = function(e, t) {
var i = this
, n = document.createElement("canvas");
$t(this.url, (function(t) {
i._width = t.width,
i._height = t.height,
n.width = i._width,
n.height = i._height;
var r = n.getContext("2d");
r.drawImage(t, 0, 0);
var o = r.getImageData(0, 0, t.width, t.height);
i._buffer = o.data.buffer,
n.remove(),
e()
}
), (function(e, n) {
t && t("".concat(i.getClassName(), " could not be loaded"), n)
}
), 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), n = g_.ConvertPanoramaToCubemap(i, e._width, e._height, e._size), r = [], o = 0; o < 6; o++) {
var a = n[t._FacesMapping[o]];
r.push(a)
}
return r
}
), null, this._onLoad, this._onError))
}
,
t.prototype._getFloat32ArrayFromArrayBuffer = function(e) {
for (var t = new DataView(e), i = new Float32Array(3 * e.byteLength / 4), n = 0, r = 0; r < e.byteLength; r++)
(r + 1) % 4 != 0 && (i[n++] = t.getUint8(r) / 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
}(Zr)
, Q_ = function(e) {
function t(i, n, r) {
var o = e.call(this, r.scene || r.engine) || this;
return n && (r.engine || r.scene) ? (r = V(V({}, t._DefaultOptions), r),
o._generateMipMaps = r.generateMipMaps,
o._samplingMode = r.samplingMode,
o._textureMatrix = P.Identity(),
o.name = i,
o.element = n,
o._isVideo = n instanceof HTMLVideoElement,
o.anisotropicFilteringLevel = 1,
o._createInternalTexture(),
o) : o
}
return U(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.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)
if (this._isVideo) {
var i = this.element;
if (i.readyState < i.HAVE_CURRENT_DATA)
return;
t.updateVideoTexture(this._texture, i, null === e || e)
} else {
var n = this.element;
t.updateDynamicTexture(this._texture, n, null === e || e, !1)
}
}
,
t._DefaultOptions = {
generateMipMaps: !1,
samplingMode: a.TEXTURE_BILINEAR_SAMPLINGMODE,
engine: null,
scene: null
},
t
}(Zr);
function q_(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 Z_(e, t) {
if (t.length < 19)
K.Error("Unable to load TGA file - Not enough data to contain header");
else {
var i = 18
, n = q_(t);
if (n.id_length + i > t.length)
K.Error("Unable to load TGA file - Not enough data");
else {
i += n.id_length;
var r, o = !1, a = !1, s = !1;
switch (n.image_type) {
case 9:
o = !0;
case 1:
a = !0;
break;
case 10:
o = !0;
case 2:
break;
case 11:
o = !0;
case 3:
s = !0
}
var l, c, u, h, d, p, f, _ = n.pixel_size >> 3, m = n.width * n.height * _;
if (a && (l = t.subarray(i, i += n.colormap_length * (n.colormap_size >> 3))),
o) {
r = 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)
r.set(T, b + y * _);
b += _ * v
} else {
for (v *= _,
y = 0; y < v; ++y)
r[b + y] = t[i++];
b += v
}
} else
r = t.subarray(i, i += a ? n.width * n.height : m);
switch ((48 & n.flags) >> 4) {
default:
case 2:
c = 0,
h = 1,
f = n.width,
u = 0,
d = 1,
p = n.height;
break;
case 0:
c = 0,
h = 1,
f = n.width,
u = n.height - 1,
d = -1,
p = -1;
break;
case 3:
c = n.width - 1,
h = -1,
f = -1,
u = 0,
d = 1,
p = n.height;
break;
case 1:
c = n.width - 1,
h = -1,
f = -1,
u = n.height - 1,
d = -1,
p = -1
}
var E = "_getImageData" + (s ? "Grey" : "") + n.pixel_size + "bits"
, S = J_[E](n, l, r, u, d, p, c, h, f);
e.getEngine()._uploadDataToTextureDirectly(e, S)
}
}
}
var J_ = {
GetTGAHeader: q_,
UploadContent: Z_,
_getImageData8bits: function(e, t, i, n, r, 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 = n; h !== o; h += r)
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, n, r, 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 = n; h !== o; h += r)
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, n, r, o, a, s, l) {
var c, u, h = i, d = e.width, p = e.height, f = 0, _ = new Uint8Array(d * p * 4);
for (u = n; u !== o; u += r)
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, n, r, o, a, s, l) {
var c, u, h = i, d = e.width, p = e.height, f = 0, _ = new Uint8Array(d * p * 4);
for (u = n; u !== o; u += r)
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, n, r, 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 = n; h !== o; h += r)
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, n, r, o, a, s, l) {
var c, u, h = i, d = e.width, p = e.height, f = 0, _ = new Uint8Array(d * p * 4);
for (u = n; u !== o; u += r)
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 _
}
}
, $_ = function() {
function e() {
this.supportCascades = !1
}
return e.prototype.canLoad = function(e) {
return oe(e, ".tga")
}
,
e.prototype.loadCubeData = function() {
throw ".env not supported in Cube."
}
,
e.prototype.loadData = function(e, t, i) {
var n = new Uint8Array(e.buffer,e.byteOffset,e.byteLength)
, r = q_(n);
i(r.width, r.height, t.generateMipMaps, !1, (function() {
Z_(t, n)
}
))
}
,
e
}();
vr._TextureLoaders.push(new $_);
var em = function() {
function e() {
this.supportCascades = !1
}
return e.prototype.canLoad = function(e) {
return oe(e, ".hdr")
}
,
e.prototype.loadCubeData = function() {
throw ".env not supported in Cube."
}
,
e.prototype.loadData = function(e, t, i) {
for (var n = new Uint8Array(e.buffer,e.byteOffset,e.byteLength), r = v_.RGBE_ReadHeader(n), o = v_.RGBE_ReadPixels(n, r), s = r.width * r.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(r.width, r.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
}();
vr._TextureLoaders.push(new em);
var tm, im = function() {};
!function(e) {
e[e.cTFETC1 = 0] = "cTFETC1",
e[e.cTFBC1 = 1] = "cTFBC1",
e[e.cTFBC4 = 2] = "cTFBC4",
e[e.cTFPVRTC1_4_OPAQUE_ONLY = 3] = "cTFPVRTC1_4_OPAQUE_ONLY",
e[e.cTFBC7_M6_OPAQUE_ONLY = 4] = "cTFBC7_M6_OPAQUE_ONLY",
e[e.cTFETC2 = 5] = "cTFETC2",
e[e.cTFBC3 = 6] = "cTFBC3",
e[e.cTFBC5 = 7] = "cTFBC5"
}(tm || (tm = {}));
var nm = {
JSModuleURL: "https://preview.babylonjs.com/basisTranscoder/basis_transcoder.js",
WasmModuleURL: "https://preview.babylonjs.com/basisTranscoder/basis_transcoder.wasm"
}
, rm = function(e, t) {
var i;
switch (e) {
case tm.cTFETC1:
i = a.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL;
break;
case tm.cTFBC1:
i = a.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1;
break;
case tm.cTFBC4:
i = a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5
}
if (void 0 === i)
throw "The chosen Basis transcoder format is not currently supported";
return i
}
, om = null
, am = null
, sm = 0
, lm = function(e, t) {
var i = e instanceof ArrayBuffer ? new Uint8Array(e) : e;
return new Promise((function(e, n) {
(om || (om = new Promise((function(e, t) {
am ? e(am) : gi.LoadFileAsync(nm.WasmModuleURL).then((function(i) {
var n = URL.createObjectURL(new Blob(["(".concat(hm, ")()")],{
type: "application/javascript"
}));
am = new Worker(n);
var r = function(i) {
"init" === i.data.action ? (am.removeEventListener("message", r),
e(am)) : "error" === i.data.action && t(i.data.error || "error initializing worker")
};
am.addEventListener("message", r),
am.postMessage({
action: "init",
url: nm.JSModuleURL,
wasmBinary: i
})
}
)).catch(t)
}
))),
om).then((function() {
var r = sm++
, o = function(t) {
"transcode" === t.data.action && t.data.id === r && (am.removeEventListener("message", o),
t.data.success ? e(t.data) : n("Transcode is not supported on this device"))
};
am.addEventListener("message", o);
var a = new Uint8Array(i.byteLength);
a.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength)),
am.postMessage({
action: "transcode",
id: r,
imageData: a,
config: t,
ignoreSupportedFormats: !1
}, [a.buffer])
}
), (function(e) {
n(e)
}
))
}
))
}
, cm = function(e, t) {
for (var i = e.getEngine(), n = function(n) {
var r = t.fileInfo.images[n].levels[0];
if (e._invertVScale = e.invertY,
-1 === t.format)
if (e.type = a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,
e.format = a.TEXTUREFORMAT_RGB,
!i._features.basisNeedsPOT || d.Log2(r.width) % 1 == 0 && d.Log2(r.height) % 1 == 0)
e._invertVScale = !e.invertY,
e.width = r.width + 3 & -4,
e.height = r.height + 3 & -4,
i._uploadDataToTextureDirectly(e, r.transcodedPixels, n, 0, a.TEXTUREFORMAT_RGB, !0);
else {
var o = new Lt(i,At.Temp);
e._invertVScale = e.invertY,
o.type = a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,
o.format = a.TEXTUREFORMAT_RGB,
o.width = r.width + 3 & -4,
o.height = r.height + 3 & -4,
i._bindTextureDirectly(i._gl.TEXTURE_2D, o, !0),
i._uploadDataToTextureDirectly(o, r.transcodedPixels, n, 0, a.TEXTUREFORMAT_RGB, !0),
i._rescaleTexture(o, e, i.scenes[0], i._getInternalFormat(a.TEXTUREFORMAT_RGB), (function() {
i._releaseTexture(o),
i._bindTextureDirectly(i._gl.TEXTURE_2D, e, !0)
}
))
}
else
e.width = r.width,
e.height = r.height,
e.generateMipMaps = t.fileInfo.images[n].levels.length > 1,
t.fileInfo.images[n].levels.forEach((function(r, o) {
i._uploadCompressedDataToTextureDirectly(e, um.GetInternalFormatFromBasisFormat(t.format, i), r.width, r.height, r.transcodedPixels, n, o)
}
)),
!i._features.basisNeedsPOT || d.Log2(e.width) % 1 == 0 && d.Log2(e.height) % 1 == 0 || (gi.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 = io.CLAMP_ADDRESSMODE,
e._cachedWrapV = io.CLAMP_ADDRESSMODE)
}, r = 0; r < t.fileInfo.images.length; r++)
n(r)
}
, um = {
JSModuleURL: nm.JSModuleURL,
WasmModuleURL: nm.WasmModuleURL,
GetInternalFormatFromBasisFormat: rm,
TranscodeAsync: lm,
LoadTextureFromTranscodeResult: cm
};
function hm() {
var e = null;
function t(e, t, i, n, r) {
var o = e.getImageTranscodedSizeInBytes(t, i, n)
, a = new Uint8Array(o);
return e.transcodeImage(a, t, i, n, 1, 0) ? (r && (a = function(e, t, i, n) {
for (var r = new Uint16Array(4), o = new Uint16Array(i * n), a = i / 4, s = n / 4, l = 0; l < s; l++)
for (var c = 0; c < a; c++) {
var u = 0 + 8 * (l * a + c);
r[0] = e[u] | e[u + 1] << 8,
r[1] = e[u + 2] | e[u + 3] << 8,
r[2] = (2 * (31 & r[0]) + 1 * (31 & r[1])) / 3 | (2 * (2016 & r[0]) + 1 * (2016 & r[1])) / 3 & 2016 | (2 * (63488 & r[0]) + 1 * (63488 & r[1])) / 3 & 63488,
r[3] = (2 * (31 & r[1]) + 1 * (31 & r[0])) / 3 | (2 * (2016 & r[1]) + 1 * (2016 & r[0])) / 3 & 2016 | (2 * (63488 & r[1]) + 1 * (63488 & r[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++] = r[3 & d],
o[p++] = r[d >> 2 & 3],
o[p++] = r[d >> 4 & 3],
o[p++] = r[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) {
Module = {
wasmBinary: i.data.wasmBinary
};
try {
importScripts(i.data.url)
} catch (e) {
postMessage({
action: "error",
error: e
})
}
e = new Promise((function(e) {
Module.onRuntimeInitialized = function() {
Module.initializeBasis(),
e()
}
}
))
}
e.then((function() {
postMessage({
action: "init"
})
}
))
} else if ("transcode" === i.data.action) {
var n = i.data.config
, r = i.data.imageData
, o = new Module.BasisFile(r)
, a = function(e) {
for (var t = e.getHasAlpha(), i = e.getNumImages(), n = [], r = 0; r < i; r++) {
for (var o = {
levels: []
}, a = e.getNumLevels(r), s = 0; s < a; s++) {
var l = {
width: e.getImageWidth(r, s),
height: e.getImageHeight(r, s)
};
o.levels.push(l)
}
n.push(o)
}
return {
hasAlpha: t,
images: n
}
}(o)
, s = i.data.ignoreSupportedFormats ? null : function(e, t) {
var i = null;
return e.supportedCompressionFormats && (e.supportedCompressionFormats.etc1 ? i = 0 : e.supportedCompressionFormats.s3tc ? i = t.hasAlpha ? 6 : 1 : e.supportedCompressionFormats.pvrtc || e.supportedCompressionFormats.etc2 && (i = 5)),
i
}(i.data.config, a)
, l = !1;
null === s && (l = !0,
s = a.hasAlpha ? 6 : 1);
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 === n.loadSingleImage || n.loadSingleImage === h) {
var p = d.levels.length;
!1 === n.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(um, "JSModuleURL", {
get: function() {
return nm.JSModuleURL
},
set: function(e) {
nm.JSModuleURL = e
}
}),
Object.defineProperty(um, "WasmModuleURL", {
get: function() {
return nm.WasmModuleURL
},
set: function(e) {
nm.WasmModuleURL = e
}
});
var dm = function() {
function e() {
this.supportCascades = !1
}
return e.prototype.canLoad = function(e) {
return oe(e, ".basis")
}
,
e.prototype.loadCubeData = function(e, t, i, n, r) {
if (!Array.isArray(e)) {
var o = t.getEngine().getCaps()
, a = {
supportedCompressionFormats: {
etc1: !!o.etc1,
s3tc: !!o.s3tc,
pvrtc: !!o.pvrtc,
etc2: !!o.etc2
}
};
lm(e, a).then((function(e) {
var i = e.fileInfo.images[0].levels.length > 1 && t.generateMipMaps;
cm(t, e),
t.getEngine()._setCubeMapTextureParams(t, i),
t.isReady = !0,
t.onLoadedObservable.notifyObservers(t),
t.onLoadedObservable.clear(),
n && n()
}
)).catch((function(e) {
gi.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),
t.isReady = !0,
r && r(e)
}
))
}
}
,
e.prototype.loadData = function(e, t, i) {
var n = t.getEngine().getCaps()
, r = {
supportedCompressionFormats: {
etc1: !!n.etc1,
s3tc: !!n.s3tc,
pvrtc: !!n.pvrtc,
etc2: !!n.etc2
}
};
lm(e, r).then((function(e) {
var n = e.fileInfo.images[0].levels[0]
, r = e.fileInfo.images[0].levels.length > 1 && t.generateMipMaps;
i(n.width, n.height, r, -1 !== e.format, (function() {
cm(t, e)
}
))
}
)).catch((function() {
gi.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),
i(0, 0, !1, !1, (function() {}
), !0)
}
))
}
,
e
}();
vr._TextureLoaders.push(new dm);
var pm = function(e) {
function t(t, i, n, r, 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, r, c, d, void 0, void 0, void 0, void 0, void 0, void 0, void 0, !0) || this).isSupported)
return l.dispose(),
l;
var f = []
, _ = [];
l._initTypes(n, f, _, o);
var m = !o || void 0 === o.generateDepthBuffer || o.generateDepthBuffer
, g = !(!o || void 0 === o.generateStencilBuffer) && o.generateStencilBuffer;
return l._size = i,
l._multiRenderTargetOptions = {
samplingModes: _,
generateMipMaps: c,
generateDepthBuffer: m,
generateStencilBuffer: g,
generateDepthTexture: u,
depthTextureFormat: h,
types: f,
textureCount: n
},
l._count = n,
l._drawOnlyOnFirstAttachmentByDefault = p,
n > 0 && (l._createInternalTextures(),
l._createTextures(s)),
l
}
return U(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, n) {
for (var r = 0; r < e; r++)
n && n.types && void 0 !== n.types[r] ? t.push(n.types[r]) : t.push(n && n.defaultType ? n.defaultType : a.TEXTURETYPE_UNSIGNED_INT),
n && n.samplingModes && void 0 !== n.samplingModes[r] ? i.push(n.samplingModes[r]) : i.push(io.BILINEAR_SAMPLINGMODE)
}
,
t.prototype._rebuild = function(e, t) {
if (void 0 === e && (e = !1),
!(this._count < 1)) {
this.releaseInternalTextures(),
this._createInternalTextures(),
e && (this._releaseTextures(),
this._createTextures(t));
for (var i = this._renderTarget.textures, n = 0; n < i.length; n++)
this._textures[n]._texture = i[n];
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 n = new io(null,this.getScene());
(null == e ? void 0 : e[i]) && (n.name = e[i]),
n._texture = t[i],
this._textures.push(n)
}
}
,
t.prototype.setInternalTexture = function(e, t, i) {
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 io(null,this.getScene())),
this.textures[t]._texture = e,
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))
}
,
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._size = e,
this._rebuild()
}
,
t.prototype.updateCount = function(e, t, i) {
this._multiRenderTargetOptions.textureCount = e,
this._count = e;
var n = []
, r = [];
this._initTypes(e, n, r, t),
this._multiRenderTargetOptions.types = n,
this._multiRenderTargetOptions.samplingModes = r,
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 n = i.length - 1; n >= 0; n--)
this._textures[n]._texture = null;
null === (t = this._renderTarget) || void 0 === t || t.dispose(),
this._renderTarget = null
}
}
,
t
}(ns)
, fm = function(e, t, i) {
this.id = e,
this.scale = t,
this.offset = i
}
, _m = function() {
function e(t, i, n, r) {
var o, a, s, l, c, u, h, d, p, f, _, m, g;
return this.name = t,
this.meshes = i,
this.scene = r,
this.options = n,
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 : Bi.UVKind,
this.options.uvsOut = null !== (s = this.options.uvsOut) && void 0 !== s ? s : Bi.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 N(0,0,0,1)),
this.sets = {},
this.frames = [],
this
}
return e.prototype._createFrames = function(e) {
for (var t = this, i = this._calculateSize(), n = new A(1,1).divide(i), r = 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 Ds(this.name + ".TexturePack." + c + "Set",{
width: i.x,
height: i.y
},this.scene,!0,io.TRILINEAR_SAMPLINGMODE,vr.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 Ds("temp",f,g.scene,!0)
, u = c.getContext()
, h = g._getFrameOffset(l)
, m = function() {
r++,
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),
r == o)
return t._calculateMeshUVFrames(d, p, i, n, t.options.updateInputMeshes || !1),
void e()
}
, v = s[a] || "_blank";
if (_ && null !== _[v]) {
var y = _[v]
, b = new Image;
b.src = y instanceof Ds ? y.getContext().canvas.toDataURL("image/png") : y.url,
gi.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 n = 0; n < p; n++)
u.drawImage(b, 0, 0, b.width, b.height, n + d * e[0], p - f, d, d),
u.drawImage(b, 0, 0, b.width, b.height, 2 * p - n, p - f, d, d),
u.drawImage(b, 0, 0, b.width, b.height, p, n - f, d, d),
u.drawImage(b, 0, 0, b.width, b.height, p, 2 * p - n - 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 || D.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 n = Math.max(2, Math.ceil(Math.sqrt(e)))
, r = t * n + 2 * i * n;
return new A(r,r);
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, n, r) {
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 = n.clone().scale(t)
, u = this._getFrameOffset(a).add(c)
, h = new fm(a,l,u);
this.frames.push(h),
r && (this._updateMeshUV(s, a),
this._updateTextureReferences(s))
}
}
,
e.prototype._getFrameOffset = function(e) {
var t, i, n, r = this.meshes.length;
switch (this.options.layout) {
case 0:
return new A(e * (t = 1 / r),0);
case 1:
var o = Math.max(2, Math.ceil(Math.sqrt(r)));
return i = Math.floor(e / o),
new A((n = e - i * o) * (t = 1 / o),i * t);
case 2:
var a = this.options.colnum || 1
, s = Math.max(1, Math.ceil(r / a));
return i = e - (n = Math.floor(e / s)) * s,
t = new A(1 / a,1 / s),
new A(n * t.x,i * t.y)
}
return A.Zero()
}
,
e.prototype._updateMeshUV = function(e, t) {
var i = this.frames[t]
, n = e.getVerticesData(this.options.uvsIn || Bi.UVKind)
, r = []
, o = 0;
n.length && (o = n.length || 0);
for (var a = 0; a < o; a += 2)
r.push(n[a] * i.scale.x + i.offset.x, n[a + 1] * i.scale.y + i.offset.y);
e.setVerticesData(this.options.uvsOut || Bi.UVKind, r)
}
,
e.prototype._updateTextureReferences = function(e, t) {
void 0 === t && (t = !1);
for (var i = e.material, n = Object.keys(this.sets), r = function(e) {
e.dispose && e.dispose()
}, o = 0; o < n.length; o++) {
var a = n[o];
if (t)
null !== i[a] && r(i[a]),
i[a] = this.sets[a];
else {
if (!i)
return;
null !== i[a] && (r(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 n = 0, r = function(i) {
var r = e.meshes[i]
, o = r.material;
if (!o)
return ++n === e.meshes.length ? {
value: e._createFrames(t)
} : "continue";
o.forceCompilationAsync(r).then((function() {
!function(i) {
if (n++,
e.options.map) {
for (var r = 0; r < e.options.map.length; r++)
null !== i[e.options.map[r]] && (e.sets[e.options.map[r]] || (e.sets[e.options.map[r]] = !0),
e._expecting++);
n === e.meshes.length && e._createFrames(t)
}
}(o)
}
))
}, o = 0; o < e.meshes.length; o++) {
var a = r(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 n = {
name: i.name,
sets: {},
options: {},
frames: []
}
, r = Object.keys(i.sets)
, o = Object.keys(i.options);
try {
for (var a = 0; a < r.length; a++) {
var s = r[a]
, l = i.sets[s];
n.sets[s] = l.getContext().canvas.toDataURL("image/" + e, t)
}
for (a = 0; a < o.length; a++) {
var c = o[a];
n.options[c] = i.options[c]
}
for (a = 0; a < i.frames.length; a++) {
var u = i.frames[a];
n.frames.push(u.scale.x, u.scale.y, u.offset.x, u.offset.y)
}
} catch (e) {
return void K.Warn("Unable to download: " + e)
}
var h = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(n, 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), n = 0; n < i.length; n++)
this.options[i[n]] = t.options[i[n]];
for (n = 0; n < t.frames.length; n += 4) {
var r = new fm(n / 4,new A(t.frames[n],t.frames[n + 1]),new A(t.frames[n + 2],t.frames[n + 3]));
this.frames.push(r)
}
var o = Object.keys(t.sets);
for (n = 0; n < o.length; n++) {
var a = new io(t.sets[o[n]],this.scene,!1,!1);
this.sets[o[n]] = a
}
} catch (e) {
K.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
}()
, mm = function(e) {
function t(t, i, n, r, o, a) {
var s = e.call(this, t, n, null, r, o, a) || this;
return s._animate = !0,
s._time = 0,
s._texturePath = i,
s._loadJson(i),
s.refreshRate = 1,
s
}
return U(t, e),
t.prototype._loadJson = function(e) {
var t = this
, i = function() {
try {
t.setFragment(t._texturePath)
} catch (e) {
K.Log("No json or ShaderStore or DOM element found for CustomProceduralTexture")
}
}
, n = e + "/config.json"
, r = new Ye;
r.open("GET", n),
r.addEventListener("load", (function() {
if (200 === r.status || r.responseText && r.responseText.length > 0)
try {
t._config = JSON.parse(r.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),
r.addEventListener("error", (function() {
i()
}
), !1);
try {
r.send()
} catch (e) {
K.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 io(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 D(t.r,t.g,t.b));
break;
case "color4":
this.setColor4(t.name, new N(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 x(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
}(xf);
Pt.ShadersStore.noisePixelShader = "uniform float brightness;\nuniform float persistence;\nuniform float timeScale;\nvarying vec2 vUV;\nvec2 hash22(vec2 p)\n{\np=p*mat2(127.1,311.7,269.5,183.3);\np=-1.0+2.0*fract(sin(p)*43758.5453123);\nreturn sin(p*6.283+timeScale);\n}\nfloat interpolationNoise(vec2 p)\n{\nvec2 pi=floor(p);\nvec2 pf=p-pi;\nvec2 w=pf*pf*(3.-2.*pf);\nfloat f00=dot(hash22(pi+vec2(.0,.0)),pf-vec2(.0,.0));\nfloat f01=dot(hash22(pi+vec2(.0,1.)),pf-vec2(.0,1.));\nfloat f10=dot(hash22(pi+vec2(1.0,0.)),pf-vec2(1.0,0.));\nfloat f11=dot(hash22(pi+vec2(1.0,1.)),pf-vec2(1.0,1.));\nfloat xm1=mix(f00,f10,w.x);\nfloat xm2=mix(f01,f11,w.x);\nfloat ym=mix(xm1,xm2,w.y); \nreturn ym;\n}\nfloat perlinNoise2D(float x,float y)\n{\nfloat sum=0.0;\nfloat frequency=0.0;\nfloat amplitude=0.0;\nfor(int i=0; i0\r\n",
t.compilationString += this._declareOutput(r, t) + " = ".concat(o.associatedVariableName, " * ").concat(n, ";\r\n"),
t.compilationString += "#else\r\n",
t.compilationString += this._declareOutput(r, t) + " = ".concat(o.associatedVariableName, ";\r\n"),
t.compilationString += "#endif\r\n",
this
}
,
t
}(Wp);
y("BABYLON.BonesBlock", Em);
var Sm = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Vertex) || this;
return i.registerInput("world0", Op.Vector4),
i.registerInput("world1", Op.Vector4),
i.registerInput("world2", Op.Vector4),
i.registerInput("world3", Op.Vector4),
i.registerInput("world", Op.Matrix, !0),
i.registerOutput("output", Op.Matrix),
i.registerOutput("instanceID", Op.Float),
i
}
return U(t, e),
t.prototype.getClassName = function() {
return "InstancesBlock"
}
,
Object.defineProperty(t.prototype, "world0", {
get: function() {
return this._inputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "world1", {
get: function() {
return this._inputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "world2", {
get: function() {
return this._inputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "world3", {
get: function() {
return this._inputs[3]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "world", {
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
}),
Object.defineProperty(t.prototype, "instanceID", {
get: function() {
return this._outputs[1]
},
enumerable: !1,
configurable: !0
}),
t.prototype.autoConfigure = function(e) {
if (!this.world0.connectedPoint) {
var t = e.getInputBlockByPredicate((function(e) {
return e.isAttribute && "world0" === e.name
}
));
t || (t = new tf("world0")).setAsAttribute("world0"),
t.output.connectTo(this.world0)
}
if (!this.world1.connectedPoint) {
var i = e.getInputBlockByPredicate((function(e) {
return e.isAttribute && "world1" === e.name
}
));
i || (i = new tf("world1")).setAsAttribute("world1"),
i.output.connectTo(this.world1)
}
if (!this.world2.connectedPoint) {
var n = e.getInputBlockByPredicate((function(e) {
return e.isAttribute && "world2" === e.name
}
));
n || (n = new tf("world2")).setAsAttribute("world2"),
n.output.connectTo(this.world2)
}
if (!this.world3.connectedPoint) {
var r = e.getInputBlockByPredicate((function(e) {
return e.isAttribute && "world3" === e.name
}
));
r || (r = new tf("world3")).setAsAttribute("world3"),
r.output.connectTo(this.world3)
}
if (!this.world.connectedPoint) {
var o = e.getInputBlockByPredicate((function(e) {
return e.isAttribute && "world" === e.name
}
));
o || (o = new tf("world")).setAsSystemValue(Qp.World),
o.output.connectTo(this.world)
}
this.world.define = "!INSTANCES || THIN_INSTANCES"
}
,
t.prototype.prepareDefines = function(e, t, i, n, r) {
void 0 === n && (n = !1);
var o = !1;
i.INSTANCES !== n && (i.setValue("INSTANCES", n),
o = !0),
r && i.THIN_INSTANCES !== !!(null == r ? void 0 : r.getRenderingMesh().hasThinInstances) && (i.setValue("THIN_INSTANCES", !!(null == r ? void 0 : r.getRenderingMesh().hasThinInstances)),
o = !0),
o && i.markAsUnprocessed()
}
,
t.prototype._buildBlock = function(t) {
e.prototype._buildBlock.call(this, t);
var i = t.sharedData.scene.getEngine();
t.sharedData.blocksWithDefines.push(this);
var n = this._outputs[0]
, r = this._outputs[1]
, o = this.world0
, a = this.world1
, s = this.world2
, l = this.world3;
return t.compilationString += "#ifdef INSTANCES\r\n",
t.compilationString += this._declareOutput(n, t) + " = mat4(".concat(o.associatedVariableName, ", ").concat(a.associatedVariableName, ", ").concat(s.associatedVariableName, ", ").concat(l.associatedVariableName, ");\r\n"),
t.compilationString += "#ifdef THIN_INSTANCES\r\n",
t.compilationString += "".concat(n.associatedVariableName, " = ").concat(this.world.associatedVariableName, " * ").concat(n.associatedVariableName, ";\r\n"),
t.compilationString += "#endif\r\n",
i._caps.canUseGLInstanceID ? t.compilationString += this._declareOutput(r, t) + " = float(gl_InstanceID);\r\n" : t.compilationString += this._declareOutput(r, t) + " = 0.0;\r\n",
t.compilationString += "#else\r\n",
t.compilationString += this._declareOutput(n, t) + " = ".concat(this.world.associatedVariableName, ";\r\n"),
t.compilationString += this._declareOutput(r, t) + " = 0.0;\r\n",
t.compilationString += "#endif\r\n",
this
}
,
t
}(Wp);
y("BABYLON.InstancesBlock", Sm);
var Am = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Vertex) || this;
return i.registerInput("position", Op.Vector3),
i.registerInput("normal", Op.Vector3),
i.registerInput("tangent", Op.Vector3),
i.registerInput("uv", Op.Vector2),
i.registerOutput("positionOutput", Op.Vector3),
i.registerOutput("normalOutput", Op.Vector3),
i.registerOutput("tangentOutput", Op.Vector3),
i.registerOutput("uvOutput", Op.Vector2),
i
}
return U(t, e),
t.prototype.getClassName = function() {
return "MorphTargetsBlock"
}
,
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, "tangent", {
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, "positionOutput", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "normalOutput", {
get: function() {
return this._outputs[1]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "tangentOutput", {
get: function() {
return this._outputs[2]
},
enumerable: !1,
configurable: !0
}),
Object.defineProperty(t.prototype, "uvOutput", {
get: function() {
return this._outputs[3]
},
enumerable: !1,
configurable: !0
}),
t.prototype.initialize = function(e) {
e._excludeVariableName("morphTargetInfluences")
}
,
t.prototype.autoConfigure = function(e) {
if (!this.position.isConnected) {
var t = e.getInputBlockByPredicate((function(e) {
return e.isAttribute && "position" === e.name
}
));
t || (t = new tf("position")).setAsAttribute(),
t.output.connectTo(this.position)
}
if (!this.normal.isConnected) {
var i = e.getInputBlockByPredicate((function(e) {
return e.isAttribute && "normal" === e.name
}
));
i || (i = new tf("normal")).setAsAttribute("normal"),
i.output.connectTo(this.normal)
}
if (!this.tangent.isConnected) {
var n = e.getInputBlockByPredicate((function(e) {
return e.isAttribute && "tangent" === e.name
}
));
n || (n = new tf("tangent")).setAsAttribute("tangent"),
n.output.connectTo(this.tangent)
}
if (!this.uv.isConnected) {
var r = e.getInputBlockByPredicate((function(e) {
return e.isAttribute && "uv" === e.name
}
));
r || (r = new tf("uv")).setAsAttribute("uv"),
r.output.connectTo(this.uv)
}
}
,
t.prototype.prepareDefines = function(e, t, i) {
if (e.morphTargetManager) {
var n = e.morphTargetManager;
(null == n ? void 0 : n.isUsingTextureForTargets) && n.numInfluencers !== i.NUM_MORPH_INFLUENCERS && i.markAsAttributesDirty()
}
i._areAttributesDirty && Mr.PrepareDefinesForMorphTargets(e, i)
}
,
t.prototype.bind = function(e, t, i) {
i && i.morphTargetManager && i.morphTargetManager.numInfluencers > 0 && (Mr.BindMorphTargetParameters(i, e),
i.morphTargetManager.isUsingTextureForTargets && i.morphTargetManager._bind(e))
}
,
t.prototype.replaceRepeatableContent = function(e, t, i, n) {
var r = 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 = n.NUM_MORPH_INFLUENCERS
, f = i.morphTargetManager
, _ = f && f.supportsNormals && n.NORMAL
, m = f && f.supportsTangents && n.TANGENT
, g = f && f.supportsUVs && n.UV1
, v = "";
(null == f ? void 0 : f.isUsingTextureForTargets) && p > 0 && (v += "float vertexID;\r\n");
for (var y = 0; y < p; y++)
v += "#ifdef MORPHTARGETS\r\n",
(null == f ? void 0 : f.isUsingTextureForTargets) ? (v += "vertexID = float(gl_VertexID) * morphTargetTextureInfo.x;\r\n",
v += "".concat(l.associatedVariableName, " += (readVector3FromRawSampler(").concat(y, ", vertexID) - ").concat(r.associatedVariableName, ") * morphTargetInfluences[").concat(y, "];\r\n"),
v += "vertexID += 1.0;\r\n") : v += "".concat(l.associatedVariableName, " += (position").concat(y, " - ").concat(r.associatedVariableName, ") * morphTargetInfluences[").concat(y, "];\r\n"),
_ && (v += "#ifdef MORPHTARGETS_NORMAL\r\n",
(null == f ? void 0 : f.isUsingTextureForTargets) ? (v += "".concat(c.associatedVariableName, " += (readVector3FromRawSampler(").concat(y, ", vertexID) - ").concat(o.associatedVariableName, ") * morphTargetInfluences[").concat(y, "];\r\n"),
v += "vertexID += 1.0;\r\n") : v += "".concat(c.associatedVariableName, " += (normal").concat(y, " - ").concat(o.associatedVariableName, ") * morphTargetInfluences[").concat(y, "];\r\n"),
v += "#endif\r\n"),
g && (v += "#ifdef MORPHTARGETS_UV\r\n",
(null == f ? void 0 : f.isUsingTextureForTargets) ? (v += "".concat(h.associatedVariableName, " += (readVector3FromRawSampler(").concat(y, ", vertexID).xy - ").concat(s.associatedVariableName, ") * morphTargetInfluences[").concat(y, "];\r\n"),
v += "vertexID += 1.0;\r\n") : v += "".concat(h.associatedVariableName, ".xy += (uv_").concat(y, " - ").concat(s.associatedVariableName, ".xy) * morphTargetInfluences[").concat(y, "];\r\n"),
v += "#endif\r\n"),
m && (v += "#ifdef MORPHTARGETS_TANGENT\r\n",
(null == f ? void 0 : f.isUsingTextureForTargets) ? v += "".concat(u.associatedVariableName, " += (readVector3FromRawSampler(").concat(y, ", vertexID) - ").concat(a.associatedVariableName, ") * morphTargetInfluences[").concat(y, "];\r\n") : v += "".concat(u.associatedVariableName, ".xyz += (tangent").concat(y, " - ").concat(a.associatedVariableName, ".xyz) * morphTargetInfluences[").concat(y, "];\r\n"),
v += "#endif\r\n"),
v += "#endif\r\n";
if (d.compilationString = d.compilationString.replace(this._repeatableContentAnchor, v),
p > 0)
for (y = 0; y < p; y++)
d.attributes.push(Bi.PositionKind + y),
_ && d.attributes.push(Bi.NormalKind + y),
m && d.attributes.push(Bi.TangentKind + y),
g && d.attributes.push(Bi.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
, n = this.normal
, r = 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, ";\r\n"),
t.compilationString += "#ifdef NORMAL\r\n",
t.compilationString += "".concat(this._declareOutput(s, t), " = ").concat(n.associatedVariableName, ";\r\n"),
t.compilationString += "#else\r\n",
t.compilationString += "".concat(this._declareOutput(s, t), " = vec3(0., 0., 0.);\r\n"),
t.compilationString += "#endif\r\n",
t.compilationString += "#ifdef TANGENT\r\n",
t.compilationString += "".concat(this._declareOutput(l, t), " = ").concat(r.associatedVariableName, ";\r\n"),
t.compilationString += "#else\r\n",
t.compilationString += "".concat(this._declareOutput(l, t), " = vec3(0., 0., 0.);\r\n"),
t.compilationString += "#endif\r\n",
t.compilationString += "#ifdef UV1\r\n",
t.compilationString += "".concat(this._declareOutput(c, t), " = ").concat(o.associatedVariableName, ";\r\n"),
t.compilationString += "#else\r\n",
t.compilationString += "".concat(this._declareOutput(c, t), " = vec2(0., 0.);\r\n"),
t.compilationString += "#endif\r\n",
this._repeatableContentAnchor = t._repeatableContentAnchor,
t.compilationString += this._repeatableContentAnchor,
this
}
,
t
}(Wp);
y("BABYLON.MorphTargetsBlock", Am);
var xm = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Vertex) || this;
return i.registerInput("worldPosition", Op.Vector4, !1, Dp.Vertex),
i.registerOutput("direction", Op.Vector3),
i.registerOutput("color", Op.Color3),
i.registerOutput("intensity", Op.Float),
i
}
return U(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
}),
t.prototype.bind = function(e, t, i) {
if (i) {
this.light && this.light.isDisposed && (this.light = null);
var n = this.light
, r = t.getScene();
if (!n && r.lights.length && (n = this.light = r.lights[0],
this._forcePrepareDefines = !0),
!n || !n.isEnabled)
return e.setFloat3(this._lightDataUniformName, 0, 0, 0),
void e.setFloat4(this._lightColorUniformName, 0, 0, 0, 0);
n.transferToNodeMaterialEffect(e, this._lightDataUniformName),
e.setColor4(this._lightColorUniformName, n.diffuse, n.intensity)
}
}
,
t.prototype.prepareDefines = function(e, t, i) {
if (i._areLightsDirty || this._forcePrepareDefines) {
this._forcePrepareDefines = !1;
var n = this.light;
i.setValue(this._lightTypeDefineName, !!(n && n instanceof __), !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
, n = this.color
, r = this.intensity;
return this._lightDataUniformName = t._getFreeVariableName("lightData"),
this._lightColorUniformName = t._getFreeVariableName("lightColor"),
this._lightTypeDefineName = t._getFreeDefineName("LIGHTPOINTTYPE"),
t._emitUniformFromString(this._lightDataUniformName, "vec3"),
t._emitUniformFromString(this._lightColorUniformName, "vec4"),
t.compilationString += "#ifdef ".concat(this._lightTypeDefineName, "\r\n"),
t.compilationString += this._declareOutput(i, t) + " = normalize(".concat(this.worldPosition.associatedVariableName, ".xyz - ").concat(this._lightDataUniformName, ");\r\n"),
t.compilationString += "#else\r\n",
t.compilationString += this._declareOutput(i, t) + " = ".concat(this._lightDataUniformName, ";\r\n"),
t.compilationString += "#endif\r\n",
t.compilationString += this._declareOutput(n, t) + " = ".concat(this._lightColorUniformName, ".rgb;\r\n"),
t.compilationString += this._declareOutput(r, t) + " = ".concat(this._lightColorUniformName, ".a;\r\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, n) {
e.prototype._deserialize.call(this, t, i, n),
t.lightId && (this.light = i.getLightById(t.lightId))
}
,
t
}(Wp);
y("BABYLON.LightInformationBlock", xm);
var Rm = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Fragment) || this;
return i.convertInputToLinearSpace = !0,
i.registerInput("color", Op.Color4),
i.registerOutput("output", Op.Color4),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Color3),
i
}
return U(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
}),
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")
}
,
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) {
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");
var i = this.color
, n = this._outputs[0]
, r = "//".concat(this.name);
return t._emitFunctionFromInclude("helperFunctions", r),
t._emitFunctionFromInclude("imageProcessingDeclaration", r),
t._emitFunctionFromInclude("imageProcessingFunctions", r),
i.connectedPoint.type === Op.Color4 || i.connectedPoint.type === Op.Vector4 ? t.compilationString += "".concat(this._declareOutput(n, t), " = ").concat(i.associatedVariableName, ";\r\n") : t.compilationString += "".concat(this._declareOutput(n, t), " = vec4(").concat(i.associatedVariableName, ", 1.0);\r\n"),
t.compilationString += "#ifdef IMAGEPROCESSINGPOSTPROCESS\r\n",
this.convertInputToLinearSpace && (t.compilationString += "".concat(n.associatedVariableName, ".rgb = toLinearSpace(").concat(i.associatedVariableName, ".rgb);\r\n")),
t.compilationString += "#else\r\n",
t.compilationString += "#ifdef IMAGEPROCESSING\r\n",
this.convertInputToLinearSpace && (t.compilationString += "".concat(n.associatedVariableName, ".rgb = toLinearSpace(").concat(i.associatedVariableName, ".rgb);\r\n")),
t.compilationString += "".concat(n.associatedVariableName, " = applyImageProcessing(").concat(n.associatedVariableName, ");\r\n"),
t.compilationString += "#endif\r\n",
t.compilationString += "#endif\r\n",
this
}
,
t.prototype._dumpPropertiesCode = function() {
return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".convertInputToLinearSpace = ").concat(this.convertInputToLinearSpace, ";\r\n")
}
,
t.prototype.serialize = function() {
var t = e.prototype.serialize.call(this);
return t.convertInputToLinearSpace = this.convertInputToLinearSpace,
t
}
,
t.prototype._deserialize = function(t, i, n) {
var r;
e.prototype._deserialize.call(this, t, i, n),
this.convertInputToLinearSpace = null === (r = t.convertInputToLinearSpace) || void 0 === r || r
}
,
k([Yp("Convert input to linear space", Xp.Boolean, "ADVANCED")], t.prototype, "convertInputToLinearSpace", void 0),
t
}(Wp);
y("BABYLON.ImageProcessingBlock", Rm);
var Cm = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Fragment) || this;
return i._tangentSpaceParameterName = "",
i.invertX = !1,
i.invertY = !1,
i.useParallaxOcclusion = !1,
i._isUnique = !0,
i.registerInput("worldPosition", Op.Vector4, !1),
i.registerInput("worldNormal", Op.Vector4, !1),
i.registerInput("worldTangent", Op.Vector4, !0),
i.registerInput("uv", Op.Vector2, !1),
i.registerInput("normalMapColor", Op.Color3, !1),
i.registerInput("strength", Op.Float, !1),
i.registerInput("viewDirection", Op.Vector3, !0),
i.registerInput("parallaxScale", Op.Float, !0),
i.registerInput("parallaxHeight", Op.Float, !0),
i.registerOutput("output", Op.Vector4),
i.registerOutput("uvOffset", Op.Vector2),
i
}
return U(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, "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 n = this.normalMapColor.connectedPoint._ownerBlock.samplerName
, r = this.viewDirection.isConnected && (this.useParallaxOcclusion && n || !this.useParallaxOcclusion && this.parallaxHeight.isConnected);
i.setValue("BUMP", !0),
i.setValue("PARALLAX", r, !0),
i.setValue("PARALLAXOCCLUSION", this.useParallaxOcclusion, !0)
}
,
t.prototype.bind = function(e, t) {
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)
}
,
t.prototype.autoConfigure = function(e) {
if (!this.uv.isConnected) {
var t = e.getInputBlockByPredicate((function(e) {
return e.isAttribute && "uv" === e.name
}
));
t || (t = new tf("uv")).setAsAttribute(),
t.output.connectTo(this.uv)
}
if (!this.strength.isConnected) {
var i = new tf("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)
, n = this.uv
, r = 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");
var s = this.normalMapColor.connectedPoint._ownerBlock.samplerName
, 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 ? "\r\n#if !defined(NORMALXYSCALE)\r\n1.0/\r\n#endif\r\n".concat(t._emitFloat(this.strength.connectInputBlock.value)) : "\r\n#if !defined(NORMALXYSCALE)\r\n1.0/\r\n#endif\r\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)"
};
a.isConnected && (t.compilationString += "vec3 tbnNormal = normalize(".concat(o.associatedVariableName, ".xyz);\r\n"),
t.compilationString += "vec3 tbnTangent = normalize(".concat(a.associatedVariableName, ".xyz);\r\n"),
t.compilationString += "vec3 tbnBitangent = cross(tbnNormal, tbnTangent);\r\n",
t.compilationString += "mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\r\n"),
t._emitFunctionFromInclude("bumpFragmentMainFunctions", i, {
replaceStrings: [h, {
search: /varying mat3 vTBN/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\r\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 d = l && s ? "texture2D(".concat(s, ", ").concat(n.associatedVariableName, " + uvOffset).xyz") : this.normalMapColor.associatedVariableName;
return t.compilationString += this._declareOutput(this.output, t) + " = vec4(0.);\r\n",
t.compilationString += t._emitCodeFromInclude("bumpFragment", i, {
replaceStrings: [{
search: /perturbNormal\(TBN,texture2D\(bumpSampler,vBumpUV\+uvOffset\).xyz,vBumpInfos.y\)/g,
replace: "perturbNormal(TBN, ".concat(d, ", 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: n.associatedVariableName
}, {
search: /vPositionW/g,
replace: r.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, ";\r\n");
return (t += "".concat(this._codeVariableName, ".invertY = ").concat(this.invertY, ";\r\n")) + "".concat(this._codeVariableName, ".useParallaxOcclusion = ").concat(this.useParallaxOcclusion, ";\r\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
}
,
t.prototype._deserialize = function(t, i, n) {
e.prototype._deserialize.call(this, t, i, n),
this.invertX = t.invertX,
this.invertY = t.invertY,
this.useParallaxOcclusion = !!t.useParallaxOcclusion
}
,
k([Yp("Invert X axis", Xp.Boolean, "PROPERTIES", {
notifiers: {
update: !1
}
})], t.prototype, "invertX", void 0),
k([Yp("Invert Y axis", Xp.Boolean, "PROPERTIES", {
notifiers: {
update: !1
}
})], t.prototype, "invertY", void 0),
k([Yp("Use parallax occlusion", Xp.Boolean)], t.prototype, "useParallaxOcclusion", void 0),
t
}(Wp);
y("BABYLON.PerturbNormalBlock", Cm);
var Pm = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Fragment, !0) || this;
return i.registerInput("value", Op.Float, !0),
i.registerInput("cutoff", Op.Float, !0),
i
}
return U(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;\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.DiscardBlock", Pm);
var Mm = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Fragment) || this;
return i.registerOutput("output", Op.Float, Dp.Fragment),
i
}
return U(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 === Dp.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;\r\n",
this
}
,
t
}(Wp);
y("BABYLON.FrontFacingBlock", Mm);
var Im = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Fragment) || this;
return i.registerInput("input", Op.AutoDetect, !1),
i.registerOutput("dx", Op.BasedOnInput),
i.registerOutput("dy", Op.BasedOnInput),
i._outputs[0]._typeConnectionSource = i._inputs[0],
i._outputs[1]._typeConnectionSource = i._inputs[0],
i
}
return U(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]
, n = 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, ");\r\n")),
n.hasEndpoints && (t.compilationString += this._declareOutput(n, t) + " = dFdy(".concat(this.input.associatedVariableName, ");\r\n")),
this
}
,
t
}(Wp);
y("BABYLON.DerivativeBlock", Im);
var Om = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Fragment) || this;
return i.registerOutput("xy", Op.Vector2, Dp.Fragment),
i.registerOutput("xyz", Op.Vector3, Dp.Fragment),
i.registerOutput("xyzw", Op.Vector4, Dp.Fragment),
i.registerOutput("x", Op.Float, Dp.Fragment),
i.registerOutput("y", Op.Float, Dp.Fragment),
i.registerOutput("z", Op.Float, Dp.Fragment),
i.registerOutput("w", Op.Float, Dp.Fragment),
i
}
return U(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, n = this._outputs; i < n.length; i++) {
var r = n[i];
r.hasEndpoints && (t += "".concat(this._declareOutput(r, e), " = gl_FragCoord.").concat(r.name, ";\r\n"))
}
return t
}
,
t.prototype._buildBlock = function(t) {
if (e.prototype._buildBlock.call(this, t),
t.target === Dp.Vertex)
throw "FragCoordBlock must only be used in a fragment shader";
return t.compilationString += this.writeOutputs(t),
this
}
,
t
}(Wp);
y("BABYLON.FragCoordBlock", Om);
var Dm = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Fragment) || this;
return i.registerOutput("xy", Op.Vector2, Dp.Fragment),
i.registerOutput("x", Op.Float, Dp.Fragment),
i.registerOutput("y", Op.Float, Dp.Fragment),
i
}
return U(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 = "", n = 0, r = this._outputs; n < r.length; n++) {
var o = r[n];
o.hasEndpoints && (i += "".concat(this._declareOutput(o, e), " = ").concat(t, ".").concat(o.name, ";\r\n"))
}
return i
}
,
t.prototype._buildBlock = function(t) {
if (e.prototype._buildBlock.call(this, t),
this._scene = t.sharedData.scene,
t.target === Dp.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
}(Wp);
y("BABYLON.ScreenSizeBlock", Dm);
var Nm = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Fragment) || this;
return i.registerInput("vector", Op.Vector3),
i.registerInput("worldViewProjection", Op.Matrix),
i.registerOutput("output", Op.Vector2),
i.registerOutput("x", Op.Float),
i.registerOutput("y", Op.Float),
i.inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
i
}
return U(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 === Qp.WorldViewProjection
}
));
t || (t = new tf("worldViewProjection")).setAsSystemValue(Qp.WorldViewProjection),
t.output.connectTo(this.worldViewProjection)
}
}
,
t.prototype._buildBlock = function(t) {
e.prototype._buildBlock.call(this, t);
var i = this.vector
, n = this.worldViewProjection;
if (i.connectedPoint) {
var r = n.associatedVariableName
, o = t._getFreeVariableName("screenSpaceTemp");
switch (i.connectedPoint.type) {
case Op.Vector3:
t.compilationString += "vec4 ".concat(o, " = ").concat(r, " * vec4(").concat(i.associatedVariableName, ", 1.0);\r\n");
break;
case Op.Vector4:
t.compilationString += "vec4 ".concat(o, " = ").concat(r, " * ").concat(i.associatedVariableName, ";\r\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;\r\n")),
this.x.hasEndpoints && (t.compilationString += this._declareOutput(this.x, t) + " = ".concat(o, ".x;\r\n")),
this.y.hasEndpoints && (t.compilationString += this._declareOutput(this.y, t) + " = ".concat(o, ".y;\r\n")),
this
}
}
,
t
}(Wp);
y("BABYLON.ScreenSpaceBlock", Nm);
var Lm = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Fragment) || this;
return i.registerInput("input", Op.Vector2),
i.registerInput("strength", Op.Float),
i.registerInput("center", Op.Vector2),
i.registerInput("offset", Op.Vector2),
i.registerOutput("output", Op.Vector2),
i.registerOutput("x", Op.Float),
i.registerOutput("y", Op.Float),
i
}
return U(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 tf("center");
e.value = new A(.5,.5),
e.output.connectTo(this.center)
}
if (!this.strength.isConnected) {
var t = new tf("strength");
t.value = 1,
t.output.connectTo(this.strength)
}
if (!this.offset.isConnected) {
var i = new tf("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")
, n = t._getFreeVariableName("angle")
, r = 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(n, " = ").concat(this.strength.associatedVariableName, " * length(").concat(i, ");\n float ").concat(r, " = cos(").concat(n, ") * ").concat(i, ".x - sin(").concat(n, ") * ").concat(i, ".y;\n float ").concat(o, " = sin(").concat(n, ") * ").concat(i, ".x + cos(").concat(n, ") * ").concat(i, ".y;\n vec2 ").concat(a, " = vec2(").concat(r, " + ").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, ";\r\n")),
this.x.hasEndpoints && (t.compilationString += this._declareOutput(this.x, t) + " = ".concat(a, ".x;\r\n")),
this.y.hasEndpoints && (t.compilationString += this._declareOutput(this.y, t) + " = ".concat(a, ".y;\r\n")),
this
}
,
t
}(Wp);
y("BABYLON.TwirlBlock", Lm);
var Fm = function(e) {
function t(t) {
var i = e.call(this, t, Dp.VertexAndFragment, !1) || this;
return i.registerInput("worldPosition", Op.Vector4, !1, Dp.Vertex),
i.registerInput("view", Op.Matrix, !1, Dp.Vertex),
i.registerInput("input", Op.Color3, !1, Dp.Fragment),
i.registerInput("fogColor", Op.Color3, !1, Dp.Fragment),
i.registerOutput("output", Op.Color3, Dp.Fragment),
i.input.acceptedConnectionPointTypes.push(Op.Color4),
i.fogColor.acceptedConnectionPointTypes.push(Op.Color4),
i
}
return U(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 === Qp.View
}
));
t || (t = new tf("view")).setAsSystemValue(Qp.View),
t.output.connectTo(this.view)
}
if (!this.fogColor.isConnected) {
var i = e.getInputBlockByPredicate((function(e) {
return e.systemValue === Qp.FogColor
}
));
i || (i = new tf("fogColor",void 0,Op.Color3)).setAsSystemValue(Qp.FogColor),
i.output.connectTo(this.fogColor)
}
}
,
t.prototype.prepareDefines = function(e, t, i) {
var n = e.getScene();
i.setValue("FOG", t.fogEnabled && Mr.GetFogState(e, n))
}
,
t.prototype.bind = function(e, t, i) {
if (i) {
var n = i.getScene();
e.setFloat4(this._fogParameters, n.fogMode, n.fogStart, n.fogEnd, n.fogDensity)
}
}
,
t.prototype._buildBlock = function(t) {
if (e.prototype._buildBlock.call(this, t),
t.target === Dp.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")
, n = this.input
, r = this.fogColor;
this._fogParameters = t._getFreeVariableName("fogParameters");
var o = this._outputs[0];
t._emitUniformFromString(this._fogParameters, "vec4"),
t.compilationString += "#ifdef FOG\r\n",
t.compilationString += "float ".concat(i, " = CalcFogFactor(").concat(this._fogDistanceName, ", ").concat(this._fogParameters, ");\r\n"),
t.compilationString += this._declareOutput(o, t) + " = ".concat(i, " * ").concat(n.associatedVariableName, ".rgb + (1.0 - ").concat(i, ") * ").concat(r.associatedVariableName, ".rgb;\r\n"),
t.compilationString += "#else\r\n".concat(this._declareOutput(o, t), " = ").concat(n.associatedVariableName, ".rgb;\r\n"),
t.compilationString += "#endif\r\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;\r\n")
}
return this
}
,
t
}(Wp);
y("BABYLON.FogBlock", Fm);
var wm = function(e) {
function t(t) {
var i = e.call(this, t, Dp.VertexAndFragment) || this;
return i._isUnique = !0,
i.registerInput("worldPosition", Op.Vector4, !1, Dp.Vertex),
i.registerInput("worldNormal", Op.Vector4, !1, Dp.Fragment),
i.registerInput("cameraPosition", Op.Vector3, !1, Dp.Fragment),
i.registerInput("glossiness", Op.Float, !0, Dp.Fragment),
i.registerInput("glossPower", Op.Float, !0, Dp.Fragment),
i.registerInput("diffuseColor", Op.Color3, !0, Dp.Fragment),
i.registerInput("specularColor", Op.Color3, !0, Dp.Fragment),
i.registerInput("view", Op.Matrix, !0),
i.registerOutput("diffuseOutput", Op.Color3, Dp.Fragment),
i.registerOutput("specularOutput", Op.Color3, Dp.Fragment),
i.registerOutput("shadow", Op.Float, Dp.Fragment),
i
}
return U(t, e),
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 === Qp.CameraPosition
}
));
t || (t = new tf("cameraPosition")).setAsSystemValue(Qp.CameraPosition),
t.output.connectTo(this.cameraPosition)
}
}
,
t.prototype.prepareDefines = function(e, t, i) {
if (i._areLightsDirty) {
var n = e.getScene();
if (this.light) {
var r = {
needNormals: !1,
needRebuild: !1,
lightmapMode: !1,
shadowEnabled: !1,
specularEnabled: !1
};
Mr.PrepareDefinesForLight(n, e, this.light, this._lightId, i, !0, r),
r.needRebuild && i.rebuild()
} else
Mr.PrepareDefinesForLights(n, e, i, !0, t.maxSimultaneousLights)
}
}
,
t.prototype.updateUniformsAndSamples = function(e, t, i, n) {
for (var r = 0; r < t.maxSimultaneousLights && i["LIGHT" + r]; r++) {
var o = e.uniforms.indexOf("vLightData" + r) >= 0;
Mr.PrepareUniformsAndSamplersForLight(r, e.uniforms, e.samplers, i["PROJECTEDLIGHTTEXTURE" + r], n, o)
}
}
,
t.prototype.bind = function(e, t, i) {
if (i) {
var n = i.getScene();
this.light ? Mr.BindLight(this.light, this._lightId, n, e, !0) : Mr.BindLights(n, 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 n = "v_" + t.associatedVariableName;
e._emitVaryingFromString(n, "vec4") && (e.compilationString += "".concat(n, " = ").concat(t.associatedVariableName, ";\r\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, ";\r\n"),
this.view.isConnected && (e.compilationString += "mat4 view = ".concat(this.view.associatedVariableName, ";\r\n")),
e.compilationString += e._emitCodeFromInclude("shadowsVertex", i, {
repeatKey: "maxSimultaneousLights"
}))
}
,
t.prototype._buildBlock = function(t) {
if (e.prototype._buildBlock.call(this, t),
t.target === Dp.Fragment) {
t.sharedData.forcedBindableBlocks.push(this),
t.sharedData.blocksWithDefines.push(this);
var i = "//".concat(this.name)
, n = this.worldPosition;
t._emitFunctionFromInclude("helperFunctions", i),
t._emitFunctionFromInclude("lightsFragmentFunctions", i, {
replaceStrings: [{
search: /vPositionW/g,
replace: "v_" + n.associatedVariableName + ".xyz"
}]
}),
t._emitFunctionFromInclude("shadowsFragmentFunctions", i, {
replaceStrings: [{
search: /vPositionW/g,
replace: "v_" + n.associatedVariableName + ".xyz"
}]
}),
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"
}),
0 === this._lightId && (t._registerTempVariable("viewDirectionW") && (t.compilationString += "vec3 viewDirectionW = normalize(".concat(this.cameraPosition.associatedVariableName, " - ").concat("v_" + n.associatedVariableName, ".xyz);\r\n")),
t.compilationString += "lightingInfo info;\r\n",
t.compilationString += "float shadow = 1.;\r\n",
t.compilationString += "float glossiness = ".concat(this.glossiness.isConnected ? this.glossiness.associatedVariableName : "1.0", " * ").concat(this.glossPower.isConnected ? this.glossPower.associatedVariableName : "1024.0", ";\r\n"),
t.compilationString += "vec3 diffuseBase = vec3(0., 0., 0.);\r\n",
t.compilationString += "vec3 specularBase = vec3(0., 0., 0.);\r\n",
t.compilationString += "vec3 normalW = ".concat(this.worldNormal.associatedVariableName, ".xyz;\r\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 r = this.diffuseOutput
, o = this.specularOutput;
return t.compilationString += this._declareOutput(r, t) + " = diffuseBase".concat(this.diffuseColor.isConnected ? " * " + this.diffuseColor.associatedVariableName : "", ";\r\n"),
o.hasEndpoints && (t.compilationString += this._declareOutput(o, t) + " = specularBase".concat(this.specularColor.isConnected ? " * " + this.specularColor.associatedVariableName : "", ";\r\n")),
this.shadow.hasEndpoints && (t.compilationString += this._declareOutput(this.shadow, t) + " = shadow;\r\n"),
this
}
this._injectVertexCode(t)
}
,
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, n) {
e.prototype._deserialize.call(this, t, i, n),
t.lightId && (this.light = i.getLightById(t.lightId))
}
,
t
}(Wp);
y("BABYLON.LightBlock", wm);
var Bm = function(e) {
function t(t, i, n, r, o, a) {
var s = e.call(this, t, i, n) || this;
return s._blockType = r,
s._blockName = o,
s._nameForCheking = a,
s._nameForCheking || (s._nameForCheking = t),
s.needDualDirectionValidation = !0,
s
}
return U(t, e),
t.prototype.checkCompatibilityState = function(e) {
return e instanceof t && e.name === this._nameForCheking ? Up.Compatible : Up.TypeIncompatible
}
,
t.prototype.createCustomInputBlock = function() {
return [new this._blockType(this._blockName), this.name]
}
,
t
}(zp)
, Um = function(e) {
function t(i) {
var n = e.call(this, i, Dp.VertexAndFragment) || this;
return n.registerOutput("source", Op.Object, Dp.VertexAndFragment, new Bm("source",n,Vp.Output,t,"ImageSourceBlock")),
n
}
return U(t, e),
Object.defineProperty(t.prototype, "texture", {
get: function() {
return this._texture
},
set: function(e) {
var t, i = this;
if (this._texture !== e) {
var n = null !== (t = null == e ? void 0 : e.getScene()) && void 0 !== t ? t : E.LastCreatedScene;
!e && n && n.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
return e.hasTexture(i._texture)
}
)),
this._texture = e,
e && n && n.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 === Dp.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, ");\r\n"),
t += "".concat(this._codeVariableName, ".texture.wrapU = ").concat(this.texture.wrapU, ";\r\n"),
t += "".concat(this._codeVariableName, ".texture.wrapV = ").concat(this.texture.wrapV, ";\r\n"),
t += "".concat(this._codeVariableName, ".texture.uAng = ").concat(this.texture.uAng, ";\r\n"),
t += "".concat(this._codeVariableName, ".texture.vAng = ").concat(this.texture.vAng, ";\r\n"),
t += "".concat(this._codeVariableName, ".texture.wAng = ").concat(this.texture.wAng, ";\r\n"),
t += "".concat(this._codeVariableName, ".texture.uOffset = ").concat(this.texture.uOffset, ";\r\n"),
t += "".concat(this._codeVariableName, ".texture.vOffset = ").concat(this.texture.vOffset, ";\r\n"),
t += "".concat(this._codeVariableName, ".texture.uScale = ").concat(this.texture.uScale, ";\r\n"),
t += "".concat(this._codeVariableName, ".texture.vScale = ").concat(this.texture.vScale, ";\r\n"),
t += "".concat(this._codeVariableName, ".texture.coordinatesMode = ").concat(this.texture.coordinatesMode, ";\r\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, n) {
e.prototype._deserialize.call(this, t, i, n),
t.texture && !Of.IgnoreTexturesAtLoadTime && void 0 !== t.texture.url && (n = 0 === t.texture.url.indexOf("data:") ? "" : n,
this.texture = io.Parse(t.texture, i, n))
}
,
t
}(Wp);
y("BABYLON.ImageSourceBlock", Um);
var Vm = function(e) {
function t(t, i) {
void 0 === i && (i = !1);
var n = e.call(this, t, i ? Dp.Fragment : Dp.VertexAndFragment) || this;
return n._convertToGammaSpace = !1,
n._convertToLinearSpace = !1,
n.disableLevelMultiplication = !1,
n._fragmentOnly = i,
n.registerInput("uv", Op.Vector2, !1, Dp.VertexAndFragment),
n.registerInput("source", Op.Object, !0, Dp.VertexAndFragment, new Bm("source",n,Vp.Input,Um,"ImageSourceBlock")),
n.registerOutput("rgba", Op.Color4, Dp.Neutral),
n.registerOutput("rgb", Op.Color3, Dp.Neutral),
n.registerOutput("r", Op.Float, Dp.Neutral),
n.registerOutput("g", Op.Float, Dp.Neutral),
n.registerOutput("b", Op.Float, Dp.Neutral),
n.registerOutput("a", Op.Float, Dp.Neutral),
n.registerOutput("level", Op.Float, Dp.Neutral),
n._inputs[0].acceptedConnectionPointTypes.push(Op.Vector3),
n._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
n._inputs[0]._prioritizeVertex = !i,
n
}
return U(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 n = null !== (t = null == e ? void 0 : e.getScene()) && void 0 !== t ? t : E.LastCreatedScene;
!e && n && n.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
return e.hasTexture(i._texture)
}
)),
this._texture = e,
e && n && n.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._imageSource
},
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 n = null !== (t = this.texture.getScene()) && void 0 !== t ? t : E.LastCreatedScene;
null == n || n.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 n = null !== (t = this.texture.getScene()) && void 0 !== t ? t : E.LastCreatedScene;
null == n || n.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, "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 Dp.Fragment;
if (!this.uv.isConnected)
return Dp.VertexAndFragment;
if (this.uv.sourceBlock.isInput)
return Dp.VertexAndFragment;
for (var e = this.uv.connectedPoint; e; ) {
if (e.target === Dp.Fragment)
return Dp.Fragment;
if (e.target === Dp.Vertex)
return Dp.VertexAndFragment;
if (e.target === Dp.Neutral || e.target === Dp.VertexAndFragment) {
var t = e.ownerBlock;
if (t.target === Dp.Fragment)
return Dp.Fragment;
e = null;
for (var i = 0, n = t.inputs; i < n.length; i++) {
var r = n[i];
if (r.connectedPoint) {
e = r.connectedPoint;
break
}
}
}
}
return Dp.VertexAndFragment
},
set: function(e) {},
enumerable: !1,
configurable: !0
}),
t.prototype.autoConfigure = function(e) {
if (!this.uv.isConnected)
if (e.mode === cf.PostProcess)
(t = e.getBlockByPredicate((function(e) {
return "uv" === e.name
}
))) && t.connectTo(this);
else {
var t, i = e.mode === cf.Particle ? "particle_uv" : "uv";
(t = e.getInputBlockByPredicate((function(e) {
return e.isAttribute && e.name === i
}
))) || (t = new tf("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 n = this.convertToGammaSpace && this.texture && !this.texture.gammaSpace
, r = this.convertToLinearSpace && this.texture && this.texture.gammaSpace;
i.setValue(this._linearDefineName, n, !0),
i.setValue(this._gammaDefineName, r, !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 !== Dp.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, "\r\n"),
e.compilationString += "".concat(this._transformedUVName, " = vec2(").concat(this._textureTransformName, " * vec4(").concat(t.associatedVariableName, ".xy, 1.0, 0.0));\r\n"),
e.compilationString += "#elif defined(".concat(this._mainUVDefineName, ")\r\n"),
e.compilationString += "".concat(this._mainUVName, " = ").concat(t.associatedVariableName, ".xy;\r\n"),
e.compilationString += "#endif\r\n",
this._outputs.some((function(e) {
return e.isConnectedInVertexShader
}
))) {
this._writeTextureRead(e, !0);
for (var i = 0, n = this._outputs; i < n.length; i++) {
var r = n[i];
r.hasEndpoints && "level" !== r.name && this._writeOutput(e, r, r.name, !0)
}
}
}
,
t.prototype._generateTextureLookup = function(e) {
var t = this.samplerName;
e.compilationString += "#ifdef ".concat(this._defineName, "\r\n"),
e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(t, ", ").concat(this._transformedUVName, ");\r\n"),
e.compilationString += "#elif defined(".concat(this._mainUVDefineName, ")\r\n"),
e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(t, ", ").concat(this._mainUVName ? this._mainUVName : this.uv.associatedVariableName, ");\r\n"),
e.compilationString += "#endif\r\n"
}
,
t.prototype._writeTextureRead = function(e, t) {
void 0 === t && (t = !1);
var i = this.uv;
if (t) {
if (e.target === Dp.Fragment)
return;
this._generateTextureLookup(e)
} else
this.uv.ownerBlock.target !== Dp.Fragment ? this._generateTextureLookup(e) : e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this.samplerName, ", ").concat(i.associatedVariableName, ");\r\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, n) {
if (void 0 === n && (n = !1),
n) {
if (e.target === Dp.Fragment)
return;
return e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\r\n"),
void this._generateConversionCode(e, t, i)
}
if (this.uv.ownerBlock.target === Dp.Fragment)
return e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\r\n"),
void this._generateConversionCode(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, ";\r\n"),
this._generateConversionCode(e, t, i)
}
,
t.prototype._buildBlock = function(t) {
if (e.prototype._buildBlock.call(this, t),
this.source.isConnected ? this._imageSource = this.source.connectedPoint.ownerBlock : this._imageSource = null,
(t.target === Dp.Vertex || this._fragmentOnly || t.target === Dp.Fragment && void 0 === this._tempTextureRead) && (this._tempTextureRead = t._getFreeVariableName("tempTextureRead"),
this._linearDefineName = t._getFreeDefineName("ISLINEAR"),
this._gammaDefineName = t._getFreeDefineName("ISGAMMA")),
(!this._isMixed && t.target === Dp.Fragment || this._isMixed && t.target === Dp.Vertex) && (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)),
t.target === Dp.Fragment) {
if (this._outputs.some((function(e) {
return e.isConnectedInFragmentShader
}
))) {
this._isMixed && !this._imageSource && t._emit2DSampler(this._samplerName);
var i = "//".concat(this.name);
t._emitFunctionFromInclude("helperFunctions", i),
this._isMixed && t._emitUniformFromString(this._textureInfoName, "float"),
this._writeTextureRead(t);
for (var n = 0, r = this._outputs; n < r.length; n++) {
var o = r[n];
o.hasEndpoints && "level" !== o.name && this._writeOutput(t, o, o.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, ";\r\n"),
t += "".concat(this._codeVariableName, ".convertToLinearSpace = ").concat(this.convertToLinearSpace, ";\r\n"),
t += "".concat(this._codeVariableName, ".disableLevelMultiplication = ").concat(this.disableLevelMultiplication, ";\r\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, ");\r\n"),
t += "".concat(this._codeVariableName, ".texture.wrapU = ").concat(this.texture.wrapU, ";\r\n"),
t += "".concat(this._codeVariableName, ".texture.wrapV = ").concat(this.texture.wrapV, ";\r\n"),
t += "".concat(this._codeVariableName, ".texture.uAng = ").concat(this.texture.uAng, ";\r\n"),
t += "".concat(this._codeVariableName, ".texture.vAng = ").concat(this.texture.vAng, ";\r\n"),
t += "".concat(this._codeVariableName, ".texture.wAng = ").concat(this.texture.wAng, ";\r\n"),
t += "".concat(this._codeVariableName, ".texture.uOffset = ").concat(this.texture.uOffset, ";\r\n"),
t += "".concat(this._codeVariableName, ".texture.vOffset = ").concat(this.texture.vOffset, ";\r\n"),
t += "".concat(this._codeVariableName, ".texture.uScale = ").concat(this.texture.uScale, ";\r\n"),
t += "".concat(this._codeVariableName, ".texture.vScale = ").concat(this.texture.vScale, ";\r\n"),
t += "".concat(this._codeVariableName, ".texture.coordinatesMode = ").concat(this.texture.coordinatesMode, ";\r\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, n) {
e.prototype._deserialize.call(this, t, i, n),
this.convertToGammaSpace = t.convertToGammaSpace,
this.convertToLinearSpace = !!t.convertToLinearSpace,
this._fragmentOnly = !!t.fragmentOnly,
this.disableLevelMultiplication = !!t.disableLevelMultiplication,
t.texture && !Of.IgnoreTexturesAtLoadTime && void 0 !== t.texture.url && (n = 0 === t.texture.url.indexOf("data:") ? "" : n,
this.texture = io.Parse(t.texture, i, n))
}
,
t
}(Wp);
y("BABYLON.TextureBlock", Vm);
var km = function(e) {
function t(t) {
return e.call(this, t, Dp.VertexAndFragment) || this
}
return U(t, e),
Object.defineProperty(t.prototype, "texture", {
get: function() {
return this._texture
},
set: function(e) {
var t, i = this;
if (this._texture !== e) {
var n = null !== (t = null == e ? void 0 : e.getScene()) && void 0 !== t ? t : E.LastCreatedScene;
!e && n && n.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
return e.hasTexture(i._texture)
}
)),
this._texture = e,
e && n && n.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(t) {
return t.hasTexture(e)
}
))
}
},
enumerable: !1,
configurable: !0
}),
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 tf("position")).setAsAttribute(),
t.output.connectTo(this.position)
}
if (!this.world.isConnected) {
var i = e.getInputBlockByPredicate((function(e) {
return e.systemValue === Qp.World
}
));
i || (i = new tf("world")).setAsSystemValue(Qp.World),
i.output.connectTo(this.world)
}
if (this.view && !this.view.isConnected) {
var n = e.getInputBlockByPredicate((function(e) {
return e.systemValue === Qp.View
}
));
n || (n = new tf("view")).setAsSystemValue(Qp.View),
n.output.connectTo(this.view)
}
}
,
t.prototype.prepareDefines = function(e, t, i) {
if (i._areTexturesDirty) {
var n = this._getTexture();
n && n.getTextureMatrix && (i.setValue(this._define3DName, n.isCube, !0),
i.setValue(this._defineLocalCubicName, !!n.boundingBoxSize, !0),
i.setValue(this._defineExplicitName, n.coordinatesMode === a.TEXTURE_EXPLICIT_MODE, !0),
i.setValue(this._defineSkyboxName, n.coordinatesMode === a.TEXTURE_SKYBOX_MODE, !0),
i.setValue(this._defineCubicName, n.coordinatesMode === a.TEXTURE_CUBIC_MODE || n.coordinatesMode === a.TEXTURE_INVCUBIC_MODE, !0),
i.setValue("INVERTCUBICMAP", n.coordinatesMode === a.TEXTURE_INVCUBIC_MODE, !0),
i.setValue(this._defineSphericalName, n.coordinatesMode === a.TEXTURE_SPHERICAL_MODE, !0),
i.setValue(this._definePlanarName, n.coordinatesMode === a.TEXTURE_PLANAR_MODE, !0),
i.setValue(this._defineProjectionName, n.coordinatesMode === a.TEXTURE_PROJECTION_MODE, !0),
i.setValue(this._defineEquirectangularName, n.coordinatesMode === a.TEXTURE_EQUIRECTANGULAR_MODE, !0),
i.setValue(this._defineEquirectangularFixedName, n.coordinatesMode === a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE, !0),
i.setValue(this._defineMirroredEquirectangularFixedName, n.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 n = this._getTexture();
if (i && n && (e.setMatrix(this._reflectionMatrixName, n.getReflectionTextureMatrix()),
n.isCube ? e.setTexture(this._cubeSamplerName, n) : e.setTexture(this._2DSamplerName, n),
n.boundingBoxSize)) {
var r = n;
e.setVector3(this._reflectionPositionName, r.boundingBoxPosition),
e.setVector3(this._reflectionSizeName, r.boundingBoxSize)
}
}
,
t.prototype.handleVertexSide = function(e) {
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 = ""
, i = "v_" + this.worldPosition.associatedVariableName;
return e._emitVaryingFromString(i, "vec4") && (t += "".concat(i, " = ").concat(this.worldPosition.associatedVariableName, ";\r\n")),
this._positionUVWName = e._getFreeVariableName("positionUVW"),
this._directionWName = e._getFreeVariableName("directionW"),
e._emitVaryingFromString(this._positionUVWName, "vec3", this._defineSkyboxName) && (t += "#ifdef ".concat(this._defineSkyboxName, "\r\n"),
t += "".concat(this._positionUVWName, " = ").concat(this.position.associatedVariableName, ".xyz;\r\n"),
t += "#endif\r\n"),
e._emitVaryingFromString(this._directionWName, "vec3", "defined(".concat(this._defineEquirectangularFixedName, ") || defined(").concat(this._defineMirroredEquirectangularFixedName, ")")) && (t += "#if defined(".concat(this._defineEquirectangularFixedName, ") || defined(").concat(this._defineMirroredEquirectangularFixedName, ")\r\n"),
t += "".concat(this._directionWName, " = normalize(vec3(").concat(this.world.associatedVariableName, " * vec4(").concat(this.position.associatedVariableName, ".xyz, 0.0)));\r\n"),
t += "#endif\r\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, "\r\n"),
e._samplerDeclaration += "uniform samplerCube ".concat(this._cubeSamplerName, ";\r\n"),
e._samplerDeclaration += "#else\r\n",
e._samplerDeclaration += "uniform sampler2D ".concat(this._2DSamplerName, ";\r\n"),
e._samplerDeclaration += "#endif\r\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) {
void 0 === i && (i = !1),
t || (t = "v_".concat(this.worldPosition.associatedVariableName));
var n = this._reflectionMatrixName
, r = "normalize(".concat(this._directionWName, ")")
, o = "".concat(this._positionUVWName)
, a = "".concat(this.cameraPosition.associatedVariableName)
, s = "".concat(this.view.associatedVariableName);
e += ".xyz";
var l = "\n #ifdef ".concat(this._defineMirroredEquirectangularFixedName, "\n vec3 ").concat(this._reflectionVectorName, " = computeMirroredFixedEquirectangularCoords(").concat(t, ", ").concat(e, ", ").concat(r, ");\n #endif\n\n #ifdef ").concat(this._defineEquirectangularFixedName, "\n vec3 ").concat(this._reflectionVectorName, " = computeFixedEquirectangularCoords(").concat(t, ", ").concat(e, ", ").concat(r, ");\n #endif\n\n #ifdef ").concat(this._defineEquirectangularName, "\n vec3 ").concat(this._reflectionVectorName, " = computeEquirectangularCoords(").concat(t, ", ").concat(e, ", ").concat(a, ".xyz, ").concat(n, ");\n #endif\n\n #ifdef ").concat(this._defineSphericalName, "\n vec3 ").concat(this._reflectionVectorName, " = computeSphericalCoords(").concat(t, ", ").concat(e, ", ").concat(s, ", ").concat(n, ");\n #endif\n\n #ifdef ").concat(this._definePlanarName, "\n vec3 ").concat(this._reflectionVectorName, " = computePlanarCoords(").concat(t, ", ").concat(e, ", ").concat(a, ".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(a, ".xyz, ").concat(n, ", ").concat(this._reflectionSizeName, ", ").concat(this._reflectionPositionName, ");\n #else\n vec3 ").concat(this._reflectionVectorName, " = computeCubicCoords(").concat(t, ", ").concat(e, ", ").concat(a, ".xyz, ").concat(n, ");\n #endif\n #endif\n\n #ifdef ").concat(this._defineProjectionName, "\n vec3 ").concat(this._reflectionVectorName, " = computeProjectionCoords(").concat(t, ", ").concat(s, ", ").concat(n, ");\n #endif\n\n #ifdef ").concat(this._defineSkyboxName, "\n vec3 ").concat(this._reflectionVectorName, " = computeSkyBoxCoords(").concat(o, ", ").concat(n, ");\n #endif\n\n #ifdef ").concat(this._defineExplicitName, "\n vec3 ").concat(this._reflectionVectorName, " = vec3(0, 0, 0);\n #endif\n\n #ifdef ").concat(this._defineOppositeZ, "\n ").concat(this._reflectionVectorName, ".z *= -1.0;\n #endif\r\n");
return i || (l += "\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\r\n")),
l
}
,
t.prototype.handleFragmentSideCodeReflectionColor = function(e, t) {
void 0 === t && (t = ".rgb");
var i = "vec" + (0 === t.length ? "4" : t.length - 1)
, n = "".concat(i, " ").concat(this._reflectionColorName, ";\n #ifdef ").concat(this._define3DName, "\r\n");
return n += e ? "".concat(this._reflectionColorName, " = textureCubeLodEXT(").concat(this._cubeSamplerName, ", ").concat(this._reflectionVectorName, ", ").concat(e, ")").concat(t, ";\r\n") : "".concat(this._reflectionColorName, " = textureCube(").concat(this._cubeSamplerName, ", ").concat(this._reflectionVectorName, ")").concat(t, ";\r\n"),
n += "\n #else\r\n",
(n += e ? "".concat(this._reflectionColorName, " = texture2DLodEXT(").concat(this._2DSamplerName, ", ").concat(this._reflectionCoordsName, ", ").concat(e, ")").concat(t, ";\r\n") : "".concat(this._reflectionColorName, " = texture2D(").concat(this._2DSamplerName, ", ").concat(this._reflectionCoordsName, ")").concat(t, ";\r\n")) + "#endif\r\n"
}
,
t.prototype.writeOutputs = function(e, t) {
var i = "";
if (e.target === Dp.Fragment)
for (var n = 0, r = this._outputs; n < r.length; n++) {
var o = r[n];
o.hasEndpoints && (i += "".concat(this._declareOutput(o, e), " = ").concat(t, ".").concat(o.name, ";\r\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", ");\r\n")
} else
t += "".concat(this._codeVariableName, '.texture = new BABYLON.Texture("').concat(this.texture.name, '", null);\r\n');
return t + "".concat(this._codeVariableName, ".texture.coordinatesMode = ").concat(this.texture.coordinatesMode, ";\r\n")
}
,
t.prototype.serialize = function() {
var t = e.prototype.serialize.call(this);
return this.texture && !this.texture.isRenderTarget && (t.texture = this.texture.serialize()),
t
}
,
t.prototype._deserialize = function(t, i, n) {
e.prototype._deserialize.call(this, t, i, n),
t.texture && (n = 0 === t.texture.url.indexOf("data:") ? "" : n,
t.texture.isCube ? this.texture = Bd.Parse(t.texture, i, n) : this.texture = io.Parse(t.texture, i, n))
}
,
t
}(Wp);
y("BABYLON.ReflectionTextureBaseBlock", km);
var Gm = function(e) {
function t(t) {
var i = e.call(this, t) || this;
return i.registerInput("position", Op.Vector3, !1, Dp.Vertex),
i.registerInput("worldPosition", Op.Vector4, !1, Dp.Vertex),
i.registerInput("worldNormal", Op.Vector4, !1, Dp.Fragment),
i.registerInput("world", Op.Matrix, !1, Dp.Vertex),
i.registerInput("cameraPosition", Op.Vector3, !1, Dp.Fragment),
i.registerInput("view", Op.Matrix, !1, Dp.Fragment),
i.registerOutput("rgb", Op.Color3, Dp.Fragment),
i.registerOutput("rgba", Op.Color4, Dp.Fragment),
i.registerOutput("r", Op.Float, Dp.Fragment),
i.registerOutput("g", Op.Float, Dp.Fragment),
i.registerOutput("b", Op.Float, Dp.Fragment),
i.registerOutput("a", Op.Float, Dp.Fragment),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
i
}
return U(t, e),
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 === Qp.CameraPosition
}
));
i || (i = new tf("cameraPosition")).setAsSystemValue(Qp.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, "vec3(0.)"),
this;
if (t.target !== Dp.Fragment)
return t.compilationString += this.handleVertexSide(t),
this;
this.handleFragmentSideInits(t);
var i = t._getFreeVariableName("normalWUnit");
return t.compilationString += "vec4 ".concat(i, " = normalize(").concat(this.worldNormal.associatedVariableName, ");\r\n"),
t.compilationString += this.handleFragmentSideCodeReflectionCoords(i),
t.compilationString += this.handleFragmentSideCodeReflectionColor(void 0, ""),
t.compilationString += this.writeOutputs(t, this._reflectionColorName),
this
}
,
t
}(km);
y("BABYLON.ReflectionTextureBlock", Gm);
var zm = function(e) {
function t(t) {
var i = e.call(this, t, Dp.VertexAndFragment) || this;
return i._samplerName = "textureSampler",
i.useNonLinearDepth = !1,
i.force32itsFloat = !1,
i._isUnique = !0,
i.registerInput("uv", Op.Vector2, !1, Dp.VertexAndFragment),
i.registerOutput("depth", Op.Float, Dp.Neutral),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector3),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
i._inputs[0]._prioritizeVertex = !1,
i
}
return U(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 ? Dp.VertexAndFragment : Dp.Fragment : Dp.VertexAndFragment
},
enumerable: !1,
configurable: !0
}),
t.prototype._getTexture = function(e) {
return e.enableDepthRenderer(void 0, this.useNonLinearDepth, this.force32itsFloat).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 === Op.Vector3 ? "3" : t.type === Op.Vector4 ? "4" : "2"))),
this._mainUVName = "vMain" + t.associatedVariableName,
e._emitVaryingFromString(this._mainUVName, "vec2"),
e.compilationString += "".concat(this._mainUVName, " = ").concat(t.associatedVariableName, ".xy;\r\n"),
this._outputs.some((function(e) {
return e.isConnectedInVertexShader
}
))) {
this._writeTextureRead(e, !0);
for (var i = 0, n = this._outputs; i < n.length; i++) {
var r = n[i];
r.hasEndpoints && this._writeOutput(e, r, "r", !0)
}
}
}
,
t.prototype._writeTextureRead = function(e, t) {
void 0 === t && (t = !1);
var i = this.uv;
if (t) {
if (e.target === Dp.Fragment)
return;
e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(i.associatedVariableName, ".xy);\r\n")
} else
this.uv.ownerBlock.target !== Dp.Fragment ? e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(this._mainUVName, ");\r\n") : e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(i.associatedVariableName, ".xy);\r\n")
}
,
t.prototype._writeOutput = function(e, t, i, n) {
if (void 0 === n && (n = !1),
n) {
if (e.target === Dp.Fragment)
return;
e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\r\n")
} else
this.uv.ownerBlock.target,
Dp.Fragment,
e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\r\n")
}
,
t.prototype._buildBlock = function(t) {
if (e.prototype._buildBlock.call(this, t),
this._tempTextureRead = t._getFreeVariableName("tempTextureRead"),
t.sharedData.bindableBlocks.indexOf(this) < 0 && t.sharedData.bindableBlocks.push(this),
t.target !== Dp.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, n = this._outputs; i < n.length; i++) {
var r = n[i];
r.hasEndpoints && this._writeOutput(t, r, "r")
}
return this
}
}
,
t.prototype.serialize = function() {
var t = e.prototype.serialize.call(this);
return t.useNonLinearDepth = this.useNonLinearDepth,
t.force32itsFloat = this.force32itsFloat,
t
}
,
t.prototype._deserialize = function(t, i, n) {
e.prototype._deserialize.call(this, t, i, n),
this.useNonLinearDepth = t.useNonLinearDepth,
this.force32itsFloat = t.force32itsFloat
}
,
k([Yp("Use non linear depth", Xp.Boolean, "ADVANCED", {
notifiers: {
activatePreviewCommand: !0,
callback: function(e) {
return e.disableDepthRenderer()
}
}
})], t.prototype, "useNonLinearDepth", void 0),
k([Yp("Force 32 bits float", Xp.Boolean, "ADVANCED", {
notifiers: {
activatePreviewCommand: !0,
callback: function(e) {
return e.disableDepthRenderer()
}
}
})], t.prototype, "force32itsFloat", void 0),
t
}(Wp);
y("BABYLON.SceneDepthBlock", zm);
var Wm = function(e) {
function t(t) {
var i = e.call(this, t, Dp.VertexAndFragment, !0) || this;
return i.registerInput("worldPosition", Op.Vector4, !1),
i
}
return U(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 Dp.VertexAndFragment
},
set: function(e) {},
enumerable: !1,
configurable: !0
}),
t.prototype.prepareDefines = function(e, t, i) {
var n = e.getScene()
, r = void 0 !== n.clipPlane && null !== n.clipPlane
, o = void 0 !== n.clipPlane2 && null !== n.clipPlane2
, a = void 0 !== n.clipPlane3 && null !== n.clipPlane3
, s = void 0 !== n.clipPlane4 && null !== n.clipPlane4
, l = void 0 !== n.clipPlane5 && null !== n.clipPlane5
, c = void 0 !== n.clipPlane6 && null !== n.clipPlane6;
i.setValue("CLIPPLANE", r, !0),
i.setValue("CLIPPLANE2", o, !0),
i.setValue("CLIPPLANE3", a, !0),
i.setValue("CLIPPLANE4", s, !0),
i.setValue("CLIPPLANE5", l, !0),
i.setValue("CLIPPLANE6", c, !0)
}
,
t.prototype.bind = function(e, t, i) {
if (i) {
var n = i.getScene();
Mr.BindClipPlane(e, n)
}
}
,
t.prototype._buildBlock = function(t) {
e.prototype._buildBlock.call(this, t);
var i = "//".concat(this.name);
if (t.target !== Dp.Fragment) {
var n = 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: n.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
}(Wp);
y("BABYLON.ClipPlanesBlock", Wm);
var Hm = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("left", Op.AutoDetect),
i.registerInput("right", Op.AutoDetect),
i.registerOutput("output", Op.BasedOnInput),
i._outputs[0]._typeConnectionSource = i._inputs[0],
i._linkConnectionTypes(0, 1),
i
}
return U(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, ";\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.AddBlock", Hm);
var Xm = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("input", Op.AutoDetect),
i.registerInput("factor", Op.Float),
i.registerOutput("output", Op.BasedOnInput),
i._outputs[0]._typeConnectionSource = i._inputs[0],
i
}
return U(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, ";\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.ScaleBlock", Xm);
var jm = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.minimum = 0,
i.maximum = 1,
i.registerInput("value", Op.AutoDetect),
i.registerOutput("output", Op.BasedOnInput),
i._outputs[0]._typeConnectionSource = i._inputs[0],
i
}
return U(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), ");\r\n"),
this
}
,
t.prototype._dumpPropertiesCode = function() {
return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".minimum = ").concat(this.minimum, ";\r\n") + "".concat(this._codeVariableName, ".maximum = ").concat(this.maximum, ";\r\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, n) {
e.prototype._deserialize.call(this, t, i, n),
this.minimum = t.minimum,
this.maximum = t.maximum
}
,
k([Yp("Minimum", Xp.Float)], t.prototype, "minimum", void 0),
k([Yp("Maximum", Xp.Float)], t.prototype, "maximum", void 0),
t
}(Wp);
y("BABYLON.ClampBlock", jm);
var Ym = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("left", Op.AutoDetect),
i.registerInput("right", Op.AutoDetect),
i.registerOutput("output", Op.Vector3),
i._linkConnectionTypes(0, 1),
i._inputs[0].excludedConnectionPointTypes.push(Op.Float),
i._inputs[0].excludedConnectionPointTypes.push(Op.Matrix),
i._inputs[0].excludedConnectionPointTypes.push(Op.Vector2),
i._inputs[1].excludedConnectionPointTypes.push(Op.Float),
i._inputs[1].excludedConnectionPointTypes.push(Op.Matrix),
i._inputs[1].excludedConnectionPointTypes.push(Op.Vector2),
i
}
return U(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);\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.CrossBlock", Ym);
var Km = function(e) {
function t(t) {
return e.call(this, t) || this
}
return U(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 n = this._code
, r = this._options.functionName;
this._inputs.forEach((function(e) {
var i = new RegExp("\\{TYPE_" + e.name + "\\}","gm")
, o = t._getGLType(e.type);
n = n.replace(i, o),
r = r.replace(i, o)
}
)),
this._outputs.forEach((function(e) {
var i = new RegExp("\\{TYPE_" + e.name + "\\}","gm")
, o = t._getGLType(e.type);
n = n.replace(i, o),
r = r.replace(i, o)
}
)),
t._emitFunction(r, n, ""),
this._outputs.forEach((function(e) {
t.compilationString += i._declareOutput(e, t) + ";\r\n"
}
)),
t.compilationString += r + "(";
var o = !1;
return this._inputs.forEach((function(e, i) {
i > 0 && (t.compilationString += ", "),
t.compilationString += e.associatedVariableName,
o = !0
}
)),
this._outputs.forEach((function(e, i) {
(i > 0 || o) && (t.compilationString += ", "),
t.compilationString += e.associatedVariableName
}
)),
t.compilationString += ");\r\n",
this
}
,
t.prototype._dumpPropertiesCode = function() {
return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".options = ").concat(JSON.stringify(this._options), ";\r\n")
}
,
t.prototype.serialize = function() {
var t = e.prototype.serialize.call(this);
return t.options = this._options,
t
}
,
t.prototype._deserialize = function(t, i, n) {
this._deserializeOptions(t.options),
e.prototype._deserialize.call(this, t, i, n)
}
,
t.prototype._deserializeOptions = function(e) {
var t, i, n, r = this;
this._options = e,
this._code = e.code.join("\r\n") + "\r\n",
this.name = this.name || e.name,
this.target = Dp[e.target],
null === (t = e.inParameters) || void 0 === t || t.forEach((function(e, t) {
var i = Op[e.type];
r.registerInput(e.name, i),
Object.defineProperty(r, e.name, {
get: function() {
return this._inputs[t]
},
enumerable: !0,
configurable: !0
})
}
)),
null === (i = e.outParameters) || void 0 === i || i.forEach((function(e, t) {
r.registerOutput(e.name, Op[e.type]),
Object.defineProperty(r, e.name, {
get: function() {
return this._outputs[t]
},
enumerable: !0,
configurable: !0
}),
"BasedOnInput" === e.type && (r._outputs[t]._typeConnectionSource = r._findInputByName(e.typeFromInput)[0])
}
)),
null === (n = e.inLinkedConnectionTypes) || void 0 === n || n.forEach((function(e) {
r._linkConnectionTypes(r._findInputByName(e.input1)[1], r._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
}(Wp);
y("BABYLON.CustomBlock", Km);
var Qm = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("left", Op.AutoDetect),
i.registerInput("right", Op.AutoDetect),
i.registerOutput("output", Op.Float),
i._linkConnectionTypes(0, 1),
i._inputs[0].excludedConnectionPointTypes.push(Op.Float),
i._inputs[0].excludedConnectionPointTypes.push(Op.Matrix),
i._inputs[1].excludedConnectionPointTypes.push(Op.Float),
i._inputs[1].excludedConnectionPointTypes.push(Op.Matrix),
i
}
return U(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, ");\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.DotBlock", Qm);
var qm = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("input", Op.AutoDetect),
i.registerOutput("output", Op.BasedOnInput),
i._outputs[0]._typeConnectionSource = i._inputs[0],
i._inputs[0].excludedConnectionPointTypes.push(Op.Float),
i._inputs[0].excludedConnectionPointTypes.push(Op.Matrix),
i
}
return U(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]
, n = this._inputs[0];
return t.compilationString += this._declareOutput(i, t) + " = normalize(".concat(n.associatedVariableName, ");\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.NormalizeBlock", qm);
var Zm = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.rSwizzle = "r",
i.gSwizzle = "g",
i.bSwizzle = "b",
i.aSwizzle = "a",
i.registerInput("rgb ", Op.Color3, !0),
i.registerInput("r", Op.Float, !0),
i.registerInput("g", Op.Float, !0),
i.registerInput("b", Op.Float, !0),
i.registerInput("a", Op.Float, !0),
i.registerOutput("rgba", Op.Color4),
i.registerOutput("rgb", Op.Color3),
i
}
return U(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
, n = this.g
, r = 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), ";\r\n")),
l.hasEndpoints && (t.compilationString += this._declareOutput(l, t) + " = ".concat(a.associatedVariableName).concat(this._buildSwizzle(3), ";\r\n"))) : (s.hasEndpoints && (t.compilationString += this._declareOutput(s, t) + " = vec4(".concat(i.isConnected ? this._writeVariable(i) : "0.0", ", ").concat(n.isConnected ? this._writeVariable(n) : "0.0", ", ").concat(r.isConnected ? this._writeVariable(r) : "0.0", ", ").concat(o.isConnected ? this._writeVariable(o) : "0.0", ")").concat(this._buildSwizzle(4), ";\r\n")),
l.hasEndpoints && (t.compilationString += this._declareOutput(l, t) + " = vec3(".concat(i.isConnected ? this._writeVariable(i) : "0.0", ", ").concat(n.isConnected ? this._writeVariable(n) : "0.0", ", ").concat(r.isConnected ? this._writeVariable(r) : "0.0", ")").concat(this._buildSwizzle(3), ";\r\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, n) {
var r, o, a, s;
e.prototype._deserialize.call(this, t, i, n),
this.rSwizzle = null !== (r = t.rSwizzle) && void 0 !== r ? r : "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, "};\r\n"),
t += "".concat(this._codeVariableName, ".gSwizzle = ").concat(this.gSwizzle, "};\r\n"),
(t += "".concat(this._codeVariableName, ".bSwizzle = ").concat(this.bSwizzle, "};\r\n")) + "".concat(this._codeVariableName, ".aSwizzle = ").concat(this.aSwizzle, "};\r\n")
}
,
t
}(Wp);
y("BABYLON.ColorMergerBlock", Zm);
var Jm = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("xyzw", Op.Vector4, !0),
i.registerInput("xyz ", Op.Vector3, !0),
i.registerInput("xy ", Op.Vector2, !0),
i.registerOutput("xyz", Op.Vector3),
i.registerOutput("xy", Op.Vector2),
i.registerOutput("zw", Op.Vector2),
i.registerOutput("x", Op.Float),
i.registerOutput("y", Op.Float),
i.registerOutput("z", Op.Float),
i.registerOutput("w", Op.Float),
i.inputsAreExclusive = !0,
i
}
return U(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
, n = this._outputs[0]
, r = this._outputs[1]
, o = this._outputs[2]
, a = this._outputs[3]
, s = this._outputs[4]
, l = this._outputs[5]
, c = this._outputs[6];
return n.hasEndpoints && (i === this.xyIn ? t.compilationString += this._declareOutput(n, t) + " = vec3(".concat(i.associatedVariableName, ", 0.0);\r\n") : t.compilationString += this._declareOutput(n, t) + " = ".concat(i.associatedVariableName, ".xyz;\r\n")),
o.hasEndpoints && this.xyzw.isConnected && (t.compilationString += this._declareOutput(o, t) + " = ".concat(this.xyzw.associatedVariableName, ".zw;\r\n")),
r.hasEndpoints && (t.compilationString += this._declareOutput(r, t) + " = ".concat(i.associatedVariableName, ".xy;\r\n")),
a.hasEndpoints && (t.compilationString += this._declareOutput(a, t) + " = ".concat(i.associatedVariableName, ".x;\r\n")),
s.hasEndpoints && (t.compilationString += this._declareOutput(s, t) + " = ".concat(i.associatedVariableName, ".y;\r\n")),
l.hasEndpoints && (t.compilationString += this._declareOutput(l, t) + " = ".concat(i.associatedVariableName, ".z;\r\n")),
c.hasEndpoints && (t.compilationString += this._declareOutput(c, t) + " = ".concat(i.associatedVariableName, ".w;\r\n")),
this
}
,
t
}(Wp);
y("BABYLON.VectorSplitterBlock", Jm);
var $m = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("left", Op.AutoDetect),
i.registerInput("right", Op.AutoDetect),
i.registerInput("gradient", Op.AutoDetect),
i.registerOutput("output", Op.BasedOnInput),
i._outputs[0]._typeConnectionSource = i._inputs[0],
i._linkConnectionTypes(0, 1),
i._linkConnectionTypes(1, 2, !0),
i._inputs[2].acceptedConnectionPointTypes.push(Op.Float),
i
}
return U(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, ");\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.LerpBlock", $m);
var eg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("left", Op.AutoDetect),
i.registerInput("right", Op.AutoDetect),
i.registerOutput("output", Op.BasedOnInput),
i._outputs[0]._typeConnectionSource = i._inputs[0],
i._linkConnectionTypes(0, 1),
i
}
return U(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, ";\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.DivideBlock", eg);
var tg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("left", Op.AutoDetect),
i.registerInput("right", Op.AutoDetect),
i.registerOutput("output", Op.BasedOnInput),
i._outputs[0]._typeConnectionSource = i._inputs[0],
i._linkConnectionTypes(0, 1),
i
}
return U(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, ";\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.SubtractBlock", tg);
var ig = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("value", Op.Float),
i.registerInput("edge", Op.Float),
i.registerOutput("output", Op.Float),
i
}
return U(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, ");\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.StepBlock", ig);
var ng = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("input", Op.AutoDetect),
i.registerOutput("output", Op.BasedOnInput),
i._outputs[0]._typeConnectionSource = i._inputs[0],
i._outputs[0].excludedConnectionPointTypes.push(Op.Matrix),
i
}
return U(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, ";\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.OneMinusBlock", ng),
y("BABYLON.OppositeBlock", ng);
var rg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("worldPosition", Op.Vector4),
i.registerInput("cameraPosition", Op.Vector3),
i.registerOutput("output", Op.Vector3),
i
}
return U(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 === Qp.CameraPosition
}
));
t || (t = new tf("cameraPosition")).setAsSystemValue(Qp.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);\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.ViewDirectionBlock", rg);
var og = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("worldNormal", Op.Vector4),
i.registerInput("viewDirection", Op.Vector3),
i.registerInput("bias", Op.Float),
i.registerInput("power", Op.Float),
i.registerOutput("fresnel", Op.Float),
i
}
return U(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 rg("View direction");
t.output.connectTo(this.viewDirection),
t.autoConfigure(e)
}
if (!this.bias.isConnected) {
var i = new tf("bias");
i.value = 0,
i.output.connectTo(this.bias)
}
if (!this.power.isConnected) {
var n = new tf("power");
n.value = 1,
n.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, ");\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.FresnelBlock", og);
var ag = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("left", Op.AutoDetect),
i.registerInput("right", Op.AutoDetect),
i.registerOutput("output", Op.BasedOnInput),
i._outputs[0]._typeConnectionSource = i._inputs[0],
i._linkConnectionTypes(0, 1),
i
}
return U(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, ");\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.MaxBlock", ag);
var sg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("left", Op.AutoDetect),
i.registerInput("right", Op.AutoDetect),
i.registerOutput("output", Op.BasedOnInput),
i._outputs[0]._typeConnectionSource = i._inputs[0],
i._linkConnectionTypes(0, 1),
i
}
return U(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, ");\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.MinBlock", sg);
var lg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("left", Op.AutoDetect),
i.registerInput("right", Op.AutoDetect),
i.registerOutput("output", Op.Float),
i._linkConnectionTypes(0, 1),
i._inputs[0].excludedConnectionPointTypes.push(Op.Float),
i._inputs[0].excludedConnectionPointTypes.push(Op.Matrix),
i._inputs[1].excludedConnectionPointTypes.push(Op.Float),
i._inputs[1].excludedConnectionPointTypes.push(Op.Matrix),
i
}
return U(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, ");\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.DistanceBlock", lg);
var cg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("value", Op.AutoDetect),
i.registerOutput("output", Op.Float),
i._inputs[0].excludedConnectionPointTypes.push(Op.Float),
i._inputs[0].excludedConnectionPointTypes.push(Op.Matrix),
i
}
return U(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, ");\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.LengthBlock", cg);
var ug = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("value", Op.AutoDetect),
i.registerOutput("output", Op.BasedOnInput),
i._outputs[0]._typeConnectionSource = i._inputs[0],
i
}
return U(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, ";\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.NegateBlock", ug);
var hg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("value", Op.AutoDetect),
i.registerInput("power", Op.AutoDetect),
i.registerOutput("output", Op.BasedOnInput),
i._outputs[0]._typeConnectionSource = i._inputs[0],
i._linkConnectionTypes(0, 1),
i
}
return U(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, ");\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.PowBlock", hg);
var dg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("seed", Op.Vector2),
i.registerOutput("output", Op.Float),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector3),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Color3),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Color4),
i
}
return U(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]
, n = "//".concat(this.name);
return t._emitFunctionFromInclude("helperFunctions", n),
t.compilationString += this._declareOutput(i, t) + " = getRand(".concat(this.seed.associatedVariableName, ".xy);\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.RandomNumberBlock", dg);
var pg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("x", Op.Float),
i.registerInput("y", Op.Float),
i.registerOutput("output", Op.Float),
i
}
return U(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, ");\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.ArcTan2Block", pg);
var fg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("value", Op.AutoDetect),
i.registerInput("edge0", Op.Float),
i.registerInput("edge1", Op.Float),
i.registerOutput("output", Op.BasedOnInput),
i._outputs[0]._typeConnectionSource = i._inputs[0],
i
}
return U(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, ");\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.SmoothStepBlock", fg);
var _g = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("input", Op.AutoDetect),
i.registerOutput("output", Op.BasedOnInput),
i._outputs[0]._typeConnectionSource = i._inputs[0],
i._outputs[0].excludedConnectionPointTypes.push(Op.Matrix),
i
}
return U(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 t.compilationString += this._declareOutput(i, t) + " = 1. / ".concat(this.input.associatedVariableName, ";\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.ReciprocalBlock", _g);
var mg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("value", Op.AutoDetect),
i.registerInput("reference", Op.AutoDetect),
i.registerInput("distance", Op.Float),
i.registerInput("replacement", Op.AutoDetect),
i.registerOutput("output", Op.BasedOnInput),
i._outputs[0]._typeConnectionSource = i._inputs[0],
i._linkConnectionTypes(0, 1),
i._linkConnectionTypes(0, 3),
i._inputs[0].excludedConnectionPointTypes.push(Op.Float),
i._inputs[0].excludedConnectionPointTypes.push(Op.Matrix),
i._inputs[1].excludedConnectionPointTypes.push(Op.Float),
i._inputs[1].excludedConnectionPointTypes.push(Op.Matrix),
i._inputs[3].excludedConnectionPointTypes.push(Op.Float),
i._inputs[3].excludedConnectionPointTypes.push(Op.Matrix),
i
}
return U(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) + ";\r\n",
t.compilationString += "if (length(".concat(this.value.associatedVariableName, " - ").concat(this.reference.associatedVariableName, ") < ").concat(this.distance.associatedVariableName, ") {\r\n"),
t.compilationString += "".concat(i.associatedVariableName, " = ").concat(this.replacement.associatedVariableName, ";\r\n"),
t.compilationString += "} else {\r\n",
t.compilationString += "".concat(i.associatedVariableName, " = ").concat(this.value.associatedVariableName, ";\r\n"),
t.compilationString += "}\r\n",
this
}
,
t
}(Wp);
y("BABYLON.ReplaceColorBlock", mg);
var gg, vg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("value", Op.AutoDetect),
i.registerInput("steps", Op.AutoDetect),
i.registerOutput("output", Op.BasedOnInput),
i._outputs[0]._typeConnectionSource = i._inputs[0],
i._linkConnectionTypes(0, 1),
i._inputs[0].excludedConnectionPointTypes.push(Op.Matrix),
i._inputs[1].excludedConnectionPointTypes.push(Op.Matrix),
i
}
return U(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, ");\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.PosterizeBlock", vg),
function(e) {
e[e.SawTooth = 0] = "SawTooth",
e[e.Square = 1] = "Square",
e[e.Triangle = 2] = "Triangle"
}(gg || (gg = {}));
var yg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.kind = gg.SawTooth,
i.registerInput("input", Op.AutoDetect),
i.registerOutput("output", Op.BasedOnInput),
i._outputs[0]._typeConnectionSource = i._inputs[0],
i._inputs[0].excludedConnectionPointTypes.push(Op.Matrix),
i
}
return U(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 gg.SawTooth:
t.compilationString += this._declareOutput(i, t) + " = ".concat(this.input.associatedVariableName, " - floor(0.5 + ").concat(this.input.associatedVariableName, ");\r\n");
break;
case gg.Square:
t.compilationString += this._declareOutput(i, t) + " = 1.0 - 2.0 * round(fract(".concat(this.input.associatedVariableName, "));\r\n");
break;
case gg.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;\r\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, n) {
e.prototype._deserialize.call(this, t, i, n),
this.kind = t.kind
}
,
t
}(Wp);
y("BABYLON.WaveBlock", yg);
var bg = 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
}()
, Tg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.colorSteps = [new bg(0,D.Black()), new bg(1,D.White())],
i.onValueChangedObservable = new h,
i.registerInput("gradient", Op.Float),
i.registerOutput("output", Op.Color3),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector2),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector3),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Color3),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Color4),
i
}
return U(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 n = t._getFreeVariableName("gradientTempColor")
, r = t._getFreeVariableName("gradientTempPosition");
t.compilationString += "vec3 ".concat(n, " = ").concat(this._writeColorConstant(0), ";\r\n"),
t.compilationString += "float ".concat(r, ";\r\n");
var o = this.gradient.associatedVariableName;
this.gradient.connectedPoint.type !== Op.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(r, " = 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), ");\r\n"),
t.compilationString += "".concat(n, " = mix(").concat(n, ", ").concat(this._writeColorConstant(a), ", ").concat(r, ");\r\n")
}
return t.compilationString += this._declareOutput(i, t) + " = ".concat(n, ";\r\n"),
this
}
t.compilationString += this._declareOutput(i, t) + " = vec3(0., 0., 0.);\r\n"
}
,
t.prototype.serialize = function() {
var t = e.prototype.serialize.call(this);
t.colorSteps = [];
for (var i = 0, n = this.colorSteps; i < n.length; i++) {
var r = n[i];
t.colorSteps.push({
step: r.step,
color: {
r: r.color.r,
g: r.color.g,
b: r.color.b
}
})
}
return t
}
,
t.prototype._deserialize = function(t, i, n) {
e.prototype._deserialize.call(this, t, i, n),
this.colorSteps = [];
for (var r = 0, o = t.colorSteps; r < o.length; r++) {
var a = o[r];
this.colorSteps.push(new bg(a.step,new D(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 = [];\r\n");
for (var i = 0, n = this.colorSteps; i < n.length; i++) {
var r = n[i];
t += "".concat(this._codeVariableName, ".colorSteps.push(new BABYLON.GradientBlockColorStep(").concat(r.step, ", new BABYLON.Color3(").concat(r.color.r, ", ").concat(r.color.g, ", ").concat(r.color.b, ")));\r\n")
}
return t
}
,
t
}(Wp);
y("BABYLON.GradientBlock", Tg);
var Eg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("left", Op.AutoDetect),
i.registerInput("right", Op.AutoDetect),
i.registerInput("gradient", Op.AutoDetect),
i.registerOutput("output", Op.BasedOnInput),
i._outputs[0]._typeConnectionSource = i._inputs[0],
i._linkConnectionTypes(0, 1),
i._linkConnectionTypes(1, 2, !0),
i._inputs[2].acceptedConnectionPointTypes.push(Op.Float),
i
}
return U(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, "));\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.NLerpBlock", Eg);
var Sg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.manhattanDistance = !1,
i.registerInput("seed", Op.Vector3),
i.registerInput("jitter", Op.Float),
i.registerOutput("output", Op.Vector2),
i.registerOutput("x", Op.Float),
i.registerOutput("y", Op.Float),
i
}
return U(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){\r\n return mod((34.0 * x + 1.0) * x, 289.0);\r\n}\r\n\r\nvec3 dist(vec3 x, vec3 y, vec3 z, bool manhattanDistance){\r\n return manhattanDistance ? abs(x) + abs(y) + abs(z) : (x * x + y * y + z * z);\r\n}\r\n\r\nvec2 worley(vec3 P, float jitter, bool manhattanDistance){\r\n float K = 0.142857142857; // 1/7\r\n float Ko = 0.428571428571; // 1/2-K/2\r\n float K2 = 0.020408163265306; // 1/(7*7)\r\n float Kz = 0.166666666667; // 1/6\r\n float Kzo = 0.416666666667; // 1/2-1/6*2\r\n\r\n vec3 Pi = mod(floor(P), 289.0);\r\n vec3 Pf = fract(P) - 0.5;\r\n\r\n vec3 Pfx = Pf.x + vec3(1.0, 0.0, -1.0);\r\n vec3 Pfy = Pf.y + vec3(1.0, 0.0, -1.0);\r\n vec3 Pfz = Pf.z + vec3(1.0, 0.0, -1.0);\r\n\r\n vec3 p = permute(Pi.x + vec3(-1.0, 0.0, 1.0));\r\n vec3 p1 = permute(p + Pi.y - 1.0);\r\n vec3 p2 = permute(p + Pi.y);\r\n vec3 p3 = permute(p + Pi.y + 1.0);\r\n\r\n vec3 p11 = permute(p1 + Pi.z - 1.0);\r\n vec3 p12 = permute(p1 + Pi.z);\r\n vec3 p13 = permute(p1 + Pi.z + 1.0);\r\n\r\n vec3 p21 = permute(p2 + Pi.z - 1.0);\r\n vec3 p22 = permute(p2 + Pi.z);\r\n vec3 p23 = permute(p2 + Pi.z + 1.0);\r\n\r\n vec3 p31 = permute(p3 + Pi.z - 1.0);\r\n vec3 p32 = permute(p3 + Pi.z);\r\n vec3 p33 = permute(p3 + Pi.z + 1.0);\r\n\r\n vec3 ox11 = fract(p11*K) - Ko;\r\n vec3 oy11 = mod(floor(p11*K), 7.0)*K - Ko;\r\n vec3 oz11 = floor(p11*K2)*Kz - Kzo; // p11 < 289 guaranteed\r\n\r\n vec3 ox12 = fract(p12*K) - Ko;\r\n vec3 oy12 = mod(floor(p12*K), 7.0)*K - Ko;\r\n vec3 oz12 = floor(p12*K2)*Kz - Kzo;\r\n\r\n vec3 ox13 = fract(p13*K) - Ko;\r\n vec3 oy13 = mod(floor(p13*K), 7.0)*K - Ko;\r\n vec3 oz13 = floor(p13*K2)*Kz - Kzo;\r\n\r\n vec3 ox21 = fract(p21*K) - Ko;\r\n vec3 oy21 = mod(floor(p21*K), 7.0)*K - Ko;\r\n vec3 oz21 = floor(p21*K2)*Kz - Kzo;\r\n\r\n vec3 ox22 = fract(p22*K) - Ko;\r\n vec3 oy22 = mod(floor(p22*K), 7.0)*K - Ko;\r\n vec3 oz22 = floor(p22*K2)*Kz - Kzo;\r\n\r\n vec3 ox23 = fract(p23*K) - Ko;\r\n vec3 oy23 = mod(floor(p23*K), 7.0)*K - Ko;\r\n vec3 oz23 = floor(p23*K2)*Kz - Kzo;\r\n\r\n vec3 ox31 = fract(p31*K) - Ko;\r\n vec3 oy31 = mod(floor(p31*K), 7.0)*K - Ko;\r\n vec3 oz31 = floor(p31*K2)*Kz - Kzo;\r\n\r\n vec3 ox32 = fract(p32*K) - Ko;\r\n vec3 oy32 = mod(floor(p32*K), 7.0)*K - Ko;\r\n vec3 oz32 = floor(p32*K2)*Kz - Kzo;\r\n\r\n vec3 ox33 = fract(p33*K) - Ko;\r\n vec3 oy33 = mod(floor(p33*K), 7.0)*K - Ko;\r\n vec3 oz33 = floor(p33*K2)*Kz - Kzo;\r\n\r\n vec3 dx11 = Pfx + jitter*ox11;\r\n vec3 dy11 = Pfy.x + jitter*oy11;\r\n vec3 dz11 = Pfz.x + jitter*oz11;\r\n\r\n vec3 dx12 = Pfx + jitter*ox12;\r\n vec3 dy12 = Pfy.x + jitter*oy12;\r\n vec3 dz12 = Pfz.y + jitter*oz12;\r\n\r\n vec3 dx13 = Pfx + jitter*ox13;\r\n vec3 dy13 = Pfy.x + jitter*oy13;\r\n vec3 dz13 = Pfz.z + jitter*oz13;\r\n\r\n vec3 dx21 = Pfx + jitter*ox21;\r\n vec3 dy21 = Pfy.y + jitter*oy21;\r\n vec3 dz21 = Pfz.x + jitter*oz21;\r\n\r\n vec3 dx22 = Pfx + jitter*ox22;\r\n vec3 dy22 = Pfy.y + jitter*oy22;\r\n vec3 dz22 = Pfz.y + jitter*oz22;\r\n\r\n vec3 dx23 = Pfx + jitter*ox23;\r\n vec3 dy23 = Pfy.y + jitter*oy23;\r\n vec3 dz23 = Pfz.z + jitter*oz23;\r\n\r\n vec3 dx31 = Pfx + jitter*ox31;\r\n vec3 dy31 = Pfy.z + jitter*oy31;\r\n vec3 dz31 = Pfz.x + jitter*oz31;\r\n\r\n vec3 dx32 = Pfx + jitter*ox32;\r\n vec3 dy32 = Pfy.z + jitter*oy32;\r\n vec3 dz32 = Pfz.y + jitter*oz32;\r\n\r\n vec3 dx33 = Pfx + jitter*ox33;\r\n vec3 dy33 = Pfy.z + jitter*oy33;\r\n vec3 dz33 = Pfz.z + jitter*oz33;\r\n\r\n vec3 d11 = dist(dx11, dy11, dz11, manhattanDistance);\r\n vec3 d12 =dist(dx12, dy12, dz12, manhattanDistance);\r\n vec3 d13 = dist(dx13, dy13, dz13, manhattanDistance);\r\n vec3 d21 = dist(dx21, dy21, dz21, manhattanDistance);\r\n vec3 d22 = dist(dx22, dy22, dz22, manhattanDistance);\r\n vec3 d23 = dist(dx23, dy23, dz23, manhattanDistance);\r\n vec3 d31 = dist(dx31, dy31, dz31, manhattanDistance);\r\n vec3 d32 = dist(dx32, dy32, dz32, manhattanDistance);\r\n vec3 d33 = dist(dx33, dy33, dz33, manhattanDistance);\r\n\r\n vec3 d1a = min(d11, d12);\r\n d12 = max(d11, d12);\r\n d11 = min(d1a, d13); // Smallest now not in d12 or d13\r\n d13 = max(d1a, d13);\r\n d12 = min(d12, d13); // 2nd smallest now not in d13\r\n vec3 d2a = min(d21, d22);\r\n d22 = max(d21, d22);\r\n d21 = min(d2a, d23); // Smallest now not in d22 or d23\r\n d23 = max(d2a, d23);\r\n d22 = min(d22, d23); // 2nd smallest now not in d23\r\n vec3 d3a = min(d31, d32);\r\n d32 = max(d31, d32);\r\n d31 = min(d3a, d33); // Smallest now not in d32 or d33\r\n d33 = max(d3a, d33);\r\n d32 = min(d32, d33); // 2nd smallest now not in d33\r\n vec3 da = min(d11, d21);\r\n d21 = max(d11, d21);\r\n d11 = min(da, d31); // Smallest now in d11\r\n d31 = max(da, d31); // 2nd smallest now not in d31\r\n d11.xy = (d11.x < d11.y) ? d11.xy : d11.yx;\r\n d11.xz = (d11.x < d11.z) ? d11.xz : d11.zx; // d11.x now smallest\r\n d12 = min(d12, d21); // 2nd smallest now not in d21\r\n d12 = min(d12, d22); // nor in d22\r\n d12 = min(d12, d31); // nor in d31\r\n d12 = min(d12, d32); // nor in d32\r\n d11.yz = min(d11.yz,d12.xy); // nor in d12.yz\r\n d11.y = min(d11.y,d12.z); // Only two more to go\r\n d11.y = min(d11.y,d11.z); // Done! (Phew!)\r\n return sqrt(d11.xy); // F1, F2\r\n}\r\n\r\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, ");\r\n"),
this.output.hasEndpoints && (t.compilationString += this._declareOutput(this.output, t) + " = ".concat(i, ";\r\n")),
this.x.hasEndpoints && (t.compilationString += this._declareOutput(this.x, t) + " = ".concat(i, ".x;\r\n")),
this.y.hasEndpoints && (t.compilationString += this._declareOutput(this.y, t) + " = ".concat(i, ".y;\r\n")),
this
}
}
,
t.prototype._dumpPropertiesCode = function() {
return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".manhattanDistance = ").concat(this.manhattanDistance, ";\r\n")
}
,
t.prototype.serialize = function() {
var t = e.prototype.serialize.call(this);
return t.manhattanDistance = this.manhattanDistance,
t
}
,
t.prototype._deserialize = function(t, i, n) {
e.prototype._deserialize.call(this, t, i, n),
this.manhattanDistance = t.manhattanDistance
}
,
k([Yp("Use Manhattan Distance", Xp.Boolean, "PROPERTIES", {
notifiers: {
update: !1
}
})], t.prototype, "manhattanDistance", void 0),
t
}(Wp);
y("BABYLON.WorleyNoise3DBlock", Sg);
var Ag = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("seed", Op.Vector3),
i.registerOutput("output", Op.Float),
i
}
return U(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;\r\nconst float UNSKEWFACTOR = 1.0/6.0;\r\nconst float SIMPLEX_CORNER_POS = 0.5;\r\nconst float SIMPLEX_TETRAHADRON_HEIGHT = 0.70710678118654752440084436210485;\r\nfloat SimplexPerlin3D( vec3 P ){\r\n P.x = P == vec3(0., 0., 0.) ? 0.00001 : P.x;\r\n P *= SIMPLEX_TETRAHADRON_HEIGHT;\r\n vec3 Pi = floor( P + dot( P, vec3( SKEWFACTOR) ) ); vec3 x0 = P - Pi + dot(Pi, vec3( UNSKEWFACTOR ) );\r\n vec3 g = step(x0.yzx, x0.xyz);\r\n vec3 l = 1.0 - g;\r\n vec3 Pi_1 = min( g.xyz, l.zxy );\r\n vec3 Pi_2 = max( g.xyz, l.zxy );\r\n vec3 x1 = x0 - Pi_1 + UNSKEWFACTOR;\r\n vec3 x2 = x0 - Pi_2 + SKEWFACTOR;\r\n vec3 x3 = x0 - SIMPLEX_CORNER_POS;\r\n vec4 v1234_x = vec4( x0.x, x1.x, x2.x, x3.x );\r\n vec4 v1234_y = vec4( x0.y, x1.y, x2.y, x3.y );\r\n vec4 v1234_z = vec4( x0.z, x1.z, x2.z, x3.z );\r\n Pi.xyz = Pi.xyz - floor(Pi.xyz * ( 1.0 / 69.0 )) * 69.0;\r\n vec3 Pi_inc1 = step( Pi, vec3( 69.0 - 1.5 ) ) * ( Pi + 1.0 );\r\n vec4 Pt = vec4( Pi.xy, Pi_inc1.xy ) + vec2( 50.0, 161.0 ).xyxy;\r\n Pt *= Pt;\r\n vec4 V1xy_V2xy = mix( Pt.xyxy, Pt.zwzw, vec4( Pi_1.xy, Pi_2.xy ) );\r\n Pt = vec4( Pt.x, V1xy_V2xy.xz, Pt.z ) * vec4( Pt.y, V1xy_V2xy.yw, Pt.w );\r\n const vec3 SOMELARGEFLOATS = vec3( 635.298681, 682.357502, 668.926525 );\r\n const vec3 ZINC = vec3( 48.500388, 65.294118, 63.934599 );\r\n vec3 lowz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi.zzz * ZINC.xyz ) );\r\n vec3 highz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi_inc1.zzz * ZINC.xyz ) );\r\n Pi_1 = ( Pi_1.z < 0.5 ) ? lowz_mods : highz_mods;\r\n Pi_2 = ( Pi_2.z < 0.5 ) ? lowz_mods : highz_mods;\r\n vec4 hash_0 = fract( Pt * vec4( lowz_mods.x, Pi_1.x, Pi_2.x, highz_mods.x ) ) - 0.49999;\r\n vec4 hash_1 = fract( Pt * vec4( lowz_mods.y, Pi_1.y, Pi_2.y, highz_mods.y ) ) - 0.49999;\r\n vec4 hash_2 = fract( Pt * vec4( lowz_mods.z, Pi_1.z, Pi_2.z, highz_mods.z ) ) - 0.49999;\r\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 );\r\n const float FINAL_NORMALIZATION = 37.837227241611314102871574478976;\r\n vec4 kernel_weights = v1234_x * v1234_x + v1234_y * v1234_y + v1234_z * v1234_z;\r\n kernel_weights = max(0.5 - kernel_weights, 0.0);\r\n kernel_weights = kernel_weights*kernel_weights*kernel_weights;\r\n return dot( kernel_weights, grad_results ) * FINAL_NORMALIZATION;\r\n}\r\n", "// SimplexPerlin3D"),
t.compilationString += this._declareOutput(this._outputs[0], t) + " = SimplexPerlin3D(".concat(this.seed.associatedVariableName, ");\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.SimplexPerlin3DBlock", Ag);
var xg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("normalMap0", Op.Vector3),
i.registerInput("normalMap1", Op.Vector3),
i.registerOutput("output", Op.Vector3),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Color3),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Color4),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
i._inputs[1].acceptedConnectionPointTypes.push(Op.Color3),
i._inputs[1].acceptedConnectionPointTypes.push(Op.Color4),
i._inputs[1].acceptedConnectionPointTypes.push(Op.Vector4),
i
}
return U(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]
, n = this._inputs[0]
, r = this._inputs[1]
, o = t._getFreeVariableName("stepR")
, a = t._getFreeVariableName("stepG");
return t.compilationString += "float ".concat(o, " = step(0.5, ").concat(n.associatedVariableName, ".r);\r\n"),
t.compilationString += "float ".concat(a, " = step(0.5, ").concat(n.associatedVariableName, ".g);\r\n"),
t.compilationString += this._declareOutput(i, t) + ";\r\n",
t.compilationString += "".concat(i.associatedVariableName, ".r = (1.0 - ").concat(o, ") * ").concat(n.associatedVariableName, ".r * ").concat(r.associatedVariableName, ".r * 2.0 + ").concat(o, " * (1.0 - (1.0 - ").concat(n.associatedVariableName, ".r) * (1.0 - ").concat(r.associatedVariableName, ".r) * 2.0);\r\n"),
t.compilationString += "".concat(i.associatedVariableName, ".g = (1.0 - ").concat(a, ") * ").concat(n.associatedVariableName, ".g * ").concat(r.associatedVariableName, ".g * 2.0 + ").concat(a, " * (1.0 - (1.0 - ").concat(n.associatedVariableName, ".g) * (1.0 - ").concat(r.associatedVariableName, ".g) * 2.0);\r\n"),
t.compilationString += "".concat(i.associatedVariableName, ".b = ").concat(n.associatedVariableName, ".b * ").concat(r.associatedVariableName, ".b;\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.NormalBlendBlock", xg);
var Rg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("input", Op.Vector2),
i.registerInput("angle", Op.Float),
i.registerOutput("output", Op.Vector2),
i
}
return U(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 tf("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]
, n = this.angle
, r = this.input;
return t.compilationString += this._declareOutput(i, t) + " = vec2(cos(".concat(n.associatedVariableName, ") * ").concat(r.associatedVariableName, ".x - sin(").concat(n.associatedVariableName, ") * ").concat(r.associatedVariableName, ".y, sin(").concat(n.associatedVariableName, ") * ").concat(r.associatedVariableName, ".x + cos(").concat(n.associatedVariableName, ") * ").concat(r.associatedVariableName, ".y);\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.Rotate2dBlock", Rg);
var Cg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("incident", Op.Vector3),
i.registerInput("normal", Op.Vector3),
i.registerOutput("output", Op.Vector3),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Color3),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Color4),
i._inputs[1].acceptedConnectionPointTypes.push(Op.Vector4),
i._inputs[1].acceptedConnectionPointTypes.push(Op.Color3),
i._inputs[1].acceptedConnectionPointTypes.push(Op.Color4),
i
}
return U(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);\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.ReflectBlock", Cg);
var Pg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("incident", Op.Vector3),
i.registerInput("normal", Op.Vector3),
i.registerInput("ior", Op.Float),
i.registerOutput("output", Op.Vector3),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Color3),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Color4),
i._inputs[1].acceptedConnectionPointTypes.push(Op.Vector4),
i._inputs[1].acceptedConnectionPointTypes.push(Op.Color3),
i._inputs[1].acceptedConnectionPointTypes.push(Op.Color4),
i
}
return U(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, ");\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.RefractBlock", Pg);
var Mg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("color", Op.Color3),
i.registerInput("level", Op.Float),
i.registerOutput("output", Op.Color3),
i
}
return U(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]
, n = this.color.associatedVariableName
, r = t._getFreeVariableName("colorMin")
, o = t._getFreeVariableName("colorMax")
, a = t._getFreeVariableName("colorMerge");
return t.compilationString += "float ".concat(r, " = min(min(").concat(n, ".x, ").concat(n, ".y), ").concat(n, ".z);\r\n"),
t.compilationString += "float ".concat(o, " = max(max(").concat(n, ".x, ").concat(n, ".y), ").concat(n, ".z);\r\n"),
t.compilationString += "float ".concat(a, " = 0.5 * (").concat(r, " + ").concat(o, ");\r\n"),
t.compilationString += this._declareOutput(i, t) + " = mix(".concat(n, ", vec3(").concat(a, ", ").concat(a, ", ").concat(a, "), ").concat(this.level.associatedVariableName, ");\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.DesaturateBlock", Mg);
var Ig = function(e) {
function t(i) {
var n = e.call(this, i, Dp.Fragment) || this;
return n.albedoScaling = !1,
n.linkSheenWithAlbedo = !1,
n._isUnique = !0,
n.registerInput("intensity", Op.Float, !0, Dp.Fragment),
n.registerInput("color", Op.Color3, !0, Dp.Fragment),
n.registerInput("roughness", Op.Float, !0, Dp.Fragment),
n.registerOutput("sheen", Op.Object, Dp.Fragment, new Bm("sheen",n,Vp.Output,t,"SheenBlock")),
n
}
return U(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, n) {
e.prototype.prepareDefines.call(this, t, i, n),
n.setValue("SHEEN", !0),
n.setValue("SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE", !0, !0),
n.setValue("SHEEN_LINKWITHALBEDO", this.linkSheenWithAlbedo, !0),
n.setValue("SHEEN_ROUGHNESS", this.roughness.isConnected, !0),
n.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."
, n = 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(n, ",\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\r\n")
}
,
t.prototype._buildBlock = function(e) {
return e.target === Dp.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, ";\r\n")) + "".concat(this._codeVariableName, ".linkSheenWithAlbedo = ").concat(this.linkSheenWithAlbedo, ";\r\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, n) {
e.prototype._deserialize.call(this, t, i, n),
this.albedoScaling = t.albedoScaling,
this.linkSheenWithAlbedo = t.linkSheenWithAlbedo
}
,
k([Yp("Albedo scaling", Xp.Boolean, "PROPERTIES", {
notifiers: {
update: !0
}
})], t.prototype, "albedoScaling", void 0),
k([Yp("Link sheen with albedo", Xp.Boolean, "PROPERTIES", {
notifiers: {
update: !0
}
})], t.prototype, "linkSheenWithAlbedo", void 0),
t
}(Wp);
y("BABYLON.SheenBlock", Ig);
var Og = function(e) {
function t(i) {
var n = e.call(this, i, Dp.Fragment) || this;
return n._isUnique = !0,
n.registerInput("intensity", Op.Float, !0, Dp.Fragment),
n.registerInput("direction", Op.Vector2, !0, Dp.Fragment),
n.registerInput("uv", Op.Vector2, !0),
n.registerInput("worldTangent", Op.Vector4, !0),
n.registerOutput("anisotropy", Op.Object, Dp.Fragment, new Bm("anisotropy",n,Vp.Output,t,"AnisotropyBlock")),
n
}
return U(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, "anisotropy", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
t.prototype._generateTBNSpace = function(e) {
var t = ""
, i = "//".concat(this.name)
, n = this.uv
, r = this.worldPositionConnectionPoint
, o = this.worldNormalConnectionPoint
, a = this.worldTangent;
n.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)"
};
return a.isConnected && (t += "vec3 tbnNormal = normalize(".concat(o.associatedVariableName, ".xyz);\r\n"),
t += "vec3 tbnTangent = normalize(".concat(a.associatedVariableName, ".xyz);\r\n"),
t += "vec3 tbnBitangent = cross(tbnNormal, tbnTangent);\r\n",
t += "mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\r\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_" + r.associatedVariableName + ".xyz", ", ").concat(n.isConnected ? n.associatedVariableName : "vec2(0.)", ", vec2(1., 1.));\n #endif\r\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 n = this.intensity.isConnected ? this.intensity.associatedVariableName : "1.0"
, r = this.direction.isConnected ? this.direction.associatedVariableName : "vec2(1., 0.)";
return i + "anisotropicOutParams anisotropicOut;\n anisotropicBlock(\n vec3(".concat(r, ", ").concat(n, "),\n #ifdef ANISOTROPIC_TEXTURE\n vec3(0.),\n #endif\n TBN,\n normalW,\n viewDirectionW,\n anisotropicOut\n );\r\n")
}
,
t.prototype.prepareDefines = function(t, i, n) {
e.prototype.prepareDefines.call(this, t, i, n),
n.setValue("ANISOTROPIC", !0),
n.setValue("ANISOTROPIC_TEXTURE", !1, !0)
}
,
t.prototype._buildBlock = function(e) {
return e.target === Dp.Fragment && e.sharedData.blocksWithDefines.push(this),
this
}
,
t
}(Wp);
y("BABYLON.AnisotropyBlock", Og);
var Dg = function(e) {
function t(i) {
var n = e.call(this, i) || this;
return n.useSphericalHarmonics = !0,
n.forceIrradianceInFragment = !1,
n._isUnique = !0,
n.registerInput("position", Op.Vector3, !1, Dp.Vertex),
n.registerInput("world", Op.Matrix, !1, Dp.Vertex),
n.registerInput("color", Op.Color3, !0, Dp.Fragment),
n.registerOutput("reflection", Op.Object, Dp.Fragment, new Bm("reflection",n,Vp.Output,t,"ReflectionBlock")),
n
}
return U(t, e),
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, n) {
e.prototype.prepareDefines.call(this, t, i, n);
var r = this._getTexture()
, o = r && r.getTextureMatrix;
n.setValue("REFLECTION", o, !0),
o && (n.setValue(this._defineLODReflectionAlpha, r.lodLevelInAlpha, !0),
n.setValue(this._defineLinearSpecularReflection, r.linearSpecularLOD, !0),
n.setValue(this._defineOppositeZ, this._scene.useRightHandedSystem ? !r.invertZ : r.invertZ, !0),
n.setValue("SPHERICAL_HARMONICS", this.useSphericalHarmonics, !0),
n.setValue("GAMMAREFLECTION", r.gammaSpace, !0),
n.setValue("RGBDREFLECTION", r.isRGBD, !0),
r && r.coordinatesMode !== io.SKYBOX_MODE && r.isCube && (n.setValue("USESPHERICALFROMREFLECTIONMAP", !0),
n.setValue("USEIRRADIANCEMAP", !1),
this.forceIrradianceInFragment || this._scene.getEngine().getCaps().maxVaryingVectors <= 8 ? n.setValue("USESPHERICALINVERTEX", !1) : n.setValue("USESPHERICALINVERTEX", !0)))
}
,
t.prototype.bind = function(t, i, n, r) {
e.prototype.bind.call(this, t, i, n);
var o = this._getTexture();
if (o && r) {
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, d.Log2(a));
var s = r.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 n = 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(n, " = vec3(").concat(this._reflectionMatrixName, " * vec4(normalize(").concat(this.worldNormal.associatedVariableName, ").xyz, 0)).xyz;\n #ifdef ").concat(this._defineOppositeZ, "\n ").concat(n, ".z *= -1.0;\n #endif\n ").concat(this._vEnvironmentIrradianceName, " = computeEnvironmentIrradiance(").concat(n, ");\n #endif\r\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\r\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\r\n"), "//".concat(this.name));
var n = "\n vec3 computeReflectionCoordsPBR(vec4 worldPos, vec3 worldNormal) {\n ".concat(this.handleFragmentSideCodeReflectionCoords("worldNormal", "worldPos", !0), "\n return ").concat(this._reflectionVectorName, ";\n }\r\n");
return e._emitFunction("computeReflectionCoordsPBR", n, "//".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("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\r\n")
}
,
t.prototype._buildBlock = function(e) {
return this._scene = e.sharedData.scene,
e.target !== Dp.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, ";\r\n")),
(t += "".concat(this._codeVariableName, ".useSphericalHarmonics = ").concat(this.useSphericalHarmonics, ";\r\n")) + "".concat(this._codeVariableName, ".forceIrradianceInFragment = ").concat(this.forceIrradianceInFragment, ";\r\n")
}
,
t.prototype.serialize = function() {
var t, i, n = e.prototype.serialize.call(this);
return n.useSphericalHarmonics = this.useSphericalHarmonics,
n.forceIrradianceInFragment = this.forceIrradianceInFragment,
n.gammaSpace = null === (i = null === (t = this.texture) || void 0 === t ? void 0 : t.gammaSpace) || void 0 === i || i,
n
}
,
t.prototype._deserialize = function(t, i, n) {
e.prototype._deserialize.call(this, t, i, n),
this.useSphericalHarmonics = t.useSphericalHarmonics,
this.forceIrradianceInFragment = t.forceIrradianceInFragment,
this.texture && (this.texture.gammaSpace = t.gammaSpace)
}
,
k([Yp("Spherical Harmonics", Xp.Boolean, "ADVANCED", {
notifiers: {
update: !0
}
})], t.prototype, "useSphericalHarmonics", void 0),
k([Yp("Force irradiance in fragment", Xp.Boolean, "ADVANCED", {
notifiers: {
update: !0
}
})], t.prototype, "forceIrradianceInFragment", void 0),
t
}(km);
y("BABYLON.ReflectionBlock", Dg);
var Ng = function(e) {
function t(i) {
var n = e.call(this, i, Dp.Fragment) || this;
return n.remapF0OnInterfaceChange = !0,
n._isUnique = !0,
n.registerInput("intensity", Op.Float, !1, Dp.Fragment),
n.registerInput("roughness", Op.Float, !0, Dp.Fragment),
n.registerInput("indexOfRefraction", Op.Float, !0, Dp.Fragment),
n.registerInput("normalMapColor", Op.Color3, !0, Dp.Fragment),
n.registerInput("uv", Op.Vector2, !0, Dp.Fragment),
n.registerInput("tintColor", Op.Color3, !0, Dp.Fragment),
n.registerInput("tintAtDistance", Op.Float, !0, Dp.Fragment),
n.registerInput("tintThickness", Op.Float, !0, Dp.Fragment),
n.registerInput("worldTangent", Op.Vector4, !0),
n.registerOutput("clearcoat", Op.Object, Dp.Fragment, new Bm("clearcoat",n,Vp.Output,t,"ClearCoatBlock")),
n
}
return U(t, e),
t.prototype.initialize = function(e) {
e._excludeVariableName("clearcoatOut"),
e._excludeVariableName("vClearCoatParams"),
e._excludeVariableName("vClearCoatTintParams"),
e._excludeVariableName("vClearCoatRefractionParams"),
e._excludeVariableName("vClearCoatTangentSpaceParams")
}
,
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, "clearcoat", {
get: function() {
return this._outputs[0]
},
enumerable: !1,
configurable: !0
}),
t.prototype.autoConfigure = function() {
if (!this.intensity.isConnected) {
var e = new tf("ClearCoat intensity",Dp.Fragment,Op.Float);
e.value = 1,
e.output.connectTo(this.intensity)
}
}
,
t.prototype.prepareDefines = function(t, i, n) {
e.prototype.prepareDefines.call(this, t, i, n),
n.setValue("CLEARCOAT", !0),
n.setValue("CLEARCOAT_TEXTURE", !1, !0),
n.setValue("CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE", !0, !0),
n.setValue("CLEARCOAT_TINT", this.tintColor.isConnected || this.tintThickness.isConnected || this.tintAtDistance.isConnected, !0),
n.setValue("CLEARCOAT_BUMP", this.normalMapColor.isConnected, !0),
n.setValue("CLEARCOAT_DEFAULTIOR", !this.indexOfRefraction.isConnected || this.indexOfRefraction.connectInputBlock.value === Qd._DefaultIndexOfRefraction, !0),
n.setValue("CLEARCOAT_REMAP_F0", this.remapF0OnInterfaceChange, !0)
}
,
t.prototype.bind = function(t, i, n) {
var r, o;
e.prototype.bind.call(this, t, i, n);
var a = null !== (o = null === (r = this.indexOfRefraction.connectInputBlock) || void 0 === r ? void 0 : r.value) && void 0 !== o ? o : Qd._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)
}
,
t.prototype._generateTBNSpace = function(e, t, i) {
var n = ""
, r = "//".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)"
};
return o.isConnected && (n += "vec3 tbnNormal = normalize(".concat(i, ".xyz);\r\n"),
n += "vec3 tbnTangent = normalize(".concat(o.associatedVariableName, ".xyz);\r\n"),
n += "vec3 tbnBitangent = cross(tbnNormal, tbnTangent);\r\n",
n += "mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\r\n"),
e._emitFunctionFromInclude("bumpFragmentMainFunctions", r, {
replaceStrings: [a]
}),
n
}
,
t.GetCode = function(e, t, i, n, r, 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.";
return t && (e._emitUniformFromString("vClearCoatRefractionParams", "vec4"),
e._emitUniformFromString("vClearCoatTangentSpaceParams", "vec2")),
r && t && (s += t._generateTBNSpace(e, n, 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(n, ".xyz,\n geometricNormalW,\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\r\n")
}
,
t.prototype._buildBlock = function(e) {
return this._scene = e.sharedData.scene,
e.target === Dp.Fragment && (e.sharedData.bindableBlocks.push(this),
e.sharedData.blocksWithDefines.push(this)),
this
}
,
t.prototype._dumpPropertiesCode = function() {
return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".remapF0OnInterfaceChange = ").concat(this.remapF0OnInterfaceChange, ";\r\n")
}
,
t.prototype.serialize = function() {
var t = e.prototype.serialize.call(this);
return t.remapF0OnInterfaceChange = this.remapF0OnInterfaceChange,
t
}
,
t.prototype._deserialize = function(t, i, n) {
var r;
e.prototype._deserialize.call(this, t, i, n),
this.remapF0OnInterfaceChange = null === (r = t.remapF0OnInterfaceChange) || void 0 === r || r
}
,
k([Yp("Remap F0 on interface change", Xp.Boolean, "ADVANCED")], t.prototype, "remapF0OnInterfaceChange", void 0),
t
}(Wp);
y("BABYLON.ClearCoatBlock", Ng);
var Lg = function(e) {
function t(i) {
var n = e.call(this, i, Dp.Fragment) || this;
return n.linkRefractionWithTransparency = !1,
n.invertRefractionY = !1,
n.useThicknessAsDepth = !1,
n._isUnique = !0,
n.registerInput("intensity", Op.Float, !1, Dp.Fragment),
n.registerInput("tintAtDistance", Op.Float, !0, Dp.Fragment),
n.registerInput("volumeIndexOfRefraction", Op.Float, !0, Dp.Fragment),
n.registerOutput("refraction", Op.Object, Dp.Fragment, new Bm("refraction",n,Vp.Output,t,"RefractionBlock")),
n
}
return U(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 tf("Refraction intensity",Dp.Fragment,Op.Float);
t.value = 1,
t.output.connectTo(this.intensity)
}
if (this.view && !this.view.isConnected) {
var i = e.getInputBlockByPredicate((function(e) {
return e.systemValue === Qp.View
}
));
i || (i = new tf("view")).setAsSystemValue(Qp.View),
i.output.connectTo(this.view)
}
}
,
t.prototype.prepareDefines = function(t, i, n) {
e.prototype.prepareDefines.call(this, t, i, n);
var r = this._getTexture()
, o = r && r.getTextureMatrix;
n.setValue("SS_REFRACTION", o, !0),
o && (n.setValue(this._define3DName, r.isCube, !0),
n.setValue(this._defineLODRefractionAlpha, r.lodLevelInAlpha, !0),
n.setValue(this._defineLinearSpecularRefraction, r.linearSpecularLOD, !0),
n.setValue(this._defineOppositeZ, this._scene.useRightHandedSystem ? !r.invertZ : r.invertZ, !0),
n.setValue("SS_LINKREFRACTIONTOTRANSPARENCY", this.linkRefractionWithTransparency, !0),
n.setValue("SS_GAMMAREFRACTION", r.gammaSpace, !0),
n.setValue("SS_RGBDREFRACTION", r.isRGBD, !0),
n.setValue("SS_USE_LOCAL_REFRACTIONMAP_CUBIC", !!r.boundingBoxSize, !0),
n.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, n) {
var r, o, a, s;
e.prototype.bind.call(this, t, i, n);
var l = this._getTexture();
if (l) {
l.isCube ? t.setTexture(this._cubeSamplerName, l) : t.setTexture(this._2DSamplerName, l),
t.setMatrix(this._refractionMatrixName, l.getReflectionTextureMatrix());
var c = 1;
l.isCube || l.depth && (c = l.depth);
var u = null !== (s = null !== (o = null === (r = this.volumeIndexOfRefraction.connectInputBlock) || void 0 === r ? void 0 : r.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 h = l.getSize().width;
if (t.setFloat2(this._vRefractionFilteringInfoName, h, d.Log2(h)),
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, "\r\n"),
e._samplerDeclaration += "uniform samplerCube ".concat(this._cubeSamplerName, ";\r\n"),
e._samplerDeclaration += "#else\r\n",
e._samplerDeclaration += "uniform sampler2D ".concat(this._2DSamplerName, ";\r\n"),
e._samplerDeclaration += "#endif\r\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\r\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\r\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, '");\r\n') : "".concat(this._codeVariableName, '.texture = new BABYLON.Texture("').concat(this.texture.name, '");\r\n'),
t += "".concat(this._codeVariableName, ".texture.coordinatesMode = ").concat(this.texture.coordinatesMode, ";\r\n")),
t += "".concat(this._codeVariableName, ".linkRefractionWithTransparency = ").concat(this.linkRefractionWithTransparency, ";\r\n"),
(t += "".concat(this._codeVariableName, ".invertRefractionY = ").concat(this.invertRefractionY, ";\r\n")) + "".concat(this._codeVariableName, ".useThicknessAsDepth = ").concat(this.useThicknessAsDepth, ";\r\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, n) {
e.prototype._deserialize.call(this, t, i, n),
t.texture && (n = 0 === t.texture.url.indexOf("data:") ? "" : n,
t.texture.isCube ? this.texture = Bd.Parse(t.texture, i, n) : this.texture = io.Parse(t.texture, i, n)),
this.linkRefractionWithTransparency = t.linkRefractionWithTransparency,
this.invertRefractionY = t.invertRefractionY,
this.useThicknessAsDepth = !!t.useThicknessAsDepth
}
,
k([Yp("Link refraction to transparency", Xp.Boolean, "ADVANCED", {
notifiers: {
update: !0
}
})], t.prototype, "linkRefractionWithTransparency", void 0),
k([Yp("Invert refraction Y", Xp.Boolean, "ADVANCED", {
notifiers: {
update: !0
}
})], t.prototype, "invertRefractionY", void 0),
k([Yp("Use thickness as depth", Xp.Boolean, "ADVANCED", {
notifiers: {
update: !0
}
})], t.prototype, "useThicknessAsDepth", void 0),
t
}(Wp);
y("BABYLON.RefractionBlock", Lg);
var Fg = function(e) {
function t(i) {
var n = e.call(this, i, Dp.Fragment) || this;
return n._isUnique = !0,
n.registerInput("thickness", Op.Float, !1, Dp.Fragment),
n.registerInput("tintColor", Op.Color3, !0, Dp.Fragment),
n.registerInput("translucencyIntensity", Op.Float, !0, Dp.Fragment),
n.registerInput("translucencyDiffusionDist", Op.Color3, !0, Dp.Fragment),
n.registerInput("refraction", Op.Object, !0, Dp.Fragment, new Bm("refraction",n,Vp.Input,Lg,"RefractionBlock")),
n.registerOutput("subsurface", Op.Object, Dp.Fragment, new Bm("subsurface",n,Vp.Output,t,"SubSurfaceBlock")),
n
}
return U(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 tf("SubSurface thickness",Dp.Fragment,Op.Float);
e.value = 0,
e.output.connectTo(this.thickness)
}
}
,
t.prototype.prepareDefines = function(t, i, n) {
e.prototype.prepareDefines.call(this, t, i, n);
var r = this.translucencyDiffusionDist.isConnected || this.translucencyIntensity.isConnected;
n.setValue("SUBSURFACE", r || this.refraction.isConnected, !0),
n.setValue("SS_TRANSLUCENCY", r, !0),
n.setValue("SS_THICKNESSANDMASK_TEXTURE", !1, !0),
n.setValue("SS_REFRACTIONINTENSITY_TEXTURE", !1, !0),
n.setValue("SS_TRANSLUCENCYINTENSITY_TEXTURE", !1, !0),
n.setValue("SS_MASK_FROM_THICKNESS_TEXTURE", !1, !0),
n.setValue("SS_USE_GLTF_TEXTURES", !1, !0)
}
,
t.GetCode = function(e, t, i, n) {
var r, 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.", A = (null == t ? void 0 : t.translucencyDiffusionDist.isConnected) ? null == t ? void 0 : t.translucencyDiffusionDist.associatedVariableName : "vec3(1.)", x = (null == t ? void 0 : t.refraction.isConnected) ? null === (r = null == t ? void 0 : t.refraction.connectedPoint) || void 0 === r ? void 0 : r.ownerBlock : null, R = (null == x ? void 0 : x.tintAtDistance.isConnected) ? x.tintAtDistance.associatedVariableName : "1.", C = (null == x ? void 0 : x.intensity.isConnected) ? x.intensity.associatedVariableName : "1.", P = (null == x ? void 0 : x.view.isConnected) ? x.view.associatedVariableName : "";
return (b += null !== (o = null == x ? void 0 : x.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(n, ".xyz,\n viewDirectionW,\n ").concat(P, ",\n ").concat(null !== (a = null == x ? void 0 : x._vRefractionInfosName) && void 0 !== a ? a : "", ",\n ").concat(null !== (s = null == x ? void 0 : x._refractionMatrixName) && void 0 !== s ? s : "", ",\n ").concat(null !== (l = null == x ? void 0 : x._vRefractionMicrosurfaceInfosName) && void 0 !== l ? l : "", ",\n vLightingIntensity,\n #ifdef SS_LINKREFRACTIONTOTRANSPARENCY\n alpha,\n #endif\n #ifdef ").concat(null !== (c = null == x ? void 0 : x._defineLODRefractionAlpha) && void 0 !== c ? c : "IGNORE", "\n NdotVUnclamped,\n #endif\n #ifdef ").concat(null !== (u = null == x ? void 0 : x._defineLinearSpecularRefraction) && void 0 !== u ? u : "IGNORE", "\n roughness,\n #endif\n alphaG,\n #ifdef ").concat(null !== (h = null == x ? void 0 : x._define3DName) && void 0 !== h ? h : "IGNORE", "\n ").concat(null !== (d = null == x ? void 0 : x._cubeSamplerName) && void 0 !== d ? d : "", ",\n #else\n ").concat(null !== (p = null == x ? void 0 : x._2DSamplerName) && void 0 !== p ? p : "", ",\n #endif\n #ifndef LODBASEDMICROSFURACE\n #ifdef ").concat(null !== (f = null == x ? void 0 : x._define3DName) && void 0 !== f ? f : "IGNORE", "\n ").concat(null !== (_ = null == x ? void 0 : x._cubeSamplerName) && void 0 !== _ ? _ : "", ",\n ").concat(null !== (m = null == x ? void 0 : x._cubeSamplerName) && void 0 !== m ? m : "", ",\n #else\n ").concat(null !== (g = null == x ? void 0 : x._2DSamplerName) && void 0 !== g ? g : "", ",\n ").concat(null !== (v = null == x ? void 0 : x._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 == x ? void 0 : x._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(A, ",\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\r\n")
}
,
t.prototype._buildBlock = function(e) {
return e.target === Dp.Fragment && e.sharedData.blocksWithDefines.push(this),
this
}
,
t
}(Wp);
y("BABYLON.SubSurfaceBlock", Fg);
var wg = {
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", ""]
}
, Bg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.VertexAndFragment) || this;
return i._environmentBRDFTexture = null,
i._metallicReflectanceColor = D.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.debugMode = 0,
i.debugLimit = 0,
i.debugFactor = 1,
i._isUnique = !0,
i.registerInput("worldPosition", Op.Vector4, !1, Dp.Vertex),
i.registerInput("worldNormal", Op.Vector4, !1, Dp.Fragment),
i.registerInput("view", Op.Matrix, !1),
i.registerInput("cameraPosition", Op.Vector3, !1, Dp.Fragment),
i.registerInput("perturbedNormal", Op.Vector4, !0, Dp.Fragment),
i.registerInput("baseColor", Op.Color3, !0, Dp.Fragment),
i.registerInput("metallic", Op.Float, !1, Dp.Fragment),
i.registerInput("roughness", Op.Float, !1, Dp.Fragment),
i.registerInput("ambientOcc", Op.Float, !0, Dp.Fragment),
i.registerInput("opacity", Op.Float, !0, Dp.Fragment),
i.registerInput("indexOfRefraction", Op.Float, !0, Dp.Fragment),
i.registerInput("ambientColor", Op.Color3, !0, Dp.Fragment),
i.registerInput("reflection", Op.Object, !0, Dp.Fragment, new Bm("reflection",i,Vp.Input,Dg,"ReflectionBlock")),
i.registerInput("clearcoat", Op.Object, !0, Dp.Fragment, new Bm("clearcoat",i,Vp.Input,Ng,"ClearCoatBlock")),
i.registerInput("sheen", Op.Object, !0, Dp.Fragment, new Bm("sheen",i,Vp.Input,Ig,"SheenBlock")),
i.registerInput("subsurface", Op.Object, !0, Dp.Fragment, new Bm("subsurface",i,Vp.Input,Fg,"SubSurfaceBlock")),
i.registerInput("anisotropy", Op.Object, !0, Dp.Fragment, new Bm("anisotropy",i,Vp.Input,Og,"AnisotropyBlock")),
i.registerOutput("ambientClr", Op.Color3, Dp.Fragment),
i.registerOutput("diffuseDir", Op.Color3, Dp.Fragment),
i.registerOutput("specularDir", Op.Color3, Dp.Fragment),
i.registerOutput("clearcoatDir", Op.Color3, Dp.Fragment),
i.registerOutput("sheenDir", Op.Color3, Dp.Fragment),
i.registerOutput("diffuseInd", Op.Color3, Dp.Fragment),
i.registerOutput("specularInd", Op.Color3, Dp.Fragment),
i.registerOutput("clearcoatInd", Op.Color3, Dp.Fragment),
i.registerOutput("sheenInd", Op.Color3, Dp.Fragment),
i.registerOutput("refraction", Op.Color3, Dp.Fragment),
i.registerOutput("lighting", Op.Color3, Dp.Fragment),
i.registerOutput("shadow", Op.Float, Dp.Fragment),
i.registerOutput("alpha", Op.Float, Dp.Fragment),
i
}
return U(t, e),
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, "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 === Qp.CameraPosition
}
));
t || (t = new tf("cameraPosition")).setAsSystemValue(Qp.CameraPosition),
t.output.connectTo(this.cameraPosition)
}
if (!this.view.isConnected) {
var i = e.getInputBlockByPredicate((function(e) {
return e.systemValue === Qp.View
}
));
i || (i = new tf("view")).setAsSystemValue(Qp.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 === rp.LIGHTFALLOFF_STANDARD ? (i.setValue("USEPHYSICALLIGHTFALLOFF", !1),
i.setValue("USEGLTFLIGHTFALLOFF", !1)) : this.lightFalloff === rp.LIGHTFALLOFF_GLTF ? (i.setValue("USEPHYSICALLIGHTFALLOFF", !1),
i.setValue("USEGLTFLIGHTFALLOFF", !0)) : (i.setValue("USEPHYSICALLIGHTFALLOFF", !0),
i.setValue("USEGLTFLIGHTFALLOFF", !1));
var n = this.alphaTestCutoff.toString();
i.setValue("ALPHABLEND", this.useAlphaBlending, !0),
i.setValue("ALPHAFROMALBEDO", !1, !0),
i.setValue("ALPHATEST", this.useAlphaTest, !0),
i.setValue("ALPHATESTVALUE", n.indexOf(".") < 0 ? n + "." : n, !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 r = e.getScene();
if (r.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 && vs.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
};
Mr.PrepareDefinesForLight(r, e, this.light, this._lightId, i, !0, o),
o.needRebuild && i.rebuild()
} else
Mr.PrepareDefinesForLights(r, e, i, !0, t.maxSimultaneousLights),
i._needNormals = !0,
Mr.PrepareDefinesForMultiview(r, i)
}
,
t.prototype.updateUniformsAndSamples = function(e, t, i, n) {
for (var r = 0; r < t.maxSimultaneousLights && i["LIGHT" + r]; r++) {
var o = e.uniforms.indexOf("vLightData" + r) >= 0;
Mr.PrepareUniformsAndSamplersForLight(r, e.uniforms, e.samplers, i["PROJECTEDLIGHTTEXTURE" + r], n, 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 n, r;
if (i) {
var o = i.getScene();
this.light ? Mr.BindLight(this.light, this._lightId, o, e, !0) : Mr.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 !== (r = null === (n = this.indexOfRefraction.connectInputBlock) || void 0 === n ? void 0 : n.value) && void 0 !== r ? r : 1.5
, c = Math.pow((l - 1) / (l + 1), 2);
this._metallicReflectanceColor.scaleToRef(c * this._metallicF0Factor, L.Color3[0]);
var u = this._metallicF0Factor;
e.setColor4(this._vMetallicReflectanceFactorsName, L.Color3[0], u),
t.imageProcessingConfiguration && t.imageProcessingConfiguration.bind(e)
}
}
,
t.prototype._injectVertexCode = function(e) {
var t, i, n = this.worldPosition, r = "//".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", r, {
replaceStrings: [{
search: /{X}/g,
replace: this._lightId.toString()
}]
}, this._lightId.toString())) : (e._emitFunctionFromInclude(e.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", r, {
repeatKey: "maxSimultaneousLights"
}),
this._lightId = 0,
e.sharedData.dynamicUniformBlocks.push(this));
var o = "v_" + n.associatedVariableName;
e._emitVaryingFromString(o, "vec4") && (e.compilationString += "".concat(o, " = ").concat(n.associatedVariableName, ";\r\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._emitUniformFromString("vDebugMode", "vec2", "defined(IGNORE) || DEBUGMODE > 0"),
e._emitUniformFromString("ambientFromScene", "vec3"),
e._emitVaryingFromString("vClipSpacePosition", "vec4", "defined(IGNORE) || DEBUGMODE > 0") && (e._injectAtEnd += "#if DEBUGMODE > 0\r\n",
e._injectAtEnd += "vClipSpacePosition = gl_Position;\r\n",
e._injectAtEnd += "#endif\r\n"),
this.light ? e.compilationString += e._emitCodeFromInclude("shadowsVertex", r, {
replaceStrings: [{
search: /{X}/g,
replace: this._lightId.toString()
}, {
search: /worldPos/g,
replace: n.associatedVariableName
}]
}) : (e.compilationString += "vec4 worldPos = ".concat(n.associatedVariableName, ";\r\n"),
this.view.isConnected && (e.compilationString += "mat4 view = ".concat(this.view.associatedVariableName, ";\r\n")),
e.compilationString += e._emitCodeFromInclude("shadowsVertex", r, {
repeatKey: "maxSimultaneousLights"
}))
}
,
t.prototype._getAlbedoOpacityCode = function() {
var e = "albedoOpacityOutParams albedoOpacityOut;\r\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;\r\n")
}
,
t.prototype._getAmbientOcclusionCode = function() {
var e = "ambientOcclusionOutParams aoOut;\r\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 );\r\n")
}
,
t.prototype._getReflectivityCode = function(e) {
var t = "reflectivityOutParams reflectivityOut;\r\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\r\n")
}
,
t.prototype._buildBlock = function(t) {
var i, n, r, o, a, s, l, c, u, h, d, p, f, _, m, g, v, y, b, T, E, S, A, x, R, C, P, M, I, O, D, N, L, F, w, B, U, V, k, G;
e.prototype._buildBlock.call(this, t),
this._scene = t.sharedData.scene,
this._environmentBRDFTexture || (this._environmentBRDFTexture = Hd(this._scene));
var z = this.reflection.isConnected ? null === (i = this.reflection.connectedPoint) || void 0 === i ? void 0 : i.ownerBlock : null;
if (z && (z.worldPositionConnectionPoint = this.worldPosition,
z.cameraPositionConnectionPoint = this.cameraPosition,
z.worldNormalConnectionPoint = this.worldNormal),
t.target !== Dp.Fragment)
return this._injectVertexCode(t),
this;
t.sharedData.forcedBindableBlocks.push(this),
t.sharedData.blocksWithDefines.push(this),
t.sharedData.blockingBlocks.push(this);
var W = "//".concat(this.name)
, H = "v_" + this.worldPosition.associatedVariableName
, X = this.perturbedNormal;
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.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"),
this.light ? t._emitFunctionFromInclude(t.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", W, {
replaceStrings: [{
search: /{X}/g,
replace: this._lightId.toString()
}]
}, this._lightId.toString()) : t._emitFunctionFromInclude(t.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", W, {
repeatKey: "maxSimultaneousLights"
}),
t._emitFunctionFromInclude("helperFunctions", W),
t._emitFunctionFromInclude("importanceSampling", W),
t._emitFunctionFromInclude("pbrHelperFunctions", W),
t._emitFunctionFromInclude("imageProcessingDeclaration", W),
t._emitFunctionFromInclude("imageProcessingFunctions", W),
t._emitFunctionFromInclude("shadowsFragmentFunctions", W, {
replaceStrings: [{
search: /vPositionW/g,
replace: H + ".xyz"
}]
}),
t._emitFunctionFromInclude("pbrDirectLightingSetupFunctions", W, {
replaceStrings: [{
search: /vPositionW/g,
replace: H + ".xyz"
}]
}),
t._emitFunctionFromInclude("pbrDirectLightingFalloffFunctions", W),
t._emitFunctionFromInclude("pbrBRDFFunctions", W, {
replaceStrings: [{
search: /REFLECTIONMAP_SKYBOX/g,
replace: null !== (n = null == z ? void 0 : z._defineSkyboxName) && void 0 !== n ? n : "REFLECTIONMAP_SKYBOX"
}]
}),
t._emitFunctionFromInclude("hdrFilteringFunctions", W),
t._emitFunctionFromInclude("pbrDirectLightingFunctions", W, {
replaceStrings: [{
search: /vPositionW/g,
replace: H + ".xyz"
}]
}),
t._emitFunctionFromInclude("pbrIBLFunctions", W),
t._emitFunctionFromInclude("pbrBlockAlbedoOpacity", W),
t._emitFunctionFromInclude("pbrBlockReflectivity", W),
t._emitFunctionFromInclude("pbrBlockAmbientOcclusion", W),
t._emitFunctionFromInclude("pbrBlockAlphaFresnel", W),
t._emitFunctionFromInclude("pbrBlockAnisotropic", W),
t._emitUniformFromString("vLightingIntensity", "vec4"),
this._vNormalWName = t._getFreeVariableName("vNormalW"),
t.compilationString += "vec4 ".concat(this._vNormalWName, " = normalize(").concat(this.worldNormal.associatedVariableName, ");\r\n"),
t._registerTempVariable("viewDirectionW") && (t.compilationString += "vec3 viewDirectionW = normalize(".concat(this.cameraPosition.associatedVariableName, " - ").concat(H, ".xyz);\r\n")),
t.compilationString += "vec3 geometricNormalW = ".concat(this._vNormalWName, ".xyz;\r\n"),
t.compilationString += "vec3 normalW = ".concat(X.isConnected ? "normalize(" + X.associatedVariableName + ".xyz)" : "geometricNormalW", ";\r\n"),
this._invertNormalName = t._getFreeVariableName("invertNormal"),
t._emitUniformFromString(this._invertNormalName, "float"),
t.compilationString += t._emitCodeFromInclude("pbrBlockNormalFinal", W, {
replaceStrings: [{
search: /vPositionW/g,
replace: H + ".xyz"
}, {
search: /vEyePosition.w/g,
replace: this._invertNormalName
}]
}),
t.compilationString += this._getAlbedoOpacityCode(),
t.compilationString += t._emitCodeFromInclude("depthPrePass", W),
t.compilationString += this._getAmbientOcclusionCode(),
t.compilationString += t._emitCodeFromInclude("pbrBlockLightmapInit", W),
t.compilationString += "#ifdef UNLIT\n vec3 diffuseBase = vec3(1., 1., 1.);\n #else\r\n",
t.compilationString += this._getReflectivityCode(t),
t.compilationString += t._emitCodeFromInclude("pbrBlockGeometryInfo", W, {
replaceStrings: [{
search: /REFLECTIONMAP_SKYBOX/g,
replace: null !== (r = null == z ? void 0 : z._defineSkyboxName) && void 0 !== r ? r : "REFLECTIONMAP_SKYBOX"
}, {
search: /REFLECTIONMAP_3D/g,
replace: null !== (o = null == z ? void 0 : z._define3DName) && void 0 !== o ? o : "REFLECTIONMAP_3D"
}]
});
var j = this.anisotropy.isConnected ? null === (a = this.anisotropy.connectedPoint) || void 0 === a ? void 0 : a.ownerBlock : null;
j && (j.worldPositionConnectionPoint = this.worldPosition,
j.worldNormalConnectionPoint = this.worldNormal,
t.compilationString += j.getCode(t, !this.perturbedNormal.isConnected)),
z && z.hasTexture && (t.compilationString += z.getCode(t, j ? "anisotropicOut.anisotropicNormal" : "normalW")),
t._emitFunctionFromInclude("pbrBlockReflection", W, {
replaceStrings: [{
search: /computeReflectionCoords/g,
replace: "computeReflectionCoordsPBR"
}, {
search: /REFLECTIONMAP_3D/g,
replace: null !== (s = null == z ? void 0 : z._define3DName) && void 0 !== s ? s : "REFLECTIONMAP_3D"
}, {
search: /REFLECTIONMAP_OPPOSITEZ/g,
replace: null !== (l = null == z ? void 0 : z._defineOppositeZ) && void 0 !== l ? l : "REFLECTIONMAP_OPPOSITEZ"
}, {
search: /REFLECTIONMAP_PROJECTION/g,
replace: null !== (c = null == z ? void 0 : z._defineProjectionName) && void 0 !== c ? c : "REFLECTIONMAP_PROJECTION"
}, {
search: /REFLECTIONMAP_SKYBOX/g,
replace: null !== (u = null == z ? void 0 : z._defineSkyboxName) && void 0 !== u ? u : "REFLECTIONMAP_SKYBOX"
}, {
search: /LODINREFLECTIONALPHA/g,
replace: null !== (h = null == z ? void 0 : z._defineLODReflectionAlpha) && void 0 !== h ? h : "LODINREFLECTIONALPHA"
}, {
search: /LINEARSPECULARREFLECTION/g,
replace: null !== (d = null == z ? void 0 : z._defineLinearSpecularReflection) && void 0 !== d ? d : "LINEARSPECULARREFLECTION"
}, {
search: /vReflectionFilteringInfo/g,
replace: null !== (p = null == z ? void 0 : z._vReflectionFilteringInfoName) && void 0 !== p ? p : "vReflectionFilteringInfo"
}]
}),
t.compilationString += t._emitCodeFromInclude("pbrBlockReflectance0", W, {
replaceStrings: [{
search: /metallicReflectanceFactors/g,
replace: this._vMetallicReflectanceFactorsName
}]
});
var Y = this.sheen.isConnected ? null === (f = this.sheen.connectedPoint) || void 0 === f ? void 0 : f.ownerBlock : null;
Y && (t.compilationString += Y.getCode(z)),
t._emitFunctionFromInclude("pbrBlockSheen", W, {
replaceStrings: [{
search: /REFLECTIONMAP_3D/g,
replace: null !== (_ = null == z ? void 0 : z._define3DName) && void 0 !== _ ? _ : "REFLECTIONMAP_3D"
}, {
search: /REFLECTIONMAP_SKYBOX/g,
replace: null !== (m = null == z ? void 0 : z._defineSkyboxName) && void 0 !== m ? m : "REFLECTIONMAP_SKYBOX"
}, {
search: /LODINREFLECTIONALPHA/g,
replace: null !== (g = null == z ? void 0 : z._defineLODReflectionAlpha) && void 0 !== g ? g : "LODINREFLECTIONALPHA"
}, {
search: /LINEARSPECULARREFLECTION/g,
replace: null !== (v = null == z ? void 0 : z._defineLinearSpecularReflection) && void 0 !== v ? v : "LINEARSPECULARREFLECTION"
}]
});
var K = this.clearcoat.isConnected ? null === (y = this.clearcoat.connectedPoint) || void 0 === y ? void 0 : y.ownerBlock : null
, Q = !this.perturbedNormal.isConnected && !this.anisotropy.isConnected
, q = this.perturbedNormal.isConnected && (null === (T = (null === (b = this.perturbedNormal.connectedPoint) || void 0 === b ? void 0 : b.ownerBlock).worldTangent) || void 0 === T ? void 0 : T.isConnected)
, Z = this.anisotropy.isConnected && (null === (E = this.anisotropy.connectedPoint) || void 0 === E ? void 0 : E.ownerBlock).worldTangent.isConnected
, J = q || !this.perturbedNormal.isConnected && Z;
t.compilationString += Ng.GetCode(t, K, z, H, Q, J, this.worldNormal.associatedVariableName),
Q && (J = null !== (S = null == K ? void 0 : K.worldTangent.isConnected) && void 0 !== S && S),
t._emitFunctionFromInclude("pbrBlockClearcoat", W, {
replaceStrings: [{
search: /computeReflectionCoords/g,
replace: "computeReflectionCoordsPBR"
}, {
search: /REFLECTIONMAP_3D/g,
replace: null !== (A = null == z ? void 0 : z._define3DName) && void 0 !== A ? A : "REFLECTIONMAP_3D"
}, {
search: /REFLECTIONMAP_OPPOSITEZ/g,
replace: null !== (x = null == z ? void 0 : z._defineOppositeZ) && void 0 !== x ? x : "REFLECTIONMAP_OPPOSITEZ"
}, {
search: /REFLECTIONMAP_PROJECTION/g,
replace: null !== (R = null == z ? void 0 : z._defineProjectionName) && void 0 !== R ? R : "REFLECTIONMAP_PROJECTION"
}, {
search: /REFLECTIONMAP_SKYBOX/g,
replace: null !== (C = null == z ? void 0 : z._defineSkyboxName) && void 0 !== C ? C : "REFLECTIONMAP_SKYBOX"
}, {
search: /LODINREFLECTIONALPHA/g,
replace: null !== (P = null == z ? void 0 : z._defineLODReflectionAlpha) && void 0 !== P ? P : "LODINREFLECTIONALPHA"
}, {
search: /LINEARSPECULARREFLECTION/g,
replace: null !== (M = null == z ? void 0 : z._defineLinearSpecularReflection) && void 0 !== M ? M : "LINEARSPECULARREFLECTION"
}, {
search: /defined\(TANGENT\)/g,
replace: J ? "defined(TANGENT)" : "defined(IGNORE)"
}]
}),
t.compilationString += t._emitCodeFromInclude("pbrBlockReflectance", W, {
replaceStrings: [{
search: /REFLECTIONMAP_SKYBOX/g,
replace: null !== (I = null == z ? void 0 : z._defineSkyboxName) && void 0 !== I ? I : "REFLECTIONMAP_SKYBOX"
}, {
search: /REFLECTIONMAP_3D/g,
replace: null !== (O = null == z ? void 0 : z._define3DName) && void 0 !== O ? O : "REFLECTIONMAP_3D"
}]
});
var $ = this.subsurface.isConnected ? null === (D = this.subsurface.connectedPoint) || void 0 === D ? void 0 : D.ownerBlock : null
, ee = this.subsurface.isConnected ? null === (L = (null === (N = this.subsurface.connectedPoint) || void 0 === N ? void 0 : N.ownerBlock).refraction.connectedPoint) || void 0 === L ? void 0 : L.ownerBlock : null;
ee && (ee.viewConnectionPoint = this.view,
ee.indexOfRefractionConnectionPoint = this.indexOfRefraction),
t.compilationString += Fg.GetCode(t, $, z, H),
t._emitFunctionFromInclude("pbrBlockSubSurface", W, {
replaceStrings: [{
search: /REFLECTIONMAP_3D/g,
replace: null !== (F = null == z ? void 0 : z._define3DName) && void 0 !== F ? F : "REFLECTIONMAP_3D"
}, {
search: /REFLECTIONMAP_OPPOSITEZ/g,
replace: null !== (w = null == z ? void 0 : z._defineOppositeZ) && void 0 !== w ? w : "REFLECTIONMAP_OPPOSITEZ"
}, {
search: /REFLECTIONMAP_PROJECTION/g,
replace: null !== (B = null == z ? void 0 : z._defineProjectionName) && void 0 !== B ? B : "REFLECTIONMAP_PROJECTION"
}, {
search: /SS_REFRACTIONMAP_3D/g,
replace: null !== (U = null == ee ? void 0 : ee._define3DName) && void 0 !== U ? U : "SS_REFRACTIONMAP_3D"
}, {
search: /SS_LODINREFRACTIONALPHA/g,
replace: null !== (V = null == ee ? void 0 : ee._defineLODRefractionAlpha) && void 0 !== V ? V : "SS_LODINREFRACTIONALPHA"
}, {
search: /SS_LINEARSPECULARREFRACTION/g,
replace: null !== (k = null == ee ? void 0 : ee._defineLinearSpecularRefraction) && void 0 !== k ? k : "SS_LINEARSPECULARREFRACTION"
}, {
search: /SS_REFRACTIONMAP_OPPOSITEZ/g,
replace: null !== (G = null == ee ? void 0 : ee._defineOppositeZ) && void 0 !== G ? G : "SS_REFRACTIONMAP_OPPOSITEZ"
}]
}),
t.compilationString += t._emitCodeFromInclude("pbrBlockDirectLighting", W),
this.light ? t.compilationString += t._emitCodeFromInclude("lightFragment", W, {
replaceStrings: [{
search: /{X}/g,
replace: this._lightId.toString()
}]
}) : t.compilationString += t._emitCodeFromInclude("lightFragment", W, {
repeatKey: "maxSimultaneousLights"
}),
t.compilationString += t._emitCodeFromInclude("pbrBlockFinalLitComponents", W),
t.compilationString += "#endif\r\n";
var te = this.ambientColor.isConnected ? this.ambientColor.associatedVariableName : "vec3(0., 0., 0.)"
, ie = rp.DEFAULT_AO_ON_ANALYTICAL_LIGHTS.toString();
-1 === ie.indexOf(".") && (ie += "."),
t.compilationString += t._emitCodeFromInclude("pbrBlockFinalUnlitComponents", W, {
replaceStrings: [{
search: /vec3 finalEmissive[\s\S]*?finalEmissive\*=vLightingIntensity\.y;/g,
replace: ""
}, {
search: /vAmbientColor/g,
replace: te + " * ambientFromScene"
}, {
search: /vAmbientInfos\.w/g,
replace: ie
}]
}),
t.compilationString += t._emitCodeFromInclude("pbrBlockFinalColorComposition", W, {
replaceStrings: [{
search: /finalEmissive/g,
replace: "vec3(0.)"
}]
}),
t.compilationString += t._emitCodeFromInclude("pbrBlockImageProcessing", W, {
replaceStrings: [{
search: /visibility/g,
replace: "1."
}]
}),
t.compilationString += t._emitCodeFromInclude("pbrDebug", W, {
replaceStrings: [{
search: /vNormalW/g,
replace: this._vNormalWName
}, {
search: /vPositionW/g,
replace: H
}, {
search: /albedoTexture\.rgb;/g,
replace: "vec3(1.);\r\ngl_FragColor.rgb = toGammaSpace(gl_FragColor.rgb);\r\n"
}]
});
for (var ne = 0, re = this._outputs; ne < re.length; ne++) {
var oe = re[ne];
if (oe.hasEndpoints) {
var ae = wg[oe.name];
if (ae) {
var se = ae[0]
, le = ae[1];
le && (t.compilationString += "#if ".concat(le, "\r\n")),
t.compilationString += "".concat(this._declareOutput(oe, t), " = ").concat(se, ";\r\n"),
le && (t.compilationString += "#else\r\n",
t.compilationString += "".concat(this._declareOutput(oe, t), " = vec3(0.);\r\n"),
t.compilationString += "#endif\r\n")
} else
console.error("There's no remapping for the ".concat(oe.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, ";\r\n"),
t += "".concat(this._codeVariableName, ".useAlphaTest = ").concat(this.useAlphaTest, ";\r\n"),
t += "".concat(this._codeVariableName, ".alphaTestCutoff = ").concat(this.alphaTestCutoff, ";\r\n"),
t += "".concat(this._codeVariableName, ".useAlphaBlending = ").concat(this.useAlphaBlending, ";\r\n"),
t += "".concat(this._codeVariableName, ".useRadianceOverAlpha = ").concat(this.useRadianceOverAlpha, ";\r\n"),
t += "".concat(this._codeVariableName, ".useSpecularOverAlpha = ").concat(this.useSpecularOverAlpha, ";\r\n"),
t += "".concat(this._codeVariableName, ".enableSpecularAntiAliasing = ").concat(this.enableSpecularAntiAliasing, ";\r\n"),
t += "".concat(this._codeVariableName, ".realTimeFiltering = ").concat(this.realTimeFiltering, ";\r\n"),
t += "".concat(this._codeVariableName, ".realTimeFilteringQuality = ").concat(this.realTimeFilteringQuality, ";\r\n"),
t += "".concat(this._codeVariableName, ".useEnergyConservation = ").concat(this.useEnergyConservation, ";\r\n"),
t += "".concat(this._codeVariableName, ".useRadianceOcclusion = ").concat(this.useRadianceOcclusion, ";\r\n"),
t += "".concat(this._codeVariableName, ".useHorizonOcclusion = ").concat(this.useHorizonOcclusion, ";\r\n"),
t += "".concat(this._codeVariableName, ".unlit = ").concat(this.unlit, ";\r\n"),
t += "".concat(this._codeVariableName, ".forceNormalForward = ").concat(this.forceNormalForward, ";\r\n"),
t += "".concat(this._codeVariableName, ".debugMode = ").concat(this.debugMode, ";\r\n"),
(t += "".concat(this._codeVariableName, ".debugLimit = ").concat(this.debugLimit, ";\r\n")) + "".concat(this._codeVariableName, ".debugFactor = ").concat(this.debugFactor, ";\r\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
}
,
t.prototype._deserialize = function(t, i, n) {
var r, o;
e.prototype._deserialize.call(this, t, i, n),
t.lightId && (this.light = i.getLightById(t.lightId)),
this.lightFalloff = null !== (r = t.lightFalloff) && void 0 !== r ? r : 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
}
,
k([Yp("Direct lights", Xp.Float, "INTENSITY", {
min: 0,
max: 1,
notifiers: {
update: !0
}
})], t.prototype, "directIntensity", void 0),
k([Yp("Environment lights", Xp.Float, "INTENSITY", {
min: 0,
max: 1,
notifiers: {
update: !0
}
})], t.prototype, "environmentIntensity", void 0),
k([Yp("Specular highlights", Xp.Float, "INTENSITY", {
min: 0,
max: 1,
notifiers: {
update: !0
}
})], t.prototype, "specularIntensity", void 0),
k([Yp("Light falloff", Xp.List, "LIGHTING & COLORS", {
notifiers: {
update: !0
},
options: [{
label: "Physical",
value: rp.LIGHTFALLOFF_PHYSICAL
}, {
label: "GLTF",
value: rp.LIGHTFALLOFF_GLTF
}, {
label: "Standard",
value: rp.LIGHTFALLOFF_STANDARD
}]
})], t.prototype, "lightFalloff", void 0),
k([Yp("Alpha Testing", Xp.Boolean, "OPACITY")], t.prototype, "useAlphaTest", void 0),
k([Yp("Alpha CutOff", Xp.Float, "OPACITY", {
min: 0,
max: 1,
notifiers: {
update: !0
}
})], t.prototype, "alphaTestCutoff", void 0),
k([Yp("Alpha blending", Xp.Boolean, "OPACITY")], t.prototype, "useAlphaBlending", void 0),
k([Yp("Radiance over alpha", Xp.Boolean, "RENDERING", {
notifiers: {
update: !0
}
})], t.prototype, "useRadianceOverAlpha", void 0),
k([Yp("Specular over alpha", Xp.Boolean, "RENDERING", {
notifiers: {
update: !0
}
})], t.prototype, "useSpecularOverAlpha", void 0),
k([Yp("Specular anti-aliasing", Xp.Boolean, "RENDERING", {
notifiers: {
update: !0
}
})], t.prototype, "enableSpecularAntiAliasing", void 0),
k([Yp("Realtime filtering", Xp.Boolean, "RENDERING", {
notifiers: {
update: !0
}
})], t.prototype, "realTimeFiltering", void 0),
k([Yp("Realtime filtering quality", Xp.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),
k([Yp("Energy Conservation", Xp.Boolean, "ADVANCED", {
notifiers: {
update: !0
}
})], t.prototype, "useEnergyConservation", void 0),
k([Yp("Radiance occlusion", Xp.Boolean, "ADVANCED", {
notifiers: {
update: !0
}
})], t.prototype, "useRadianceOcclusion", void 0),
k([Yp("Horizon occlusion", Xp.Boolean, "ADVANCED", {
notifiers: {
update: !0
}
})], t.prototype, "useHorizonOcclusion", void 0),
k([Yp("Unlit", Xp.Boolean, "ADVANCED", {
notifiers: {
update: !0
}
})], t.prototype, "unlit", void 0),
k([Yp("Force normal forward", Xp.Boolean, "ADVANCED", {
notifiers: {
update: !0
}
})], t.prototype, "forceNormalForward", void 0),
k([Yp("Debug mode", Xp.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),
k([Yp("Split position", Xp.Float, "DEBUG", {
min: -1,
max: 1,
notifiers: {
update: !0
}
})], t.prototype, "debugLimit", void 0),
k([Yp("Output factor", Xp.Float, "DEBUG", {
min: 0,
max: 5,
notifiers: {
update: !0
}
})], t.prototype, "debugFactor", void 0),
t
}(Wp);
y("BABYLON.PBRMetallicRoughnessBlock", Bg);
var Ug = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("left", Op.AutoDetect),
i.registerInput("right", Op.AutoDetect),
i.registerOutput("output", Op.BasedOnInput),
i._outputs[0]._typeConnectionSource = i._inputs[0],
i._linkConnectionTypes(0, 1),
i
}
return U(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, ");\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.ModBlock", Ug);
var Vg, kg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("row0", Op.Vector4),
i.registerInput("row1", Op.Vector4),
i.registerInput("row2", Op.Vector4),
i.registerInput("row3", Op.Vector4),
i.registerOutput("output", Op.Matrix),
i
}
return U(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 tf("row0");
e.value = new R(1,0,0,0),
e.output.connectTo(this.row0)
}
if (!this.row1.isConnected) {
var t = new tf("row1");
t.value = new R(0,1,0,0),
t.output.connectTo(this.row1)
}
if (!this.row2.isConnected) {
var i = new tf("row2");
i.value = new R(0,0,1,0),
i.output.connectTo(this.row2)
}
if (!this.row3.isConnected) {
var n = new tf("row3");
n.value = new R(0,0,0,1),
n.output.connectTo(this.row3)
}
}
,
t.prototype._buildBlock = function(t) {
e.prototype._buildBlock.call(this, t);
var i = this._outputs[0]
, n = this.row0
, r = this.row1
, o = this.row2
, a = this.row3;
return t.compilationString += this._declareOutput(i, t) + " = mat4(".concat(n.associatedVariableName, ", ").concat(r.associatedVariableName, ", ").concat(o.associatedVariableName, ", ").concat(a.associatedVariableName, ");\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.MatrixBuilder", kg),
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"
}(Vg || (Vg = {}));
var Gg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.condition = Vg.LessThan,
i.registerInput("a", Op.Float),
i.registerInput("b", Op.Float),
i.registerInput("true", Op.AutoDetect, !0),
i.registerInput("false", Op.AutoDetect, !0),
i.registerOutput("output", Op.BasedOnInput),
i._linkConnectionTypes(2, 3),
i._outputs[0]._typeConnectionSource = i._inputs[2],
i._outputs[0]._defaultConnectionPointType = Op.Float,
i
}
return U(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]
, n = this.true.isConnected ? this.true.associatedVariableName : "1.0"
, r = this.false.isConnected ? this.false.associatedVariableName : "0.0";
switch (this.condition) {
case Vg.Equal:
t.compilationString += this._declareOutput(i, t) + " = ".concat(this.a.associatedVariableName, " == ").concat(this.b.associatedVariableName, " ? ").concat(n, " : ").concat(r, ";\r\n");
break;
case Vg.NotEqual:
t.compilationString += this._declareOutput(i, t) + " = ".concat(this.a.associatedVariableName, " != ").concat(this.b.associatedVariableName, " ? ").concat(n, " : ").concat(r, ";\r\n");
break;
case Vg.LessThan:
t.compilationString += this._declareOutput(i, t) + " = ".concat(this.a.associatedVariableName, " < ").concat(this.b.associatedVariableName, " ? ").concat(n, " : ").concat(r, ";\r\n");
break;
case Vg.LessOrEqual:
t.compilationString += this._declareOutput(i, t) + " = ".concat(this.a.associatedVariableName, " <= ").concat(this.b.associatedVariableName, " ? ").concat(n, " : ").concat(r, ";\r\n");
break;
case Vg.GreaterThan:
t.compilationString += this._declareOutput(i, t) + " = ".concat(this.a.associatedVariableName, " > ").concat(this.b.associatedVariableName, " ? ").concat(n, " : ").concat(r, ";\r\n");
break;
case Vg.GreaterOrEqual:
t.compilationString += this._declareOutput(i, t) + " = ".concat(this.a.associatedVariableName, " >= ").concat(this.b.associatedVariableName, " ? ").concat(n, " : ").concat(r, ";\r\n");
break;
case Vg.Xor:
t.compilationString += this._declareOutput(i, t) + " = (mod(".concat(this.a.associatedVariableName, " + ").concat(this.b.associatedVariableName, ", 2.0) > 0.0) ? ").concat(n, " : ").concat(r, ";\r\n");
break;
case Vg.Or:
t.compilationString += this._declareOutput(i, t) + " = (min(".concat(this.a.associatedVariableName, " + ").concat(this.b.associatedVariableName, ", 1.0) > 0.0) ? ").concat(n, " : ").concat(r, ";\r\n");
break;
case Vg.And:
t.compilationString += this._declareOutput(i, t) + " = (".concat(this.a.associatedVariableName, " * ").concat(this.b.associatedVariableName, " > 0.0) ? ").concat(n, " : ").concat(r, ";\r\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, n) {
e.prototype._deserialize.call(this, t, i, n),
this.condition = t.condition
}
,
t.prototype._dumpPropertiesCode = function() {
return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".condition = BABYLON.ConditionalBlockConditions.").concat(Vg[this.condition], ";\r\n")
}
,
t
}(Wp);
y("BABYLON.ConditionalBlock", Gg);
var zg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.octaves = 6,
i.registerInput("seed", Op.AutoDetect),
i.registerInput("chaos", Op.AutoDetect, !0),
i.registerInput("offsetX", Op.Float, !0),
i.registerInput("offsetY", Op.Float, !0),
i.registerInput("offsetZ", Op.Float, !0),
i.registerOutput("output", Op.Float),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector2),
i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector3),
i._linkConnectionTypes(0, 1),
i
}
return U(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, n;
if (e.prototype._buildBlock.call(this, t),
this.seed.isConnected && this._outputs[0].hasEndpoints) {
var r = "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, r).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) === Op.Vector2 ? "vec2" : "vec3";
t.compilationString += "".concat(a, " ").concat(o, " = ").concat(this.seed.associatedVariableName, ";\r\n"),
this.offsetX.isConnected && (t.compilationString += "".concat(o, ".x += 0.1 * ").concat(this.offsetX.associatedVariableName, ";\r\n")),
this.offsetY.isConnected && (t.compilationString += "".concat(o, ".y += 0.1 * ").concat(this.offsetY.associatedVariableName, ";\r\n")),
this.offsetZ.isConnected && "vec3" === a && (t.compilationString += "".concat(o, ".z += 0.1 * ").concat(this.offsetZ.associatedVariableName, ";\r\n"));
var s;
return s = this.chaos.isConnected ? this.chaos.associatedVariableName : (null === (n = this.seed.connectedPoint) || void 0 === n ? void 0 : n.type) === Op.Vector2 ? "vec2(0., 0.)" : "vec3(0., 0., 0.)",
t.compilationString += this._declareOutput(this._outputs[0], t) + " = ".concat(r, "(").concat(o, ", ").concat(s, ");\r\n"),
this
}
}
,
t.prototype._dumpPropertiesCode = function() {
return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".octaves = ").concat(this.octaves, ";\r\n")
}
,
t.prototype.serialize = function() {
var t = e.prototype.serialize.call(this);
return t.octaves = this.octaves,
t
}
,
t.prototype._deserialize = function(t, i, n) {
e.prototype._deserialize.call(this, t, i, n),
this.octaves = t.octaves
}
,
k([Yp("Octaves", Xp.Int)], t.prototype, "octaves", void 0),
t
}(Wp);
y("BABYLON.CloudBlock", zg);
var Wg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("seed", Op.Vector2),
i.registerInput("offset", Op.Float),
i.registerInput("density", Op.Float),
i.registerOutput("output", Op.Float),
i.registerOutput("cells", Op.Float),
i
}
return U(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 n = t._getFreeVariableName("tempOutput")
, r = t._getFreeVariableName("tempCells");
return t.compilationString += "float ".concat(n, " = 0.0;\r\n"),
t.compilationString += "float ".concat(r, " = 0.0;\r\n"),
t.compilationString += "voronoi(".concat(this.seed.associatedVariableName, ", ").concat(this.offset.associatedVariableName, ", ").concat(this.density.associatedVariableName, ", ").concat(n, ", ").concat(r, ");\r\n"),
this.output.hasEndpoints && (t.compilationString += this._declareOutput(this.output, t) + " = ".concat(n, ";\r\n")),
this.cells.hasEndpoints && (t.compilationString += this._declareOutput(this.cells, t) + " = ".concat(r, ";\r\n")),
this
}
}
,
t
}(Wp);
y("BABYLON.VoronoiNoiseBlock", Wg);
var Hg = function(e) {
function t(t) {
var i = e.call(this, t, Dp.Neutral) || this;
return i.registerInput("input", Op.AutoDetect),
i.registerOutput("output", Op.BasedOnInput),
i._outputs[0]._typeConnectionSource = i._inputs[0],
i
}
return U(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];
return e.isConnected && e.connectedPoint.ownerBlock.isInput ? Dp.Vertex : 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]
, n = this._inputs[0];
return t.compilationString += this._declareOutput(i, t) + " = ".concat(n.associatedVariableName, ";\r\n"),
this
}
,
t
}(Wp);
y("BABYLON.ElbowBlock", Hg);
var Xg = function() {
function e() {}
return e.prototype.optimize = function(e, t) {}
,
e
}()
, jg = 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 n = this.mm.get(e);
void 0 === n && this.mm.set(e, n = new Map),
n.set(t, i)
}
,
e
}()
, Yg = function() {
function e(e, t, i) {
var n = this;
this._baseMaterial = e,
this._scene = null != t ? t : E.LastCreatedScene,
this._options = i,
this._subMeshToEffect = new Map,
this._subMeshToDepthWrapper = new jg,
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 && !n._meshes.has(i) && n._meshes.set(i, i.onDisposeObservable.add((function(e) {
for (var t = n._subMeshToEffect.keys(), i = t.next(); !0 !== i.done; i = t.next()) {
var r = i.value;
(null == r ? void 0 : r.getMesh()) === e && (n._subMeshToEffect.delete(r),
n._subMeshToDepthWrapper.mm.delete(r))
}
}
))),
n._subMeshToEffect.set(e.subMesh, [e.effect, n._scene.getEngine().currentRenderPassId]),
n._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
}),
e.prototype.getEffect = function(e, t, i) {
var n, r = null === (n = this._subMeshToDepthWrapper.mm.get(e)) || void 0 === n ? void 0 : n.get(t);
if (!r)
return null;
var o = r.drawWrapper[i];
return o || (o = r.drawWrapper[i] = new Gt(this._scene.getEngine())).setEffect(r.mainDrawWrapper.effect, r.mainDrawWrapper.defines),
o
}
,
e.prototype.isReadyForSubMesh = function(e, t, i, n, r) {
var o, a;
return !(this.standalone && !this._baseMaterial.isReadyForSubMesh(e.getMesh(), e, n)) && null !== (a = null === (o = this._makeEffect(e, t, i, r)) || 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
, n = i[0]
, r = i[1];
n.onDisposeObservable.remove(r)
}
}
,
e.prototype._makeEffect = function(e, t, i, n) {
var r, 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 Gt(s);
d.defines = null !== (o = null === (r = e._getDrawWrapper(u)) || void 0 === r ? void 0 : r.defines) && void 0 !== o ? o : null,
(h = {
drawWrapper: [],
mainDrawWrapper: d,
depthDefines: "",
token: fi()
}).drawWrapper[n] = 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.rawVertexSourceCode
, _ = c.rawFragmentSourceCode
, m = this._options && this._options.remappedVariables ? "#include(".concat(this._options.remappedVariables.join(","), ")") : Mt.IncludesShadersStore.shadowMapVertexNormalBias
, g = this._options && this._options.remappedVariables ? "#include(".concat(this._options.remappedVariables.join(","), ")") : Mt.IncludesShadersStore.shadowMapVertexMetric
, v = this._options && this._options.remappedVariables ? "#include(".concat(this._options.remappedVariables.join(","), ")") : Mt.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow
, y = Mt.IncludesShadersStore.shadowMapFragment;
f = (f = -1 !== (f = (f = f.replace(/void\s+?main/g, Mt.IncludesShadersStore.shadowMapVertexExtraDeclaration + "\r\nvoid main")).replace(/#define SHADOWDEPTH_NORMALBIAS|#define CUSTOM_VERTEX_UPDATE_WORLDPOS/g, m)).indexOf("#define SHADOWDEPTH_METRIC") ? f.replace(/#define SHADOWDEPTH_METRIC/g, g) : f.replace(/}\s*$/g, g + "\r\n}")).replace(/#define SHADER_NAME.*?\n|out vec4 glFragColor;\n/g, "");
var b = _.indexOf("#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW") >= 0 || _.indexOf("#define CUSTOM_FRAGMENT_BEFORE_FOG") >= 0
, T = -1 !== _.indexOf("#define SHADOWDEPTH_FRAGMENT")
, E = "";
b ? _ = _.replace(/#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW|#define CUSTOM_FRAGMENT_BEFORE_FOG/g, v) : E = v + "\r\n",
_ = _.replace(/void\s+?main/g, Mt.IncludesShadersStore.shadowMapFragmentExtraDeclaration + "\r\nvoid main"),
T ? _ = _.replace(/#define SHADOWDEPTH_FRAGMENT/g, y) : E += y + "\r\n",
E && (_ = _.replace(/}\s*$/g, E + "}")),
_ = _.replace(/#define SHADER_NAME.*?\n|out vec4 glFragColor;\n/g, "");
var S = c.getUniformNames().slice();
S.push("biasAndScaleSM", "depthValuesSM", "lightDataSM", "softTransparentShadowSM"),
h.mainDrawWrapper.effect = s.createEffect({
vertexSource: f,
fragmentSource: _,
vertexToken: h.token,
fragmentToken: h.token
}, {
attributes: c.getAttributesNames(),
uniformsNames: S,
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 A = 0; A < h.drawWrapper.length; ++A)
A !== n && (null === (a = h.drawWrapper[A]) || void 0 === a || a.setEffect(h.mainDrawWrapper.effect, h.mainDrawWrapper.defines));
return h.mainDrawWrapper.effect
}
,
e
}();
function Kg(e) {
return e instanceof rp ? new Zd(e) : null
}
function Qg(e) {
return e instanceof rp ? new Yd(e) : null
}
function qg(e) {
return e instanceof rp ? new Qd(e) : null
}
function Zg(e) {
return e instanceof rp ? new $d(e) : null
}
function Jg(e) {
return e instanceof rp ? new tp(e) : null
}
function $g(e) {
return e instanceof rp || e instanceof Os ? new Ps(e) : null
}
function ev(e, t, i, n, r, 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)),
n(f)
} finally {
e._free(p)
}
}
var _ = function(t, i, n) {
void 0 === n && (n = 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;
r(t, p)
} else {
if ((p = new Float32Array(l)).set(new Float32Array(e.HEAPF32.buffer,h,l)),
1 !== n)
for (f = 0; f < p.length; f++)
p[f] = p[f] / n;
r(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 tv() {
var e;
onmessage = function(t) {
var i = t.data;
switch (i.id) {
case "init":
var n = i.decoder;
n.url && (importScripts(n.url),
e = DracoDecoderModule({
wasmBinary: n.wasmBinary
})),
postMessage("done");
break;
case "decodeMesh":
if (!e)
throw new Error("Draco decoder module is not available");
e.then((function(e) {
ev(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 iv = function() {
function e(t) {
void 0 === t && (t = e.DefaultNumWorkers);
var i = e.Configuration.decoder
, n = i.wasmUrl && i.wasmBinaryUrl && "object" == typeof WebAssembly ? {
url: gi.GetAbsoluteUrl(i.wasmUrl),
wasmBinaryPromise: gi.LoadFileAsync(gi.GetAbsoluteUrl(i.wasmBinaryUrl))
} : {
url: gi.GetAbsoluteUrl(i.fallbackUrl),
wasmBinaryPromise: Promise.resolve(void 0)
};
t && "function" == typeof Worker ? this._workerPoolPromise = n.wasmBinaryPromise.then((function(e) {
var i = "".concat(ev, "(").concat(tv, ")()")
, r = URL.createObjectURL(new Blob([i],{
type: "application/javascript"
}));
return new vp(t,(function() {
return new Promise((function(t, i) {
var o = new Worker(r)
, 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: n.url,
wasmBinary: e
}
})
}
))
}
))
}
)) : this._decoderModulePromise = n.wasmBinaryPromise.then((function(e) {
if (!n.url)
throw new Error("Draco decoder module is not available");
return gi.LoadScriptAsync(n.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 n = e instanceof ArrayBuffer ? new Uint8Array(e) : e;
if (this._workerPoolPromise)
return this._workerPoolPromise.then((function(e) {
return new Promise((function(r, o) {
e.push((function(e, a) {
var s = new $n
, 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),
r(s),
a();
else if ("indices" === t.data.id)
s.indices = t.data.value;
else {
var n = i && i[t.data.id] ? i[t.data.id] : 1;
if (1 !== n)
for (var o = 0; o < t.data.value.length; o++)
t.data.value[o] = t.data.value[o] / n;
s.set(t.data.value, t.data.id)
}
};
e.addEventListener("error", l),
e.addEventListener("message", c);
var u = new Uint8Array(n.byteLength);
u.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength)),
e.postMessage({
id: "decodeMesh",
dataView: u,
attributes: t
}, [u.buffer])
}
))
}
))
}
));
if (this._decoderModulePromise)
return this._decoderModulePromise.then((function(e) {
var r = new $n;
return ev(e.module, n, t, (function(e) {
r.indices = e
}
), (function(e, t) {
r.set(t, e)
}
), i),
r
}
));
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
}()
, nv = function() {
function e() {
var t = e.Configuration.decoder;
this._decoderModulePromise = gi.LoadScriptAsync(gi.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, n, r) {
return this._decoderModulePromise.then((function() {
var o = new Uint8Array(t * i);
return MeshoptDecoder.decodeGltfBuffer(o, t, i, e, n, r),
o
}
))
}
,
e.Configuration = {
decoder: {
url: "https://preview.babylonjs.com/meshopt_decoder.js"
}
},
e._Default = null,
e
}()
, rv = 0
, ov = function() {
function e(e, t, i, n) {
this.pos = e,
this.normal = t,
this.uv = i,
this.vertColor = n
}
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(x.Lerp(this.pos, t.pos, i),x.Lerp(this.normal, t.normal, i),this.uv && t.uv ? A.Lerp(this.uv, t.uv, i) : void 0,this.vertColor && t.vertColor ? N.Lerp(this.vertColor, t.vertColor, i) : void 0)
}
,
e
}()
, av = function() {
function e(e, t) {
this.normal = e,
this.w = t
}
return e.FromPoints = function(t, i, n) {
var r = n.subtract(t)
, o = i.subtract(t);
if (0 === r.lengthSquared() || 0 === o.lengthSquared())
return null;
var a = x.Normalize(x.Cross(r, o));
return new e(a,x.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, n, r, o) {
var a, s, l = 0, c = [];
for (a = 0; a < t.vertices.length; a++) {
var u = (s = x.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:
(x.Dot(this.normal, t.plane.normal) > 0 ? i : n).push(t);
break;
case 1:
r.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 - x.Dot(this.normal, m.pos)) / x.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 sv(h,t.shared)).plane && r.push(y),
d.length >= 3 && (y = new sv(d,t.shared)).plane && o.push(y)
}
}
,
e.EPSILON = 1e-5,
e
}()
, sv = function() {
function e(e, t) {
this.vertices = e,
this.shared = t,
this.plane = av.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
}()
, lv = 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, n = 0; n < e.length; n++)
this._plane.splitPolygon(e[n], 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, n = new Array, r = 0; r < t.length; r++)
this._plane.splitPolygon(t[r], this._polygons, this._polygons, i, n);
i.length && (this._front || (this._front = new e),
this._front.build(i)),
n.length && (this._back || (this._back = new e),
this._back.build(n))
}
}
,
e
}()
, cv = function() {
function e() {
this._polygons = new Array
}
return e.FromMesh = function(t, i) {
void 0 === i && (i = !1);
var n, r, o, s, l, c, u, h, d, p = void 0, f = void 0, _ = new Array, m = null, g = !1;
if (!(t instanceof Vr))
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(Bi.PositionKind), b = t.getVerticesData(Bi.NormalKind), T = t.getVerticesData(Bi.UVKind), E = t.getVerticesData(Bi.ColorKind), S = t.subMeshes, R = 0, M = S.length; R < M; R++)
for (var I = S[R].indexStart, O = S[R].indexCount + S[R].indexStart; I < O; I += 3) {
l = [];
for (var D = 0; D < 3; D++) {
var L = 0 === D ? I + D : g ? I + 3 - D : I + D
, F = new x(b[3 * v[L]],b[3 * v[L] + 1],b[3 * v[L] + 2]);
T && (p = new A(T[2 * v[L]],T[2 * v[L] + 1])),
E && (f = new N(E[4 * v[L]],E[4 * v[L] + 1],E[4 * v[L] + 2],E[4 * v[L] + 3]));
var w = new x(y[3 * v[L]],y[3 * v[L] + 1],y[3 * v[L] + 2]);
o = x.TransformCoordinates(w, c),
r = x.TransformNormal(F, c),
n = new ov(o,r,p,f),
l.push(n)
}
(s = new sv(l,{
subMeshId: R,
meshId: rv,
materialIndex: S[R].materialIndex
})).plane && _.push(s)
}
var B = e._FromPolygons(_);
return B.matrix = i ? P.Identity() : c,
B.position = i ? x.Zero() : u,
B.rotation = i ? x.Zero() : h,
B.scaling = i ? x.One() : d,
B.rotationQuaternion = i && m ? C.Identity() : m,
rv++,
B
}
,
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 lv(this.clone()._polygons)
, n = new lv(t.clone()._polygons);
return i.clipTo(n),
n.clipTo(i),
n.invert(),
n.clipTo(i),
n.invert(),
i.build(n.allPolygons()),
e._FromPolygons(i.allPolygons()).copyTransformAttributes(this)
}
,
e.prototype.unionInPlace = function(e) {
var t = new lv(this._polygons)
, i = new lv(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 lv(this.clone()._polygons)
, n = new lv(t.clone()._polygons);
return i.invert(),
i.clipTo(n),
n.clipTo(i),
n.invert(),
n.clipTo(i),
n.invert(),
i.build(n.allPolygons()),
i.invert(),
e._FromPolygons(i.allPolygons()).copyTransformAttributes(this)
}
,
e.prototype.subtractInPlace = function(e) {
var t = new lv(this._polygons)
, i = new lv(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 lv(this.clone()._polygons)
, n = new lv(t.clone()._polygons);
return i.invert(),
n.clipTo(i),
n.invert(),
i.clipTo(n),
n.clipTo(i),
i.build(n.allPolygons()),
i.invert(),
e._FromPolygons(i.allPolygons()).copyTransformAttributes(this)
}
,
e.prototype.intersectInPlace = function(e) {
var t = new lv(this._polygons)
, i = new lv(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 n = this.matrix.clone();
n.invert();
var r, o, a, s = new Vr(e,t), l = [], c = [], u = [], h = null, d = null, p = x.Zero(), f = x.Zero(), _ = A.Zero(), m = new N(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[(r = g[E]).shared.meshId] || (T[r.shared.meshId] = {}),
T[r.shared.meshId][r.shared.subMeshId] || (T[r.shared.meshId][r.shared.subMeshId] = {
indexStart: 1 / 0,
indexEnd: -1 / 0,
materialIndex: r.shared.materialIndex
}),
a = T[r.shared.meshId][r.shared.subMeshId];
for (var R = 2, C = r.vertices.length; R < C; R++) {
v[0] = 0,
v[1] = R - 1,
v[2] = R;
for (var P = 0; P < 3; P++) {
p.copyFrom(r.vertices[v[P]].pos),
f.copyFrom(r.vertices[v[P]].normal),
r.vertices[v[P]].uv && (h || (h = []),
_.copyFrom(r.vertices[v[P]].uv)),
r.vertices[v[P]].vertColor && (d || (d = []),
m.copyFrom(r.vertices[v[P]].vertColor));
var M = x.TransformCoordinates(p, n)
, I = x.TransformNormal(f, n);
o = y[M.x + "," + M.y + "," + M.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] !== I.x || u[3 * o + 1] !== I.y || u[3 * o + 2] !== I.z || O || D) && (l.push(M.x, M.y, M.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[M.x + "," + M.y + "," + M.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(Bi.PositionKind, l),
s.setVerticesData(Bi.NormalKind, u),
h && s.setVerticesData(Bi.UVKind, h),
d && s.setVerticesData(Bi.ColorKind, d),
s.setIndices(c, null),
i) {
var L = 0
, F = void 0;
for (var w in s.subMeshes = new Array,
T) {
for (var B in F = -1,
T[w])
a = T[w][B],
hr.CreateFromIndices(a.materialIndex + L, a.indexStart, a.indexEnd - a.indexStart + 1, s),
F = Math.max(a.materialIndex, F);
L += ++F
}
}
return s
}
,
e.prototype.toMesh = function(e, t, i, n) {
void 0 === t && (t = null);
var r = this.buildMeshGeometry(e, i, n);
return r.material = t,
r.position.copyFrom(this.position),
r.rotation.copyFrom(this.rotation),
this.rotationQuaternion && (r.rotationQuaternion = this.rotationQuaternion.clone()),
r.scaling.copyFrom(this.scaling),
r.computeWorldMatrix(!0),
r
}
,
e
}();
Vr._GoldbergMeshParser = function(e, t) {
return uv.Parse(e, t)
}
;
var uv = 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 U(t, e),
t.prototype.relatedGoldbergFace = function(e, t) {
return void 0 === t ? (e > this.goldbergData.nbUnsharedFaces - 1 && (K.Warn("Maximum number of unshared faces used"),
e = this.goldbergData.nbUnsharedFaces - 1),
this.goldbergData.nbUnsharedFaces + e) : (e > 11 && (K.Warn("Last pole used"),
e = 11),
t > this.goldbergData.nbFacesAtPole - 1 && (K.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], n = e[t][1], r = e[t][2], o = i; o < n + 1; o++)
this.goldbergData.faceColors[o] = r;
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(Bi.ColorKind, t)
}
,
t.prototype.updateGoldbergFaceColors = function(e) {
var t = this._changeGoldbergFaceColors(e);
this.updateVerticesData(Bi.ColorKind, t)
}
,
t.prototype._changeGoldbergFaceUVs = function(e) {
for (var t = this.getVerticesData(Bi.UVKind), i = 0; i < e.length; i++) {
for (var n = e[i][0], r = 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 = n; p < Math.min(12, r + 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, n); p < r + 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(Bi.UVKind, t)
}
,
t.prototype.updateGoldbergFaceUVs = function(e) {
var t = this._changeGoldbergFaceUVs(e);
this.updateVerticesData(Bi.UVKind, t)
}
,
t.prototype.placeOnGoldbergFaceAt = function(e, t, i) {
var n = x.RotationFromAxis(this.goldbergData.faceXaxis[t], this.goldbergData.faceYaxis[t], this.goldbergData.faceZaxis[t]);
e.rotation = n,
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 n = 0, r = this.goldbergData.faceColors; n < r.length; n++) {
var o = r[n];
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 n = e.goldbergData;
n.faceColors = n.faceColors.map((function(e) {
return N.FromArray(e)
}
)),
n.faceCenters = n.faceCenters.map((function(e) {
return x.FromArray(e)
}
)),
n.faceZaxis = n.faceZaxis.map((function(e) {
return x.FromArray(e)
}
)),
n.faceXaxis = n.faceXaxis.map((function(e) {
return x.FromArray(e)
}
)),
n.faceYaxis = n.faceYaxis.map((function(e) {
return x.FromArray(e)
}
));
var r = new t(e.name,i);
return r.goldbergData = n,
r
}
,
t
}(Vr)
, hv = function(e) {
function t(t, i, n, r, o, a) {
void 0 === r && (r = 1),
void 0 === o && (o = 60),
void 0 === a && (a = !0);
var s = e.call(this, t, n) || this;
s._sectionPolygonPointsCount = 4,
s._running = !1,
s._autoStart = a,
s._generator = i,
s._diameter = r,
s._length = o,
s._sectionVectors = [],
s._sectionNormalVectors = [];
for (var l = 0; l < s._sectionPolygonPointsCount; l++)
s._sectionVectors[l] = x.Zero(),
s._sectionNormalVectors[l] = x.Zero();
return s._createMesh(),
s
}
return U(t, e),
t.prototype.getClassName = function() {
return "TrailMesh"
}
,
t.prototype._createMesh = function() {
var e = new $n
, t = []
, i = []
, n = []
, r = x.Zero();
r = this._generator instanceof Sr && 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(r.x + Math.cos(a * o) * this._diameter, r.y + Math.sin(a * o) * this._diameter, r.z);
for (a = 1; a <= this._length; a++) {
for (var s = 0; s < this._sectionPolygonPointsCount; s++)
t.push(r.x + Math.cos(s * o) * this._diameter, r.y + Math.sin(s * o) * this._diameter, r.z);
var l = t.length / 3 - 2 * this._sectionPolygonPointsCount;
for (s = 0; s < this._sectionPolygonPointsCount - 1; s++)
n.push(l + s, l + s + this._sectionPolygonPointsCount, l + s + this._sectionPolygonPointsCount + 1),
n.push(l + s, l + s + this._sectionPolygonPointsCount + 1, l + s + 1);
n.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount - 1 + this._sectionPolygonPointsCount, l + this._sectionPolygonPointsCount),
n.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount, l)
}
$n.ComputeNormals(t, n, i),
e.positions = t,
e.normals = i,
e.indices = n,
e.applyToMesh(this, !0),
this._autoStart && this.start()
}
,
t.prototype.start = function() {
var e = this;
this._running || (this._running = !0,
this._beforeRenderObserver = this.getScene().onBeforeRenderObservable.add((function() {
e.update()
}
)))
}
,
t.prototype.stop = function() {
this._beforeRenderObserver && this._running && (this._running = !1,
this.getScene().onBeforeRenderObservable.remove(this._beforeRenderObserver))
}
,
t.prototype.update = function() {
var e = this.getVerticesData(Bi.PositionKind)
, t = this.getVerticesData(Bi.NormalKind)
, i = this._generator.getWorldMatrix();
if (e && t) {
for (var n = 3 * this._sectionPolygonPointsCount; n < e.length; n++)
e[n - 3 * this._sectionPolygonPointsCount] = e[n] - t[n] / this._length * this._diameter;
for (n = 3 * this._sectionPolygonPointsCount; n < t.length; n++)
t[n - 3 * this._sectionPolygonPointsCount] = t[n];
var r = e.length - 3 * this._sectionPolygonPointsCount
, o = 2 * Math.PI / this._sectionPolygonPointsCount;
for (n = 0; n < this._sectionPolygonPointsCount; n++)
this._sectionVectors[n].copyFromFloats(Math.cos(n * o) * this._diameter, Math.sin(n * o) * this._diameter, 0),
this._sectionNormalVectors[n].copyFromFloats(Math.cos(n * o), Math.sin(n * o), 0),
x.TransformCoordinatesToRef(this._sectionVectors[n], i, this._sectionVectors[n]),
x.TransformNormalToRef(this._sectionNormalVectors[n], i, this._sectionNormalVectors[n]);
for (n = 0; n < this._sectionPolygonPointsCount; n++)
e[r + 3 * n] = this._sectionVectors[n].x,
e[r + 3 * n + 1] = this._sectionVectors[n].y,
e[r + 3 * n + 2] = this._sectionVectors[n].z,
t[r + 3 * n] = this._sectionNormalVectors[n].x,
t[r + 3 * n + 1] = this._sectionNormalVectors[n].y,
t[r + 3 * n + 2] = this._sectionNormalVectors[n].z;
this.updateVerticesData(Bi.PositionKind, e, !0, !1),
this.updateVerticesData(Bi.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.Parse = function(e, i) {
return new t(e.name,e._generator,i,e._diameter,e._length,e._autoStart)
}
,
t
}(Vr);
function dv(e) {
var t = e.pattern || Vr.NO_FLIP
, i = e.tileWidth || e.tileSize || 1
, n = e.tileHeight || e.tileSize || 1
, r = 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 / n)
, h = c - u * n
, d = i * s / 2
, p = n * 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,
r) {
case Vr.CENTER:
m -= l /= 2,
v += l;
break;
case Vr.LEFT:
v += l,
f = -l / 2;
break;
case Vr.RIGHT:
m -= l,
f = l / 2
}
switch (o) {
case Vr.CENTER:
g -= h /= 2,
y += h;
break;
case Vr.BOTTOM:
y += h,
_ = -h / 2;
break;
case Vr.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 !== Vr.ROTATE_TILE && t !== Vr.ROTATE_ROW || (E[1] = [1, 1, 0, 1, 0, 0, 1, 0]),
t !== Vr.FLIP_TILE && t !== Vr.FLIP_ROW || (E[1] = [1, 0, 0, 0, 0, 1, 1, 1]),
t !== Vr.FLIP_N_ROTATE_TILE && t !== Vr.FLIP_N_ROTATE_ROW || (E[1] = [0, 1, 1, 1, 1, 0, 0, 0]);
for (var S = [], A = [], x = [], R = 0, C = 0; C < u; C++)
for (var P = 0; P < s; P++)
b.push(P * i - d + f, C * n - p + _, 0),
b.push((P + 1) * i - d + f, C * n - p + _, 0),
b.push((P + 1) * i - d + f, (C + 1) * n - p + _, 0),
b.push(P * i - d + f, (C + 1) * n - p + _, 0),
x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
S = t === Vr.FLIP_TILE || t === Vr.ROTATE_TILE || t === Vr.FLIP_N_ROTATE_TILE ? S.concat(E[(P % 2 + C % 2) % 2]) : t === Vr.FLIP_ROW || t === Vr.ROTATE_ROW || t === Vr.FLIP_N_ROTATE_ROW ? S.concat(E[C % 2]) : S.concat(E[0]),
A.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 M = h > 0 && (o === Vr.CENTER || o === Vr.TOP)
, I = h > 0 && (o === Vr.CENTER || o === Vr.BOTTOM)
, O = l > 0 && (r === Vr.CENTER || r === Vr.RIGHT)
, D = l > 0 && (r === Vr.CENTER || r === Vr.LEFT)
, N = []
, L = void 0
, F = void 0
, w = void 0
, B = void 0;
if (M && 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),
x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
R += 4,
N = [L = 1 - l / i, F = 1 - h / n, w = 1, F, w, B = 1, L, B],
t === Vr.ROTATE_ROW && (N = [1 - L, 1 - F, 1 - w, 1 - F, 1 - w, 1 - B, 1 - L, 1 - B]),
t === Vr.FLIP_ROW && (N = [1 - L, F, 1 - w, F, 1 - w, B, 1 - L, B]),
t === Vr.FLIP_N_ROTATE_ROW && (N = [L, 1 - F, w, 1 - F, w, 1 - B, L, 1 - B]),
S = S.concat(N),
A.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, g + _, 0),
b.push(v + f, g + _, 0),
b.push(v + f, g + h + _, 0),
b.push(d + f, g + h + _, 0),
x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
R += 4,
N = [L = 0, F = 1 - h / n, w = l / i, F, w, B = 1, L, B],
(t === Vr.ROTATE_ROW || t === Vr.ROTATE_TILE && s % 2 == 0) && (N = [1 - L, 1 - F, 1 - w, 1 - F, 1 - w, 1 - B, 1 - L, 1 - B]),
(t === Vr.FLIP_ROW || t === Vr.FLIP_TILE && s % 2 == 0) && (N = [1 - L, F, 1 - w, F, 1 - w, B, 1 - L, B]),
(t === Vr.FLIP_N_ROTATE_ROW || t === Vr.FLIP_N_ROTATE_TILE && s % 2 == 0) && (N = [L, 1 - F, w, 1 - F, w, 1 - B, L, 1 - B]),
S = S.concat(N),
A.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 && 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),
x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
R += 4,
N = [L = 1 - l / i, F = 0, w = 1, F, w, B = h / n, L, B],
(t === Vr.ROTATE_ROW && u % 2 == 1 || t === Vr.ROTATE_TILE && u % 1 == 0) && (N = [1 - L, 1 - F, 1 - w, 1 - F, 1 - w, 1 - B, 1 - L, 1 - B]),
(t === Vr.FLIP_ROW && u % 2 == 1 || t === Vr.FLIP_TILE && u % 2 == 0) && (N = [1 - L, F, 1 - w, F, 1 - w, B, 1 - L, B]),
(t === Vr.FLIP_N_ROTATE_ROW && u % 2 == 1 || t === Vr.FLIP_N_ROTATE_TILE && u % 2 == 0) && (N = [L, 1 - F, w, 1 - F, w, 1 - B, L, 1 - B]),
S = S.concat(N),
A.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, p + _, 0),
b.push(v + f, p + _, 0),
b.push(v + f, y + _, 0),
b.push(d + f, y + _, 0),
x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
R += 4,
N = [L = 0, F = 0, w = l / i, F, w, B = h / n, L, B],
(t === Vr.ROTATE_ROW && u % 2 == 1 || t === Vr.ROTATE_TILE && (u + s) % 2 == 1) && (N = [1 - L, 1 - F, 1 - w, 1 - F, 1 - w, 1 - B, 1 - L, 1 - B]),
(t === Vr.FLIP_ROW && u % 2 == 1 || t === Vr.FLIP_TILE && (u + s) % 2 == 1) && (N = [1 - L, F, 1 - w, F, 1 - w, B, 1 - L, B]),
(t === Vr.FLIP_N_ROTATE_ROW && u % 2 == 1 || t === Vr.FLIP_N_ROTATE_TILE && (u + s) % 2 == 1) && (N = [L, 1 - F, w, 1 - F, w, 1 - B, L, 1 - B]),
S = S.concat(N),
A.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) {
var U = [];
for (L = 0,
F = 1 - h / n,
w = 1,
B = 1,
U[0] = [L, F, w, F, w, B, L, B],
U[1] = [L, F, w, F, w, B, L, B],
t !== Vr.ROTATE_TILE && t !== Vr.ROTATE_ROW || (U[1] = [1 - L, 1 - F, 1 - w, 1 - F, 1 - w, 1 - B, 1 - L, 1 - B]),
t !== Vr.FLIP_TILE && t !== Vr.FLIP_ROW || (U[1] = [1 - L, F, 1 - w, F, 1 - w, B, 1 - L, B]),
t !== Vr.FLIP_N_ROTATE_TILE && t !== Vr.FLIP_N_ROTATE_ROW || (U[1] = [L, 1 - F, w, 1 - F, w, 1 - B, L, 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),
x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
R += 4,
S = t === Vr.FLIP_TILE || t === Vr.ROTATE_TILE || t === Vr.FLIP_N_ROTATE_TILE ? S.concat(U[(P + 1) % 2]) : t === Vr.FLIP_ROW || t === Vr.ROTATE_ROW || t === Vr.FLIP_N_ROTATE_ROW ? S.concat(U[1]) : S.concat(U[0]),
A.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 (I) {
var V = [];
for (L = 0,
F = 0,
w = 1,
B = h / n,
V[0] = [L, F, w, F, w, B, L, B],
V[1] = [L, F, w, F, w, B, L, B],
t !== Vr.ROTATE_TILE && t !== Vr.ROTATE_ROW || (V[1] = [1 - L, 1 - F, 1 - w, 1 - F, 1 - w, 1 - B, 1 - L, 1 - B]),
t !== Vr.FLIP_TILE && t !== Vr.FLIP_ROW || (V[1] = [1 - L, F, 1 - w, F, 1 - w, B, 1 - L, B]),
t !== Vr.FLIP_N_ROTATE_TILE && t !== Vr.FLIP_N_ROTATE_ROW || (V[1] = [L, 1 - F, w, 1 - F, w, 1 - B, L, 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),
x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
R += 4,
S = t === Vr.FLIP_TILE || t === Vr.ROTATE_TILE || t === Vr.FLIP_N_ROTATE_TILE ? S.concat(V[(P + u) % 2]) : t === Vr.FLIP_ROW || t === Vr.ROTATE_ROW || t === Vr.FLIP_N_ROTATE_ROW ? S.concat(V[u % 2]) : S.concat(V[0]),
A.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 (L = 1 - l / i,
F = 0,
w = 1,
B = 1,
k[0] = [L, F, w, F, w, B, L, B],
k[1] = [L, F, w, F, w, B, L, B],
t !== Vr.ROTATE_TILE && t !== Vr.ROTATE_ROW || (k[1] = [1 - L, 1 - F, 1 - w, 1 - F, 1 - w, 1 - B, 1 - L, 1 - B]),
t !== Vr.FLIP_TILE && t !== Vr.FLIP_ROW || (k[1] = [1 - L, F, 1 - w, F, 1 - w, B, 1 - L, B]),
t !== Vr.FLIP_N_ROTATE_TILE && t !== Vr.FLIP_N_ROTATE_ROW || (k[1] = [L, 1 - F, w, 1 - F, w, 1 - B, L, 1 - B]),
C = 0; C < u; C++)
b.push(m + f, C * n - p + _, 0),
b.push(m + l + f, C * n - p + _, 0),
b.push(m + l + f, (C + 1) * n - p + _, 0),
b.push(m + f, (C + 1) * n - p + _, 0),
x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
R += 4,
S = t === Vr.FLIP_TILE || t === Vr.ROTATE_TILE || t === Vr.FLIP_N_ROTATE_TILE ? S.concat(k[(C + 1) % 2]) : t === Vr.FLIP_ROW || t === Vr.ROTATE_ROW || t === Vr.FLIP_N_ROTATE_ROW ? S.concat(k[C % 2]) : S.concat(k[0]),
A.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 (L = 0,
F = 0,
w = l / n,
B = 1,
G[0] = [L, F, w, F, w, B, L, B],
G[1] = [L, F, w, F, w, B, L, B],
t !== Vr.ROTATE_TILE && t !== Vr.ROTATE_ROW || (G[1] = [1 - L, 1 - F, 1 - w, 1 - F, 1 - w, 1 - B, 1 - L, 1 - B]),
t !== Vr.FLIP_TILE && t !== Vr.FLIP_ROW || (G[1] = [1 - L, F, 1 - w, F, 1 - w, B, 1 - L, B]),
t !== Vr.FLIP_N_ROTATE_TILE && t !== Vr.FLIP_N_ROTATE_ROW || (G[1] = [L, 1 - F, w, 1 - F, w, 1 - B, L, 1 - B]),
C = 0; C < u; C++)
b.push(v - l + f, C * n - p + _, 0),
b.push(v + f, C * n - p + _, 0),
b.push(v + f, (C + 1) * n - p + _, 0),
b.push(v - l + f, (C + 1) * n - p + _, 0),
x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
R += 4,
S = t === Vr.FLIP_TILE || t === Vr.ROTATE_TILE || t === Vr.FLIP_N_ROTATE_TILE ? S.concat(G[(C + s) % 2]) : t === Vr.FLIP_ROW || t === Vr.ROTATE_ROW || t === Vr.FLIP_N_ROTATE_ROW ? S.concat(G[C % 2]) : S.concat(G[0]),
A.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 || $n.DEFAULTSIDE;
$n._ComputeSides(z, b, x, T, S, e.frontUVs, e.backUVs);
var W = new $n;
W.indices = x,
W.positions = b,
W.normals = T,
W.uvs = S;
var H = z === $n.DOUBLESIDE ? A.concat(A) : A;
return W.colors = H,
W
}
function pv(e, t, i) {
void 0 === i && (i = null);
var n = new Vr(e,i);
return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
n._originalBuilderSideOrientation = t.sideOrientation,
dv(t).applyToMesh(n, t.updatable),
n
}
var fv = {
CreateTiledPlane: pv
};
function _v(e) {
for (var t = e.faceUV || new Array(6), i = e.faceColors, n = e.pattern || Vr.NO_FLIP, r = 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 || $n.DEFAULTSIDE, d = 0; d < 6; d++)
void 0 === t[d] && (t[d] = new R(0,0,1,1)),
i && void 0 === i[d] && (i[d] = new N(1,1,1,1));
var p = r / 2
, f = o / 2
, _ = a / 2
, m = [];
for (d = 0; d < 2; d++)
m[d] = dv({
pattern: n,
tileWidth: s,
tileHeight: l,
width: r,
height: o,
alignVertical: u,
alignHorizontal: c,
sideOrientation: h
});
for (d = 2; d < 4; d++)
m[d] = dv({
pattern: n,
tileWidth: s,
tileHeight: l,
width: a,
height: o,
alignVertical: u,
alignHorizontal: c,
sideOrientation: h
});
var g = u;
for (u === Vr.BOTTOM ? g = Vr.TOP : u === Vr.TOP && (g = Vr.BOTTOM),
d = 4; d < 6; d++)
m[d] = dv({
pattern: n,
tileWidth: s,
tileHeight: l,
width: r,
height: a,
alignVertical: g,
alignHorizontal: c,
sideOrientation: h
});
var v = []
, y = []
, b = []
, T = []
, E = []
, S = []
, A = []
, C = []
, M = 0
, I = 0;
for (d = 0; d < 6; d++) {
var O = m[d].positions.length;
S[d] = [],
A[d] = [];
for (var D = 0; D < O / 3; D++)
S[d].push(new x(m[d].positions[3 * D],m[d].positions[3 * D + 1],m[d].positions[3 * D + 2])),
A[d].push(new x(m[d].normals[3 * D],m[d].normals[3 * D + 1],m[d].normals[3 * D + 2]));
M = m[d].uvs.length,
C[d] = [];
for (var L = 0; L < M; L += 2)
C[d][L] = t[d].x + (t[d].z - t[d].x) * m[d].uvs[L],
C[d][L + 1] = t[d].y + (t[d].w - t[d].y) * m[d].uvs[L + 1],
pr.UseOpenGLOrientationForUV && (C[d][L + 1] = 1 - C[d][L + 1]);
if (b = b.concat(C[d]),
T = T.concat(m[d].indices.map((function(e) {
return e + I
}
))),
I += 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 w = new x(0,0,_)
, B = P.RotationY(Math.PI);
v = S[0].map((function(e) {
return x.TransformNormal(e, B).add(w)
}
)).map((function(e) {
return [e.x, e.y, e.z]
}
)).reduce((function(e, t) {
return e.concat(t)
}
), []),
y = A[0].map((function(e) {
return x.TransformNormal(e, B)
}
)).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(w)
}
)).map((function(e) {
return [e.x, e.y, e.z]
}
)).reduce((function(e, t) {
return e.concat(t)
}
), [])),
y = y.concat(A[1].map((function(e) {
return [e.x, e.y, e.z]
}
)).reduce((function(e, t) {
return e.concat(t)
}
), []));
var U = new x(p,0,0)
, V = P.RotationY(-Math.PI / 2);
v = v.concat(S[2].map((function(e) {
return x.TransformNormal(e, V).add(U)
}
)).map((function(e) {
return [e.x, e.y, e.z]
}
)).reduce((function(e, t) {
return e.concat(t)
}
), [])),
y = y.concat(A[2].map((function(e) {
return x.TransformNormal(e, V)
}
)).map((function(e) {
return [e.x, e.y, e.z]
}
)).reduce((function(e, t) {
return e.concat(t)
}
), []));
var k = P.RotationY(Math.PI / 2);
v = v.concat(S[3].map((function(e) {
return x.TransformNormal(e, k).subtract(U)
}
)).map((function(e) {
return [e.x, e.y, e.z]
}
)).reduce((function(e, t) {
return e.concat(t)
}
), [])),
y = y.concat(A[3].map((function(e) {
return x.TransformNormal(e, k)
}
)).map((function(e) {
return [e.x, e.y, e.z]
}
)).reduce((function(e, t) {
return e.concat(t)
}
), []));
var G = new x(0,f,0)
, z = P.RotationX(Math.PI / 2);
v = v.concat(S[4].map((function(e) {
return x.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(A[4].map((function(e) {
return x.TransformNormal(e, z)
}
)).map((function(e) {
return [e.x, e.y, e.z]
}
)).reduce((function(e, t) {
return e.concat(t)
}
), []));
var W = P.RotationX(-Math.PI / 2);
v = v.concat(S[5].map((function(e) {
return x.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(A[5].map((function(e) {
return x.TransformNormal(e, W)
}
)).map((function(e) {
return [e.x, e.y, e.z]
}
)).reduce((function(e, t) {
return e.concat(t)
}
), [])),
$n._ComputeSides(h, v, T, y, b);
var H = new $n;
if (H.indices = T,
H.positions = v,
H.normals = y,
H.uvs = b,
i) {
var X = h === $n.DOUBLESIDE ? E.concat(E) : E;
H.colors = X
}
return H
}
function mv(e, t, i) {
void 0 === i && (i = null);
var n = new Vr(e,i);
return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
n._originalBuilderSideOrientation = t.sideOrientation,
_v(t).applyToMesh(n, t.updatable),
n
}
$n.CreateTiledPlane = dv;
var gv = {
CreateTiledBox: mv
};
function vv(e) {
var t, i, n = new Array, r = 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 || $n.DEFAULTSIDE, f = function(e) {
var t = Math.cos(e)
, i = Math.sin(e)
, n = d / h * e
, r = Math.cos(n)
, o = s * (2 + r) * .5 * t
, a = s * (2 + r) * i * .5
, l = s * Math.sin(n) * .5;
return new x(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 = x.Cross(v, y);
for (y = x.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);
r.push(m.x + E * y.x + S * b.x),
r.push(m.y + E * y.y + S * b.y),
r.push(m.z + E * y.z + S * b.z),
a.push(t / c),
a.push(pr.UseOpenGLOrientationForUV ? 1 - i / u : i / u)
}
}
for (t = 0; t < c; t++)
for (i = 0; i < u; i++) {
var A = (i + 1) % u
, R = t * u + i
, C = (t + 1) * u + i
, P = (t + 1) * u + A
, M = t * u + A;
n.push(M),
n.push(C),
n.push(R),
n.push(M),
n.push(P),
n.push(C)
}
$n.ComputeNormals(r, n, o),
$n._ComputeSides(p, r, n, o, a, e.frontUVs, e.backUVs);
var I = new $n;
return I.indices = n,
I.positions = r,
I.normals = o,
I.uvs = a,
I
}
function yv(e, t, i) {
void 0 === t && (t = {});
var n = new Vr(e,i);
return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
n._originalBuilderSideOrientation = t.sideOrientation,
vv(t).applyToMesh(n, t.updatable),
n
}
$n.CreateTiledBox = _v;
var bv = {
CreateTorusKnot: yv
};
$n.CreateTorusKnot = vv,
Vr.CreateTorusKnot = function(e, t, i, n, r, o, a, s, l, c) {
return yv(e, {
radius: t,
tube: i,
radialSegments: n,
tubularSegments: r,
p: o,
q: a,
sideOrientation: c,
updatable: l
}, s)
}
;
var Tv = function(e) {
function t(t, i) {
var n = e.call(this, t.x, t.y) || this;
return n.index = i,
n
}
return U(t, e),
t
}(A)
, Ev = 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 n = new Tv(e,t.elements.length);
i.push(n),
t.elements.push(n)
}
)),
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
}()
, Sv = function() {
function e() {}
return e.Rectangle = function(e, t, i, n) {
return [new A(e,t), new A(i,t), new A(i,n), new A(e,n)]
}
,
e.Circle = function(e, t, i, n) {
void 0 === t && (t = 0),
void 0 === i && (i = 0),
void 0 === n && (n = 32);
for (var r = new Array, o = 0, a = 2 * Math.PI / n, s = 0; s < n; s++)
r.push(new A(t + Math.cos(o) * e,i + Math.sin(o) * e)),
o -= a;
return r
}
,
e.Parse = function(e) {
var t, i = e.split(/[^-+eE.\d]+/).map(parseFloat).filter((function(e) {
return !isNaN(e)
}
)), n = [];
for (t = 0; t < (2147483646 & i.length); t += 2)
n.push(new A(i[t],i[t + 1]));
return n
}
,
e.StartingAt = function(e, t) {
return Rn.StartingAt(e, t)
}
,
e
}()
, Av = function() {
function e(e, t, i, n) {
var r;
void 0 === n && (n = earcut),
this._points = new Ev,
this._outlinepoints = new Ev,
this._holes = new Array,
this._epoints = new Array,
this._eholes = new Array,
this.bjsEarcut = n,
this._name = e,
this._scene = i || E.LastCreatedScene,
r = t instanceof Rn ? t.getPoints() : t,
this._addToepoint(r),
this._points.add(r),
this._outlinepoints.add(r),
void 0 === this.bjsEarcut && K.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 n = i[t];
this._epoints.push(n.x, n.y)
}
}
,
e.prototype.addHole = function(e) {
this._points.add(e);
var t = new Ev;
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 n = new Vr(this._name,this._scene)
, r = this.buildVertexData(t, i);
return n.setVerticesData(Bi.PositionKind, r.positions, e),
n.setVerticesData(Bi.NormalKind, r.normals, e),
n.setVerticesData(Bi.UVKind, r.uvs, e),
n.setIndices(r.indices),
n
}
,
e.prototype.buildVertexData = function(e, t) {
var i = this;
void 0 === e && (e = 0),
void 0 === t && (t = 2);
var n = new $n
, r = new Array
, o = new Array
, a = new Array
, s = this._points.computeBounds();
this._points.elements.forEach((function(e) {
r.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) {
r.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, r, a, l, s, this._outlinepoints, e, !1, t),
this._holes.forEach((function(n) {
i._addSide(o, r, a, l, s, n, e, !0, t)
}
))
}
return n.indices = l,
n.positions = o,
n.normals = r,
n.uvs = a,
n
}
,
e.prototype._addSide = function(e, t, i, n, r, 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]
, _ = o.elements[(h + 2) % o.elements.length]
, g = new x(-(p.y - d.y),0,p.x - d.x)
, v = new x(-(d.y - f.y),0,d.x - f.x)
, y = new x(-(_.y - p.y),0,_.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 = x.Dot(T, b);
T = S > l ? S < m - 1 ? new x(d.x,0,d.y).subtract(new x(p.x,0,p.y)).normalize() : v.add(g).normalize() : b;
var A = x.Dot(y, g);
E = A > l ? A < m - 1 ? new x(p.x,0,p.y).subtract(new x(d.x,0,d.y)).normalize() : y.add(g).normalize() : b,
i.push(u / r.width, 0),
i.push(u / r.width, 1),
u += g.length(),
i.push(u / r.width, 0),
i.push(u / r.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 ? (n.push(c),
n.push(c + 2),
n.push(c + 1),
n.push(c + 1),
n.push(c + 2),
n.push(c + 3)) : (n.push(c),
n.push(c + 1),
n.push(c + 2),
n.push(c + 1),
n.push(c + 3),
n.push(c + 2)),
c += 4
}
}
,
e
}();
function xv(e, t, i, n, r, o, a) {
for (var s = i || new Array(3), l = n, c = [], u = a || !1, h = 0; h < 3; h++)
void 0 === s[h] && (s[h] = new R(0,0,1,1)),
l && void 0 === l[h] && (l[h] = new N(1,1,1,1));
var d = e.getVerticesData(Bi.PositionKind)
, p = e.getVerticesData(Bi.NormalKind)
, f = e.getVerticesData(Bi.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, A = 0, x = 0; x < p.length; x += 3)
Math.abs(p[x + 1]) < .001 && (A = 1),
Math.abs(p[x + 1] - 1) < .001 && (A = 0),
Math.abs(p[x + 1] + 1) < .001 && (A = 2),
S = x / 3,
1 === A ? (g = S - m,
f[2 * S] = g % 4 < 1.5 ? u ? s[A].x + (s[A].z - s[A].x) * T[Math.floor(g / 4)] / b : s[A].x : u ? s[A].x + (s[A].z - s[A].x) * T[Math.floor(g / 4) + 1] / b : s[A].z,
f[2 * S + 1] = g % 2 == 0 ? pr.UseOpenGLOrientationForUV ? 1 - s[A].w : s[A].w : pr.UseOpenGLOrientationForUV ? 1 - s[A].y : s[A].y) : (f[2 * S] = (1 - f[2 * S]) * s[A].x + f[2 * S] * s[A].z,
f[2 * S + 1] = (1 - f[2 * S + 1]) * s[A].y + f[2 * S + 1] * s[A].w,
pr.UseOpenGLOrientationForUV && (f[2 * S + 1] = 1 - f[2 * S + 1])),
l && c.push(l[A].r, l[A].g, l[A].b, l[A].a);
$n._ComputeSides(t, d, _, p, f, r, o);
var C = new $n;
if (C.indices = _,
C.positions = d,
C.normals = p,
C.uvs = f,
l) {
var P = t === $n.DOUBLESIDE ? c.concat(c) : c;
C.colors = P
}
return C
}
function Rv(e, t, i, n) {
void 0 === i && (i = null),
void 0 === n && (n = earcut),
t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation);
for (var r = t.shape, o = t.holes || [], a = t.depth || 0, s = t.smoothingThreshold || 2, l = [], c = [], u = 0; u < r.length; u++)
l[u] = new A(r[u].x,r[u].z);
l[0].equalsWithEpsilon(l[l.length - 1], 1e-8) && l.pop();
for (var h = new Av(e,l,i || E.LastCreatedScene,n), 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,
xv(f, t.sideOrientation, t.faceUV, t.faceColors, t.frontUVs, t.backUVs, t.wrap).applyToMesh(f, t.updatable),
f
}
function Cv(e, t, i, n) {
return void 0 === i && (i = null),
void 0 === n && (n = earcut),
Rv(e, t, i, n)
}
var Pv = {
ExtrudePolygon: Cv,
CreatePolygon: Rv
};
function Mv(e, t, i) {
void 0 === i && (i = null);
var n, r, 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 = Vr._GetDefaultSideOrientation(t.sideOrientation), p = t.cap || Vr.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 (r = [],
p != Vr.CAP_START && p != Vr.CAP_ALL || (r.push(new x(0,s[0].y,0)),
r.push(new x(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++)
n = new x(Math.cos(g * y) * s[v].x * l,s[v].y,Math.sin(g * y) * s[v].x * l),
r.push(n);
p != Vr.CAP_END && p != Vr.CAP_ALL || (r.push(new x(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)),
r.push(new x(0,s[s.length - 1].y,0))),
_.push(r)
}
return nc(e, {
pathArray: _,
closeArray: a,
sideOrientation: d,
updatable: h,
invertUV: m,
frontUVs: t.frontUVs,
backUVs: t.backUVs
}, i)
}
$n.CreatePolygon = xv,
Vr.CreatePolygon = function(e, t, i, n, r, o, a) {
return void 0 === a && (a = earcut),
Rv(e, {
shape: t,
holes: n,
updatable: r,
sideOrientation: o
}, i, a)
}
,
Vr.ExtrudePolygon = function(e, t, i, n, r, o, a, s) {
return void 0 === s && (s = earcut),
Cv(e, {
shape: t,
holes: r,
depth: i,
updatable: o,
sideOrientation: a
}, n, s)
}
;
var Iv = {
CreateLathe: Mv
};
function Ov(e, t, i) {
void 0 === i && (i = null);
var n = t.path
, r = t.instance
, o = 1;
void 0 !== t.radius ? o = t.radius : r && (o = r._creationDataStorage.radius);
var a = t.tessellation || 64
, s = t.radiusFunction || null
, l = t.cap || Vr.NO_CAP
, c = t.invertUV || !1
, u = t.updatable
, h = Vr._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, n, r, o, a, s) {
for (var l, c, u, h, d = t.getTangents(), p = t.getNormals(), f = t.getDistances(), _ = 2 * Math.PI / r * s, m = o || function() {
return n
}
, g = I.Matrix[0], v = a === Vr.NO_CAP || a === Vr.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 < r; b++)
P.RotationAxisToRef(d[y], _ * b, g),
h = l[b] ? l[b] : x.Zero(),
x.TransformCoordinatesToRef(u, g, h),
h.scaleInPlace(c).addInPlace(e[y]),
l[b] = h;
i[v] = l,
v++
}
var T = function(t, i) {
for (var n = Array(), r = 0; r < t; r++)
n.push(e[i]);
return n
};
switch (a) {
case Vr.NO_CAP:
break;
case Vr.CAP_START:
i[0] = T(r, 0),
i[1] = i[2].slice(0);
break;
case Vr.CAP_END:
i[v] = i[v - 1].slice(0),
i[v + 1] = T(r, e.length - 1);
break;
case Vr.CAP_ALL:
i[0] = T(r, 0),
i[1] = i[2].slice(0),
i[v] = i[v - 1].slice(0),
i[v + 1] = T(r, e.length - 1)
}
return i
};
if (r) {
var _ = r._creationDataStorage
, m = t.arc || _.arc;
return r = nc("", {
pathArray: p = f(n, d = _.path3D.update(n), _.pathArray, o, _.tessellation, s, _.cap, m),
instance: r
}),
_.path3D = d,
_.pathArray = p,
_.arc = m,
_.radius = o,
r
}
l = l < 0 || l > 3 ? 0 : l;
var g = nc(e, {
pathArray: p = f(n, d = new Cn(n), 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
}
Vr.CreateLathe = function(e, t, i, n, r, o, a) {
return Mv(e, {
shape: t,
radius: i,
tessellation: n,
sideOrientation: a,
updatable: o
}, r)
}
;
var Dv = {
CreateTube: Ov
};
function Nv(e) {
var t, i = e.sideOrientation || $n.DEFAULTSIDE, n = e.radius || 1, r = void 0 === e.flat || e.flat, o = e.subdivisions || 4, a = e.radiusX || n, s = e.radiusY || n, l = e.radiusZ || n, 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] = x.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().scaleInPlace(n),
T[t].copyFromFloats(.134765625 * p[2 * S] + .05859375 + -.0390625 * f[E], .2333984375 * p[2 * S + 1] + .025390625 + .01953125 * f[E])
}
for (var R = function(e, t, i, n) {
var c, u = x.Lerp(b[0], b[2], t / o), h = x.Lerp(b[1], b[2], t / o), d = o === t ? b[2] : x.Lerp(u, h, e / (o - t));
if (d.normalize(),
r) {
var p = x.Lerp(b[0], b[2], n / o)
, f = x.Lerp(b[1], b[2], n / o);
c = x.Lerp(p, f, i / (o - n))
} else
c = new x(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)
, R = 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(R.x, pr.UseOpenGLOrientationForUV ? 1 - R.y : R.y),
_.push(y),
y++
}, C = 0; C < o; C++)
for (var P = 0; P + C < o; P++)
R(P, C, P + 1 / 3, C + 1 / 3),
R(P + 1, C, P + 1 / 3, C + 1 / 3),
R(P, C + 1, P + 1 / 3, C + 1 / 3),
P + C + 1 < o && (R(P + 1, C, P + 2 / 3, C + 2 / 3),
R(P + 1, C + 1, P + 2 / 3, C + 2 / 3),
R(P, C + 1, P + 2 / 3, C + 2 / 3))
}
$n._ComputeSides(i, m, _, g, v, e.frontUVs, e.backUVs);
var M = new $n;
return M.indices = _,
M.positions = m,
M.normals = g,
M.uvs = v,
M
}
function Lv(e, t, i) {
void 0 === t && (t = {}),
void 0 === i && (i = null);
var n = new Vr(e,i);
return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
n._originalBuilderSideOrientation = t.sideOrientation,
Nv(t).applyToMesh(n, t.updatable),
n
}
Vr.CreateTube = function(e, t, i, n, r, o, a, s, l, c) {
return Ov(e, {
path: t,
radius: i,
tessellation: n,
radiusFunction: r,
arc: 1,
cap: o,
updatable: s,
sideOrientation: l,
instance: c
}, a)
}
;
var Fv = {
CreateIcoSphere: Lv
};
function wv(e, t, i) {
var n = t.getIndices()
, r = t.getVerticesData(Bi.PositionKind)
, o = t.getVerticesData(Bi.NormalKind)
, a = t.getVerticesData(Bi.UVKind)
, s = i.position || x.Zero()
, l = i.normal || x.Up()
, c = i.size || x.One()
, u = i.angle || 0;
if (!l) {
var h = new x(0,0,1)
, d = t.getScene().activeCamera
, p = x.TransformCoordinates(h, d.getWorldMatrix());
l = d.globalPosition.subtract(p)
}
var f = -Math.atan2(l.z, l.x) - Math.PI / 2
, _ = Math.sqrt(l.x * l.x + l.z * l.z)
, m = Math.atan2(l.y, _)
, g = P.RotationYawPitchRoll(f, m, u).multiply(P.Translation(s.x, s.y, s.z))
, v = P.Invert(g)
, y = t.getWorldMatrix().multiply(v)
, b = new $n;
b.indices = [],
b.positions = [],
b.normals = [],
b.uvs = [];
for (var T = 0, E = function(e) {
var t = new Ec;
if (!n || !r || !o)
return t;
var s = n[e];
if (t.position = new x(r[3 * s],r[3 * s + 1],r[3 * s + 2]),
t.position = x.TransformCoordinates(t.position, y),
t.normal = new x(o[3 * s],o[3 * s + 1],o[3 * s + 2]),
t.normal = x.TransformNormal(t.normal, y),
i.captureUVS && a) {
var l = a[2 * s + 1];
t.uv = new A(a[2 * s],pr.UseOpenGLOrientationForUV ? 1 - l : l)
}
return t
}, S = function(e, t) {
if (0 === e.length)
return e;
for (var i = .5 * Math.abs(x.Dot(c, t)), n = function(e, n) {
var r = x.GetClipFactor(e.position, n.position, t, i);
return new Ec(x.Lerp(e.position, n.position, r),x.Lerp(e.normal, n.normal, r))
}, r = new Array, o = 0; o < e.length; o += 3) {
var a = null
, s = null
, l = null
, u = null
, h = x.Dot(e[o].position, t) - i > 0
, d = x.Dot(e[o + 1].position, t) - i > 0
, p = x.Dot(e[o + 2].position, t) - i > 0;
switch ((h ? 1 : 0) + (d ? 1 : 0) + (p ? 1 : 0)) {
case 0:
r.push(e[o]),
r.push(e[o + 1]),
r.push(e[o + 2]);
break;
case 1:
if (h && (a = e[o + 1],
s = e[o + 2],
l = n(e[o], a),
u = n(e[o], s)),
d) {
a = e[o],
s = e[o + 2],
l = n(e[o + 1], a),
u = n(e[o + 1], s),
r.push(l),
r.push(s.clone()),
r.push(a.clone()),
r.push(s.clone()),
r.push(l.clone()),
r.push(u);
break
}
p && (a = e[o],
s = e[o + 1],
l = n(e[o + 2], a),
u = n(e[o + 2], s)),
a && s && l && u && (r.push(a.clone()),
r.push(s.clone()),
r.push(l),
r.push(u),
r.push(l.clone()),
r.push(s.clone()));
break;
case 2:
h || (s = n(a = e[o].clone(), e[o + 1]),
l = n(a, e[o + 2]),
r.push(a),
r.push(s),
r.push(l)),
d || (s = n(a = e[o + 1].clone(), e[o + 2]),
l = n(a, e[o]),
r.push(a),
r.push(s),
r.push(l)),
p || (s = n(a = e[o + 2].clone(), e[o]),
l = n(a, e[o + 1]),
r.push(a),
r.push(s),
r.push(l))
}
}
return r
}, R = 0; R < n.length; R += 3) {
var C = new Array;
if (C.push(E(R)),
C.push(E(R + 1)),
C.push(E(R + 2)),
C = S(C, new x(1,0,0)),
C = S(C, new x(-1,0,0)),
C = S(C, new x(0,1,0)),
C = S(C, new x(0,-1,0)),
C = S(C, new x(0,0,1)),
0 !== (C = S(C, new x(0,0,-1))).length)
for (var M = 0; M < C.length; M++) {
var I = C[M];
if (b.indices.push(T),
I.position.toArray(b.positions, 3 * T),
I.normal.toArray(b.normals, 3 * T),
i.captureUVS)
I.uv.toArray(b.uvs, 2 * T);
else {
b.uvs.push(.5 + I.position.x / c.x);
var O = .5 + I.position.y / c.y;
b.uvs.push(pr.UseOpenGLOrientationForUV ? 1 - O : O)
}
T++
}
}
var D = new Vr(e,t.getScene());
return b.applyToMesh(D),
D.position = s.clone(),
D.rotation = new x(m,f,u),
D
}
$n.CreateIcoSphere = Nv,
Vr.CreateIcoSphere = function(e, t, i) {
return Lv(e, t, i)
}
;
var Bv = {
CreateDecal: wv
};
Vr.CreateDecal = function(e, t, i, n, r, o) {
return wv(e, t, {
position: i,
normal: n,
size: r,
angle: o
})
}
;
var Uv = 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),
K.Warn("x is not an integer, floor(x) used")),
t !== Math.floor(t) && (Math.floor(t),
K.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),
K.Warn("m not an integer only floor(m) used")),
t !== Math.floor(t) && (Math.floor(t),
K.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),
K.Warn("m is not an integer, floor(m) used")),
t !== Math.floor(t) && (Math.floor(t),
K.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 = x.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
}()
, Vv = 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 kv("icosahedron","Regular",[[0, _, -1], [-_, 1, 0], [-1, 0, -_], [1, 0, -_], [_, 1, 0], [0, _, 1], [-1, 0, _], [-_, -1, 0], [0, -_, -1], [_, -1, 0], [1, 0, _], [0, -_, 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, n, r, o, a, s = 12, l = {}, c = this.m, u = this.n, h = c;
0 !== u && (h = d.HCF(c, u)),
e = c / h,
t = u / h;
var p, f, _, m = Uv.Zero(), g = new Uv(c,u), v = new Uv(-u,c + u), y = Uv.Zero(), b = Uv.Zero(), T = Uv.Zero(), E = [], S = [], A = this.vertByDist, x = function(e, t, i, n) {
f = t + "|" + n,
(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++),
A[i][0] > 2 ? S[l[p]] = [-A[i][0], A[i][1], l[p]] : S[l[p]] = [E[A[i][0]], A[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 (r = (E = this.IDATA.face[R])[2],
o = E[1],
a = E[0],
_ = m.x + "|" + m.y,
(p = R + "|" + _)in l || (l[p] = r,
S[r] = [E[A[_][0]], A[_][1]]),
_ = g.x + "|" + g.y,
(p = R + "|" + _)in l || (l[p] = o,
S[o] = [E[A[_][0]], A[_][1]]),
_ = v.x + "|" + v.y,
(p = R + "|" + _)in l || (l[p] = a,
S[a] = [E[A[_][0]], A[_][1]]),
i = this.IDATA.edgematch[R][0],
"B" === (n = this.IDATA.edgematch[R][1]))
for (var C = 1; C < h; C++)
b.x = c - C * (e + t),
b.y = u + C * e,
T.x = -C * t,
T.y = C * (e + t),
x(R, i, _ = b.x + "|" + b.y, T.x + "|" + T.y);
if ("O" === n)
for (C = 1; C < h; C++)
T.x = -C * t,
T.y = C * (e + t),
y.x = C * e,
y.y = C * t,
x(R, i, _ = T.x + "|" + T.y, y.x + "|" + y.y);
if (i = this.IDATA.edgematch[R][2],
(n = this.IDATA.edgematch[R][3]) && "A" === n)
for (C = 1; C < h; C++)
y.x = C * e,
y.y = C * t,
b.x = c - (h - C) * (e + t),
b.y = u + (h - C) * e,
x(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++,
A[_][0] > 2 ? S[l[p]] = [-A[_][0], A[_][1], l[p]] : S[l[p]] = [E[A[_][0]], A[_][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
, n = e * e + t * t + e * t;
this.coau = (e + t) / n,
this.cobu = -t / n,
this.coav = -i * (e - t) / n,
this.cobv = i * (2 * e + t) / n
}
,
e.prototype.createInnerFacets = function() {
for (var e = this.m, t = this.n, i = 0; i < t + e + 1; i++)
for (var n = this.min[i]; n < this.max[i] + 1; n++)
n < this.max[i] && n < this.max[i + 1] + 1 && this.innerFacets.push(["|" + n + "|" + i, "|" + n + "|" + (i + 1), "|" + (n + 1) + "|" + i]),
i > 0 && n < this.max[i - 1] && n + 1 < this.max[i] + 1 && this.innerFacets.push(["|" + n + "|" + i, "|" + (n + 1) + "|" + i, "|" + (n + 1) + "|" + (i - 1)])
}
,
e.prototype.edgeVecsABOB = function() {
for (var e = this.m, t = this.n, i = new Uv(-t,e + t), n = 1; n < e + t; n++) {
var r = new Uv(this.min[n],n)
, o = new Uv(this.min[n - 1],n - 1)
, a = new Uv(this.min[n + 1],n + 1)
, s = r.clone()
, l = o.clone()
, c = a.clone();
s.rotate60About(i),
l.rotate60About(i),
c.rotate60About(i);
var u = new Uv(this.max[s.y],s.y)
, h = new Uv(this.max[s.y - 1],s.y - 1)
, d = new Uv(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([r, h, d]),
this.vertexTypes.push([1, 0, 0]),
this.isoVecsABOB.push([r, d, u])) : s.y === c.y ? (this.vertexTypes.push([1, 1, 0]),
this.isoVecsABOB.push([r, o, h]),
this.vertexTypes.push([1, 0, 1]),
this.isoVecsABOB.push([r, h, a])) : (this.vertexTypes.push([1, 1, 0]),
this.isoVecsABOB.push([r, o, h]),
this.vertexTypes.push([1, 0, 0]),
this.isoVecsABOB.push([r, h, u])))
}
}
,
e.prototype.mapABOBtoOBOA = function() {
for (var e = new Uv(0,0), t = 0; t < this.isoVecsABOB.length; t++) {
for (var i = [], n = 0; n < 3; n++)
e.x = this.isoVecsABOB[t][n].x,
e.y = this.isoVecsABOB[t][n].y,
0 === this.vertexTypes[t][n] && e.rotateNeg120(this.m, this.n),
i.push(e.clone());
this.isoVecsOBOA.push(i)
}
}
,
e.prototype.mapABOBtoBAOA = function() {
for (var e = new Uv(0,0), t = 0; t < this.isoVecsABOB.length; t++) {
for (var i = [], n = 0; n < 3; n++)
e.x = this.isoVecsABOB[t][n].x,
e.y = this.isoVecsABOB[t][n].y,
1 === this.vertexTypes[t][n] && e.rotate120(this.m, this.n),
i.push(e.clone());
this.isoVecsBAOA.push(i)
}
}
,
e.prototype.MapToFace = function(e, t) {
for (var i, n = this.IDATA.face[e], r = n[2], o = n[1], a = n[0], s = x.FromArray(this.IDATA.vertex[r]), l = x.FromArray(this.IDATA.vertex[o]), c = x.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 = [], _ = I.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
, n = Uv.Zero()
, r = new Uv(e,t)
, o = new Uv(-t,e + t);
i.push(n, r, o);
for (var a = t; a < e + 1; a++)
for (var s = 0; s < e + 1 - a; s++)
i.push(new Uv(s,a));
if (t > 0) {
for (var l = d.HCF(e, t), c = e / l, u = t / l, h = 1; h < l; h++)
i.push(new Uv(h * c,h * u)),
i.push(new Uv(-h * u,h * (c + u))),
i.push(new Uv(e - h * (c + u),t + h * c));
for (var p = e / t, f = 1; f < t; f++)
for (var _ = 0; _ < f * p; _++)
i.push(new Uv(_,f)),
i.push(new Uv(_,f).rotate120(e, t)),
i.push(new Uv(_,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 (h = 0; h < m.length; h++)
m[h] = 1 / 0,
g[h] = -1 / 0;
var v = 0
, y = 0
, b = i.length;
for (h = 0; h < b; h++)
y = i[h].x,
m[v = i[h].y] = Math.min(y, m[v]),
g[v] = Math.max(y, g[v]);
var T = function(i, n) {
var r = i.clone();
return "A" === n && r.rotateNeg120(e, t),
"B" === n && r.rotate120(e, t),
r.x < 0 ? r.y : r.x + r.y
}
, E = []
, S = []
, A = []
, x = []
, R = {}
, C = []
, P = -1
, M = -1;
for (h = 0; h < b; h++)
E[h] = i[h].toCartesianOrigin(new Uv(0,0), .5),
S[h] = T(i[h], "O"),
A[h] = T(i[h], "A"),
x[h] = T(i[h], "B"),
S[h] === A[h] && A[h] === x[h] ? (P = 3,
M = S[h]) : S[h] === A[h] ? (P = 4,
M = S[h]) : A[h] === x[h] ? (P = 5,
M = A[h]) : x[h] === S[h] && (P = 6,
M = S[h]),
S[h] < A[h] && S[h] < x[h] && (P = 2,
M = S[h]),
A[h] < S[h] && A[h] < x[h] && (P = 1,
M = A[h]),
x[h] < A[h] && x[h] < S[h] && (P = 0,
M = x[h]),
C.push([P, M, i[h].x, i[h].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 I = 0; I < C.length; I++)
R[C[I][2] + "|" + C[I][3]] = [C[I][0], C[I][1], I];
return this.m = e,
this.n = t,
this.vertices = i,
this.vertByDist = R,
this.cartesian = E,
this.min = m,
this.max = g,
this
}
,
e
}()
, kv = function(e, t, i, n) {
this.name = e,
this.category = t,
this.vertex = i,
this.face = n
}
, Gv = function(e) {
function t() {
return null !== e && e.apply(this, arguments) || this
}
return U(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], n = 0; n < t.isoVecsABOB.length; n++) {
for (var r = [], o = 0; o < 3; o++)
0 === t.vertexTypes[n][o] ? r.push(e + "|" + t.isoVecsABOB[n][o].x + "|" + t.isoVecsABOB[n][o].y) : r.push(i + "|" + t.isoVecsABOB[n][o].x + "|" + t.isoVecsABOB[n][o].y);
this.face.push([t.vecToidx[r[0]], t.vecToidx[r[1]], t.vecToidx[r[2]]])
}
}
,
t.prototype.mapOBOAtoDATA = function(e, t) {
for (var i = t.IDATA.edgematch[e][0], n = 0; n < t.isoVecsOBOA.length; n++) {
for (var r = [], o = 0; o < 3; o++)
1 === t.vertexTypes[n][o] ? r.push(e + "|" + t.isoVecsOBOA[n][o].x + "|" + t.isoVecsOBOA[n][o].y) : r.push(i + "|" + t.isoVecsOBOA[n][o].x + "|" + t.isoVecsOBOA[n][o].y);
this.face.push([t.vecToidx[r[0]], t.vecToidx[r[1]], t.vecToidx[r[2]]])
}
}
,
t.prototype.mapBAOAtoDATA = function(e, t) {
for (var i = t.IDATA.edgematch[e][2], n = 0; n < t.isoVecsBAOA.length; n++) {
for (var r = [], o = 0; o < 3; o++)
1 === t.vertexTypes[n][o] ? r.push(e + "|" + t.isoVecsBAOA[n][o].x + "|" + t.isoVecsBAOA[n][o].y) : r.push(i + "|" + t.isoVecsBAOA[n][o].x + "|" + t.isoVecsBAOA[n][o].y);
this.face.push([t.vecToidx[r[0]], t.vecToidx[r[1]], t.vecToidx[r[2]]])
}
}
,
t.prototype.orderData = function(e) {
for (var t = [], i = 0; i < 13; i++)
t[i] = [];
var n = e.closestTo;
for (i = 0; i < n.length; i++)
n[i][0] > -1 ? n[i][1] > 0 && t[n[i][0]].push([i, n[i][1]]) : t[12].push([i, n[i][0]]);
var r = [];
for (i = 0; i < 12; i++)
r[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++)
r[t[i][a][0]] = o++
}
for (a = 0; a < t[12].length; a++)
r[t[12][a][0]] = o++;
for (i = 0; i < this.vertex.length; i++)
this.vertex[i].push(r[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] = r[this.face[i][a]];
this.sharedNodes = t[12].length,
this.poleNodes = this.vertex.length - this.sharedNodes
}
,
t.prototype.setOrder = function(e, t) {
var i = []
, n = []
, r = t.pop();
n.push(r);
var o = this.face[r].indexOf(e);
o = (o + 2) % 3;
var a = this.face[r][o];
i.push(a);
for (var s = 0; t.length > 0; )
r = t[s],
this.face[r].indexOf(a) > -1 ? (o = (this.face[r].indexOf(a) + 1) % 3,
a = this.face[r][o],
i.push(a),
n.push(r),
t.splice(s, 1),
s = 0) : s++;
return this.adjacentFaces.push(i),
n
}
,
t.prototype.toGoldbergPolyhedronData = function() {
var e = this
, t = new kv("GeoDual","Goldberg",[],[]);
t.name = "GD dual";
for (var i = this.vertex.length, n = new Array(i), r = 0; r < i; r++)
n[r] = [];
for (var o = 0; o < this.face.length; o++)
for (var a = 0; a < 3; a++)
n[this.face[o][a]].push(o);
var s = 0
, l = 0
, c = 0
, u = []
, h = [];
this.adjacentFaces = [];
for (var d = 0; d < n.length; d++)
t.face[d] = this.setOrder(d, n[d].concat([])),
n[d].forEach((function(i) {
s = 0,
l = 0,
c = 0,
u = e.face[i];
for (var n = 0; n < 3; n++)
h = e.vertex[u[n]],
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, _, -1], [-_, 1, 0], [-1, 0, -_], [1, 0, -_], [_, 1, 0], [0, _, 1], [-1, 0, _], [-_, -1, 0], [0, -_, -1], [_, -1, 0], [1, 0, _], [0, -_, 1]],[]);
e.setIndices(),
e.calcCoeffs(),
e.createInnerFacets(),
e.edgeVecsABOB(),
e.mapABOBtoOBOA(),
e.mapABOBtoBAOA();
for (var n = 0; n < e.IDATA.face.length; n++)
e.MapToFace(n, i),
i.innerToData(n, e),
"B" === e.IDATA.edgematch[n][1] && i.mapABOBtoDATA(n, e),
"O" === e.IDATA.edgematch[n][1] && i.mapOBOAtoDATA(n, e),
"A" === e.IDATA.edgematch[n][3] && i.mapBAOAtoDATA(n, e);
return i.orderData(e),
i.vertex = i.vertex.map((function(e) {
var t = e[0]
, i = e[1]
, n = e[2]
, r = Math.sqrt(t * t + i * i + n * n);
return e[0] *= 1 / r,
e[1] *= 1 / r,
e[2] *= 1 / r,
e
}
)),
i
}
,
t
}(kv);
function zv(e, t, i) {
void 0 === i && (i = null);
var n = t.m || 1;
n !== Math.floor(n) && (Math.floor(n),
K.Warn("m not an integer only floor(m) used"));
var r = t.n || 0;
if (r !== Math.floor(r) && (Math.floor(r),
K.Warn("n not an integer only floor(n) used")),
r > n) {
var o = r;
r = n,
n = o,
K.Warn("n > m therefore m and n swapped")
}
var a = new Vv;
return a.build(n, r),
Td(e, {
custom: Gv.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)
}
function Wv(e, t) {
for (var i = e.size, n = e.sizeX || i || 1, r = e.sizeY || i || 1, o = e.sizeZ || i || 1, a = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.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] * n),
d = Math.max(d, t.vertex[_][0] * n),
p = Math.min(p, t.vertex[_][1] * r),
f = Math.max(f, t.vertex[_][1] * r);
for (var m = 0, g = 0; g < t.face.length; g++) {
var v = t.face[g]
, y = x.FromArray(t.vertex[v[0]])
, b = x.FromArray(t.vertex[v[2]])
, T = x.FromArray(t.vertex[v[1]])
, E = b.subtract(y)
, S = T.subtract(y)
, A = x.Cross(S, E).normalize();
for (_ = 0; _ < v.length; _++) {
c.push(A.x, A.y, A.z);
var R = t.vertex[v[_]];
s.push(R[0] * n, R[1] * r, R[2] * o);
var C = (R[1] * r - p) / (f - p);
u.push((R[0] * n - h) / (d - h), pr.UseOpenGLOrientationForUV ? 1 - C : C)
}
for (_ = 0; _ < v.length - 2; _++)
l.push(m, m + _ + 2, m + _ + 1);
m += v.length
}
$n._ComputeSides(a, s, l, c, u);
var P = new $n;
return P.positions = s,
P.indices = l,
P.normals = c,
P.uvs = u,
P
}
function Hv(e, t, i) {
void 0 === i && (i = null);
var n = t.size
, r = t.sizeX || n || 1
, o = t.sizeY || n || 1
, a = t.sizeZ || n || 1
, s = t.m || 1;
s !== Math.floor(s) && (Math.floor(s),
K.Warn("m not an integer only floor(m) used"));
var l = t.n || 0;
if (l !== Math.floor(l) && (Math.floor(l),
K.Warn("n not an integer only floor(n) used")),
l > s) {
var c = l;
l = s,
s = c,
K.Warn("n > m therefore m and n swapped")
}
var u = new Vv;
u.build(s, l);
var h = Gv.BuildGeodesicData(u)
, d = h.toGoldbergPolyhedronData()
, p = new uv(e,i);
t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
p._originalBuilderSideOrientation = t.sideOrientation,
Wv(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(x.FromArray(h.vertex[f])),
p.goldbergData.faceCenters[f].x *= r,
p.goldbergData.faceCenters[f].y *= o,
p.goldbergData.faceCenters[f].z *= a,
p.goldbergData.faceColors.push(new N(1,1,1,1));
for (f = 0; f < d.face.length; f++) {
var _ = d.face[f]
, m = x.FromArray(d.vertex[_[0]])
, g = x.FromArray(d.vertex[_[2]])
, v = x.FromArray(d.vertex[_[1]])
, y = g.subtract(m)
, b = v.subtract(m)
, T = x.Cross(b, y).normalize()
, E = x.Cross(b, T).normalize();
p.goldbergData.faceXaxis.push(b.normalize()),
p.goldbergData.faceYaxis.push(T),
p.goldbergData.faceZaxis.push(E)
}
return p
}
Vr.CreateGoldberg = Hv;
var Xv, jv = {
CreateBox: Ml,
CreateTiledBox: mv,
CreateSphere: Dl,
CreateDisc: Pd,
CreateIcoSphere: Lv,
CreateRibbon: nc,
CreateCylinder: Ys,
CreateTorus: qs,
CreateTorusKnot: yv,
CreateLineSystem: Zl,
CreateLines: Jl,
CreateDashedLines: $l,
ExtrudeShape: oc,
ExtrudeShapeCustom: ac,
CreateLathe: Mv,
CreateTiledPlane: pv,
CreatePlane: vo,
CreateGround: il,
CreateTiledGround: nl,
CreateGroundFromHeightMap: rl,
CreatePolygon: Rv,
ExtrudePolygon: Cv,
CreateTube: Ov,
CreatePolyhedron: Td,
CreateGeodesic: zv,
CreateGoldberg: Hv,
CreateDecal: wv,
CreateCapsule: Gl
}, Yv = function(e, t, i) {
this.quality = e,
this.distance = t,
this.optimizeMesh = i
}, Kv = 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(n) {
void 0 !== i.distance && e.mesh.addLODLevel(i.distance, n),
n.isVisible = !0,
i.quality === e.settings[e.settings.length - 1].quality && e.successCallback && e.successCallback(),
t.executeNext()
}
))
}
));
else {
var i = this._getSimplifier(e);
yi.Run(e.settings.length, (function(t) {
var n, r;
n = e.settings[t.index],
r = function() {
t.executeNext()
}
,
i.simplify(n, (function(t) {
void 0 !== n.distance && e.mesh.addLODLevel(n.distance, t),
t.isVisible = !0,
r()
}
))
}
), (function() {
e.successCallback && e.successCallback(),
t.executeNext()
}
))
}
}
,
e.prototype._getSimplifier = function(e) {
return e.simplificationType,
Xv.QUADRATIC,
new $v(e.mesh)
}
,
e
}();
!function(e) {
e[e.QUADRATIC = 0] = "QUADRATIC"
}(Xv || (Xv = {}));
var Qv = function(e) {
this._vertices = e,
this.error = new Array(4),
this.deleted = !1,
this.isDirty = !1,
this.deletePending = !1,
this.borderFactor = 0
}
, qv = function() {
function e(e, t) {
this.position = e,
this.id = t,
this.isBorder = !0,
this.q = new Zv,
this.triangleCount = 0,
this.triangleStart = 0,
this.originalOffsets = []
}
return e.prototype.updatePosition = function(e) {
this.position.copyFrom(e)
}
,
e
}()
, Zv = 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, n, r, o, a, s, l) {
return this.data[e] * this.data[r] * this.data[l] + this.data[i] * this.data[n] * this.data[s] + this.data[t] * this.data[o] * this.data[a] - this.data[i] * this.data[r] * this.data[a] - this.data[e] * this.data[o] * this.data[s] - this.data[t] * this.data[n] * 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, n = 0; n < 10; ++n)
i.data[n] = this.data[n] + t.data[n];
return i
}
,
e.FromData = function(t, i, n, r) {
return new e(e.DataFromNumbers(t, i, n, r))
}
,
e.DataFromNumbers = function(e, t, i, n) {
return [e * e, e * t, e * i, e * n, t * t, t * i, t * n, i * i, i * n, n * n]
}
,
e
}()
, Jv = function(e, t) {
this.vertexId = e,
this.triangleId = t
}
, $v = function() {
function e(e) {
this._mesh = e,
this.syncIterations = 5e3,
this.aggressiveness = 7,
this.decimationIterations = 100,
this.boundingBoxEpsilon = m
}
return e.prototype.simplify = function(e, t) {
var i = this;
this._initDecimatedMesh(),
yi.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 n = this
, r = ~~(this._triangles.length * e.quality)
, o = 0
, a = this._triangles.length;
yi.Run(this.decimationIterations, (function(e) {
var t, i;
a - o <= r ? e.breakLoop() : (t = e.index,
i = function() {
e.executeNext()
}
,
setTimeout((function() {
t % 5 == 0 && n._updateMesh(0 === t);
for (var e = 0; e < n._triangles.length; ++e)
n._triangles[e].isDirty = !1;
var s = 1e-9 * Math.pow(t + 3, n.aggressiveness);
yi.SyncAsyncForLoop(n._triangles.length, n.syncIterations, (function(e) {
var t = ~~((n._triangles.length / 2 + e) % n._triangles.length)
, i = n._triangles[t];
if (i && !(i.error[3] > s || i.deleted || i.isDirty))
for (var r = function(e) {
if (i.error[e] < s) {
var t = []
, r = []
, a = i._vertices[e]
, l = i._vertices[(e + 1) % 3];
if (a.isBorder || l.isBorder)
return "continue";
var c = x.Zero();
n._calculateError(a, l, c);
var u = new Array;
if (n._isFlipped(a, l, c, t, u))
return "continue";
if (n._isFlipped(l, a, c, r, u))
return "continue";
if (t.indexOf(!0) < 0 || r.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 = n._references.length;
o = n._updateTriangles(a, a, t, o),
o = n._updateTriangles(a, l, r, o);
var p = n._references.length - d;
if (p <= a.triangleCount) {
if (p)
for (var f = 0; f < p; f++)
n._references[a.triangleStart + f] = n._references[d + f]
} else
a.triangleStart = d;
return a.triangleCount = p,
"break"
}
}, a = 0; a < 3 && "break" !== r(a); ++a)
;
}
), i, (function() {
return a - o <= r
}
))
}
), 0))
}
), (function() {
setTimeout((function() {
n._reconstructMesh(t),
i()
}
), 0)
}
))
}
,
e.prototype._initWithMesh = function(e, t, i) {
var n = this;
this._vertices = [],
this._triangles = [];
var r = this._mesh.getVerticesData(Bi.PositionKind)
, o = this._mesh.getIndices()
, a = this._mesh.subMeshes[e]
, s = []
, l = a.verticesCount;
yi.SyncAsyncForLoop(l, this.syncIterations / 4 >> 0, (function(e) {
if (r) {
var t = e + a.verticesStart
, o = x.FromArray(r, 3 * t)
, l = function(e) {
if (i)
for (var t = 0; t < n._vertices.length; ++t)
if (n._vertices[t].position.equalsWithEpsilon(e, 1e-4))
return n._vertices[t];
return null
}(o) || new qv(o,n._vertices.length);
l.originalOffsets.push(t),
l.id === n._vertices.length && n._vertices.push(l),
s.push(l.id)
}
}
), (function() {
yi.SyncAsyncForLoop(a.indexCount / 3, n.syncIterations, (function(e) {
if (o) {
var t = 3 * (a.indexStart / 3 + e)
, i = o[t + 0]
, r = o[t + 1]
, l = o[t + 2]
, c = n._vertices[s[i - a.verticesStart]]
, u = n._vertices[s[r - a.verticesStart]]
, h = n._vertices[s[l - a.verticesStart]]
, d = new Qv([c, u, h]);
d.originalOffset = t,
n._triangles.push(d)
}
}
), (function() {
n._init(t)
}
))
}
))
}
,
e.prototype._init = function(e) {
var t = this;
yi.SyncAsyncForLoop(this._triangles.length, this.syncIterations, (function(e) {
var i = t._triangles[e];
i.normal = x.Cross(i._vertices[1].position.subtract(i._vertices[0].position), i._vertices[2].position.subtract(i._vertices[0].position)).normalize();
for (var n = 0; n < 3; n++)
i._vertices[n].q.addArrayInPlace(Zv.DataFromNumbers(i.normal.x, i.normal.y, i.normal.z, -x.Dot(i.normal, i._vertices[0].position)))
}
), (function() {
yi.SyncAsyncForLoop(t._triangles.length, t.syncIterations, (function(e) {
for (var i = t._triangles[e], n = 0; n < 3; ++n)
i.error[n] = t._calculateError(i._vertices[n], i._vertices[(n + 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, n, r = [];
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],
n = 0; n < 3; ++n)
i._vertices[n].triangleCount = 1;
r.push(i)
}
var o = this._reconstructedMesh.getVerticesData(Bi.PositionKind) || []
, a = this._reconstructedMesh.getVerticesData(Bi.NormalKind) || []
, s = this._reconstructedMesh.getVerticesData(Bi.UVKind) || []
, l = this._reconstructedMesh.getVerticesData(Bi.ColorKind) || []
, c = this._mesh.getVerticesData(Bi.NormalKind)
, u = this._mesh.getVerticesData(Bi.UVKind)
, h = this._mesh.getVerticesData(Bi.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 < r.length; ++t)
i = r[t],
[0, 1, 2].forEach((function(e) {
var t = y[i.originalOffset + e]
, n = i._vertices[e].originalOffsets.indexOf(t);
n < 0 && (n = 0),
v.push(i._vertices[e].id + n + m)
}
));
this._reconstructedMesh.setIndices(v),
this._reconstructedMesh.setVerticesData(Bi.PositionKind, o),
a.length > 0 && this._reconstructedMesh.setVerticesData(Bi.NormalKind, a),
s.length > 0 && this._reconstructedMesh.setVerticesData(Bi.UVKind, s),
l.length > 0 && this._reconstructedMesh.setVerticesData(Bi.ColorKind, l);
var b = this._mesh.subMeshes[e];
e > 0 && (this._reconstructedMesh.subMeshes = [],
g.forEach((function(e) {
hr.AddToMesh(e.materialIndex, e.verticesStart, e.verticesCount, e.indexStart, e.indexCount, e.getMesh())
}
)),
hr.AddToMesh(b.materialIndex, m, d, _, 3 * r.length, this._reconstructedMesh))
}
,
e.prototype._initDecimatedMesh = function() {
this._reconstructedMesh = new Vr(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, n, r) {
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(x.Dot(u, h)) > .999)
return !0;
var d = x.Cross(u, h).normalize();
if (n[o] = !1,
x.Dot(d, a.normal) < .2)
return !0
} else
n[o] = !0,
r.push(a)
}
}
return !1
}
,
e.prototype._updateTriangles = function(e, t, i, n) {
for (var r = n, 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,
r++) : (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 r
}
,
e.prototype._identifyBorder = function() {
for (var e = 0; e < this._vertices.length; ++e) {
var t = []
, i = []
, n = this._vertices[e]
, r = void 0;
for (r = 0; r < n.triangleCount; ++r)
for (var o = this._triangles[this._references[n.triangleStart + r].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 (r = 0; r < t.length; ++r)
1 === t[r] ? this._vertices[i[r]].isBorder = !0 : this._vertices[i[r]].isBorder = !1
}
}
,
e.prototype._updateMesh = function(e) {
var t, i, n, r;
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],
n = 0; n < 3; ++n)
(r = i._vertices[n]).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],
n = 0; n < 3; ++n)
s[(r = i._vertices[n]).triangleStart + r.triangleCount] = new Jv(n,t),
r.triangleCount++;
this._references = s,
e && this._identifyBorder()
}
,
e.prototype._vertexError = function(e, t) {
var i = t.x
, n = t.y
, r = t.z;
return e.data[0] * i * i + 2 * e.data[1] * i * n + 2 * e.data[2] * i * r + 2 * e.data[3] * i + e.data[4] * n * n + 2 * e.data[5] * n * r + 2 * e.data[6] * n + e.data[7] * r * r + 2 * e.data[8] * r + e.data[9]
}
,
e.prototype._calculateError = function(e, t, i) {
var n = e.q.add(t.q)
, r = e.isBorder && t.isBorder
, o = 0
, a = n.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
if (0 === a || r) {
var s = e.position.add(t.position).divide(new x(2,2,2))
, l = this._vertexError(n, e.position)
, c = this._vertexError(n, t.position)
, u = this._vertexError(n, 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 = x.Zero()),
i.x = -1 / a * n.det(1, 2, 3, 4, 5, 6, 5, 7, 8),
i.y = 1 / a * n.det(0, 2, 3, 1, 5, 6, 2, 7, 8),
i.z = -1 / a * n.det(0, 1, 3, 1, 4, 6, 2, 5, 8),
o = this._vertexError(n, i);
return o
}
,
e
}();
Object.defineProperty(mn.prototype, "simplificationQueue", {
get: function() {
if (!this._simplificationQueue) {
this._simplificationQueue = new Kv;
var e = this._getComponent(Wi.NAME_SIMPLIFICATIONQUEUE);
e || (e = new ey(this),
this._addComponent(e))
}
return this._simplificationQueue
},
set: function(e) {
this._simplificationQueue = e
},
enumerable: !0,
configurable: !0
}),
Vr.prototype.simplify = function(e, t, i, n) {
return void 0 === t && (t = !0),
void 0 === i && (i = Xv.QUADRATIC),
this.getScene().simplificationQueue.addTask({
settings: e,
parallelProcessing: t,
mesh: this,
simplificationType: i,
successCallback: n
}),
this
}
;
var ey = function() {
function e(e) {
this.name = Wi.NAME_SIMPLIFICATIONQUEUE,
this.scene = e
}
return e.prototype.register = function() {
this.scene._beforeCameraUpdateStage.registerStep(Wi.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
}();
Vr.prototype.thinInstanceAdd = function(e, t) {
void 0 === t && (t = !0),
this._thinInstanceUpdateBufferSize("matrix", Array.isArray(e) ? e.length : 1);
var i = this._thinInstanceDataStorage.instancesCount;
if (Array.isArray(e))
for (var n = 0; n < e.length; ++n)
this.thinInstanceSetMatrixAt(this._thinInstanceDataStorage.instancesCount++, e[n], n === e.length - 1 && t);
else
this.thinInstanceSetMatrixAt(this._thinInstanceDataStorage.instancesCount++, e, t);
return i
}
,
Vr.prototype.thinInstanceAddSelf = function(e) {
return void 0 === e && (e = !0),
this.thinInstanceAdd(P.IdentityReadOnly, e)
}
,
Vr.prototype.thinInstanceRegisterAttribute = function(e, t) {
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 Bi(this.getEngine(),this._userThinInstanceBuffersStorage.data[e],e,!0,!1,t,!0),
this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[e])
}
,
Vr.prototype.thinInstanceSetMatrixAt = function(e, t, i) {
if (void 0 === i && (i = !0),
!this._thinInstanceDataStorage.matrixData || e >= this._thinInstanceDataStorage.instancesCount)
return !1;
var n = this._thinInstanceDataStorage.matrixData;
return t.copyToArray(n, 16 * e),
this._thinInstanceDataStorage.worldMatrices && (this._thinInstanceDataStorage.worldMatrices[e] = t),
i && (this.thinInstanceBufferUpdated("matrix"),
this.doNotSyncBoundingInfo || this.thinInstanceRefreshBoundingInfo(!1)),
!0
}
,
Vr.prototype.thinInstanceSetAttributeAt = function(e, t, i, n) {
return void 0 === n && (n = !0),
!(!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]),
n && this.thinInstanceBufferUpdated(e),
0))
}
,
Object.defineProperty(Vr.prototype, "thinInstanceCount", {
get: function() {
return this._thinInstanceDataStorage.instancesCount
},
set: function(e) {
var t, i;
e <= (null !== (i = null === (t = this._thinInstanceDataStorage.matrixData) || void 0 === t ? void 0 : t.length) && void 0 !== i ? i : 0) / 16 && (this._thinInstanceDataStorage.instancesCount = e)
},
enumerable: !0,
configurable: !0
}),
Vr.prototype._thinInstanceCreateMatrixBuffer = function(e, t, i) {
void 0 === i && (i = !1);
for (var n = new wi(this.getEngine(),t,!i,16,!1,!0), r = 0; r < 4; r++)
this.setVerticesBuffer(n.createVertexBuffer(e + r, 4 * r, 4));
return n
}
,
Vr.prototype.thinInstanceSetBuffer = function(e, t, i, n) {
var r, o, a;
void 0 === i && (i = 0),
void 0 === n && (n = !1),
i = i || 16,
"matrix" === e ? (null === (r = this._thinInstanceDataStorage.matrixBuffer) || void 0 === r || r.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, n),
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, n))) : (e === Bi.ColorKind && (e = Bi.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 Bi(this.getEngine(),t,e,!n,!1,i,!0),
this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[e])))
}
,
Vr.prototype.thinInstanceBufferUpdated = function(e) {
var t, i, n;
"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) : (null === (n = this._userThinInstanceBuffersStorage) || void 0 === n ? void 0 : n.vertexBuffers[e]) && this._userThinInstanceBuffersStorage.vertexBuffers[e].updateDirectly(this._userThinInstanceBuffersStorage.data[e], 0)
}
,
Vr.prototype.thinInstancePartialBufferUpdate = function(e, t, i) {
var n;
"matrix" === e ? this._thinInstanceDataStorage.matrixBuffer && this._thinInstanceDataStorage.matrixBuffer.updateDirectly(t, i) : (null === (n = this._userThinInstanceBuffersStorage) || void 0 === n ? void 0 : n.vertexBuffers[e]) && this._userThinInstanceBuffersStorage.vertexBuffers[e].updateDirectly(t, i)
}
,
Vr.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] = P.FromArray(e, 16 * t)
}
return this._thinInstanceDataStorage.worldMatrices
}
,
Vr.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 n = this._thinInstanceDataStorage.boundingVectors;
e && (n.length = 0,
this.refreshBoundingInfo(t, i));
var r = this.getBoundingInfo()
, o = this._thinInstanceDataStorage.matrixData;
if (0 === n.length)
for (var a = 0; a < r.boundingBox.vectors.length; ++a)
n.push(r.boundingBox.vectors[a].clone());
I.Vector3[0].setAll(Number.POSITIVE_INFINITY),
I.Vector3[1].setAll(Number.NEGATIVE_INFINITY);
for (var s = 0; s < this._thinInstanceDataStorage.instancesCount; ++s)
for (P.FromArrayToRef(o, 16 * s, I.Matrix[0]),
a = 0; a < n.length; ++a)
x.TransformCoordinatesToRef(n[a], I.Matrix[0], I.Vector3[2]),
I.Vector3[0].minimizeInPlace(I.Vector3[2]),
I.Vector3[1].maximizeInPlace(I.Vector3[2]);
r.reConstruct(I.Vector3[0], I.Vector3[1]),
this._updateBoundingInfo()
}
}
,
Vr.prototype._thinInstanceUpdateBufferSize = function(e, t) {
var i, n, r;
void 0 === t && (t = 1);
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 === (n = this._thinInstanceDataStorage.previousMatrixBuffer) || void 0 === n || n.dispose(),
this._thinInstanceDataStorage.previousMatrixBuffer = this._thinInstanceCreateMatrixBuffer("previousWorld", l, !1))) : (null === (r = this._userThinInstanceBuffersStorage.vertexBuffers[e]) || void 0 === r || r.dispose(),
this._userThinInstanceBuffersStorage.data[e] = l,
this._userThinInstanceBuffersStorage.sizes[e] = u,
this._userThinInstanceBuffersStorage.vertexBuffers[e] = new Bi(this.getEngine(),l,e,!0,!1,a,!0),
this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[e]))
}
}
}
,
Vr.prototype._thinInstanceInitializeUserStorage = function() {
this._userThinInstanceBuffersStorage || (this._userThinInstanceBuffersStorage = {
data: {},
sizes: {},
vertexBuffers: {},
strides: {}
})
}
,
Vr.prototype._disposeThinInstanceSpecificData = function() {
var e;
(null === (e = this._thinInstanceDataStorage) || void 0 === e ? void 0 : e.matrixBuffer) && (this._thinInstanceDataStorage.matrixBuffer.dispose(),
this._thinInstanceDataStorage.matrixBuffer = null)
}
;
var ty = function() {
function e(e) {
void 0 === e && (e = Recast),
this.bjsRECAST = {},
this.name = "RecastJSPlugin",
this._maximumSubStepCount = 10,
this._timeStep = 1 / 60,
this._worker = null,
"function" == typeof e ? K.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) : K.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
}
,
e.prototype.createNavMesh = function(e, t, i) {
var n, r, 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 (n = 0; n < e.length; n++)
if (e[n]) {
var c = e[n]
, u = c.getIndices();
if (!u)
continue;
var h = c.getVerticesData(Bi.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 P;
f[_].multiplyToRef(p, m),
d.push(m)
}
else
d.push(p);
for (var g = 0; g < d.length; g++) {
var v = d[g];
for (r = 0; r < u.length; r++)
a.push(u[r] + l);
var y = x.Zero()
, b = x.Zero();
for (o = 0; o < h.length; o += 3)
x.FromArrayToRef(h, o, b),
x.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, n = this.navMesh.getDebugNavMesh(), r = n.getTriangleCount(), o = [], a = [];
for (t = 0; t < 3 * r; t++)
o.push(t);
for (t = 0; t < r; t++)
for (i = 0; i < 3; i++) {
var s = n.getTriangle(t).getPoint(i);
a.push(s.x, s.y, s.z)
}
var l = new Vr("NavMeshDebug",e)
, c = new $n;
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 x(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 x(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 n = this.navMesh.getRandomPointAround(this._tempVec1, t);
i.set(n.x, n.y, n.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 x(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 n = this.navMesh.moveAlong(this._tempVec1, this._tempVec2);
i.set(n.x, n.y, n.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 n = this.navMesh.computePath(this._tempVec1, this._tempVec2)
, r = n.getPointCount()
, o = [];
for (i = 0; i < r; i++) {
var a = n.getPoint(i);
o.push(new x(a.x,a.y,a.z))
}
return o
}
,
e.prototype.createCrowd = function(e, t, i) {
return new iy(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 x(e.x,e.y,e.z)
}
,
e.prototype.buildFromNavmeshData = function(e) {
var t = e.length * e.BYTES_PER_ELEMENT
, i = this.bjsRECAST._malloc(t)
, n = new Uint8Array(this.bjsRECAST.HEAPU8.buffer,i,t);
n.set(e);
var r = new this.bjsRECAST.NavmeshData;
r.dataPointer = n.byteOffset,
r.size = e.length,
this.navMesh = new this.bjsRECAST.NavMesh,
this.navMesh.buildFromNavmeshData(r),
this.bjsRECAST._free(n.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
}()
, iy = function() {
function e(e, t, i, n) {
var r = 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 h,
this.bjsRECASTPlugin = e,
this.recastCrowd = new this.bjsRECASTPlugin.bjsRECAST.Crowd(t,i,this.bjsRECASTPlugin.navMesh.getNavMesh()),
this._scene = n,
this._onBeforeAnimationsObserver = n.onBeforeAnimationsObservable.add((function() {
r.update(.001 * n.getEngine().getDeltaTime())
}
))
}
return e.prototype.addAgent = function(e, t, i) {
var n = new this.bjsRECASTPlugin.bjsRECAST.dtCrowdAgentParams;
n.radius = t.radius,
n.height = t.height,
n.maxAcceleration = t.maxAcceleration,
n.maxSpeed = t.maxSpeed,
n.collisionQueryRange = t.collisionQueryRange,
n.pathOptimizationRange = t.pathOptimizationRange,
n.separationWeight = t.separationWeight,
n.updateFlags = 7,
n.obstacleAvoidanceType = 0,
n.queryFilterType = 0,
n.userData = 0;
var r = this.recastCrowd.addAgent(new this.bjsRECASTPlugin.bjsRECAST.Vec3(e.x,e.y,e.z), n);
return this.transforms.push(i),
this.agents.push(r),
this.reachRadii.push(t.reachRadius ? t.reachRadius : t.radius),
this._agentDestinationArmed.push(!1),
this._agentDestination.push(new x(0,0,0)),
r
}
,
e.prototype.getAgentPosition = function(e) {
var t = this.recastCrowd.getAgentPosition(e);
return new x(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 x(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 x(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) {
this.bjsRECASTPlugin.navMesh.update();
var t = this.bjsRECASTPlugin.getTimeStep()
, i = this.bjsRECASTPlugin.getMaximumSubStepCount();
if (t <= m)
this.recastCrowd.update(e);
else {
var n = Math.floor(e / t);
i && n > i && (n = i),
n < 1 && (n = 1);
for (var r = e / n, o = 0; o < n; o++)
this.recastCrowd.update(r)
}
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 x(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.getPath(e), n = i.getPointCount(), r = [];
for (t = 0; t < n; t++) {
var o = i.getPoint(t);
r.push(new x(o.x,o.y,o.z))
}
return r
}
,
e.prototype.dispose = function() {
this.recastCrowd.destroy(),
this._scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver),
this._onBeforeAnimationsObserver = null,
this.onReachTargetObservable.clear()
}
,
e
}();
vr.OfflineProviderFactory = function(e, t, i) {
return void 0 === i && (i = !1),
new ny(e,t,i)
}
;
var ny = function() {
function e(t, i, n) {
void 0 === n && (n = !1),
this._idbFactory = "undefined" != typeof window ? window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB : indexedDB,
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 ? n ? (this._enableSceneOffline = !0,
this._enableTexturesOffline = !0,
this._manifestVersionFound = 1,
gi.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
, n = function() {
i._enableSceneOffline = !1,
i._enableTexturesOffline = !1,
t(!1)
}
, r = 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 = r()
, s = new Ye;
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 r = JSON.parse(s.response);
i._enableSceneOffline = r.enableSceneOffline,
i._enableTexturesOffline = r.enableTexturesOffline && e._IsUASupportingBlobStorage,
r.version && !isNaN(parseInt(r.version)) && (i._manifestVersionFound = r.version),
t(!0)
} catch (e) {
n()
}
else
n()
}
), !1),
s.addEventListener("error", (function() {
if (o) {
o = !1;
var e = r();
s.open("GET", e),
s.send()
} else
n()
}
), !1);
try {
s.send()
} catch (e) {
K.Error("Error on XHR send request."),
t(!1)
}
}
,
e.prototype.open = function(e, t) {
var i = this
, n = 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 r = this._idbFactory.open("babylonjs", 1);
r.onerror = function() {
n()
}
,
r.onblocked = function() {
K.Error("IDB request blocked. Please reload the page."),
n()
}
,
r.onsuccess = function() {
i._db = r.result,
e()
}
,
r.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) {
K.Error("Error while creating object stores. Exception: " + e.message),
n()
}
}
}
else
this._isSupported = !1,
t && t()
}
,
e.prototype.loadImage = function(t, i) {
var n = this
, r = e._ReturnFullUrlLocation(t)
, o = function() {
n._hasReachedQuota || null === n._db ? i.src = t : n._saveImageIntoDBAsync(r, i)
};
this._mustUpdateRessources ? o() : this._loadImageFromDBAsync(r, i, o)
}
,
e.prototype._loadImageFromDBAsync = function(e, t, i) {
if (this._isSupported && null !== this._db) {
var n, r = this._db.transaction(["textures"]);
r.onabort = function() {
t.src = e
}
,
r.oncomplete = function() {
var r;
if (n) {
var o = window.URL || window.webkitURL;
r = o.createObjectURL(n.data),
t.onerror = function() {
K.Error("Error loading image from blob URL: " + r + " switching back to web url: " + e),
t.src = e
}
,
t.src = r
} else
i()
}
;
var o = r.objectStore("textures").get(e);
o.onsuccess = function(e) {
n = e.target.result
}
,
o.onerror = function() {
K.Error("Error loading texture " + e + " from DB."),
t.src = e
}
} else
K.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),
t.src = e
}
,
e.prototype._saveImageIntoDBAsync = function(t, i) {
var n, r = this;
if (this._isSupported) {
var o = function() {
var e;
if (n) {
var t = window.URL || window.webkitURL;
try {
e = t.createObjectURL(n)
} catch (i) {
e = t.createObjectURL(n)
}
}
e && (i.src = e)
};
if (e._IsUASupportingBlobStorage) {
var a = new Ye;
a.open("GET", t),
a.responseType = "blob",
a.addEventListener("load", (function() {
if (200 === a.status && r._db) {
n = a.response;
var s = r._db.transaction(["textures"], "readwrite");
s.onabort = function(e) {
try {
var t = (e.srcElement || e.target).error;
t && "QuotaExceededError" === t.name && (r._hasReachedQuota = !0)
} catch (e) {}
o()
}
,
s.oncomplete = function() {
o()
}
;
var l = {
textureUrl: t,
data: n
};
try {
var c = s.objectStore("textures").put(l);
c.onsuccess = function() {}
,
c.onerror = function() {
o()
}
} catch (n) {
25 === n.code && (e._IsUASupportingBlobStorage = !1,
r._enableTexturesOffline = !1),
i.src = t
}
} else
i.src = t
}
), !1),
a.addEventListener("error", (function() {
K.Error("Error in XHR request in BABYLON.Database."),
i.src = t
}
), !1),
a.send()
} else
i.src = t
} else
K.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 n, r = this;
if (this._isSupported && this._db)
try {
var o = this._db.transaction(["versions"]);
o.oncomplete = function() {
n ? r._manifestVersionFound !== n.data ? (r._mustUpdateRessources = !0,
i()) : t(n.data) : (r._mustUpdateRessources = !0,
i())
}
,
o.onabort = function() {
t(-1)
}
;
var a = o.objectStore("versions").get(e);
a.onsuccess = function(e) {
n = e.target.result
}
,
a.onerror = function() {
K.Error("Error loading version for scene " + e + " from DB."),
t(-1)
}
} catch (e) {
K.Error("Error while accessing 'versions' object store (READ OP). Exception: " + e.message),
t(-1)
}
else
K.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 n = this._db.transaction(["versions"], "readwrite");
n.onabort = function(e) {
try {
var n = e.srcElement.error;
n && "QuotaExceededError" === n.name && (i._hasReachedQuota = !0)
} catch (e) {}
t(-1)
}
,
n.oncomplete = function() {
t(i._manifestVersionFound)
}
;
var r = {
sceneUrl: e,
data: this._manifestVersionFound
}
, o = n.objectStore("versions").put(r);
o.onsuccess = function() {}
,
o.onerror = function() {
K.Error("Error in DB add version request in BABYLON.Database.")
}
} catch (e) {
K.Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + e.message),
t(-1)
}
else
t(-1)
}
,
e.prototype.loadFile = function(t, i, n, r, o) {
var a = this
, s = e._ReturnFullUrlLocation(t)
, l = function() {
a._saveFileAsync(s, i, n, o, r)
};
this._checkVersionFromDB(s, (function(e) {
-1 !== e ? a._mustUpdateRessources ? a._saveFileAsync(s, i, n, o, r) : a._loadFileAsync(s, i, l) : r && r()
}
))
}
,
e.prototype._loadFileAsync = function(e, t, i) {
if (this._isSupported && this._db) {
var n, r;
r = -1 !== e.indexOf(".babylon") ? "scenes" : "textures";
var o = this._db.transaction([r]);
o.oncomplete = function() {
n ? t(n.data) : i()
}
,
o.onabort = function() {
i()
}
;
var a = o.objectStore(r).get(e);
a.onsuccess = function(e) {
n = e.target.result
}
,
a.onerror = function() {
K.Error("Error loading file " + e + " from DB."),
i()
}
} else
K.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),
t()
}
,
e.prototype._saveFileAsync = function(t, i, n, r, o) {
var a = this;
if (this._isSupported) {
var s;
s = -1 !== t.indexOf(".babylon") ? "scenes" : "textures";
var l, c = new Ye;
c.open("GET", t + (null == t.match(/\?/) ? "?" : "&") + Date.now()),
r && (c.responseType = "arraybuffer"),
n && (c.onprogress = n),
c.addEventListener("load", (function() {
if (200 === c.status || c.status < 400 && e._ValidateXHRData(c, r ? 6 : 1))
if (l = r ? c.response : c.responseText,
!a._hasReachedQuota && a._db) {
var n = a._db.transaction([s], "readwrite");
n.onabort = function(e) {
try {
var t = e.srcElement.error;
t && "QuotaExceededError" === t.name && (a._hasReachedQuota = !0)
} catch (e) {}
i(l)
}
,
n.oncomplete = function() {
i(l)
}
;
var u;
u = "scenes" === s ? {
sceneUrl: t,
data: l,
version: a._manifestVersionFound
} : {
textureUrl: t,
data: l
};
try {
var h = n.objectStore(s).put(u);
h.onsuccess = function() {}
,
h.onerror = function() {
K.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() {
K.Error("error on XHR request."),
i()
}
), !1),
c.send()
} else
K.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."),
i()
}
,
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 = q_(e.response);
if (i.width && i.height && i.width > 0 && i.height > 0)
return !0;
if (2 === t)
return !1
}
if (4 & t) {
var n = new Uint8Array(e.response,0,3);
return 68 === n[0] && 68 === n[1] && 83 === n[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
}()
, ry = 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
}();
Pt.ShadersStore.gpuUpdateParticlesPixelShader = "#version 300 es\nvoid main() {\ndiscard;\n}\n";
Pt.ShadersStore.gpuUpdateParticlesVertexShader = "#version 300 es\n#define PI 3.14159\nuniform float currentCount;\nuniform float timeDelta;\nuniform float stopFactor;\n#ifndef LOCAL\nuniform mat4 emitterWM;\n#endif\nuniform vec2 lifeTime;\nuniform vec2 emitPower;\nuniform vec2 sizeRange;\nuniform vec4 scaleRange;\n#ifndef COLORGRADIENTS\nuniform vec4 color1;\nuniform vec4 color2;\n#endif\nuniform vec3 gravity;\nuniform sampler2D randomSampler;\nuniform sampler2D randomSampler2;\nuniform vec4 angleRange;\n#ifdef BOXEMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\nuniform vec3 minEmitBox;\nuniform vec3 maxEmitBox;\n#endif\n#ifdef POINTEMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\n#endif\n#ifdef HEMISPHERICEMITTER\nuniform float radius;\nuniform float radiusRange;\nuniform float directionRandomizer;\n#endif\n#ifdef SPHEREEMITTER\nuniform float radius;\nuniform float radiusRange;\n#ifdef DIRECTEDSPHEREEMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\n#else\nuniform float directionRandomizer;\n#endif\n#endif\n#ifdef CYLINDEREMITTER\nuniform float radius;\nuniform float height;\nuniform float radiusRange;\n#ifdef DIRECTEDCYLINDEREMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\n#else\nuniform float directionRandomizer;\n#endif\n#endif\n#ifdef CONEEMITTER\nuniform vec2 radius;\nuniform float coneAngle;\nuniform vec2 height;\nuniform float directionRandomizer;\n#endif\nin vec3 position;\n#ifdef CUSTOMEMITTER\nin vec3 initialPosition;\n#endif\nin float age;\nin float life;\nin vec4 seed;\nin 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;\nin vec3 noiseCoordinates2;\n#endif\nout vec3 outPosition;\n#ifdef CUSTOMEMITTER\nout vec3 outInitialPosition;\n#endif\nout float outAge;\nout float outLife;\nout vec4 outSeed;\nout 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;\nout 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;\nuniform float limitVelocityDamping;\n#endif\n#ifdef DRAGGRADIENTS\nuniform sampler2D dragGradientSampler;\n#endif\n#ifdef NOISE\nuniform vec3 noiseStrength;\nuniform sampler2D noiseSampler;\n#endif\n#ifdef ANIMATESHEET\nuniform vec4 cellInfos;\n#endif\nvec3 getRandomVec3(float offset) {\nreturn texture(randomSampler2,vec2(float(gl_VertexID)*offset/currentCount,0)).rgb;\n}\nvec4 getRandomVec4(float offset) {\nreturn texture(randomSampler,vec2(float(gl_VertexID)*offset/currentCount,0));\n}\nvoid main() {\nfloat newAge=age+timeDelta; \nif (newAge>=life && stopFactor != 0.) {\nvec3 newPosition;\nvec3 newDirection;\nvec4 randoms=getRandomVec4(seed.x);\noutLife=lifeTime.x+(lifeTime.y-lifeTime.x)*randoms.r;\noutAge=newAge-life;\noutSeed=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;\noutSize.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;\noutAngle.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);\nvec3 randoms3=getRandomVec3(seed.z);\nnewPosition=vec3(0,0,0);\nnewDirection=direction1+(direction2-direction1)*randoms3;\n#elif defined(BOXEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\nnewPosition=minEmitBox+(maxEmitBox-minEmitBox)*randoms2;\nnewDirection=direction1+(direction2-direction1)*randoms3; \n#elif defined(HEMISPHERICEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\nfloat phi=2.0*PI*randoms2.x;\nfloat theta=acos(2.0*randoms2.y-1.0);\nfloat randX=cos(phi)*sin(theta);\nfloat randY=cos(theta);\nfloat randZ=sin(phi)*sin(theta);\nnewPosition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,abs(randY),randZ);\nnewDirection=newPosition+directionRandomizer*randoms3; \n#elif defined(SPHEREEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\nfloat phi=2.0*PI*randoms2.x;\nfloat theta=acos(2.0*randoms2.y-1.0);\nfloat randX=cos(phi)*sin(theta);\nfloat randY=cos(theta);\nfloat randZ=sin(phi)*sin(theta);\nnewPosition=(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);\nvec3 randoms3=getRandomVec3(seed.z);\nfloat yPos=(randoms2.x-0.5)*height;\nfloat angle=randoms2.y*PI*2.;\nfloat inverseRadiusRangeSquared=((1.-radiusRange)*(1.-radiusRange));\nfloat positionRadius=radius*sqrt(inverseRadiusRangeSquared+(randoms2.z*(1.-inverseRadiusRangeSquared)));\nfloat xPos=positionRadius*cos(angle);\nfloat zPos=positionRadius*sin(angle);\nnewPosition=vec3(xPos,yPos,zPos);\n#ifdef DIRECTEDCYLINDEREMITTER\nnewDirection=direction1+(direction2-direction1)*randoms3;\n#else\nangle=angle+((randoms3.x-0.5)*PI)*directionRandomizer;\nnewDirection=vec3(cos(angle),(randoms3.y-0.5)*directionRandomizer,sin(angle));\nnewDirection=normalize(newDirection);\n#endif\n#elif defined(CONEEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nfloat s=2.0*PI*randoms2.x;\n#ifdef CONEEMITTERSPAWNPOINT\nfloat h=0.0001;\n#else\nfloat h=randoms2.y*height.y;\nh=1.-h*h; \n#endif\nfloat lRadius=radius.x-radius.x*randoms2.z*radius.y;\nlRadius=lRadius*h;\nfloat randX=lRadius*sin(s);\nfloat randZ=lRadius*cos(s);\nfloat randY=h *height.x;\nnewPosition=vec3(randX,randY,randZ); \nif (abs(cos(coneAngle))==1.0) {\nnewDirection=vec3(0.,1.0,0.);\n} else {\nvec3 randoms3=getRandomVec3(seed.z);\nnewDirection=normalize(newPosition+directionRandomizer*randoms3); \n}\n#elif defined(CUSTOMEMITTER)\nnewPosition=initialPosition;\noutInitialPosition=initialPosition;\n#else \nnewPosition=vec3(0.,0.,0.);\nnewDirection=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;\noutNoiseCoordinates2=noiseCoordinates2;\n#endif\n} else {\nfloat directionScale=timeDelta;\noutAge=newAge;\nfloat 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;\noutSeed=seed;\n#ifndef COLORGRADIENTS \noutColor=color;\n#endif\n#ifdef SIZEGRADIENTS\noutSize.x=texture(sizeGradientSampler,vec2(ageGradient,0)).r;\noutSize.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;\nfloat currentVelocity=length(updatedDirection);\nif (currentVelocity>limitVelocity) {\nupdatedDirection=updatedDirection*limitVelocityDamping;\n}\n#endif\noutDirection=updatedDirection;\n#ifdef NOISE\nfloat fetchedR=texture(noiseSampler,vec2(noiseCoordinates1.x,noiseCoordinates1.y)*vec2(0.5)+vec2(0.5)).r;\nfloat fetchedG=texture(noiseSampler,vec2(noiseCoordinates1.z,noiseCoordinates2.x)*vec2(0.5)+vec2(0.5)).r;\nfloat fetchedB=texture(noiseSampler,vec2(noiseCoordinates2.y,noiseCoordinates2.z)*vec2(0.5)+vec2(0.5)).r;\nvec3 force=vec3(2.*fetchedR-1.,2.*fetchedG-1.,2.*fetchedB-1.)*noiseStrength;\noutDirection=outDirection+force*timeDelta;\noutNoiseCoordinates1=noiseCoordinates1;\noutNoiseCoordinates2=noiseCoordinates2;\n#endif \n#endif \n#ifdef ANGULARSPEEDGRADIENTS\nfloat angularSpeed=texture(angularSpeedGradientSampler,vec2(ageGradient,0)).r;\noutAngle=angle+angularSpeed*timeDelta;\n#else\noutAngle=vec2(angle.x+angle.y*timeDelta,angle.y);\n#endif\n#ifdef ANIMATESHEET \nfloat offsetAge=outAge;\nfloat dist=cellInfos.y-cellInfos.x;\n#ifdef ANIMATESHEETRANDOMSTART\noutCellStartOffset=cellStartOffset;\noffsetAge+=cellStartOffset;\n#else\nfloat cellStartOffset=0.;\n#endif \nfloat ratio=0.;\nif (cellInfos.w==1.0) {\nratio=clamp(mod(cellStartOffset+cellInfos.z*offsetAge,life)/life,0.,1.0);\n}\nelse {\nratio=clamp(cellStartOffset+cellInfos.z*offsetAge/life,0.,1.0);\n}\noutCellIndex=float(int(cellInfos.x+ratio*dist));\n#endif\n}\n}";
var oy = 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.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 yf && 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 Mt("gpuUpdateParticles",this._updateEffectOptions,this._engine),
new ry(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 n = this._engine;
n.bindTransformFeedbackBuffer(t.getBuffer()),
n.setRasterizerState(!1),
n.beginTransformFeedback(!0),
n.drawArraysType(a.MATERIAL_PointListDrawMode, 0, i),
n.endTransformFeedback(),
n.setRasterizerState(!0),
n.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 = [],
e = 0; e < this._renderVAO.length; e++)
this._engine.releaseVertexArrayObject(this._renderVAO[e]);
this._renderVAO = []
}
,
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 yf && (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 n = this._engine.recordVertexArrayObject(t, null, this._updateEffect);
return this._engine.bindArrayBuffer(null),
n
}
,
e
}();
y("BABYLON.WebGL2ParticleSystem", oy);
Pt.ShadersStoreWGSL.gpuUpdateParticlesComputeShader = "struct Particle {\nposition : 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};\nstruct Particles {\nparticles : array;\n};\nstruct SimParams {\ncurrentCount : 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