text: var BABYLON;!function(e){var n=function(){function n(){}return Object.defineProperty(n,"Version",{get:function(){return"5.0.0 - A12.4"},enumerable:!1,configurable:!0}),Object.defineProperty(n,"Copyright",{get:function(){return"All rights reserved (c) 2020 Mackey Kinard"},enumerable:!1,configurable:!0}),n.HasAudioContext=function(){return null!=e.Engine.audioEngine&&null!=e.Engine.audioEngine.audioContext&&null!=e.Engine.audioEngine.audioContext.state&&"running"===e.Engine.audioEngine.audioContext.state},n.RegisterOnShowSceneLoader=function(n){e.SceneManager.SetWindowState("showSceneLoader",n)},n.RegisterOnUpdateSceneLoader=function(n){e.SceneManager.SetWindowState("updateSceneLoader",n)},n.RegisterOnTickSceneLoader=function(n){e.SceneManager.SetWindowState("tickSceneLoader",n)},n.LoadSceneFile=function(e,n){if(void 0===n&&(n=null),window.toolkit)if(window.top.loadScene)window.top.loadScene(e,n);else{var a=window.location.protocol+"//"+window.location.hostname+":"+window.location.port+window.location.pathname+"?scene="+e;null!=n&&""!==n&&(a+=n),window.location.replace(a)}},n.ShowParentLoader=function(e){window.toolkit&&window.top.showGameLoading&&window.top.showGameLoading(e)},n.GetRenderQuality=function(){var n=e.RenderQuality.High,a=e.SceneManager.GetLocalStorageItem("renderQuality");return null!=a&&""!==a&&(n=parseInt(a)),n},n.SetRenderQuality=function(n){var a=n;e.SceneManager.SetLocalStorageItem("renderQuality",a.toString())},n.GetLocalStorageItem=function(e){return null!=window.top.localStorage?window.top.localStorage.getItem(e):null},n.SetLocalStorageItem=function(e,n){null!=window.top.localStorage&&window.top.localStorage.setItem(e,n)},n.GetSessionStorageItem=function(e){return null!=window.top.sessionStorage?window.top.sessionStorage.getItem(e):null},n.SetSessionStorageItem=function(e,n){null!=window.top.sessionStorage&&window.top.sessionStorage.setItem(e,n)},n.SetWindowState=function(e,n){null==window.top.state&&(window.top.state={}),window.top.state[e]=n},n.GetWindowState=function(e){var n=null;return null!=window.top.state&&null!=window.top.state[e]&&(n=window.top.state[e]),null!=n?n:null},n.PostWindowMessage=function(e,n,a){window.top.postMessage(e,n,a)},n.EnableSceneParsing=function(n){e.SceneManager.SceneParsingEnabled=n},n.IsSceneParsingEnabled=function(){return e.SceneManager.SceneParsingEnabled},n.GetFullscreenUI=function(n){if(null==e.SceneManager.AdvDynamicTexture){var a="Default-Screen-UI",t=!0,r=e.Texture.BILINEAR_SAMPLINGMODE;e.SceneManager.AdvDynamicTexture=e.GUI.AdvancedDynamicTexture.CreateFullscreenUI(a,t,n,r)}return e.SceneManager.AdvDynamicTexture},n.GetAmbientSkybox=function(e){return e.getMeshByID("Ambient Skybox")},n.GetIntensityFactor=function(){return null!=window.intensityFactor?window.intensityFactor:2},n.IsDebugMode=function(){return null!=window.debugModeEnabled&&window.debugModeEnabled===!0},n.ConsoleLog=function(){for(var n=[],a=0;a<arguments.length;a++)n[a]=arguments[a];e.SceneManager.IsDebugMode()&&console.log.apply(console,n)},n.ConsoleInfo=function(){for(var n=[],a=0;a<arguments.length;a++)n[a]=arguments[a];e.SceneManager.IsDebugMode()&&console.info.apply(console,n)},n.ConsoleWarn=function(){for(var n=[],a=0;a<arguments.length;a++)n[a]=arguments[a];e.SceneManager.IsDebugMode()&&console.warn.apply(console,n)},n.ConsoleError=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];console.error.apply(console,e)},n.LogMessage=function(n){e.SceneManager.IsDebugMode()&&e.Tools.Log(n)},n.LogWarning=function(n){e.SceneManager.IsDebugMode()&&e.Tools.Warn(n)},n.LogError=function(n){e.Tools.Error(n)},n.IsWindows=function(){return"undefined"!=typeof Windows&&"undefined"!=typeof Windows.UI&&"undefined"!=typeof Windows.System&&"undefined"!=typeof Windows.Foundation},n.IsCordova=function(){return null!=window.cordova},n.IsWebAssembly=function(){return window.WebAssembly},n.IsOculusBrowser=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/OculusBrowser/i)&&(e=!0),e},n.IsSamsungBrowser=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/SamsungBrowser/i)&&(e=!0),e},n.IsWindowsPhone=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/Windows Phone/i)&&(e=!0),e},n.IsBlackBerry=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/BlackBerry/i)&&(e=!0),e},n.IsOperaMini=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/Opera Mini/i)&&(e=!0),e},n.IsAndroid=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/Android/i)&&(e=!0),e},n.IsWebOS=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/webOS/i)&&(e=!0),e},n.IsIOS=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/iPhone|iPad|iPod/i)&&(e=!0),e},n.IsIPHONE=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/iPhone/i)&&(e=!0),e},n.IsIPAD=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/iPad/i)&&(e=!0),e},n.IsIPOD=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/iPod/i)&&(e=!0),e},n.IsIE11=function(){return void 0!==navigator.msMaxTouchPoints},n.IsMobile=function(){var e=!1;if(null!=navigator&&null!=navigator.userAgent){var n=navigator.userAgent;(n.match(/Android/i)||n.match(/webOS/i)||n.match(/iPhone|iPad|iPod/i)||n.match(/BlackBerry/i)||n.match(/Opera Mini/i)||n.match(/Windows Phone/i))&&(e=!0)}return e},n.IsPlaystation=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/Playstation/i)&&(e=!0),e},n.IsXboxConsole=function(){var n=!1;if(e.SceneManager.IsWindows()&&"undefined"!=typeof Windows.System.Profile&&"undefined"!=typeof Windows.System.Profile.AnalyticsInfo&&"undefined"!=typeof Windows.System.Profile.AnalyticsInfo.versionInfo&&"undefined"!=typeof Windows.System.Profile.AnalyticsInfo.versionInfo.deviceFamily){var a=Windows.System.Profile.AnalyticsInfo.versionInfo.deviceFamily;a.match(/Xbox/i)&&(n=!0)}return n},n.IsXboxLive=function(){return e.SceneManager.IsWindows()&&"undefined"!=typeof Microsoft&&"undefined"!=typeof Microsoft.Xbox&&"undefined"!=typeof Microsoft.Xbox.Services},n.GetTime=function(){return.001*TimerPlugin.getTimeMilliseconds()},n.GetGameTime=function(){return.001*(TimerPlugin.getTimeMilliseconds()-TimerPlugin.gameTimeMilliseconds)},n.GetDeltaSeconds=function(n){var a=n||e.SceneManager.GetLastCreatedScene();return.001*a.getEngine().getDeltaTime()},n.GetAnimationRatio=function(n){var a=n||e.SceneManager.GetLastCreatedScene();return.06*a.getEngine().getDeltaTime()},n.SetTimeout=function(n,a){var t=null;return t=TimerPlugin.requestTimeout(function(){null!=t&&e.SceneManager.ClearTimeout(t),null!=a&&a()},n)},n.ClearTimeout=function(e){TimerPlugin.clearRequestTimeout(e)},n.SetInterval=function(e,n){return TimerPlugin.requestInterval(n,e)},n.ClearInterval=function(e){TimerPlugin.clearRequestInterval(e)},n.RunOnce=function(e,n,a){e.executeOnceBeforeRender(n,a)},n.PopupDebug=function(e){e.debugLayer&&(e.debugLayer.hide(),e.debugLayer.show({enablePopup:!0,globalRoot:null}))},n.ToggleDebug=function(n,a,t){if(void 0===a&&(a=!1),void 0===t&&(t=null),n.debugLayer){var r=window;e.SceneManager.debugLayerVisible===!0?(e.SceneManager.debugLayerVisible=!1,r.METER&&r.METER.show&&r.METER.show(),n.debugLayer.hide()):(e.SceneManager.debugLayerVisible=!0,r.METER&&r.METER.hide&&r.METER.hide(),n.debugLayer.show({embedMode:a,globalRoot:t}))}},n.DisposeScene=function(n,a){void 0===a&&(a=new e.Color4(0,0,0,1));var t=n.getEngine();n.dispose(),t.clear(a,!0,!0,!0)},n.SafeDestroy=function(n,a,t){void 0===a&&(a=5),void 0===t&&(t=!1),a>0?(t===!0&&n.setEnabled(!1),e.SceneManager.SetTimeout(a,function(){n.dispose(!1,!1)})):n.dispose(!1,!1)},n.AlertMessage=function(n,a){void 0===a&&(a="Babylon.js");var t=null;return e.SceneManager.IsWindows()?t=new Windows.UI.Popups.MessageDialog(n,a).showAsync():window.alert(n),t},n.GetQueryStringParam=function(e,n){n||(n=window.location.href),e=e.replace(/[\[\]]/g,"\\$&");var a=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)"),t=a.exec(n);return t?t[2]?decodeURIComponent(t[2].replace(/\+/g," ")):"":null},n.GetWebGLVersionString=function(n){var a="WebGL - Unknown",t=n||e.SceneManager.GetLastCreatedScene();if(null!=t){var r=t.getEngine();if(null!=r){var i=r.getGlInfo();null!=i&&(a=i.version+" - "+i.renderer)}}return a},n.GetWebGLVersionNumber=function(n){var a=0,t=n||e.SceneManager.GetLastCreatedScene();if(null!=t){var r=t.getEngine();null!=r&&(a=r.webGLVersion)}return a},n.GetRootUrl=function(e){return null!=e._rootUrl&&""!==e._rootUrl?e._rootUrl:"/"},n.SetRootUrl=function(e,n){e._rootUrl=n},n.GetSceneFile=function(e){return null!=e._fileName&&""!==e._fileName?e._fileName:null},n.SetSceneFile=function(e,n){e._fileName=n},n.GetRightHanded=function(e){return null!=e._righty&&e._righty===!0},n.SetRightHanded=function(e,n){e._righty=n},n.SetWindowsLaunchMode=function(n){void 0===n&&(n=1),e.SceneManager.IsWindows()&&"undefined"!=typeof Windows.UI.ViewManagement&&"undefined"!=typeof Windows.UI.ViewManagement.ApplicationView&&(Windows.UI.ViewManagement.ApplicationView.preferredLaunchWindowingMode=n)},n.ShowPageErrorMessage=function(e,n,a){void 0===n&&(n="Error"),void 0===a&&(a=0),window.showErrorMessage&&window.showErrorMessage(e,n,a)},n.QuitWindowsApplication=function(){e.SceneManager.IsWindows()&&window.close()},n.LoadTextFile=function(n,a,t,r){return e.Tools.LoadFile(n,a,t,null,!1,r)},n.LoadTextFileAsync=function(n){return e.Tools.LoadFileAsync(n,!1)},n.PostDataToServer=function(e,n,a,t,r){void 0===a&&(a="application/x-www-form-urlencoded"),void 0===t&&(t=null),void 0===r&&(r=null);var i=new XMLHttpRequest;return i.open("POST",e,!0),i.setRequestHeader("Content-Type",a),i.onreadystatechange=function(){i.readyState===XMLHttpRequest.DONE&&null!=t&&t(i.status)},i.onerror=function(){null!=r&&r("Failed to post data to server.")},i.send(n),i},n.PostDataToServerAsync=function(n,a,t){return void 0===t&&(t="application/x-www-form-urlencoded"),new Promise(function(r,i){e.SceneManager.PostDataToServer(n,a,t,function(e){r(e)},function(e){i(e)})})},n.ShowSceneLoader=function(){window.showSceneLoader&&window.showSceneLoader()},n.HideSceneLoader=function(){window.hideSceneLoader&&window.hideSceneLoader()},n.UpdateLoaderStatus=function(e,n,a){window.updateStatus&&window.updateStatus(e,n,a)},n.GetEngineInstances=function(){return e.EngineStore.Instances},n.GetLastCreatedEngine=function(){return e.EngineStore.LastCreatedEngine},n.GetLastCreatedScene=function(){return e.EngineStore.LastCreatedScene},n.GetAssetContainer=function(e,n){return null==e||null==n||""===n?null:null!=e.assetContainers?e.assetContainers.get(n.toLowerCase()):null},n.SetAssetContainer=function(e,n,a){null!=e&&null!=n&&""!==n&&null!=a&&(null==e.assetContainers&&(e.assetContainers=new Map),e.assetContainers.set(n.toLowerCase(),a))},n.ClearAssetContainers=function(e){return null==e?null:(null!=e.assetContainers,void(e.assetContainers=new Map))},n.GetMesh=function(e,n){return null==e?null:e.getNodeByName(n)},n.GetMeshByID=function(e,n){return null==e?null:e.getNodeByID(n)},n.GetAbstractMesh=function(e,n){return null==e?null:e.getNodeByName(n)},n.GetAbstractMeshByID=function(e,n){return null==e?null:e.getNodeByID(n)},n.GetTransformNode=function(e,n){return null==e?null:e.getNodeByName(n)},n.GetTransformNodeByID=function(e,n){return null==e?null:e.getNodeByID(n)},n.GetTransformDetailMesh=function(n){var a=null,t=n.name+".Detail",r=n.getChildren(function(n){return n.name===t&&n instanceof e.AbstractMesh},!0);return null!=r&&r.length>0&&(a=r[0]),a},n.GetPrimitiveMeshes=function(e){return e.getChildMeshes(!0,function(e){return e.name.indexOf("_primitive")>=0})},n.GetTransformLayer=function(e){return null!=e.metadata&&null!=e.metadata.unity&&null!=e.metadata.unity.layer?e.metadata.unity.layer:0},n.GetTransformTag=function(e){return null!=e.metadata&&null!=e.metadata.unity&&null!=e.metadata.unity.group&&""!==e.metadata.unity.group?e.metadata.unity.group:"Untagged"},n.HasTransformTags=function(n,a){return e.Tags.MatchesQuery(n,a)},n.TextureFloatSupported=function(e){var n=!1,a=!1,t=e.getEngine(),r=t.getCaps();return r.textureHalfFloatRender&&r.textureHalfFloatLinearFiltering?n=!0:r.textureFloatRender&&r.textureFloatLinearFiltering&&(a=!0),n||a},n.RegisterClickAction=function(n,a,t){var r=null;return null!=a&&(a.isPickable=!0,null==a.actionManager&&(a.actionManager=new e.ActionManager(n)),r=a.actionManager.registerAction(new e.ExecuteCodeAction({trigger:e.ActionManager.OnPickTrigger},t))),r},n.UnregisterClickAction=function(e,n){var a=!1;return null!=e&&null!=n&&(a=e.actionManager.unregisterAction(n)),a},n.StartTweenAnimation=function(n,a,t,r,i,o,l,s,u,c,d){void 0===l&&(l=1),void 0===s&&(s=null),void 0===u&&(u=null),void 0===c&&(c=null),void 0===d&&(d=null);var g=l||1,m=s||30,p=u||e.Animation.ANIMATIONLOOPMODE_CONSTANT,f=e.Utilities.CreateTweenAnimation(a,r,i,o,m,p);null!=c&&f.setEasingFunction(c);var h=e.Utilities.GetLastKeyFrameIndex(f),S=p!=e.Animation.ANIMATIONLOOPMODE_CONSTANT;return n.beginDirectAnimation(t,[f],0,h,S,g,d)},n.GetMaterialWithName=function(e,n){var a=null;if(null!=e.materials&&e.materials.length>0)for(var t=(e.materials.length,0);t<e.materials.length;t++){var r=e.materials[t];if(r.name.startsWith(n)){a=r;break}}return a},n.GetAllMaterialsWithName=function(e,n){var a=null;if(null!=e.materials&&e.materials.length>0)for(var t=(e.materials.length,0);t<e.materials.length;t++){var r=e.materials[t];r.name.startsWith(n)&&(null==a&&(a=[]),a.push(r))}return a},n.InstantiatePrefab=function(n,a,t,r,i,o){void 0===r&&(r=!1),void 0===i&&(i=!0),void 0===o&&(o=null);var l=e.Utilities.CloneAssetContainerItem(n,a,function(e){return e},r,i);if(null!=l){null!=t&&""!==t&&(l.name=t);var s=[];s.push(l);var u=l.getChildren(null,!1);null!=u&&u.length>0&&u.forEach(function(e){s.push(e)}),s.forEach(function(n){n.id=e.Utilities.CreateGuid()});var c=[];e.Utilities.ParseSceneComponents(n.scene,s,c),null!=o&&n.scene.onAfterRenderObservable.addOnce(function(){if(null!=c&&c.length>0)for(var e=0;e<c.length;e++){var n=c[e];null!=n&&n.addPreloaderTasks&&n.addPreloaderTasks(o)}})}return l},n.CloneTransformNode=function(n,a,t){var r=e.Utilities.GetAssetContainerNode(n,a),i=r.clone(t,null,!0);return null!=i&&i.setEnabled(!0),i},n.CloneAbstractMesh=function(n,a,t){var r=e.Utilities.GetAssetContainerMesh(n,a),i=r.clone(t,null,!0);return null!=i&&i.setEnabled(!0),i},n.CreateInstancedMesh=function(n,a,t){var r=e.Utilities.GetAssetContainerMesh(n,a),i=r.createInstance(t);return null!=i&&i.setEnabled(!0),i},n.RegisterScriptComponent=function(e,n,a){void 0===a&&(a=!0),null!=e&&e.registerComponentInstance&&e.registerComponentInstance(e,n,a)},n.DestroyScriptComponent=function(e){null!=e&&e.destroyComponentInstance&&e.destroyComponentInstance(e)},n.FindScriptComponent=function(e,n){if(null==e)return null;var a=null;if(null!=e.metadata&&e.metadata.unity){var t=e.metadata.unity;if(null!=t.components&&t.components.length>0)for(var r=0;r<t.components.length;r++){var i=t.components[r];if(null!=i.instance&&i.klass===n){a=i.instance;break}}}return null!=a?a:null},n.FindAllScriptComponents=function(e,n){if(null==e)return null;var a=null;if(null!=e.metadata&&e.metadata.unity){var t=e.metadata.unity;if(null!=t.components&&t.components.length>0)for(var r=0;r<t.components.length;r++){var i=t.components[r];null!=i.instance&&i.klass===n&&(null==a&&(a=[]),a.push(i.instance))}}return null!=a?a:null},n.FindSceneMetadata=function(e){return null==e?null:null!=e.metadata&&e.metadata.unity?e.metadata.unity:null},n.FindSceneCameraRig=function(e){return null==e?null:null!=e.cameraRig?e.cameraRig:null},n.FindSceneLightRig=function(e){return null==e?null:null!=e.lightRig?e.lightRig:null},n.FindTransformWithScript=function(n,a){var t=n.getNodes();return e.Utilities.SearchTransformNodeForScript(a,t)},n.FindAllTransformsWithScript=function(n,a){var t=n.getNodes();return e.Utilities.SearchAllTransformNodesForScript(a,t)},n.FindChildTransformNode=function(n,a,t,r,i){if(void 0===t&&(t=e.SearchType.ExactMatch),void 0===r&&(r=!0),void 0===i&&(i=null),null==n)return null;var o=null!=t?t:e.SearchType.ExactMatch,l=n.getChildren(i,r);return e.Utilities.SearchTransformNodes(a,l,o)},n.FindChildTransformWithTags=function(n,a,t,r){if(void 0===t&&(t=!0),void 0===r&&(r=null),null==n)return null;var i=n.getChildren(r,t);return e.Utilities.SearchTransformNodeForTags(a,i)},n.FindAllChildTransformsWithTags=function(n,a,t,r){if(void 0===t&&(t=!0),void 0===r&&(r=null),null==n)return null;var i=n.getChildren(r,t);return e.Utilities.SearchAllTransformNodesForTags(a,i)},n.FindChildTransformWithScript=function(n,a,t,r){if(void 0===t&&(t=!0),void 0===r&&(r=null),null==n)return null;var i=n.getChildren(r,t);return e.Utilities.SearchTransformNodeForScript(a,i)},n.FindAllChildTransformsWithScript=function(n,a,t,r){if(void 0===t&&(t=!0),void 0===r&&(r=null),null==n)return null;var i=n.getChildren(r,t);return e.Utilities.SearchAllTransformNodesForScript(a,i)},n.SearchForScriptComponentByName=function(n,a){var t=n.getNodes(),r=e.Utilities.SearchTransformNodeForScript(a,t);return e.SceneManager.FindScriptComponent(r,a)},n.SearchForAllScriptComponentsByName=function(n,a){var t=null,r=n.getNodes(),i=e.Utilities.SearchAllTransformNodesForScript(a,r);return null!=i&&i.length>0&&i.forEach(function(n){var r=e.SceneManager.FindScriptComponent(n,a);null!=r&&(null==t&&(t=[]),t.push(r))}),null!=t?t:null},n.MoveWithCollisions=function(e,n){return null==e?null:void(null!=n&&e.moveWithCollisions(n))},n.MoveWithTranslation=function(e,n){return null==e?null:void(null!=n&&e.position.addInPlace(n))},n.TurnWithRotation=function(n,a,t){return void 0===t&&(t=e.Space.LOCAL),null==n?null:void(0!=a&&n.rotate(e.Axis.Y,a,t))},n.GetPhysicsHeapSize=function(){if("undefined"==typeof Ammo)return 0;var e=0;return Ammo&&Ammo.HEAP8&&Ammo.HEAP8.length&&(e=Ammo.HEAP8.length/1048576),e},n.ConfigurePhysicsEngine=function(n,a,t,r,i,o,l){if(void 0===a&&(a=!0),void 0===t&&(t=0),void 0===r&&(r=0),void 0===i&&(i=!0),void 0===o&&(o=0),void 0===l&&(l=null),"undefined"!=typeof Ammo){var s=new e.Vector3(0,(-9.81),0),u=null!=l?l:s;if(Ammo&&e.AmmoJSPlugin){var c=n.isPhysicsEnabled(),d=c===!0?n.getPhysicsEngine():null,g=c===!0&&null!=d?d.getPhysicsPlugin():null,m=c===!0&&null!=d&&"AmmoJSPlugin"===d.getPhysicsPluginName();if(m===!1){var p=null,f=e.SceneManager.GetPhysicsHeapSize();if(r>0){var h=new Ammo.btAxisSweep3(new Ammo.btVector3((-r),(-r),(-r)),new Ammo.btVector3(r,r,r));p=new e.AmmoJSPlugin(a,Ammo,h),e.Tools.Log("Ammo.js plugin (btAxisSweep3 - "+f+" MB)")}else p=new e.AmmoJSPlugin(a),e.Tools.Log("Ammo.js plugin (btDbvtBroadphase - "+f+" MB)");null!=e.SceneManager.OnSetupPhysicsPlugin&&e.SceneManager.OnSetupPhysicsPlugin(n,p),p.onCreateCustomShape=function(a){var t=null,r="Unknown",i=a.object;if(null!=i.name&&(r=i.name),null!=i._colliderType){var o=i._colliderType;t=e.Utilities.CreateImpostorCustomShape(n,a,o,e.Utilities.ShowDebugColliders(),e.Utilities.ColliderVisibility())}else e.Tools.Warn("No custom shape collider type defined for entity: "+r);return t},n.enablePhysics(u,p),c=n.isPhysicsEnabled(),d=c===!0?n.getPhysicsEngine():null,g=c===!0&&null!=d?d.getPhysicsPlugin():null,m=c===!0&&null!=d&&"AmmoJSPlugin"===d.getPhysicsPluginName(),null!=d&&t>0&&d.setSubTimeStep(t)}else e.Tools.Warn("Ammo.js plugin enabled");if(m===!0&&null!=d&&null!=g&&null!=g.world){if(null==Ammo.btSmoothTriangleMesh&&e.Tools.Warn("Ammo.js using default triangle"),null==Ammo.btSmoothVehicleRaycaster&&e.Tools.Warn("Ammo.js using default vehicle raycaster"),g.world.getBroadphase().getOverlappingPairCache().setInternalGhostPairCallback(new Ammo.btGhostPairCallback),g.world.getDispatchInfo().set_m_allowedCcdPenetration(o),Ammo.addFunction){var S="iiiiiiii",M=Ammo.addFunction(function(e,n,a,t,r,i,o){return!!g.world.adjustInternalEdgeContacts&&(g.world.adjustInternalEdgeContacts(e,r,n,i,o),!0)},S);null!=M?(g.world.setContactAddedCallback(M),e.Tools.Log("Ammo.js internal edges supported")):e.Tools.Warn("Ammo.js failed to load addFunction. Internal edge contact support disabled.")}else e.Tools.Warn("Ammo.js is missing addFunction. Internal edge contact support disabled.");var y=n;y._monitorContactManifolds||(y._monitorContactManifolds=!0,i===!0&&(e.Tools.Log("Ammo.js contact manifolds enabled"),n.registerBeforeRender(function(){var e=g.world.getDispatcher().getNumManifolds();if(e>0)for(var n=0;n<e;n++){var a=g.world.getDispatcher().getManifoldByIndexInternal(n),t=Ammo.castObject(a.getBody0(),Ammo.btCollisionObject),r=Ammo.castObject(a.getBody1(),Ammo.btCollisionObject);null!=t&&null!=t.entity&&null!=t.entity.physicsImpostor&&null!=r&&null!=r.entity&&r.isActive()&&null!=t.entity.physicsImpostor.tmpCollisionObjects&&(t.entity.physicsImpostor.tmpCollisionObjects[r.entity.uniqueId]=r.entity),null!=r&&null!=r.entity&&null!=r.entity.physicsImpostor&&null!=t&&null!=t.entity&&t.isActive()&&null!=r.entity.physicsImpostor.tmpCollisionObjects&&(r.entity.physicsImpostor.tmpCollisionObjects[t.entity.uniqueId]=t.entity)}})))}else e.Tools.Warn("Ammo.js physics plugins are invalid")}else e.Tools.Warn("Ammo.js physics plugin not available")}},n.GetPhysicsEngine=function(e){return"undefined"==typeof Ammo?null:e.getPhysicsEngine()},n.GetPhysicsWorld=function(n){if("undefined"==typeof Ammo)return null;var a=null,t=e.SceneManager.GetPhysicsEngine(n);if(null!=t){var r=t.getPhysicsPlugin();null!=r&&(a=r.world)}return a},n.PhysicsRaycast=function(n,a,t,r,i,o){if(void 0===i&&(i=null),void 0===o&&(o=null),null==n)return null;if("undefined"==typeof Ammo)return null;if(null==e.SceneManager.TempPhysicsWorld&&(e.SceneManager.TempPhysicsWorld=e.SceneManager.GetPhysicsWorld(n)),null==e.SceneManager.TempPhysicsWorld)return null;null==e.SceneManager.TempVRayDest&&(e.SceneManager.TempVRayDest=new Ammo.btVector3(0,0,0)),null==e.SceneManager.TempVRayOrigin&&(e.SceneManager.TempVRayOrigin=new Ammo.btVector3(0,0,0)),null==e.SceneManager.TempCastEndPoint&&(e.SceneManager.TempCastEndPoint=new e.Vector3(0,0,0)),null==e.SceneManager.TempRaycastResult&&(e.SceneManager.TempRaycastResult=new e.RaycastHitResult),null==e.SceneManager.ClosestRayResultCallback&&(e.SceneManager.ClosestRayResultCallback=new Ammo.ClosestRayResultCallback(e.SceneManager.TempVRayOrigin,e.SceneManager.TempVRayDest));var l=Ammo.castObject(e.SceneManager.ClosestRayResultCallback,Ammo.RayResultCallback);if(l.set_m_closestHitFraction(1),l.set_m_collisionObject(null),null!=i?l.set_m_collisionFilterGroup(i):l.set_m_collisionFilterGroup(e.CollisionFilters.DefaultFilter),null!=o?l.set_m_collisionFilterMask(o):l.set_m_collisionFilterMask(e.CollisionFilters.AllFilter),e.SceneManager.TempCastEndPoint.copyFrom(a),t.scaleAndAddToRef(r,e.SceneManager.TempCastEndPoint),e.SceneManager.TempVRayOrigin.setValue(a.x,a.y,a.z),e.SceneManager.TempVRayDest.setValue(e.SceneManager.TempCastEndPoint.x,e.SceneManager.TempCastEndPoint.y,e.SceneManager.TempCastEndPoint.z),e.SceneManager.ClosestRayResultCallback.get_m_rayFromWorld().setValue(a.x,a.y,a.z),e.SceneManager.ClosestRayResultCallback.get_m_rayToWorld().setValue(e.SceneManager.TempCastEndPoint.x,e.SceneManager.TempCastEndPoint.y,e.SceneManager.TempCastEndPoint.z),e.SceneManager.TempRaycastResult.reset(a,e.SceneManager.TempCastEndPoint),e.SceneManager.TempPhysicsWorld.rayTest(e.SceneManager.TempVRayOrigin,e.SceneManager.TempVRayDest,e.SceneManager.ClosestRayResultCallback),e.SceneManager.ClosestRayResultCallback.hasHit()){var s=e.SceneManager.ClosestRayResultCallback.get_m_hitPointWorld(),u=e.SceneManager.ClosestRayResultCallback.get_m_hitNormalWorld();e.SceneManager.TempRaycastResult.update(!0,s.x(),s.y(),s.z(),u.x(),u.y(),u.z(),l.get_m_collisionObject())}return e.SceneManager.TempRaycastResult},n.PhysicsRaycastToPoint=function(n,a,t,r,i){if(void 0===r&&(r=null),void 0===i&&(i=null),null==n)return null;if("undefined"==typeof Ammo)return null;if(null==e.SceneManager.TempPhysicsWorld&&(e.SceneManager.TempPhysicsWorld=e.SceneManager.GetPhysicsWorld(n)),null==e.SceneManager.TempPhysicsWorld)return null;null==e.SceneManager.TempVRayDest&&(e.SceneManager.TempVRayDest=new Ammo.btVector3(0,0,0)),null==e.SceneManager.TempVRayOrigin&&(e.SceneManager.TempVRayOrigin=new Ammo.btVector3(0,0,0)),null==e.SceneManager.TempRaycastResult&&(e.SceneManager.TempRaycastResult=new e.RaycastHitResult),null==e.SceneManager.ClosestRayResultCallback&&(e.SceneManager.ClosestRayResultCallback=new Ammo.ClosestRayResultCallback(e.SceneManager.TempVRayOrigin,e.SceneManager.TempVRayDest));var o=Ammo.castObject(e.SceneManager.ClosestRayResultCallback,Ammo.RayResultCallback);if(o.set_m_closestHitFraction(1),o.set_m_collisionObject(null),null!=r?o.set_m_collisionFilterGroup(r):o.set_m_collisionFilterGroup(e.CollisionFilters.DefaultFilter),null!=i?o.set_m_collisionFilterMask(i):o.set_m_collisionFilterMask(e.CollisionFilters.AllFilter),e.SceneManager.TempVRayOrigin.setValue(a.x,a.y,a.z),e.SceneManager.TempVRayDest.setValue(t.x,t.y,t.z),e.SceneManager.ClosestRayResultCallback.get_m_rayFromWorld().setValue(a.x,a.y,a.z),e.SceneManager.ClosestRayResultCallback.get_m_rayToWorld().setValue(t.x,t.y,t.z),e.SceneManager.TempRaycastResult.reset(a,t),e.SceneManager.TempPhysicsWorld.rayTest(e.SceneManager.TempVRayOrigin,e.SceneManager.TempVRayDest,e.SceneManager.ClosestRayResultCallback),e.SceneManager.ClosestRayResultCallback.hasHit()){var l=e.SceneManager.ClosestRayResultCallback.get_m_hitPointWorld(),s=e.SceneManager.ClosestRayResultCallback.get_m_hitNormalWorld();e.SceneManager.TempRaycastResult.update(!0,l.x(),l.y(),l.z(),s.x(),s.y(),s.z(),o.get_m_collisionObject())}return e.SceneManager.TempRaycastResult},n.PhysicsShapecast=function(n,a,t,r,i,o,l){if(void 0===o&&(o=null),void 0===l&&(l=null),null==n)return null;if("undefined"==typeof Ammo)return null;if(null==e.SceneManager.TempPhysicsWorld&&(e.SceneManager.TempPhysicsWorld=e.SceneManager.GetPhysicsWorld(n)),null==e.SceneManager.TempPhysicsWorld)return null;null==e.SceneManager.TempVRayDest&&(e.SceneManager.TempVRayDest=new Ammo.btVector3(0,0,0)),null==e.SceneManager.TempVRayOrigin&&(e.SceneManager.TempVRayOrigin=new Ammo.btVector3(0,0,0)),null==e.SceneManager.TempCastEndPoint&&(e.SceneManager.TempCastEndPoint=new e.Vector3(0,0,0)),null==e.SceneManager.TempTransformFrom&&(e.SceneManager.TempTransformFrom=new Ammo.btTransform),null==e.SceneManager.TempTransformTo&&(e.SceneManager.TempTransformTo=new Ammo.btTransform),null==e.SceneManager.TempRaycastResult&&(e.SceneManager.TempRaycastResult=new e.RaycastHitResult),null==e.SceneManager.ClosestConvexResultCallback&&(e.SceneManager.ClosestConvexResultCallback=new Ammo.ClosestConvexResultCallback(e.SceneManager.TempVRayOrigin,e.SceneManager.TempVRayDest));var s=Ammo.castObject(e.SceneManager.ClosestConvexResultCallback,Ammo.ConvexResultCallback);s.set_m_closestHitFraction(1),null!=o?s.set_m_collisionFilterGroup(o):s.set_m_collisionFilterGroup(e.CollisionFilters.DefaultFilter),null!=l?s.set_m_collisionFilterMask(l):s.set_m_collisionFilterMask(e.CollisionFilters.AllFilter),null!=e.SceneManager.ClosestConvexResultCallback.set_m_hitCollisionObject&&e.SceneManager.ClosestConvexResultCallback.set_m_hitCollisionObject(null),e.SceneManager.TempCastEndPoint.copyFrom(t),r.scaleAndAddToRef(i,e.SceneManager.TempCastEndPoint),e.SceneManager.TempVRayOrigin.setValue(t.x,t.y,t.z),e.SceneManager.TempVRayDest.setValue(e.SceneManager.TempCastEndPoint.x,e.SceneManager.TempCastEndPoint.y,e.SceneManager.TempCastEndPoint.z),e.SceneManager.ClosestConvexResultCallback.get_m_convexFromWorld().setValue(t.x,t.y,t.z),e.SceneManager.ClosestConvexResultCallback.get_m_convexToWorld().setValue(e.SceneManager.TempCastEndPoint.x,e.SceneManager.TempCastEndPoint.y,e.SceneManager.TempCastEndPoint.z);var u=0;if(e.SceneManager.TempRaycastResult.reset(t,e.SceneManager.TempCastEndPoint),e.SceneManager.TempTransformFrom.setIdentity(),e.SceneManager.TempTransformFrom.setOrigin(e.SceneManager.TempVRayOrigin),e.SceneManager.TempTransformTo.setIdentity(),e.SceneManager.TempTransformTo.setOrigin(e.SceneManager.TempVRayDest),e.SceneManager.TempPhysicsWorld.convexSweepTest(a,e.SceneManager.TempTransformFrom,e.SceneManager.TempTransformTo,e.SceneManager.ClosestConvexResultCallback,u),e.SceneManager.ClosestConvexResultCallback.hasHit()){var c=e.SceneManager.ClosestConvexResultCallback.get_m_hitPointWorld(),d=e.SceneManager.ClosestConvexResultCallback.get_m_hitNormalWorld();e.SceneManager.TempRaycastResult.update(!0,c.x(),c.y(),c.z(),d.x(),d.y(),d.z(),e.SceneManager.ClosestConvexResultCallback.get_m_hitCollisionObject())}return e.SceneManager.TempRaycastResult},n.PhysicsShapecastToPoint=function(n,a,t,r,i,o){if(void 0===i&&(i=null),void 0===o&&(o=null),null==n)return null;if("undefined"==typeof Ammo)return null;if(null==e.SceneManager.TempPhysicsWorld&&(e.SceneManager.TempPhysicsWorld=e.SceneManager.GetPhysicsWorld(n)),null==e.SceneManager.TempPhysicsWorld)return null;null==e.SceneManager.TempVRayDest&&(e.SceneManager.TempVRayDest=new Ammo.btVector3(0,0,0)),null==e.SceneManager.TempVRayOrigin&&(e.SceneManager.TempVRayOrigin=new Ammo.btVector3(0,0,0)),null==e.SceneManager.TempTransformFrom&&(e.SceneManager.TempTransformFrom=new Ammo.btTransform),null==e.SceneManager.TempTransformTo&&(e.SceneManager.TempTransformTo=new Ammo.btTransform),null==e.SceneManager.TempRaycastResult&&(e.SceneManager.TempRaycastResult=new e.RaycastHitResult),null==e.SceneManager.ClosestConvexResultCallback&&(e.SceneManager.ClosestConvexResultCallback=new Ammo.ClosestConvexResultCallback(e.SceneManager.TempVRayOrigin,e.SceneManager.TempVRayDest));var l=Ammo.castObject(e.SceneManager.ClosestConvexResultCallback,Ammo.ConvexResultCallback);l.set_m_closestHitFraction(1),null!=i?l.set_m_collisionFilterGroup(i):l.set_m_collisionFilterGroup(e.CollisionFilters.DefaultFilter),null!=o?l.set_m_collisionFilterMask(o):l.set_m_collisionFilterMask(e.CollisionFilters.AllFilter),null!=e.SceneManager.ClosestConvexResultCallback.set_m_hitCollisionObject&&e.SceneManager.ClosestConvexResultCallback.set_m_hitCollisionObject(null),e.SceneManager.TempVRayOrigin.setValue(t.x,t.y,t.z),e.SceneManager.TempVRayDest.setValue(r.x,r.y,r.z),e.SceneManager.ClosestConvexResultCallback.get_m_convexFromWorld().setValue(t.x,t.y,t.z),e.SceneManager.ClosestConvexResultCallback.get_m_convexToWorld().setValue(r.x,r.y,r.z);var s=0;if(e.SceneManager.TempRaycastResult.reset(t,r),e.SceneManager.TempTransformFrom.setIdentity(),e.SceneManager.TempTransformFrom.setOrigin(e.SceneManager.TempVRayOrigin),e.SceneManager.TempTransformTo.setIdentity(),e.SceneManager.TempTransformTo.setOrigin(e.SceneManager.TempVRayDest),e.SceneManager.TempPhysicsWorld.convexSweepTest(a,e.SceneManager.TempTransformFrom,e.SceneManager.TempTransformTo,e.SceneManager.ClosestConvexResultCallback,s),e.SceneManager.ClosestConvexResultCallback.hasHit()){var u=e.SceneManager.ClosestConvexResultCallback.get_m_hitPointWorld(),c=e.SceneManager.ClosestConvexResultCallback.get_m_hitNormalWorld();e.SceneManager.TempRaycastResult.update(!0,u.x(),u.y(),u.z(),c.x(),c.y(),c.z(),e.SceneManager.ClosestConvexResultCallback.get_m_hitCollisionObject())}return e.SceneManager.TempRaycastResult},n.CreatePhysicsImpostor=function(n,a,t,r,i){if(void 0===i&&(i=!0),null!=a&&"undefined"!=typeof Ammo){a.checkCollisions=!1;var o=a.parent;i===!0&&(a.parent=null),a._colliderType=t;var l=t;switch(t){case e.PhysicsImpostor.MeshImpostor:case e.PhysicsImpostor.BoxImpostor:case e.PhysicsImpostor.SphereImpostor:case e.PhysicsImpostor.CapsuleImpostor:case e.PhysicsImpostor.ConvexHullImpostor:l=e.PhysicsImpostor.CustomImpostor}a.physicsImpostor=new e.PhysicsImpostor(a,l,r,n),i===!0&&(a.parent=o)}},n.GetPhysicsImposterType=function(n){if("undefined"==typeof Ammo)return null;
  var a="Unknown";switch(n){case e.PhysicsImpostor.NoImpostor:a="No";break;case e.PhysicsImpostor.SphereImpostor:a="Sphere";break;case e.PhysicsImpostor.BoxImpostor:a="Box";break;case e.PhysicsImpostor.PlaneImpostor:a="Plane";break;case e.PhysicsImpostor.MeshImpostor:a="Mesh";break;case e.PhysicsImpostor.CapsuleImpostor:a="Capsule";break;case e.PhysicsImpostor.CylinderImpostor:a="Cylinder";break;case e.PhysicsImpostor.ParticleImpostor:a="Particle";break;case e.PhysicsImpostor.HeightmapImpostor:a="Heightmap";break;case e.PhysicsImpostor.ConvexHullImpostor:a="ConvexHull";break;case e.PhysicsImpostor.CustomImpostor:a="CustomShape"}return a},n.CreatePhysicsBoxShape=function(n){return"undefined"==typeof Ammo?null:(null==e.SceneManager.TempShapeVector&&(e.SceneManager.TempShapeVector=new Ammo.btVector3(0,0,0)),e.SceneManager.TempShapeVector.setValue(n.x,n.y,n.z),new Ammo.btBoxShape(e.SceneManager.TempShapeVector))},n.CreatePhysicsSphereShape=function(e){return"undefined"==typeof Ammo?null:new Ammo.btSphereShape(e)},n.CreatePhysicsCapsuleShape=function(e,n){return"undefined"==typeof Ammo?null:new Ammo.btCapsuleShape(e,n)},n.CreatePhysicsCompoundShape=function(e){return void 0===e&&(e=!1),"undefined"==typeof Ammo?null:new Ammo.btCompoundShape(e)},n.CreatePhysicsEmptyShape=function(){return"undefined"==typeof Ammo?null:new Ammo.btEmptyShape},n.GetRecastHeapSize=function(){if("undefined"==typeof Recast)return 0;var e=0;return Recast&&Recast.HEAP8&&Recast.HEAP8.length&&(e=Recast.HEAP8.length/1048576),e},n.GetNavigationTools=function(){if("undefined"!=typeof Recast)return null==e.SceneManager.PluginInstance&&(e.SceneManager.PluginInstance=new e.RecastJSPlugin),e.SceneManager.PluginInstance},n.GetCrowdInterface=function(n){if("undefined"==typeof Recast)return null;if(e.SceneManager.HasNavigationData()){var a=e.SceneManager.GetNavigationTools();return null!=a&&null==e.SceneManager.CrowdInterface&&(e.SceneManager.CrowdInterface=a.createCrowd(e.SceneManager.MAX_AGENT_COUNT,e.SceneManager.MAX_AGENT_RADIUS,n)),e.SceneManager.CrowdInterface}return null},n.HasNavigationData=function(){if("undefined"==typeof Recast)return!1;var n=e.SceneManager.GetNavigationTools();return null!=n&&null!=n.navMesh},n.GetNavigationMesh=function(){return"undefined"==typeof Recast?null:e.SceneManager.NavigationMesh},n.BakeNavigationMesh=function(n,a,t,r,i,o){if(void 0===r&&(r=!1),void 0===i&&(i=null),void 0===o&&(o=!1),"undefined"==typeof Recast)return null;e.Tools.Log("Recast.js baking navigation mesh data");var l=e.SceneManager.GetNavigationTools();if(null!=l)if(l.createNavMesh(a,t),null!=l.navMesh){var s="NavigationMesh",u=n.getMaterialByName(s);null==u&&(u=new e.StandardMaterial(s,n),u.diffuseColor=i||new e.Color3(.05,.225,.75),u.alpha=.5),e.SceneManager.NavigationMesh=l.createDebugNavMesh(n),null!=e.SceneManager.NavigationMesh&&(e.SceneManager.NavigationMesh.material=u,e.SceneManager.NavigationMesh.isPickable=!0,e.SceneManager.NavigationMesh.isVisible=!0,e.SceneManager.NavigationMesh.visibility=r===!0?1:0,e.Tags.AddTagsTo(e.SceneManager.NavigationMesh,"Navigation"),e.Utilities.ValidateTransformMetadata(e.SceneManager.NavigationMesh),o===!0&&(e.SceneManager.NavigationMesh.checkCollisions=!0,e.RigidbodyPhysics&&(e.SceneManager.NavigationMesh.metadata.unity.physics=e.RigidbodyPhysics.CreatePhysicsMetadata(0,0,.05,new e.Vector3(0,0,0)),e.SceneManager.NavigationMesh.metadata.unity.collision=e.RigidbodyPhysics.CreateCollisionMetadata("MeshCollider",!1,!1,0,.6,.6),e.RigidbodyPhysics.SetupPhysicsComponent(n,e.SceneManager.NavigationMesh)))),null!=e.SceneManager.NavigationMesh?e.SceneManager.OnNavMeshReadyObservable.hasObservers()===!0&&e.SceneManager.OnNavMeshReadyObservable.notifyObservers(e.SceneManager.NavigationMesh):e.Tools.Warn("Failed to generate navigation mesh geometry")}else e.Tools.Warn("Failed to create navigation mesh data");return e.SceneManager.NavigationMesh},n.LoadNavigationMesh=function(n,a,t,r,i,o){if(void 0===t&&(t=!1),void 0===r&&(r=null),void 0===i&&(i=0),void 0===o&&(o=!1),"undefined"==typeof Recast)return null;e.Tools.Log("Recast.js loading prebaked navigation mesh");var l=e.SceneManager.GetNavigationTools();if(null!=l)if(l.setTimeStep&&l.setTimeStep(i),l.buildFromNavmeshData(a),null!=l.navMesh){var s="NavigationMesh",u=n.getMaterialByName(s);null==u&&(u=new e.StandardMaterial(s,n),u.diffuseColor=r||new e.Color3(.05,.225,.75),u.alpha=.5),e.SceneManager.NavigationMesh=l.createDebugNavMesh(n),null!=e.SceneManager.NavigationMesh&&(e.SceneManager.NavigationMesh.material=u,e.SceneManager.NavigationMesh.isPickable=!0,e.SceneManager.NavigationMesh.isVisible=!0,e.SceneManager.NavigationMesh.visibility=t===!0?1:0,e.Tags.AddTagsTo(e.SceneManager.NavigationMesh,"Navigation"),e.Utilities.ValidateTransformMetadata(e.SceneManager.NavigationMesh),o===!0&&(e.SceneManager.NavigationMesh.checkCollisions=!0,e.RigidbodyPhysics&&(e.SceneManager.NavigationMesh.metadata.unity.physics=e.RigidbodyPhysics.CreatePhysicsMetadata(0,0,.05,new e.Vector3(0,0,0)),e.SceneManager.NavigationMesh.metadata.unity.collision=e.RigidbodyPhysics.CreateCollisionMetadata("MeshCollider",!1,!1,0,.6,.6),e.RigidbodyPhysics.SetupPhysicsComponent(n,e.SceneManager.NavigationMesh)))),null!=e.SceneManager.NavigationMesh?e.SceneManager.OnNavMeshReadyObservable.hasObservers()===!0&&e.SceneManager.OnNavMeshReadyObservable.notifyObservers(e.SceneManager.NavigationMesh):e.Tools.Warn("Failed to generate navigation mesh geometry")}else e.Tools.Warn("Failed to build navigation mesh data");return e.SceneManager.NavigationMesh},n.SaveNavigationMesh=function(){if("undefined"==typeof Recast)return null;var n=e.SceneManager.GetNavigationTools();return null!=n&&null!=n.navMesh?n.getNavmeshData():null},n.ComputeNavigationPath=function(n,a,t){if(void 0===t&&(t=!0),"undefined"==typeof Recast)return null;var r=e.SceneManager.GetNavigationTools(),i=t===!0?r.getClosestPoint(n):n,o=t===!0?r.getClosestPoint(a):a;return null!=r&&null!=r.navMesh?r.computePath(i,o):null},n.MoveAlongNavigationPath=function(n,a,t,r,i,o){void 0===i&&(i=null);var l=null;if(t&&t.length>0){for(var s=0,u=[{frame:0,value:a.position}],c=0;c<t.length;c++)s+=e.Vector3.Distance(u[c].value,t[c]),u.push({frame:s,value:t[c]});l=new e.Animation("Navigation","position",3,e.Animation.ANIMATIONTYPE_VECTOR3,e.Animation.ANIMATIONLOOPMODE_CONSTANT),null!=i&&l.setEasingFunction(i),l.setKeys(u),a.animations=[l],n.beginAnimation(a,0,s,!1,r,o)}return l},n.AddNavigationCylinderObstacle=function(n,a,t){if("undefined"==typeof Recast)return null;var r=e.SceneManager.GetNavigationTools();return null!=r&&null!=r.navMesh?r.addCylinderObstacle(n,a,t):null},n.AddNavigationBoxObstacle=function(n,a,t){if("undefined"==typeof Recast)return null;var r=e.SceneManager.GetNavigationTools();return null!=r&&null!=r.navMesh?r.addBoxObstacle(n,a,t):null},n.RemoveNavigationObstacle=function(n){if("undefined"==typeof Recast)return null;var a=e.SceneManager.GetNavigationTools();null!=a&&null!=a.navMesh&&a.removeObstacle(n)},n.ConfigureUserInput=function(n,a){void 0===a&&(a=null);var t=!(null==a||!a.pointerLock)&&a.pointerLock,r=!(null==a||!a.preventDefault)&&a.preventDefault,i=!(null==a||!a.useCapture)&&a.useCapture,o=!(null==a||!a.enableVirtualJoystick)&&a.enableVirtualJoystick,l=!(null==a||!a.disableRightStick)&&a.disableRightStick;if(e.SceneManager.resetUserInput(),!e.SceneManager.input){if(document.documentElement.tabIndex=1,document.documentElement.addEventListener("keyup",e.SceneManager.inputKeyUpHandler,i),document.documentElement.addEventListener("pointerup",e.SceneManager.inputPointerUpHandler,i),e.UserInputOptions.UseCanvasElement===!0){var s=document.getElementById("renderingCanvas")||n.getEngine().getRenderingCanvas();s.tabIndex=2,s.addEventListener("focusout",e.SceneManager.resetKeyMapHandler,i),s.addEventListener("keydown",e.SceneManager.inputKeyDownHandler,i),s.addEventListener("pointerdown",e.SceneManager.inputPointerDownHandler,i),s.addEventListener("pointermove",e.SceneManager.inputPointerMoveHandler,i),s.addEventListener("onwheel"in document?"wheel":"mousewheel",e.SceneManager.inputPointerWheelHandler,i)}else document.documentElement.addEventListener("focusout",e.SceneManager.resetKeyMapHandler,i),document.documentElement.addEventListener("keydown",e.SceneManager.inputKeyDownHandler,i),document.documentElement.addEventListener("pointerdown",e.SceneManager.inputPointerDownHandler,i),document.documentElement.addEventListener("pointermove",e.SceneManager.inputPointerMoveHandler,i),document.documentElement.addEventListener("onwheel"in document?"wheel":"mousewheel",e.SceneManager.inputPointerWheelHandler,i);e.SceneManager.preventDefault=r,null==e.SceneManager.GamepadManager&&(e.SceneManager.GamepadManager=new e.GamepadManager,e.SceneManager.GamepadManager.onGamepadConnectedObservable.add(e.SceneManager.inputManagerGamepadConnected),e.SceneManager.GamepadManager.onGamepadDisconnectedObservable.add(e.SceneManager.inputManagerGamepadDisconnected)),e.SceneManager.virtualJoystick===!1&&(e.SceneManager.virtualJoystick=o,e.SceneManager.virtualJoystick===!0&&(null==e.SceneManager.leftJoystick&&(e.SceneManager.leftJoystick=new e.VirtualJoystick((!0)),e.SceneManager.leftJoystick.setJoystickSensibility(5*e.UserInputOptions.JoystickLeftSensibility)),l===!1&&null==e.SceneManager.rightJoystick&&(e.SceneManager.rightJoystick=new e.VirtualJoystick((!1)),e.SceneManager.rightJoystick.reverseUpDown=!0,e.SceneManager.rightJoystick.setJoystickSensibility(5*e.UserInputOptions.JoystickRightSensibility),e.SceneManager.rightJoystick.setJoystickColor(e.UserInputOptions.JoystickRightHandleColor)))),e.SceneManager.input=!0,document.documentElement.focus(),t===!0&&e.SceneManager.LockMousePointer(n,!0)}n.registerAfterRender(function(){e.SceneManager.updateUserInput(n)})},n.DisableUserInput=function(n,a){void 0===a&&(a=!1),e.SceneManager.LockMousePointer(n,!1),e.SceneManager.resetUserInput()},n.ToggleFullscreenMode=function(e,n){void 0===n&&(n=!0),e.getEngine().switchFullscreen(n)},n.EnterFullscreenMode=function(e,n){void 0===n&&(n=!0),e.getEngine().enterFullscreen(n)},n.ExitFullscreenMode=function(e){e.getEngine().exitFullscreen()},n.LockMousePointer=function(n,a){a===!0?e.SceneManager.LockMousePointerObserver=n.onPointerObservable.add(function(a,t){a.type==e.PointerEventTypes.POINTERDOWN&&(document.pointerLockElement||n.getEngine().enterPointerlock())}):e.SceneManager.IsPointerLockHandled()&&(n.onPointerObservable.remove(e.SceneManager.LockMousePointerObserver),e.SceneManager.LockMousePointerObserver=null)},n.IsPointerLocked=function(){return e.SceneManager.PointerLockedFlag},n.IsPointerLockHandled=function(){return null!=e.SceneManager.LockMousePointerObserver},n.GetUserInput=function(n,a){void 0===a&&(a=e.PlayerNumber.One);var t=0;if(e.SceneManager.input)switch(n){case e.UserInputAxis.Vertical:case e.UserInputAxis.Horizontal:t=a===e.PlayerNumber.Four?n===e.UserInputAxis.Horizontal?e.SceneManager.horizontal4:e.SceneManager.vertical4:a===e.PlayerNumber.Three?n===e.UserInputAxis.Horizontal?e.SceneManager.horizontal3:e.SceneManager.vertical3:a===e.PlayerNumber.Two?n===e.UserInputAxis.Horizontal?e.SceneManager.horizontal2:e.SceneManager.vertical2:n===e.UserInputAxis.Horizontal?e.SceneManager.horizontal:e.SceneManager.vertical;break;case e.UserInputAxis.MouseX:case e.UserInputAxis.MouseY:t=a===e.PlayerNumber.Four?n===e.UserInputAxis.MouseX?e.SceneManager.mousex4:e.SceneManager.mousey4:a===e.PlayerNumber.Three?n===e.UserInputAxis.MouseX?e.SceneManager.mousex3:e.SceneManager.mousey3:a===e.PlayerNumber.Two?n===e.UserInputAxis.MouseX?e.SceneManager.mousex2:e.SceneManager.mousey2:n===e.UserInputAxis.MouseX?e.SceneManager.mousex:e.SceneManager.mousey;break;case e.UserInputAxis.Wheel:a===e.PlayerNumber.One&&(t=e.SceneManager.wheel)}return t},n.OnKeyboardUp=function(n){e.SceneManager.input&&e.SceneManager.keyButtonUp.push(n)},n.OnKeyboardDown=function(n){e.SceneManager.input&&e.SceneManager.keyButtonDown.push(n)},n.OnKeyboardPress=function(n,a){e.SceneManager.input&&e.SceneManager.keyButtonPress.push({index:n,action:a})},n.GetKeyboardInput=function(n){var a=!1;if(e.SceneManager.input){var t="k:"+n.toString();null!=e.SceneManager.keymap[t]&&(a=e.SceneManager.keymap[t])}return a},n.OnPointerUp=function(n){e.SceneManager.input&&e.SceneManager.mouseButtonUp.push(n)},n.OnPointerDown=function(n){e.SceneManager.input&&e.SceneManager.mouseButtonDown.push(n)},n.OnPointerPress=function(n,a){e.SceneManager.input&&e.SceneManager.mouseButtonPress.push({index:n,action:a})},n.GetPointerInput=function(n){var a=!1;if(e.SceneManager.input){var t="p:"+n.toString();null!=e.SceneManager.keymap[t]&&(a=e.SceneManager.keymap[t])}return a},n.GetLeftJoystick=function(){return e.SceneManager.input?e.SceneManager.leftJoystick:null},n.GetRightJoystick=function(){return e.SceneManager.input?e.SceneManager.rightJoystick:null},n.GetJoystickPress=function(n){var a=!1;return e.SceneManager.input&&(n===e.JoystickButton.Left&&null!=e.SceneManager.leftJoystick&&e.SceneManager.leftJoystick.pressed===!0?a=!0:n===e.JoystickButton.Right&&null!=e.SceneManager.rightJoystick&&e.SceneManager.rightJoystick.pressed===!0&&(a=!0)),a},n.DisposeVirtualJoysticks=function(){e.SceneManager.input&&(null!=e.SceneManager.leftJoystick&&(e.SceneManager.leftJoystick.releaseCanvas(),e.SceneManager.leftJoystick=null),null!=e.SceneManager.rightJoystick&&(e.SceneManager.rightJoystick.releaseCanvas(),e.SceneManager.rightJoystick=null),e.SceneManager.virtualJoystick=!1)},n.OnGamepadButtonUp=function(n,a){if(void 0===a&&(a=e.PlayerNumber.One),e.SceneManager.input)switch(a){case e.PlayerNumber.One:e.SceneManager.gamepad1ButtonUp.push(n);break;case e.PlayerNumber.Two:e.SceneManager.gamepad2ButtonUp.push(n);break;case e.PlayerNumber.Three:e.SceneManager.gamepad3ButtonUp.push(n);break;case e.PlayerNumber.Four:e.SceneManager.gamepad4ButtonUp.push(n)}},n.OnGamepadButtonDown=function(n,a){if(void 0===a&&(a=e.PlayerNumber.One),e.SceneManager.input)switch(a){case e.PlayerNumber.One:e.SceneManager.gamepad1ButtonDown.push(n);break;case e.PlayerNumber.Two:e.SceneManager.gamepad2ButtonDown.push(n);break;case e.PlayerNumber.Three:e.SceneManager.gamepad3ButtonDown.push(n);break;case e.PlayerNumber.Four:e.SceneManager.gamepad4ButtonDown.push(n)}},n.OnGamepadButtonPress=function(n,a,t){if(void 0===t&&(t=e.PlayerNumber.One),e.SceneManager.input)switch(t){case e.PlayerNumber.One:e.SceneManager.gamepad1ButtonPress.push({index:n,action:a});break;case e.PlayerNumber.Two:e.SceneManager.gamepad2ButtonPress.push({index:n,action:a});break;case e.PlayerNumber.Three:e.SceneManager.gamepad3ButtonPress.push({index:n,action:a});break;case e.PlayerNumber.Four:e.SceneManager.gamepad4ButtonPress.push({index:n,action:a})}},n.GetGamepadButtonInput=function(n,a){void 0===a&&(a=e.PlayerNumber.One);var t=!1;if(e.SceneManager.input){var r=null;switch(a){case e.PlayerNumber.One:r="b1:"+n.toString();break;case e.PlayerNumber.Two:r="b2:"+n.toString();break;case e.PlayerNumber.Three:r="b3:"+n.toString();break;case e.PlayerNumber.Four:r="b4:"+n.toString()}null!=r&&null!=e.SceneManager.keymap[r]&&(t=e.SceneManager.keymap[r])}return t},n.OnGamepadDirectionUp=function(n,a){if(void 0===a&&(a=e.PlayerNumber.One),e.SceneManager.input)switch(a){case e.PlayerNumber.One:e.SceneManager.gamepad1DpadUp.push(n);break;case e.PlayerNumber.Two:e.SceneManager.gamepad2DpadUp.push(n);break;case e.PlayerNumber.Three:e.SceneManager.gamepad3DpadUp.push(n);break;case e.PlayerNumber.Four:e.SceneManager.gamepad4DpadUp.push(n)}},n.OnGamepadDirectionDown=function(n,a){if(void 0===a&&(a=e.PlayerNumber.One),e.SceneManager.input)switch(a){case e.PlayerNumber.One:e.SceneManager.gamepad1DpadDown.push(n);break;case e.PlayerNumber.Two:e.SceneManager.gamepad2DpadDown.push(n);break;case e.PlayerNumber.Three:e.SceneManager.gamepad3DpadDown.push(n);break;case e.PlayerNumber.Four:e.SceneManager.gamepad4DpadDown.push(n)}},n.OnGamepadDirectionPress=function(n,a,t){if(void 0===t&&(t=e.PlayerNumber.One),e.SceneManager.input)switch(t){case e.PlayerNumber.One:e.SceneManager.gamepad1DpadPress.push({index:n,action:a});break;case e.PlayerNumber.Two:e.SceneManager.gamepad2DpadPress.push({index:n,action:a});break;case e.PlayerNumber.Three:e.SceneManager.gamepad3DpadPress.push({index:n,action:a});break;case e.PlayerNumber.Four:e.SceneManager.gamepad4DpadPress.push({index:n,action:a})}},n.GetGamepadDirectionInput=function(n,a){void 0===a&&(a=e.PlayerNumber.One);var t=!1;if(e.SceneManager.input){var r=null;switch(a){case e.PlayerNumber.One:r="d1:"+n.toString();break;case e.PlayerNumber.Two:r="d2:"+n.toString();break;case e.PlayerNumber.Three:r="d3:"+n.toString();break;case e.PlayerNumber.Four:r="d4:"+n.toString()}null!=r&&null!=e.SceneManager.keymap[r]&&(t=e.SceneManager.keymap[r])}return t},n.OnGamepadTriggerLeft=function(n,a){if(void 0===a&&(a=e.PlayerNumber.One),e.SceneManager.input)switch(a){case e.PlayerNumber.One:e.SceneManager.gamepad1LeftTrigger.push(n);break;case e.PlayerNumber.Two:e.SceneManager.gamepad2LeftTrigger.push(n);break;case e.PlayerNumber.Three:e.SceneManager.gamepad3LeftTrigger.push(n);break;case e.PlayerNumber.Four:e.SceneManager.gamepad4LeftTrigger.push(n)}},n.OnGamepadTriggerRight=function(n,a){if(void 0===a&&(a=e.PlayerNumber.One),e.SceneManager.input)switch(a){case e.PlayerNumber.One:e.SceneManager.gamepad1RightTrigger.push(n);break;case e.PlayerNumber.Two:e.SceneManager.gamepad2RightTrigger.push(n);break;case e.PlayerNumber.Three:e.SceneManager.gamepad3RightTrigger.push(n);break;case e.PlayerNumber.Four:e.SceneManager.gamepad4RightTrigger.push(n)}},n.GetGamepadTriggerInput=function(n,a){void 0===a&&(a=e.PlayerNumber.One);var t=0;if(e.SceneManager.input){var r=null;switch(a){case e.PlayerNumber.One:r="t1:"+n.toString();break;case e.PlayerNumber.Two:r="t2:"+n.toString();break;case e.PlayerNumber.Three:r="t3:"+n.toString();break;case e.PlayerNumber.Four:r="t4:"+n.toString()}null!=r&&null!=e.SceneManager.keymap[r]&&(t=e.SceneManager.keymap[r])}return t},n.GetGamepadType=function(n){void 0===n&&(n=e.PlayerNumber.One);var a=e.GamepadType.None;if(e.SceneManager.input)switch(n){case e.PlayerNumber.One:a=e.SceneManager.gamepad1Type;break;case e.PlayerNumber.Two:a=e.SceneManager.gamepad2Type;break;case e.PlayerNumber.Three:a=e.SceneManager.gamepad3Type;break;case e.PlayerNumber.Four:a=e.SceneManager.gamepad4Type}return a},n.GetGamepad=function(n){void 0===n&&(n=e.PlayerNumber.One);var a=null;if(e.SceneManager.input)switch(n){case e.PlayerNumber.One:a=e.SceneManager.gamepad1;break;case e.PlayerNumber.Two:a=e.SceneManager.gamepad2;break;case e.PlayerNumber.Three:a=e.SceneManager.gamepad3;break;case e.PlayerNumber.Four:a=e.SceneManager.gamepad4}return a},n.tickKeyboardInput=function(n){if(e.SceneManager.EnableUserInput!==!1){var a=e.SceneManager.GetKeyboardInput(e.UserInputKey.W)||e.SceneManager.GetKeyboardInput(e.UserInputKey.UpArrow),t=e.SceneManager.GetKeyboardInput(e.UserInputKey.A),r=e.SceneManager.GetKeyboardInput(e.UserInputKey.S)||e.SceneManager.GetKeyboardInput(e.UserInputKey.DownArrow),i=e.SceneManager.GetKeyboardInput(e.UserInputKey.D),o=e.SceneManager.GetKeyboardInput(e.UserInputKey.LeftArrow),l=e.SceneManager.GetKeyboardInput(e.UserInputKey.RightArrow);a===!0?e.SceneManager.k_vertical=e.Utilities.GetKeyboardInputValue(n,e.SceneManager.k_vertical,1):r===!0?e.SceneManager.k_vertical=e.Utilities.GetKeyboardInputValue(n,e.SceneManager.k_vertical,-1):e.SceneManager.k_vertical=0,e.UserInputOptions.UseArrowKeyRotation===!0?(i===!0?e.SceneManager.k_horizontal=e.Utilities.GetKeyboardInputValue(n,e.SceneManager.k_horizontal,1):t===!0?e.SceneManager.k_horizontal=e.Utilities.GetKeyboardInputValue(n,e.SceneManager.k_horizontal,-1):e.SceneManager.k_horizontal=0,l===!0?e.SceneManager.a_mousex=1:o===!0?e.SceneManager.a_mousex=-1:e.SceneManager.a_mousex=0):i===!0||l===!0?e.SceneManager.k_horizontal=e.Utilities.GetKeyboardInputValue(n,e.SceneManager.k_horizontal,1):t===!0||o===!0?e.SceneManager.k_horizontal=e.Utilities.GetKeyboardInputValue(n,e.SceneManager.k_horizontal,-1):e.SceneManager.k_horizontal=0}},n.updateUserInput=function(n){e.SceneManager.EnableUserInput!==!1&&(e.SceneManager.PointerLockedFlag=n.getEngine().isPointerLock,e.SceneManager.tickKeyboardInput(n),e.SceneManager.inputVirtualJoysticks(),e.SceneManager.x_horizontal=0,e.SceneManager.x_vertical=0,e.SceneManager.x_mousex=0,e.SceneManager.x_mousey=0,0!==e.SceneManager.j_horizontal?e.SceneManager.x_horizontal=e.SceneManager.j_horizontal:0!==e.SceneManager.g_horizontal1?e.SceneManager.x_horizontal=e.SceneManager.g_horizontal1:0!==e.SceneManager.k_horizontal&&(e.SceneManager.x_horizontal=e.SceneManager.k_horizontal),0!==e.SceneManager.j_vertical?e.SceneManager.x_vertical=e.SceneManager.j_vertical:0!==e.SceneManager.g_vertical1?e.SceneManager.x_vertical=e.SceneManager.g_vertical1:0!==e.SceneManager.k_vertical&&(e.SceneManager.x_vertical=e.SceneManager.k_vertical),0!==e.SceneManager.j_mousex?e.SceneManager.x_mousex=e.SceneManager.j_mousex:0!==e.SceneManager.g_mousex1?e.SceneManager.x_mousex=e.SceneManager.g_mousex1:0!==e.SceneManager.a_mousex?e.SceneManager.x_mousex=e.SceneManager.a_mousex:0!==e.SceneManager.k_mousex&&(e.SceneManager.x_mousex=e.SceneManager.k_mousex),0!==e.SceneManager.j_mousey?e.SceneManager.x_mousey=e.SceneManager.j_mousey:0!==e.SceneManager.g_mousey1?e.SceneManager.x_mousey=e.SceneManager.g_mousey1:0!==e.SceneManager.k_mousey&&(e.SceneManager.x_mousey=e.SceneManager.k_mousey),e.SceneManager.horizontal=e.SceneManager.x_horizontal,e.SceneManager.vertical=e.SceneManager.x_vertical,e.SceneManager.mousex=e.SceneManager.x_mousex,e.SceneManager.mousey=e.SceneManager.x_mousey,e.SceneManager.wheel=e.SceneManager.x_wheel,e.SceneManager.horizontal2=e.SceneManager.g_horizontal2,e.SceneManager.vertical2=e.SceneManager.g_vertical2,e.SceneManager.mousex2=e.SceneManager.g_mousex2,e.SceneManager.mousey2=e.SceneManager.g_mousey2,e.SceneManager.horizontal3=e.SceneManager.g_horizontal3,e.SceneManager.vertical3=e.SceneManager.g_vertical3,e.SceneManager.mousex3=e.SceneManager.g_mousex3,e.SceneManager.mousey3=e.SceneManager.g_mousey3,e.SceneManager.horizontal4=e.SceneManager.g_horizontal4,e.SceneManager.vertical4=e.SceneManager.g_vertical4,e.SceneManager.mousex4=e.SceneManager.g_mousex4,e.SceneManager.mousey4=e.SceneManager.g_mousey4,e.SceneManager.k_mousex=0,e.SceneManager.k_mousey=0,e.SceneManager.x_mousey=0)},n.resetUserInput=function(){e.SceneManager.input=!1,e.SceneManager.keymap={},e.SceneManager.wheel=0,e.SceneManager.mousex=0,e.SceneManager.mousey=0,e.SceneManager.vertical=0,e.SceneManager.horizontal=0,e.SceneManager.mousex2=0,e.SceneManager.mousey2=0,e.SceneManager.vertical2=0,e.SceneManager.horizontal2=0,e.SceneManager.mousex3=0,e.SceneManager.mousey3=0,e.SceneManager.vertical3=0,e.SceneManager.horizontal3=0,e.SceneManager.mousex4=0,e.SceneManager.mousey4=0,e.SceneManager.vertical4=0,e.SceneManager.horizontal4=0,e.SceneManager.a_mousex=0,e.SceneManager.x_wheel=0,e.SceneManager.x_mousex=0,e.SceneManager.x_mousey=0,e.SceneManager.x_vertical=0,e.SceneManager.x_horizontal=0,e.SceneManager.k_mousex=0,e.SceneManager.k_mousey=0,e.SceneManager.k_vertical=0,e.SceneManager.k_horizontal=0,e.SceneManager.j_mousex=0,e.SceneManager.j_mousey=0,e.SceneManager.j_vertical=0,e.SceneManager.j_horizontal=0,e.SceneManager.g_mousex1=0,e.SceneManager.g_mousey1=0,e.SceneManager.g_vertical1=0,e.SceneManager.g_horizontal1=0,e.SceneManager.g_mousex2=0,e.SceneManager.g_mousey2=0,e.SceneManager.g_vertical2=0,e.SceneManager.g_horizontal2=0,e.SceneManager.g_mousex3=0,e.SceneManager.g_mousey3=0,e.SceneManager.g_vertical3=0,e.SceneManager.g_horizontal3=0,e.SceneManager.g_mousex4=0,e.SceneManager.g_mousey4=0,e.SceneManager.g_vertical4=0,e.SceneManager.g_horizontal4=0,e.SceneManager.preventDefault=!1,e.SceneManager.mouseButtonUp=[],e.SceneManager.mouseButtonDown=[],e.SceneManager.mouseButtonPress=[],e.SceneManager.keyButtonUp=[],e.SceneManager.keyButtonDown=[],e.SceneManager.keyButtonPress=[],e.SceneManager.gamepad1ButtonUp=[],e.SceneManager.gamepad1ButtonDown=[],e.SceneManager.gamepad1ButtonPress=[],e.SceneManager.gamepad1DpadUp=[],e.SceneManager.gamepad1DpadDown=[],e.SceneManager.gamepad1DpadPress=[],e.SceneManager.gamepad1LeftTrigger=[],e.SceneManager.gamepad1RightTrigger=[],e.SceneManager.gamepad2ButtonUp=[],e.SceneManager.gamepad2ButtonDown=[],e.SceneManager.gamepad2ButtonPress=[],e.SceneManager.gamepad2DpadUp=[],e.SceneManager.gamepad2DpadDown=[],e.SceneManager.gamepad2DpadPress=[],e.SceneManager.gamepad2LeftTrigger=[],e.SceneManager.gamepad2RightTrigger=[],e.SceneManager.gamepad3ButtonUp=[],e.SceneManager.gamepad3ButtonDown=[],e.SceneManager.gamepad3ButtonPress=[],e.SceneManager.gamepad3DpadUp=[],e.SceneManager.gamepad3DpadDown=[],e.SceneManager.gamepad3DpadPress=[],e.SceneManager.gamepad3LeftTrigger=[],e.SceneManager.gamepad3RightTrigger=[],e.SceneManager.gamepad4ButtonUp=[],e.SceneManager.gamepad4ButtonDown=[],e.SceneManager.gamepad4ButtonPress=[],e.SceneManager.gamepad4DpadUp=[],e.SceneManager.gamepad4DpadDown=[],e.SceneManager.gamepad4DpadPress=[],e.SceneManager.gamepad4LeftTrigger=[],e.SceneManager.gamepad4RightTrigger=[],e.SceneManager.previousPosition=null},n.resetKeyMapHandler=function(n){e.SceneManager.keymap={}},n.inputKeyDownHandler=function(n){if(e.SceneManager.EnableUserInput===!1)return!1;var a="k:"+n.keyCode.toString(),t=!1;return null!=e.SceneManager.keymap[a]&&(t=e.SceneManager.keymap[a]),e.SceneManager.keymap[a]=!0,null!=e.SceneManager.keyButtonDown&&e.SceneManager.keyButtonDown.length>0&&e.SceneManager.keyButtonDown.forEach(function(e){e(n.keyCode)}),t||null!=e.SceneManager.keyButtonPress&&e.SceneManager.keyButtonPress.length>0&&e.SceneManager.keyButtonPress.forEach(function(e){e.index===n.keyCode&&e.action()}),e.SceneManager.preventDefault&&n.preventDefault(),!0},n.inputKeyUpHandler=function(n){if(e.SceneManager.EnableUserInput===!1)return!1;var a="k:"+n.keyCode.toString();return e.SceneManager.keymap[a]=!1,null!=e.SceneManager.keyButtonUp&&e.SceneManager.keyButtonUp.length>0&&e.SceneManager.keyButtonUp.forEach(function(e){e(n.keyCode)}),e.SceneManager.preventDefault&&n.preventDefault(),!0},n.inputPointerWheelHandler=function(n){if(e.SceneManager.EnableUserInput===!1)return!1;var a=n.deltaY?-n.deltaY:n.wheelDelta/40;return e.SceneManager.x_wheel=Math.abs(a)>e.UserInputOptions.PointerWheelDeadZone?0+a:0,e.SceneManager.preventDefault&&n.preventDefault(),!0},n.inputPointerDownHandler=function(n){if(e.SceneManager.EnableUserInput===!1)return!1;e.SceneManager.previousPosition={x:n.clientX,y:n.clientY};var a="p:"+n.button.toString(),t=!1;return null!=e.SceneManager.keymap[a]&&(t=e.SceneManager.keymap[a]),e.SceneManager.keymap[a]=!0,null!=e.SceneManager.mouseButtonDown&&e.SceneManager.mouseButtonDown.length>0&&e.SceneManager.mouseButtonDown.forEach(function(e){e(n.button)}),t||null!=e.SceneManager.mouseButtonPress&&e.SceneManager.mouseButtonPress.length>0&&e.SceneManager.mouseButtonPress.forEach(function(e){e.index===n.button&&e.action()}),e.SceneManager.preventDefault&&n.preventDefault(),!0},n.inputPointerUpHandler=function(n){if(e.SceneManager.EnableUserInput===!1)return!1;e.SceneManager.previousPosition=null,e.SceneManager.k_mousex=0,e.SceneManager.k_mousey=0;var a="p:"+n.button.toString();return e.SceneManager.keymap[a]=!1,null!=e.SceneManager.mouseButtonUp&&e.SceneManager.mouseButtonUp.length>0&&e.SceneManager.mouseButtonUp.forEach(function(e){e(n.button)}),e.SceneManager.preventDefault&&n.preventDefault(),!0},n.inputPointerMoveHandler=function(n){if(e.SceneManager.EnableUserInput===!1)return!1;if(e.SceneManager.virtualJoystick===!1){var a=0,t=0;e.SceneManager.IsPointerLocked()?(a=n.movementX||n.mozMovementX||n.webkitMovementX||n.msMovementX||0,t=n.movementY||n.mozMovementY||n.webkitMovementY||n.msMovementY||0,e.SceneManager.previousPosition=null):null!=e.SceneManager.previousPosition&&(a=n.clientX-e.SceneManager.previousPosition.x,t=n.clientY-e.SceneManager.previousPosition.y,e.SceneManager.previousPosition={x:n.clientX,y:n.clientY}),e.UserInputOptions.PointerMouseInverted===!0&&(a*=-1,t*=-1),e.SceneManager.rightHanded&&(a*=-1);var r=a*e.UserInputOptions.PointerAngularSensibility*.1,i=t*e.UserInputOptions.PointerAngularSensibility*.1;Math.abs(a)<=e.UserInputOptions.PointerMouseDeadZone&&(r=0),Math.abs(t)<=e.UserInputOptions.PointerMouseDeadZone&&(i=0),e.SceneManager.k_mousex+=r,e.SceneManager.k_mousey+=i}return e.SceneManager.preventDefault&&n.preventDefault(),!0},n.inputVirtualJoysticks=function(){if(e.SceneManager.EnableUserInput!==!1){if(null!=e.SceneManager.leftJoystick){var n=e.SceneManager.leftJoystick.deltaPosition;e.SceneManager.leftJoystick.pressed||(n=n.scale(.9));var a=n.x,t=n.y;n.x=Math.abs(a)>e.UserInputOptions.JoystickDeadStickValue?a:0,n.y=Math.abs(t)>e.UserInputOptions.JoystickDeadStickValue?t:0,e.SceneManager.j_horizontal=n.x,e.SceneManager.j_vertical=n.y}if(null!=e.SceneManager.rightJoystick){var r=e.SceneManager.rightJoystick.deltaPosition;e.SceneManager.rightJoystick.pressed||(r=r.scale(.9));var i=r.x,o=r.y;r.x=Math.abs(i)>e.UserInputOptions.JoystickDeadStickValue?i:0,r.y=Math.abs(o)>e.UserInputOptions.JoystickDeadStickValue?o:0,e.SceneManager.j_mousex=r.x,e.SceneManager.j_mousey=r.y}}},n.inputOneButtonDownHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad1){var a="b1:"+n.toString(),t=!1;null!=e.SceneManager.keymap[a]&&(t=e.SceneManager.keymap[a]),e.SceneManager.keymap[a]=!0,null!=e.SceneManager.gamepad1ButtonDown&&e.SceneManager.gamepad1ButtonDown.length>0&&e.SceneManager.gamepad1ButtonDown.forEach(function(e){e(n)}),t||null!=e.SceneManager.gamepad1ButtonPress&&e.SceneManager.gamepad1ButtonPress.length>0&&e.SceneManager.gamepad1ButtonPress.forEach(function(e){e.index===n&&e.action()})}},n.inputOneButtonUpHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad1){var a="b1:"+n.toString();e.SceneManager.keymap[a]=!1,null!=e.SceneManager.gamepad1ButtonUp&&e.SceneManager.gamepad1ButtonUp.length>0&&e.SceneManager.gamepad1ButtonUp.forEach(function(e){e(n)})}},n.inputOneXboxDPadDownHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad1){var a="d1:"+n.toString(),t=!1;null!=e.SceneManager.keymap[a]&&(t=e.SceneManager.keymap[a]),e.SceneManager.keymap[a]=!0,null!=e.SceneManager.gamepad1DpadDown&&e.SceneManager.gamepad1DpadDown.length>0&&e.SceneManager.gamepad1DpadDown.forEach(function(e){e(n)}),t||null!=e.SceneManager.gamepad1DpadPress&&e.SceneManager.gamepad1DpadPress.length>0&&e.SceneManager.gamepad1DpadPress.forEach(function(e){e.index===n&&e.action()})}},n.inputOneShockDPadDownHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad1){var a="d1:"+n.toString(),t=!1;null!=e.SceneManager.keymap[a]&&(t=e.SceneManager.keymap[a]),e.SceneManager.keymap[a]=!0,null!=e.SceneManager.gamepad1DpadDown&&e.SceneManager.gamepad1DpadDown.length>0&&e.SceneManager.gamepad1DpadDown.forEach(function(e){e(n)}),t||null!=e.SceneManager.gamepad1DpadPress&&e.SceneManager.gamepad1DpadPress.length>0&&e.SceneManager.gamepad1DpadPress.forEach(function(e){e.index===n&&e.action()})}},n.inputOneXboxDPadUpHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad1){var a="d1:"+n.toString();e.SceneManager.keymap[a]=!1,null!=e.SceneManager.gamepad1DpadUp&&e.SceneManager.gamepad1DpadUp.length>0&&e.SceneManager.gamepad1DpadUp.forEach(function(e){e(n)})}},n.inputOneShockDPadUpHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad1){var a="d1:"+n.toString();e.SceneManager.keymap[a]=!1,null!=e.SceneManager.gamepad1DpadUp&&e.SceneManager.gamepad1DpadUp.length>0&&e.SceneManager.gamepad1DpadUp.forEach(function(e){e(n)})}},n.inputOneXboxLeftTriggerHandler=function(n){e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad1&&(e.SceneManager.keymap["t1:0"]=n,null!=e.SceneManager.gamepad1LeftTrigger&&e.SceneManager.gamepad1LeftTrigger.length>0&&e.SceneManager.gamepad1LeftTrigger.forEach(function(e){
  e(n)}))},n.inputOneXboxRightTriggerHandler=function(n){e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad1&&(e.SceneManager.keymap["t1:1"]=n,null!=e.SceneManager.gamepad1RightTrigger&&e.SceneManager.gamepad1RightTrigger.length>0&&e.SceneManager.gamepad1RightTrigger.forEach(function(e){e(n)}))},n.inputOneLeftStickHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad1){var a=n,t=a.x*e.UserInputOptions.GamepadLStickSensibility,r=a.y*e.UserInputOptions.GamepadLStickSensibility;a.x=Math.abs(t)>e.UserInputOptions.GamepadDeadStickValue?t:0,a.y=Math.abs(r)>e.UserInputOptions.GamepadDeadStickValue?r:0,e.SceneManager.g_horizontal1=e.UserInputOptions.GamepadLStickXInverted?-a.x:a.x,e.SceneManager.g_vertical1=e.UserInputOptions.GamepadLStickYInverted?a.y:-a.y}},n.inputOneRightStickHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad1){var a=n,t=a.x*e.UserInputOptions.GamepadRStickSensibility,r=a.y*e.UserInputOptions.GamepadRStickSensibility;a.x=Math.abs(t)>e.UserInputOptions.GamepadDeadStickValue?t:0,a.y=Math.abs(r)>e.UserInputOptions.GamepadDeadStickValue?r:0,e.SceneManager.g_mousex1=e.UserInputOptions.GamepadRStickXInverted?-a.x:a.x,e.SceneManager.g_mousey1=e.UserInputOptions.GamepadRStickYInverted?-a.y:a.y}},n.inputTwoButtonDownHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad2){var a="b2:"+n.toString(),t=!1;null!=e.SceneManager.keymap[a]&&(t=e.SceneManager.keymap[a]),e.SceneManager.keymap[a]=!0,null!=e.SceneManager.gamepad2ButtonDown&&e.SceneManager.gamepad2ButtonDown.length>0&&e.SceneManager.gamepad2ButtonDown.forEach(function(e){e(n)}),t||null!=e.SceneManager.gamepad2ButtonPress&&e.SceneManager.gamepad2ButtonPress.length>0&&e.SceneManager.gamepad2ButtonPress.forEach(function(e){e.index===n&&e.action()})}},n.inputTwoButtonUpHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad2){var a="b2:"+n.toString();e.SceneManager.keymap[a]=!1,null!=e.SceneManager.gamepad2ButtonUp&&e.SceneManager.gamepad2ButtonUp.length>0&&e.SceneManager.gamepad2ButtonUp.forEach(function(e){e(n)})}},n.inputTwoXboxDPadDownHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad2){var a="d2:"+n.toString(),t=!1;null!=e.SceneManager.keymap[a]&&(t=e.SceneManager.keymap[a]),e.SceneManager.keymap[a]=!0,null!=e.SceneManager.gamepad2DpadDown&&e.SceneManager.gamepad2DpadDown.length>0&&e.SceneManager.gamepad2DpadDown.forEach(function(e){e(n)}),t||null!=e.SceneManager.gamepad2DpadPress&&e.SceneManager.gamepad2DpadPress.length>0&&e.SceneManager.gamepad2DpadPress.forEach(function(e){e.index===n&&e.action()})}},n.inputTwoShockDPadDownHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad2){var a="d2:"+n.toString(),t=!1;null!=e.SceneManager.keymap[a]&&(t=e.SceneManager.keymap[a]),e.SceneManager.keymap[a]=!0,null!=e.SceneManager.gamepad2DpadDown&&e.SceneManager.gamepad2DpadDown.length>0&&e.SceneManager.gamepad2DpadDown.forEach(function(e){e(n)}),t||null!=e.SceneManager.gamepad2DpadPress&&e.SceneManager.gamepad2DpadPress.length>0&&e.SceneManager.gamepad2DpadPress.forEach(function(e){e.index===n&&e.action()})}},n.inputTwoXboxDPadUpHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad2){var a="d2:"+n.toString();e.SceneManager.keymap[a]=!1,null!=e.SceneManager.gamepad2DpadUp&&e.SceneManager.gamepad2DpadUp.length>0&&e.SceneManager.gamepad2DpadUp.forEach(function(e){e(n)})}},n.inputTwoShockDPadUpHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad2){var a="d2:"+n.toString();e.SceneManager.keymap[a]=!1,null!=e.SceneManager.gamepad2DpadUp&&e.SceneManager.gamepad2DpadUp.length>0&&e.SceneManager.gamepad2DpadUp.forEach(function(e){e(n)})}},n.inputTwoXboxLeftTriggerHandler=function(n){e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad2&&(e.SceneManager.keymap["t2:0"]=n,null!=e.SceneManager.gamepad2LeftTrigger&&e.SceneManager.gamepad2LeftTrigger.length>0&&e.SceneManager.gamepad2LeftTrigger.forEach(function(e){e(n)}))},n.inputTwoXboxRightTriggerHandler=function(n){e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad2&&(e.SceneManager.keymap["t2:1"]=n,null!=e.SceneManager.gamepad2RightTrigger&&e.SceneManager.gamepad2RightTrigger.length>0&&e.SceneManager.gamepad2RightTrigger.forEach(function(e){e(n)}))},n.inputTwoLeftStickHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad2){var a=n,t=a.x*e.UserInputOptions.GamepadLStickSensibility,r=a.y*e.UserInputOptions.GamepadLStickSensibility;a.x=Math.abs(t)>e.UserInputOptions.GamepadDeadStickValue?t:0,a.y=Math.abs(r)>e.UserInputOptions.GamepadDeadStickValue?r:0,e.SceneManager.g_horizontal2=e.UserInputOptions.GamepadLStickXInverted?-a.x:a.x,e.SceneManager.g_vertical2=e.UserInputOptions.GamepadLStickYInverted?a.y:-a.y}},n.inputTwoRightStickHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad2){var a=n,t=a.x*e.UserInputOptions.GamepadRStickSensibility,r=a.y*e.UserInputOptions.GamepadRStickSensibility;a.x=Math.abs(t)>e.UserInputOptions.GamepadDeadStickValue?t:0,a.y=Math.abs(r)>e.UserInputOptions.GamepadDeadStickValue?r:0,e.SceneManager.g_mousex2=e.UserInputOptions.GamepadRStickXInverted?-a.x:a.x,e.SceneManager.g_mousey2=e.UserInputOptions.GamepadRStickYInverted?-a.y:a.y}},n.inputThreeButtonDownHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad3){var a="b3:"+n.toString(),t=!1;null!=e.SceneManager.keymap[a]&&(t=e.SceneManager.keymap[a]),e.SceneManager.keymap[a]=!0,null!=e.SceneManager.gamepad3ButtonDown&&e.SceneManager.gamepad3ButtonDown.length>0&&e.SceneManager.gamepad3ButtonDown.forEach(function(e){e(n)}),t||null!=e.SceneManager.gamepad3ButtonPress&&e.SceneManager.gamepad3ButtonPress.length>0&&e.SceneManager.gamepad3ButtonPress.forEach(function(e){e.index===n&&e.action()})}},n.inputThreeButtonUpHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad3){var a="b3:"+n.toString();e.SceneManager.keymap[a]=!1,null!=e.SceneManager.gamepad3ButtonUp&&e.SceneManager.gamepad3ButtonUp.length>0&&e.SceneManager.gamepad3ButtonUp.forEach(function(e){e(n)})}},n.inputThreeXboxDPadDownHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad3){var a="d3:"+n.toString(),t=!1;null!=e.SceneManager.keymap[a]&&(t=e.SceneManager.keymap[a]),e.SceneManager.keymap[a]=!0,null!=e.SceneManager.gamepad3DpadDown&&e.SceneManager.gamepad3DpadDown.length>0&&e.SceneManager.gamepad3DpadDown.forEach(function(e){e(n)}),t||null!=e.SceneManager.gamepad3DpadPress&&e.SceneManager.gamepad3DpadPress.length>0&&e.SceneManager.gamepad3DpadPress.forEach(function(e){e.index===n&&e.action()})}},n.inputThreeShockDPadDownHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad3){var a="d3:"+n.toString(),t=!1;null!=e.SceneManager.keymap[a]&&(t=e.SceneManager.keymap[a]),e.SceneManager.keymap[a]=!0,null!=e.SceneManager.gamepad3DpadDown&&e.SceneManager.gamepad3DpadDown.length>0&&e.SceneManager.gamepad3DpadDown.forEach(function(e){e(n)}),t||null!=e.SceneManager.gamepad3DpadPress&&e.SceneManager.gamepad3DpadPress.length>0&&e.SceneManager.gamepad3DpadPress.forEach(function(e){e.index===n&&e.action()})}},n.inputThreeXboxDPadUpHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad3){var a="d3:"+n.toString();e.SceneManager.keymap[a]=!1,null!=e.SceneManager.gamepad3DpadUp&&e.SceneManager.gamepad3DpadUp.length>0&&e.SceneManager.gamepad3DpadUp.forEach(function(e){e(n)})}},n.inputThreeShockDPadUpHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad3){var a="d3:"+n.toString();e.SceneManager.keymap[a]=!1,null!=e.SceneManager.gamepad3DpadUp&&e.SceneManager.gamepad3DpadUp.length>0&&e.SceneManager.gamepad3DpadUp.forEach(function(e){e(n)})}},n.inputThreeXboxLeftTriggerHandler=function(n){e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad3&&(e.SceneManager.keymap["t3:0"]=n,null!=e.SceneManager.gamepad3LeftTrigger&&e.SceneManager.gamepad3LeftTrigger.length>0&&e.SceneManager.gamepad3LeftTrigger.forEach(function(e){e(n)}))},n.inputThreeXboxRightTriggerHandler=function(n){e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad3&&(e.SceneManager.keymap["t3:1"]=n,null!=e.SceneManager.gamepad3RightTrigger&&e.SceneManager.gamepad3RightTrigger.length>0&&e.SceneManager.gamepad3RightTrigger.forEach(function(e){e(n)}))},n.inputThreeLeftStickHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad3){var a=n,t=a.x*e.UserInputOptions.GamepadLStickSensibility,r=a.y*e.UserInputOptions.GamepadLStickSensibility;a.x=Math.abs(t)>e.UserInputOptions.GamepadDeadStickValue?t:0,a.y=Math.abs(r)>e.UserInputOptions.GamepadDeadStickValue?r:0,e.SceneManager.g_horizontal3=e.UserInputOptions.GamepadLStickXInverted?-a.x:a.x,e.SceneManager.g_vertical3=e.UserInputOptions.GamepadLStickYInverted?a.y:-a.y}},n.inputThreeRightStickHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad3){var a=n,t=a.x*e.UserInputOptions.GamepadRStickSensibility,r=a.y*e.UserInputOptions.GamepadRStickSensibility;a.x=Math.abs(t)>e.UserInputOptions.GamepadDeadStickValue?t:0,a.y=Math.abs(r)>e.UserInputOptions.GamepadDeadStickValue?r:0,e.SceneManager.g_mousex3=e.UserInputOptions.GamepadRStickXInverted?-a.x:a.x,e.SceneManager.g_mousey3=e.UserInputOptions.GamepadRStickYInverted?-a.y:a.y}},n.inputFourButtonDownHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad4){var a="b4:"+n.toString(),t=!1;null!=e.SceneManager.keymap[a]&&(t=e.SceneManager.keymap[a]),e.SceneManager.keymap[a]=!0,null!=e.SceneManager.gamepad4ButtonDown&&e.SceneManager.gamepad4ButtonDown.length>0&&e.SceneManager.gamepad4ButtonDown.forEach(function(e){e(n)}),t||null!=e.SceneManager.gamepad4ButtonPress&&e.SceneManager.gamepad4ButtonPress.length>0&&e.SceneManager.gamepad4ButtonPress.forEach(function(e){e.index===n&&e.action()})}},n.inputFourButtonUpHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad4){var a="b4:"+n.toString();e.SceneManager.keymap[a]=!1,null!=e.SceneManager.gamepad4ButtonUp&&e.SceneManager.gamepad4ButtonUp.length>0&&e.SceneManager.gamepad4ButtonUp.forEach(function(e){e(n)})}},n.inputFourXboxDPadDownHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad4){var a="d4:"+n.toString(),t=!1;null!=e.SceneManager.keymap[a]&&(t=e.SceneManager.keymap[a]),e.SceneManager.keymap[a]=!0,null!=e.SceneManager.gamepad4DpadDown&&e.SceneManager.gamepad4DpadDown.length>0&&e.SceneManager.gamepad4DpadDown.forEach(function(e){e(n)}),t||null!=e.SceneManager.gamepad4DpadPress&&e.SceneManager.gamepad4DpadPress.length>0&&e.SceneManager.gamepad4DpadPress.forEach(function(e){e.index===n&&e.action()})}},n.inputFourShockDPadDownHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad4){var a="d4:"+n.toString(),t=!1;null!=e.SceneManager.keymap[a]&&(t=e.SceneManager.keymap[a]),e.SceneManager.keymap[a]=!0,null!=e.SceneManager.gamepad4DpadDown&&e.SceneManager.gamepad4DpadDown.length>0&&e.SceneManager.gamepad4DpadDown.forEach(function(e){e(n)}),t||null!=e.SceneManager.gamepad4DpadPress&&e.SceneManager.gamepad4DpadPress.length>0&&e.SceneManager.gamepad4DpadPress.forEach(function(e){e.index===n&&e.action()})}},n.inputFourXboxDPadUpHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad4){var a="d4:"+n.toString();e.SceneManager.keymap[a]=!1,null!=e.SceneManager.gamepad4DpadUp&&e.SceneManager.gamepad4DpadUp.length>0&&e.SceneManager.gamepad4DpadUp.forEach(function(e){e(n)})}},n.inputFourShockDPadUpHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad4){var a="d4:"+n.toString();e.SceneManager.keymap[a]=!1,null!=e.SceneManager.gamepad4DpadUp&&e.SceneManager.gamepad4DpadUp.length>0&&e.SceneManager.gamepad4DpadUp.forEach(function(e){e(n)})}},n.inputFourXboxLeftTriggerHandler=function(n){e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad4&&(e.SceneManager.keymap["t4:0"]=n,null!=e.SceneManager.gamepad4LeftTrigger&&e.SceneManager.gamepad4LeftTrigger.length>0&&e.SceneManager.gamepad4LeftTrigger.forEach(function(e){e(n)}))},n.inputFourXboxRightTriggerHandler=function(n){e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad4&&(e.SceneManager.keymap["t4:1"]=n,null!=e.SceneManager.gamepad4RightTrigger&&e.SceneManager.gamepad4RightTrigger.length>0&&e.SceneManager.gamepad4RightTrigger.forEach(function(e){e(n)}))},n.inputFourLeftStickHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad4){var a=n,t=a.x*e.UserInputOptions.GamepadLStickSensibility,r=a.y*e.UserInputOptions.GamepadLStickSensibility;a.x=Math.abs(t)>e.UserInputOptions.GamepadDeadStickValue?t:0,a.y=Math.abs(r)>e.UserInputOptions.GamepadDeadStickValue?r:0,e.SceneManager.g_horizontal4=e.UserInputOptions.GamepadLStickXInverted?-a.x:a.x,e.SceneManager.g_vertical4=e.UserInputOptions.GamepadLStickYInverted?a.y:-a.y}},n.inputFourRightStickHandler=function(n){if(e.SceneManager.EnableUserInput!==!1&&null!=e.SceneManager.gamepad4){var a=n,t=a.x*e.UserInputOptions.GamepadRStickSensibility,r=a.y*e.UserInputOptions.GamepadRStickSensibility;a.x=Math.abs(t)>e.UserInputOptions.GamepadDeadStickValue?t:0,a.y=Math.abs(r)>e.UserInputOptions.GamepadDeadStickValue?r:0,e.SceneManager.g_mousex4=e.UserInputOptions.GamepadRStickXInverted?-a.x:a.x,e.SceneManager.g_mousey4=e.UserInputOptions.GamepadRStickYInverted?-a.y:a.y}},n.inputManagerGamepadConnected=function(n,a){if(null==e.SceneManager.gamepad1&&0===n.index)if(e.SceneManager.gamepad1=n,e.Tools.Log("Gamepad One Connected: "+e.SceneManager.gamepad1.id),e.SceneManager.gamepad1 instanceof e.Xbox360Pad){e.SceneManager.gamepad1Type=e.GamepadType.Xbox360;var t=e.SceneManager.gamepad1;t.onbuttonup(e.SceneManager.inputOneButtonUpHandler),t.onbuttondown(e.SceneManager.inputOneButtonDownHandler),t.onleftstickchanged(e.SceneManager.inputOneLeftStickHandler),t.onrightstickchanged(e.SceneManager.inputOneRightStickHandler),t.ondpadup(e.SceneManager.inputOneXboxDPadUpHandler),t.ondpaddown(e.SceneManager.inputOneXboxDPadDownHandler),t.onlefttriggerchanged(e.SceneManager.inputOneXboxLeftTriggerHandler),t.onrighttriggerchanged(e.SceneManager.inputOneXboxRightTriggerHandler)}else if(e.SceneManager.gamepad1 instanceof e.DualShockPad){e.SceneManager.gamepad1Type=e.GamepadType.DualShock;var r=e.SceneManager.gamepad1;r.onbuttonup(e.SceneManager.inputOneButtonUpHandler),r.onbuttondown(e.SceneManager.inputOneButtonDownHandler),r.onleftstickchanged(e.SceneManager.inputOneLeftStickHandler),r.onrightstickchanged(e.SceneManager.inputOneRightStickHandler),r.ondpadup(e.SceneManager.inputOneShockDPadUpHandler),r.ondpaddown(e.SceneManager.inputOneShockDPadDownHandler),r.onlefttriggerchanged(e.SceneManager.inputOneXboxLeftTriggerHandler),r.onrighttriggerchanged(e.SceneManager.inputOneXboxRightTriggerHandler)}else if(e.SceneManager.gamepad1 instanceof e.PoseEnabledController);else{e.SceneManager.gamepad1Type=e.GamepadType.Generic;var i=e.SceneManager.gamepad1;i.onbuttonup(e.SceneManager.inputOneButtonUpHandler),i.onbuttondown(e.SceneManager.inputOneButtonDownHandler),i.onleftstickchanged(e.SceneManager.inputOneLeftStickHandler),i.onrightstickchanged(e.SceneManager.inputOneRightStickHandler)}if(null==e.SceneManager.gamepad2&&1===n.index)if(e.SceneManager.gamepad2=n,e.Tools.Log("Gamepad Two Connected: "+e.SceneManager.gamepad2.id),e.SceneManager.gamepad2 instanceof e.Xbox360Pad){e.SceneManager.gamepad2Type=e.GamepadType.Xbox360;var o=e.SceneManager.gamepad2;o.onbuttonup(e.SceneManager.inputTwoButtonUpHandler),o.onbuttondown(e.SceneManager.inputTwoButtonDownHandler),o.onleftstickchanged(e.SceneManager.inputTwoLeftStickHandler),o.onrightstickchanged(e.SceneManager.inputTwoRightStickHandler),o.ondpadup(e.SceneManager.inputTwoXboxDPadUpHandler),o.ondpaddown(e.SceneManager.inputTwoXboxDPadDownHandler),o.onlefttriggerchanged(e.SceneManager.inputTwoXboxLeftTriggerHandler),o.onrighttriggerchanged(e.SceneManager.inputTwoXboxRightTriggerHandler)}else if(e.SceneManager.gamepad2 instanceof e.DualShockPad){e.SceneManager.gamepad2Type=e.GamepadType.DualShock;var l=e.SceneManager.gamepad2;l.onbuttonup(e.SceneManager.inputOneButtonUpHandler),l.onbuttondown(e.SceneManager.inputOneButtonDownHandler),l.onleftstickchanged(e.SceneManager.inputOneLeftStickHandler),l.onrightstickchanged(e.SceneManager.inputOneRightStickHandler),l.ondpadup(e.SceneManager.inputOneShockDPadUpHandler),l.ondpaddown(e.SceneManager.inputOneShockDPadDownHandler),l.onlefttriggerchanged(e.SceneManager.inputOneXboxLeftTriggerHandler),l.onrighttriggerchanged(e.SceneManager.inputOneXboxRightTriggerHandler)}else if(e.SceneManager.gamepad2 instanceof e.PoseEnabledController);else{e.SceneManager.gamepad2Type=e.GamepadType.Generic;var s=e.SceneManager.gamepad2;s.onbuttonup(e.SceneManager.inputTwoButtonUpHandler),s.onbuttondown(e.SceneManager.inputTwoButtonDownHandler),s.onleftstickchanged(e.SceneManager.inputTwoLeftStickHandler),s.onrightstickchanged(e.SceneManager.inputTwoRightStickHandler)}if(null==e.SceneManager.gamepad3&&2===n.index)if(e.SceneManager.gamepad3=n,e.Tools.Log("Gamepad Three Connected: "+e.SceneManager.gamepad3.id),e.SceneManager.gamepad3 instanceof e.Xbox360Pad){e.SceneManager.gamepad3Type=e.GamepadType.Xbox360;var u=e.SceneManager.gamepad3;u.onbuttonup(e.SceneManager.inputThreeButtonUpHandler),u.onbuttondown(e.SceneManager.inputThreeButtonDownHandler),u.onleftstickchanged(e.SceneManager.inputThreeLeftStickHandler),u.onrightstickchanged(e.SceneManager.inputThreeRightStickHandler),u.ondpadup(e.SceneManager.inputThreeXboxDPadUpHandler),u.ondpaddown(e.SceneManager.inputThreeXboxDPadDownHandler),u.onlefttriggerchanged(e.SceneManager.inputThreeXboxLeftTriggerHandler),u.onrighttriggerchanged(e.SceneManager.inputThreeXboxRightTriggerHandler)}else if(e.SceneManager.gamepad3 instanceof e.DualShockPad){var c=e.SceneManager.gamepad3;c.onbuttonup(e.SceneManager.inputOneButtonUpHandler),c.onbuttondown(e.SceneManager.inputOneButtonDownHandler),c.onleftstickchanged(e.SceneManager.inputOneLeftStickHandler),c.onrightstickchanged(e.SceneManager.inputOneRightStickHandler),c.ondpadup(e.SceneManager.inputOneShockDPadUpHandler),c.ondpaddown(e.SceneManager.inputOneShockDPadDownHandler),c.onlefttriggerchanged(e.SceneManager.inputOneXboxLeftTriggerHandler),c.onrighttriggerchanged(e.SceneManager.inputOneXboxRightTriggerHandler)}else if(e.SceneManager.gamepad3 instanceof e.PoseEnabledController);else{e.SceneManager.gamepad3Type=e.GamepadType.Generic;var d=e.SceneManager.gamepad3;d.onbuttonup(e.SceneManager.inputThreeButtonUpHandler),d.onbuttondown(e.SceneManager.inputThreeButtonDownHandler),d.onleftstickchanged(e.SceneManager.inputThreeLeftStickHandler),d.onrightstickchanged(e.SceneManager.inputThreeRightStickHandler)}if(null==e.SceneManager.gamepad4&&3===n.index)if(e.SceneManager.gamepad4=n,e.Tools.Log("Gamepad Four Connected: "+e.SceneManager.gamepad4.id),e.SceneManager.gamepad4 instanceof e.Xbox360Pad){e.SceneManager.gamepad4Type=e.GamepadType.Xbox360;var g=e.SceneManager.gamepad4;g.onbuttonup(e.SceneManager.inputFourButtonUpHandler),g.onbuttondown(e.SceneManager.inputFourButtonDownHandler),g.onleftstickchanged(e.SceneManager.inputFourLeftStickHandler),g.onrightstickchanged(e.SceneManager.inputFourRightStickHandler),g.ondpadup(e.SceneManager.inputFourXboxDPadUpHandler),g.ondpaddown(e.SceneManager.inputFourXboxDPadDownHandler),g.onlefttriggerchanged(e.SceneManager.inputFourXboxLeftTriggerHandler),g.onrighttriggerchanged(e.SceneManager.inputFourXboxRightTriggerHandler)}else if(e.SceneManager.gamepad4 instanceof e.DualShockPad){var m=e.SceneManager.gamepad4;m.onbuttonup(e.SceneManager.inputOneButtonUpHandler),m.onbuttondown(e.SceneManager.inputOneButtonDownHandler),m.onleftstickchanged(e.SceneManager.inputOneLeftStickHandler),m.onrightstickchanged(e.SceneManager.inputOneRightStickHandler),m.ondpadup(e.SceneManager.inputOneShockDPadUpHandler),m.ondpaddown(e.SceneManager.inputOneShockDPadDownHandler),m.onlefttriggerchanged(e.SceneManager.inputOneXboxLeftTriggerHandler),m.onrighttriggerchanged(e.SceneManager.inputOneXboxRightTriggerHandler)}else if(e.SceneManager.gamepad4 instanceof e.PoseEnabledController);else{e.SceneManager.gamepad4Type=e.GamepadType.Generic;var p=e.SceneManager.gamepad4;p.onbuttonup(e.SceneManager.inputFourButtonUpHandler),p.onbuttondown(e.SceneManager.inputFourButtonDownHandler),p.onleftstickchanged(e.SceneManager.inputFourLeftStickHandler),p.onrightstickchanged(e.SceneManager.inputFourRightStickHandler)}null!=e.SceneManager.GamepadConnected&&e.SceneManager.GamepadConnected(n,a)},n.inputManagerGamepadDisconnected=function(n,a){null!=e.SceneManager.GamepadDisconnected&&e.SceneManager.GamepadDisconnected(n,a)},n.inputManagerLeftControllerMainButton=function(e,n){},n.inputManagerLeftControllerPadState=function(e,n){},n.inputManagerLeftControllerPadValues=function(e,n){},n.inputManagerLeftControllerAuxButton=function(e,n){},n.inputManagerLeftControllerTriggered=function(e,n){},n.inputManagerRightControllerMainButton=function(e,n){},n.inputManagerRightControllerPadState=function(e,n){},n.inputManagerRightControllerPadValues=function(e,n){},n.inputManagerRightControllerAuxButton=function(e,n){},n.inputManagerRightControllerTriggered=function(e,n){},n.inputManagerControllerConnected=function(e,n){},n.EnableUserInput=!0,n.PauseRenderLoop=!1,n.AutoUpdateProgress=!0,n.WaitForSeconds=function(n){return new Promise(function(a){return e.SceneManager.SetTimeout(1e3*n,a)})},n.OnFontsReadyObservable=new e.Observable,n.OnEngineResizeObservable=new e.Observable,n.OnLoadCompleteObservable=new e.Observable,n.SceneParsingEnabled=!0,n.AdvDynamicTexture=null,n.OnSetupPhysicsPlugin=null,n.TempVRayDest=null,n.TempVRayOrigin=null,n.TempShapeVector=null,n.TempPhysicsWorld=null,n.TempTransformFrom=null,n.TempTransformTo=null,n.TempCastEndPoint=null,n.TempRaycastResult=null,n.ClosestRayResultCallback=null,n.ClosestConvexResultCallback=null,n.MAX_AGENT_COUNT=200,n.MAX_AGENT_RADIUS=2,n.NavigationMesh=null,n.CrowdInterface=null,n.PluginInstance=null,n.OnNavMeshReadyObservable=new e.Observable,n.GamepadManager=null,n.GamepadConnected=null,n.GamepadDisconnected=null,n.PointerLockedFlag=!1,n.LockMousePointerObserver=null,n.input=!1,n.keymap={},n.wheel=0,n.mousex=0,n.mousey=0,n.vertical=0,n.horizontal=0,n.mousex2=0,n.mousey2=0,n.vertical2=0,n.horizontal2=0,n.mousex3=0,n.mousey3=0,n.vertical3=0,n.horizontal3=0,n.mousex4=0,n.mousey4=0,n.vertical4=0,n.horizontal4=0,n.a_mousex=0,n.x_wheel=0,n.x_mousex=0,n.x_mousey=0,n.x_vertical=0,n.x_horizontal=0,n.k_mousex=0,n.k_mousey=0,n.k_vertical=0,n.k_horizontal=0,n.j_mousex=0,n.j_mousey=0,n.j_vertical=0,n.j_horizontal=0,n.g_mousex1=0,n.g_mousey1=0,n.g_vertical1=0,n.g_horizontal1=0,n.g_mousex2=0,n.g_mousey2=0,n.g_vertical2=0,n.g_horizontal2=0,n.g_mousex3=0,n.g_mousey3=0,n.g_vertical3=0,n.g_horizontal3=0,n.g_mousex4=0,n.g_mousey4=0,n.g_vertical4=0,n.g_horizontal4=0,n.mouseButtonPress=[],n.mouseButtonDown=[],n.mouseButtonUp=[],n.keyButtonPress=[],n.keyButtonDown=[],n.keyButtonUp=[],n.leftJoystick=null,n.rightJoystick=null,n.virtualJoystick=!1,n.previousPosition=null,n.preventDefault=!1,n.rightHanded=!0,n.gamepad1=null,n.gamepad1Type=-1,n.gamepad1ButtonPress=[],n.gamepad1ButtonDown=[],n.gamepad1ButtonUp=[],n.gamepad1DpadPress=[],n.gamepad1DpadDown=[],n.gamepad1DpadUp=[],n.gamepad1LeftTrigger=[],n.gamepad1RightTrigger=[],n.gamepad2=null,n.gamepad2Type=-1,n.gamepad2ButtonPress=[],n.gamepad2ButtonDown=[],n.gamepad2ButtonUp=[],n.gamepad2DpadPress=[],n.gamepad2DpadDown=[],n.gamepad2DpadUp=[],n.gamepad2LeftTrigger=[],n.gamepad2RightTrigger=[],n.gamepad3=null,n.gamepad3Type=-1,n.gamepad3ButtonPress=[],n.gamepad3ButtonDown=[],n.gamepad3ButtonUp=[],n.gamepad3DpadPress=[],n.gamepad3DpadDown=[],n.gamepad3DpadUp=[],n.gamepad3LeftTrigger=[],n.gamepad3RightTrigger=[],n.gamepad4=null,n.gamepad4Type=-1,n.gamepad4ButtonPress=[],n.gamepad4ButtonDown=[],n.gamepad4ButtonUp=[],n.gamepad4DpadPress=[],n.gamepad4DpadDown=[],n.gamepad4DpadUp=[],n.gamepad4LeftTrigger=[],n.gamepad4RightTrigger=[],n.debugLayerVisible=!1,n}();e.SceneManager=n}(BABYLON||(BABYLON={}));var SM=BABYLON.SceneManager,BABYLON;!function(e){var n;!function(n){n[n.Deg2Rad=2*Math.PI/360]="Deg2Rad",n[n.Rad2Deg=1/e.System.Deg2Rad]="Rad2Deg",n[n.Epsilon=1e-5]="Epsilon",n[n.SingleEpsilon=1.401298e-45]="SingleEpsilon",n[n.EpsilonNormalSqrt=1e-15]="EpsilonNormalSqrt",n[n.Kph2Mph=.621371]="Kph2Mph",n[n.Mph2Kph=1.60934]="Mph2Kph",n[n.Mps2Kph=3.6]="Mps2Kph",n[n.Meter2Inch=39.3701]="Meter2Inch",n[n.Inch2Meter=.0254]="Inch2Meter",n[n.Gravity=9.81]="Gravity",n[n.Gravity3G=29.400000000000002]="Gravity3G",n[n.SkidFactor=.25]="SkidFactor",n[n.MaxInteger=2147483647]="MaxInteger",n[n.WalkingVelocity=4.4]="WalkingVelocity",n[n.TerminalVelocity=55]="TerminalVelocity",n[n.SmoothDeltaFactor=.2]="SmoothDeltaFactor",n[n.ToLinearSpace=2.2]="ToLinearSpace",n[n.ToGammaSpace=.45454545454545453]="ToGammaSpace"}(n=e.System||(e.System={}));var a;!function(e){e[e.Default=-1]="Default",e[e.Right=0]="Right",e[e.Left=1]="Left"}(a=e.Handedness||(e.Handedness={}));var t;!function(e){e[e.ExactMatch=0]="ExactMatch",e[e.StartsWith=1]="StartsWith",e[e.EndsWith=2]="EndsWith",e[e.IndexOf=3]="IndexOf"}(t=e.SearchType||(e.SearchType={}));var r;!function(e){e[e.Auto=0]="Auto",e[e.One=1]="One",e[e.Two=2]="Two",e[e.Three=3]="Three",e[e.Four=4]="Four"}(r=e.PlayerNumber||(e.PlayerNumber={}));var i;!function(e){e[e.FirstPerson=0]="FirstPerson",e[e.ThirdPerson=1]="ThirdPerson"}(i=e.PlayerControl||(e.PlayerControl={}));var o;!function(e){e[e.High=0]="High",e[e.Medium=1]="Medium",e[e.Low=2]="Low"}(o=e.RenderQuality||(e.RenderQuality={}));var l;!function(e){e[e.None=-1]="None",e[e.Generic=0]="Generic",e[e.Xbox360=1]="Xbox360",e[e.DualShock=2]="DualShock",e[e.PoseController=3]="PoseController"}(l=e.GamepadType||(e.GamepadType={}));var s;!function(e){e[e.Left=0]="Left",e[e.Right=1]="Right"}(s=e.JoystickButton||(e.JoystickButton={}));var u;!function(e){e[e.Left=0]="Left",e[e.Right=1]="Right"}(u=e.Xbox360Trigger||(e.Xbox360Trigger={}));var c;!function(e){e[e.DirectVelocity=0]="DirectVelocity",e[e.AppliedForces=1]="AppliedForces"}(c=e.MovementType||(e.MovementType={}));var d;!function(e){e[e.Top=0]="Top",e[e.Left=1]="Left",e[e.Right=2]="Right",e[e.Bottom=3]="Bottom"}(d=e.CollisionContact||(e.CollisionContact={}));var g;!function(e){e[e.AABB=0]="AABB",e[e.OBB=1]="OBB"}(g=e.IntersectionPrecision||(e.IntersectionPrecision={}));var m;!function(e){e[e.DefaultFilter=1]="DefaultFilter",e[e.StaticFilter=2]="StaticFilter",e[e.KinematicFilter=4]="KinematicFilter",e[e.DebrisFilter=8]="DebrisFilter",e[e.SensorTrigger=16]="SensorTrigger",e[e.CharacterFilter=32]="CharacterFilter",e[e.GroundFilter=64]="GroundFilter",e[e.AllFilter=-1]="AllFilter"}(m=e.CollisionFilters||(e.CollisionFilters={}));var p;!function(e){e[e.ACTIVE_TAG=1]="ACTIVE_TAG",e[e.ISLAND_SLEEPING=2]="ISLAND_SLEEPING",e[e.WANTS_DEACTIVATION=3]="WANTS_DEACTIVATION",e[e.DISABLE_DEACTIVATION=4]="DISABLE_DEACTIVATION",e[e.DISABLE_SIMULATION=5]="DISABLE_SIMULATION"}(p=e.CollisionState||(e.CollisionState={}));var f;!function(e){e[e.CF_STATIC_OBJECT=1]="CF_STATIC_OBJECT",e[e.CF_KINEMATIC_OBJECT=2]="CF_KINEMATIC_OBJECT",e[e.CF_NO_CONTACT_RESPONSE=4]="CF_NO_CONTACT_RESPONSE",e[e.CF_CUSTOM_MATERIAL_CALLBACK=8]="CF_CUSTOM_MATERIAL_CALLBACK",e[e.CF_CHARACTER_OBJECT=16]="CF_CHARACTER_OBJECT",e[e.CF_DISABLE_VISUALIZE_OBJECT=32]="CF_DISABLE_VISUALIZE_OBJECT",e[e.CF_DISABLE_SPU_COLLISION_PROCESSING=64]="CF_DISABLE_SPU_COLLISION_PROCESSING",e[e.CF_HAS_CONTACT_STIFFNESS_DAMPING=128]="CF_HAS_CONTACT_STIFFNESS_DAMPING",e[e.CF_HAS_CUSTOM_DEBUG_RENDERING_COLOR=256]="CF_HAS_CUSTOM_DEBUG_RENDERING_COLOR",e[e.CF_HAS_FRICTION_ANCHOR=512]="CF_HAS_FRICTION_ANCHOR",e[e.CF_HAS_COLLISION_SOUND_TRIGGER=1024]="CF_HAS_COLLISION_SOUND_TRIGGER"}(f=e.CollisionFlags||(e.CollisionFlags={}));var h;!function(e){e[e.Left=0]="Left",e[e.Middle=1]="Middle",e[e.Right=2]="Right"}(h=e.UserInputPointer||(e.UserInputPointer={}));var S;!function(e){e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical",e[e.ClientX=2]="ClientX",e[e.ClientY=3]="ClientY",e[e.MouseX=4]="MouseX",e[e.MouseY=5]="MouseY",e[e.Wheel=6]="Wheel"}(S=e.UserInputAxis||(e.UserInputAxis={}));var M;!function(e){e[e.BackSpace=8]="BackSpace",e[e.Tab=9]="Tab",e[e.Enter=13]="Enter",e[e.Shift=16]="Shift",e[e.Ctrl=17]="Ctrl",e[e.Alt=18]="Alt",e[e.Pause=19]="Pause",e[e.Break=19]="Break",e[e.CapsLock=20]="CapsLock",e[e.Escape=27]="Escape",e[e.SpaceBar=32]="SpaceBar",e[e.PageUp=33]="PageUp",e[e.PageDown=34]="PageDown",e[e.End=35]="End",e[e.Home=36]="Home",e[e.LeftArrow=37]="LeftArrow",e[e.UpArrow=38]="UpArrow",e[e.RightArrow=39]="RightArrow",e[e.DownArrow=40]="DownArrow",e[e.Insert=45]="Insert",e[e.Delete=46]="Delete",e[e.Num0=48]="Num0",e[e.Num1=49]="Num1",e[e.Num2=50]="Num2",e[e.Num3=51]="Num3",e[e.Num4=52]="Num4",e[e.Num5=53]="Num5",e[e.Num6=54]="Num6",e[e.Num7=55]="Num7",e[e.Num8=56]="Num8",e[e.Num9=57]="Num9",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.LeftWindowKey=91]="LeftWindowKey",e[e.RightWindowKey=92]="RightWindowKey",e[e.SelectKey=93]="SelectKey",e[e.Numpad0=96]="Numpad0",e[e.Numpad1=97]="Numpad1",e[e.Numpad2=98]="Numpad2",e[e.Numpad3=99]="Numpad3",e[e.Numpad4=100]="Numpad4",e[e.Numpad5=101]="Numpad5",e[e.Numpad6=102]="Numpad6",e[e.Numpad7=103]="Numpad7",e[e.Numpad8=104]="Numpad8",e[e.Numpad9=105]="Numpad9",e[e.Multiply=106]="Multiply",e[e.Add=107]="Add",e[e.Subtract=109]="Subtract",e[e.DecimalPoint=110]="DecimalPoint",e[e.Divide=111]="Divide",e[e.F1=112]="F1",e[e.F2=113]="F2",e[e.F3=114]="F3",e[e.F4=115]="F4",e[e.F5=116]="F5",e[e.F6=117]="F6",e[e.F7=118]="F7",e[e.F8=119]="F8",e[e.F9=120]="F9",e[e.F10=121]="F10",e[e.F11=122]="F11",e[e.F12=123]="F12",e[e.NumLock=144]="NumLock",e[e.ScrollLock=145]="ScrollLock",e[e.SemiColon=186]="SemiColon",e[e.EqualSign=187]="EqualSign",e[e.Comma=188]="Comma",e[e.Dash=189]="Dash",e[e.Period=190]="Period",e[e.ForwardSlash=191]="ForwardSlash",e[e.GraveAccent=192]="GraveAccent",e[e.OpenBracket=219]="OpenBracket",e[e.BackSlash=220]="BackSlash",e[e.CloseBraket=221]="CloseBraket",e[e.SingleQuote=222]="SingleQuote"}(M=e.UserInputKey||(e.UserInputKey={}));var y=function(){function e(){}return e.KeyboardSmoothing=!1,e.KeyboardMoveSensibility=3,e.KeyboardMoveDeadZone=.001,e.GamepadDeadStickValue=.25,e.GamepadLStickXInverted=!1,e.GamepadLStickYInverted=!1,e.GamepadRStickXInverted=!1,e.GamepadRStickYInverted=!0,e.GamepadLStickSensibility=1,e.GamepadRStickSensibility=1,e.JoystickRightHandleColor="yellow",e.JoystickLeftSensibility=1,e.JoystickRightSensibility=1,e.JoystickDeadStickValue=.1,e.PointerAngularSensibility=.5,e.PointerWheelDeadZone=.1,e.PointerMouseDeadZone=.1,e.PointerMouseInverted=!0,e.UseArrowKeyRotation=!0,e.UseCanvasElement=!0,e}();e.UserInputOptions=y;var v=function(){function e(){this.mesh=null,this.state=0}return e}();e.TriggerVolume=v;var b=function(){function e(){this.ListenerDictionary={}}return e.prototype.AddListener=function(e,n){var a;null==this.ListenerDictionary[e]?(a=[],this.ListenerDictionary[e]=a):a=this.ListenerDictionary[e],a.push(n)},e.prototype.RemoveListener=function(e,n){var a=this.ListenerDictionary[e];if(null!=a){var t=a.findIndex(function(e){return n==e});t>=0&&a.splice(t,1)}},e.prototype.RaiseMessage=function(e,n){void 0===n&&(n=null);var a=this.ListenerDictionary[e];null!=a&&a.forEach(function(e){e(n)})},e}();e.EventMessageBus=b;var T=function(){function n(e,n,a,t){
  void 0===a&&(a=!1),void 0===t&&(t=!0),this.assetContainer=null,this.prefabName=null,this.makeNewMaterials=!1,this.cloneAnimations=!0,this.AvailableInstances=[],this.assetContainer=e,this.prefabName=n,this.makeNewMaterials=a,this.cloneAnimations=t}return n.prototype.GetInstance=function(n,a){void 0===n&&(n=null),void 0===a&&(a=null);var t=this.AvailableInstances.length>0?this.AvailableInstances.pop():this.CreateNewInstance();return null!=t&&(null!=n?t.position.copyFrom(n):t.position.set(0,0,0),null!=a?null!=t.rotationQuaternion?t.rotationQuaternion.copyFrom(a):t.rotationQuaternion=a.clone():null!=t.rotationQuaternion?t.rotationQuaternion.set(0,0,0,1):t.rotationQuaternion=new e.Quaternion(0,0,0,1),t.setEnabled(!0)),t},n.prototype.ReturnInstance=function(n){null!=n&&(n.setEnabled(!1),n.position.set(0,0,0),null!=n.rotationQuaternion?n.rotationQuaternion.set(0,0,0,1):n.rotationQuaternion=new e.Quaternion(0,0,0,1),n.name=this.prefabName+".Unassigned",this.AvailableInstances.push(n))},n.prototype.PrePopulatePool=function(e){for(var n=0;n<e;n++){var a=this.CreateNewInstance();null!=a&&this.ReturnInstance(a)}},n.prototype.CreateNewInstance=function(){var n=null;return null!=this.assetContainer&&null!=this.prefabName&&""!==this.prefabName&&(n=e.SceneManager.InstantiatePrefab(this.assetContainer,this.prefabName,this.prefabName+".Instance",this.makeNewMaterials,this.cloneAnimations)),n},n}();e.PrefabObjectPool=T;var _=function(){function n(){this._hit=!1,this._dest=new e.Vector3(0,0,0),this._origin=new e.Vector3(0,0,0),this._hitPoint=new e.Vector3(0,0,0),this._hitNormal=new e.Vector3(0,0,0),this._hitDistance=0,this._collisionObject=null,this.reset(e.Vector3.Zero(),e.Vector3.Zero())}return Object.defineProperty(n.prototype,"hasHit",{get:function(){return this._hit},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"hitPoint",{get:function(){return this._hitPoint},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"hitNormal",{get:function(){return this._hitNormal},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"hitDistance",{get:function(){return this._hitDistance},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"collisionObject",{get:function(){return this._collisionObject},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"rayDestination",{get:function(){return this._dest},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"rayOrigin",{get:function(){return this._origin},enumerable:!1,configurable:!0}),n.prototype.reset=function(e,n){this._hit=!1,this._hitPoint.set(0,0,0),this._hitNormal.set(0,0,0),this._hitDistance=0,this._collisionObject=null,this._origin.copyFrom(e),this._dest.copyFrom(n)},n.prototype.update=function(n,a,t,r,i,o,l,s){void 0===s&&(s=null),this._hit=n,this._hitPoint.set(a,t,r),this._hitNormal.set(i,o,l),this._hitDistance=e.Vector3.Distance(this._origin,this.hitPoint),this._collisionObject=s},n}();e.RaycastHitResult=_;var x=function(){function n(e,n,a,t){void 0===a&&(a=0),void 0===t&&(t=.5),this._numPoints=-1,this._pointMesh=null,this._pointSize=.5,this._pointType=0,this._linesName="MeshLines",this._linesMesh=null,this._babylonScene=null,this._pointMesh=null,this._linesMesh=null,this._linesName=e,this._babylonScene=n,this._pointType=a,this._pointSize=t}return Object.defineProperty(n.prototype,"pointMesh",{get:function(){return this._pointMesh},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"linesMesh",{get:function(){return this._linesMesh},enumerable:!1,configurable:!0}),n.prototype.dispose=function(e){void 0===e&&(e=!0),this._babylonScene=null,this._linesName=null,null!=this._pointMesh&&(this._pointMesh.dispose(e),this._pointMesh=null),null!=this._linesMesh&&(this._linesMesh.dispose(e),this._linesMesh=null)},n.prototype.hidePoint=function(e){void 0===e&&(e=!0),null!=this._pointMesh&&(this._pointMesh.isVisible=!e)},n.prototype.drawPoint=function(n){null==this._pointMesh&&(1===this._pointType?(this._pointMesh=e.MeshBuilder.CreateBox(this._linesName+".EndPoint",{size:2*this._pointSize},this._babylonScene),this._pointMesh.visibility=.25):(this._pointMesh=e.MeshBuilder.CreateSphere(this._linesName+".EndPoint",{segments:24,diameter:2*this._pointSize},this._babylonScene),this._pointMesh.visibility=.25)),null!=this._pointMesh&&(this._pointMesh.isVisible=!0,this._pointMesh.position.copyFrom(n))},n.prototype.drawLine=function(n,a){void 0===a&&(a=null),null==this._linesMesh?(this._numPoints=n.length,this._linesMesh=e.MeshBuilder.CreateLines(this._linesName,{points:n,updatable:!0},this._babylonScene),null!=a&&(this._linesMesh.color=a),this._linesMesh.refreshBoundingInfo(!1)):n.length===this._numPoints?(this._linesMesh=e.MeshBuilder.CreateLines(this._linesName,{points:n,instance:this._linesMesh},this._babylonScene),null!=a&&(this._linesMesh.color=a),this._linesMesh.refreshBoundingInfo(!1)):e.Tools.Warn("Dynamic line mesh point count mismatch for "+this._linesName)},n}();e.LinesMeshRenderer=x;var A=function(){function n(){}return n.IsLayerMasked=function(e,n){return 0!=(e&1<<n)},n.GetLoadingState=function(){return e.Utilities.LoadingState},n.Approximately=function(n,a){return Math.abs(a-n)<Math.max(1e-6*Math.max(Math.abs(n),Math.abs(a)),8*e.System.SingleEpsilon)},n.MoveTowardsVector2=function(n,a,t){var r=new e.Vector2(0,0);return e.Utilities.MoveTowardsVector2ToRef(n,a,t,r),r},n.MoveTowardsVector2ToRef=function(e,n,a,t){var r=n.x-e.x,i=n.y-e.y,o=r*r+i*i;if(0==o||a>=0&&o<=a*a)t.set(n.x,n.y);else{var l=Math.sqrt(o);t.set(e.x+r/l*a,e.y+i/l*a)}},n.MoveTowardsVector3=function(n,a,t){var r=new e.Vector3(0,0,0);return e.Utilities.MoveTowardsVector3ToRef(n,a,t,r),r},n.MoveTowardsVector3ToRef=function(e,n,a,t){var r=n.x-e.x,i=n.y-e.y,o=n.z-e.z,l=r*r+i*i+o*o;if(0==l||l<=a*a)t.set(n.x,n.y,n.z);else{var s=Math.sqrt(l);t.set(e.x+r/s*a,e.y+i/s*a,e.z+o/s*a)}},n.MoveTowardsVector4=function(n,a,t){var r=new e.Vector4(0,0,0,0);return e.Utilities.MoveTowardsVector4ToRef(n,a,t,r),r},n.MoveTowardsVector4ToRef=function(e,n,a,t){var r=n.x-e.x,i=n.y-e.y,o=n.z-e.z,l=n.w-e.w,s=r*r+i*i+o*o+l*l;if(0==s||a>=0&&s<=a*a)t.set(n.x,n.y,n.z,n.w);else{var u=Math.sqrt(s);t.set(e.x+r/u*a,e.y+i/u*a,e.z+o/u*a,e.w+l/u*a)}},n.ClampMagnitudeVector2=function(n,a){var t=new e.Vector2(0,0);return e.Utilities.ClampMagnitudeVector2ToRef(n,a,t),t},n.ClampMagnitudeVector2ToRef=function(e,n,a){var t=e.lengthSquared();if(t>n*n){var r=Math.sqrt(t),i=e.x/r,o=e.y/r;a.set(i*n,o*n)}},n.ClampMagnitudeVector3=function(n,a){var t=new e.Vector3(0,0,0);return e.Utilities.ClampMagnitudeVector3ToRef(n,a,t),t},n.ClampMagnitudeVector3ToRef=function(e,n,a){var t=e.lengthSquared();if(t>n*n){var r=Math.sqrt(t),i=e.x/r,o=e.y/r,l=e.z/r;a.set(i*n,o*n,l*n)}},n.ZeroPad=function(e,n){var a=n-e.toString().length+1;return Array(+(a>0&&a)).join("0")+e},n.LerpLog=function(e,n,a){var t=Math.min(Math.max(a,0),1),r=Math.sin(t*Math.PI*.5);return e+(n-e)*r},n.LerpExp=function(e,n,a){var t=Math.min(Math.max(a,0),1),r=1-Math.cos(t*Math.PI*.5);return e+(n-e)*r},n.LerpClamp=function(e,n,a){var t=Math.min(Math.max(a,0),1);return e+(n-e)*t},n.LerpUnclamp=function(e,n,a){return e+(n-e)*a},n.GetAngle=function(n,a){var t=Math.sqrt(n.lengthSquared()*a.lengthSquared());if(t<e.System.EpsilonNormalSqrt)return 0;var r=e.Scalar.Clamp(e.Vector3.Dot(n,a)/t,-1,1);return Math.acos(r)*e.System.Rad2Deg},n.ClampAngle=function(n,a,t){var r=n;do r<-360&&(r+=360),r>360&&(r-=360);while(r<-360||r>360);return e.Scalar.Clamp(r,a,t)},n.SmoothDamp=function(n,a,t,r,i,o){if(!o)return 0;var l=n-a,s=Math.max(1e-4,t),u=2/s,c=u*i,d=1/(1+c+.48*c*c+.235*c*c*c),g=a,m=r*s;l=e.Scalar.Clamp(l,-m,m);var p=n-l,f=(o.x+u*l)*i;o.x=(o.x-u*f)*d;var h=p+(l+f)*d;return g-n>0==h>g&&(h=g,o.x=(h-g)/i),h},n.SmoothDampAngle=function(n,a,t,r,i,o){var l=n+e.Scalar.DeltaAngle(n,a);return e.Utilities.SmoothDamp(n,l,t,r,i,o)},n.SmoothDampVector2=function(n,a,t,r,i,o){var l=new e.Vector2(0,0);return e.Utilities.SmoothDampVector2ToRef(n,a,t,r,i,o,l),l},n.SmoothDampVector2ToRef=function(e,n,a,t,r,i,o){a=Math.max(1e-4,a);var l=2/a,s=l*r,u=1/(1+s+.48*s*s+.235*s*s*s),c=e.x-n.x,d=e.y-n.y,g=n.clone(),m=t*a,p=m*m,f=c*c+d*d;if(f>p){var h=Math.sqrt(f);c=c/h*m,d=d/h*m}n.x=e.x-c,n.y=e.y-d;var S=(i.x+l*c)*r,M=(i.y+l*d)*r;i.x=(i.x-l*S)*u,i.y=(i.y-l*M)*u;var y=n.x+(c+S)*u,v=n.y+(d+M)*u,b=g.x-e.x,T=g.y-e.y,_=y-g.x,x=v-g.y;b*_+T*x>0&&(y=g.x,v=g.y,i.x=(y-g.x)/r,i.y=(v-g.y)/r),o.set(y,v)},n.SmoothDampVector3=function(n,a,t,r,i,o){var l=new e.Vector3(0,0,0);return e.Utilities.SmoothDampVector3ToRef(n,a,t,r,i,o,l),l},n.SmoothDampVector3ToRef=function(e,n,a,t,r,i,o){var l=0,s=0,u=0;a=Math.max(1e-4,a);var c=2/a,d=c*r,g=1/(1+d+.48*d*d+.235*d*d*d),m=e.x-n.x,p=e.y-n.y,f=e.z-n.z,h=n.clone(),S=t*a,M=S*S,y=m*m+p*p+f*f;if(y>M){var v=Math.sqrt(y);m=m/v*S,p=p/v*S,f=f/v*S}n.x=e.x-m,n.y=e.y-p,n.z=e.z-f;var b=(i.x+c*m)*r,T=(i.y+c*p)*r,_=(i.z+c*f)*r;i.x=(i.x-c*b)*g,i.y=(i.y-c*T)*g,i.z=(i.z-c*_)*g,l=n.x+(m+b)*g,s=n.y+(p+T)*g,u=n.z+(f+_)*g;var x=h.x-e.x,A=h.y-e.y,C=h.z-e.z,O=l-h.x,P=s-h.y,w=u-h.z;x*O+A*P+C*w>0&&(l=h.x,s=h.y,u=h.z,i.x=(l-h.x)/r,i.y=(s-h.y)/r,i.z=(u-h.z)/r),o.set(l,s,u)},n.ToMatrix=function(n,a,t){return e.Matrix.RotationYawPitchRoll(e.Tools.ToRadians(a),e.Tools.ToRadians(n),e.Tools.ToRadians(t))},n.ToMatrixToRef=function(n,a,t,r){e.Matrix.RotationYawPitchRollToRef(e.Tools.ToRadians(a),e.Tools.ToRadians(n),e.Tools.ToRadians(t),r)},n.FastMatrixLerp=function(n,a,t,r){e.Matrix.LerpToRef(n,a,t,r)},n.FastMatrixSlerp=function(n,a,t,r){e.Matrix.DecomposeLerpToRef(n,a,t,r)},n.ToEuler=function(n){var a=n.toEulerAngles();return a.x=e.Tools.ToDegrees(a.x),a.y=e.Tools.ToDegrees(a.y),a.z=e.Tools.ToDegrees(a.z),a},n.ToEulerToRef=function(n,a){n.toEulerAnglesToRef(a),a.x=e.Tools.ToDegrees(a.x),a.y=e.Tools.ToDegrees(a.y),a.z=e.Tools.ToDegrees(a.z)},n.FromEuler=function(n,a,t){return e.Quaternion.FromEulerAngles(e.Tools.ToRadians(n),e.Tools.ToRadians(a),e.Tools.ToRadians(t))},n.FromEulerToRef=function(n,a,t,r){e.Quaternion.FromEulerAnglesToRef(e.Tools.ToRadians(n),e.Tools.ToRadians(a),e.Tools.ToRadians(t),r)},n.QuaternionDiff=function(n,a){var t=new e.Quaternion(0,0,0,0);return e.Utilities.QuaternionDiffToRef(n,a,t),t},n.QuaternionDiffToRef=function(n,a,t){e.Quaternion.InverseToRef(n,e.Utilities.TempQuaternion),e.Utilities.TempQuaternion.multiplyToRef(a,t)},n.QuaternionSubtractToRef=function(e,n,a){a.set(e._x-n._x,e._y-n._y,e._z-n._z,e._w-n._w)},n.RotateVector=function(n,a){var t=2*(a.y*n.z-a.z*n.y),r=2*(a.z*n.x-a.x*n.z),i=2*(a.x*n.y-a.y*n.x);return new e.Vector3(n.x+a.w*t+(a.y*i-a.z*r),n.y+a.w*r+(a.z*t-a.x*i),n.z+a.w*i+(a.x*r-a.y*t))},n.RotateVectorToRef=function(e,n,a){var t=2*(n.y*e.z-n.z*e.y),r=2*(n.z*e.x-n.x*e.z),i=2*(n.x*e.y-n.y*e.x);a.x=e.x+n.w*t+(n.y*i-n.z*r),a.y=e.y+n.w*r+(n.z*t-n.x*i),a.z=e.z+n.w*i+(n.x*r-n.y*t)},n.LookRotation=function(n){var a=e.Quaternion.Zero();return e.Utilities.LookRotationToRef(n,a),a},n.LookRotationToRef=function(n,a){e.Utilities.TempMatrix.reset(),e.Matrix.LookAtLHToRef(e.Utilities.ZeroVector,n,e.Utilities.UpVector,e.Utilities.TempMatrix),e.Utilities.TempMatrix.invert(),e.Quaternion.FromRotationMatrixToRef(e.Utilities.TempMatrix,a)},n.Vector3Rad2Deg=function(n){var a=e.Vector3.Zero();return e.Utilities.Vector3Rad2DegToRef(n,a),a},n.Vector3Rad2DegToRef=function(n,a){a.x=e.Tools.ToDegrees(n.x),a.y=e.Tools.ToDegrees(n.y),a.z=e.Tools.ToDegrees(n.z)},n.MultiplyQuaternionByVector=function(n,a){var t=new e.Vector3(0,0,0);return e.Utilities.MultiplyQuaternionByVectorToRef(n,a,t),t},n.MultiplyQuaternionByVectorToRef=function(e,n,a){var t=n.x,r=n.y,i=n.z,o=e.x,l=e.y,s=e.z,u=e.w,c=u*t+l*i-s*r,d=u*r+s*t-o*i,g=u*i+o*r-l*t,m=-o*t-l*r-s*i;a.x=c*u+m*-o+d*-s-g*-l,a.y=d*u+m*-l+g*-o-c*-s,a.z=g*u+m*-s+c*-l-d*-o},n.ValidateTransformRotation=function(e){null!=e.rotationQuaternion&&(e.rotation=e.rotationQuaternion.toEulerAngles(),e.rotationQuaternion=null)},n.ValidateTransformQuaternion=function(n){null==n.rotationQuaternion&&null!=n.rotation&&(n.rotationQuaternion=e.Quaternion.FromEulerAngles(n.rotation.x,n.rotation.y,n.rotation.z),n.rotation.set(0,0,0))},n.GetKeyboardInputValue=function(n,a,t){var r=t;return e.UserInputOptions.KeyboardSmoothing===!0&&(r=e.Scalar.MoveTowards(a,t,e.UserInputOptions.KeyboardMoveSensibility*e.SceneManager.GetDeltaSeconds(n)),Math.abs(r)<e.UserInputOptions.KeyboardMoveDeadZone&&(r=0)),r},n.DownloadEnvironment=function(n,a,t){void 0===a&&(a=null),void 0===t&&(t=null),e.EnvironmentTextureTools.CreateEnvTextureAsync(n).then(function(t){var r=n.name||"Environment",i=new Blob([t],{type:"octet/stream"});e.Tools.Download(i,r+".env"),null!=a&&a()})["catch"](function(e){console.error(e),null!=t&&t()})},n.HasOwnProperty=function(e,n){return null!=e&&null!=n&&""!==n&&n in e},n.GetFilenameFromUrl=function(e){return e.substring(e.lastIndexOf("/")+1)},n.GetUrlParameter=function(e){var n=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]"),a=new RegExp("[\\?&]"+n+"=([^&#]*)"),t=a.exec(window.location.search);return null!==t?decodeURIComponent(t[1].replace(/\+/g," ")):null},n.CreateFontFace=function(n,a,t,r,i){void 0===r&&(r=null),void 0===i&&(i=null);var o=e.SceneManager.GetRootUrl(n)+t.filename,l=new FontFace(a,'url("'+o+'") format("'+t.format+'")',r);return null!=l&&(document.fonts.add(l),null!=i&&l.loaded.then(function(e){i(e)},function(e){i(null)})),l},n.CreateFontFaceElement=function(n,a,t,r){void 0===r&&(r=null);var i=document.createElement("style"),o=e.SceneManager.GetRootUrl(n)+t.filename;return i.type="text/css",document.getElementsByTagName("head")[0].appendChild(i),null!=r&&""!==r?i.innerHTML='@font-face { font-family: "'+a+'"; src: url("'+o+'") format("'+t.format+'"); '+r+" }":i.innerHTML='@font-face { font-family: "'+a+'"; src: url("'+o+'") format("'+t.format+'"); }',i},n.PrintToScreen=function(n,a){if(void 0===a&&(a="white"),e.Utilities.PrintElement=document.getElementById("print"),null==e.Utilities.PrintElement){var t=document.createElement("div");t.id="print",t.style.position="absolute",t.style.left="6px",t.style.bottom="3px",t.style.fontSize="12px",t.style.zIndex="10000",t.style.color="#0c0",document.body.appendChild(t),e.Utilities.PrintElement=t}null!=e.Utilities.PrintElement&&e.Utilities.PrintElement.innerHTML!==n&&(e.Utilities.PrintElement.style.color!==a&&(e.Utilities.PrintElement.style.color=a),e.Utilities.PrintElement.innerHTML=n)},n.AddMeshVerts=function(n,a,t,r,i){if(void 0===r&&(r=!0),void 0===i&&(i=!1),null==e.Utilities.TmpHullMatrix&&(e.Utilities.TmpHullMatrix=new e.Matrix),null==e.Utilities.TmpAmmoVectorA&&(e.Utilities.TmpAmmoVectorA=new Ammo.btVector3(0,0,0)),null==e.Utilities.TmpAmmoVectorB&&(e.Utilities.TmpAmmoVectorB=new Ammo.btVector3(0,0,0)),null==e.Utilities.TmpAmmoVectorC&&(e.Utilities.TmpAmmoVectorC=new Ammo.btVector3(0,0,0)),null==e.Utilities.TmpAmmoNormalA&&(e.Utilities.TmpAmmoNormalA=new Ammo.btVector3(0,0,0)),null==e.Utilities.TmpAmmoNormalB&&(e.Utilities.TmpAmmoNormalB=new Ammo.btVector3(0,0,0)),null==e.Utilities.TmpAmmoNormalC&&(e.Utilities.TmpAmmoNormalC=new Ammo.btVector3(0,0,0)),!n.addTriangle){var o=t;return e.Tools.Warn("No AddTriangle Function For Triangle Mesh On: "+o.name),0}var l=0;if(t&&t.getIndices&&t.getWorldMatrix&&t.getChildMeshes){var s=t.getIndices();s||(s=[]);var u=t.getVerticesData(e.VertexBuffer.PositionKind);u||(u=[]);var c=t.getVerticesData(e.VertexBuffer.NormalKind);c||(c=[]),t.computeWorldMatrix(!1);for(var d=s.length/3,g=0;g<d;g++){for(var m=[],p=[],f=0;f<3;f++){var h=new e.Vector3(u[3*s[3*g+f]+0],u[3*s[3*g+f]+1],u[3*s[3*g+f]+2]),S=new e.Vector3(c[3*s[3*g+f]+0],c[3*s[3*g+f]+1],c[3*s[3*g+f]+2]);r===!0&&(e.Matrix.ScalingToRef(t.scaling.x,t.scaling.y,t.scaling.z,e.Utilities.TmpHullMatrix),h=e.Vector3.TransformCoordinates(h,e.Utilities.TmpHullMatrix));var M=void 0,y=void 0;0==f?(M=e.Utilities.TmpAmmoVectorA,y=e.Utilities.TmpAmmoNormalA):1==f?(M=e.Utilities.TmpAmmoVectorB,y=e.Utilities.TmpAmmoNormalB):(M=e.Utilities.TmpAmmoVectorC,y=e.Utilities.TmpAmmoNormalC),M.setValue(h.x,h.y,h.z),y.setValue(S.x,S.y,S.z),m.push(M),p.push(y)}var v=!1;i===!0?n.addTriangleNormals(m[0],m[1],m[2],p[0],p[1],p[2],v):n.addTriangle(m[0],m[1],m[2],v),l++}t.getChildMeshes().forEach(function(t){l+=e.Utilities.AddMeshVerts(n,a,t,r,i)})}return l},n.AddHullVerts=function(n,a,t,r){if(void 0===r&&(r=!0),null==e.Utilities.TmpHullMatrix&&(e.Utilities.TmpHullMatrix=new e.Matrix),null==e.Utilities.TmpAmmoVectorA&&(e.Utilities.TmpAmmoVectorA=new Ammo.btVector3(0,0,0)),null==e.Utilities.TmpAmmoVectorB&&(e.Utilities.TmpAmmoVectorB=new Ammo.btVector3(0,0,0)),null==e.Utilities.TmpAmmoVectorC&&(e.Utilities.TmpAmmoVectorC=new Ammo.btVector3(0,0,0)),!n.addPoint){var i=t;return e.Tools.Warn("No AddPoint Function For Convex Hull Shape On: "+i.name),0}var o=0;if(t&&t.getIndices&&t.getWorldMatrix&&t.getChildMeshes){var l=t.getIndices();l||(l=[]);var s=t.getVerticesData(e.VertexBuffer.PositionKind);s||(s=[]),t.computeWorldMatrix(!1);for(var u=l.length/3,c=0;c<u;c++){for(var d=[],g=0;g<3;g++){var m=void 0,p=new e.Vector3(s[3*l[3*c+g]+0],s[3*l[3*c+g]+1],s[3*l[3*c+g]+2]);r===!0&&(e.Matrix.ScalingToRef(t.scaling.x,t.scaling.y,t.scaling.z,e.Utilities.TmpHullMatrix),p=e.Vector3.TransformCoordinates(p,e.Utilities.TmpHullMatrix)),m=0==g?e.Utilities.TmpAmmoVectorA:1==g?e.Utilities.TmpAmmoVectorB:e.Utilities.TmpAmmoVectorC,m.setValue(p.x,p.y,p.z),d.push(m)}n.addPoint(d[0],!0),n.addPoint(d[1],!0),n.addPoint(d[2],!0),o++}t.getChildMeshes().forEach(function(t){o+=e.Utilities.AddHullVerts(n,a,t,r)})}return o},n.CreateImpostorCustomShape=function(n,a,t,r,i){void 0===r&&(r=!1),void 0===i&&(i=0),null==e.Utilities.TmpAmmoVectorD&&(e.Utilities.TmpAmmoVectorD=new Ammo.btVector3(0,0,0));var o=null,l=a.object,s=a.object;if(t===e.PhysicsImpostor.MeshImpostor){if(0!==a.getParam("mass")&&(a.setParam("mass",0),e.Tools.Warn("Mesh impostor not supported for non-static object: "+s.name+". Forced to static mesh impostor")),0==a.getParam("mass")){var u=null,c=0;null!=Ammo.btSmoothTriangleMesh?(u=new Ammo.btSmoothTriangleMesh,a._pluginData.toDispose.push(u),c=e.Utilities.AddMeshVerts(u,l,l,!0,!0)):(u=new Ammo.btTriangleMesh,a._pluginData.toDispose.push(u),c=e.Utilities.AddMeshVerts(u,l,l,!0,!1)),o=0==c?new Ammo.btCompoundShape:new Ammo.btBvhTriangleMeshShape(u)}return o}if(t===e.PhysicsImpostor.ConvexHullImpostor){var d=new Ammo.btConvexHullShape,c=e.Utilities.AddHullVerts(d,l,l,!0);return 0==c?(a._pluginData.toDispose.push(d),o=new Ammo.btCompoundShape):o=d,o.setMargin(0),o}var g=s,m=null!=s.metadata&&s.metadata.unity&&s.metadata.unity.collision&&s.metadata.unity.collision.center?e.Utilities.ParseVector3(s.metadata.unity.collision.center):new e.Vector3(0,0,0),p=new e.Quaternion(0,0,0,1);switch(t){case e.PhysicsImpostor.BoxImpostor:var f=null!=s.metadata&&s.metadata.unity&&s.metadata.unity.collision&&s.metadata.unity.collision.boxsize?e.Utilities.ParseVector3(s.metadata.unity.collision.boxsize):new e.Vector3(1,1,1);if(f.x*=g.scaling.x,f.y*=g.scaling.y,f.z*=g.scaling.z,r===!0&&null==s._debugCollider){var h=s.name+".Debug",S=e.MeshBuilder.CreateBox(h,{width:f.x,height:f.y,depth:f.z},n);S.position.set(0,0,0),S.rotationQuaternion=s.rotationQuaternion.clone(),S.setParent(s),S.position.copyFrom(m),S.visibility=i,S.material=e.Utilities.GetColliderMaterial(n),S.checkCollisions=!1,S.isPickable=!1,s._debugCollider=S}e.Utilities.TmpAmmoVectorD.setValue(f.x/2,f.y/2,f.z/2),o=new Ammo.btBoxShape(e.Utilities.TmpAmmoVectorD);break;case e.PhysicsImpostor.SphereImpostor:var M=null!=s.metadata&&s.metadata.unity&&s.metadata.unity.collision&&s.metadata.unity.collision.sphereradius?s.metadata.unity.collision.sphereradius:.5;if(M*=Math.max(Math.abs(g.scaling.x),Math.abs(g.scaling.y),Math.abs(g.scaling.z)),r===!0&&null==s._debugCollider){var y=null!=s.metadata&&s.metadata.unity&&s.metadata.unity.collision&&s.metadata.unity.collision.segments?s.metadata.unity.collision.segments:24,h=s.name+".Debug",v=e.MeshBuilder.CreateSphere(h,{segments:y,diameter:2*M},n);v.position.set(0,0,0),v.rotationQuaternion=s.rotationQuaternion.clone(),v.setParent(s),v.position.copyFrom(m),v.visibility=i,v.material=e.Utilities.GetColliderMaterial(n),v.checkCollisions=!1,v.isPickable=!1,s._debugCollider=v}o=new Ammo.btSphereShape(M);break;case e.PhysicsImpostor.CapsuleImpostor:var b=null!=s.metadata&&s.metadata.unity&&s.metadata.unity.collision&&s.metadata.unity.collision.capsulesize?e.Utilities.ParseVector3(s.metadata.unity.collision.capsulesize):new e.Vector3(.5,2,1);if(b.x*=Math.max(Math.abs(g.scaling.x),Math.abs(g.scaling.z)),b.y*=g.scaling.y,0!==b.z&&2!==b.z||(0===b.z?e.Utilities.FromEulerToRef(0,0,90,p):2===b.z&&e.Utilities.FromEulerToRef(90,0,0,p)),r===!0&&null==s._debugCollider){var h=s.name+".Debug",y=null!=s.metadata&&s.metadata.unity&&s.metadata.unity.collision&&s.metadata.unity.collision.segments?s.metadata.unity.collision.segments:24,T=e.MeshBuilder.CreateCapsule(h,{tessellation:y,subdivisions:8,capSubdivisions:16,height:b.y,radius:b.x},n);T.position.set(0,0,0),T.rotationQuaternion=s.rotationQuaternion.clone(),T.setParent(s),T.position.copyFrom(m),T.rotationQuaternion=p.clone(),T.visibility=i,T.material=e.Utilities.GetColliderMaterial(n),T.checkCollisions=!1,T.isPickable=!1,s._debugCollider=T}o=new Ammo.btCapsuleShape(b.x,b.y/2);break;default:e.Tools.Warn("The impostor type ("+t+") is not currently supported by the babylon toolkit for: "+s.name)}var _=new Ammo.btCompoundShape;if(null!=o){m.x*=g.scaling.x,m.y*=g.scaling.y,m.z*=g.scaling.z;var x=new Ammo.btVector3(m.x,m.y,m.z),A=new Ammo.btQuaternion(p.x,p.y,p.z,p.w),C=new Ammo.btTransform;C.setIdentity(),C.setOrigin(x),C.setRotation(A),_.addChildShape(C,o)}return _},n.ShowDebugColliders=function(){return null!=window.showDebugColliders&&window.showDebugColliders},n.ColliderVisibility=function(){return null!=window.colliderVisibility?window.colliderVisibility:0},n.CollisionWireframe=function(){return null!=window.collisionWireframe&&window.collisionWireframe},n.GetColliderMaterial=function(n){var a="Collider-Material",t=n.getMaterialByName(a);if(null==t){var r=new e.PBRMaterial(a,n);r.albedoColor=new e.Color3(0,.75,0),r.wireframe=e.Utilities.CollisionWireframe(),r.unlit=!0,t=r}return t},n.GetDirectTargetAngle=function(n,a){return e.Utilities.TempVector3.set(0,0,0),e.Utilities.InverseTransformPointToRef(n,a,e.Utilities.TempVector3),Math.atan2(e.Utilities.TempVector3.x,e.Utilities.TempVector3.z)},n.GetSmoothTargetAngle=function(n,a){return e.Utilities.TempVector3.set(0,0,0),e.Utilities.InverseTransformPointToRef(n,a,e.Utilities.TempVector3),e.Utilities.TempVector3.x/e.Utilities.TempVector3.length()},n.CalculatCatmullRom=function(n,a,t,r,i){var o=new e.Vector3(0,0,0);return e.Utilities.CalculatCatmullRomToRef(n,a,t,r,i,o),o},n.CalculatCatmullRomToRef=function(e,n,a,t,r,i){},n.StartsWith=function(e,n){return 0===e.lastIndexOf(n,0)},n.EndsWith=function(e,n){return e.indexOf(n,e.length-n.length)!==-1},n.ReplaceAll=function(e,n,a){return e.replace(new RegExp(n,"g"),a)},n.IsNullOrEmpty=function(e){return null==e||""===e},n.SafeStringPush=function(e,n){e.indexOf(n)===-1&&e.push(n)},n.ParseColor3=function(n,a,t){void 0===a&&(a=null),void 0===t&&(t=!1);var r=null;return r=null!=n&&null!=n.r&&null!=n.g&&null!=n.b?t===!0?new e.Color3(n.r,n.g,n.b).toLinearSpace():new e.Color3(n.r,n.g,n.b):a},n.ParseColor4=function(n,a,t){void 0===a&&(a=null),void 0===t&&(t=!1);var r=null;if(null!=n&&null!=n.r&&null!=n.g&&null!=n.b){var i=null!=n.a?n.a:1;r=t===!0?new e.Color4(n.r,n.g,n.b,i).toLinearSpace():new e.Color4(n.r,n.g,n.b,i)}else r=a;return r},n.ParseVector2=function(n,a){void 0===a&&(a=null);var t=null;return t=null!=n&&null!=n.x&&null!=n.y?new e.Vector2(n.x,n.y):a},n.ParseVector3=function(n,a){void 0===a&&(a=null);var t=null;return t=null!=n&&null!=n.x&&null!=n.y&&null!=n.z?new e.Vector3(n.x,n.y,n.z):a},n.ParseVector4=function(n,a){void 0===a&&(a=null);var t=null;return t=null!=n&&null!=n.x&&null!=n.y&&null!=n.z&&null!=n.w?new e.Vector4(n.x,n.y,n.z,n.w):a},n.ParseSound=function(n,a,t,r,i){var o=null;if(null!=n&&null!=n.filename&&""!==n.filename){var l=e.SceneManager.GetRootUrl(a),s=n.filename;o=new e.Sound(t,l+s,a,r,i)}return o},n.ParseTexture=function(n,a,t,r,i,o,l,s,u,c){var d=null;if(null!=n&&null!=n.filename&&""!==n.filename){var g=e.SceneManager.GetRootUrl(a),m=n.filename;d=new e.Texture(g+m,a,t,r,i,o,l,s,u,c)}return d},n.ParseCubemap=function(n,a){var t=null;if(null!=n&&null!=n.info){var r=e.SceneManager.GetRootUrl(a),i=r+n.info.rooturl;t=e.CubeTexture.Parse(n.info,a,i),null!=t&&(t.gammaSpace=!1)}return t},n.ParseTextAsset=function(e,n){void 0===n&&(n=null);var a=null;return a=null!=e&&null!=e.base64&&""!==e.base64?window.atob(e.base64):n},n.ParseJsonAsset=function(n,a,t){void 0===a&&(a=null),void 0===t&&(t=null);var r=e.Utilities.ParseTextAsset(n,a);return null!=r&&""!==r?JSON.parse(r,t):null},n.ParseTransformByID=function(n,a,t){void 0===t&&(t=null);var r=null;return r=null!=n&&null!=n.id?e.SceneManager.GetTransformNodeByID(a,n.id):t},n.ParseTransformByName=function(n,a,t){void 0===t&&(t=null);var r=null;return r=null!=n&&null!=n.id?e.SceneManager.GetTransformNode(a,n.id):t},n.ParseChildTransform=function(n,a,t){void 0===t&&(t=null);var r=null;return r=null!=a&&null!=a.name?e.SceneManager.FindChildTransformNode(n,a.name,e.SearchType.IndexOf,!1):t},n.GetAbsolutePosition=function(n,a,t){return void 0===a&&(a=null),void 0===t&&(t=!0),e.Utilities.TransformPoint(n,a||e.Utilities.ZeroVector,t)},n.GetAbsolutePositionToRef=function(n,a,t,r){void 0===t&&(t=null),void 0===r&&(r=!0),e.Utilities.TransformPointToRef(n,t||e.Utilities.ZeroVector,a,r)},n.TransformPoint=function(n,a,t){return void 0===t&&(t=!0),t===!0&&n.computeWorldMatrix(),e.Vector3.TransformCoordinates(a,n.getWorldMatrix())},n.InverseTransformPoint=function(n,a,t){return void 0===t&&(t=!0),t===!0&&n.computeWorldMatrix(),e.Utilities.TempMatrix.reset(),n.getWorldMatrix().invertToRef(e.Utilities.TempMatrix),e.Vector3.TransformCoordinates(a,e.Utilities.TempMatrix)},n.TransformPointToRef=function(n,a,t,r){return void 0===r&&(r=!0),r===!0&&n.computeWorldMatrix(),e.Vector3.TransformCoordinatesToRef(a,n.getWorldMatrix(),t)},n.InverseTransformPointToRef=function(n,a,t,r){return void 0===r&&(r=!0),r===!0&&n.computeWorldMatrix(),e.Utilities.TempMatrix.reset(),n.getWorldMatrix().invertToRef(e.Utilities.TempMatrix),e.Vector3.TransformCoordinatesToRef(a,e.Utilities.TempMatrix,t)},n.TransformDirection=function(n,a,t){return void 0===t&&(t=!0),t===!0&&n.computeWorldMatrix(),e.Vector3.TransformNormal(a,n.getWorldMatrix())},n.InverseTransformDirection=function(n,a,t){return void 0===t&&(t=!0),t===!0&&n.computeWorldMatrix(),e.Utilities.TempMatrix.reset(),n.getWorldMatrix().invertToRef(e.Utilities.TempMatrix),e.Vector3.TransformNormal(a,e.Utilities.TempMatrix)},n.TransformDirectionToRef=function(n,a,t,r){return void 0===r&&(r=!0),r===!0&&n.computeWorldMatrix(),e.Vector3.TransformNormalToRef(a,n.getWorldMatrix(),t)},n.InverseTransformDirectionToRef=function(n,a,t,r){return void 0===r&&(r=!0),r===!0&&n.computeWorldMatrix(),e.Utilities.TempMatrix.reset(),n.getWorldMatrix().invertToRef(e.Utilities.TempMatrix),e.Vector3.TransformNormalToRef(a,e.Utilities.TempMatrix,t)},n.RecomputeCenterPivotPoint=function(n){var a=n.getBoundingInfo().boundingSphere.center;n.setPivotMatrix(e.Matrix.Translation(-a.x,-a.y,-a.z))},n.GetDirectionVector=function(e,n){return e.getDirection(n)},n.GetDirectionVectorToRef=function(e,n,a){e.getDirectionToRef(n,a)},n.GetForwardVector=function(n){return n.getDirection(e.Vector3.Forward())},n.GetForwardVectorToRef=function(n,a){n.getDirectionToRef(e.Vector3.Forward(),a)},n.GetRightVector=function(n){return n.getDirection(e.Vector3.Right())},n.GetRightVectorToRef=function(n,a){n.getDirectionToRef(e.Vector3.Right(),a)},n.GetUpVector=function(n){return n.getDirection(e.Vector3.Up())},n.GetUpVectorToRef=function(n,a){n.getDirectionToRef(e.Vector3.Up(),a)},n.BlendFloatValue=function(n,a,t){var r=e.Scalar.Clamp(t,0,1);return r>0?e.Scalar.Lerp(n,a,r):n},n.BlendVector2Value=function(n,a,t){var r=e.Scalar.Clamp(t,0,1);if(r>0){var i=e.Vector2.Lerp(n,a,r);n.copyFrom(i)}},n.BlendVector3Value=function(n,a,t){var r=e.Scalar.Clamp(t,0,1);r>0&&e.Vector3.LerpToRef(n,a,r,n)},n.BlendQuaternionValue=function(n,a,t){var r=e.Scalar.Clamp(t,0,1);r>0&&e.Quaternion.SlerpToRef(n,a,r,n)},n.SetAnimationTargetProperty=function(e,n){null!=e&&(e.targetProperty=n,e.targetPropertyPath=e.targetProperty.split("."))},n.SampleAnimationFloat=function(n,a){var t=0;if(null!=n&&n.dataType===e.Animation.ANIMATIONTYPE_FLOAT){var r=n.getKeys();a<r[0].frame?a=r[0].frame:a>r[r.length-1].frame&&(a=r[r.length-1].frame),null==n._state&&(n._state={key:0,repeatCount:0,loopMode:e.Animation.ANIMATIONLOOPMODE_CONSTANT,workValue:e.Matrix.Zero()}),t=e.Utilities.InterpolateAnimation(n,a,n._state)}return t},n.SampleAnimationVector2=function(n,a){var t=null;if(null!=n&&n.dataType===e.Animation.ANIMATIONTYPE_VECTOR2){var r=n.getKeys();a<r[0].frame?a=r[0].frame:a>r[r.length-1].frame&&(a=r[r.length-1].frame),null==n._state&&(n._state={key:0,repeatCount:0,loopMode:e.Animation.ANIMATIONLOOPMODE_CONSTANT,workValue:e.Matrix.Zero()}),t=e.Utilities.InterpolateAnimation(n,a,n._state)}return t},n.SampleAnimationVector3=function(n,a){var t=null;if(null!=n&&n.dataType===e.Animation.ANIMATIONTYPE_VECTOR3){var r=n.getKeys();a<r[0].frame?a=r[0].frame:a>r[r.length-1].frame&&(a=r[r.length-1].frame),null==n._state&&(n._state={key:0,repeatCount:0,loopMode:e.Animation.ANIMATIONLOOPMODE_CONSTANT,workValue:e.Matrix.Zero()}),t=e.Utilities.InterpolateAnimation(n,a,n._state)}return t},n.SampleAnimationQuaternion=function(n,a){var t=null;if(null!=n&&n.dataType===e.Animation.ANIMATIONTYPE_QUATERNION){var r=n.getKeys();a<r[0].frame?a=r[0].frame:a>r[r.length-1].frame&&(a=r[r.length-1].frame),null==n._state&&(n._state={key:0,repeatCount:0,loopMode:e.Animation.ANIMATIONLOOPMODE_CONSTANT,workValue:e.Matrix.Zero()}),t=e.Utilities.InterpolateAnimation(n,a,n._state)}return t},n.SampleAnimationMatrix=function(n,a){var t=null;if(null!=n&&n.dataType===e.Animation.ANIMATIONTYPE_MATRIX){var r=n.getKeys();a<r[0].frame?a=r[0].frame:a>r[r.length-1].frame&&(a=r[r.length-1].frame),null==n._state&&(n._state={key:0,repeatCount:0,loopMode:e.Animation.ANIMATIONLOOPMODE_CONSTANT,workValue:e.Matrix.Zero()}),t=e.Utilities.InterpolateAnimation(n,a,n._state)}return t},n.CreateTweenAnimation=function(n,a,t,r,i,o){void 0===i&&(i=30),void 0===o&&(o=e.Animation.ANIMATIONLOOPMODE_CONSTANT);var l=[];l.push({frame:0,value:t}),l.push({frame:i,value:r});var s=new e.Animation(n,a,i,e.Animation.ANIMATIONTYPE_FLOAT,o);return s.setKeys(l),s},n.GetLastKeyFrameIndex=function(e){var n=0;if(null!=e){var a=e.getKeys();if(null!=a&&a.length>0){var t=a[a.length-1];null!=t&&(n=t.frame)}}return n},n.InterpolateAnimation=function(e,n,a){return e._interpolate(n,a)},n.InitializeShaderMaterial=function(n,a){void 0===a&&(a=!0);var t=n,r=e.Utilities.HasOwnProperty(t,"getShaderName")?t.getShaderName():"glsl",i=!!e.Utilities.HasOwnProperty(t,"getAlphaBlending")&&t.getAlphaBlending(),o=!!e.Utilities.HasOwnProperty(t,"getAlphaTesting")&&t.getAlphaTesting(),l=e.Utilities.HasOwnProperty(t,"getDefaultDefines")?t.getDefaultDefines():null,s=e.Utilities.HasOwnProperty(t,"getDefaultAttributes")?t.getDefaultAttributes():null,u=e.Utilities.HasOwnProperty(t,"getDefaultUniforms")?t.getDefaultUniforms():null;(null==l||l.length<=0)&&(l=["#define DIFFUSECOLOR","#define DIFFUSETEXTURE"]),(null==s||s.length<=0)&&(s=["position","normal","uv","uv2","color"]),(null==u||u.length<=0)&&(u=["world","worldView","worldViewProjection","view","projection","viewProjection","diffuseColor","diffuseTexture","diffuseTextureInfos","diffuseTextureMatrix"]);var c={vertex:r,fragment:r},d={needAlphaBlending:i,needAlphaTesting:o,attributes:s,uniforms:u,defines:l,samplers:[],uniformBuffers:[]};t._shaderPath=c,t._options=d,a===!0&&(t.fn_afterBind=t._afterBind,t._afterBind=function(e){var a=n.getScene();if(a.texturesEnabled)for(var r in t._textures){var i=t._textures[r];null!=i&&(t._effect.setFloat2(r+"Infos",i.coordinatesIndex,i.level),t._effect.setMatrix(r+"Matrix",i.getTextureMatrix()));
  }if(t.fn_afterBind)try{t.fn_afterBind(e)}catch(o){}})},n.WorldToScreenPoint=function(n,a,t){void 0===t&&(t=null);var r=null,i=null!=t?t.viewport:null!=n.activeCamera?n.activeCamera.viewport:null;return null!=i&&(r=e.Vector3.Project(a,e.Matrix.Identity(),n.getTransformMatrix(),i.toGlobal(n.getEngine().getRenderWidth(),n.getEngine().getRenderHeight()))),r},n.ScreenToWorldPoint=function(n,a){return e.Vector3.Unproject(a,n.getEngine().getRenderWidth(),n.getEngine().getRenderHeight(),e.Matrix.Identity(),n.getViewMatrix(),n.getProjectionMatrix())},n.ConvertAmmoVector3=function(n){var a=new e.Vector3(0,0,0);return e.Utilities.ConvertAmmoVector3ToRef(n,a),a},n.ConvertAmmoVector3ToRef=function(e,n){n.set(e.x(),e.y(),e.z())},n.ConvertAmmoQuaternion=function(n){var a=new e.Quaternion(0,0,0,1);return e.Utilities.ConvertAmmoQuaternionToRef(n,a),a},n.ConvertAmmoQuaternionToRef=function(e,n){n.set(e.x(),e.y(),e.z(),e.w())},n.CloneSkeletonPrefab=function(n,a,t,r,i){void 0===i&&(i=null);var o=new e.Skeleton(t,r||t,n);o.needInitialSkinMatrix=a.needInitialSkinMatrix,o.overrideMesh=i||a.overrideMesh;for(var l=0;l<a.bones.length;l++){var s=a.bones[l],u=null,c=s.getParent();if(c){var d=a.bones.indexOf(c);u=o.bones[d]}var g=new e.Bone(s.name,o,u,s.getBaseMatrix().clone(),s.getRestPose().clone());g._index=s._index,g.metadata=s.metadata,s._linkedTransformNode&&g.linkTransformNode(s._linkedTransformNode),e.DeepCopier.DeepCopy(s.animations,g.animations)}var m=o,p=a;if(p._ranges){m._ranges={};for(var f in p._ranges){var h=p._ranges[f];h&&(m._ranges[f]=h.clone())}}return p._isDirty=!0,o},n.GetSceneTransforms=function(e){var n=null;return null!=e.transformNodes&&e.transformNodes.length>0&&e.transformNodes.forEach(function(e){null!=e.metadata&&null!=e.metadata.unity&&null!=e.metadata.unity.prefab&&e.metadata.unity.prefab===!1&&(null==n&&(n=[]),n.push(e))}),null!=e.meshes&&e.meshes.length>0&&e.meshes.forEach(function(e){null!=e.metadata&&null!=e.metadata.unity&&null!=e.metadata.unity.prefab&&e.metadata.unity.prefab===!1&&(null==n&&(n=[]),n.push(e))}),n},n.ParseSceneComponents=function(n,a,t){if(null!=a&&a.length>0){var r=new e.MetadataParser(n);a.forEach(function(e){r.parseSceneComponents(e)}),r.postProcessSceneComponents(t)}},n.GetAssetContainerMesh=function(n,a){var t=null,r=a.toLowerCase();if(null==t&&null!=n.meshes&&n.meshes.length>0)for(var i=0;i<n.meshes.length;i++){var o=n.meshes[i];if(o instanceof e.Mesh&&o.name.toLowerCase()===r){t=o;break}}return t},n.GetAssetContainerNode=function(e,n){var a=null,t=n.toLowerCase();if(null==a&&null!=e.transformNodes&&e.transformNodes.length>0)for(var r=0;r<e.transformNodes.length;r++){var i=e.transformNodes[r];if(i.name.toLowerCase()===t){a=i;break}}return a},n.CloneAssetContainerItem=function(n,a,t,r,i){void 0===r&&(r=!1),void 0===i&&(i=!0);var o=null,l={},s={},u={},c=null,d=null,g=[],m=[],p=a.toLowerCase(),f=null,h=function(n,a){a.setEnabled(!0),null==f&&(f=a),l[n.uniqueId]=a.uniqueId,s[a.uniqueId]=a,t&&(a.name=t(n.name)),null!=n.metadata&&null!=n.metadata.unity&&null!=n.metadata.unity.entity&&(a.metadata=e.Utilities.CloneEntityMetadata(n.metadata));var r=null!=a.metadata&&null!=a.metadata.unity&&null!=a.metadata.unity.animator?a.metadata.unity.animator:null;if(null!=r&&""!==r&&(null==c&&(c=[]),c.indexOf(r)<0&&c.push(r),a.metadata.unity.animator=e.Utilities.CreateGuid(),u[r]=a.metadata.unity.animator),n instanceof e.AbstractMesh&&null!=n.skeleton&&(null==d&&(d=[]),d.indexOf(n.skeleton)<0&&d.push(n.skeleton)),a instanceof e.Mesh){var i=a;if(i.morphTargetManager){var o=n.morphTargetManager;i.morphTargetManager=o.clone();for(var g=0;g<o.numTargets;g++){var m=o.getTarget(g),p=i.morphTargetManager.getTarget(g);l[m.uniqueId]=p.uniqueId,s[p.uniqueId]=p}}}};if(null==o&&null!=n.transformNodes&&n.transformNodes.length>0)for(var S=0;S<n.transformNodes.length;S++){var M=n.transformNodes[S];if(M.name.toLowerCase()===p){var y=e.Utilities.InstantiateHierarchy(M,null,function(e,n){h(e,n)});if(y){o=y;break}}}if(null==o&&null!=n.meshes&&n.meshes.length>0)for(var v=function(a){var i=n.meshes[a];if(i.name.toLowerCase()===p){var u=e.Utilities.InstantiateHierarchy(i,null,function(e,a){h(e,a);var o=a;if(i.isWorldMatrixFrozen===!0&&o.freezeWorldMatrix&&o.freezeWorldMatrix(),a.material&&o.material)if(r===!0){var u=e.material;if(m.indexOf(u)===-1){var c=u.clone(t?t(u.name):"Clone of "+u.name);if(u.isFrozen===!0&&c.freeze&&c.freeze(),m.push(u),l[u.uniqueId]=c.uniqueId,s[c.uniqueId]=c,"MultiMaterial"===u.getClassName())for(var d=u,g=0,p=d.subMaterials;g<p.length;g++){var f=p[g];f&&(c=f.clone(t?t(f.name):"Clone of "+f.name),f.isFrozen===!0&&c.freeze&&c.freeze(),m.push(f),l[f.uniqueId]=c.uniqueId,s[c.uniqueId]=c)}}o.material=s[l[u.uniqueId]]}else"MultiMaterial"===o.material.getClassName()?n.scene.multiMaterials.indexOf(o.material)===-1&&n.scene.addMultiMaterial(o.material):n.scene.materials.indexOf(o.material)===-1&&n.scene.addMaterial(o.material)});if(u)return o=u,"break"}},S=0;S<n.meshes.length;S++){var b=v(S);if("break"===b)break}return null!=d&&d.length>0&&d.forEach(function(a){for(var r=t?t(a.name):"Clone of "+a.name,i=e.Utilities.CloneSkeletonPrefab(n.scene,a,r,r,f),o=0,u=n.meshes;o<u.length;o++){var c=u[o];if(c.skeleton===a&&!c.isAnInstance){var d=s[l[c.uniqueId]];if(d.skeleton=i,g.indexOf(i)!==-1)continue;g.push(i);for(var m=0,p=i.bones;m<p.length;m++){var h=p[m];h._linkedTransformNode&&(h._linkedTransformNode=s[l[h._linkedTransformNode.uniqueId]])}}}}),i===!0&&n.animationGroups.forEach(function(e){var n=e,a=null!=n.metadata&&null!=n.metadata.unity&&null!=n.metadata.unity.source&&""!==n.metadata.unity.source?n.metadata.unity.source:null;if(null!=a&&""!==a&&null!=c&&c.indexOf(a)>=0){var t=e.clone(e.name,function(e){var n=s[l[e.uniqueId]];return n||e}),r=u[a]||a;null!=n.metadata&&(t.metadata={},t.metadata.unity={},t.metadata.unity.id=n.metadata.unity.id,t.metadata.unity.clip=n.metadata.unity.clip,t.metadata.unity.source=r,t.metadata.unity.legacy=n.metadata.unity.legacy,t.metadata.unity.length=n.metadata.unity.length,t.metadata.unity.looping=n.metadata.unity.looping,t.metadata.unity.settings=n.metadata.unity.settings,t.metadata.unity.behavior=n.metadata.unity.behavior,t.metadata.unity.wrapmode=n.metadata.unity.wrapmode,t.metadata.unity.framerate=n.metadata.unity.framerate,t.metadata.unity.humanmotion=n.metadata.unity.humanmotion,t.metadata.unity.averagespeed=n.metadata.unity.averagespeed,t.metadata.unity.averageduration=n.metadata.unity.averageduration,t.metadata.unity.averageangularspeed=n.metadata.unity.averageangularspeed)}}),null!=o&&(o.parent=null),o},n.InstantiateHierarchy=function(n,a,t){if(void 0===a&&(a=null),n instanceof e.Mesh){var r=null!=n.metadata&&null!=n.metadata.unity&&null!=n.metadata.unity.instance&&n.metadata.unity.instance===!0;return e.Utilities.InstantiateMeshHierarchy(n,a,r,t)}return e.Utilities.InstantiateNodeHierarchy(n,a,t)},n.InstantiateNodeHierarchy=function(n,a,t){void 0===a&&(a=null);var r=n.clone("Clone of "+(n.name||n.id),a||n.parent,!0);r&&t&&t(n,r);for(var i=0,o=n.getChildTransformNodes(!0);i<o.length;i++){var l=o[i];e.Utilities.InstantiateHierarchy(l,r,t)}return r},n.InstantiateMeshHierarchy=function(n,a,t,r){void 0===a&&(a=null);var i=n.getTotalVertices()>0&&t===!0?n.createInstance("Instance of "+(n.name||n.id)):n.clone("Clone of "+(n.name||n.id),a||n.parent,!0);i&&(i.parent=a||n.parent,i.position=n.position.clone(),i.scaling=n.scaling.clone(),n.rotationQuaternion?i.rotationQuaternion=n.rotationQuaternion.clone():i.rotation=n.rotation.clone(),r&&r(n,i));for(var o=0,l=n.getChildTransformNodes(!0);o<l.length;o++){var s=l[o];e.Utilities.InstantiateHierarchy(s,i,r)}return i},n.ComputeBlendingSpeed=function(e,n,a){void 0===a&&(a=!1);var t=1/(e*n);return a===!0&&(t*=.5),t},n.CalculateCameraDistance=function(e,n,a){void 0===a&&(a=1);var t=1;return Math.round(e*a*n*t)},n.InstantiateClass=function(e){for(var n=e.split("."),a=window||this,t=0,r=n.length;t<r;t++)a=a[n[t]];return"function"==typeof a?a:null},n.GetSimpleClassName=function(e){if(e&&e.constructor&&e.constructor.toString){var n=e.constructor.toString().match(/function\s*(\w+)/);if(n&&2==n.length)return n[1]}},n.DisposeEntity=function(n){if(null!=n){if(null!=n.metadata&&n.metadata.unity){var a=n.metadata.unity;null!=a.components&&a.components.length>0&&a.components.forEach(function(n){if(null!=n.instance){try{e.SceneManager.DestroyScriptComponent(n.instance)}catch(a){}n.instance=null}}),delete n.metadata.unity}if(null!=n.metadata&&n.metadata.mixer&&delete n.metadata.mixer,null!=n.metadata&&null!=n.metadata.clone&&delete n.metadata.clone,null!=n.physicsImpostor){var t=n.physicsImpostor;null!=t.onCollideEvent&&(t.onCollideEvent=null),null!=t.tmpCollisionObjects&&delete t.tmpCollisionObjects,null!=n.physicsImpostor.physicsBody&&(null!=n.physicsImpostor.physicsBody.entity&&delete n.physicsImpostor.physicsBody.entity,null!=n.physicsImpostor.physicsBody.triangleMapInfo&&delete n.physicsImpostor.physicsBody.triangleMapInfo),n.physicsImpostor.dispose(),n.physicsImpostor=null}null!=n.skeleton&&(null!=n.skeleton._sockets&&delete n.skeleton._sockets,null!=n.skeleton.bones&&n.skeleton.bones.length>0&&n.skeleton.bones.forEach(function(e){null!=e&&null!=e.metadata&&(e.metadata=null)})),null!=n.cameraRig&&(n.cameraRig.dispose&&n.cameraRig.dispose(),delete n.cameraRig),null!=n.lightRig&&(n.lightRig.dispose&&n.lightRig.dispose(),delete n.lightRig),null!=n.shadowBox&&(n.shadowBox.dispose&&n.shadowBox.dispose(),delete n.shadowBox)}},n.SearchTransformNodes=function(n,a,t){void 0===t&&(t=e.SearchType.ExactMatch);var r=null,i=null!=t?t:e.SearchType.ExactMatch;if(null!=a&&a.length>0)for(var o=0;o<a.length;o++){var l=a[o];if(i===e.SearchType.ExactMatch){if(l.name===n){r=l;break}}else if(i===e.SearchType.StartsWith){if(e.Utilities.StartsWith(l.name,n)){r=l;break}}else if(i===e.SearchType.EndsWith){if(e.Utilities.EndsWith(l.name,n)){r=l;break}}else if(i===e.SearchType.IndexOf){if(l.name.indexOf(n)>=0){r=l;break}}else if(l.name===n){r=l;break}}return r},n.SearchTransformNodeForTags=function(n,a){var t=null;if(null!=a&&a.length>0)for(var r=0;r<a.length;r++){var i=a[r];if(i instanceof e.TransformNode&&e.Tags.MatchesQuery(i,n)){t=i;break}}return t},n.SearchAllTransformNodesForTags=function(n,a){var t=null;if(null!=a&&a.length>0)for(var r=0;r<a.length;r++){var i=a[r];i instanceof e.TransformNode&&e.Tags.MatchesQuery(i,n)&&(null==t&&(t=[]),t.push(i))}return t},n.SearchTransformNodeForScript=function(n,a){var t=null;if(null!=a&&a.length>0)for(var r=0;r<a.length;r++){var i=a[r];if(i instanceof e.TransformNode){var o=e.SceneManager.FindScriptComponent(i,n);if(null!=o){t=i;break}}}return t},n.SearchAllTransformNodesForScript=function(n,a){var t=null;if(null!=a&&a.length>0)for(var r=0;r<a.length;r++){var i=a[r];if(i instanceof e.TransformNode){var o=e.SceneManager.FindScriptComponent(i,n);null!=o&&(null==t&&(t=[]),t.push(i))}}return t},n.CreateGuid=function(n){void 0===n&&(n=null);var a=e.Tools.RandomId();return e.Utilities.IsNullOrEmpty(n)||(a+="-"+n),a},n.ValidateTransformGuid=function(e){if(null!=e&&null!=e.metadata&&null!=e.metadata.unity&&null!=e.metadata.unity.guid&&""!==e.metadata.unity.guid){var n=e.metadata.unity.guid;e.id!==n&&(e.id=n),delete e.metadata.unity.guid}},n.RegisterInstancedMeshBuffers=function(n){var a=null!=n.metadata.unity.buffers?n.metadata.unity.buffers:null;null!=a&&(null!=a.floats&&a.floats.length>0&&a.floats.forEach(function(e){null!=e.kind&&""!==e.kind&&null!=e.value&&(n.registerInstancedBuffer(e.kind,1),n.instancedBuffers[e.kind]=e.value)}),null!=a.colors&&a.colors.length>0&&a.colors.forEach(function(a){null!=a.kind&&""!==a.kind&&null!=a.value&&(n.registerInstancedBuffer(a.kind,4),n.instancedBuffers[a.kind]=new e.Color4(a.value.r||0,a.value.g||0,a.value.b||0,a.value.a||1).toLinearSpace())}),null!=a.vector2&&a.vector2.length>0&&a.vector2.forEach(function(a){null!=a.kind&&""!==a.kind&&null!=a.value&&(n.registerInstancedBuffer(a.kind,2),n.instancedBuffers[a.kind]=new e.Vector2(a.value.x||0,a.value.y||0))}),null!=a.vector3&&a.vector3.length>0&&a.vector3.forEach(function(a){null!=a.kind&&""!==a.kind&&null!=a.value&&(n.registerInstancedBuffer(a.kind,3),n.instancedBuffers[a.kind]=new e.Vector3(a.value.x||0,a.value.y||0,a.value.z||0))}),null!=a.vector4&&a.vector4.length>0&&a.vector4.forEach(function(a){null!=a.kind&&""!==a.kind&&null!=a.value&&(n.registerInstancedBuffer(a.kind,4),n.instancedBuffers[a.kind]=new e.Vector4(a.value.x||0,a.value.y||0,a.value.z||0,a.value.w||0))}))},n.CloneValue=function(n,a){return n?n instanceof e.Mesh?null:n instanceof e.SubMesh?n.clone(a):n.clone?n.clone():n:null},n.CloneEntityMetadata=function(n){var a=null;if(null!=n){var t=null;if(null!=n.unity){var r=null!=n.unity.instance&&n.unity.instance,i=null==n.unity.visible||n.unity.visible,o=null!=n.unity.visibility?n.unity.visibility:1,l=null!=n.unity.billboard?n.unity.billboard:0,s=null!=n.unity.tags?n.unity.tags:"Untagged Layer0",u=null!=n.unity.skin&&n.unity.skin,c=null!=n.unity.bone?n.unity.bone:null,d=null!=n.unity.rootbone&&n.unity.rootbone,g=null!=n.unity.group?n.unity.group:"Untagged",m=null!=n.unity.layer?n.unity.layer:0,p=null!=n.unity.layername?n.unity.layername:"Default",f=null!=n.unity.navigation?n.unity.navigation:null,h=null!=n.unity.lightmapped&&n.unity.lightmapped,S=null!=n.unity.animator?n.unity.animator:null,M=null,y=null,v=null,b=null;n.unity.physics&&(M={},e.Utilities.DeepCopyProperties(n.unity.physics,M)),n.unity.renderer&&(y={},e.Utilities.DeepCopyProperties(n.unity.renderer,y)),n.unity.collision&&(v={},e.Utilities.DeepCopyProperties(n.unity.collision,v)),n.unity.properties&&(b={},e.Utilities.DeepCopyProperties(n.unity.properties,b));var T=null;null!=n.unity.wheels&&n.unity.wheels.length>0&&(T=[],n.unity.wheels.forEach(function(n){if(null!=n){var a={};e.Utilities.DeepCopyProperties(n,a),T.push(a)}}));var _=null;null!=n.unity.components&&n.unity.components.length>0&&(_=[],n.unity.components.forEach(function(n){if(null!=n){var a={},t=null!=n.alias&&"script"===n.alias;e.Utilities.DeepCopyProperties(n,a,["instance"]),t===!0&&(a.instance=null),_.push(a)}})),t={},t.parsed=!1,t.prefab=!1,t.buffers=null,t.lods=null,t.coverages=null,t.distances=null,t.handlers=null,t.instance=r,t.visible=i,t.visibility=o,t.billboard=l,t.tags=s,t.skin=u,t.bone=c,t.rootbone=d,t.group=g,t.layer=m,t.layername=p,t.navigation=f,t.lightmapped=h,t.animator=S,t.renderer=y,t.physics=M,t.wheels=T,t.collision=v,t.properties=b,t.components=_}null!=t&&(a={unity:t})}return a},n.DeepCopyProperties=function(n,a,t,r){for(var i in n)if(("_"!==i[0]||r&&r.indexOf(i)!==-1)&&(!t||t.indexOf(i)===-1)){var o=n[i],l=typeof o;if("function"!==l)if("object"===l)if(o instanceof Array){if(a[i]=[],o.length>0)if("object"==typeof o[0])for(var s=0;s<o.length;s++){var u=e.Utilities.CloneValue(o[s],a);a[i].indexOf(u)===-1&&a[i].push(u)}else a[i]=o.slice(0)}else a[i]=e.Utilities.CloneValue(o,a);else a[i]=o}},n.ValidateTransformMetadata=function(n){null==n.metadata&&(n.metadata={}),null==n.metadata.unity&&(n.metadata.unity={});var a=n.metadata.unity;e.Utilities.HasOwnProperty(a,"entity")||(n.metadata.unity.entity=!0),e.Utilities.HasOwnProperty(a,"parsed")||(n.metadata.unity.parsed=!1),e.Utilities.HasOwnProperty(a,"prefab")||(n.metadata.unity.prefab=!1),e.Utilities.HasOwnProperty(a,"instance")||(n.metadata.unity.instance=!1),e.Utilities.HasOwnProperty(a,"buffers")||(n.metadata.unity.buffers=null),e.Utilities.HasOwnProperty(a,"visible")||(n.metadata.unity.visible=!0),e.Utilities.HasOwnProperty(a,"visibility")||(n.metadata.unity.visibility=1),e.Utilities.HasOwnProperty(a,"billboard")||(n.metadata.unity.billboard=0),e.Utilities.HasOwnProperty(a,"tags")||(n.metadata.unity.tags="Untagged Layer0"),e.Utilities.HasOwnProperty(a,"skin")||(n.metadata.unity.skin=!1),e.Utilities.HasOwnProperty(a,"bone")||(n.metadata.unity.bone=null),e.Utilities.HasOwnProperty(a,"rootbone")||(n.metadata.unity.rootbone=!1),e.Utilities.HasOwnProperty(a,"group")||(n.metadata.unity.group="Untagged"),e.Utilities.HasOwnProperty(a,"layer")||(n.metadata.unity.layer=0),e.Utilities.HasOwnProperty(a,"layername")||(n.metadata.unity.layername="Default"),e.Utilities.HasOwnProperty(a,"navigation")||(n.metadata.unity.navigation=null),e.Utilities.HasOwnProperty(a,"lightmapped")||(n.metadata.unity.lightmapped=!1),e.Utilities.HasOwnProperty(a,"animator")||(n.metadata.unity.animator=null),e.Utilities.HasOwnProperty(a,"lods")||(n.metadata.unity.lods=null),e.Utilities.HasOwnProperty(a,"coverages")||(n.metadata.unity.coverages=null),e.Utilities.HasOwnProperty(a,"distances")||(n.metadata.unity.distances=null),e.Utilities.HasOwnProperty(a,"handlers")||(n.metadata.unity.handlers=null),e.Utilities.HasOwnProperty(a,"physics")||(n.metadata.unity.physics=null),e.Utilities.HasOwnProperty(a,"wheels")||(n.metadata.unity.wheels=null),e.Utilities.HasOwnProperty(a,"renderer")||(n.metadata.unity.renderer=null),e.Utilities.HasOwnProperty(a,"collision")||(n.metadata.unity.collision=null),e.Utilities.HasOwnProperty(a,"properties")||(n.metadata.unity.properties=null),e.Utilities.HasOwnProperty(a,"components")||(n.metadata.unity.components=null)},n.UpVector=e.Vector3.Up(),n.AuxVector=e.Vector3.Zero(),n.ZeroVector=e.Vector3.Zero(),n.TempMatrix=e.Matrix.Zero(),n.TempVector2=e.Vector2.Zero(),n.TempVector3=e.Vector3.Zero(),n.TempQuaternion=e.Quaternion.Zero(),n.PrintElement=null,n.LoadingState=-1,n.OnPreloaderProgress=null,n.OnPreloaderComplete=null,n.IsLastSceneExecuteReady=!1,n.OnLastSceneExecuteReady=new e.Observable,n.TmpHullMatrix=null,n.TmpAmmoVectorA=null,n.TmpAmmoVectorB=null,n.TmpAmmoVectorC=null,n.TmpAmmoVectorD=null,n.TmpAmmoNormalA=null,n.TmpAmmoNormalB=null,n.TmpAmmoNormalC=null,n}();e.Utilities=A}(BABYLON||(BABYLON={}));var UTIL=BABYLON.Utilities,__extends=this&&this.__extends||function(){var e=function(n,a){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])})(n,a)};return function(n,a){function t(){this.constructor=n}e(n,a),n.prototype=null===a?Object.create(a):(t.prototype=a.prototype,new t)}}(),BABYLON;!function(e){var n=function(){function e(){this._defines={},this._defines={}}return e.prototype.getDefines=function(){return this._defines},e.prototype.defineBoolean=function(e){this._defines[e]=!0},e.prototype.defineNumeric=function(e,n){this._defines[e]=n},e.ShaderIndexer=0,e}();e.UniversalShaderDefines=n;var a=function(){function e(){}return e}();e.UniversalAlbedoChunks=a;var t=function(n){function a(a,t){var r=n.call(this,a,t)||this;return r.universalMaterial=!0,r.locals=null,r.terrainInfo=null,r._defines=null,r._uniforms=[],r._samplers=[],r._attributes=[],r._textures={},r._vectors4={},r._floats={},r.locals=new e.UniversalShaderDefines,r._defines=null,r._createdShaderName=null,r.enableShaderChunks=!1,r.materialShaderChunks=new e.UniversalAlbedoChunks,r.customShaderNameResolve=r._buildCustomShader,r.customShaderChunkResolve(),r}return __extends(a,n),a.prototype.updateShaderChunks=function(){},a.prototype.getClassName=function(){return"UniversalAlbedoMaterial"},a.prototype.getShaderName=function(){return"pbr"},a.prototype.getShaderChunk=function(){return null},a.prototype.getShaderDefines=function(){return this._defines},a.prototype.getCustomAttributes=function(){return null},a.prototype.getTexture=function(e){return this._textures[e]},a.prototype.getVector4=function(e){return this._vectors4[e]},a.prototype.getFloat=function(e){return this._floats[e]},a.prototype.setTexture=function(e,n,a){return void 0===a&&(a=!1),a===!0&&this.checkSampler(e),this._textures[e]=n,this},a.prototype.setVector4=function(e,n,a){return void 0===a&&(a=!1),a===!0&&this.checkUniform(e),this._vectors4[e]=n,this},a.prototype.setFloat=function(e,n,a){return void 0===a&&(a=!1),a===!0&&this.checkUniform(e),this._floats[e]=n,this},a.prototype.addAttribute=function(e){this._attributes.indexOf(e)===-1&&this._attributes.push(e)},a.prototype.checkUniform=function(e){this._uniforms.indexOf(e)===-1&&(this._uniforms.push(e),this.locals.defineBoolean(e.toUpperCase()))},a.prototype.checkSampler=function(e){this._samplers.indexOf(e)===-1&&(this._samplers.push(e),this.locals.defineBoolean(e.toUpperCase()),this.checkUniform(e+"Infos"),this.checkUniform(e+"Matrix"))},a.prototype.getAnimatables=function(){var e=n.prototype.getAnimatables.call(this);for(var a in this._textures){var t=this._textures[a];t&&t.animations&&t.animations.length>0&&e.push(t)}return e},a.prototype.getActiveTextures=function(){var e=n.prototype.getActiveTextures.call(this);for(var a in this._textures){var t=this._textures[a];t&&e.push(t)}return e},a.prototype.hasTexture=function(e){if(n.prototype.hasTexture.call(this,e))return!0;var a=!1;for(var t in this._textures){var r=this._textures[t];if(r===r){a=!0;break}}return a},a.prototype.dispose=function(e,a){if(a)for(var t in this._textures){var r=this._textures[t];r&&r.dispose(),this._textures[t]=null}this._textures={},n.prototype.dispose.call(this,e,a)},a.prototype.clone=function(n){var a,t=this,r=e.SerializationHelper.Clone(function(){return new e.UniversalAlbedoMaterial(n,t.getScene())},this);r._textures={};for(a in this._textures){var i=this._textures[a];i&&r.setTexture(a,i.clone(),!0)}r._vectors4={};for(a in this._vectors4)r.setVector4(a,this._vectors4[a].clone(),!0);r._floats={};for(a in this._floats)r.setFloat(a,this._floats[a],!0);return r},a.prototype.serialize=function(){var n,a=e.SerializationHelper.Serialize(this);a.customType="BABYLON.UniversalAlbedoMaterial",a.textures={};for(n in this._textures){var t=this._textures[n];t&&(a.textures[n]=t.serialize())}a.vectors4={};for(n in this._vectors4)a.vectors4[n]=this._vectors4[n].asArray();a.floats={};for(n in this._floats)a.floats[n]=this._floats[n];return a},a.Parse=function(n,a,t){var r,i=e.SerializationHelper.Parse(function(){return new e.UniversalAlbedoMaterial(n.name,a)},n,a,t);for(r in n.textures){var o=n.textures[r];o&&i.setTexture(r,e.Texture.Parse(o,a,t),!0)}for(r in n.vectors4)i.setVector4(r,e.Vector4.FromArray(n.vectors4[r]),!0);for(r in n.floats)i.setFloat(r,n.floats[r],!0);return i},a.prototype.customShaderChunkResolve=function(){var n=this.getShaderChunk();if(null!=n&&""!==n){var a=n+"ShaderChunks";if(null!=e.Effect.ShadersStore[a]){var t=e.Effect.ShadersStore[a],r=e.Utilities.HasOwnProperty(t,"VertexBegin")?t.VertexBegin:null;null!=r&&""!==r&&(this.materialShaderChunks.Vertex_Begin=r);var i=e.Utilities.HasOwnProperty(t,"VertexDefinitions")?t.VertexDefinitions:null;null!=i&&""!==i&&(this.materialShaderChunks.Vertex_Definitions=i);var o=e.Utilities.HasOwnProperty(t,"VertexMainBegin")?t.VertexMainBegin:null;null!=o&&""!==o&&(this.materialShaderChunks.Vertex_MainBegin=o);var l=e.Utilities.HasOwnProperty(t,"VertexUpdatePosition")?t.VertexUpdatePosition:null;null!=l&&""!==l&&(this.materialShaderChunks.Vertex_Before_PositionUpdated=l.replace("result","positionUpdated"));var s=e.Utilities.HasOwnProperty(t,"VertexUpdateNormal")?t.VertexUpdateNormal:null;null!=s&&""!==s&&(this.materialShaderChunks.Vertex_Before_NormalUpdated=s.replace("result","normalUpdated"));var u=e.Utilities.HasOwnProperty(t,"VertexWorldPos")?t.VertexWorldPos:null;null!=u&&""!==u&&(this.materialShaderChunks.Vertex_After_WorldPosComputed=u);var c=e.Utilities.HasOwnProperty(t,"VertexMainEnd")?t.VertexMainEnd:null;null!=c&&""!==c&&(this.materialShaderChunks.Vertex_MainEnd=c);var d=e.Utilities.HasOwnProperty(t,"FragmentBegin")?t.FragmentBegin:null;null!=d&&""!==d&&(this.materialShaderChunks.Fragment_Begin=d);var g=e.Utilities.HasOwnProperty(t,"FragmentDefinitions")?t.FragmentDefinitions:null;null!=g&&""!==g&&(this.materialShaderChunks.Fragment_Definitions=g);var m=e.Utilities.HasOwnProperty(t,"FragmentMainBegin")?t.FragmentMainBegin:null;null!=m&&""!==m&&(this.materialShaderChunks.Fragment_MainBegin=m);var p=e.Utilities.HasOwnProperty(t,"FragmentUpdateAlbedo")?t.FragmentUpdateAlbedo:null;null!=p&&""!==p&&(this.materialShaderChunks.Fragment_Custom_Albedo=p.replace("result","surfaceAlbedo"));var f=e.Utilities.HasOwnProperty(t,"FragmentUpdateAlpha")?t.FragmentUpdateAlpha:null;null!=f&&""!==f&&(this.materialShaderChunks.Fragment_Custom_Alpha=f.replace("result","alpha"));var h=e.Utilities.HasOwnProperty(t,"FragmentMetallicRoughness")?t.FragmentMetallicRoughness:null;null!=h&&""!==h&&(this.materialShaderChunks.Fragment_MetallicRoughness=h);var S=e.Utilities.HasOwnProperty(t,"FragmentMicroSurface")?t.FragmentMicroSurface:null;null!=S&&""!==S&&(this.materialShaderChunks.Fragment_MicroSurface=S);var M=e.Utilities.HasOwnProperty(t,"FragmentBeforeLights")?t.FragmentBeforeLights:null;null!=M&&""!==M&&(this.materialShaderChunks.Fragment_Before_Lights=M);var y=e.Utilities.HasOwnProperty(t,"FragmentBeforeFog")?t.FragmentBeforeFog:null;null!=y&&""!==y&&(this.materialShaderChunks.Fragment_Before_Fog=y);var v=e.Utilities.HasOwnProperty(t,"FragmentBeforeFragColor")?t.FragmentBeforeFragColor:null;null!=v&&""!==v&&(this.materialShaderChunks.Fragment_Before_FragColor=v.replace("result","color"))}else e.Tools.Warn("Failed To Locate Shader Chunk Base: "+a)}},a.prototype._buildCustomShader=function(n,a,t,r,i,o,l){var s=this;null==l||null!=l.processFinalCode&&void 0!=l.processFinalCode||(l.processFinalCode=function(n,a){if("vertex"===n)return a;var t=new e.ShaderCodeInliner(a);return t.inlineToken="#define pbr_inline",t.processCode(),t.code}),this._defines=i;var u=this.locals.getDefines();if(null!=u&&null!=this._defines){var c=Object.keys(u);if(null!=c&&c.length>0){for(var d=this._defines,g=0,m=c;g<m.length;g++){var p=m[g];d[p]=u[p]}this._defines.rebuild()}}var f=0;if(null!=this._uniforms&&this._uniforms.length>0)for(f=0;f<this._uniforms.length;f++){var h=this._uniforms[f];a.indexOf(h)===-1&&a.push(h)}if(f=0,null!=this._samplers&&this._samplers.length>0)for(f=0;f<this._samplers.length;f++){var S=this._samplers[f];r.indexOf(S)===-1&&r.push(S)}if(f=0,null!=this._attributes&&this._attributes.length>0)for(f=0;f<this._attributes.length;f++){var M=this._attributes[f];o.indexOf(M)===-1&&o.push(M)}f=0;var y=this.getCustomAttributes();if(null!=y&&y.length>0)for(f=0;f<y.length;f++){var v=y[f];o.indexOf(v)===-1&&o.push(v)}if(null!=this._createdShaderName&&""!==this._createdShaderName)return this._createdShaderName;var b=this.getShaderName();null!=b&&""!==b||(b=n),null!=b&&""!==b||(b="pbr");var T=this._afterBind.bind(this);return this._afterBind=function(e,n){if(n){s._attachAfterBind(e,n);try{T(e,n)}catch(n){}}},this._createdShaderName=this.enableShaderChunks===!0?this._createShaderChunks(b):b,this._createdShaderName},a.prototype._createShaderChunks=function(n){var a=this.getShaderChunk();null!=a&&""!==a||(a=n),e.UniversalShaderDefines.ShaderIndexer++;var t=(a+"Custom"+e.UniversalShaderDefines.ShaderIndexer).trim(),r=e.Effect.ShadersStore[n+"VertexShader"],i=e.Effect.ShadersStore[n+"PixelShader"];i=i.replace(/#include<pbrBlockAlbedoOpacity>/g,e.Effect.IncludesShadersStore.pbrBlockAlbedoOpacity),i=i.replace(/#include<pbrBlockReflectivity>/g,e.Effect.IncludesShadersStore.pbrBlockReflectivity),i=i.replace(/#include<pbrBlockFinalColorComposition>/g,e.Effect.IncludesShadersStore.pbrBlockFinalColorComposition),this.updateShaderChunks();var o=t+"VertexShader";e.Effect.ShadersStore[o]=r.replace("#define CUSTOM_VERTEX_BEGIN",this.materialShaderChunks.Vertex_Begin?this.materialShaderChunks.Vertex_Begin:"").replace("#define CUSTOM_VERTEX_DEFINITIONS",this.materialShaderChunks.Vertex_Definitions?this.materialShaderChunks.Vertex_Definitions:"").replace("#define CUSTOM_VERTEX_MAIN_BEGIN",this.materialShaderChunks.Vertex_MainBegin?this.materialShaderChunks.Vertex_MainBegin:"").replace("#define CUSTOM_VERTEX_UPDATE_POSITION",this.materialShaderChunks.Vertex_Before_PositionUpdated?this.materialShaderChunks.Vertex_Before_PositionUpdated:"").replace("#define CUSTOM_VERTEX_UPDATE_NORMAL",this.materialShaderChunks.Vertex_Before_NormalUpdated?this.materialShaderChunks.Vertex_Before_NormalUpdated:"").replace("#define CUSTOM_VERTEX_MAIN_END",this.materialShaderChunks.Vertex_MainEnd?this.materialShaderChunks.Vertex_MainEnd:""),this.materialShaderChunks.Vertex_After_WorldPosComputed&&(e.Effect.ShadersStore[o]=e.Effect.ShadersStore[o].replace("#define CUSTOM_VERTEX_UPDATE_WORLDPOS",this.materialShaderChunks.Vertex_After_WorldPosComputed));var l=t+"PixelShader";return e.Effect.ShadersStore[l]=i.replace("#define CUSTOM_FRAGMENT_BEGIN",this.materialShaderChunks.Fragment_Begin?this.materialShaderChunks.Fragment_Begin:"").replace("#define CUSTOM_FRAGMENT_DEFINITIONS",this.materialShaderChunks.Fragment_Definitions?this.materialShaderChunks.Fragment_Definitions:"").replace("#define CUSTOM_FRAGMENT_MAIN_BEGIN",this.materialShaderChunks.Fragment_MainBegin?this.materialShaderChunks.Fragment_MainBegin:"").replace("#define CUSTOM_FRAGMENT_UPDATE_ALBEDO",this.materialShaderChunks.Fragment_Custom_Albedo?this.materialShaderChunks.Fragment_Custom_Albedo:"").replace("#define CUSTOM_FRAGMENT_UPDATE_ALPHA",this.materialShaderChunks.Fragment_Custom_Alpha?this.materialShaderChunks.Fragment_Custom_Alpha:"").replace("#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS",this.materialShaderChunks.Fragment_MetallicRoughness?this.materialShaderChunks.Fragment_MetallicRoughness:"").replace("#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE",this.materialShaderChunks.Fragment_MicroSurface?this.materialShaderChunks.Fragment_MicroSurface:"").replace("#define CUSTOM_FRAGMENT_BEFORE_LIGHTS",this.materialShaderChunks.Fragment_Before_Lights?this.materialShaderChunks.Fragment_Before_Lights:"").replace("#define CUSTOM_FRAGMENT_BEFORE_FOG",this.materialShaderChunks.Fragment_Before_Fog?this.materialShaderChunks.Fragment_Before_Fog:"").replace("#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR",this.materialShaderChunks.Fragment_Before_FragColor?this.materialShaderChunks.Fragment_Before_FragColor:""),this.materialShaderChunks.Fragment_Before_Fog&&(e.Effect.ShadersStore[l]=e.Effect.ShadersStore[l].replace("#define CUSTOM_FRAGMENT_BEFORE_FOG",this.materialShaderChunks.Fragment_Before_Fog)),t},a.prototype._attachAfterBind=function(e,n){var a,t=this.getScene();if(t.texturesEnabled)for(a in this._textures){var r=this._textures[a];null!=r&&r.isReady&&r.isReady()&&(n.setTexture(a,r),n.setFloat2(a+"Infos",r.coordinatesIndex,r.level),n.setMatrix(a+"Matrix",r.getTextureMatrix()))}for(a in this._vectors4)n.setVector4(a,this._vectors4[a]);for(a in this._floats)n.setFloat(a,this._floats[a])},a}(e.PBRMaterial);e.UniversalAlbedoMaterial=t,e._TypeStore.RegisteredTypes.UniversalAlbedoMaterial=t;var r=function(n){function a(e,a){var t=n.call(this,e,a)||this;return t.enableShaderChunks=!0,t}return __extends(a,n),a.prototype.getClassName=function(){return"UniversalTerrainMaterial"},a.prototype.getShaderName=function(){return"pbr"},a.prototype.getShaderChunk=function(){return null},a.prototype.updateShaderChunks=function(){var n="surfaceAlbedo",a="splatmapSampler",t="detailsSampler",r="normalsSampler",i=e.System.ToLinearSpace;null!=this.materialShaderChunks.Vertex_Definitions&&""!==this.materialShaderChunks.Vertex_Definitions?this.materialShaderChunks.Vertex_Definitions=this.formatTerrainVertexDefintions()+this.materialShaderChunks.Vertex_Definitions:this.materialShaderChunks.Vertex_Definitions=this.formatTerrainVertexDefintions(),null!=this.materialShaderChunks.Vertex_MainEnd&&""!==this.materialShaderChunks.Vertex_MainEnd?this.materialShaderChunks.Vertex_MainEnd=this.formatTerrainVertexMainEnd()+this.materialShaderChunks.Vertex_MainEnd:this.materialShaderChunks.Vertex_MainEnd=this.formatTerrainVertexMainEnd(),null!=this.materialShaderChunks.Fragment_Definitions&&""!==this.materialShaderChunks.Fragment_Definitions?this.materialShaderChunks.Fragment_Definitions=this.formatTerrainFragmentDefintions(a,t,r)+this.materialShaderChunks.Fragment_Definitions:this.materialShaderChunks.Fragment_Definitions=this.formatTerrainFragmentDefintions(a,t,r),null!=this.materialShaderChunks.Fragment_Custom_Albedo&&""!==this.materialShaderChunks.Fragment_Custom_Albedo?this.materialShaderChunks.Fragment_Custom_Albedo=this.formatTerrainFragmentUpdateColor(this.terrainInfo,n,a,t,r,i)+this.materialShaderChunks.Fragment_Custom_Albedo:this.materialShaderChunks.Fragment_Custom_Albedo=this.formatTerrainFragmentUpdateColor(this.terrainInfo,n,a,t,r,i);
  },a.prototype.formatTerrainVertexDefintions=function(){return"\r\n#define TERRAIN_VERTEX_DEFINITIONS\r\n\r\nvarying vec2 vSplatmapUV;\r\n\r\n"},a.prototype.formatTerrainVertexMainEnd=function(){return"\r\n#define TERRAIN_VERTEX_MAIN_END\r\n\r\n#ifdef UV1\r\nvSplatmapUV = uv;\r\n#endif\r\n\r\n"},a.prototype.formatTerrainFragmentDefintions=function(e,n,a){return"\r\n#define TERRAIN_FRAGMENT_DEFNITIONS\r\n\r\nvarying vec2 vSplatmapUV;\r\nuniform sampler2D "+e+";\r\nuniform sampler2D "+n+";\r\nuniform sampler2D "+a+";\r\n\r\nfloat calculateMipmapLevel(const in vec2 uvs, const in vec2 size)\r\n{\r\n    vec2 dx = dFdx(uvs * size.x);\r\n    vec2 dy = dFdy(uvs * size.y);\r\n    float d = max(dot(dx, dx), dot(dy, dy));\r\n    return 0.4 * log2(d);\r\n}\r\n\r\nvec4 sampleTextureAtlas2D(const in sampler2D atlas, const in float gamma, const in vec2 tile, const in vec4 rect, in vec2 uvs, in float lod)\r\n{\r\n    if (lod < 0.0) lod = clamp(calculateMipmapLevel(uvs, vec2(tile.x, tile.x)), 0.0, tile.y);   // Tile Info (tile.xy)\r\n    float size = pow(2.0, tile.y - lod);                                                        // Tile Bits (tile.y)\r\n    float sizex = size / rect.z;                                                                // Tile Width (rect.z)\r\n    float sizey = size / rect.w;                                                                // Tile Height (rect.w)\r\n    uvs = fract(uvs);                                                                           // Perfrom Tiling (fract)\r\n    uvs.x = uvs.x * ((sizex * rect.z - 1.0) / sizex) + 0.5 / sizex + rect.z * rect.x;           // Tile Position X (rect.x)\r\n    uvs.y = uvs.y * ((sizey * rect.w - 1.0) / sizey) + 0.5 / sizey + rect.w * rect.y;           // Tile Position Y (rect.y)\r\n    vec4 color = texture2DLodEXT(atlas, uvs, lod);\r\n    if (gamma != 1.0) {\r\n        color.r = pow(color.r, gamma);\r\n        color.g = pow(color.g, gamma);\r\n        color.b = pow(color.b, gamma);\r\n    }\r\n    return color;\r\n}\r\n\r\nvec4 sampleSplatmapAtlas2D(const in sampler2D atlas, const in vec2 tile, const in vec4 rect, in vec2 uvs)\r\n{\r\n    float size = pow(2.0, tile.y);                                                              // Tile Bits (tile.y)\r\n\t   float sizex = size / rect.z;                                                                // Tile Width (rect.z)\r\n\t   float sizey = size / rect.w;                                                                // Tile Height (rect.w)\r\n\t   uvs.x = uvs.x * ((sizex * rect.z - 1.0) / sizex) + 0.5 / sizex + rect.z * rect.x;           // Tile Position X (rect.x)\r\n\t   uvs.y = uvs.y * ((sizey * rect.w - 1.0) / sizey) + 0.5 / sizey + rect.w * rect.y;           // Tile Position Y (rect.y)\r\n    return texture2D(atlas, uvs);\r\n}\r\n\r\nvec3 blendSplatmapAtlasColors(const in vec4 splatmap, in vec4 color1, in vec4 color2, in vec4 color3, in vec4 color4, in vec3 mixbuffer)\r\n{\r\n    vec3 buffer1 = mix(mixbuffer, color1.rgb, splatmap.r);\r\n    vec3 buffer2 = mix(buffer1, color2.rgb, splatmap.g);\r\n    vec3 buffer3 = mix(buffer2, color3.rgb, splatmap.b);\r\n    return mix(buffer3, color4.rgb, splatmap.a);\r\n}\r\n\r\nvec3 perturbNormalSamplerColor(mat3 cotangentFrame, vec3 samplerColor, float scale)\r\n{\r\n    vec3 map = samplerColor.xyz;\r\n    map = map * 2.00787402 - 1.00787402;\r\n    #ifdef NORMALXYSCALE\r\n        map = normalize(map * vec3(scale, scale, 1.0));\r\n    #endif\r\n    return normalize(cotangentFrame * map);\r\n}\r\n\r\n\r\n"},a.prototype.formatTerrainFragmentUpdateColor=function(e,n,a,t,r,i){void 0===i&&(i=1);var o="";if(null!=e&&null!=e.textureAtlas&&null!=e.splatmapAtlas&&e.splatmapCount>0){o="\r\n#define TERRAIN_FRAGMENT_UPDATE_COLOR\r\n\r\nvec3 normalsColor = vec3(0.5, 0.5, 1.0);\r\nvec3 normalsBuffer = normalW.rgb;\r\nvec3 splatmapBuffer = "+n+".rgb;\r\nfloat autoMipMapLevel = -1.0;\r\nfloat normalCorrection = 1.0;\r\nfloat detailCorrection = "+i.toFixed(4)+";\r\n\r\n#if defined(ALBEDO) && defined("+a.toUpperCase()+") && defined("+t.toUpperCase()+")\r\n\r\n// Reset Normal Values\r\n#if defined(BUMP) || defined(PARALLAX) || defined(ANISOTROPIC)\r\n    uvOffset = vec2(0.0, 0.0);\r\n    #ifdef NORMAL\r\n        normalW = normalize(vNormalW);\r\n    #else\r\n        normalW = normalize(cross(dFdx(vPositionW), dFdy(vPositionW))) * vEyePosition.w;\r\n    #endif\r\n    #ifdef CLEARCOAT\r\n        clearCoatNormalW = normalW;\r\n    #endif\r\n    #if defined(BUMP) || defined(PARALLAX)\r\n        #if defined(TANGENT) && defined(NORMAL)\r\n            TBN = vTBN;\r\n        #else\r\n            TBN = cotangent_frame(normalW, vPositionW, vSplatmapUV);\r\n        #endif\r\n    #elif defined(ANISOTROPIC)\r\n        #if defined(TANGENT) && defined(NORMAL)\r\n            TBN = vTBN;\r\n        #else\r\n            TBN = cotangent_frame(normalW, vPositionW, vSplatmapUV, vec2(1.0, 1.0));\r\n        #endif\r\n    #endif\r\n    #ifdef PARALLAX\r\n        invTBN = transposeMat3(TBN);\r\n    #endif\r\n    normalW = perturbNormalSamplerColor(TBN, normalsColor, 1.0);\r\n#endif\r\n\r\n// Global Atlas Values\r\nfloat splatTileSize = "+e.splatmapAtlas[2].toFixed(4)+";\r\nfloat splatTileBits = "+e.splatmapAtlas[3].toFixed(4)+";\r\nfloat detailTileSize = "+e.textureAtlas[2].toFixed(4)+";\r\nfloat detailTileBits = "+e.textureAtlas[3].toFixed(4)+";\r\n\r\n// Sample splatmap textures\r\n";for(var l=0,s=0;s<e.splatmapCount;s++){l=4*s;var u=e["splatmapRect"+s];if(o+="vec4 splatmapRect"+s+" = vec4("+u[0].toFixed(4)+", "+u[1].toFixed(4)+", "+u[2].toFixed(4)+", "+u[3].toFixed(4)+");\r\n",o+="vec4 splatmapAlbedo"+s+" = sampleSplatmapAtlas2D("+a+", vec2(splatTileSize, splatTileBits), splatmapRect"+s+", (vSplatmapUV + uvOffset));\r\n",o+="vec4 textureAlbedo"+(l+0)+" = vec4(0.0, 0.0, 0.0, 1.0);\r\n",o+="vec4 textureAlbedo"+(l+1)+" = vec4(0.0, 0.0, 0.0, 1.0);\r\n",o+="vec4 textureAlbedo"+(l+2)+" = vec4(0.0, 0.0, 0.0, 1.0);\r\n",o+="vec4 textureAlbedo"+(l+3)+" = vec4(0.0, 0.0, 0.0, 1.0);\r\n",e["textureRect"+(l+0)]){var c=e["textureRect"+(l+0)],d=e["textureInfo"+(l+0)];o+="vec4 textureRect"+(l+0)+" = vec4("+c[0].toFixed(4)+", "+c[1].toFixed(4)+", "+c[2].toFixed(4)+", "+c[3].toFixed(4)+");\r\n",o+="vec2 textureScale"+(l+0)+" = vec2("+d[0].toFixed(4)+", "+d[1].toFixed(4)+");\r\n",o+="vec2 textureOffset"+(l+0)+" = vec2("+d[2].toFixed(4)+", "+d[3].toFixed(4)+");\r\n",o+="vec2 textureTileUV"+(l+0)+" = ((vSplatmapUV + textureOffset"+(l+0)+") * textureScale"+(l+0)+");\r\n",o+="textureAlbedo"+(l+0)+" = sampleTextureAtlas2D("+t+", detailCorrection, vec2(detailTileSize, detailTileBits), textureRect"+(l+0)+", textureTileUV"+(l+0)+", autoMipMapLevel);\r\n"}if(e["textureRect"+(l+1)]){var c=e["textureRect"+(l+1)],d=e["textureInfo"+(l+1)];o+="vec4 textureRect"+(l+1)+" = vec4("+c[0].toFixed(4)+", "+c[1].toFixed(4)+", "+c[2].toFixed(4)+", "+c[3].toFixed(4)+");\r\n",o+="vec2 textureScale"+(l+1)+" = vec2("+d[0].toFixed(4)+", "+d[1].toFixed(4)+");\r\n",o+="vec2 textureOffset"+(l+1)+" = vec2("+d[2].toFixed(4)+", "+d[3].toFixed(4)+");\r\n",o+="vec2 textureTileUV"+(l+1)+" = ((vSplatmapUV + textureOffset"+(l+1)+") * textureScale"+(l+1)+");\r\n",o+="textureAlbedo"+(l+1)+" = sampleTextureAtlas2D("+t+", detailCorrection, vec2(detailTileSize, detailTileBits), textureRect"+(l+1)+", textureTileUV"+(l+1)+", autoMipMapLevel);\r\n"}if(e["textureRect"+(l+2)]){var c=e["textureRect"+(l+2)],d=e["textureInfo"+(l+2)];o+="vec4 textureRect"+(l+2)+" = vec4("+c[0].toFixed(4)+", "+c[1].toFixed(4)+", "+c[2].toFixed(4)+", "+c[3].toFixed(4)+");\r\n",o+="vec2 textureScale"+(l+2)+" = vec2("+d[0].toFixed(4)+", "+d[1].toFixed(4)+");\r\n",o+="vec2 textureOffset"+(l+2)+" = vec2("+d[2].toFixed(4)+", "+d[3].toFixed(4)+");\r\n",o+="vec2 textureTileUV"+(l+2)+" = ((vSplatmapUV + textureOffset"+(l+2)+") * textureScale"+(l+2)+");\r\n",o+="textureAlbedo"+(l+2)+" = sampleTextureAtlas2D("+t+", detailCorrection, vec2(detailTileSize, detailTileBits), textureRect"+(l+2)+", textureTileUV"+(l+2)+", autoMipMapLevel);\r\n"}if(e["textureRect"+(l+3)]){var c=e["textureRect"+(l+3)],d=e["textureInfo"+(l+3)];o+="vec4 textureRect"+(l+3)+" = vec4("+c[0].toFixed(4)+", "+c[1].toFixed(4)+", "+c[2].toFixed(4)+", "+c[3].toFixed(4)+");\r\n",o+="vec2 textureScale"+(l+3)+" = vec2("+d[0].toFixed(4)+", "+d[1].toFixed(4)+");\r\n",o+="vec2 textureOffset"+(l+3)+" = vec2("+d[2].toFixed(4)+", "+d[3].toFixed(4)+");\r\n",o+="vec2 textureTileUV"+(l+3)+" = ((vSplatmapUV + textureOffset"+(l+3)+") * textureScale"+(l+3)+");\r\n",o+="textureAlbedo"+(l+3)+" = sampleTextureAtlas2D("+t+", detailCorrection, vec2(detailTileSize, detailTileBits), textureRect"+(l+3)+", textureTileUV"+(l+3)+", autoMipMapLevel);\r\n"}if(o+="splatmapBuffer = blendSplatmapAtlasColors(splatmapAlbedo"+s+", textureAlbedo"+(l+0)+", textureAlbedo"+(l+1)+", textureAlbedo"+(l+2)+", textureAlbedo"+(l+3)+", splatmapBuffer);\r\n",o+="#if defined(BUMP) || defined(PARALLAX) || defined(ANISOTROPIC)\r\n",o+="    #if defined("+r.toUpperCase()+")\r\n",o+="        vec4 normalColor"+(l+0)+" = vec4(0.0, 0.0, 0.0, 1.0);\r\n",o+="        vec4 normalColor"+(l+1)+" = vec4(0.0, 0.0, 0.0, 1.0);\r\n",o+="        vec4 normalColor"+(l+2)+" = vec4(0.0, 0.0, 0.0, 1.0);\r\n",o+="        vec4 normalColor"+(l+3)+" = vec4(0.0, 0.0, 0.0, 1.0);\r\n",e["textureRect"+(l+0)]){var g=e["normalsScale"+(l+0)];o+="        float normalScale"+(l+0)+" = "+g.toFixed(4)+";\r\n",o+="        normalColor"+(l+0)+" = sampleTextureAtlas2D("+r+", normalCorrection, vec2(detailTileSize, detailTileBits), textureRect"+(l+0)+", textureTileUV"+(l+0)+", autoMipMapLevel);\r\n",o+="        normalColor"+(l+0)+".rgb = perturbNormalSamplerColor(TBN, normalColor"+(l+0)+".rgb, normalScale"+(l+0)+");\r\n"}if(e["textureRect"+(l+1)]){var g=e["normalsScale"+(l+1)];o+="        float normalScale"+(l+1)+" = "+g.toFixed(4)+";\r\n",o+="        normalColor"+(l+1)+" = sampleTextureAtlas2D("+r+", normalCorrection, vec2(detailTileSize, detailTileBits), textureRect"+(l+1)+", textureTileUV"+(l+1)+", autoMipMapLevel);\r\n",o+="        normalColor"+(l+1)+".rgb = perturbNormalSamplerColor(TBN, normalColor"+(l+1)+".rgb, normalScale"+(l+1)+");\r\n"}if(e["textureRect"+(l+2)]){var g=e["normalsScale"+(l+2)];o+="        float normalScale"+(l+2)+" = "+g.toFixed(4)+";\r\n",o+="        normalColor"+(l+2)+" = sampleTextureAtlas2D("+r+", normalCorrection, vec2(detailTileSize, detailTileBits), textureRect"+(l+2)+", textureTileUV"+(l+2)+", autoMipMapLevel);\r\n",o+="        normalColor"+(l+2)+".rgb = perturbNormalSamplerColor(TBN, normalColor"+(l+2)+".rgb, normalScale"+(l+2)+");\r\n"}if(e["textureRect"+(l+3)]){var g=e["normalsScale"+(l+3)];o+="        float normalScale"+(l+3)+" = "+g.toFixed(4)+";\r\n",o+="        normalColor"+(l+3)+" = sampleTextureAtlas2D("+r+", normalCorrection, vec2(detailTileSize, detailTileBits), textureRect"+(l+3)+", textureTileUV"+(l+3)+", autoMipMapLevel);\r\n",o+="        normalColor"+(l+3)+".rgb = perturbNormalSamplerColor(TBN, normalColor"+(l+3)+".rgb, normalScale"+(l+3)+");\r\n"}o+="        normalsBuffer = blendSplatmapAtlasColors(splatmapAlbedo"+s+", normalColor"+(l+0)+", normalColor"+(l+1)+", normalColor"+(l+2)+", normalColor"+(l+3)+", normalsBuffer);\r\n",o+="    #endif\r\n",o+="#endif\r\n",o+="\r\n"}o+="// Update Color Values\r\n"+n+".rgb = splatmapBuffer.rgb;\r\n#if defined(BUMP) || defined(PARALLAX) || defined(ANISOTROPIC)\r\n    #if defined("+r.toUpperCase()+")\r\n        normalW.rgb = normalsBuffer.rgb;\r\n    #endif\r\n    #if defined(FORCENORMALFORWARD) && defined(NORMAL)\r\n        vec3 faceNormal = normalize(cross(dFdx(vPositionW), dFdy(vPositionW))) * vEyePosition.w;\r\n        #if defined(TWOSIDEDLIGHTING)\r\n            faceNormal = gl_FrontFacing ? faceNormal : -faceNormal;\r\n        #endif\r\n        normalW *= sign(dot(normalW, faceNormal));\r\n    #endif\r\n    #if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\r\n        normalW = gl_FrontFacing ? normalW : -normalW;\r\n    #endif\r\n#endif\r\n\r\n#endif\r\n\r\n"}return o},a}(e.UniversalAlbedoMaterial);e.UniversalTerrainMaterial=r,e._TypeStore.RegisteredTypes.UniversalTerrainMaterial=r}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var n=function(){function n(n,a,t){if(void 0===t&&(t={}),this._update=null,this._late=null,this._after=null,this._fixed=null,this._ready=null,this._lateUpdate=!1,this._properties=null,this._awoken=!1,this._started=!1,this._scene=null,this._transform=null,this._scriptReady=!1,this._registeredClassname=null,this._lateUpdateObserver=null,this._fixedUpdateObserver=null,this.onTriggerEnterObservable=new e.Observable,this.onTriggerStayObservable=new e.Observable,this.onTriggerExitObservable=new e.Observable,this.intersectMesh=null,this.triggerVolumeList=null,this.useTriggerVolumePrecision=!1,this.includeTriggerVolumeDescendants=!1,null==n)throw new Error("Null transform object specified.");if(null==a)throw new Error("Null host scene object specified.");this._scene=a,this._transform=n,this._properties=t||{},this._registeredClassname=null;var r=this;r._update=function(){e.ScriptComponent.UpdateInstance(r)},r._late=function(){e.ScriptComponent.LateInstance(r)},r._after=function(){e.ScriptComponent.AfterInstance(r)},r._fixed=function(){e.ScriptComponent.FixedInstance(r)},r._ready=function(){e.ScriptComponent.ReadyInstance(r)},r.registerComponentInstance&&r.destroyComponentInstance||e.Tools.Warn("Invalid component registration handlers for: "+this._transform.name)}return Object.defineProperty(n.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"transform",{get:function(){return this._transform},enumerable:!1,configurable:!0}),n.prototype.setProperty=function(e,n){null==this._properties&&(this._properties={}),this._properties[e]=n},n.prototype.getProperty=function(e,n){void 0===n&&(n=null);var a=null;return null!=this._properties&&(a=this._properties[e],null==a&&(a=this._properties["auto__"+e])),null==a&&(a=n),null!=a?a:null},n.prototype.getClassName=function(){return this._registeredClassname},n.prototype.getReadyState=function(){return this._scriptReady},n.prototype.getTime=function(){return e.SceneManager.GetTime()},n.prototype.getGameTime=function(){return e.SceneManager.GetGameTime()},n.prototype.getDeltaSeconds=function(){return e.SceneManager.GetDeltaSeconds(this.scene)},n.prototype.getAnimationRatio=function(){return e.SceneManager.GetAnimationRatio(this.scene)},n.prototype.getTransformMesh=function(){return this._transform instanceof e.Mesh?this._transform:null},n.prototype.getAbstractMesh=function(){return this._transform instanceof e.AbstractMesh?this._transform:null},n.prototype.getInstancedMesh=function(){return this._transform instanceof e.InstancedMesh?this._transform:null},n.prototype.getPrimitiveMeshes=function(){return e.SceneManager.GetPrimitiveMeshes(this.transform)},n.prototype.getMetadata=function(){return e.SceneManager.FindSceneMetadata(this._transform)},n.prototype.getComponent=function(n){var a=e.SceneManager.FindScriptComponent(this._transform,n);return null!=a?a:null},n.prototype.getComponents=function(n){var a=e.SceneManager.FindAllScriptComponents(this._transform,n);return null!=a?a:null},n.prototype.getLightRig=function(){return e.SceneManager.FindSceneLightRig(this._transform)},n.prototype.getCameraRig=function(){return e.SceneManager.FindSceneCameraRig(this._transform)},n.prototype.getTransformTag=function(){return e.SceneManager.GetTransformTag(this.transform)},n.prototype.hasTransformTags=function(n){return e.SceneManager.HasTransformTags(this._transform,n)},n.prototype.getChildNode=function(n,a,t,r){return void 0===a&&(a=e.SearchType.ExactMatch),void 0===t&&(t=!0),void 0===r&&(r=null),e.SceneManager.FindChildTransformNode(this._transform,n,a,t,r)},n.prototype.getChildWithTags=function(n,a,t){return void 0===a&&(a=!0),void 0===t&&(t=null),e.SceneManager.FindChildTransformWithTags(this._transform,n,a,t)},n.prototype.getChildrenWithTags=function(n,a,t){return void 0===a&&(a=!0),void 0===t&&(t=null),e.SceneManager.FindAllChildTransformsWithTags(this._transform,n,a,t)},n.prototype.getChildWithScript=function(n,a,t){return void 0===a&&(a=!0),void 0===t&&(t=null),e.SceneManager.FindChildTransformWithScript(this._transform,n,a,t)},n.prototype.getChildrenWithScript=function(n,a,t){return void 0===a&&(a=!0),void 0===t&&(t=null),e.SceneManager.FindAllChildTransformsWithScript(this._transform,n,a,t)},n.prototype.registerOnClickAction=function(n){var a=null;return this.transform instanceof e.AbstractMesh&&(a=e.SceneManager.RegisterClickAction(this.scene,this.transform,n)),a},n.prototype.unregisterOnClickAction=function(n){var a=!1;return this.transform instanceof e.AbstractMesh&&(a=e.SceneManager.UnregisterClickAction(this.transform,n)),a},n.prototype.setTriggerIntersectMesh=function(e){this.intersectMesh=e},n.prototype.getTriggerVolumeList=function(){return this.triggerVolumeList},n.prototype.resetTriggerVolumeList=function(){this.triggerVolumeList=null},n.prototype.registerTriggerVolume=function(n){var a=new e.TriggerVolume;a.mesh=n,a.state=0,null==this.triggerVolumeList&&(this.triggerVolumeList=[]),this.triggerVolumeList.push(a)},n.prototype.unregisterTriggerVolume=function(e){if(null!=this.triggerVolumeList&&this.triggerVolumeList.length>0)for(var n=0;n<this.triggerVolumeList.length;n++){var a=this.triggerVolumeList[n];if(a.mesh===e){this.triggerVolumeList.splice(n);break}a=null}},n.prototype.registerComponentInstance=function(n,a,t){if(void 0===t&&(t=!0),t===!0){e.Utilities.ValidateTransformMetadata(this._transform);var r={alias:"script",order:0,klass:a,properties:null,instance:n};null==this._transform.metadata.unity.components&&(this._transform.metadata.unity.components=[]),this._transform.metadata.unity.components.push(r)}n._registeredClassname=a,e.ScriptComponent.RegisterInstance(n)},n.prototype.destroyComponentInstance=function(n){e.ScriptComponent.DestroyInstance(n)},n.RegisterInstance=function(n){null!=n&&(null!=n._update&&n.scene.registerBeforeRender(n._update),n.late&&null!=n._late&&null!=n.scene.onBeforeRenderTargetsRenderObservable&&(n._lateUpdateObserver=n.scene.onBeforeRenderTargetsRenderObservable.add(n._late)),n.after&&null!=n._after&&n.scene.registerAfterRender(n._after),n.fixed&&null!=n._fixed&&null!=n.scene.onAfterPhysicsObservable&&(n._fixedUpdateObserver=n.scene.onAfterPhysicsObservable.add(n._fixed)),e.Utilities.IsLastSceneExecuteReady===!1?null!=n._ready&&null!=e.Utilities.OnLastSceneExecuteReady&&e.Utilities.OnLastSceneExecuteReady.addOnce(n._ready):null!=n._ready&&null!=n.scene.onAfterRenderObservable&&n.scene.onAfterRenderObservable.addOnce(n._ready))},n.UpdateInstance=function(n){null!=n&&null!=n.transform&&n.transform._isEnabled===!0&&(n._awoken===!1?(n._awoken=!0,e.ScriptComponent.ParseAutoProperties(n),n.awake&&n.awake()):n._started===!1?(n._started=!0,n.start&&n.start()):n._awoken===!0&&n._started===!0&&(n.update&&n.update(),n._lateUpdate=!0))},n.LateInstance=function(e){null!=e&&null!=e.transform&&e.transform._isEnabled===!0&&e._lateUpdate===!0&&(e._lateUpdate=!1,e._started&&e.late&&e.late())},n.AfterInstance=function(e){if(null!=e&&null!=e.transform&&e.transform._isEnabled===!0&&(e._started&&e.after&&e.after(),null!=e.triggerVolumeList&&e.triggerVolumeList.length>0)){var n=e.intersectMesh||e.getAbstractMesh();null!=n&&e.triggerVolumeList.forEach(function(a){if(null!=a.mesh){var t=n.intersectsMesh(a.mesh,e.useTriggerVolumePrecision,e.includeTriggerVolumeDescendants);t===!0?0===a.state?(a.state=1,e.onTriggerEnterObservable.hasObservers()&&e.onTriggerEnterObservable.notifyObservers(a.mesh)):1===a.state&&e.onTriggerStayObservable.hasObservers()&&e.onTriggerStayObservable.notifyObservers(a.mesh):0!==a.state&&(a.state=0,e.onTriggerExitObservable.hasObservers()&&e.onTriggerExitObservable.notifyObservers(a.mesh))}})}},n.FixedInstance=function(e){null!=e&&null!=e.transform&&e.transform._isEnabled===!0&&e._started&&e.fixed&&e.fixed()},n.ReadyInstance=function(e){null!=e&&null!=e.transform&&e.transform._isEnabled===!0&&(e.ready&&e.ready(),e._scriptReady=!0)},n.DestroyInstance=function(e){if(null!=e){e.scene.unregisterBeforeRender(e._update),null!=e._lateUpdateObserver&&null!=e.scene.onBeforeRenderTargetsRenderObservable&&e.scene.onBeforeRenderTargetsRenderObservable.remove(e._lateUpdateObserver),e.after&&null!=e._after&&e.scene.unregisterAfterRender(e._after),null!=e._fixedUpdateObserver&&null!=e.scene.onAfterPhysicsObservable&&e.scene.onAfterPhysicsObservable.remove(e._fixedUpdateObserver);try{e.destroy&&e.destroy()}catch(n){}e.onTriggerEnterObservable.clear(),e.onTriggerEnterObservable=null,e.onTriggerStayObservable.clear(),e.onTriggerStayObservable=null,e.onTriggerExitObservable.clear(),e.onTriggerExitObservable=null,e._scriptReady=!1,e._transform=null,e._properties=null,e._started=!1,e._update=null,e._late=null,e._after=null,e._fixed=null,e._ready=null,e._scene=null}},n.ParseAutoProperties=function(n){var a=Object.keys(n._properties);if(null!=a&&a.length>0)for(var t=function(t){var r=a[t];if(e.Utilities.StartsWith(r,"auto__")){var i=r.replace("auto__","");if(e.Utilities.HasOwnProperty(n,i)){var o=n.getProperty(r);if(null!=o){var l=typeof o;if(null!=l&&""!==l)if("object"===l)if(Array.isArray(o)){var s=[],u=o;u.forEach(function(a){if(null!=a){var t=typeof a;"object"===t?s.push(e.ScriptComponent.UnpackObjectProperty(a,n.scene)):s.push(a)}}),n[i]=s}else{var c=n[i],d=e.ScriptComponent.UnpackObjectProperty(o,n.scene);c instanceof e.Color3&&d instanceof e.Color4?n[i]=new e.Color3(d.r,d.g,d.b):n[i]=d}else n[i]=o;else n[i]=o}else n[i]=o}else e.Tools.Warn(n.getClassName()||"Unregistered Class: Auto property '"+i+"' not found for transform '"+n.transform.name+"'")}},r=0;r<a.length;r++)t(r)},n.UnpackObjectProperty=function(n,a){var t=null;if(null!=n)if(void 0!==n.x&&void 0!==n.y)t=void 0!==n.z?void 0!==n.w?new e.Vector4(n.x,n.y,n.z,n.w):new e.Vector3(n.x,n.y,n.z):new e.Vector2(n.x,n.y);else if(void 0!==n.r&&void 0!==n.g&&void 0!==n.b){var r=1;void 0!==n.a&&(r=n.a),t=new e.Color4(n.r,n.g,n.b,r)}else if(void 0!==n.type)switch(n.type){case"UnityEngine.AnimationCurve":var i=n;t=e.Animation.Parse(i.animation);break;case"UnityEngine.Transform":var o=n;t=e.Utilities.ParseTransformByID(o,a);break;case"UnityEngine.Material":var l=n;t=a.getMaterialByName(l.name);break;case"UnityEngine.Texture2D":var s=n;t=e.Utilities.ParseTexture(s,a);break;case"UnityEngine.Cubemap":var u=n;t=e.Utilities.ParseCubemap(u,a);break;case"UnityEngine.AudioClip":var c=n;t=c;break;case"UnityEngine.Video.VideoClip":var d=n;t=d;break;case"UnityEngine.Font":var g=n;t=g;break;case"UnityEngine.TextAsset":var m=n;t=null!=m.base64?window.atob(m.base64):m;break;case"UnityEditor.DefaultAsset":var p=n;t=null!=p.base64?window.atob(p.base64):p;break;default:t=n}else t=n;return t},n}();e.ScriptComponent=n}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var n=function(){function n(e){this._babylonScene=e,this._physicList=[],this._shadowList=[],this._scriptList=[],this._freezeList=[]}return n.prototype.parseSceneComponents=function(n){e.MetadataParser.DoParseSceneComponents(this._babylonScene,n,this._physicList,this._shadowList,this._scriptList,this._freezeList)},n.prototype.postProcessSceneComponents=function(n){e.MetadataParser.DoProcessPendingPhysics(this._babylonScene,this._physicList),e.MetadataParser.DoProcessPendingShadows(this._babylonScene,this._shadowList),e.MetadataParser.DoProcessPendingScripts(this._babylonScene,this._scriptList,n),e.MetadataParser.DoProcessPendingFreezes(this._freezeList),this._babylonScene=null,this._physicList=null,this._shadowList=null,this._scriptList=null,this._freezeList=null},n.DoParseSceneComponents=function(n,a,t,r,i,o){if(null!=a&&null!=a.metadata&&null!=a.metadata.unity&&null!=a.metadata.unity.parsed&&a.metadata.unity.parsed===!1){a.setEnabled(!0),a.metadata.unity.parsed=!0,a.metadata.unity.prefab=!1;var l=a.metadata.unity;a.isVisible=null==a.metadata.unity.visible||a.metadata.unity.visible,a.visibility=null!=a.metadata.unity.visibility?a.metadata.unity.visibility:1,a.billboardMode=null!=a.metadata.unity.billboard?a.metadata.unity.billboard:0,a.onDisposeObservable.addOnce(function(){e.Utilities.DisposeEntity(a)});var s=a instanceof e.AbstractMesh,u=(null!=a.metadata.unity.lightmapped&&a.metadata.unity.lightmapped,l.tags);if(null!=u&&""!==u&&(e.Tags.AddTagsTo(a,u),u.indexOf("NavigationMesh")>=0&&(a.isVisible=!1,a.isPickable=!1,a.useVertexColors=!1)),null!=l.physics&&null!=t&&t.push(a),null!=l.renderer)if(s===!0)a.isPickable=!0,a.useVertexColors=!1,a.cullingStrategy=e.AbstractMesh.CULLINGSTRATEGY_STANDARD,null!=l.renderer.cullingstrategy&&l.renderer.cullingstrategy!==e.AbstractMesh.CULLINGSTRATEGY_STANDARD&&(a.cullingStrategy=l.renderer.cullingstrategy),null!=l.renderer.castshadows&&l.renderer.castshadows===!0&&null!=r&&r.push(a),null!=l.renderer.receiveshadows&&l.renderer.receiveshadows===!0&&(a.receiveShadows=!0),null!=l.renderer.checkcollisions&&l.renderer.checkcollisions===!0&&(a.checkCollisions=!0),null!=l.renderer.istriggervolume&&l.renderer.istriggervolume===!0&&(a.collisionResponse=!1),null!=l.renderer.usevertexcolors&&(a.useVertexColors=l.renderer.usevertexcolors),null!=l.renderer.setmeshpickable&&(a.isPickable=l.renderer.setmeshpickable),null!=l.renderer.showboundingbox&&(a.showBoundingBox=l.renderer.showboundingbox),null!=l.renderer.defaultellipsoid&&(a.ellipsoid=e.Utilities.ParseVector3(l.renderer.defaultellipsoid)),null!=l.renderer.ellipsoidoffset&&(a.ellipsoidOffset=e.Utilities.ParseVector3(l.renderer.ellipsoidoffset)),null!=l.renderer.rendergroupid&&(a.renderingGroupId=l.renderer.rendergroupid),null!=l.renderer.freezeworldmatrix&&l.renderer.freezeworldmatrix===!0&&null!=o&&o.push(a);else{var c=e.SceneManager.GetPrimitiveMeshes(a);null!=c&&c.length>0&&c.forEach(function(n){n.isPickable=!0,n.useVertexColors=!1,n.cullingStrategy=e.AbstractMesh.CULLINGSTRATEGY_STANDARD,null!=l.renderer.cullingstrategy&&l.renderer.cullingstrategy!==e.AbstractMesh.CULLINGSTRATEGY_STANDARD&&(n.cullingStrategy=l.renderer.cullingstrategy),null!=l.renderer.castshadows&&l.renderer.castshadows===!0&&null!=r&&r.push(n),null!=l.renderer.receiveshadows&&l.renderer.receiveshadows===!0&&(n.receiveShadows=!0),null!=l.renderer.checkcollisions&&l.renderer.checkcollisions===!0&&(n.checkCollisions=!0),null!=l.renderer.istriggervolume&&l.renderer.istriggervolume===!0&&(n.collisionResponse=!1),null!=l.renderer.usevertexcolors&&(n.useVertexColors=l.renderer.usevertexcolors),null!=l.renderer.setmeshpickable&&(n.isPickable=l.renderer.setmeshpickable),null!=l.renderer.showboundingbox&&(n.showBoundingBox=l.renderer.showboundingbox),null!=l.renderer.defaultellipsoid&&(n.ellipsoid=e.Utilities.ParseVector3(l.renderer.defaultellipsoid)),null!=l.renderer.ellipsoidoffset&&(n.ellipsoidOffset=e.Utilities.ParseVector3(l.renderer.ellipsoidoffset)),null!=l.renderer.rendergroupid&&(n.renderingGroupId=l.renderer.rendergroupid),null!=l.renderer.freezeworldmatrix&&l.renderer.freezeworldmatrix===!0&&null!=o&&o.push(n)})}if(null!=l.components){var d=l.components;null!=d&&d.length>0&&d.forEach(function(t){if(null!=t)switch(t.alias){case"camera":e.MetadataParser.SetupCameraComponent(n,a,t);break;case"light":e.MetadataParser.SetupLightComponent(n,a,t);break;case"script":null!=i&&i.push({mesh:a,comp:t})}})}}},n.DoProcessPendingScripts=function(n,a,t){null!=a&&a.length>0&&(a.sort(function(e,n){return e.comp.order<n.comp.order?-1:e.comp.order>n.comp.order?1:0}),a.forEach(function(a){if(null!=a.comp.klass&&""!==a.comp.klass&&"BABYLON.ScriptComponent"!==a.comp.klass){var r=e.Utilities.InstantiateClass(a.comp.klass);if(null!=r){var i=new r(a.mesh,n,a.comp.properties);if(null!=i){var o=i instanceof e.ScriptComponent;o===!0?(a.comp.instance=i,a.comp.instance.addPreloaderTasks&&t.push(a.comp.instance),e.SceneManager.RegisterScriptComponent(a.comp.instance,a.comp.klass,!1)):e.Tools.Warn("Non script component instantiated class: "+a.comp.klass)}else e.Tools.Warn("Failed to instantiate script class: "+a.comp.klass)}else e.Tools.Warn("Failed to locate script class: "+a.comp.klass)}}))},n.DoProcessPendingShadows=function(e,n){null!=n&&n.length>0&&null!=e.lights&&e.lights.length>0&&e.lights.forEach(function(e){if(null!=e._shadowGenerator&&null!=e.metadata&&null!=e.metadata.unity&&e.metadata.unity.autorender===!0){var a=e._shadowGenerator,t=a.getShadowMap();null!=t&&(null==t.renderList&&(t.renderList=[]),n.forEach(function(e){t.renderList.push(e)}))}})},n.DoProcessPendingPhysics=function(n,a){if(null!=a&&a.length>0){var t=n.isPhysicsEnabled(),r=t===!0?n.getPhysicsEngine():null,i=t===!0&&null!=r&&"AmmoJSPlugin"===r.getPhysicsPluginName();i===!0?a.forEach(function(a){e.RigidbodyPhysics?e.RigidbodyPhysics.SetupPhysicsComponent(n,a):e.Tools.Warn("Ammo.js rigidbody physics system not loaded. Physics impostors will not be created for: "+a.name)}):e.Tools.Warn("Ammo.js physics engine not loaded. Physics impostors will not be created.")}},n.DoProcessPendingFreezes=function(e){null!=e&&e.length>0&&e.forEach(function(e){e.freezeWorldMatrix()})},n.SetupCameraComponent=function(n,a,t){a.checkCollisions=!1;var r=a.name+".Rig",i=e.SceneManager.GetRightHanded(n)===!0?Math.PI:0,o=new e.UniversalCamera(r,e.Vector3.Zero(),n);o.checkCollisions=!1,o.rotationQuaternion=e.Quaternion.FromEulerAngles(0,i,0),o.parent=a;var l=null!=t.culling&&t.culling,s=(null!=t.clearflags?t.clearflags:0,null!=t.renderlist?t.renderlist:null),u=null!=t.maincamera&&t.maincamera;u===!0&&(n.activeCamera=o);var c=null!=t.type?t.type:0;switch(c){case 0:o.mode=e.Camera.PERSPECTIVE_CAMERA,null!=t.perspectiveyfov&&(o.fov=t.perspectiveyfov),null!=t.perspectiveznear&&(o.minZ=t.perspectiveznear),null!=t.perspectivezfar&&(o.maxZ=t.perspectivezfar);break;case 1:o.mode=e.Camera.ORTHOGRAPHIC_CAMERA,null!=t.orthoxmag&&(o.orthoLeft=-t.orthoxmag,o.orthoRight=t.orthoxmag),null!=t.orthoymag&&(o.orthoBottom=-t.orthoymag,o.orthoTop=t.orthoymag),null!=t.orthoznear&&(o.minZ=t.orthoznear),null!=t.orthozfar&&(o.maxZ=t.orthozfar)}if(0===l);else if(l===-1);else{var d=0,g=s;if(null!=g&&g.length>0){var m=function(){var a=g[d],t=e.SceneManager.GetMeshByID(n,a);if(null!=t){var r=t.name+".Detail",i=t.getChildren(function(e){return e.name===r},!0);null!=i&&i.length>0}};for(d=0;d<g.length;d++)m()}}a.cameraRig=o},n.SetupLightComponent=function(n,a,t){a.checkCollisions=!1;var r,i=a.name+".Rig",o=1,l=null!=t.culling&&t.culling,s=(null!=t.clearflags?t.clearflags:0,null!=t.renderlist?t.renderlist:null),u=null!=t.type?t.type:0,c=e.SceneManager.GetRenderQuality(),d=null!=t.exponentdecayspeed?t.exponentdecayspeed:1,g=!1;switch(u){case 0:var m=e.SceneManager.GetRightHanded(n)===!0?e.Vector3.Backward():e.Vector3.Forward(),p=null!=t.orthoscale?t.orthoscale:.1,f=new e.DirectionalLight(i,m,n);f.shadowOrthoScale=p,r=f,r.falloffType=e.Light.FALLOFF_STANDARD,g=c===e.RenderQuality.High||c===e.RenderQuality.Medium,o=1;break;case 1:var h=r=new e.PointLight(i,e.Vector3.Zero(),n);r=h,r.falloffType=e.Light.FALLOFF_STANDARD,g=c===e.RenderQuality.High||c===e.RenderQuality.Medium,o=1;break;case 2:var m=e.SceneManager.GetRightHanded(n)===!0?e.Vector3.Backward():e.Vector3.Forward(),S=null!=t.spotangle?t.spotangle:Math.PI/4,M=new e.SpotLight(i,e.Vector3.Zero(),m,0,d,n);M.angle=.966*e.Tools.ToRadians(S),M.innerAngle=.8*M.angle,r=M,r.falloffType=e.Light.FALLOFF_GLTF,g=c===e.RenderQuality.High||c===e.RenderQuality.Medium,o=10}if(null!=r){var y=null!=t.range?t.range:Number.MAX_VALUE,v=null!=t.color?e.Utilities.ParseColor3(t.color,e.Color3.White()):e.Color3.White(),b=null!=t.specular?e.Utilities.ParseColor3(t.specular,e.Color3.White()):e.Color3.White();r.parent=a,r.range=y,r.diffuse=v,r.specular=b,r.intensity=(null!=t.intensity?t.intensity:1)*o,r.lightmapMode=e.Light.LIGHTMAP_DEFAULT,r.intensityMode=e.Light.INTENSITYMODE_AUTOMATIC,r.shadowEnabled=!1;var T=null==t.autorender||t.autorender,_=null!=t.softshadows&&t.softshadows,x=null!=t.numcascades?t.numcascades:0,A=null!=t.cascadelambda?t.cascadelambda:1,C=null!=t.setdepthclamp&&t.setdepthclamp,O=null!=t.blendpertecntage?t.blendpertecntage:1e-8,P=null!=t.boundsrefreshrate?t.boundsrefreshrate:1,w=null!=t.lightcontactratio?t.lightcontactratio:.1,B=null!=t.stabilizecascades&&t.stabilizecascades,k=null!=t.penumbradarkness?t.penumbradarkness:1,L=null!=t.softshadowsfilter?t.softshadowsfilter:99,U=null!=t.freezeshadows&&t.freezeshadows,N=null!=t.calcdepths&&t.calcdepths,R=null!=t.depthscaling?t.depthscaling:50,I=null!=t.blurscaling?t.blurscaling:2,D=null==t.kernelblur||t.kernelblur,E=null!=t.blurkernelsize?t.blurkernelsize:1,F=null!=t.blurboxoffset?t.blurboxoffset:1,V=null!=t.shadowmapsize?t.shadowmapsize:1024,G=null!=t.generateshadows&&t.generateshadows,H=null!=t.shadowbiasfactor?t.shadowbiasfactor:.1,z=null!=t.shadowmapbias?t.shadowmapbias:.05,Y=null!=t.normalmapbias?t.normalmapbias:.4,W=null!=t.shadowstrength?t.shadowstrength:1,X=null!=t.shadowdistance?t.shadowdistance:150,j=null!=t.shadownearplane?t.shadownearplane:.2,Q=null!=t.shadowfilterquality?t.shadowfilterquality:"Medium",K=null!=t.transparencyshadow&&t.transparencyshadow,q=null!=t.softtransparency&&t.softtransparency,J=null==t.forcebackfacesonly||t.forcebackfacesonly,Z=null!=t.frustumedgefalloff?t.frustumedgefalloff:0;
  if(g===!0&&G===!0){var $=r,ee=e.SceneManager.GetWebGLVersionNumber(n),ne=0===u&&x>=2&&ee>=2,ae=ne===!0?new e.CascadedShadowGenerator(V,r,(!0)):new e.ShadowGenerator(V,$,(!0));if(ae.bias=z*H,ae.normalBias=Y*H*.1,ae.depthScale=R,ae.useKernelBlur=D,ae.blurKernel=E,ae.blurScale=I,ae.blurBoxOffset=F,ae.frustumEdgeFalloff=Z,ae.forceBackFacesOnly=J,ae.setTransparencyShadow(K),ae.enableSoftTransparentShadow=q,ae.contactHardeningLightSizeUVRatio=w,_===!0)if(ee<=1)ae.usePoissonSampling=!0;else if(ne===!0)ae.usePercentageCloserFiltering=!0;else switch(L){case 0:ae.usePoissonSampling=!0;break;case 1:ae.useExponentialShadowMap=!0;break;case 2:ae.useBlurExponentialShadowMap=!0;break;case 3:ae.useCloseExponentialShadowMap=!0;break;case 4:ae.useBlurCloseExponentialShadowMap=!0;break;case 5:ae.useContactHardeningShadow=!0;break;case 99:ae.usePercentageCloserFiltering=!0;break;default:ae.usePoissonSampling=!0}switch(Q){case"High":ae.filteringQuality=e.ShadowGenerator.QUALITY_HIGH;break;case"Medium":ae.filteringQuality=e.ShadowGenerator.QUALITY_MEDIUM;break;case"Low":ae.filteringQuality=e.ShadowGenerator.QUALITY_LOW}if(ne===!0){var te=ae;te.lambda=A,te.depthClamp=C,te.shadowMaxZ=X,te.numCascades=x,te.penumbraDarkness=k,te.autoCalcDepthBounds=N,te.stabilizeCascades=B,te.cascadeBlendPercentage=O,te.autoCalcDepthBoundsRefreshRate=P,te.freezeShadowCastersBoundingInfo=U,te.setDarkness(1-e.Scalar.Clamp(W)),$.shadowEnabled=!0,te.splitFrustum()}else{var re=ae;re.setDarkness(1-e.Scalar.Clamp(W)),$.shadowEnabled=!0,$.shadowMinZ=j,$.shadowMaxZ=X}null==r.metadata&&(r.metadata={}),null==r.metadata.unity&&(r.metadata.unity={}),r.metadata.unity.autorender=T}if(0===l){var ie=a.name+".Holder";r.includedOnlyMeshes=[new e.Mesh(ie,n)]}else if(l===-1)r.includedOnlyMeshes=[];else{var oe=0;r.includedOnlyMeshes=[];var le=s;if(null!=le&&le.length>0){var se=function(){var a=le[oe],t=e.SceneManager.GetMeshByID(n,a);if(null!=t){var i=t.name+".Detail",o=t.getChildren(function(e){return e.name===i},!0);null!=o&&o.length>0?r.includedOnlyMeshes.push(o[0]):r.includedOnlyMeshes.push(t)}};for(oe=0;oe<le.length;oe++)se()}}a.lightRig=r}},n}();e.MetadataParser=n}(BABYLON||(BABYLON={}));var CVTOOLS_NAME="CVTOOLS_unity_metadata",CVTOOLS_MESH="CVTOOLS_babylon_mesh",CVTOOLS_HAND="CVTOOLS_left_handed",CubeTextureLoader=function(){function e(){}return e}(),CVTOOLS_unity_metadata=function(){function e(n){this.name=CVTOOLS_NAME,this.enabled=!1,this._materialMap=null,this._lightmapMap=null,this._reflectionMap=null,this._reflectionCache=null,this._activeMeshes=!1,this._parseScene=!1,this._leftHanded=!1,this._disposeRoot=!1,this._sceneParsed=!1,this._preWarmTime=1,this._postWarmTime=1,this._hideLoader=!1,this._rootUrl=null,this._loader=n,this.enabled=this._loader.isExtensionUsed(CVTOOLS_NAME),this._parseScene=this._leftHanded=this._disposeRoot=this._sceneParsed=!1,this._masterList=null,this._detailList=null,this._parserList=null,this._shaderList=null,this._preloadList=null,this._materialMap=null,this._lightmapMap=null,this._reflectionMap=null,this._reflectionCache=null,this._preWarmTime=1,this._postWarmTime=1,this._hideLoader=!1,e.LastAssetsManager=null,this._rootUrl=null,this.order=100}return e.prototype.dispose=function(){delete this._loader},e.prototype.onLoading=function(){var n=this;BABYLON.Utilities.LoadingState=0,this._rootUrl=this._loader._uniqueRootUrl?this._loader._uniqueRootUrl:"/",e.LastRootUrl=this._rootUrl,e.LastParseScene=!1,e.LastBabylonScene=this._loader.babylonScene,this._parseScene=this._loader.isExtensionUsed(CVTOOLS_NAME)&&BABYLON.SceneManager.IsSceneParsingEnabled()===!0,this._leftHanded=this._loader.isExtensionUsed(CVTOOLS_HAND),this._disposeRoot=this._sceneParsed=!1,this._masterList=[],this._detailList=[],this._parserList=[],this._shaderList=[],this._preloadList=[],this._materialMap=new Map,this._lightmapMap=new Map,this._reflectionMap={},this._reflectionCache={},this._preWarmTime=1,this._postWarmTime=1,this._hideLoader=!1,this._parseScene===!0&&(BABYLON.Utilities.IsLastSceneExecuteReady=!1,BABYLON.Utilities.OnLastSceneExecuteReady.clear(),e.LastAssetsManager=new BABYLON.AssetsManager(this._loader.babylonScene),e.LastAssetsManager.onProgress=function(e,n,a){if(BABYLON.SceneManager.AutoUpdateProgress===!0){var t="Preloading asset "+(n-e)+" of "+n;BABYLON.SceneManager.UpdateLoaderStatus("Please wait",t,BABYLON.Utilities.LoadingState)}else null!=BABYLON.Utilities.OnPreloaderProgress&&BABYLON.Utilities.OnPreloaderProgress(e,n,a)},e.LastAssetsManager.onFinish=function(a){BABYLON.Utilities.LoadingState=3,BABYLON.SceneManager.SetTimeout(2500,function(){BABYLON.SceneManager.AutoUpdateProgress===!0&&BABYLON.SceneManager.UpdateLoaderStatus("Please wait","Preparing scene content",BABYLON.Utilities.LoadingState),BABYLON.SceneManager.SetTimeout(1e3*(n._postWarmTime+1.5),function(){null!=BABYLON.Utilities.OnPreloaderComplete&&BABYLON.Utilities.OnPreloaderComplete(a),1==n._hideLoader&&BABYLON.SceneManager.HideSceneLoader(),e.LastBabylonScene.onAfterRenderObservable.addOnce(function(){BABYLON.Utilities.IsLastSceneExecuteReady=!0,BABYLON.Utilities.OnLastSceneExecuteReady.hasObservers()===!0&&BABYLON.Utilities.OnLastSceneExecuteReady.notifyObservers(e.LastBabylonScene),BABYLON.Utilities.OnLastSceneExecuteReady.clear()})})})},this._loader.parent.onCompleteObservable.addOnce(function(){})),this._leftHanded===!0&&null!=this._loader.rootBabylonMesh&&(this._loader.rootBabylonMesh.rotationQuaternion=BABYLON.Quaternion.Identity(),this._loader.rootBabylonMesh.scaling=BABYLON.Vector3.One())},e.prototype.loadSceneAsync=function(n,a){if(this._parseScene===!0&&null!=a.extras&&null!=a.extras.metadata){if(this.preProcessSceneProperties(a,e.LastBabylonScene),null!=a.extras.metadata.rawmaterials){var t=this._loader,r=a.extras.metadata.rawmaterials;this._preloadRawMaterialsAsync(n,t._gltf.materials,r)}return BABYLON.Utilities.LoadingState=1,this.loadSceneExAsync(n,a)}return BABYLON.Utilities.LoadingState=1,null},e.prototype.loadSceneExAsync=function(e,n){var a=this,t=this._loader,r=new Array;if(t.logOpen(e+" "+(n.name||"")),n.nodes)for(var i=0,o=n.nodes;i<o.length;i++){var l=o[i],s=BABYLON.GLTF2.ArrayItem.Get(e+"/nodes/"+l,t._gltf.nodes,l),u=s;r.push(this.loadNodeAsync("/nodes/"+u.index,s,function(e){e.parent=t._rootBabylonMesh}))}if(null!=this._reflectionMap){var c=function(e){if(d._reflectionMap.hasOwnProperty(e)){var n=e,t=d._reflectionMap[n];r.push(d.loadDataUrlAsync("material/reflectionTexture/"+n,n).then(function(e){if(null!=e&&null!=t){var n=new Blob([e]);t.forEach(function(e){var t=a._reflectionCache[e.mapkey];if(null!=t)null!=e.material&&BABYLON.Utilities.HasOwnProperty(e.material,"reflectionTexture")&&(e.material.reflectionTexture=t);else{var r=URL.createObjectURL(n),i=function(){URL.revokeObjectURL(r)},o=new BABYLON.CubeTexture(r,a._loader.babylonScene,null,null,null,i,i,null,e.prefiltered,e.extension);o.name=e.name,null!=e.boundingBoxSize&&(o.boundingBoxSize=e.boundingBoxSize),null!=e.boundingBoxPosition&&(o.boundingBoxPosition=e.boundingBoxPosition),a._reflectionCache[e.mapkey]=o,null!=e.material&&BABYLON.Utilities.HasOwnProperty(e.material,"reflectionTexture")&&(e.material.reflectionTexture=o)}})}}))}},d=this;for(var g in this._reflectionMap)c(g)}if(t._gltf.nodes)for(var m=0,p=t._gltf.nodes;m<p.length;m++){var s=p[m];if(s._babylonTransformNode&&s._babylonBones)for(var f=0,h=s._babylonBones;f<h.length;f++){var S=h[f];S.linkTransformNode(s._babylonTransformNode)}}return r.push(t._loadAnimationsAsync()),t.logClose(),Promise.all(r).then(function(){})},e.prototype.onReady=function(){var n=this;if(this._parseScene===!0){var a=this._loader._fileName?this._loader._fileName:"Unknown";null!=this._loader.rootBabylonMesh&&(this._loader.rootBabylonMesh.name="Root."+a.replace(".gltf","").replace(".glb",""));var t=e.LastRootUrl,r=e.LastBabylonScene;this._processShaderMaterials(r,this._shaderList),this._processLevelOfDetail(r,this._detailList),this._processActiveMeshes(r,this._activeMeshes),this._processUnityMeshes(this._masterList),e.LastParseScene===!0&&this.postProcessSceneProperties(t,r),this._disposeRoot===!0&&null!=this._loader.rootBabylonMesh&&this._loader.rootBabylonMesh.dispose(!0),null!=this._parserList&&this._parserList.length>0&&BABYLON.Utilities.ParseSceneComponents(r,this._parserList,this._preloadList),e.LastBabylonScene.onAfterRenderObservable.addOnce(function(){BABYLON.Utilities.LoadingState=2,BABYLON.SceneManager.SetTimeout(1e3*n._preWarmTime,function(){n._processPreloadTimeout()})})}},e.prototype._processActiveMeshes=function(e,n){n===!0&&e.freeActiveMeshes()},e.prototype._processUnityMeshes=function(e){null!=e&&e.length>0&&e.forEach(function(e){BABYLON.Utilities.RegisterInstancedMeshBuffers(e)})},e.prototype._processPreloadTimeout=function(){if(null!=e.LastAssetsManager){if(null!=this._preloadList&&this._preloadList.length>0)for(var n=0;n<this._preloadList.length;n++){var a=this._preloadList[n];null!=a&&a.addPreloaderTasks&&a.addPreloaderTasks(e.LastAssetsManager)}e.LastAssetsManager.load()}},e.prototype.loadNodeAsync=function(e,n,a){var t=this;return this._parseScene===!0&&null!=n.extras&&null!=n.extras.metadata?this._loader.loadNodeAsync(e,n,function(e){var r=e,i=n.extras.metadata;null==r.metadata&&(r.metadata={}),r.metadata.unity=i,BABYLON.Utilities.ValidateTransformGuid(r),BABYLON.Utilities.ValidateTransformMetadata(r),BABYLON.Utilities.ValidateTransformQuaternion(r),t._leftHanded===!0||t._loader.babylonScene.useRightHandedSystem===!0?r.overrideMaterialSideOrientation=BABYLON.Material.CounterClockWiseSideOrientation:r.overrideMaterialSideOrientation=BABYLON.Material.ClockWiseSideOrientation,r.isVisible=null==r.metadata.unity.visible||r.metadata.unity.visible,r.visibility=null!=r.metadata.unity.visibility?r.metadata.unity.visibility:1,r.billboardMode=null!=r.metadata.unity.billboard?r.metadata.unity.billboard:0,r.metadata.unity.prefab=t._loader._forAssetContainer,r.metadata.unity.prefab===!0?r.setEnabled(!1):t._parserList.push(r),t._masterList.push(r),a(r)}):null},e.prototype.loadMaterialPropertiesAsync=function(e,n,a){if(this._parseScene===!0){var t=-1;n.index&&(t=n.index,t>=0&&null!=this._materialMap&&(this._materialMap.has(t)||this._materialMap.set(t,a))),a.gltfIndex=t;var r=this._loader,i=new Array;return a instanceof BABYLON.ShaderMaterial?i.push(this._parseShaderMaterialPropertiesAsync(e+"/shaderMaterial",n,a)):a instanceof BABYLON.StandardMaterial?i.push(this._parseDiffuseMaterialPropertiesAsync(e+"/standardMaterial",n,a)):(i.push(r.loadMaterialBasePropertiesAsync(e,n,a)),n.pbrMetallicRoughness&&i.push(r._loadMaterialMetallicRoughnessPropertiesAsync(e+"/pbrMetallicRoughness",n.pbrMetallicRoughness,a)),r.loadMaterialAlphaProperties(e,n,a),this._parseCommonConstantProperties(i,e+"/commonConstant",n,a)),Promise.all(i).then(function(){})}return null},e.prototype._getCachedMaterialByIndex=function(e){var n=null;return e>=0&&null!=this._materialMap&&(n=this._materialMap.get(e)||null),n},e.prototype._getCachedLightmapByIndex=function(e){var n=null;return e>=0&&null!=this._lightmapMap&&(n=this._lightmapMap.get(e)||null),n},e.prototype.createMaterial=function(e,n,a){if(this._parseScene===!0&&n.index){var t=n.index;if(t>=0){var r=this._getCachedMaterialByIndex(t);if(null!=r)return r}}if(this._parseScene===!0&&null!=n.extras&&null!=n.extras.metadata&&null!=n.extras.metadata.customMaterial){var i=null,o=n.name||"No Name",l=n.extras.metadata,s=l.customMaterial,u=(l.customShader,BABYLON.Utilities.InstantiateClass(s));if(null!=u){var c=new u(o,this._loader.babylonScene);if(null!=c){var d=c instanceof BABYLON.Material;d===!0?(i=c,i.fillMode=a,i instanceof BABYLON.ShaderMaterial&&BABYLON.Utilities.InitializeShaderMaterial(i)):BABYLON.Tools.Warn("Non material instantiated class: "+s)}else BABYLON.Tools.Warn("Failed to instantiate material class: "+s)}else BABYLON.Tools.Warn("Failed to locate material class: "+s);return i}return null},e.prototype.loadDataUrlAsync=function(e,n){var a=this._loader;if(!BABYLON.GLTF2.GLTFLoader._ValidateUri(n))throw new Error(e+": '"+n+"' is invalid");if(BABYLON.Tools.IsBase64(n)){var t=new Uint8Array(BABYLON.Tools.DecodeBase64(n));return a.log(e+": Decoded "+n.substr(0,64)+"... ("+t.length+" bytes)"),Promise.resolve(t)}return a.log(e+": Loading "+n),a._parent.preprocessUrlAsync(n).then(function(t){return new Promise(function(r,i){a._parent._loadFile(t,a._babylonScene,function(t){a._disposed||(a.log(e+": Loaded "+n+" ("+t.byteLength+" bytes)"),r(new Uint8Array(t)))},!0,function(a){i(new BABYLON.LoadFileError(e+": Failed to load '"+n+"'"+(a?": "+a.status+" "+a.statusText:""),a))})})})},e.prototype._loadSkinAsync=function(e,n,a){if(this._parseScene===!0){var t=this._loader,r=a,i=function(e){t._forEachPrimitive(n,function(n){n.skeleton=e,n instanceof BABYLON.AbstractMesh&&null!=u._offscreen&&u._offscreen===!0&&(n.alwaysSelectAsActiveMesh=!0)})};if(r._data)return i(r._data.babylonSkeleton),r._data.promise;var o=null!=a.extras&&null!=a.extras.metadata&&null!=a.extras.metadata.name&&""!==a.extras.metadata.name?a.extras.metadata.name:"Skeleton"+r.index,l=this._loader._fileName?this._loader._fileName:"Unknown",s=l.replace(".gltf","").replace(".glb","")+"."+o;t._babylonScene._blockEntityCollection=t._forAssetContainer;var u=new BABYLON.Skeleton(a.name||s,s,t._babylonScene);t._babylonScene._blockEntityCollection=!1,u.overrideMesh=t._rootBabylonMesh,null!=a.extras&&null!=a.extras.metadata&&null!=a.extras.metadata.offscreen&&a.extras.metadata.offscreen===!0&&(u._offscreen=!0),t._loadBones(e,a,u),i(u);var c=t._loadSkinInverseBindMatricesDataAsync(e,a).then(function(e){t._updateBoneMatrices(u,e)});return r._data={babylonSkeleton:u,promise:c},c}return null},e.prototype.loadAnimationAsync=function(e,n){if(this._parseScene===!0&&null!=n.extras&&null!=n.extras.metadata){var a=this._loader,t=n;a._babylonScene._blockEntityCollection=a._forAssetContainer;var r=new BABYLON.AnimationGroup(n.name||"animation"+t.index,a._babylonScene);a._babylonScene._blockEntityCollection=!1,t._babylonAnimationGroup=r;var i=new Array;BABYLON.GLTF2.ArrayItem.Assign(t.channels),BABYLON.GLTF2.ArrayItem.Assign(t.samplers);for(var o=0,l=n.channels;o<l.length;o++){var s=l[o],u=s;i.push(a._loadAnimationChannelAsync(e+"/channels/"+u.index,e,n,s,r))}return Promise.all(i).then(function(){var e={};return e.unity=n.extras.metadata,r.metadata=e,r.normalize(0),r})}return null},e.prototype._loadMeshPrimitiveAsync=function(e,n,a,t,r,i){var o=this;if(this._parseScene===!0){var l=this._loader;l.logOpen(""+e);var s,u=void 0==a.skin&&!t.primitives[0].targets,c=void 0,d=r._instanceData;if(u&&d)s=d.babylonSourceMesh.createInstance(n),c=d.promise;else{var g=new Array,m=new BABYLON.Mesh(n,l._babylonScene);l._createMorphTargets(e,a,t,r,m),g.push(l._loadVertexDataAsync(e,r,m).then(function(n){return l._loadMorphTargetsAsync(e,r,m,n).then(function(){n.applyToMesh(m),o._setupBabylonMesh(m,a,t,r)})}));var p=BABYLON.GLTF2.GLTFLoader._GetDrawMode(e,r.mode);if(null!=r.extras&&null!=r.extras.metadata&&null!=r.extras.metadata.multimaterial&&null!=r.extras.metadata.submeshes)this._setupBabylonMaterials(e,g,p,m,t,r);else if(void 0==r.material){var f=l._defaultBabylonMaterialData[p];f||(f=l._createDefaultMaterial("__GLTFLoader._default",p),l._parent.onMaterialLoadedObservable.notifyObservers(f),l._defaultBabylonMaterialData[p]=f),m.material=f}else{var h=BABYLON.GLTF2.ArrayItem.Get(e+"/material",l._gltf.materials,r.material);g.push(l._loadMaterialAsync("/materials/"+h.index,h,m,p,function(e){m.material=e}))}c=Promise.all(g),u&&(r._instanceData={babylonSourceMesh:m,promise:c}),s=m}return BABYLON.GLTF2.GLTFLoader.AddPointerMetadata(s,e),l._parent.onMeshLoadedObservable.notifyObservers(s),i(s),l.logClose(),c.then(function(){return s})}return null},e.prototype._setupBabylonMesh=function(e,n,a,t){if(this._parseScene===!0){this._loader;if(null!=t.extras&&null!=t.extras.metadata&&null!=t.extras.metadata.multimaterial&&null!=t.extras.metadata.submeshes){var r=t.extras.metadata.submeshes;e.subMeshes=[];for(var i=0;i<r.length;i++){var o=r[i];BABYLON.SubMesh.AddToMesh(o.materialIndex,o.verticesStart,o.verticesCount,o.indexStart,o.indexCount,e)}}null!=n.extras&&null!=n.extras.metadata&&null!=n.extras.metadata.lods&&null!=n.extras.metadata.distances&&null!=this._detailList&&this._detailList.push(e),e.computeWorldMatrix(!0)}},e.prototype._processLevelOfDetail=function(e,n){null!=n&&n.length>0&&n.forEach(function(n){if(null!=n.metadata&&null!=n.metadata.unity&&null!=n.metadata.unity.lods){var a=n.metadata.unity.lods,t=n.isEnabled(!1),r=n;if(null!=n.metadata.unity.distances){var i=n.metadata.unity.distances;if(i.length>=a.length){var o=i.length>a.length?i[i.length-1]:0;r.setEnabled(!1);for(var l=0;l<a.length;l++){var s=a[l],u=e.getMeshByID(s);null!=u?r.addLODLevel(i[l],u):BABYLON.Tools.Warn("Failed to locate lod mesh with id "+s+" for "+n.name)}o>0&&r.addLODLevel(o,null),t===!0&&r.setEnabled(!0)}else BABYLON.Tools.Warn("Invalid level of detail distances for "+n.name)}else null!=n.metadata.unity.coverages}})},e.prototype._setupBabylonMaterials=function(e,n,a,t,r,i){if(this._parseScene===!0){var o=this._loader,l=i.extras.metadata.multimaterial,s=l.materials,u=[],c=l.id||"MM_"+r.name,d=l.name||"MM_"+r.name,g=new BABYLON.MultiMaterial("["+d+"]",o._babylonScene);g.id=c,s.forEach(function(n){var a=BABYLON.GLTF2.ArrayItem.Get(e+"/material",o._gltf.materials,parseInt(n));u.push(a)}),n.push(this._parseMultiMaterialAsync("/materials/"+d,u,t,a,function(e){g.subMaterials=e,t.material=g}))}},e.prototype._processShaderMaterials=function(e,n){null!=n&&n.length>0&&n.forEach(function(e){e.freeze()})},e.prototype.preProcessSceneProperties=function(n,a){if(this._loader._forAssetContainer!==!0&&this._sceneParsed===!1&&null!=n.extras&&null!=n.extras.metadata&&null!=n.extras.metadata.properties&&n.extras.metadata.properties===!0){this._sceneParsed=!0,e.LastParseScene=!0;var t=null!=this._rootUrl?this._rootUrl:"/",r=this._loader._fileName?this._loader._fileName:null,i=n.extras.metadata;if(null==a.metadata&&(a.metadata={}),null==a.metadata.unity&&(a.metadata.unity={}),a.metadata.unity=i,this._disposeRoot=null!=i.disposeroot&&i.disposeroot===!0,this._hideLoader=null!=i.hideloader&&i.hideloader===!0,this._preWarmTime=null!=i.prewarmup&&i.prewarmup>1?i.prewarmup:1,this._postWarmTime=null!=i.postwarmup&&i.postwarmup>1?i.postwarmup:1,BABYLON.SceneManager.SetRootUrl(a,t),BABYLON.SceneManager.SetSceneFile(a,r),BABYLON.SceneManager.SetRightHanded(a,!this._leftHanded),BABYLON.SceneManager.EnableUserInput=!0,window.intensityFactor=null!=i.intensity?i.intensity:2,window.debugModeEnabled=null!=i.debugging&&i.debugging,window.showDebugColliders=null!=i.showdebugcolliders&&i.showdebugcolliders,window.colliderVisibility=null!=i.collidervisibility?i.collidervisibility:0,window.collisionWireframe=null!=i.collisionwireframe&&i.collisionwireframe,null!=i.clearcolor&&(a.clearColor=BABYLON.Utilities.ParseColor4(i.clearcolor)),null!=i.autoclear&&i.autoclear===!0&&(a.autoClear=!0,a.autoClearDepthAndStencil=!0),null!=i.rendergroups&&(BABYLON.RenderingManager.MAX_RENDERINGGROUPS=i.rendergroups),null!=i.imageprocessing){var o=i.imageprocessing,l=null!=o.contrast?o.contrast:1,s=null!=o.exposure?o.exposure:1;null!=a.imageProcessingConfiguration&&(a.imageProcessingConfiguration.contrast=l,a.imageProcessingConfiguration.exposure=s)}if(null!=i.ambientcoloring&&(a.ambientColor=BABYLON.Utilities.ParseColor3(i.ambientcoloring)),null!=i.ambientlighting&&i.ambientlighting>0){var u=a;null==u._AmbientLight&&(u._AmbientLight=new BABYLON.HemisphericLight("Ambient Lighting",new BABYLON.Vector3(0,1,0),a),u._AmbientLight.falloffType=BABYLON.Light.FALLOFF_STANDARD,u._AmbientLight.lightmapMode=BABYLON.Light.LIGHTMAP_DEFAULT),null!=u._AmbientLight&&(null!=i.ambientskycolor&&(u._AmbientLight.diffuse=BABYLON.Utilities.ParseColor3(i.ambientskycolor,BABYLON.Color3.Gray())),null!=i.ambientspecularcolor&&(u._AmbientLight.specular=BABYLON.Utilities.ParseColor3(i.ambientspecularcolor,BABYLON.Color3.White())),null!=i.ambientgroundcolor&&(u._AmbientLight.groundColor=BABYLON.Utilities.ParseColor3(i.ambientgroundcolor,BABYLON.Color3.Gray())),null!=i.ambientlightintensity&&(u._AmbientLight.intensity=i.ambientlightintensity))}if(null!=i.fogmode){var c=i.fogmode;if(c>0){var d=.6;a.fogMode=c,a.fogEnabled=!0,null!=i.fogdensity&&(a.fogDensity=i.fogdensity*d),null!=i.fogstart&&(a.fogStart=i.fogstart),null!=i.fogend&&(a.fogEnd=i.fogend),null!=i.fogcolor&&(a.fogColor=BABYLON.Utilities.ParseColor3(i.fogcolor))}}var g=new BABYLON.Vector3(0,(-9.81),0),m=null!=i.defaultgravity?BABYLON.Utilities.ParseVector3(i.defaultgravity,g):g;if(a.gravity=m.clone(),a.collisionsEnabled=!0,null!=i.enablephysics){var p=i.enablephysics;if(p===!0){var f=null!=i.subtimestep?i.subtimestep:0,h=null!=i.maxworldsweep?i.maxworldsweep:0,S=null==i.ccdenabled||i.ccdenabled,M=null!=i.ccdpenetration?i.ccdpenetration:0,y=null==i.deltaworldstep||i.deltaworldstep;BABYLON.SceneManager.ConfigurePhysicsEngine(a,y,f,h,S,M,m)}}var v=!1,b=0;if(null!=i.userinput){var T=i.userinput;b=T.joystickInputValue,v=T.disableRightStick;var _=T.joystickRightColorText;null!=_&&""!==_&&(BABYLON.UserInputOptions.JoystickRightHandleColor=_),BABYLON.UserInputOptions.KeyboardSmoothing=T.keyboardSmoothing,BABYLON.UserInputOptions.KeyboardMoveSensibility=T.keyboardSensitivity,BABYLON.UserInputOptions.KeyboardMoveDeadZone=T.keyboardDeadZone,BABYLON.UserInputOptions.GamepadDeadStickValue=T.padDeadStick,BABYLON.UserInputOptions.GamepadLStickXInverted=T.padLStickXInvert,BABYLON.UserInputOptions.GamepadLStickYInverted=T.padLStickYInvert,BABYLON.UserInputOptions.GamepadRStickXInverted=T.padRStickXInvert,BABYLON.UserInputOptions.GamepadRStickYInverted=T.padRStickYInvert,BABYLON.UserInputOptions.GamepadLStickSensibility=T.padLStickLevel,BABYLON.UserInputOptions.GamepadRStickSensibility=T.padRStickLevel,BABYLON.UserInputOptions.JoystickDeadStickValue=T.joystickDeadStick,BABYLON.UserInputOptions.JoystickLeftSensibility=T.joystickLeftLevel,BABYLON.UserInputOptions.JoystickRightSensibility=T.joystickRightLevel,BABYLON.UserInputOptions.PointerAngularSensibility=T.mouseSensitivity,BABYLON.UserInputOptions.PointerWheelDeadZone=T.wheelDeadZone,BABYLON.UserInputOptions.PointerMouseDeadZone=T.mouseDeadZone,BABYLON.UserInputOptions.PointerMouseInverted=T.mouseMoveInvert,BABYLON.UserInputOptions.UseArrowKeyRotation=T.arrowKeyRotation,BABYLON.UserInputOptions.UseCanvasElement=T.useCanvasElement}if(null!=i.enableinput){var x=i.enableinput;if(x===!0){var A=null!=i.pointerlock&&i.pointerlock,C=null!=i.preventdefault&&i.preventdefault,O=null!=i.usecapture&&i.usecapture,P={pointerLock:A,preventDefault:C,useCapture:O,enableVirtualJoystick:1===b||2===b&&BABYLON.SceneManager.IsMobile(),disableRightStick:v};BABYLON.SceneManager.ConfigureUserInput(a,P)}}null!=i.freezeactivemeshes&&i.freezeactivemeshes===!0&&(this._activeMeshes=!0)}},e.prototype.postProcessSceneProperties=function(n,a){if(null!=a.metadata&&null!=a.metadata.unity){var t=a.metadata.unity;if(null!=t.skybox){var r=t.skybox,i=null!=r.skyfog&&r.skyfog,o=(null!=r.skysrgb&&r.skysrgb,null!=r.skytags?r.skytags:"Untagged"),l=null!=r.skysize?r.skysize:1e3,s=null!=r.rotation?r.rotation:0,u=null!=r.basename&&""!==r.basename?n+r.basename:null,c=null!=r.skyfaces?r.skyfaces:null,d=null!=r.extensions&&r.extensions.length>0?r.extensions:null,g=null!=r.polynomial?r.polynomial:1;try{if(null!=c&&""!==c&&null!=u&&""!==u&&null!=e.LastAssetsManager){var m=null;if("png"===c||"jpg"===c||"jpeg"===c)m=e.LastAssetsManager.addCubeTextureTask("Skybox.TextureTask",u,d);else{var p=u+"."+c;m=e.LastAssetsManager.addCubeTextureTask("Skybox.TextureTask",p,null,!1,null,!0)}null!=m&&(m.onSuccess=function(e){if(null!=e.texture){var n=e.texture;"png"!==c&&"jpg"!==c&&"jpeg"!==c||(n.isRGBD=!0),n.name=r.basename,n.gammaSpace=!1,n.coordinatesMode=BABYLON.Texture.SKYBOX_MODE,n.rotationY=BABYLON.Tools.ToRadians(s),BABYLON.SceneManager.GetRightHanded(a)===!0&&(n.rotationY+=Math.PI);var t="Ambient Skybox",d=BABYLON.Mesh.CreateBox(t,l,a);d.id=t,d.infiniteDistance=!0,d.applyFog=i,null!=o&&""!==o&&BABYLON.Tags.AddTagsTo(d,o),a.useRightHandedSystem===!0&&(d.scaling.x*=-1);var g=new BABYLON.StandardMaterial("Skybox-Material",a);g.backFaceCulling=!1,g.disableLighting=!0,g.diffuseColor=new BABYLON.Color3(0,0,0),g.emissiveColor=new BABYLON.Color3(0,0,0),g.specularColor=new BABYLON.Color3(0,0,0),g.ambientColor=new BABYLON.Color3(0,0,0),g.reflectionTexture=n,d.material=g}else console.error("Failed to load skybox texture task: "+u)},m.onError=function(e,n,a){console.error(n,a)})}}catch(f){console.warn(f)}if(null!=r.environment){var h=r.environment;a.environmentIntensity=null!=h.level?BABYLON.Scalar.Clamp(h.level,0,10):1;var S=null!=h.info&&""!==h.info?h.info:null;if(null!=S&&""!==S)try{var M=BABYLON.SceneManager.GetRootUrl(a),y=M+S.rooturl,v=y+S.name;if(null!=e.LastAssetsManager){var b=e.LastAssetsManager.addCubeTextureTask("Skybox.EnvironmentTextureTask",v,null,!1,null,!0);b.onSuccess=function(e){null!=e.texture?(a.environmentTexture=e.texture,a.environmentTexture.name="assets/"+S.name,null!=a.environmentTexture&&null!=a.environmentTexture.sphericalPolynomial&&(a.isReady()?a.environmentTexture.sphericalPolynomial.scaleInPlace(g):a.onReadyObservable.addOnce(function(){a.environmentTexture.sphericalPolynomial.scaleInPlace(g)}))):console.error("Failed to load environment texture task: "+y)},b.onError=function(e,n,a){console.error(n,a)}}}catch(T){console.warn(T)}}}if(null!=t.navigation&&null!=t.navigation.prebaked&&""!==t.navigation.prebaked){var _=null!=t.navigation.collision&&t.navigation.collision===!0,x=null!=t.navigation.showdebug&&t.navigation.showdebug===!0,A=null!=t.navigation.debugcolor?t.navigation.debugcolor:[.05,.225,.75],C=new BABYLON.Color3(A[0],A[1],A[2]),O=null!=t.navigation.timesteps?t.navigation.timesteps:0;if(null!=e.LastAssetsManager){var P=t.navigation.prebaked,w=e.LastAssetsManager.addBinaryFileTask("System.NavigationMeshTask",P);w.onSuccess=function(e){if(null!=e.data){var n=new Uint8Array(e.data);BABYLON.SceneManager.LoadNavigationMesh(a,n,x,C,O,_)}else console.error("Failed to load navigation mesh task: "+P)},w.onError=function(e,n,a){console.error(n,a)}}}}},e.prototype._preloadRawMaterialsAsync=function(e,n,a){var t=this._loader,r=new Array,i=BABYLON.Material.TriangleFillMode;return a.forEach(function(a){var o=BABYLON.GLTF2.ArrayItem.Get(e+"/material",n,a);if(null!=o){var l=t.createMaterial(e,o,i);BABYLON.GLTF2.GLTFLoader.AddPointerMetadata(l,e),t._parent.onMaterialLoadedObservable.notifyObservers(l),r.push(t.loadMaterialPropertiesAsync(e,o,l))}}),Promise.all(r).then(function(){})},e.prototype._parseMultiMaterialAsync=function(e,n,a,t,r){var i=this;void 0===r&&(r=function(){});var o=this._loader,l=n;l._data=l._data||{};var s=l._data[t];if(!s){o.logOpen(e+" "+(a.name||""));var u=[],c=new Array;n.forEach(function(n){var a=null;if(n.index){var r=n.index;r>=0&&(a=i._getCachedMaterialByIndex(r))}null==a&&(a=o.createMaterial(e,n,t),BABYLON.GLTF2.GLTFLoader.AddPointerMetadata(a,e),o._parent.onMaterialLoadedObservable.notifyObservers(a),c.push(o.loadMaterialPropertiesAsync(e,n,a))),u.push(a)}),s={babylonMaterials:u,babylonMeshes:[],promises:c},l._data[t]=s,o.logClose()}return s.babylonMeshes.push(a),a.onDisposeObservable.addOnce(function(){var e=s.babylonMeshes.indexOf(a);e!==-1&&s.babylonMeshes.splice(e,1)}),r(s.babylonMaterials),Promise.all(s.promises).then(function(){return s.babylonMaterials})},e.prototype._parseShaderMaterialPropertiesAsync=function(e,n,a){var t=null!=n.extras&&null!=n.extras.metadata?n.extras.metadata:null,r=a,i=new Array;r.backFaceCulling=null==t||null==t.backFaceCulling||t.backFaceCulling,n.doubleSided&&(r.backFaceCulling=!1),BABYLON.Utilities.HasOwnProperty(r,"ambientColor")&&(r.ambientColor=null!=t&&t.ambientColorFactor?BABYLON.Color3.FromArray(t.ambientColorFactor):BABYLON.Color3.Black());var o=1;if(n.pbrMetallicRoughness){var l=n.pbrMetallicRoughness;if(l){if(l.baseColorFactor){var s=BABYLON.Color4.FromArray(l.baseColorFactor);r.setVector4("diffuseColor",new BABYLON.Vector4(Math.pow(s.r,1/2.2),Math.pow(s.g,1/2.2),Math.pow(s.b,1/2.2),s.a)),o=s.a}else r.setVector4("diffuseColor",new BABYLON.Vector4(1,1,1,1));l.baseColorTexture&&i.push(this._loader.loadTextureInfoAsync(e+"/baseColorTexture",l.baseColorTexture,function(e){e.name=a.name+" (Base Color)";var n=e;n.level=null!=t&&null!=t.diffuseIntensity?t.diffuseIntensity:1,r.setTexture("diffuseTexture",n)}))}}if(n.normalTexture&&i.push(this._loader.loadTextureInfoAsync(e+"/normalTexture",n.normalTexture,function(e){e.name=a.name+" (Normal)";var t=e;void 0!=n.normalTexture.scale&&(t.level=n.normalTexture.scale),r.setTexture("bumpTexture",t)})),n.occlusionTexture&&i.push(this._loader.loadTextureInfoAsync(e+"/occlusionTexture",n.occlusionTexture,function(e){e.name=a.name+" (Occlusion)";var t=e;void 0!=n.occlusionTexture.strength&&(t.level=n.occlusionTexture.strength),r.setTexture("ambientTexture",t)})),n.emissiveFactor){var u=BABYLON.Color4.FromArray(n.emissiveFactor);(u.r>0||u.g>0||u.b>0)&&r.setVector4("emissiveColor",new BABYLON.Vector4(Math.pow(u.r,1/2.2),Math.pow(u.g,1/2.2),Math.pow(u.b,1/2.2),u.a))}n.emissiveTexture&&i.push(this._loader.loadTextureInfoAsync(e+"/emissiveTexture",n.emissiveTexture,function(e){e.name=a.name+" (Emissive)";var n=e;r.setTexture("emissiveTexture",n)})),r.alpha=o;var c=n.alphaMode||"OPAQUE";switch(c){case"OPAQUE":r.alpha=1,r.transparencyMode=BABYLON.ShaderMaterial.MATERIAL_OPAQUE;break;case"MASK":r.transparencyMode=BABYLON.ShaderMaterial.MATERIAL_ALPHATEST;break;case"BLEND":r.transparencyMode=BABYLON.ShaderMaterial.MATERIAL_ALPHABLEND;break;default:throw new Error(e+"/AlphaMode: Invalid value ("+n.alphaMode+")")}if(null!=t){if(r.wireframe=null!=t.useWireframe&&t.useWireframe,r.needDepthPrePass=null!=t.depthPrepass&&t.depthPrepass,t.customTextures){var d=function(n){var o=t.customTextures[n];null!=o&&i.push(g._loader.loadTextureInfoAsync(e+"/"+n,o,function(e){e.name=a.name+" (Custom)",r.setTexture(n,e)}))},g=this;for(var m in t.customTextures)d(m)}if(t.customVectors)for(var p in t.customVectors){var f=t.customVectors[p];null!=f&&r.setVector4(p,BABYLON.Vector4.FromArray(f))}if(t.customColors)for(var h in t.customColors){var S=t.customColors[h];null!=S&&r.setVector4(h,BABYLON.Vector4.FromArray(S))}if(t.customFloats)for(var M in t.customFloats){var y=t.customFloats[M];null!=y&&r.setFloat(M,y)}null!=t.freezeMaterial&&t.freezeMaterial===!0&&null!=this._shaderList&&this._shaderList.push(r)}return Promise.all(i).then(function(){})},e.prototype._parseDiffuseMaterialPropertiesAsync=function(e,n,a){var t=null!=n.extras&&null!=n.extras.metadata?n.extras.metadata:null,r=a,i=new Array;BABYLON.Utilities.HasOwnProperty(r,"ambientColor")&&(r.ambientColor=null!=t&&t.ambientColorFactor?BABYLON.Color3.FromArray(t.ambientColorFactor):BABYLON.Color3.Black()),BABYLON.Utilities.HasOwnProperty(r,"backFaceCulling")&&(r.backFaceCulling=null==t||null==t.backFaceCulling||t.backFaceCulling),n.doubleSided&&(BABYLON.Utilities.HasOwnProperty(r,"twoSidedLighting")&&(r.twoSidedLighting=!0),BABYLON.Utilities.HasOwnProperty(r,"backFaceCulling")&&(r.backFaceCulling=!1));var o=1;if(n.pbrMetallicRoughness){var l=n.pbrMetallicRoughness;if(l){if(BABYLON.Utilities.HasOwnProperty(r,"diffuseColor"))if(l.baseColorFactor){var s=BABYLON.Color4.FromArray(l.baseColorFactor);r.diffuseColor=new BABYLON.Color3(Math.pow(s.r,1/2.2),Math.pow(s.g,1/2.2),Math.pow(s.b,1/2.2)),o=s.a}else r.diffuseColor=BABYLON.Color3.White();BABYLON.Utilities.HasOwnProperty(r,"diffuseTexture")&&l.baseColorTexture&&i.push(this._loader.loadTextureInfoAsync(e+"/baseColorTexture",l.baseColorTexture,function(e){e.name=a.name+" (Base Color)",r.diffuseTexture=e,r.diffuseTexture.level=null!=t&&null!=t.diffuseIntensity?t.diffuseIntensity:1}))}}if(BABYLON.Utilities.HasOwnProperty(r,"bumpTexture")&&n.normalTexture&&(i.push(this._loader.loadTextureInfoAsync(e+"/normalTexture",n.normalTexture,function(e){e.name=a.name+" (Normal)",r.bumpTexture=e,void 0!=n.normalTexture.scale&&(r.bumpTexture.level=n.normalTexture.scale);
  })),BABYLON.Utilities.HasOwnProperty(r,"invertNormalMapX")&&(r.invertNormalMapX=!this._loader.babylonScene.useRightHandedSystem),BABYLON.Utilities.HasOwnProperty(r,"invertNormalMapY")&&(r.invertNormalMapY=this._loader.babylonScene.useRightHandedSystem)),BABYLON.Utilities.HasOwnProperty(r,"ambientTexture")&&n.occlusionTexture&&i.push(this._loader.loadTextureInfoAsync(e+"/occlusionTexture",n.occlusionTexture,function(e){e.name=a.name+" (Occlusion)",r.ambientTexture=e,void 0!=n.occlusionTexture.strength&&(r.ambientTexture.level=n.occlusionTexture.strength)})),BABYLON.Utilities.HasOwnProperty(r,"emissiveColor")){var u=n.emissiveFactor?BABYLON.Color4.FromArray(n.emissiveFactor):new BABYLON.Color4(0,0,0,1);r.emissiveColor=new BABYLON.Color3(Math.pow(u.r,1/2.2),Math.pow(u.g,1/2.2),Math.pow(u.b,1/2.2))}BABYLON.Utilities.HasOwnProperty(r,"emissiveTexture")&&n.emissiveTexture&&i.push(this._loader.loadTextureInfoAsync(e+"/emissiveTexture",n.emissiveTexture,function(e){e.name=a.name+" (Emissive)",r.emissiveTexture=e,BABYLON.Utilities.HasOwnProperty(r,"useEmissiveAsIllumination")&&(r.useEmissiveAsIllumination=null!=t&&null!=t.useEmissiveAsIllumination&&t.useEmissiveAsIllumination)})),BABYLON.Utilities.HasOwnProperty(r,"alpha")&&(r.alpha=o);var c=n.alphaMode||"OPAQUE";switch(c){case"OPAQUE":BABYLON.Utilities.HasOwnProperty(r,"alpha")&&(r.alpha=1);break;case"MASK":r.alphaCutOff=void 0==n.alphaCutoff?.5:n.alphaCutoff,r.diffuseTexture&&BABYLON.Utilities.HasOwnProperty(r,"diffuseTexture")&&(r.diffuseTexture.hasAlpha=!0);break;case"BLEND":r.diffuseTexture&&(BABYLON.Utilities.HasOwnProperty(r,"diffuseTexture")&&(r.diffuseTexture.hasAlpha=!0),BABYLON.Utilities.HasOwnProperty(r,"useAlphaFromDiffuseTexture")&&(r.useAlphaFromDiffuseTexture=!0));break;default:throw new Error(e+"/AlphaMode: Invalid value ("+n.alphaMode+")")}return this._parseCommonConstantProperties(i,e,n,a),Promise.all(i).then(function(){})},e.prototype._parseCommonConstantProperties=function(e,n,a,t){var r=this,i=null!=a.extras&&null!=a.extras.metadata?a.extras.metadata:null;if(null!=i){var o=t;if(BABYLON.Utilities.HasOwnProperty(o,"alphaMode")&&(o.alphaMode=null!=i&&i.alphaMode?i.alphaMode:BABYLON.Engine.ALPHA_COMBINE),BABYLON.Utilities.HasOwnProperty(o,"ambientColor")&&(o.ambientColor=null!=i&&i.ambientColorFactor?BABYLON.Color3.FromArray(i.ambientColorFactor):BABYLON.Color3.Black()),BABYLON.Utilities.HasOwnProperty(o,"backFaceCulling")&&(o.backFaceCulling=null==i||null==i.backFaceCulling||i.backFaceCulling),t instanceof BABYLON.PBRMaterial&&(t.useMetallnessFromMetallicTextureBlue=!0,t.useRoughnessFromMetallicTextureGreen=!0,t.useRoughnessFromMetallicTextureAlpha=!1,t.useAmbientOcclusionFromMetallicTextureRed=!1,t.directIntensity=null!=i.directIntensity?i.directIntensity:1,t.specularIntensity=null!=i.specularIntensity?i.specularIntensity:1,t.emissiveIntensity=null!=i.emissiveIntensity?i.emissiveIntensity:1,t.environmentIntensity=null!=i.environmentIntensity?i.environmentIntensity:1,t.indexOfRefraction=null!=i.indexOfRefraction?i.indexOfRefraction:1.5,null!=i.useAlphaFromAlbedoTexture&&(t.useAlphaFromAlbedoTexture=i.useAlphaFromAlbedoTexture),null!=i.parallaxBias&&i.parallaxBias>0&&(t.useParallax=!0,t.parallaxScaleBias=.9*i.parallaxBias,t.useParallaxOcclusion=null==i.parallaxOcclusion||i.parallaxOcclusion,t.useParallaxOcclusion===!0&&(t.parallaxScaleBias*=.5))),BABYLON.Utilities.HasOwnProperty(o,"unlit")&&(o.unlit=null!=i.unlitMaterial&&i.unlitMaterial),BABYLON.Utilities.HasOwnProperty(o,"wireframe")&&(o.wireframe=null!=i.useWireframe&&i.useWireframe),BABYLON.Utilities.HasOwnProperty(o,"disableLighting")&&(o.disableLighting=null!=i.disableLighting&&i.disableLighting),BABYLON.Utilities.HasOwnProperty(o,"maxSimultaneousLights")&&(o.maxSimultaneousLights=null!=i.maxSimultaneousLights?i.maxSimultaneousLights:4),BABYLON.Utilities.HasOwnProperty(o,"needDepthPrePass")&&(o.needDepthPrePass=null!=i.depthPrepass&&i.depthPrepass),BABYLON.Utilities.HasOwnProperty(o,"lightmapTexture")&&i.lightmapTexture){var l=null,s=null!=i.lightmapTexture.index?i.lightmapTexture.index:-1;s>=0&&(l=this._getCachedLightmapByIndex(s)),null!=l?(o.lightmapTexture=l,o.useLightmapAsShadowmap=!0,BABYLON.Utilities.HasOwnProperty(o,"ambientColor")&&(o.ambientColor=BABYLON.Color3.White())):e.push(this._loader.loadTextureInfoAsync(n+"/lightmapTexture",i.lightmapTexture,function(e){e.name="assets/LightmapTexture-"+s,e.level=i.lightmapLevel?i.lightmapLevel:1,e.gammaSpace=!1;var n=e;n.onLoadObservable.addOnce(function(){n.isReady()?n.isRGBD=!0:BABYLON.Tools.Warn("Failed to register texture as RGBD: "+n.name)}),o.lightmapTexture=e,s>=0&&null!=r._lightmapMap&&(r._lightmapMap.has(s)||r._lightmapMap.set(s,n)),o.useLightmapAsShadowmap=!0,BABYLON.Utilities.HasOwnProperty(o,"ambientColor")&&(o.ambientColor=BABYLON.Color3.White())}))}t instanceof BABYLON.PBRMaterial&&i.detailMapTexture&&e.push(this._loader.loadTextureInfoAsync(n+"/detailMapTexture",i.detailMapTexture,function(e){e.name=t.name+" (Detail Map)",e.level=1,t.detailMap.texture=e,t.detailMap.bumpLevel=i.detailBumpLevel?i.detailBumpLevel:1,t.detailMap.diffuseBlendLevel=i.detailBlendLevel?i.detailBlendLevel:.75,t.detailMap.roughnessBlendLevel=i.detailRoughLevel?i.detailRoughLevel:.5,t.detailMap.isEnabled=!0}));var u=BABYLON.SceneManager.GetRenderQuality(),c=u===BABYLON.RenderQuality.High||u===BABYLON.RenderQuality.Medium;if(c===!0&&BABYLON.Utilities.HasOwnProperty(o,"reflectionColor")&&(o.reflectionColor=null!=i&&i.reflectionColorFactor?BABYLON.Color3.FromArray(i.reflectionColorFactor):BABYLON.Color3.White()),c===!0&&BABYLON.Utilities.HasOwnProperty(o,"reflectionTexture")&&i.reflectionCubemapInfo){var d=this._loader._rootUrl,g=(d+i.reflectionCubemapInfo.rooturl+i.reflectionCubemapInfo.name).toLowerCase(),m=g.lastIndexOf("."),p=m>-1?g.substring(m).toLowerCase():"",f=!0,h=new CubeTextureLoader;h.name="assets/"+i.reflectionCubemapInfo.name,h.mapkey=g,h.material=o,h.extension=p,h.prefiltered=f,i.reflectionCubemapInfo.boundingBoxSize&&(h.boundingBoxSize=BABYLON.Vector3.FromArray(i.reflectionCubemapInfo.boundingBoxSize),h.name+=" ("+h.boundingBoxSize.x.toString()+" "+h.boundingBoxSize.y.toString()+" "+h.boundingBoxSize.z.toString()+")",h.mapkey+="_"+h.boundingBoxSize.x.toString()+"_"+h.boundingBoxSize.y.toString()+"_"+h.boundingBoxSize.z.toString()),i.reflectionCubemapInfo.boundingBoxPosition&&(h.boundingBoxPosition=BABYLON.Vector3.FromArray(i.reflectionCubemapInfo.boundingBoxPosition),h.name+=" ("+h.boundingBoxPosition.x.toString()+" "+h.boundingBoxPosition.y.toString()+" "+h.boundingBoxPosition.z.toString()+")",h.mapkey+="_"+h.boundingBoxPosition.x.toString()+"_"+h.boundingBoxPosition.y.toString()+"_"+h.boundingBoxPosition.z.toString());var S=this._reflectionMap[g];null==S?(S=[h],this._reflectionMap[g]=S):S.push(h)}if(BABYLON.Utilities.HasOwnProperty(o,"terrainInfo")&&(o.terrainInfo=null!=i.terrainInfo?i.terrainInfo:null),BABYLON.Utilities.HasOwnProperty(t,"universalMaterial")){var M=t;if(i.customTextures){var y=function(a){var r=i.customTextures[a];null!=r&&(M.checkSampler(a),e.push(v._loader.loadTextureInfoAsync(n+"/"+a,r,function(e){e.name=t.name+" (Custom)",M.setTexture(a,e,!0)})))},v=this;for(var b in i.customTextures)y(b)}if(i.customVectors)for(var T in i.customVectors){var _=i.customVectors[T];null!=_&&M.setVector4(T,BABYLON.Vector4.FromArray(_),!0)}if(i.customColors)for(var x in i.customColors){var A=i.customColors[x];null!=A&&M.setVector4(x,BABYLON.Vector4.FromArray(A),!0)}if(i.customFloats)for(var C in i.customFloats){var O=i.customFloats[C];null!=O&&M.setFloat(C,O,!0)}}else{if(i.customTextures){var P=function(a){var r=i.customTextures[a];null!=r&&BABYLON.Utilities.HasOwnProperty(o,a)&&e.push(w._loader.loadTextureInfoAsync(n+"/"+a,r,function(e){e.name=t.name+" (Custom)",o[a]=e}))},w=this;for(var b in i.customTextures)P(b)}if(i.customVectors)for(var T in i.customVectors){var _=i.customVectors[T];null!=_&&BABYLON.Utilities.HasOwnProperty(o,T)&&(o[T]=BABYLON.Vector4.FromArray(_))}if(i.customColors)for(var x in i.customColors){var A=i.customColors[x];null!=A&&BABYLON.Utilities.HasOwnProperty(o,x)&&(o[x]instanceof BABYLON.Vector4?o[x]=BABYLON.Vector4.FromArray(A):o[x]instanceof BABYLON.Color4?o[x]=BABYLON.Color4.FromArray(A):o[x]=BABYLON.Color3.FromArray(A))}if(i.customFloats)for(var C in i.customFloats){var O=i.customFloats[C];null!=O&&BABYLON.Utilities.HasOwnProperty(o,C)&&(o[C]instanceof Boolean?o[C]=O>0:o[C]=O)}}null!=i.freezeMaterial&&i.freezeMaterial===!0&&null!=this._shaderList&&this._shaderList.push(t)}},e.LastRootUrl=null,e.LastParseScene=!1,e.LastBabylonScene=null,e.LastAssetsManager=null,e}(),CVTOOLS_babylon_mesh=function(){function e(e){this.name=CVTOOLS_MESH,this.enabled=!1,this._loader=e,this.enabled=this._loader.isExtensionUsed(CVTOOLS_MESH),this.order=101}return e.prototype.dispose=function(){delete this._loader},e}(),CVTOOLS_left_handed=function(){function e(e){this.name=CVTOOLS_HAND,this.enabled=!1,this._loader=e,this.enabled=this._loader.isExtensionUsed(CVTOOLS_HAND),this.order=102}return e.prototype.dispose=function(){delete this._loader},e}();BABYLON.GLTF2.GLTFLoader.RegisterExtension(CVTOOLS_NAME,function(e){return new CVTOOLS_unity_metadata(e)}),BABYLON.GLTF2.GLTFLoader.RegisterExtension(CVTOOLS_MESH,function(e){return new CVTOOLS_babylon_mesh(e)}),BABYLON.GLTF2.GLTFLoader.RegisterExtension(CVTOOLS_HAND,function(e){return new CVTOOLS_left_handed(e)}),BABYLON.SceneManager.IsWindows()&&"undefined"!=typeof Windows.UI.ViewManagement&&"undefined"!=typeof Windows.UI.ViewManagement.ApplicationViewBoundsMode&&"undefined"!=typeof Windows.UI.ViewManagement.ApplicationViewBoundsMode.useCoreWindow&&Windows.UI.ViewManagement.ApplicationView.getForCurrentView().setDesiredBoundsMode(Windows.UI.ViewManagement.ApplicationViewBoundsMode.useCoreWindow),BABYLON.SceneManager.IsXboxConsole()&&navigator.gamepadInputEmulation&&(navigator.gamepadInputEmulation="gamepad");var TimerPlugin=window;TimerPlugin.requestAnimFrame=function(){return TimerPlugin.requestAnimationFrame||TimerPlugin.webkitRequestAnimationFrame||TimerPlugin.mozRequestAnimationFrame||TimerPlugin.oRequestAnimationFrame||TimerPlugin.msRequestAnimationFrame||function(e,n){window.setTimeout(e,1e3/60)}}(),TimerPlugin.requestInterval=function(e,n){function a(){var i=TimerPlugin.getTimeMilliseconds(),o=i-t;o>=n&&(e.call(),t=TimerPlugin.getTimeMilliseconds()),r.value=TimerPlugin.requestAnimFrame(a)}if(!(TimerPlugin.requestAnimationFrame||TimerPlugin.webkitRequestAnimationFrame||TimerPlugin.mozRequestAnimationFrame&&TimerPlugin.mozCancelRequestAnimationFrame||TimerPlugin.oRequestAnimationFrame||TimerPlugin.msRequestAnimationFrame))return window.setInterval(e,n);var t=TimerPlugin.getTimeMilliseconds(),r=new Object;return r.value=TimerPlugin.requestAnimFrame(a),r},TimerPlugin.clearRequestInterval=function(e){TimerPlugin.cancelAnimationFrame?TimerPlugin.cancelAnimationFrame(e.value):TimerPlugin.webkitCancelAnimationFrame?TimerPlugin.webkitCancelAnimationFrame(e.value):TimerPlugin.webkitCancelRequestAnimationFrame?TimerPlugin.webkitCancelRequestAnimationFrame(e.value):TimerPlugin.mozCancelRequestAnimationFrame?TimerPlugin.mozCancelRequestAnimationFrame(e.value):TimerPlugin.oCancelRequestAnimationFrame?TimerPlugin.oCancelRequestAnimationFrame(e.value):TimerPlugin.msCancelRequestAnimationFrame?TimerPlugin.msCancelRequestAnimationFrame(e.value):window.clearInterval(e),e=null},TimerPlugin.requestTimeout=function(e,n){function a(){var i=TimerPlugin.getTimeMilliseconds(),o=i-t;o>=n?e.call():r.value=TimerPlugin.requestAnimFrame(a)}if(!(TimerPlugin.requestAnimationFrame||TimerPlugin.webkitRequestAnimationFrame||TimerPlugin.mozRequestAnimationFrame&&TimerPlugin.mozCancelRequestAnimationFrame||TimerPlugin.oRequestAnimationFrame||TimerPlugin.msRequestAnimationFrame))return window.setTimeout(e,n);var t=TimerPlugin.getTimeMilliseconds(),r=new Object;return r.value=TimerPlugin.requestAnimFrame(a),r},TimerPlugin.clearRequestTimeout=function(e){TimerPlugin.cancelAnimationFrame?TimerPlugin.cancelAnimationFrame(e.value):TimerPlugin.webkitCancelAnimationFrame?TimerPlugin.webkitCancelAnimationFrame(e.value):TimerPlugin.webkitCancelRequestAnimationFrame?TimerPlugin.webkitCancelRequestAnimationFrame(e.value):TimerPlugin.mozCancelRequestAnimationFrame?TimerPlugin.mozCancelRequestAnimationFrame(e.value):TimerPlugin.oCancelRequestAnimationFrame?TimerPlugin.oCancelRequestAnimationFrame(e.value):TimerPlugin.msCancelRequestAnimationFrame?TimerPlugin.msCancelRequestAnimationFrame(e.value):window.clearTimeout(e),e=null},TimerPlugin.getTimeMilliseconds=function(){return null!=BABYLON.PrecisionDate&&null!=BABYLON.PrecisionDate.Now?BABYLON.PrecisionDate.Now:(performance||Date).now()},TimerPlugin.gameTimeMilliseconds=TimerPlugin.getTimeMilliseconds();