1234567891011 |
- var BABYLON;!function(e){var t=function(){function t(){}return Object.defineProperty(t,"Version",{get:function(){return"5.0.0 - A61"},enumerable:!1,configurable:!0}),Object.defineProperty(t,"Copyright",{get:function(){return"All rights reserved (c) 2020 Mackey Kinard"},enumerable:!1,configurable:!0}),t.RegisterOnShowSceneLoader=function(t){e.SceneManager.SetWindowState("showSceneLoader",t)},t.RegisterOnUpdateSceneLoader=function(t){e.SceneManager.SetWindowState("updateSceneLoader",t)},t.RegisterOnTickSceneLoader=function(t){e.SceneManager.SetWindowState("tickSceneLoader",t)},t.LoadSceneFile=function(e,t){if(void 0===t&&(t=null),window.toolkit)if(window.top.loadScene)window.top.loadScene(e,t);else{var n=window.location.protocol+"//"+window.location.hostname+":"+window.location.port+window.location.pathname+"?scene="+e;null!=t&&""!==t&&(n+=t),window.location.replace(n)}},t.ShowParentLoader=function(e){window.toolkit&&window.top.showGameLoading&&window.top.showGameLoading(e)},t.GetRenderQuality=function(){var t=e.RenderQuality.High,n=e.SceneManager.GetLocalStorageItem("renderQuality");return null!=n&&""!==n&&(t=parseInt(n)),t},t.SetRenderQuality=function(t){var n=t;e.SceneManager.SetLocalStorageItem("renderQuality",n.toString())},t.GetLocalStorageItem=function(e){var t;return null===(t=window.top.localStorage)||void 0===t?void 0:t.getItem(e)},t.SetLocalStorageItem=function(e,t){var n;null===(n=window.top.localStorage)||void 0===n?void 0:n.setItem(e,t)},t.GetSessionStorageItem=function(e){var t;return null===(t=window.top.sessionStorage)||void 0===t?void 0:t.getItem(e)},t.SetSessionStorageItem=function(e,t){var n;null===(n=window.top.sessionStorage)||void 0===n?void 0:n.setItem(e,t)},t.SetWindowState=function(e,t){null==window.top.state&&(window.top.state={}),window.top.state[e]=t},t.GetWindowState=function(e){var t=null;return null!=window.top.state&&null!=window.top.state[e]&&(t=window.top.state[e]),null!=t?t:null},t.PostWindowMessage=function(e,t,n){window.top.postMessage(e,t,n)},t.EnableSceneParsing=function(t){e.SceneManager.SceneParsingEnabled=t},t.IsSceneParsingEnabled=function(){return e.SceneManager.SceneParsingEnabled},t.GetFullscreenUI=function(t){if(null==e.SceneManager.AdvDynamicTexture){var n="Default-Screen-UI",a=!0,i=e.Texture.BILINEAR_SAMPLINGMODE;e.SceneManager.AdvDynamicTexture=e.GUI.AdvancedDynamicTexture.CreateFullscreenUI(n,a,t,i)}return e.SceneManager.AdvDynamicTexture},t.GetAmbientSkybox=function(e){return e.getMeshByID("Ambient Skybox")},t.GetIntensityFactor=function(){return null!=window.intensityFactor?window.intensityFactor:2},t.IsDebugMode=function(){return null!=window.debugModeEnabled&&window.debugModeEnabled===!0},t.ConsoleLog=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];e.SceneManager.IsDebugMode()&&console.log.apply(console,t)},t.ConsoleInfo=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];e.SceneManager.IsDebugMode()&&console.info.apply(console,t)},t.ConsoleWarn=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];e.SceneManager.IsDebugMode()&&console.warn.apply(console,t)},t.ConsoleError=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.error.apply(console,e)},t.LogMessage=function(t){e.SceneManager.IsDebugMode()&&e.Tools.Log(t)},t.LogWarning=function(t){e.SceneManager.IsDebugMode()&&e.Tools.Warn(t)},t.LogError=function(t){e.Tools.Error(t)},t.IsWindows=function(){return"undefined"!=typeof Windows&&"undefined"!=typeof Windows.UI&&"undefined"!=typeof Windows.System&&"undefined"!=typeof Windows.Foundation},t.IsCordova=function(){return null!=window.cordova},t.IsWebAssembly=function(){return window.WebAssembly},t.IsOculusBrowser=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/OculusBrowser/i)&&(e=!0),e},t.IsSamsungBrowser=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/SamsungBrowser/i)&&(e=!0),e},t.IsWindowsPhone=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/Windows Phone/i)&&(e=!0),e},t.IsBlackBerry=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/BlackBerry/i)&&(e=!0),e},t.IsOperaMini=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/Opera Mini/i)&&(e=!0),e},t.IsAndroid=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/Android/i)&&(e=!0),e},t.IsWebOS=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/webOS/i)&&(e=!0),e},t.IsIOS=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/iPhone|iPad|iPod/i)&&(e=!0),e},t.IsIPHONE=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/iPhone/i)&&(e=!0),e},t.IsIPAD=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/iPad/i)&&(e=!0),e},t.IsIPOD=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/iPod/i)&&(e=!0),e},t.IsIE11=function(){return void 0!==navigator.msMaxTouchPoints},t.IsMobile=function(){var e=!1;if(null!=navigator&&null!=navigator.userAgent){var t=navigator.userAgent;(t.match(/Android/i)||t.match(/webOS/i)||t.match(/iPhone|iPad|iPod/i)||t.match(/BlackBerry/i)||t.match(/Opera Mini/i)||t.match(/Windows Phone/i))&&(e=!0)}return e},t.IsPlaystation=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/Playstation/i)&&(e=!0),e},t.IsXboxConsole=function(){var t=!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 n=Windows.System.Profile.AnalyticsInfo.versionInfo.deviceFamily;n.match(/Xbox/i)&&(t=!0)}return t},t.IsXboxLive=function(){return e.SceneManager.IsWindows()&&"undefined"!=typeof Microsoft&&"undefined"!=typeof Microsoft.Xbox&&"undefined"!=typeof Microsoft.Xbox.Services},t.GetTime=function(){return.001*TimerPlugin.getTimeMilliseconds()},t.GetGameTime=function(){return.001*(TimerPlugin.getTimeMilliseconds()-TimerPlugin.gameTimeMilliseconds)},t.GetDeltaSeconds=function(e){return.001*e.getEngine().getDeltaTime()},t.GetAnimationRatio=function(e){return.06*e.getEngine().getDeltaTime()},t.SetTimeout=function(t,n){var a=null;return a=TimerPlugin.requestTimeout(function(){null!=a&&e.SceneManager.ClearTimeout(a),null!=n&&n()},t)},t.ClearTimeout=function(e){TimerPlugin.clearRequestTimeout(e)},t.SetInterval=function(e,t){return TimerPlugin.requestInterval(t,e)},t.ClearInterval=function(e){TimerPlugin.clearRequestInterval(e)},t.RunOnce=function(e,t,n){e.executeOnceBeforeRender(t,n)},t.PopupDebug=function(e){e.debugLayer&&(e.debugLayer.hide(),e.debugLayer.show({enablePopup:!0,globalRoot:null}))},t.ToggleDebug=function(t,n,a){if(void 0===n&&(n=!1),void 0===a&&(a=null),t.debugLayer){var i=window;e.SceneManager.debugLayerVisible===!0?(e.SceneManager.debugLayerVisible=!1,i.METER&&i.METER.show&&i.METER.show(),t.debugLayer.hide()):(e.SceneManager.debugLayerVisible=!0,i.METER&&i.METER.hide&&i.METER.hide(),t.debugLayer.show({embedMode:n,globalRoot:a}))}},t.DisposeScene=function(t,n){void 0===n&&(n=new e.Color4(0,0,0,1));var a=t.getEngine();t.dispose(),a.clear(n,!0,!0,!0)},t.SafeDestroy=function(t,n,a){void 0===n&&(n=5),void 0===a&&(a=!1),n>0?(a===!0&&t.setEnabled(!1),e.SceneManager.SetTimeout(n,function(){t.dispose(!1,!1)})):t.dispose(!1,!1)},t.AlertMessage=function(t,n){void 0===n&&(n="Babylon.js");var a=null;return e.SceneManager.IsWindows()?a=new Windows.UI.Popups.MessageDialog(t,n).showAsync():window.alert(t),a},t.GetQueryStringParam=function(e,t){t||(t=window.location.href),e=e.replace(/[\[\]]/g,"\\$&");var n=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)"),a=n.exec(t);return a?a[2]?decodeURIComponent(a[2].replace(/\+/g," ")):"":null},t.GetWebGLVersionString=function(e){var t="WebGL - Unknown";if(null!=e){var n=e.getEngine();if(null!=n){var a=n.getGlInfo();null!=a&&(t=a.version+" - "+a.renderer)}}return t},t.GetWebGLVersionNumber=function(e){var t=0;if(null!=e){var n=e.getEngine();null!=n&&(t=n.webGLVersion)}return t},t.GetRootUrl=function(e){return null!=e._rootUrl&&""!==e._rootUrl?e._rootUrl:"/"},t.SetRootUrl=function(e,t){e._rootUrl=t},t.GetSceneFile=function(e){return null!=e._fileName&&""!==e._fileName?e._fileName:null},t.SetSceneFile=function(e,t){e._fileName=t},t.GetRightHanded=function(e){return null!=e._righty&&e._righty===!0},t.SetRightHanded=function(e,t){e._righty=t},t.SetWindowsLaunchMode=function(t){void 0===t&&(t=1),e.SceneManager.IsWindows()&&"undefined"!=typeof Windows.UI.ViewManagement&&"undefined"!=typeof Windows.UI.ViewManagement.ApplicationView&&(Windows.UI.ViewManagement.ApplicationView.preferredLaunchWindowingMode=t)},t.ShowPageErrorMessage=function(e,t,n){void 0===t&&(t="Error"),void 0===n&&(n=0),window.showErrorMessage&&window.showErrorMessage(e,t,n)},t.QuitWindowsApplication=function(){e.SceneManager.IsWindows()&&window.close()},t.LoadTextFile=function(t,n,a,i){return e.Tools.LoadFile(t,n,a,null,!1,i)},t.LoadTextFileAsync=function(t){return e.Tools.LoadFileAsync(t,!1)},t.PostDataToServer=function(e,t,n,a,i){void 0===n&&(n="application/x-www-form-urlencoded"),void 0===a&&(a=null),void 0===i&&(i=null);var r=new XMLHttpRequest;return r.open("POST",e,!0),r.setRequestHeader("Content-Type",n),r.onreadystatechange=function(){r.readyState===XMLHttpRequest.DONE&&null!=a&&a(r.status)},r.onerror=function(){null!=i&&i("Failed to post data to server.")},r.send(t),r},t.PostDataToServerAsync=function(t,n,a){return void 0===a&&(a="application/x-www-form-urlencoded"),new Promise(function(i,r){e.SceneManager.PostDataToServer(t,n,a,function(e){i(e)},function(e){r(e)})})},t.ShowDefaultLoader=function(e){e===!0?window.showSceneLoader&&window.showSceneLoader():window.hideSceneLoader&&window.hideSceneLoader()},t.UpdateLoaderStatus=function(e,t,n){window.updateStatus&&window.updateStatus(e,t,n)},t.GetEngineInstances=function(){return e.EngineStore.Instances},t.GetLastCreatedEngine=function(){return e.EngineStore.LastCreatedEngine},t.GetLastCreatedScene=function(){return e.EngineStore.LastCreatedScene},t.GetAssetContainer=function(e,t){return null==e||null==t||""===t?null:null!=e.assetContainers?e.assetContainers.get(t.toLowerCase()):null},t.SetAssetContainer=function(e,t,n){null!=e&&null!=t&&""!==t&&null!=n&&(null==e.assetContainers&&(e.assetContainers=new Map),e.assetContainers.set(t.toLowerCase(),n))},t.ClearAssetContainers=function(e){return null==e?null:(null!=e.assetContainers,void(e.assetContainers=new Map))},t.GetMesh=function(e,t){return null==e?null:e.getNodeByName(t)},t.GetMeshByID=function(e,t){return null==e?null:e.getNodeByID(t)},t.GetAbstractMesh=function(e,t){return null==e?null:e.getNodeByName(t)},t.GetAbstractMeshByID=function(e,t){return null==e?null:e.getNodeByID(t)},t.GetTransformNode=function(e,t){return null==e?null:e.getNodeByName(t)},t.GetTransformNodeByID=function(e,t){return null==e?null:e.getNodeByID(t)},t.GetTransformDetailMesh=function(t){var n=null,a=t.name+".Detail",i=t.getChildren(function(t){return t.name===a&&t instanceof e.AbstractMesh},!0);return null!=i&&i.length>0&&(n=i[0]),n},t.GetPrimitiveMeshes=function(e){return e.getChildMeshes(!0,function(e){return e.name.indexOf("_primitive")>=0})},t.GetTransformLayer=function(e){return null!=e.metadata&&null!=e.metadata.unity&&null!=e.metadata.unity.layer?e.metadata.unity.layer:0},t.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"},t.HasTransformTags=function(t,n){return e.Tags.MatchesQuery(t,n)},t.TextureFloatSupported=function(e){var t=!1,n=!1,a=e.getEngine(),i=a.getCaps();return i.textureHalfFloatRender&&i.textureHalfFloatLinearFiltering?t=!0:i.textureFloatRender&&i.textureFloatLinearFiltering&&(n=!0),t||n},t.RegisterClickAction=function(t,n,a){var i=null;return null!=n&&(n.isPickable=!0,null==n.actionManager&&(n.actionManager=new e.ActionManager(t)),i=n.actionManager.registerAction(new e.ExecuteCodeAction({trigger:e.ActionManager.OnPickTrigger},a))),i},t.UnregisterClickAction=function(e,t){var n=!1;return null!=e&&null!=t&&(n=e.actionManager.unregisterAction(t)),n},t.StartTweenAnimation=function(t,n,a,i,r,o,s,l,u,c,h){void 0===s&&(s=1),void 0===l&&(l=30),void 0===u&&(u=e.Animation.ANIMATIONLOOPMODE_CONSTANT),void 0===c&&(c=null),void 0===h&&(h=null);var m=e.Utilities.CreateTweenAnimation(n,i,r,o,l,u);null!=c&&m.setEasingFunction(c);var p=e.Utilities.GetLastKeyFrameValue(m),d=u!=e.Animation.ANIMATIONLOOPMODE_CONSTANT;return t.beginDirectAnimation(a,[m],0,p,d,s,h)},t.GetMaterialWithName=function(e,t){var n=null;if(null!=e.materials&&e.materials.length>0)for(var a=(e.materials.length,0);a<e.materials.length;a++){var i=e.materials[a];if(i.name.startsWith(t)){n=i;break}}return n},t.GetAllMaterialsWithName=function(e,t){var n=null;if(null!=e.materials&&e.materials.length>0)for(var a=(e.materials.length,0);a<e.materials.length;a++){var i=e.materials[a];i.name.startsWith(t)&&(null==n&&(n=[]),n.push(i))}return n},t.InstantiatePrefab=function(t,n,a,i,r){void 0===i&&(i=!1),void 0===r&&(r=!0);var o=e.Utilities.CloneAssetContainerItem(t,n,function(e){return e},i,r);if(null!=o){null!=a&&""!==a&&(o.name=a);var s=[];s.push(o);var l=o.getChildren(null,!1);null!=l&&l.length>0&&l.forEach(function(e){s.push(e)}),s.forEach(function(t){t.id=e.Utilities.CreateGuid()}),e.Utilities.ParseSceneComponents(t.scene,s)}return o},t.CloneTransformNode=function(t,n,a){var i=e.Utilities.GetAssetContainerNode(t,n),r=i.clone(a,null,!0);return null!=r&&r.setEnabled(!0),r},t.CloneAbstractMesh=function(t,n,a){var i=e.Utilities.GetAssetContainerMesh(t,n),r=i.clone(a,null,!0);return null!=r&&r.setEnabled(!0),r},t.CreateInstancedMesh=function(t,n,a){var i=e.Utilities.GetAssetContainerMesh(t,n),r=i.createInstance(a);return null!=r&&r.setEnabled(!0),r},t.RegisterScriptComponent=function(e,t,n){void 0===n&&(n=!0),null!=e&&e.registerComponentInstance&&e.registerComponentInstance(e,t,n)},t.DestroyScriptComponent=function(e){null!=e&&e.destroyComponentInstance&&e.destroyComponentInstance(e)},t.FindScriptComponent=function(e,t){if(null==e)return null;var n=null;if(null!=e.metadata&&e.metadata.unity){var a=e.metadata.unity;if(null!=a.components&&a.components.length>0)for(var i=0;i<a.components.length;i++){var r=a.components[i];if(null!=r.instance&&r.klass===t){n=r.instance;break}}}return null!=n?n:null},t.FindAllScriptComponents=function(e,t){if(null==e)return null;var n=null;if(null!=e.metadata&&e.metadata.unity){var a=e.metadata.unity;if(null!=a.components&&a.components.length>0)for(var i=0;i<a.components.length;i++){var r=a.components[i];null!=r.instance&&r.klass===t&&(null==n&&(n=[]),n.push(r.instance))}}return null!=n?n:null},t.FindSceneMetadata=function(e){return null==e?null:null!=e.metadata&&e.metadata.unity?e.metadata.unity:null},t.FindSceneCameraRig=function(e){return null==e?null:null!=e.cameraRig?e.cameraRig:null},t.FindSceneLightRig=function(e){return null==e?null:null!=e.lightRig?e.lightRig:null},t.FindTransformsWithScript=function(t,n){var a=t.getNodes();return e.Utilities.SearchTransformNodeForScript(n,a)},t.FindAllTransformsWithScript=function(t,n){var a=t.getNodes();return e.Utilities.SearchAllTransformNodesForScript(n,a)},t.FindChildTransformNode=function(t,n,a,i,r){if(void 0===a&&(a=e.SearchType.ExactMatch),void 0===i&&(i=!0),void 0===r&&(r=null),null==t)return null;var o=null!=a?a:e.SearchType.ExactMatch,s=t.getChildren(r,i);return e.Utilities.SearchTransformNodes(n,s,o)},t.FindChildTransformWithTags=function(t,n,a,i){if(void 0===a&&(a=!0),void 0===i&&(i=null),null==t)return null;var r=t.getChildren(i,a);return e.Utilities.SearchTransformNodeForTags(n,r)},t.FindAllChildTransformsWithTags=function(t,n,a,i){if(void 0===a&&(a=!0),void 0===i&&(i=null),null==t)return null;var r=t.getChildren(i,a);return e.Utilities.SearchAllTransformNodesForTags(n,r)},t.FindChildTransformWithScript=function(t,n,a,i){if(void 0===a&&(a=!0),void 0===i&&(i=null),null==t)return null;var r=t.getChildren(i,a);return e.Utilities.SearchTransformNodeForScript(n,r)},t.FindAllChildTransformsWithScript=function(t,n,a,i){if(void 0===a&&(a=!0),void 0===i&&(i=null),null==t)return null;var r=t.getChildren(i,a);return e.Utilities.SearchAllTransformNodesForScript(n,r)},t.SearchForScriptComponentByName=function(t,n){var a=t.getNodes(),i=e.Utilities.SearchTransformNodeForScript(n,a);return e.SceneManager.FindScriptComponent(i,n)},t.SearchForAllScriptComponentsByName=function(t,n){var a=null,i=t.getNodes(),r=e.Utilities.SearchAllTransformNodesForScript(n,i);return null!=r&&r.length>0&&r.forEach(function(t){var i=e.SceneManager.FindScriptComponent(t,n);null!=i&&(null==a&&(a=[]),a.push(i))}),null!=a?a:null},t.MoveWithCollisions=function(e,t){return null==e?null:void(null!=t&&e.moveWithCollisions(t))},t.MoveWithTranslation=function(e,t){return null==e?null:void(null!=t&&e.position.addInPlace(t))},t.TurnWithRotation=function(t,n,a){return void 0===a&&(a=e.Space.LOCAL),null==t?null:void(0!=n&&t.rotate(e.Axis.Y,n,a))},t.GetPhysicsHeapSize=function(){if("undefined"==typeof Ammo)return 0;var e=0;return Ammo&&Ammo.HEAP8&&Ammo.HEAP8.length&&(e=Ammo.HEAP8.length/1048576),e},t.ConfigurePhysicsEngine=function(t,n,a,i,r,o,s){if(void 0===n&&(n=!0),void 0===a&&(a=0),void 0===i&&(i=0),void 0===r&&(r=!0),void 0===o&&(o=0),void 0===s&&(s=null),"undefined"!=typeof Ammo){var l=new e.Vector3(0,(-9.81),0),u=null!=s?s:l;if(Ammo&&e.AmmoJSPlugin){var c=t.isPhysicsEnabled(),h=c===!0?t.getPhysicsEngine():null,m=c===!0&&null!=h?h.getPhysicsPlugin():null,p=c===!0&&null!=h&&"AmmoJSPlugin"===h.getPhysicsPluginName();if(p===!1){var d=null,g=e.SceneManager.GetPhysicsHeapSize();if(i>0){var f=new Ammo.btAxisSweep3(new Ammo.btVector3((-i),(-i),(-i)),new Ammo.btVector3(i,i,i));d=new e.AmmoJSPlugin(n,Ammo,f),e.Tools.Log("Ammo.js plugin (btAxisSweep3 - "+g+" MB)")}else d=new e.AmmoJSPlugin(n),e.Tools.Log("Ammo.js plugin (btDbvtBroadphase - "+g+" MB)");null!=e.SceneManager.OnSetupPhysicsPlugin&&e.SceneManager.OnSetupPhysicsPlugin(t,d),d.onCreateCustomShape=function(n){var a=null,i="Unknown",r=n.object;if(null!=r.name&&(i=r.name),null!=r._colliderType){var o=r._colliderType;a=e.Utilities.CreateImpostorCustomShape(t,n,o,e.Utilities.ShowDebugColliders(),e.Utilities.ColliderVisibility())}else e.Tools.Warn("No custom shape collider type defined for entity: "+i);return a},t.enablePhysics(u,d),a>0&&d.setMaxSteps(a),c=t.isPhysicsEnabled(),h=c===!0?t.getPhysicsEngine():null,m=c===!0&&null!=h?h.getPhysicsPlugin():null,p=c===!0&&null!=h&&"AmmoJSPlugin"===h.getPhysicsPluginName()}else e.Tools.Warn("Ammo.js plugin enabled");if(p===!0&&null!=h&&null!=m&&null!=m.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"),m.world.getBroadphase().getOverlappingPairCache().setInternalGhostPairCallback(new Ammo.btGhostPairCallback),m.world.getDispatchInfo().set_m_allowedCcdPenetration(o),Ammo.addFunction){var y="iiiiiiii",_=Ammo.addFunction(function(e,t,n,a,i,r,o){return!!m.world.adjustInternalEdgeContacts&&(m.world.adjustInternalEdgeContacts(e,i,t,r,o),!0)},y);null!=_?(m.world.setContactAddedCallback(_),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 v=t;v._monitorContactManifolds||(v._monitorContactManifolds=!0,r===!0&&(e.Tools.Log("Ammo.js contact manifolds enabled"),t.registerBeforeRender(function(){var e=m.world.getDispatcher().getNumManifolds();if(e>0)for(var t=0;t<e;t++){var n=m.world.getDispatcher().getManifoldByIndexInternal(t),a=Ammo.castObject(n.getBody0(),Ammo.btCollisionObject),i=Ammo.castObject(n.getBody1(),Ammo.btCollisionObject);null!=a&&null!=a.entity&&null!=a.entity.physicsImpostor&&null!=i&&null!=i.entity&&i.isActive()&&null!=a.entity.physicsImpostor.tmpCollisionObjects&&(a.entity.physicsImpostor.tmpCollisionObjects[i.entity.uniqueId]=i.entity),null!=i&&null!=i.entity&&null!=i.entity.physicsImpostor&&null!=a&&null!=a.entity&&a.isActive()&&null!=i.entity.physicsImpostor.tmpCollisionObjects&&(i.entity.physicsImpostor.tmpCollisionObjects[a.entity.uniqueId]=a.entity)}})))}else e.Tools.Warn("Ammo.js physics plugins are invalid")}else e.Tools.Warn("Ammo.js physics plugin not available")}},t.GetPhysicsEngine=function(e){return"undefined"==typeof Ammo?null:e.getPhysicsEngine()},t.GetPhysicsWorld=function(t){if("undefined"==typeof Ammo)return null;var n=null,a=e.SceneManager.GetPhysicsEngine(t);if(null!=a){var i=a.getPhysicsPlugin();null!=i&&(n=i.world)}return n},t.PhysicsRaycast=function(t,n,a,i,r,o){if(void 0===r&&(r=null),void 0===o&&(o=null),null==t)return null;if("undefined"==typeof Ammo)return null;if(null==e.SceneManager.TempPhysicsWorld&&(e.SceneManager.TempPhysicsWorld=e.SceneManager.GetPhysicsWorld(t)),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 s=Ammo.castObject(e.SceneManager.ClosestRayResultCallback,Ammo.RayResultCallback);if(s.set_m_closestHitFraction(1),s.set_m_collisionObject(null),null!=r?s.set_m_collisionFilterGroup(r):s.set_m_collisionFilterGroup(e.CollisionFilters.DefaultFilter),null!=o?s.set_m_collisionFilterMask(o):s.set_m_collisionFilterMask(e.CollisionFilters.AllFilter),e.SceneManager.TempCastEndPoint.copyFrom(n),a.scaleAndAddToRef(i,e.SceneManager.TempCastEndPoint),e.SceneManager.TempVRayOrigin.setValue(n.x,n.y,n.z),e.SceneManager.TempVRayDest.setValue(e.SceneManager.TempCastEndPoint.x,e.SceneManager.TempCastEndPoint.y,e.SceneManager.TempCastEndPoint.z),e.SceneManager.ClosestRayResultCallback.get_m_rayFromWorld().setValue(n.x,n.y,n.z),e.SceneManager.ClosestRayResultCallback.get_m_rayToWorld().setValue(e.SceneManager.TempCastEndPoint.x,e.SceneManager.TempCastEndPoint.y,e.SceneManager.TempCastEndPoint.z),e.SceneManager.TempRaycastResult.reset(n,e.SceneManager.TempCastEndPoint),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(),u=e.SceneManager.ClosestRayResultCallback.get_m_hitNormalWorld();e.SceneManager.TempRaycastResult.update(!0,l.x(),l.y(),l.z(),u.x(),u.y(),u.z(),s.get_m_collisionObject())}return e.SceneManager.TempRaycastResult},t.PhysicsRaycastToPoint=function(t,n,a,i,r){if(void 0===i&&(i=null),void 0===r&&(r=null),null==t)return null;if("undefined"==typeof Ammo)return null;if(null==e.SceneManager.TempPhysicsWorld&&(e.SceneManager.TempPhysicsWorld=e.SceneManager.GetPhysicsWorld(t)),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!=i?o.set_m_collisionFilterGroup(i):o.set_m_collisionFilterGroup(e.CollisionFilters.DefaultFilter),null!=r?o.set_m_collisionFilterMask(r):o.set_m_collisionFilterMask(e.CollisionFilters.AllFilter),e.SceneManager.TempVRayOrigin.setValue(n.x,n.y,n.z),e.SceneManager.TempVRayDest.setValue(a.x,a.y,a.z),e.SceneManager.ClosestRayResultCallback.get_m_rayFromWorld().setValue(n.x,n.y,n.z),e.SceneManager.ClosestRayResultCallback.get_m_rayToWorld().setValue(a.x,a.y,a.z),e.SceneManager.TempRaycastResult.reset(n,a),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(),l=e.SceneManager.ClosestRayResultCallback.get_m_hitNormalWorld();e.SceneManager.TempRaycastResult.update(!0,s.x(),s.y(),s.z(),l.x(),l.y(),l.z(),o.get_m_collisionObject())}return e.SceneManager.TempRaycastResult},t.PhysicsShapecast=function(t,n,a,i,r,o,s){if(void 0===o&&(o=null),void 0===s&&(s=null),null==t)return null;if("undefined"==typeof Ammo)return null;if(null==e.SceneManager.TempPhysicsWorld&&(e.SceneManager.TempPhysicsWorld=e.SceneManager.GetPhysicsWorld(t)),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 l=Ammo.castObject(e.SceneManager.ClosestConvexResultCallback,Ammo.ConvexResultCallback);l.set_m_closestHitFraction(1),null!=o?l.set_m_collisionFilterGroup(o):l.set_m_collisionFilterGroup(e.CollisionFilters.DefaultFilter),null!=s?l.set_m_collisionFilterMask(s):l.set_m_collisionFilterMask(e.CollisionFilters.AllFilter),null!=e.SceneManager.ClosestConvexResultCallback.set_m_hitCollisionObject&&e.SceneManager.ClosestConvexResultCallback.set_m_hitCollisionObject(null),e.SceneManager.TempCastEndPoint.copyFrom(a),i.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.ClosestConvexResultCallback.get_m_convexFromWorld().setValue(a.x,a.y,a.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(a,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(n,e.SceneManager.TempTransformFrom,e.SceneManager.TempTransformTo,e.SceneManager.ClosestConvexResultCallback,u),e.SceneManager.ClosestConvexResultCallback.hasHit()){var c=e.SceneManager.ClosestConvexResultCallback.get_m_hitPointWorld(),h=e.SceneManager.ClosestConvexResultCallback.get_m_hitNormalWorld();e.SceneManager.TempRaycastResult.update(!0,c.x(),c.y(),c.z(),h.x(),h.y(),h.z(),e.SceneManager.ClosestConvexResultCallback.get_m_hitCollisionObject())}return e.SceneManager.TempRaycastResult},t.PhysicsShapecastToPoint=function(t,n,a,i,r,o){if(void 0===r&&(r=null),void 0===o&&(o=null),null==t)return null;if("undefined"==typeof Ammo)return null;if(null==e.SceneManager.TempPhysicsWorld&&(e.SceneManager.TempPhysicsWorld=e.SceneManager.GetPhysicsWorld(t)),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 s=Ammo.castObject(e.SceneManager.ClosestConvexResultCallback,Ammo.ConvexResultCallback);s.set_m_closestHitFraction(1),null!=r?s.set_m_collisionFilterGroup(r):s.set_m_collisionFilterGroup(e.CollisionFilters.DefaultFilter),null!=o?s.set_m_collisionFilterMask(o):s.set_m_collisionFilterMask(e.CollisionFilters.AllFilter),null!=e.SceneManager.ClosestConvexResultCallback.set_m_hitCollisionObject&&e.SceneManager.ClosestConvexResultCallback.set_m_hitCollisionObject(null),e.SceneManager.TempVRayOrigin.setValue(a.x,a.y,a.z),e.SceneManager.TempVRayDest.setValue(i.x,i.y,i.z),e.SceneManager.ClosestConvexResultCallback.get_m_convexFromWorld().setValue(a.x,a.y,a.z),e.SceneManager.ClosestConvexResultCallback.get_m_convexToWorld().setValue(i.x,i.y,i.z);var l=0;if(e.SceneManager.TempRaycastResult.reset(a,i),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(n,e.SceneManager.TempTransformFrom,e.SceneManager.TempTransformTo,e.SceneManager.ClosestConvexResultCallback,l),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},t.CreatePhysicsImpostor=function(t,n,a,i,r){if(void 0===r&&(r=!0),null!=n&&"undefined"!=typeof Ammo){n.checkCollisions=!1;var o=n.parent;r===!0&&(n.parent=null),n._colliderType=a;var s=a;switch(a){case e.PhysicsImpostor.MeshImpostor:case e.PhysicsImpostor.BoxImpostor:case e.PhysicsImpostor.SphereImpostor:case e.PhysicsImpostor.CapsuleImpostor:case e.PhysicsImpostor.ConvexHullImpostor:s=e.PhysicsImpostor.CustomImpostor}n.physicsImpostor=new e.PhysicsImpostor(n,s,i,t),r===!0&&(n.parent=o)}},t.GetPhysicsImposterType=function(t){if("undefined"==typeof Ammo)return null;var n="Unknown";switch(t){case e.PhysicsImpostor.NoImpostor:n="No";break;case e.PhysicsImpostor.SphereImpostor:n="Sphere";break;case e.PhysicsImpostor.BoxImpostor:n="Box";break;case e.PhysicsImpostor.PlaneImpostor:n="Plane";break;case e.PhysicsImpostor.MeshImpostor:n="Mesh";break;case e.PhysicsImpostor.CapsuleImpostor:n="Capsule";break;case e.PhysicsImpostor.CylinderImpostor:n="Cylinder";break;case e.PhysicsImpostor.ParticleImpostor:n="Particle";break;case e.PhysicsImpostor.HeightmapImpostor:n="Heightmap";break;case e.PhysicsImpostor.ConvexHullImpostor:n="ConvexHull";break;case e.PhysicsImpostor.CustomImpostor:
- n="CustomShape"}return n},t.CreatePhysicsBoxShape=function(t){return"undefined"==typeof Ammo?null:(null==e.SceneManager.TempShapeVector&&(e.SceneManager.TempShapeVector=new Ammo.btVector3(0,0,0)),e.SceneManager.TempShapeVector.setValue(t.x,t.y,t.z),new Ammo.btBoxShape(e.SceneManager.TempShapeVector))},t.CreatePhysicsSphereShape=function(e){return"undefined"==typeof Ammo?null:new Ammo.btSphereShape(e)},t.CreatePhysicsCapsuleShape=function(e,t){return"undefined"==typeof Ammo?null:new Ammo.btCapsuleShape(e,t)},t.CreatePhysicsCompoundShape=function(e){return void 0===e&&(e=!1),"undefined"==typeof Ammo?null:new Ammo.btCompoundShape(e)},t.CreatePhysicsEmptyShape=function(){return"undefined"==typeof Ammo?null:new Ammo.btEmptyShape},t.GetRecastHeapSize=function(){if("undefined"==typeof Recast)return 0;var e=0;return Recast&&Recast.HEAP8&&Recast.HEAP8.length&&(e=Recast.HEAP8.length/1048576),e},t.GetNavigationTools=function(){if("undefined"!=typeof Recast)return null==e.SceneManager.PluginInstance&&(e.SceneManager.PluginInstance=new e.RecastJSPlugin),e.SceneManager.PluginInstance},t.GetCrowdInterface=function(t){var n;return"undefined"==typeof Recast?null:e.SceneManager.HasNavigationData()?(null==e.SceneManager.CrowdInterface&&(e.SceneManager.CrowdInterface=null===(n=e.SceneManager.GetNavigationTools())||void 0===n?void 0:n.createCrowd(e.SceneManager.MAX_AGENT_COUNT,e.SceneManager.MAX_AGENT_RADIUS,t)),e.SceneManager.CrowdInterface):null},t.HasNavigationData=function(){if("undefined"==typeof Recast)return!1;var t=e.SceneManager.GetNavigationTools();return null!=t&&null!=t.navMesh},t.GetNavigationMesh=function(){return"undefined"==typeof Recast?null:e.SceneManager.NavigationMesh},t.BakeNavigationMesh=function(t,n,a,i,r,o){if(void 0===i&&(i=!1),void 0===r&&(r=null),void 0===o&&(o=!1),"undefined"==typeof Recast)return null;e.Tools.Log("Recast.js baking navigation mesh data");var s=e.SceneManager.GetNavigationTools();if(null!=s)if(s.createNavMesh(n,a),null!=s.navMesh){var l="NavigationMesh",u=t.getMaterialByName(l);null==u&&(u=new e.StandardMaterial(l,t),u.diffuseColor=r||new e.Color3(.05,.225,.75),u.alpha=.5),e.SceneManager.NavigationMesh=s.createDebugNavMesh(t),null!=e.SceneManager.NavigationMesh&&(e.SceneManager.NavigationMesh.material=u,e.SceneManager.NavigationMesh.isPickable=!0,e.SceneManager.NavigationMesh.isVisible=!0,e.SceneManager.NavigationMesh.visibility=i===!0?1:0,e.Tags.AddTagsTo(e.SceneManager.NavigationMesh,"Navigation"),e.Utilities.ValidateTransformMetadata(e.SceneManager.NavigationMesh),o===!0&&(e.SceneManager.NavigationMesh.checkCollisions=!0,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(t,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},t.LoadNavigationMesh=function(t,n,a,i,r,o){if(void 0===a&&(a=!1),void 0===i&&(i=null),void 0===r&&(r=0),void 0===o&&(o=!1),"undefined"==typeof Recast)return null;e.Tools.Log("Recast.js loading prebaked navigation mesh");var s=e.SceneManager.GetNavigationTools();if(null!=s)if(s.setTimeStep&&s.setTimeStep(r),s.buildFromNavmeshData(n),null!=s.navMesh){var l="NavigationMesh",u=t.getMaterialByName(l);null==u&&(u=new e.StandardMaterial(l,t),u.diffuseColor=i||new e.Color3(.05,.225,.75),u.alpha=.5),e.SceneManager.NavigationMesh=s.createDebugNavMesh(t),null!=e.SceneManager.NavigationMesh&&(e.SceneManager.NavigationMesh.material=u,e.SceneManager.NavigationMesh.isPickable=!0,e.SceneManager.NavigationMesh.isVisible=!0,e.SceneManager.NavigationMesh.visibility=a===!0?1:0,e.Tags.AddTagsTo(e.SceneManager.NavigationMesh,"Navigation"),e.Utilities.ValidateTransformMetadata(e.SceneManager.NavigationMesh),o===!0&&(e.SceneManager.NavigationMesh.checkCollisions=!0,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(t,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},t.SaveNavigationMesh=function(){if("undefined"==typeof Recast)return null;var t=e.SceneManager.GetNavigationTools();return null!=t&&null!=t.navMesh?t.getNavmeshData():null},t.ComputeNavigationPath=function(t,n,a){if(void 0===a&&(a=!0),"undefined"==typeof Recast)return null;var i=e.SceneManager.GetNavigationTools(),r=a===!0?i.getClosestPoint(t):t,o=a===!0?i.getClosestPoint(n):n;return null!=i&&null!=i.navMesh?i.computePath(r,o):null},t.MoveAlongNavigationPath=function(t,n,a,i,r,o){void 0===r&&(r=null);var s=null;if(a&&a.length>0){for(var l=0,u=[{frame:0,value:n.position}],c=0;c<a.length;c++)l+=e.Vector3.Distance(u[c].value,a[c]),u.push({frame:l,value:a[c]});s=new e.Animation("Navigation","position",3,e.Animation.ANIMATIONTYPE_VECTOR3,e.Animation.ANIMATIONLOOPMODE_CONSTANT),null!=r&&s.setEasingFunction(r),s.setKeys(u),n.animations=[s],t.beginAnimation(n,0,l,!1,i,o)}return s},t.EnableUserInput=function(t,n){void 0===n&&(n=null);var a=!(null==n||!n.pointerLock)&&n.pointerLock,i=!(null==n||!n.preventDefault)&&n.preventDefault,r=!(null==n||!n.useCapture)&&n.useCapture,o=!(null==n||!n.enableVirtualJoystick)&&n.enableVirtualJoystick,s=!(null==n||!n.disableRightStick)&&n.disableRightStick;if(e.SceneManager.resetUserInput(),!e.SceneManager.input){if(document.documentElement.tabIndex=1,document.documentElement.addEventListener("keyup",e.SceneManager.inputKeyUpHandler,r),document.documentElement.addEventListener("pointerup",e.SceneManager.inputPointerUpHandler,r),e.UserInputOptions.UseCanvasElement===!0){var l=document.getElementById("renderingCanvas")||t.getEngine().getRenderingCanvas();l.tabIndex=2,l.addEventListener("focusout",e.SceneManager.resetKeyMapHandler,r),l.addEventListener("keydown",e.SceneManager.inputKeyDownHandler,r),l.addEventListener("pointerdown",e.SceneManager.inputPointerDownHandler,r),l.addEventListener("pointermove",e.SceneManager.inputPointerMoveHandler,r),l.addEventListener("onwheel"in document?"wheel":"mousewheel",e.SceneManager.inputPointerWheelHandler,r)}else document.documentElement.addEventListener("focusout",e.SceneManager.resetKeyMapHandler,r),document.documentElement.addEventListener("keydown",e.SceneManager.inputKeyDownHandler,r),document.documentElement.addEventListener("pointerdown",e.SceneManager.inputPointerDownHandler,r),document.documentElement.addEventListener("pointermove",e.SceneManager.inputPointerMoveHandler,r),document.documentElement.addEventListener("onwheel"in document?"wheel":"mousewheel",e.SceneManager.inputPointerWheelHandler,r);e.SceneManager.preventDefault=i,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)),s===!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(),a===!0&&e.SceneManager.LockMousePointer(t,!0)}t.registerAfterRender(function(){e.SceneManager.updateUserInput(t)})},t.DisableUserInput=function(t,n){void 0===n&&(n=!1),e.SceneManager.LockMousePointer(t,!1),e.SceneManager.resetUserInput()},t.ToggleFullscreenMode=function(e,t){void 0===t&&(t=!0),e.getEngine().switchFullscreen(t)},t.EnterFullscreenMode=function(e,t){void 0===t&&(t=!0),e.getEngine().enterFullscreen(t)},t.ExitFullscreenMode=function(e){e.getEngine().exitFullscreen()},t.LockMousePointer=function(t,n){n===!0?e.SceneManager.LockMousePointerObserver=t.onPointerObservable.add(function(n,a){n.type==e.PointerEventTypes.POINTERDOWN&&(document.pointerLockElement||t.getEngine().enterPointerlock())}):e.SceneManager.IsPointerLockHandled()&&(t.onPointerObservable.remove(e.SceneManager.LockMousePointerObserver),e.SceneManager.LockMousePointerObserver=null)},t.IsPointerLocked=function(){return e.SceneManager.PointerLockedFlag},t.IsPointerLockHandled=function(){return null!=e.SceneManager.LockMousePointerObserver},t.GetUserInput=function(t,n){void 0===n&&(n=e.PlayerNumber.One);var a=0;if(e.SceneManager.input)switch(t){case e.UserInputAxis.Vertical:case e.UserInputAxis.Horizontal:a=n===e.PlayerNumber.Four?t===e.UserInputAxis.Horizontal?e.SceneManager.horizontal4:e.SceneManager.vertical4:n===e.PlayerNumber.Three?t===e.UserInputAxis.Horizontal?e.SceneManager.horizontal3:e.SceneManager.vertical3:n===e.PlayerNumber.Two?t===e.UserInputAxis.Horizontal?e.SceneManager.horizontal2:e.SceneManager.vertical2:t===e.UserInputAxis.Horizontal?e.SceneManager.horizontal:e.SceneManager.vertical;break;case e.UserInputAxis.MouseX:case e.UserInputAxis.MouseY:a=n===e.PlayerNumber.Four?t===e.UserInputAxis.MouseX?e.SceneManager.mousex4:e.SceneManager.mousey4:n===e.PlayerNumber.Three?t===e.UserInputAxis.MouseX?e.SceneManager.mousex3:e.SceneManager.mousey3:n===e.PlayerNumber.Two?t===e.UserInputAxis.MouseX?e.SceneManager.mousex2:e.SceneManager.mousey2:t===e.UserInputAxis.MouseX?e.SceneManager.mousex:e.SceneManager.mousey;break;case e.UserInputAxis.Wheel:n===e.PlayerNumber.One&&(a=e.SceneManager.wheel)}return a},t.OnKeyboardUp=function(t){e.SceneManager.input&&e.SceneManager.keyButtonUp.push(t)},t.OnKeyboardDown=function(t){e.SceneManager.input&&e.SceneManager.keyButtonDown.push(t)},t.OnKeyboardPress=function(t,n){e.SceneManager.input&&e.SceneManager.keyButtonPress.push({index:t,action:n})},t.GetKeyboardInput=function(t){var n=!1;if(e.SceneManager.input){var a="k:"+t.toString();null!=e.SceneManager.keymap[a]&&(n=e.SceneManager.keymap[a])}return n},t.OnPointerUp=function(t){e.SceneManager.input&&e.SceneManager.mouseButtonUp.push(t)},t.OnPointerDown=function(t){e.SceneManager.input&&e.SceneManager.mouseButtonDown.push(t)},t.OnPointerPress=function(t,n){e.SceneManager.input&&e.SceneManager.mouseButtonPress.push({index:t,action:n})},t.GetPointerInput=function(t){var n=!1;if(e.SceneManager.input){var a="p:"+t.toString();null!=e.SceneManager.keymap[a]&&(n=e.SceneManager.keymap[a])}return n},t.GetLeftJoystick=function(){return e.SceneManager.input?e.SceneManager.leftJoystick:null},t.GetRightJoystick=function(){return e.SceneManager.input?e.SceneManager.rightJoystick:null},t.GetJoystickPress=function(t){var n=!1;return e.SceneManager.input&&(t===e.JoystickButton.Left&&null!=e.SceneManager.leftJoystick&&e.SceneManager.leftJoystick.pressed===!0?n=!0:t===e.JoystickButton.Right&&null!=e.SceneManager.rightJoystick&&e.SceneManager.rightJoystick.pressed===!0&&(n=!0)),n},t.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)},t.OnGamepadButtonUp=function(t,n){if(void 0===n&&(n=e.PlayerNumber.One),e.SceneManager.input)switch(n){case e.PlayerNumber.One:e.SceneManager.gamepad1ButtonUp.push(t);break;case e.PlayerNumber.Two:e.SceneManager.gamepad2ButtonUp.push(t);break;case e.PlayerNumber.Three:e.SceneManager.gamepad3ButtonUp.push(t);break;case e.PlayerNumber.Four:e.SceneManager.gamepad4ButtonUp.push(t)}},t.OnGamepadButtonDown=function(t,n){if(void 0===n&&(n=e.PlayerNumber.One),e.SceneManager.input)switch(n){case e.PlayerNumber.One:e.SceneManager.gamepad1ButtonDown.push(t);break;case e.PlayerNumber.Two:e.SceneManager.gamepad2ButtonDown.push(t);break;case e.PlayerNumber.Three:e.SceneManager.gamepad3ButtonDown.push(t);break;case e.PlayerNumber.Four:e.SceneManager.gamepad4ButtonDown.push(t)}},t.OnGamepadButtonPress=function(t,n,a){if(void 0===a&&(a=e.PlayerNumber.One),e.SceneManager.input)switch(a){case e.PlayerNumber.One:e.SceneManager.gamepad1ButtonPress.push({index:t,action:n});break;case e.PlayerNumber.Two:e.SceneManager.gamepad2ButtonPress.push({index:t,action:n});break;case e.PlayerNumber.Three:e.SceneManager.gamepad3ButtonPress.push({index:t,action:n});break;case e.PlayerNumber.Four:e.SceneManager.gamepad4ButtonPress.push({index:t,action:n})}},t.GetGamepadButtonInput=function(t,n){void 0===n&&(n=e.PlayerNumber.One);var a=!1;if(e.SceneManager.input){var i=null;switch(n){case e.PlayerNumber.One:i="b1:"+t.toString();break;case e.PlayerNumber.Two:i="b2:"+t.toString();break;case e.PlayerNumber.Three:i="b3:"+t.toString();break;case e.PlayerNumber.Four:i="b4:"+t.toString()}null!=i&&null!=e.SceneManager.keymap[i]&&(a=e.SceneManager.keymap[i])}return a},t.OnGamepadDirectionUp=function(t,n){if(void 0===n&&(n=e.PlayerNumber.One),e.SceneManager.input)switch(n){case e.PlayerNumber.One:e.SceneManager.gamepad1DpadUp.push(t);break;case e.PlayerNumber.Two:e.SceneManager.gamepad2DpadUp.push(t);break;case e.PlayerNumber.Three:e.SceneManager.gamepad3DpadUp.push(t);break;case e.PlayerNumber.Four:e.SceneManager.gamepad4DpadUp.push(t)}},t.OnGamepadDirectionDown=function(t,n){if(void 0===n&&(n=e.PlayerNumber.One),e.SceneManager.input)switch(n){case e.PlayerNumber.One:e.SceneManager.gamepad1DpadDown.push(t);break;case e.PlayerNumber.Two:e.SceneManager.gamepad2DpadDown.push(t);break;case e.PlayerNumber.Three:e.SceneManager.gamepad3DpadDown.push(t);break;case e.PlayerNumber.Four:e.SceneManager.gamepad4DpadDown.push(t)}},t.OnGamepadDirectionPress=function(t,n,a){if(void 0===a&&(a=e.PlayerNumber.One),e.SceneManager.input)switch(a){case e.PlayerNumber.One:e.SceneManager.gamepad1DpadPress.push({index:t,action:n});break;case e.PlayerNumber.Two:e.SceneManager.gamepad2DpadPress.push({index:t,action:n});break;case e.PlayerNumber.Three:e.SceneManager.gamepad3DpadPress.push({index:t,action:n});break;case e.PlayerNumber.Four:e.SceneManager.gamepad4DpadPress.push({index:t,action:n})}},t.GetGamepadDirectionInput=function(t,n){void 0===n&&(n=e.PlayerNumber.One);var a=!1;if(e.SceneManager.input){var i=null;switch(n){case e.PlayerNumber.One:i="d1:"+t.toString();break;case e.PlayerNumber.Two:i="d2:"+t.toString();break;case e.PlayerNumber.Three:i="d3:"+t.toString();break;case e.PlayerNumber.Four:i="d4:"+t.toString()}null!=i&&null!=e.SceneManager.keymap[i]&&(a=e.SceneManager.keymap[i])}return a},t.OnGamepadTriggerLeft=function(t,n){if(void 0===n&&(n=e.PlayerNumber.One),e.SceneManager.input)switch(n){case e.PlayerNumber.One:e.SceneManager.gamepad1LeftTrigger.push(t);break;case e.PlayerNumber.Two:e.SceneManager.gamepad2LeftTrigger.push(t);break;case e.PlayerNumber.Three:e.SceneManager.gamepad3LeftTrigger.push(t);break;case e.PlayerNumber.Four:e.SceneManager.gamepad4LeftTrigger.push(t)}},t.OnGamepadTriggerRight=function(t,n){if(void 0===n&&(n=e.PlayerNumber.One),e.SceneManager.input)switch(n){case e.PlayerNumber.One:e.SceneManager.gamepad1RightTrigger.push(t);break;case e.PlayerNumber.Two:e.SceneManager.gamepad2RightTrigger.push(t);break;case e.PlayerNumber.Three:e.SceneManager.gamepad3RightTrigger.push(t);break;case e.PlayerNumber.Four:e.SceneManager.gamepad4RightTrigger.push(t)}},t.GetGamepadTriggerInput=function(t,n){void 0===n&&(n=e.PlayerNumber.One);var a=0;if(e.SceneManager.input){var i=null;switch(n){case e.PlayerNumber.One:i="t1:"+t.toString();break;case e.PlayerNumber.Two:i="t2:"+t.toString();break;case e.PlayerNumber.Three:i="t3:"+t.toString();break;case e.PlayerNumber.Four:i="t4:"+t.toString()}null!=i&&null!=e.SceneManager.keymap[i]&&(a=e.SceneManager.keymap[i])}return a},t.GetGamepadType=function(t){void 0===t&&(t=e.PlayerNumber.One);var n=e.GamepadType.None;if(e.SceneManager.input)switch(t){case e.PlayerNumber.One:n=e.SceneManager.gamepad1Type;break;case e.PlayerNumber.Two:n=e.SceneManager.gamepad2Type;break;case e.PlayerNumber.Three:n=e.SceneManager.gamepad3Type;break;case e.PlayerNumber.Four:n=e.SceneManager.gamepad4Type}return n},t.GetGamepad=function(t){void 0===t&&(t=e.PlayerNumber.One);var n=null;if(e.SceneManager.input)switch(t){case e.PlayerNumber.One:n=e.SceneManager.gamepad1;break;case e.PlayerNumber.Two:n=e.SceneManager.gamepad2;break;case e.PlayerNumber.Three:n=e.SceneManager.gamepad3;break;case e.PlayerNumber.Four:n=e.SceneManager.gamepad4}return n},t.tickKeyboardInput=function(t){var n=e.SceneManager.GetKeyboardInput(e.UserInputKey.W)||e.SceneManager.GetKeyboardInput(e.UserInputKey.UpArrow),a=e.SceneManager.GetKeyboardInput(e.UserInputKey.A),i=e.SceneManager.GetKeyboardInput(e.UserInputKey.S)||e.SceneManager.GetKeyboardInput(e.UserInputKey.DownArrow),r=e.SceneManager.GetKeyboardInput(e.UserInputKey.D),o=e.SceneManager.GetKeyboardInput(e.UserInputKey.LeftArrow),s=e.SceneManager.GetKeyboardInput(e.UserInputKey.RightArrow);n===!0?e.SceneManager.k_vertical=e.Utilities.GetKeyboardInputValue(t,e.SceneManager.k_vertical,1):i===!0?e.SceneManager.k_vertical=e.Utilities.GetKeyboardInputValue(t,e.SceneManager.k_vertical,-1):e.SceneManager.k_vertical=0,e.UserInputOptions.UseArrowKeyRotation===!0?(r===!0?e.SceneManager.k_horizontal=e.Utilities.GetKeyboardInputValue(t,e.SceneManager.k_horizontal,1):a===!0?e.SceneManager.k_horizontal=e.Utilities.GetKeyboardInputValue(t,e.SceneManager.k_horizontal,-1):e.SceneManager.k_horizontal=0,s===!0?e.SceneManager.a_mousex=1:o===!0?e.SceneManager.a_mousex=-1:e.SceneManager.a_mousex=0):r===!0||s===!0?e.SceneManager.k_horizontal=e.Utilities.GetKeyboardInputValue(t,e.SceneManager.k_horizontal,1):a===!0||o===!0?e.SceneManager.k_horizontal=e.Utilities.GetKeyboardInputValue(t,e.SceneManager.k_horizontal,-1):e.SceneManager.k_horizontal=0},t.updateUserInput=function(t){e.SceneManager.PointerLockedFlag=t.getEngine().isPointerLock,e.SceneManager.tickKeyboardInput(t),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},t.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=[]},t.resetKeyMapHandler=function(t){e.SceneManager.keymap={}},t.inputKeyDownHandler=function(t){var n="k:"+t.keyCode.toString(),a=!1;return null!=e.SceneManager.keymap[n]&&(a=e.SceneManager.keymap[n]),e.SceneManager.keymap[n]=!0,null!=e.SceneManager.keyButtonDown&&e.SceneManager.keyButtonDown.length>0&&e.SceneManager.keyButtonDown.forEach(function(e){e(t.keyCode)}),a||null!=e.SceneManager.keyButtonPress&&e.SceneManager.keyButtonPress.length>0&&e.SceneManager.keyButtonPress.forEach(function(e){e.index===t.keyCode&&e.action()}),e.SceneManager.preventDefault&&t.preventDefault(),!0},t.inputKeyUpHandler=function(t){var n="k:"+t.keyCode.toString();return e.SceneManager.keymap[n]=!1,null!=e.SceneManager.keyButtonUp&&e.SceneManager.keyButtonUp.length>0&&e.SceneManager.keyButtonUp.forEach(function(e){e(t.keyCode)}),e.SceneManager.preventDefault&&t.preventDefault(),!0},t.inputPointerWheelHandler=function(t){var n=t.deltaY?-t.deltaY:t.wheelDelta/40;return e.SceneManager.x_wheel=Math.abs(n)>e.UserInputOptions.PointerWheelDeadZone?0+n:0,e.SceneManager.preventDefault&&t.preventDefault(),!0},t.inputPointerDownHandler=function(t){0===t.button&&(e.SceneManager.previousPosition={x:t.clientX,y:t.clientY});var n="p:"+t.button.toString(),a=!1;return null!=e.SceneManager.keymap[n]&&(a=e.SceneManager.keymap[n]),e.SceneManager.keymap[n]=!0,null!=e.SceneManager.mouseButtonDown&&e.SceneManager.mouseButtonDown.length>0&&e.SceneManager.mouseButtonDown.forEach(function(e){e(t.button)}),a||null!=e.SceneManager.mouseButtonPress&&e.SceneManager.mouseButtonPress.length>0&&e.SceneManager.mouseButtonPress.forEach(function(e){e.index===t.button&&e.action()}),e.SceneManager.preventDefault&&t.preventDefault(),!0},t.inputPointerUpHandler=function(t){0===t.button&&null!=e.SceneManager.previousPosition&&(e.SceneManager.previousPosition=null,e.SceneManager.k_mousex=0,e.SceneManager.k_mousey=0);var n="p:"+t.button.toString();return e.SceneManager.keymap[n]=!1,null!=e.SceneManager.mouseButtonUp&&e.SceneManager.mouseButtonUp.length>0&&e.SceneManager.mouseButtonUp.forEach(function(e){e(t.button)}),e.SceneManager.preventDefault&&t.preventDefault(),!0},t.inputPointerMoveHandler=function(t){if(e.SceneManager.virtualJoystick===!1){var n=0,a=0;e.SceneManager.IsPointerLocked()?(n=t.movementX||t.mozMovementX||t.webkitMovementX||t.msMovementX||0,a=t.movementY||t.mozMovementY||t.webkitMovementY||t.msMovementY||0,e.SceneManager.previousPosition=null):null!=e.SceneManager.previousPosition&&(n=t.clientX-e.SceneManager.previousPosition.x,a=t.clientY-e.SceneManager.previousPosition.y,e.SceneManager.previousPosition={x:t.clientX,y:t.clientY});var i=n*e.UserInputOptions.PointerAngularSensibility*.1,r=a*e.UserInputOptions.PointerAngularSensibility*.1;Math.abs(n)<=e.UserInputOptions.PointerMouseDeadZone&&(i=0),Math.abs(a)<=e.UserInputOptions.PointerMouseDeadZone&&(r=0),e.SceneManager.k_mousex=i,e.SceneManager.rightHanded?e.SceneManager.k_mousey=-r:e.SceneManager.k_mousey=r}return e.SceneManager.preventDefault&&t.preventDefault(),!0},t.inputVirtualJoysticks=function(){if(null!=e.SceneManager.leftJoystick){var t=e.SceneManager.leftJoystick.deltaPosition;e.SceneManager.leftJoystick.pressed||(t=t.scale(.9));var n=t.x,a=t.y;t.x=Math.abs(n)>e.UserInputOptions.JoystickDeadStickValue?n:0,t.y=Math.abs(a)>e.UserInputOptions.JoystickDeadStickValue?a:0,e.SceneManager.j_horizontal=t.x,e.SceneManager.j_vertical=t.y}if(null!=e.SceneManager.rightJoystick){var i=e.SceneManager.rightJoystick.deltaPosition;e.SceneManager.rightJoystick.pressed||(i=i.scale(.9));var r=i.x,o=i.y;i.x=Math.abs(r)>e.UserInputOptions.JoystickDeadStickValue?r:0,i.y=Math.abs(o)>e.UserInputOptions.JoystickDeadStickValue?o:0,e.SceneManager.j_mousex=i.x,e.SceneManager.j_mousey=i.y}},t.inputOneButtonDownHandler=function(t){if(null!=e.SceneManager.gamepad1){var n="b1:"+t.toString(),a=!1;null!=e.SceneManager.keymap[n]&&(a=e.SceneManager.keymap[n]),e.SceneManager.keymap[n]=!0,null!=e.SceneManager.gamepad1ButtonDown&&e.SceneManager.gamepad1ButtonDown.length>0&&e.SceneManager.gamepad1ButtonDown.forEach(function(e){e(t)}),a||null!=e.SceneManager.gamepad1ButtonPress&&e.SceneManager.gamepad1ButtonPress.length>0&&e.SceneManager.gamepad1ButtonPress.forEach(function(e){e.index===t&&e.action()})}},t.inputOneButtonUpHandler=function(t){if(null!=e.SceneManager.gamepad1){var n="b1:"+t.toString();e.SceneManager.keymap[n]=!1,null!=e.SceneManager.gamepad1ButtonUp&&e.SceneManager.gamepad1ButtonUp.length>0&&e.SceneManager.gamepad1ButtonUp.forEach(function(e){e(t)})}},t.inputOneXboxDPadDownHandler=function(t){if(null!=e.SceneManager.gamepad1){var n="d1:"+t.toString(),a=!1;null!=e.SceneManager.keymap[n]&&(a=e.SceneManager.keymap[n]),e.SceneManager.keymap[n]=!0,null!=e.SceneManager.gamepad1DpadDown&&e.SceneManager.gamepad1DpadDown.length>0&&e.SceneManager.gamepad1DpadDown.forEach(function(e){e(t)}),a||null!=e.SceneManager.gamepad1DpadPress&&e.SceneManager.gamepad1DpadPress.length>0&&e.SceneManager.gamepad1DpadPress.forEach(function(e){e.index===t&&e.action()})}},t.inputOneShockDPadDownHandler=function(t){if(null!=e.SceneManager.gamepad1){var n="d1:"+t.toString(),a=!1;null!=e.SceneManager.keymap[n]&&(a=e.SceneManager.keymap[n]),e.SceneManager.keymap[n]=!0,null!=e.SceneManager.gamepad1DpadDown&&e.SceneManager.gamepad1DpadDown.length>0&&e.SceneManager.gamepad1DpadDown.forEach(function(e){e(t)}),a||null!=e.SceneManager.gamepad1DpadPress&&e.SceneManager.gamepad1DpadPress.length>0&&e.SceneManager.gamepad1DpadPress.forEach(function(e){e.index===t&&e.action()})}},t.inputOneXboxDPadUpHandler=function(t){if(null!=e.SceneManager.gamepad1){var n="d1:"+t.toString();e.SceneManager.keymap[n]=!1,null!=e.SceneManager.gamepad1DpadUp&&e.SceneManager.gamepad1DpadUp.length>0&&e.SceneManager.gamepad1DpadUp.forEach(function(e){e(t)})}},t.inputOneShockDPadUpHandler=function(t){if(null!=e.SceneManager.gamepad1){var n="d1:"+t.toString();e.SceneManager.keymap[n]=!1,null!=e.SceneManager.gamepad1DpadUp&&e.SceneManager.gamepad1DpadUp.length>0&&e.SceneManager.gamepad1DpadUp.forEach(function(e){e(t)})}},t.inputOneXboxLeftTriggerHandler=function(t){null!=e.SceneManager.gamepad1&&(e.SceneManager.keymap["t1:0"]=t,null!=e.SceneManager.gamepad1LeftTrigger&&e.SceneManager.gamepad1LeftTrigger.length>0&&e.SceneManager.gamepad1LeftTrigger.forEach(function(e){e(t)}))},t.inputOneXboxRightTriggerHandler=function(t){null!=e.SceneManager.gamepad1&&(e.SceneManager.keymap["t1:1"]=t,null!=e.SceneManager.gamepad1RightTrigger&&e.SceneManager.gamepad1RightTrigger.length>0&&e.SceneManager.gamepad1RightTrigger.forEach(function(e){e(t)}))},t.inputOneLeftStickHandler=function(t){if(null!=e.SceneManager.gamepad1){var n=t,a=n.x*e.UserInputOptions.GamepadLStickSensibility,i=n.y*e.UserInputOptions.GamepadLStickSensibility;n.x=Math.abs(a)>e.UserInputOptions.GamepadDeadStickValue?a:0,n.y=Math.abs(i)>e.UserInputOptions.GamepadDeadStickValue?i:0,e.SceneManager.g_horizontal1=e.UserInputOptions.GamepadLStickXInverted?-n.x:n.x,e.SceneManager.g_vertical1=e.UserInputOptions.GamepadLStickYInverted?n.y:-n.y}},t.inputOneRightStickHandler=function(t){if(null!=e.SceneManager.gamepad1){var n=t,a=n.x*e.UserInputOptions.GamepadRStickSensibility,i=n.y*e.UserInputOptions.GamepadRStickSensibility;n.x=Math.abs(a)>e.UserInputOptions.GamepadDeadStickValue?a:0,n.y=Math.abs(i)>e.UserInputOptions.GamepadDeadStickValue?i:0,e.SceneManager.g_mousex1=e.UserInputOptions.GamepadRStickXInverted?-n.x:n.x,e.SceneManager.g_mousey1=e.UserInputOptions.GamepadRStickYInverted?-n.y:n.y}},t.inputTwoButtonDownHandler=function(t){if(null!=e.SceneManager.gamepad2){var n="b2:"+t.toString(),a=!1;null!=e.SceneManager.keymap[n]&&(a=e.SceneManager.keymap[n]),e.SceneManager.keymap[n]=!0,null!=e.SceneManager.gamepad2ButtonDown&&e.SceneManager.gamepad2ButtonDown.length>0&&e.SceneManager.gamepad2ButtonDown.forEach(function(e){e(t)}),a||null!=e.SceneManager.gamepad2ButtonPress&&e.SceneManager.gamepad2ButtonPress.length>0&&e.SceneManager.gamepad2ButtonPress.forEach(function(e){e.index===t&&e.action()})}},t.inputTwoButtonUpHandler=function(t){if(null!=e.SceneManager.gamepad2){var n="b2:"+t.toString();e.SceneManager.keymap[n]=!1,null!=e.SceneManager.gamepad2ButtonUp&&e.SceneManager.gamepad2ButtonUp.length>0&&e.SceneManager.gamepad2ButtonUp.forEach(function(e){
- e(t)})}},t.inputTwoXboxDPadDownHandler=function(t){if(null!=e.SceneManager.gamepad2){var n="d2:"+t.toString(),a=!1;null!=e.SceneManager.keymap[n]&&(a=e.SceneManager.keymap[n]),e.SceneManager.keymap[n]=!0,null!=e.SceneManager.gamepad2DpadDown&&e.SceneManager.gamepad2DpadDown.length>0&&e.SceneManager.gamepad2DpadDown.forEach(function(e){e(t)}),a||null!=e.SceneManager.gamepad2DpadPress&&e.SceneManager.gamepad2DpadPress.length>0&&e.SceneManager.gamepad2DpadPress.forEach(function(e){e.index===t&&e.action()})}},t.inputTwoShockDPadDownHandler=function(t){if(null!=e.SceneManager.gamepad2){var n="d2:"+t.toString(),a=!1;null!=e.SceneManager.keymap[n]&&(a=e.SceneManager.keymap[n]),e.SceneManager.keymap[n]=!0,null!=e.SceneManager.gamepad2DpadDown&&e.SceneManager.gamepad2DpadDown.length>0&&e.SceneManager.gamepad2DpadDown.forEach(function(e){e(t)}),a||null!=e.SceneManager.gamepad2DpadPress&&e.SceneManager.gamepad2DpadPress.length>0&&e.SceneManager.gamepad2DpadPress.forEach(function(e){e.index===t&&e.action()})}},t.inputTwoXboxDPadUpHandler=function(t){if(null!=e.SceneManager.gamepad2){var n="d2:"+t.toString();e.SceneManager.keymap[n]=!1,null!=e.SceneManager.gamepad2DpadUp&&e.SceneManager.gamepad2DpadUp.length>0&&e.SceneManager.gamepad2DpadUp.forEach(function(e){e(t)})}},t.inputTwoShockDPadUpHandler=function(t){if(null!=e.SceneManager.gamepad2){var n="d2:"+t.toString();e.SceneManager.keymap[n]=!1,null!=e.SceneManager.gamepad2DpadUp&&e.SceneManager.gamepad2DpadUp.length>0&&e.SceneManager.gamepad2DpadUp.forEach(function(e){e(t)})}},t.inputTwoXboxLeftTriggerHandler=function(t){null!=e.SceneManager.gamepad2&&(e.SceneManager.keymap["t2:0"]=t,null!=e.SceneManager.gamepad2LeftTrigger&&e.SceneManager.gamepad2LeftTrigger.length>0&&e.SceneManager.gamepad2LeftTrigger.forEach(function(e){e(t)}))},t.inputTwoXboxRightTriggerHandler=function(t){null!=e.SceneManager.gamepad2&&(e.SceneManager.keymap["t2:1"]=t,null!=e.SceneManager.gamepad2RightTrigger&&e.SceneManager.gamepad2RightTrigger.length>0&&e.SceneManager.gamepad2RightTrigger.forEach(function(e){e(t)}))},t.inputTwoLeftStickHandler=function(t){if(null!=e.SceneManager.gamepad2){var n=t,a=n.x*e.UserInputOptions.GamepadLStickSensibility,i=n.y*e.UserInputOptions.GamepadLStickSensibility;n.x=Math.abs(a)>e.UserInputOptions.GamepadDeadStickValue?a:0,n.y=Math.abs(i)>e.UserInputOptions.GamepadDeadStickValue?i:0,e.SceneManager.g_horizontal2=e.UserInputOptions.GamepadLStickXInverted?-n.x:n.x,e.SceneManager.g_vertical2=e.UserInputOptions.GamepadLStickYInverted?n.y:-n.y}},t.inputTwoRightStickHandler=function(t){if(null!=e.SceneManager.gamepad2){var n=t,a=n.x*e.UserInputOptions.GamepadRStickSensibility,i=n.y*e.UserInputOptions.GamepadRStickSensibility;n.x=Math.abs(a)>e.UserInputOptions.GamepadDeadStickValue?a:0,n.y=Math.abs(i)>e.UserInputOptions.GamepadDeadStickValue?i:0,e.SceneManager.g_mousex2=e.UserInputOptions.GamepadRStickXInverted?-n.x:n.x,e.SceneManager.g_mousey2=e.UserInputOptions.GamepadRStickYInverted?-n.y:n.y}},t.inputThreeButtonDownHandler=function(t){if(null!=e.SceneManager.gamepad3){var n="b3:"+t.toString(),a=!1;null!=e.SceneManager.keymap[n]&&(a=e.SceneManager.keymap[n]),e.SceneManager.keymap[n]=!0,null!=e.SceneManager.gamepad3ButtonDown&&e.SceneManager.gamepad3ButtonDown.length>0&&e.SceneManager.gamepad3ButtonDown.forEach(function(e){e(t)}),a||null!=e.SceneManager.gamepad3ButtonPress&&e.SceneManager.gamepad3ButtonPress.length>0&&e.SceneManager.gamepad3ButtonPress.forEach(function(e){e.index===t&&e.action()})}},t.inputThreeButtonUpHandler=function(t){if(null!=e.SceneManager.gamepad3){var n="b3:"+t.toString();e.SceneManager.keymap[n]=!1,null!=e.SceneManager.gamepad3ButtonUp&&e.SceneManager.gamepad3ButtonUp.length>0&&e.SceneManager.gamepad3ButtonUp.forEach(function(e){e(t)})}},t.inputThreeXboxDPadDownHandler=function(t){if(null!=e.SceneManager.gamepad3){var n="d3:"+t.toString(),a=!1;null!=e.SceneManager.keymap[n]&&(a=e.SceneManager.keymap[n]),e.SceneManager.keymap[n]=!0,null!=e.SceneManager.gamepad3DpadDown&&e.SceneManager.gamepad3DpadDown.length>0&&e.SceneManager.gamepad3DpadDown.forEach(function(e){e(t)}),a||null!=e.SceneManager.gamepad3DpadPress&&e.SceneManager.gamepad3DpadPress.length>0&&e.SceneManager.gamepad3DpadPress.forEach(function(e){e.index===t&&e.action()})}},t.inputThreeShockDPadDownHandler=function(t){if(null!=e.SceneManager.gamepad3){var n="d3:"+t.toString(),a=!1;null!=e.SceneManager.keymap[n]&&(a=e.SceneManager.keymap[n]),e.SceneManager.keymap[n]=!0,null!=e.SceneManager.gamepad3DpadDown&&e.SceneManager.gamepad3DpadDown.length>0&&e.SceneManager.gamepad3DpadDown.forEach(function(e){e(t)}),a||null!=e.SceneManager.gamepad3DpadPress&&e.SceneManager.gamepad3DpadPress.length>0&&e.SceneManager.gamepad3DpadPress.forEach(function(e){e.index===t&&e.action()})}},t.inputThreeXboxDPadUpHandler=function(t){if(null!=e.SceneManager.gamepad3){var n="d3:"+t.toString();e.SceneManager.keymap[n]=!1,null!=e.SceneManager.gamepad3DpadUp&&e.SceneManager.gamepad3DpadUp.length>0&&e.SceneManager.gamepad3DpadUp.forEach(function(e){e(t)})}},t.inputThreeShockDPadUpHandler=function(t){if(null!=e.SceneManager.gamepad3){var n="d3:"+t.toString();e.SceneManager.keymap[n]=!1,null!=e.SceneManager.gamepad3DpadUp&&e.SceneManager.gamepad3DpadUp.length>0&&e.SceneManager.gamepad3DpadUp.forEach(function(e){e(t)})}},t.inputThreeXboxLeftTriggerHandler=function(t){null!=e.SceneManager.gamepad3&&(e.SceneManager.keymap["t3:0"]=t,null!=e.SceneManager.gamepad3LeftTrigger&&e.SceneManager.gamepad3LeftTrigger.length>0&&e.SceneManager.gamepad3LeftTrigger.forEach(function(e){e(t)}))},t.inputThreeXboxRightTriggerHandler=function(t){null!=e.SceneManager.gamepad3&&(e.SceneManager.keymap["t3:1"]=t,null!=e.SceneManager.gamepad3RightTrigger&&e.SceneManager.gamepad3RightTrigger.length>0&&e.SceneManager.gamepad3RightTrigger.forEach(function(e){e(t)}))},t.inputThreeLeftStickHandler=function(t){if(null!=e.SceneManager.gamepad3){var n=t,a=n.x*e.UserInputOptions.GamepadLStickSensibility,i=n.y*e.UserInputOptions.GamepadLStickSensibility;n.x=Math.abs(a)>e.UserInputOptions.GamepadDeadStickValue?a:0,n.y=Math.abs(i)>e.UserInputOptions.GamepadDeadStickValue?i:0,e.SceneManager.g_horizontal3=e.UserInputOptions.GamepadLStickXInverted?-n.x:n.x,e.SceneManager.g_vertical3=e.UserInputOptions.GamepadLStickYInverted?n.y:-n.y}},t.inputThreeRightStickHandler=function(t){if(null!=e.SceneManager.gamepad3){var n=t,a=n.x*e.UserInputOptions.GamepadRStickSensibility,i=n.y*e.UserInputOptions.GamepadRStickSensibility;n.x=Math.abs(a)>e.UserInputOptions.GamepadDeadStickValue?a:0,n.y=Math.abs(i)>e.UserInputOptions.GamepadDeadStickValue?i:0,e.SceneManager.g_mousex3=e.UserInputOptions.GamepadRStickXInverted?-n.x:n.x,e.SceneManager.g_mousey3=e.UserInputOptions.GamepadRStickYInverted?-n.y:n.y}},t.inputFourButtonDownHandler=function(t){if(null!=e.SceneManager.gamepad4){var n="b4:"+t.toString(),a=!1;null!=e.SceneManager.keymap[n]&&(a=e.SceneManager.keymap[n]),e.SceneManager.keymap[n]=!0,null!=e.SceneManager.gamepad4ButtonDown&&e.SceneManager.gamepad4ButtonDown.length>0&&e.SceneManager.gamepad4ButtonDown.forEach(function(e){e(t)}),a||null!=e.SceneManager.gamepad4ButtonPress&&e.SceneManager.gamepad4ButtonPress.length>0&&e.SceneManager.gamepad4ButtonPress.forEach(function(e){e.index===t&&e.action()})}},t.inputFourButtonUpHandler=function(t){if(null!=e.SceneManager.gamepad4){var n="b4:"+t.toString();e.SceneManager.keymap[n]=!1,null!=e.SceneManager.gamepad4ButtonUp&&e.SceneManager.gamepad4ButtonUp.length>0&&e.SceneManager.gamepad4ButtonUp.forEach(function(e){e(t)})}},t.inputFourXboxDPadDownHandler=function(t){if(null!=e.SceneManager.gamepad4){var n="d4:"+t.toString(),a=!1;null!=e.SceneManager.keymap[n]&&(a=e.SceneManager.keymap[n]),e.SceneManager.keymap[n]=!0,null!=e.SceneManager.gamepad4DpadDown&&e.SceneManager.gamepad4DpadDown.length>0&&e.SceneManager.gamepad4DpadDown.forEach(function(e){e(t)}),a||null!=e.SceneManager.gamepad4DpadPress&&e.SceneManager.gamepad4DpadPress.length>0&&e.SceneManager.gamepad4DpadPress.forEach(function(e){e.index===t&&e.action()})}},t.inputFourShockDPadDownHandler=function(t){if(null!=e.SceneManager.gamepad4){var n="d4:"+t.toString(),a=!1;null!=e.SceneManager.keymap[n]&&(a=e.SceneManager.keymap[n]),e.SceneManager.keymap[n]=!0,null!=e.SceneManager.gamepad4DpadDown&&e.SceneManager.gamepad4DpadDown.length>0&&e.SceneManager.gamepad4DpadDown.forEach(function(e){e(t)}),a||null!=e.SceneManager.gamepad4DpadPress&&e.SceneManager.gamepad4DpadPress.length>0&&e.SceneManager.gamepad4DpadPress.forEach(function(e){e.index===t&&e.action()})}},t.inputFourXboxDPadUpHandler=function(t){if(null!=e.SceneManager.gamepad4){var n="d4:"+t.toString();e.SceneManager.keymap[n]=!1,null!=e.SceneManager.gamepad4DpadUp&&e.SceneManager.gamepad4DpadUp.length>0&&e.SceneManager.gamepad4DpadUp.forEach(function(e){e(t)})}},t.inputFourShockDPadUpHandler=function(t){if(null!=e.SceneManager.gamepad4){var n="d4:"+t.toString();e.SceneManager.keymap[n]=!1,null!=e.SceneManager.gamepad4DpadUp&&e.SceneManager.gamepad4DpadUp.length>0&&e.SceneManager.gamepad4DpadUp.forEach(function(e){e(t)})}},t.inputFourXboxLeftTriggerHandler=function(t){null!=e.SceneManager.gamepad4&&(e.SceneManager.keymap["t4:0"]=t,null!=e.SceneManager.gamepad4LeftTrigger&&e.SceneManager.gamepad4LeftTrigger.length>0&&e.SceneManager.gamepad4LeftTrigger.forEach(function(e){e(t)}))},t.inputFourXboxRightTriggerHandler=function(t){null!=e.SceneManager.gamepad4&&(e.SceneManager.keymap["t4:1"]=t,null!=e.SceneManager.gamepad4RightTrigger&&e.SceneManager.gamepad4RightTrigger.length>0&&e.SceneManager.gamepad4RightTrigger.forEach(function(e){e(t)}))},t.inputFourLeftStickHandler=function(t){if(null!=e.SceneManager.gamepad4){var n=t,a=n.x*e.UserInputOptions.GamepadLStickSensibility,i=n.y*e.UserInputOptions.GamepadLStickSensibility;n.x=Math.abs(a)>e.UserInputOptions.GamepadDeadStickValue?a:0,n.y=Math.abs(i)>e.UserInputOptions.GamepadDeadStickValue?i:0,e.SceneManager.g_horizontal4=e.UserInputOptions.GamepadLStickXInverted?-n.x:n.x,e.SceneManager.g_vertical4=e.UserInputOptions.GamepadLStickYInverted?n.y:-n.y}},t.inputFourRightStickHandler=function(t){if(null!=e.SceneManager.gamepad4){var n=t,a=n.x*e.UserInputOptions.GamepadRStickSensibility,i=n.y*e.UserInputOptions.GamepadRStickSensibility;n.x=Math.abs(a)>e.UserInputOptions.GamepadDeadStickValue?a:0,n.y=Math.abs(i)>e.UserInputOptions.GamepadDeadStickValue?i:0,e.SceneManager.g_mousex4=e.UserInputOptions.GamepadRStickXInverted?-n.x:n.x,e.SceneManager.g_mousey4=e.UserInputOptions.GamepadRStickYInverted?-n.y:n.y}},t.inputManagerGamepadConnected=function(t,n){if(null==e.SceneManager.gamepad1&&0===t.index)if(e.SceneManager.gamepad1=t,e.Tools.Log("Gamepad One Connected: "+e.SceneManager.gamepad1.id),e.SceneManager.gamepad1 instanceof e.Xbox360Pad){e.SceneManager.gamepad1Type=e.GamepadType.Xbox360;var a=e.SceneManager.gamepad1;a.onbuttonup(e.SceneManager.inputOneButtonUpHandler),a.onbuttondown(e.SceneManager.inputOneButtonDownHandler),a.onleftstickchanged(e.SceneManager.inputOneLeftStickHandler),a.onrightstickchanged(e.SceneManager.inputOneRightStickHandler),a.ondpadup(e.SceneManager.inputOneXboxDPadUpHandler),a.ondpaddown(e.SceneManager.inputOneXboxDPadDownHandler),a.onlefttriggerchanged(e.SceneManager.inputOneXboxLeftTriggerHandler),a.onrighttriggerchanged(e.SceneManager.inputOneXboxRightTriggerHandler)}else if(e.SceneManager.gamepad1 instanceof e.DualShockPad){e.SceneManager.gamepad1Type=e.GamepadType.DualShock;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),i.ondpadup(e.SceneManager.inputOneShockDPadUpHandler),i.ondpaddown(e.SceneManager.inputOneShockDPadDownHandler),i.onlefttriggerchanged(e.SceneManager.inputOneXboxLeftTriggerHandler),i.onrighttriggerchanged(e.SceneManager.inputOneXboxRightTriggerHandler)}else if(e.SceneManager.gamepad1 instanceof e.PoseEnabledController);else{e.SceneManager.gamepad1Type=e.GamepadType.Generic;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)}if(null==e.SceneManager.gamepad2&&1===t.index)if(e.SceneManager.gamepad2=t,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 s=e.SceneManager.gamepad2;s.onbuttonup(e.SceneManager.inputOneButtonUpHandler),s.onbuttondown(e.SceneManager.inputOneButtonDownHandler),s.onleftstickchanged(e.SceneManager.inputOneLeftStickHandler),s.onrightstickchanged(e.SceneManager.inputOneRightStickHandler),s.ondpadup(e.SceneManager.inputOneShockDPadUpHandler),s.ondpaddown(e.SceneManager.inputOneShockDPadDownHandler),s.onlefttriggerchanged(e.SceneManager.inputOneXboxLeftTriggerHandler),s.onrighttriggerchanged(e.SceneManager.inputOneXboxRightTriggerHandler)}else if(e.SceneManager.gamepad2 instanceof e.PoseEnabledController);else{e.SceneManager.gamepad2Type=e.GamepadType.Generic;var l=e.SceneManager.gamepad2;l.onbuttonup(e.SceneManager.inputTwoButtonUpHandler),l.onbuttondown(e.SceneManager.inputTwoButtonDownHandler),l.onleftstickchanged(e.SceneManager.inputTwoLeftStickHandler),l.onrightstickchanged(e.SceneManager.inputTwoRightStickHandler)}if(null==e.SceneManager.gamepad3&&2===t.index)if(e.SceneManager.gamepad3=t,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 h=e.SceneManager.gamepad3;h.onbuttonup(e.SceneManager.inputThreeButtonUpHandler),h.onbuttondown(e.SceneManager.inputThreeButtonDownHandler),h.onleftstickchanged(e.SceneManager.inputThreeLeftStickHandler),h.onrightstickchanged(e.SceneManager.inputThreeRightStickHandler)}if(null==e.SceneManager.gamepad4&&3===t.index)if(e.SceneManager.gamepad4=t,e.Tools.Log("Gamepad Four Connected: "+e.SceneManager.gamepad4.id),e.SceneManager.gamepad4 instanceof e.Xbox360Pad){e.SceneManager.gamepad4Type=e.GamepadType.Xbox360;var m=e.SceneManager.gamepad4;m.onbuttonup(e.SceneManager.inputFourButtonUpHandler),m.onbuttondown(e.SceneManager.inputFourButtonDownHandler),m.onleftstickchanged(e.SceneManager.inputFourLeftStickHandler),m.onrightstickchanged(e.SceneManager.inputFourRightStickHandler),m.ondpadup(e.SceneManager.inputFourXboxDPadUpHandler),m.ondpaddown(e.SceneManager.inputFourXboxDPadDownHandler),m.onlefttriggerchanged(e.SceneManager.inputFourXboxLeftTriggerHandler),m.onrighttriggerchanged(e.SceneManager.inputFourXboxRightTriggerHandler)}else if(e.SceneManager.gamepad4 instanceof e.DualShockPad){var p=e.SceneManager.gamepad4;p.onbuttonup(e.SceneManager.inputOneButtonUpHandler),p.onbuttondown(e.SceneManager.inputOneButtonDownHandler),p.onleftstickchanged(e.SceneManager.inputOneLeftStickHandler),p.onrightstickchanged(e.SceneManager.inputOneRightStickHandler),p.ondpadup(e.SceneManager.inputOneShockDPadUpHandler),p.ondpaddown(e.SceneManager.inputOneShockDPadDownHandler),p.onlefttriggerchanged(e.SceneManager.inputOneXboxLeftTriggerHandler),p.onrighttriggerchanged(e.SceneManager.inputOneXboxRightTriggerHandler)}else if(e.SceneManager.gamepad4 instanceof e.PoseEnabledController);else{e.SceneManager.gamepad4Type=e.GamepadType.Generic;var d=e.SceneManager.gamepad4;d.onbuttonup(e.SceneManager.inputFourButtonUpHandler),d.onbuttondown(e.SceneManager.inputFourButtonDownHandler),d.onleftstickchanged(e.SceneManager.inputFourLeftStickHandler),d.onrightstickchanged(e.SceneManager.inputFourRightStickHandler)}null!=e.SceneManager.GamepadConnected&&e.SceneManager.GamepadConnected(t,n)},t.inputManagerGamepadDisconnected=function(t,n){null!=e.SceneManager.GamepadDisconnected&&e.SceneManager.GamepadDisconnected(t,n)},t.inputManagerLeftControllerMainButton=function(e,t){},t.inputManagerLeftControllerPadState=function(e,t){},t.inputManagerLeftControllerPadValues=function(e,t){},t.inputManagerLeftControllerAuxButton=function(e,t){},t.inputManagerLeftControllerTriggered=function(e,t){},t.inputManagerRightControllerMainButton=function(e,t){},t.inputManagerRightControllerPadState=function(e,t){},t.inputManagerRightControllerPadValues=function(e,t){},t.inputManagerRightControllerAuxButton=function(e,t){},t.inputManagerRightControllerTriggered=function(e,t){},t.inputManagerControllerConnected=function(e,t){},t.PauseRenderLoop=!1,t.OnFontsReadyObservable=new e.Observable,t.OnEngineResizeObservable=new e.Observable,t.OnLoadCompleteObservable=new e.Observable,t.SceneParsingEnabled=!0,t.AdvDynamicTexture=null,t.OnSetupPhysicsPlugin=null,t.TempVRayDest=null,t.TempVRayOrigin=null,t.TempShapeVector=null,t.TempPhysicsWorld=null,t.TempTransformFrom=null,t.TempTransformTo=null,t.TempCastEndPoint=null,t.TempRaycastResult=null,t.ClosestRayResultCallback=null,t.ClosestConvexResultCallback=null,t.MAX_AGENT_COUNT=200,t.MAX_AGENT_RADIUS=2,t.NavigationMesh=null,t.CrowdInterface=null,t.PluginInstance=null,t.OnNavMeshReadyObservable=new e.Observable,t.GamepadManager=null,t.GamepadConnected=null,t.GamepadDisconnected=null,t.PointerLockedFlag=!1,t.LockMousePointerObserver=null,t.input=!1,t.keymap={},t.wheel=0,t.mousex=0,t.mousey=0,t.vertical=0,t.horizontal=0,t.mousex2=0,t.mousey2=0,t.vertical2=0,t.horizontal2=0,t.mousex3=0,t.mousey3=0,t.vertical3=0,t.horizontal3=0,t.mousex4=0,t.mousey4=0,t.vertical4=0,t.horizontal4=0,t.a_mousex=0,t.x_wheel=0,t.x_mousex=0,t.x_mousey=0,t.x_vertical=0,t.x_horizontal=0,t.k_mousex=0,t.k_mousey=0,t.k_vertical=0,t.k_horizontal=0,t.j_mousex=0,t.j_mousey=0,t.j_vertical=0,t.j_horizontal=0,t.g_mousex1=0,t.g_mousey1=0,t.g_vertical1=0,t.g_horizontal1=0,t.g_mousex2=0,t.g_mousey2=0,t.g_vertical2=0,t.g_horizontal2=0,t.g_mousex3=0,t.g_mousey3=0,t.g_vertical3=0,t.g_horizontal3=0,t.g_mousex4=0,t.g_mousey4=0,t.g_vertical4=0,t.g_horizontal4=0,t.mouseButtonPress=[],t.mouseButtonDown=[],t.mouseButtonUp=[],t.keyButtonPress=[],t.keyButtonDown=[],t.keyButtonUp=[],t.leftJoystick=null,t.rightJoystick=null,t.virtualJoystick=!1,t.previousPosition=null,t.preventDefault=!1,t.rightHanded=!0,t.gamepad1=null,t.gamepad1Type=-1,t.gamepad1ButtonPress=[],t.gamepad1ButtonDown=[],t.gamepad1ButtonUp=[],t.gamepad1DpadPress=[],t.gamepad1DpadDown=[],t.gamepad1DpadUp=[],t.gamepad1LeftTrigger=[],t.gamepad1RightTrigger=[],t.gamepad2=null,t.gamepad2Type=-1,t.gamepad2ButtonPress=[],t.gamepad2ButtonDown=[],t.gamepad2ButtonUp=[],t.gamepad2DpadPress=[],t.gamepad2DpadDown=[],t.gamepad2DpadUp=[],t.gamepad2LeftTrigger=[],t.gamepad2RightTrigger=[],t.gamepad3=null,t.gamepad3Type=-1,t.gamepad3ButtonPress=[],t.gamepad3ButtonDown=[],t.gamepad3ButtonUp=[],t.gamepad3DpadPress=[],t.gamepad3DpadDown=[],t.gamepad3DpadUp=[],t.gamepad3LeftTrigger=[],t.gamepad3RightTrigger=[],t.gamepad4=null,t.gamepad4Type=-1,t.gamepad4ButtonPress=[],t.gamepad4ButtonDown=[],t.gamepad4ButtonUp=[],t.gamepad4DpadPress=[],t.gamepad4DpadDown=[],t.gamepad4DpadUp=[],t.gamepad4LeftTrigger=[],t.gamepad4RightTrigger=[],t.debugLayerVisible=!1,t}();e.SceneManager=t}(BABYLON||(BABYLON={}));var SM=BABYLON.SceneManager,BABYLON;!function(e){var t;!function(t){t[t.Deg2Rad=2*Math.PI/360]="Deg2Rad",t[t.Rad2Deg=1/e.System.Deg2Rad]="Rad2Deg",t[t.Epsilon=1e-5]="Epsilon",t[t.EpsilonNormalSqrt=1e-15]="EpsilonNormalSqrt",t[t.Kph2Mph=.621371]="Kph2Mph",t[t.Mph2Kph=1.60934]="Mph2Kph",t[t.Mps2Kph=3.6]="Mps2Kph",t[t.Meter2Inch=39.3701]="Meter2Inch",t[t.Inch2Meter=.0254]="Inch2Meter",t[t.Gravity=9.81]="Gravity",t[t.Gravity3G=29.400000000000002]="Gravity3G",t[t.SkidFactor=.25]="SkidFactor",t[t.MaxInteger=2147483647]="MaxInteger",t[t.WalkingVelocity=4.4]="WalkingVelocity",t[t.TerminalVelocity=55]="TerminalVelocity",t[t.SmoothDeltaFactor=.2]="SmoothDeltaFactor",t[t.ToLinearSpace=2.2]="ToLinearSpace",t[t.ToGammaSpace=.45454545454545453]="ToGammaSpace"}(t=e.System||(e.System={}));var n;!function(e){e[e.Default=-1]="Default",e[e.Right=0]="Right",e[e.Left=1]="Left"}(n=e.Handedness||(e.Handedness={}));var a;!function(e){e[e.ExactMatch=0]="ExactMatch",e[e.StartsWith=1]="StartsWith",e[e.EndsWith=2]="EndsWith",e[e.IndexOf=3]="IndexOf"}(a=e.SearchType||(e.SearchType={}));var i;!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"}(i=e.PlayerNumber||(e.PlayerNumber={}));var r;!function(e){e[e.FirstPerson=0]="FirstPerson",e[e.ThirdPerson=1]="ThirdPerson"}(r=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 s;!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"}(s=e.GamepadType||(e.GamepadType={}));var l;!function(e){e[e.Left=0]="Left",e[e.Right=1]="Right"}(l=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 h;!function(e){e[e.Top=0]="Top",e[e.Left=1]="Left",e[e.Right=2]="Right",e[e.Bottom=3]="Bottom"}(h=e.CollisionContact||(e.CollisionContact={}));var m;!function(e){e[e.AABB=0]="AABB",e[e.OBB=1]="OBB"}(m=e.IntersectionPrecision||(e.IntersectionPrecision={}));var p;!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"}(p=e.CollisionFilters||(e.CollisionFilters={}));var d;!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"}(d=e.CollisionState||(e.CollisionState={}));var g;!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"}(g=e.CollisionFlags||(e.CollisionFlags={}));var f;!function(e){e[e.Left=0]="Left",e[e.Middle=1]="Middle",e[e.Right=2]="Right"}(f=e.UserInputPointer||(e.UserInputPointer={}));var y;!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"}(y=e.UserInputAxis||(e.UserInputAxis={}));var _;!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"}(_=e.UserInputKey||(e.UserInputKey={}));var v=function(){function e(){}return e.KeyboardSmoothing=!0,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.UseArrowKeyRotation=!0,e.UseCanvasElement=!0,e}();e.UserInputOptions=v;var M=function(){function e(){this.mesh=null,this.state=0}return e}();e.TriggerVolume=M;var S=function(){function e(){this.ListenerDictionary={}}return e.prototype.AddListener=function(e,t){var n;null==this.ListenerDictionary[e]?(n=[],this.ListenerDictionary[e]=n):n=this.ListenerDictionary[e],n.push(t)},e.prototype.RemoveListener=function(e,t){var n=this.ListenerDictionary[e];if(null!=n){var a=n.findIndex(function(e){return t==e});a>=0&&n.splice(a,1)}},e.prototype.RaiseMessage=function(e,t){void 0===t&&(t=null);var n=this.ListenerDictionary[e];null!=n&&n.forEach(function(e){e(t)})},e}();e.EventMessageBus=S;var b=function(){function t(e,t,n,a){void 0===n&&(n=!1),void 0===a&&(a=!0),this.assetContainer=null,this.prefabName=null,this.makeNewMaterials=!1,this.cloneAnimations=!0,this.AvailableInstances=[],this.assetContainer=e,this.prefabName=t,this.makeNewMaterials=n,this.cloneAnimations=a}return t.prototype.GetInstance=function(t,n){void 0===t&&(t=null),void 0===n&&(n=null);var a=this.AvailableInstances.length>0?this.AvailableInstances.pop():this.CreateNewInstance();return null!=a&&(null!=t?a.position.copyFrom(t):a.position.set(0,0,0),null!=n?null!=a.rotationQuaternion?a.rotationQuaternion.copyFrom(n):a.rotationQuaternion=n.clone():null!=a.rotationQuaternion?a.rotationQuaternion.set(0,0,0,1):a.rotationQuaternion=new e.Quaternion(0,0,0,1),a.setEnabled(!0)),a},t.prototype.ReturnInstance=function(t){null!=t&&(t.setEnabled(!1),t.position.set(0,0,0),null!=t.rotationQuaternion?t.rotationQuaternion.set(0,0,0,1):t.rotationQuaternion=new e.Quaternion(0,0,0,1),t.name=this.prefabName+".Unassigned",this.AvailableInstances.push(t))},t.prototype.PrePopulatePool=function(e){for(var t=0;t<e;t++){var n=this.CreateNewInstance();null!=n&&this.ReturnInstance(n)}},t.prototype.CreateNewInstance=function(){var t=null;return null!=this.assetContainer&&null!=this.prefabName&&""!==this.prefabName&&(t=e.SceneManager.InstantiatePrefab(this.assetContainer,this.prefabName,this.prefabName+".Instance",this.makeNewMaterials,this.cloneAnimations)),t},t}();e.PrefabObjectPool=b;var T=function(){function t(){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(t.prototype,"hasHit",{get:function(){return this._hit},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hitPoint",{get:function(){return this._hitPoint},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hitNormal",{get:function(){return this._hitNormal},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hitDistance",{get:function(){return this._hitDistance},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"collisionObject",{get:function(){return this._collisionObject},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rayDestination",{get:function(){return this._dest},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rayOrigin",{get:function(){return this._origin},enumerable:!1,configurable:!0}),t.prototype.reset=function(e,t){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(t)},t.prototype.update=function(t,n,a,i,r,o,s,l){void 0===l&&(l=null),this._hit=t,this._hitPoint.set(n,a,i),this._hitNormal.set(r,o,s),this._hitDistance=e.Vector3.Distance(this._origin,this.hitPoint),this._collisionObject=l},t}();e.RaycastHitResult=T;var C=function(){function t(e,t,n,a){void 0===n&&(n=0),void 0===a&&(a=.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=t,this._pointType=n,this._pointSize=a}return Object.defineProperty(t.prototype,"pointMesh",{get:function(){return this._pointMesh;
- },enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"linesMesh",{get:function(){return this._linesMesh},enumerable:!1,configurable:!0}),t.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)},t.prototype.hidePoint=function(e){void 0===e&&(e=!0),null!=this._pointMesh&&(this._pointMesh.isVisible=!e)},t.prototype.drawPoint=function(t){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(t))},t.prototype.drawLine=function(t,n){void 0===n&&(n=null),null==this._linesMesh?(this._numPoints=t.length,this._linesMesh=e.MeshBuilder.CreateLines(this._linesName,{points:t,updatable:!0},this._babylonScene),null!=n&&(this._linesMesh.color=n),this._linesMesh.refreshBoundingInfo(!1)):t.length===this._numPoints?(this._linesMesh=e.MeshBuilder.CreateLines(this._linesName,{points:t,instance:this._linesMesh},this._babylonScene),null!=n&&(this._linesMesh.color=n),this._linesMesh.refreshBoundingInfo(!1)):e.Tools.Warn("Dynamic line mesh point count mismatch for "+this._linesName)},t}();e.LinesMeshRenderer=C;var A=function(){function t(){}return t.IsLayerMasked=function(e,t){return 0!=(e&1<<t)},t.GetLoadingState=function(){return e.Utilities.LoadingState},t.MoveTowardsVector2=function(t,n,a){var i=new e.Vector2(0,0);return e.Utilities.MoveTowardsVector2ToRef(t,n,a,i),i},t.MoveTowardsVector2ToRef=function(e,t,n,a){var i=t.x-e.x,r=t.y-e.y,o=i*i+r*r;if(0==o||n>=0&&o<=n*n)a.set(t.x,t.y);else{var s=Math.sqrt(o);a.set(e.x+i/s*n,e.y+r/s*n)}},t.MoveTowardsVector3=function(t,n,a){var i=new e.Vector3(0,0,0);return e.Utilities.MoveTowardsVector3ToRef(t,n,a,i),i},t.MoveTowardsVector3ToRef=function(e,t,n,a){var i=t.x-e.x,r=t.y-e.y,o=t.z-e.z,s=i*i+r*r+o*o;if(0==s||s<=n*n)a.set(t.x,t.y,t.z);else{var l=Math.sqrt(s);a.set(e.x+i/l*n,e.y+r/l*n,e.z+o/l*n)}},t.MoveTowardsVector4=function(t,n,a){var i=new e.Vector4(0,0,0,0);return e.Utilities.MoveTowardsVector4ToRef(t,n,a,i),i},t.MoveTowardsVector4ToRef=function(e,t,n,a){var i=t.x-e.x,r=t.y-e.y,o=t.z-e.z,s=t.w-e.w,l=i*i+r*r+o*o+s*s;if(0==l||n>=0&&l<=n*n)a.set(t.x,t.y,t.z,t.w);else{var u=Math.sqrt(l);a.set(e.x+i/u*n,e.y+r/u*n,e.z+o/u*n,e.w+s/u*n)}},t.ClampMagnitudeVector2=function(t,n){var a=new e.Vector2(0,0);return e.Utilities.ClampMagnitudeVector2ToRef(t,n,a),a},t.ClampMagnitudeVector2ToRef=function(e,t,n){var a=e.lengthSquared();if(a>t*t){var i=Math.sqrt(a),r=e.x/i,o=e.y/i;n.set(r*t,o*t)}},t.ClampMagnitudeVector3=function(t,n){var a=new e.Vector3(0,0,0);return e.Utilities.ClampMagnitudeVector3ToRef(t,n,a),a},t.ClampMagnitudeVector3ToRef=function(e,t,n){var a=e.lengthSquared();if(a>t*t){var i=Math.sqrt(a),r=e.x/i,o=e.y/i,s=e.z/i;n.set(r*t,o*t,s*t)}},t.ZeroPad=function(e,t){var n=t-e.toString().length+1;return Array(+(n>0&&n)).join("0")+e},t.LerpLog=function(e,t,n){var a=Math.min(Math.max(n,0),1),i=Math.sin(a*Math.PI*.5);return e+(t-e)*i},t.LerpExp=function(e,t,n){var a=Math.min(Math.max(n,0),1),i=1-Math.cos(a*Math.PI*.5);return e+(t-e)*i},t.LerpClamp=function(e,t,n){var a=Math.min(Math.max(n,0),1);return e+(t-e)*a},t.LerpUnclamp=function(e,t,n){return e+(t-e)*n},t.GetAngle=function(t,n){var a=Math.sqrt(t.lengthSquared()*n.lengthSquared());if(a<e.System.EpsilonNormalSqrt)return 0;var i=e.Scalar.Clamp(e.Vector3.Dot(t,n)/a,-1,1);return Math.acos(i)*e.System.Rad2Deg},t.ClampAngle=function(t,n,a){var i=t;do i<-360&&(i+=360),i>360&&(i-=360);while(i<-360||i>360);return e.Scalar.Clamp(i,n,a)},t.SmoothDamp=function(t,n,a,i,r,o){if(!o)return 0;var s=t-n,l=Math.max(1e-4,a),u=2/l,c=u*r,h=1/(1+c+.48*c*c+.235*c*c*c),m=n,p=i*l;s=e.Scalar.Clamp(s,-p,p);var d=t-s,g=(o.x+u*s)*r;o.x=(o.x-u*g)*h;var f=d+(s+g)*h;return m-t>0==f>m&&(f=m,o.x=(f-m)/r),f},t.SmoothDampAngle=function(t,n,a,i,r,o){var s=t+e.Scalar.DeltaAngle(t,n);return e.Utilities.SmoothDamp(t,s,a,i,r,o)},t.SmoothDampVector2=function(t,n,a,i,r,o){var s=new e.Vector2(0,0);return e.Utilities.SmoothDampVector2ToRef(t,n,a,i,r,o,s),s},t.SmoothDampVector2ToRef=function(e,t,n,a,i,r,o){n=Math.max(1e-4,n);var s=2/n,l=s*i,u=1/(1+l+.48*l*l+.235*l*l*l),c=e.x-t.x,h=e.y-t.y,m=t.clone(),p=a*n,d=p*p,g=c*c+h*h;if(g>d){var f=Math.sqrt(g);c=c/f*p,h=h/f*p}t.x=e.x-c,t.y=e.y-h;var y=(r.x+s*c)*i,_=(r.y+s*h)*i;r.x=(r.x-s*y)*u,r.y=(r.y-s*_)*u;var v=t.x+(c+y)*u,M=t.y+(h+_)*u,S=m.x-e.x,b=m.y-e.y,T=v-m.x,C=M-m.y;S*T+b*C>0&&(v=m.x,M=m.y,r.x=(v-m.x)/i,r.y=(M-m.y)/i),o.set(v,M)},t.SmoothDampVector3=function(t,n,a,i,r,o){var s=new e.Vector3(0,0,0);return e.Utilities.SmoothDampVector3ToRef(t,n,a,i,r,o,s),s},t.SmoothDampVector3ToRef=function(e,t,n,a,i,r,o){var s=0,l=0,u=0;n=Math.max(1e-4,n);var c=2/n,h=c*i,m=1/(1+h+.48*h*h+.235*h*h*h),p=e.x-t.x,d=e.y-t.y,g=e.z-t.z,f=t.clone(),y=a*n,_=y*y,v=p*p+d*d+g*g;if(v>_){var M=Math.sqrt(v);p=p/M*y,d=d/M*y,g=g/M*y}t.x=e.x-p,t.y=e.y-d,t.z=e.z-g;var S=(r.x+c*p)*i,b=(r.y+c*d)*i,T=(r.z+c*g)*i;r.x=(r.x-c*S)*m,r.y=(r.y-c*b)*m,r.z=(r.z-c*T)*m,s=t.x+(p+S)*m,l=t.y+(d+b)*m,u=t.z+(g+T)*m;var C=f.x-e.x,A=f.y-e.y,P=f.z-e.z,x=s-f.x,O=l-f.y,w=u-f.z;C*x+A*O+P*w>0&&(s=f.x,l=f.y,u=f.z,r.x=(s-f.x)/i,r.y=(l-f.y)/i,r.z=(u-f.z)/i),o.set(s,l,u)},t.ToMatrix=function(t,n,a){return e.Matrix.RotationYawPitchRoll(e.Tools.ToRadians(n),e.Tools.ToRadians(t),e.Tools.ToRadians(a))},t.ToMatrixToRef=function(t,n,a,i){e.Matrix.RotationYawPitchRollToRef(e.Tools.ToRadians(n),e.Tools.ToRadians(t),e.Tools.ToRadians(a),i)},t.FastMatrixLerp=function(t,n,a,i){e.Matrix.LerpToRef(t,n,a,i)},t.FastMatrixSlerp=function(t,n,a,i){e.Matrix.DecomposeLerpToRef(t,n,a,i)},t.ToEuler=function(t){var n=t.toEulerAngles();return n.x=e.Tools.ToDegrees(n.x),n.y=e.Tools.ToDegrees(n.y),n.z=e.Tools.ToDegrees(n.z),n},t.ToEulerToRef=function(t,n){t.toEulerAnglesToRef(n),n.x=e.Tools.ToDegrees(n.x),n.y=e.Tools.ToDegrees(n.y),n.z=e.Tools.ToDegrees(n.z)},t.FromEuler=function(t,n,a){return e.Quaternion.FromEulerAngles(e.Tools.ToRadians(t),e.Tools.ToRadians(n),e.Tools.ToRadians(a))},t.FromEulerToRef=function(t,n,a,i){e.Quaternion.FromEulerAnglesToRef(e.Tools.ToRadians(t),e.Tools.ToRadians(n),e.Tools.ToRadians(a),i)},t.QuaternionDiff=function(t,n){var a=new e.Quaternion(0,0,0,0);return e.Utilities.QuaternionDiffToRef(t,n,a),a},t.QuaternionDiffToRef=function(t,n,a){e.Quaternion.InverseToRef(t,e.Utilities.TempQuaternion),e.Utilities.TempQuaternion.multiplyToRef(n,a)},t.RotateVector=function(t,n){var a=2*(n.y*t.z-n.z*t.y),i=2*(n.z*t.x-n.x*t.z),r=2*(n.x*t.y-n.y*t.x);return new e.Vector3(t.x+n.w*a+(n.y*r-n.z*i),t.y+n.w*i+(n.z*a-n.x*r),t.z+n.w*r+(n.x*i-n.y*a))},t.RotateVectorToRef=function(e,t,n){var a=2*(t.y*e.z-t.z*e.y),i=2*(t.z*e.x-t.x*e.z),r=2*(t.x*e.y-t.y*e.x);n.x=e.x+t.w*a+(t.y*r-t.z*i),n.y=e.y+t.w*i+(t.z*a-t.x*r),n.z=e.z+t.w*r+(t.x*i-t.y*a)},t.LookRotation=function(t){var n=e.Quaternion.Zero();return e.Utilities.LookRotationToRef(t,n),n},t.LookRotationToRef=function(t,n){e.Utilities.TempMatrix.reset(),e.Matrix.LookAtLHToRef(e.Utilities.ZeroVector,t,e.Utilities.UpVector,e.Utilities.TempMatrix),e.Utilities.TempMatrix.invert(),e.Quaternion.FromRotationMatrixToRef(e.Utilities.TempMatrix,n)},t.Vector3Rad2Deg=function(t){var n=e.Vector3.Zero();return e.Utilities.Vector3Rad2DegToRef(t,n),n},t.Vector3Rad2DegToRef=function(t,n){n.x=e.Tools.ToDegrees(t.x),n.y=e.Tools.ToDegrees(t.y),n.z=e.Tools.ToDegrees(t.z)},t.MultiplyQuaternionByVector=function(t,n){var a=new e.Vector3(0,0,0);return e.Utilities.MultiplyQuaternionByVectorToRef(t,n,a),a},t.MultiplyQuaternionByVectorToRef=function(e,t,n){var a=t.x,i=t.y,r=t.z,o=e.x,s=e.y,l=e.z,u=e.w,c=u*a+s*r-l*i,h=u*i+l*a-o*r,m=u*r+o*i-s*a,p=-o*a-s*i-l*r;n.x=c*u+p*-o+h*-l-m*-s,n.y=h*u+p*-s+m*-o-c*-l,n.z=m*u+p*-l+c*-s-h*-o},t.ValidateTransformRotation=function(e){null!=e.rotationQuaternion&&(e.rotation=e.rotationQuaternion.toEulerAngles(),e.rotationQuaternion=null)},t.ValidateTransformQuaternion=function(t){null==t.rotationQuaternion&&null!=t.rotation&&(t.rotationQuaternion=e.Quaternion.FromEulerAngles(t.rotation.x,t.rotation.y,t.rotation.z),t.rotation.set(0,0,0))},t.GetKeyboardInputValue=function(t,n,a){var i=a;return e.UserInputOptions.KeyboardSmoothing===!0&&(i=e.Scalar.MoveTowards(n,a,e.UserInputOptions.KeyboardMoveSensibility*e.SceneManager.GetDeltaSeconds(t)),Math.abs(i)<e.UserInputOptions.KeyboardMoveDeadZone&&(i=0)),i},t.DownloadEnvironment=function(t,n,a){void 0===n&&(n=null),void 0===a&&(a=null),e.EnvironmentTextureTools.CreateEnvTextureAsync(t).then(function(a){var i=t.name||"Environment",r=new Blob([a],{type:"octet/stream"});e.Tools.Download(r,i+".env"),null!=n&&n()})["catch"](function(e){console.error(e),null!=a&&a()})},t.HasOwnProperty=function(e,t){return null!=e&&null!=t&&""!==t&&t in e},t.GetFilenameFromUrl=function(e){return e.substring(e.lastIndexOf("/")+1)},t.GetUrlParameter=function(e){var t=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]"),n=new RegExp("[\\?&]"+t+"=([^&#]*)"),a=n.exec(window.location.search);return null!==a?decodeURIComponent(a[1].replace(/\+/g," ")):null},t.CreateFontFace=function(t,n,a,i,r){void 0===i&&(i=null),void 0===r&&(r=null);var o=e.SceneManager.GetRootUrl(t)+a.filename,s=new FontFace(n,'url("'+o+'") format("'+a.format+'")',i);return null!=s&&(document.fonts.add(s),null!=r&&s.loaded.then(function(e){r(e)},function(e){r(null)})),s},t.CreateFontFaceElement=function(t,n,a,i){void 0===i&&(i=null);var r=document.createElement("style"),o=e.SceneManager.GetRootUrl(t)+a.filename;return r.type="text/css",document.getElementsByTagName("head")[0].appendChild(r),null!=i&&""!==i?r.innerHTML='@font-face { font-family: "'+n+'"; src: url("'+o+'") format("'+a.format+'"); '+i+" }":r.innerHTML='@font-face { font-family: "'+n+'"; src: url("'+o+'") format("'+a.format+'"); }',r},t.PrintToScreen=function(t,n){if(void 0===n&&(n="white"),e.Utilities.PrintElement=document.getElementById("print"),null==e.Utilities.PrintElement){var a=document.createElement("div");a.id="print",a.style.position="absolute",a.style.left="6px",a.style.bottom="3px",a.style.fontSize="12px",a.style.zIndex="10000",a.style.color="#0c0",document.body.appendChild(a),e.Utilities.PrintElement=a}null!=e.Utilities.PrintElement&&e.Utilities.PrintElement.innerHTML!==t&&(e.Utilities.PrintElement.style.color!==n&&(e.Utilities.PrintElement.style.color=n),e.Utilities.PrintElement.innerHTML=t)},t.AddMeshVerts=function(t,n,a,i,r){if(void 0===i&&(i=!0),void 0===r&&(r=!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)),!t.addTriangle){var o=a;return e.Tools.Warn("No AddTriangle Function For Triangle Mesh On: "+o.name),0}var s=0;if(a&&a.getIndices&&a.getWorldMatrix&&a.getChildMeshes){var l=a.getIndices();l||(l=[]);var u=a.getVerticesData(e.VertexBuffer.PositionKind);u||(u=[]);var c=a.getVerticesData(e.VertexBuffer.NormalKind);c||(c=[]),a.computeWorldMatrix(!1);for(var h=l.length/3,m=0;m<h;m++){for(var p=[],d=[],g=0;g<3;g++){var f=new e.Vector3(u[3*l[3*m+g]+0],u[3*l[3*m+g]+1],u[3*l[3*m+g]+2]),y=new e.Vector3(c[3*l[3*m+g]+0],c[3*l[3*m+g]+1],c[3*l[3*m+g]+2]);i===!0&&(e.Matrix.ScalingToRef(a.scaling.x,a.scaling.y,a.scaling.z,e.Utilities.TmpHullMatrix),f=e.Vector3.TransformCoordinates(f,e.Utilities.TmpHullMatrix));var _=void 0,v=void 0;0==g?(_=e.Utilities.TmpAmmoVectorA,v=e.Utilities.TmpAmmoNormalA):1==g?(_=e.Utilities.TmpAmmoVectorB,v=e.Utilities.TmpAmmoNormalB):(_=e.Utilities.TmpAmmoVectorC,v=e.Utilities.TmpAmmoNormalC),_.setValue(f.x,f.y,f.z),v.setValue(y.x,y.y,y.z),p.push(_),d.push(v)}var M=!1;r===!0?t.addTriangleNormals(p[0],p[1],p[2],d[0],d[1],d[2],M):t.addTriangle(p[0],p[1],p[2],M),s++}a.getChildMeshes().forEach(function(a){s+=e.Utilities.AddMeshVerts(t,n,a,i,r)})}return s},t.AddHullVerts=function(t,n,a,i){if(void 0===i&&(i=!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)),!t.addPoint){var r=a;return e.Tools.Warn("No AddPoint Function For Convex Hull Shape On: "+r.name),0}var o=0;if(a&&a.getIndices&&a.getWorldMatrix&&a.getChildMeshes){var s=a.getIndices();s||(s=[]);var l=a.getVerticesData(e.VertexBuffer.PositionKind);l||(l=[]),a.computeWorldMatrix(!1);for(var u=s.length/3,c=0;c<u;c++){for(var h=[],m=0;m<3;m++){var p=void 0,d=new e.Vector3(l[3*s[3*c+m]+0],l[3*s[3*c+m]+1],l[3*s[3*c+m]+2]);i===!0&&(e.Matrix.ScalingToRef(a.scaling.x,a.scaling.y,a.scaling.z,e.Utilities.TmpHullMatrix),d=e.Vector3.TransformCoordinates(d,e.Utilities.TmpHullMatrix)),p=0==m?e.Utilities.TmpAmmoVectorA:1==m?e.Utilities.TmpAmmoVectorB:e.Utilities.TmpAmmoVectorC,p.setValue(d.x,d.y,d.z),h.push(p)}t.addPoint(h[0],!0),t.addPoint(h[1],!0),t.addPoint(h[2],!0),o++}a.getChildMeshes().forEach(function(a){o+=e.Utilities.AddHullVerts(t,n,a,i)})}return o},t.CreateImpostorCustomShape=function(t,n,a,i,r){void 0===i&&(i=!1),void 0===r&&(r=0),null==e.Utilities.TmpAmmoVectorD&&(e.Utilities.TmpAmmoVectorD=new Ammo.btVector3(0,0,0));var o=null,s=n.object,l=n.object;if(a===e.PhysicsImpostor.MeshImpostor){if(0!==n.getParam("mass")&&(n.setParam("mass",0),e.Tools.Warn("Mesh impostor not supported for non-static object: "+l.name+". Forced to static mesh impostor")),0==n.getParam("mass")){var u=null,c=0;null!=Ammo.btSmoothTriangleMesh?(u=new Ammo.btSmoothTriangleMesh,n._pluginData.toDispose.push(u),c=e.Utilities.AddMeshVerts(u,s,s,!0,!0)):(u=new Ammo.btTriangleMesh,n._pluginData.toDispose.push(u),c=e.Utilities.AddMeshVerts(u,s,s,!0,!1)),o=0==c?new Ammo.btCompoundShape:new Ammo.btBvhTriangleMeshShape(u)}return o}if(a===e.PhysicsImpostor.ConvexHullImpostor){var h=new Ammo.btConvexHullShape,c=e.Utilities.AddHullVerts(h,s,s,!0);return 0==c?(n._pluginData.toDispose.push(h),o=new Ammo.btCompoundShape):o=h,o.setMargin(0),o}var m=l,p=null!=l.metadata&&l.metadata.unity&&l.metadata.unity.collision&&l.metadata.unity.collision.center?e.Utilities.ParseVector3(l.metadata.unity.collision.center):new e.Vector3(0,0,0),d=new e.Quaternion(0,0,0,1);switch(a){case e.PhysicsImpostor.BoxImpostor:var g=null!=l.metadata&&l.metadata.unity&&l.metadata.unity.collision&&l.metadata.unity.collision.boxsize?e.Utilities.ParseVector3(l.metadata.unity.collision.boxsize):new e.Vector3(1,1,1);if(g.x*=m.scaling.x,g.y*=m.scaling.y,g.z*=m.scaling.z,i===!0&&null==l._debugCollider){var f=l.name+".Debug",y=e.MeshBuilder.CreateBox(f,{width:g.x,height:g.y,depth:g.z},t);y.position.set(0,0,0),y.rotationQuaternion=l.rotationQuaternion.clone(),y.setParent(l),y.position.copyFrom(p),y.visibility=r,y.material=e.Utilities.GetColliderMaterial(t),y.checkCollisions=!1,y.isPickable=!1,l._debugCollider=y}e.Utilities.TmpAmmoVectorD.setValue(g.x/2,g.y/2,g.z/2),o=new Ammo.btBoxShape(e.Utilities.TmpAmmoVectorD);break;case e.PhysicsImpostor.SphereImpostor:var _=null!=l.metadata&&l.metadata.unity&&l.metadata.unity.collision&&l.metadata.unity.collision.sphereradius?l.metadata.unity.collision.sphereradius:.5;if(_*=Math.max(Math.abs(m.scaling.x),Math.abs(m.scaling.y),Math.abs(m.scaling.z)),i===!0&&null==l._debugCollider){var v=null!=l.metadata&&l.metadata.unity&&l.metadata.unity.collision&&l.metadata.unity.collision.segments?l.metadata.unity.collision.segments:24,f=l.name+".Debug",M=e.MeshBuilder.CreateSphere(f,{segments:v,diameter:2*_},t);M.position.set(0,0,0),M.rotationQuaternion=l.rotationQuaternion.clone(),M.setParent(l),M.position.copyFrom(p),M.visibility=r,M.material=e.Utilities.GetColliderMaterial(t),M.checkCollisions=!1,M.isPickable=!1,l._debugCollider=M}o=new Ammo.btSphereShape(_);break;case e.PhysicsImpostor.CapsuleImpostor:var S=null!=l.metadata&&l.metadata.unity&&l.metadata.unity.collision&&l.metadata.unity.collision.capsulesize?e.Utilities.ParseVector3(l.metadata.unity.collision.capsulesize):new e.Vector3(.5,2,1);if(S.x*=Math.max(Math.abs(m.scaling.x),Math.abs(m.scaling.z)),S.y*=m.scaling.y,0!==S.z&&2!==S.z||(0===S.z?e.Utilities.FromEulerToRef(0,0,90,d):2===S.z&&e.Utilities.FromEulerToRef(90,0,0,d)),i===!0&&null==l._debugCollider){var f=l.name+".Debug",v=null!=l.metadata&&l.metadata.unity&&l.metadata.unity.collision&&l.metadata.unity.collision.segments?l.metadata.unity.collision.segments:24,b=e.MeshBuilder.CreateCapsule(f,{tessellation:v,subdivisions:8,capSubdivisions:16,height:S.y,radius:S.x},t);b.position.set(0,0,0),b.rotationQuaternion=l.rotationQuaternion.clone(),b.setParent(l),b.position.copyFrom(p),b.rotationQuaternion=d.clone(),b.visibility=r,b.material=e.Utilities.GetColliderMaterial(t),b.checkCollisions=!1,b.isPickable=!1,l._debugCollider=b}o=new Ammo.btCapsuleShape(S.x,S.y/2);break;default:e.Tools.Warn("The impostor type ("+a+") is not currently supported by the babylon toolkit for: "+l.name)}var T=new Ammo.btCompoundShape;if(null!=o){p.x*=m.scaling.x,p.y*=m.scaling.y,p.z*=m.scaling.z;var C=new Ammo.btVector3(p.x,p.y,p.z),A=new Ammo.btQuaternion(d.x,d.y,d.z,d.w),P=new Ammo.btTransform;P.setIdentity(),P.setOrigin(C),P.setRotation(A),T.addChildShape(P,o)}return T},t.ShowDebugColliders=function(){return null!=window.showDebugColliders&&window.showDebugColliders},t.ColliderVisibility=function(){return null!=window.colliderVisibility?window.colliderVisibility:0},t.CollisionWireframe=function(){return null!=window.collisionWireframe&&window.collisionWireframe},t.GetColliderMaterial=function(t){var n="Collider-Material",a=t.getMaterialByName(n);if(null==a){var i=new e.PBRMaterial(n,t);i.albedoColor=new e.Color3(0,.75,0),i.wireframe=e.Utilities.CollisionWireframe(),i.unlit=!0,a=i}return a},t.GetDirectTargetAngle=function(t,n){return e.Utilities.TempVector3.set(0,0,0),e.Utilities.InverseTransformPointToRef(t,n,e.Utilities.TempVector3),Math.atan2(e.Utilities.TempVector3.x,e.Utilities.TempVector3.z)},t.GetSmoothTargetAngle=function(t,n){return e.Utilities.TempVector3.set(0,0,0),e.Utilities.InverseTransformPointToRef(t,n,e.Utilities.TempVector3),e.Utilities.TempVector3.x/e.Utilities.TempVector3.length()},t.CalculatCatmullRom=function(t,n,a,i,r){var o=new e.Vector3(0,0,0);return e.Utilities.CalculatCatmullRomToRef(t,n,a,i,r,o),o},t.CalculatCatmullRomToRef=function(e,t,n,a,i,r){},t.StartsWith=function(e,t){return 0===e.lastIndexOf(t,0)},t.EndsWith=function(e,t){return e.indexOf(t,e.length-t.length)!==-1},t.ReplaceAll=function(e,t,n){return e.replace(new RegExp(t,"g"),n)},t.IsNullOrEmpty=function(e){return null==e||""===e},t.SafeStringPush=function(e,t){e.indexOf(t)===-1&&e.push(t)},t.ParseColor3=function(t,n,a){void 0===n&&(n=null),void 0===a&&(a=!1);var i=null;return i=null!=t&&null!=t.r&&null!=t.g&&null!=t.b?a===!0?new e.Color3(t.r,t.g,t.b).toLinearSpace():new e.Color3(t.r,t.g,t.b):n},t.ParseColor4=function(t,n,a){void 0===n&&(n=null),void 0===a&&(a=!1);var i=null;if(null!=t&&null!=t.r&&null!=t.g&&null!=t.b){var r=null!=t.a?t.a:1;i=a===!0?new e.Color4(t.r,t.g,t.b,r).toLinearSpace():new e.Color4(t.r,t.g,t.b,r)}else i=n;return i},t.ParseVector2=function(t,n){void 0===n&&(n=null);var a=null;return a=null!=t&&null!=t.x&&null!=t.y?new e.Vector2(t.x,t.y):n},t.ParseVector3=function(t,n){void 0===n&&(n=null);var a=null;return a=null!=t&&null!=t.x&&null!=t.y&&null!=t.z?new e.Vector3(t.x,t.y,t.z):n},t.ParseVector4=function(t,n){void 0===n&&(n=null);var a=null;return a=null!=t&&null!=t.x&&null!=t.y&&null!=t.z&&null!=t.w?new e.Vector4(t.x,t.y,t.z,t.w):n},t.ParseSound=function(t,n,a,i,r){var o=null;if(null!=t&&null!=t.filename&&""!==t.filename){var s=e.SceneManager.GetRootUrl(n),l=t.filename;o=new e.Sound(a,s+l,n,i,r)}return o},t.ParseTexture=function(t,n,a,i,r,o,s,l,u,c){var h=null;if(null!=t&&null!=t.filename&&""!==t.filename){var m=e.SceneManager.GetRootUrl(n),p=t.filename;h=new e.Texture(m+p,n,a,i,r,o,s,l,u,c)}return h},t.ParseCubemap=function(t,n){var a=null;if(null!=t&&null!=t.info){var i=e.SceneManager.GetRootUrl(n),r=i+t.info.rooturl;a=e.CubeTexture.Parse(t.info,n,r),null!=a&&(a.gammaSpace=!1)}return a},t.ParseTextAsset=function(e,t){void 0===t&&(t=null);var n=null;return n=null!=e&&null!=e.base64&&""!==e.base64?window.atob(e.base64):t},t.ParseJsonAsset=function(t,n,a){void 0===n&&(n=null),void 0===a&&(a=null);var i=e.Utilities.ParseTextAsset(t,n);return null!=i&&""!==i?JSON.parse(i,a):null},t.ParseTransformByID=function(t,n,a){void 0===a&&(a=null);var i=null;return i=null!=t&&null!=t.id?e.SceneManager.GetTransformNodeByID(n,t.id):a},t.ParseTransformByName=function(t,n,a){void 0===a&&(a=null);var i=null;return i=null!=t&&null!=t.id?e.SceneManager.GetTransformNode(n,t.id):a},t.ParseChildTransform=function(t,n,a){void 0===a&&(a=null);var i=null;return i=null!=n&&null!=n.name?e.SceneManager.FindChildTransformNode(t,n.name,e.SearchType.IndexOf,!1):a},t.GetAbsolutePosition=function(t,n,a){return void 0===n&&(n=null),void 0===a&&(a=!0),e.Utilities.TransformPoint(t,n||e.Utilities.ZeroVector,a)},t.GetAbsolutePositionToRef=function(t,n,a,i){void 0===a&&(a=null),void 0===i&&(i=!0),e.Utilities.TransformPointToRef(t,a||e.Utilities.ZeroVector,n,i)},t.TransformPoint=function(t,n,a){return void 0===a&&(a=!0),a===!0&&t.computeWorldMatrix(),e.Vector3.TransformCoordinates(n,t.getWorldMatrix())},t.InverseTransformPoint=function(t,n,a){return void 0===a&&(a=!0),a===!0&&t.computeWorldMatrix(),e.Utilities.TempMatrix.reset(),t.getWorldMatrix().invertToRef(e.Utilities.TempMatrix),e.Vector3.TransformCoordinates(n,e.Utilities.TempMatrix)},t.TransformPointToRef=function(t,n,a,i){return void 0===i&&(i=!0),i===!0&&t.computeWorldMatrix(),e.Vector3.TransformCoordinatesToRef(n,t.getWorldMatrix(),a)},t.InverseTransformPointToRef=function(t,n,a,i){return void 0===i&&(i=!0),i===!0&&t.computeWorldMatrix(),e.Utilities.TempMatrix.reset(),t.getWorldMatrix().invertToRef(e.Utilities.TempMatrix),e.Vector3.TransformCoordinatesToRef(n,e.Utilities.TempMatrix,a)},t.TransformDirection=function(t,n,a){return void 0===a&&(a=!0),a===!0&&t.computeWorldMatrix(),e.Vector3.TransformNormal(n,t.getWorldMatrix())},t.InverseTransformDirection=function(t,n,a){return void 0===a&&(a=!0),a===!0&&t.computeWorldMatrix(),e.Utilities.TempMatrix.reset(),t.getWorldMatrix().invertToRef(e.Utilities.TempMatrix),e.Vector3.TransformNormal(n,e.Utilities.TempMatrix)},t.TransformDirectionToRef=function(t,n,a,i){return void 0===i&&(i=!0),i===!0&&t.computeWorldMatrix(),e.Vector3.TransformNormalToRef(n,t.getWorldMatrix(),a)},t.InverseTransformDirectionToRef=function(t,n,a,i){return void 0===i&&(i=!0),i===!0&&t.computeWorldMatrix(),e.Utilities.TempMatrix.reset(),t.getWorldMatrix().invertToRef(e.Utilities.TempMatrix),e.Vector3.TransformNormalToRef(n,e.Utilities.TempMatrix,a)},t.RecomputeCenterPivotPoint=function(t){var n=t.getBoundingInfo().boundingSphere.center;t.setPivotMatrix(e.Matrix.Translation(-n.x,-n.y,-n.z))},t.GetDirectionVector=function(e,t){return e.getDirection(t)},t.GetDirectionVectorToRef=function(e,t,n){e.getDirectionToRef(t,n)},t.GetForwardVector=function(t){return t.getDirection(e.Vector3.Forward())},t.GetForwardVectorToRef=function(t,n){t.getDirectionToRef(e.Vector3.Forward(),n)},t.GetRightVector=function(t){return t.getDirection(e.Vector3.Right())},t.GetRightVectorToRef=function(t,n){t.getDirectionToRef(e.Vector3.Right(),n)},t.GetUpVector=function(t){return t.getDirection(e.Vector3.Up())},t.GetUpVectorToRef=function(t,n){t.getDirectionToRef(e.Vector3.Up(),n)},t.BlendFloatValue=function(t,n,a){var i=e.Scalar.Clamp(a,0,1);return i>0?e.Scalar.Lerp(t,n,i):t},t.BlendVector2Value=function(t,n,a){var i=e.Scalar.Clamp(a,0,1);if(i>0){var r=e.Vector2.Lerp(t,n,i);t.copyFrom(r)}},t.BlendVector3Value=function(t,n,a){var i=e.Scalar.Clamp(a,0,1);i>0&&e.Vector3.LerpToRef(t,n,i,t)},t.BlendQuaternionValue=function(t,n,a){var i=e.Scalar.Clamp(a,0,1);i>0&&e.Quaternion.SlerpToRef(t,n,i,t)},t.SetAnimationTargetProperty=function(e,t){null!=e&&(e.targetProperty=t,e.targetPropertyPath=e.targetProperty.split("."))},t.SampleAnimationFloat=function(t,n){var a=0;if(null!=t&&t.dataType===e.Animation.ANIMATIONTYPE_FLOAT){var i=t.getKeys();n<i[0].frame?n=i[0].frame:n>i[i.length-1].frame&&(n=i[i.length-1].frame),null==t._state&&(t._state={key:0,repeatCount:0,loopMode:e.Animation.ANIMATIONLOOPMODE_CYCLE,workValue:e.Matrix.Zero()}),a=e.Utilities.InterpolateAnimation(t,n,t._state)}return a},t.SampleAnimationVector2=function(t,n){var a=null;if(null!=t&&t.dataType===e.Animation.ANIMATIONTYPE_VECTOR2){var i=t.getKeys();n<i[0].frame?n=i[0].frame:n>i[i.length-1].frame&&(n=i[i.length-1].frame),null==t._state&&(t._state={key:0,repeatCount:0,loopMode:e.Animation.ANIMATIONLOOPMODE_CYCLE,workValue:e.Matrix.Zero()}),a=e.Utilities.InterpolateAnimation(t,n,t._state)}return a},t.SampleAnimationVector3=function(t,n){var a=null;if(null!=t&&t.dataType===e.Animation.ANIMATIONTYPE_VECTOR3){var i=t.getKeys();n<i[0].frame?n=i[0].frame:n>i[i.length-1].frame&&(n=i[i.length-1].frame),null==t._state&&(t._state={key:0,repeatCount:0,loopMode:e.Animation.ANIMATIONLOOPMODE_CYCLE,workValue:e.Matrix.Zero()}),a=e.Utilities.InterpolateAnimation(t,n,t._state)}return a},t.SampleAnimationQuaternion=function(t,n){var a=null;if(null!=t&&t.dataType===e.Animation.ANIMATIONTYPE_QUATERNION){var i=t.getKeys();n<i[0].frame?n=i[0].frame:n>i[i.length-1].frame&&(n=i[i.length-1].frame),null==t._state&&(t._state={key:0,repeatCount:0,loopMode:e.Animation.ANIMATIONLOOPMODE_CYCLE,workValue:e.Matrix.Zero()}),a=e.Utilities.InterpolateAnimation(t,n,t._state)}return a},t.SampleAnimationMatrix=function(t,n){var a=null;if(null!=t&&t.dataType===e.Animation.ANIMATIONTYPE_MATRIX){var i=t.getKeys();n<i[0].frame?n=i[0].frame:n>i[i.length-1].frame&&(n=i[i.length-1].frame),null==t._state&&(t._state={key:0,repeatCount:0,loopMode:e.Animation.ANIMATIONLOOPMODE_CYCLE,workValue:e.Matrix.Zero()}),a=e.Utilities.InterpolateAnimation(t,n,t._state)}return a},t.CreateTweenAnimation=function(t,n,a,i,r,o){void 0===r&&(r=30),void 0===o&&(o=e.Animation.ANIMATIONLOOPMODE_CONSTANT);var s=[];s.push({frame:0,value:a}),s.push({frame:r,value:i});var l=new e.Animation(t,n,r,e.Animation.ANIMATIONTYPE_FLOAT,o);return l.setKeys(s),l},t.GetLastKeyFrameValue=function(e){var t=0;if(null!=e){var n=e.getKeys();if(null!=n&&n.length>0){var a=n[n.length-1];null!=a&&(t=a.frame)}}return t},t.InterpolateAnimation=function(e,t,n){return e._interpolate(t,n)},t.InitializeShaderMaterial=function(t,n){void 0===n&&(n=!0);var a=t,i=e.Utilities.HasOwnProperty(a,"getShaderName")?a.getShaderName():"glsl",r=!!e.Utilities.HasOwnProperty(a,"getAlphaBlending")&&a.getAlphaBlending(),o=!!e.Utilities.HasOwnProperty(a,"getAlphaTesting")&&a.getAlphaTesting(),s=e.Utilities.HasOwnProperty(a,"getDefaultDefines")?a.getDefaultDefines():null,l=e.Utilities.HasOwnProperty(a,"getDefaultAttributes")?a.getDefaultAttributes():null,u=e.Utilities.HasOwnProperty(a,"getDefaultUniforms")?a.getDefaultUniforms():null;(null==s||s.length<=0)&&(s=["#define DIFFUSECOLOR","#define DIFFUSETEXTURE"]),(null==l||l.length<=0)&&(l=["position","normal","uv","uv2","color"]),(null==u||u.length<=0)&&(u=["world","worldView","worldViewProjection","view","projection","viewProjection","diffuseColor","diffuseTexture","diffuseTextureInfos","diffuseTextureMatrix"]);var c={vertex:i,fragment:i},h={needAlphaBlending:r,needAlphaTesting:o,attributes:l,uniforms:u,defines:s,samplers:[],uniformBuffers:[]};a._shaderPath=c,a._options=h,n===!0&&(a.fn_afterBind=a._afterBind,a._afterBind=function(e){var n=t.getScene();if(n.texturesEnabled)for(var i in a._textures){var r=a._textures[i];null!=r&&(a._effect.setFloat2(i+"Infos",r.coordinatesIndex,r.level),a._effect.setMatrix(i+"Matrix",r.getTextureMatrix()))}if(a.fn_afterBind)try{a.fn_afterBind(e)}catch(o){}})},t.WorldToScreenPoint=function(t,n,a){void 0===a&&(a=null);var i=null,r=null!=a?a.viewport:null!=t.activeCamera?t.activeCamera.viewport:null;return null!=r&&(i=e.Vector3.Project(n,e.Matrix.Identity(),t.getTransformMatrix(),r.toGlobal(t.getEngine().getRenderWidth(),t.getEngine().getRenderHeight()))),i},t.ScreenToWorldPoint=function(t,n){return e.Vector3.Unproject(n,t.getEngine().getRenderWidth(),t.getEngine().getRenderHeight(),e.Matrix.Identity(),t.getViewMatrix(),t.getProjectionMatrix())},t.ConvertAmmoVector3=function(t){var n=new e.Vector3(0,0,0);return e.Utilities.ConvertAmmoVector3ToRef(t,n),n},t.ConvertAmmoVector3ToRef=function(e,t){t.set(e.x(),e.y(),e.z())},t.ConvertAmmoQuaternion=function(t){var n=new e.Quaternion(0,0,0,1);return e.Utilities.ConvertAmmoQuaternionToRef(t,n),n},t.ConvertAmmoQuaternionToRef=function(e,t){t.set(e.x(),e.y(),e.z(),e.w())},t.CloneSkeletonPrefab=function(t,n,a,i,r){void 0===r&&(r=null);var o=new e.Skeleton(a,i||a,t);o.needInitialSkinMatrix=n.needInitialSkinMatrix,o.overrideMesh=r||n.overrideMesh;for(var s=0;s<n.bones.length;s++){var l=n.bones[s],u=null,c=l.getParent();if(c){var h=n.bones.indexOf(c);u=o.bones[h]}var m=new e.Bone(l.name,o,u,l.getBaseMatrix().clone(),l.getRestPose().clone());m._index=l._index,m.metadata=l.metadata,l._linkedTransformNode&&m.linkTransformNode(l._linkedTransformNode),e.DeepCopier.DeepCopy(l.animations,m.animations)}var p=o,d=n;if(d._ranges){p._ranges={};for(var g in d._ranges){var f=d._ranges[g];f&&(p._ranges[g]=f.clone())}}return d._isDirty=!0,o},t.GetSceneTransforms=function(e){var t=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==t&&(t=[]),t.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==t&&(t=[]),t.push(e))}),t},t.ParseSceneComponents=function(t,n){if(null!=n&&n.length>0){var a=new e.MetadataParser(t);n.forEach(function(e){a.parseSceneComponents(e)}),a.postProcessSceneComponents()}},t.GetAssetContainerMesh=function(t,n){var a=null,i=n.toLowerCase();if(null==a&&null!=t.meshes&&t.meshes.length>0)for(var r=0;r<t.meshes.length;r++){var o=t.meshes[r];if(o instanceof e.Mesh&&o.name.toLowerCase()===i){a=o;break}}return a},t.GetAssetContainerNode=function(e,t){var n=null,a=t.toLowerCase();if(null==n&&null!=e.transformNodes&&e.transformNodes.length>0)for(var i=0;i<e.transformNodes.length;i++){var r=e.transformNodes[i];if(r.name.toLowerCase()===a){n=r;break}}return n},t.CloneAssetContainerItem=function(t,n,a,i,r){void 0===i&&(i=!1),void 0===r&&(r=!0);var o=null,s={},l={},u={},c=null,h=null,m=[],p=[],d=n.toLowerCase(),g=null,f=function(t,n){n.setEnabled(!0),null==g&&(g=n),s[t.uniqueId]=n.uniqueId,l[n.uniqueId]=n,a&&(n.name=a(t.name)),null!=t.metadata&&null!=t.metadata.unity&&null!=t.metadata.unity.entity&&(n.metadata=e.Utilities.CloneEntityMetadata(t.metadata));var i=null!=n.metadata&&null!=n.metadata.unity&&null!=n.metadata.unity.animator?n.metadata.unity.animator:null;if(null!=i&&""!==i&&(null==c&&(c=[]),c.indexOf(i)<0&&c.push(i),n.metadata.unity.animator=e.Utilities.CreateGuid(),u[i]=n.metadata.unity.animator),t instanceof e.AbstractMesh&&null!=t.skeleton&&(null==h&&(h=[]),h.indexOf(t.skeleton)<0&&h.push(t.skeleton)),n instanceof e.Mesh){var r=n;if(r.morphTargetManager){var o=t.morphTargetManager;r.morphTargetManager=o.clone();for(var m=0;m<o.numTargets;m++){var p=o.getTarget(m),d=r.morphTargetManager.getTarget(m);
- s[p.uniqueId]=d.uniqueId,l[d.uniqueId]=d}}}};if(null==o&&null!=t.transformNodes&&t.transformNodes.length>0)for(var y=0;y<t.transformNodes.length;y++){var _=t.transformNodes[y];if(_.name.toLowerCase()===d){var v=e.Utilities.InstantiateHierarchy(_,null,function(e,t){f(e,t)});if(v){o=v;break}}}if(null==o&&null!=t.meshes&&t.meshes.length>0)for(var M=function(n){var r=t.meshes[n];if(r.name.toLowerCase()===d){var u=e.Utilities.InstantiateHierarchy(r,null,function(e,n){f(e,n);var o=n;if(r.isWorldMatrixFrozen===!0&&o.freezeWorldMatrix&&o.freezeWorldMatrix(),n.material&&o.material)if(i===!0){var u=e.material;if(p.indexOf(u)===-1){var c=u.clone(a?a(u.name):"Clone of "+u.name);if(u.isFrozen===!0&&c.freeze&&c.freeze(),p.push(u),s[u.uniqueId]=c.uniqueId,l[c.uniqueId]=c,"MultiMaterial"===u.getClassName())for(var h=u,m=0,d=h.subMaterials;m<d.length;m++){var g=d[m];g&&(c=g.clone(a?a(g.name):"Clone of "+g.name),g.isFrozen===!0&&c.freeze&&c.freeze(),p.push(g),s[g.uniqueId]=c.uniqueId,l[c.uniqueId]=c)}}o.material=l[s[u.uniqueId]]}else"MultiMaterial"===o.material.getClassName()?t.scene.multiMaterials.indexOf(o.material)===-1&&t.scene.addMultiMaterial(o.material):t.scene.materials.indexOf(o.material)===-1&&t.scene.addMaterial(o.material)});if(u)return o=u,"break"}},y=0;y<t.meshes.length;y++){var S=M(y);if("break"===S)break}return null!=h&&h.length>0&&h.forEach(function(n){for(var i=a?a(n.name):"Clone of "+n.name,r=e.Utilities.CloneSkeletonPrefab(t.scene,n,i,i,g),o=0,u=t.meshes;o<u.length;o++){var c=u[o];if(c.skeleton===n&&!c.isAnInstance){var h=l[s[c.uniqueId]];if(h.skeleton=r,m.indexOf(r)!==-1)continue;m.push(r);for(var p=0,d=r.bones;p<d.length;p++){var f=d[p];f._linkedTransformNode&&(f._linkedTransformNode=l[s[f._linkedTransformNode.uniqueId]])}}}}),r===!0&&t.animationGroups.forEach(function(e){var t=e,n=null!=t.metadata&&null!=t.metadata.unity&&null!=t.metadata.unity.source&&""!==t.metadata.unity.source?t.metadata.unity.source:null;if(null!=n&&""!==n&&null!=c&&c.indexOf(n)>=0){var a=e.clone(e.name,function(e){var t=l[s[e.uniqueId]];return t||e}),i=u[n]||n;null!=t.metadata&&(a.metadata={},a.metadata.unity={},a.metadata.unity.id=t.metadata.unity.id,a.metadata.unity.clip=t.metadata.unity.clip,a.metadata.unity.source=i,a.metadata.unity.legacy=t.metadata.unity.legacy,a.metadata.unity.length=t.metadata.unity.length,a.metadata.unity.looping=t.metadata.unity.looping,a.metadata.unity.settings=t.metadata.unity.settings,a.metadata.unity.behavior=t.metadata.unity.behavior,a.metadata.unity.wrapmode=t.metadata.unity.wrapmode,a.metadata.unity.framerate=t.metadata.unity.framerate,a.metadata.unity.humanmotion=t.metadata.unity.humanmotion,a.metadata.unity.averagespeed=t.metadata.unity.averagespeed,a.metadata.unity.averageduration=t.metadata.unity.averageduration,a.metadata.unity.averageangularspeed=t.metadata.unity.averageangularspeed)}}),null!=o&&(o.parent=null),o},t.InstantiateHierarchy=function(t,n,a){if(void 0===n&&(n=null),t instanceof e.Mesh){var i=null!=t.metadata&&null!=t.metadata.unity&&null!=t.metadata.unity.instance&&t.metadata.unity.instance===!0;return e.Utilities.InstantiateMeshHierarchy(t,n,i,a)}return e.Utilities.InstantiateNodeHierarchy(t,n,a)},t.InstantiateNodeHierarchy=function(t,n,a){void 0===n&&(n=null);var i=t.clone("Clone of "+(t.name||t.id),n||t.parent,!0);i&&a&&a(t,i);for(var r=0,o=t.getChildTransformNodes(!0);r<o.length;r++){var s=o[r];e.Utilities.InstantiateHierarchy(s,i,a)}return i},t.InstantiateMeshHierarchy=function(t,n,a,i){void 0===n&&(n=null);var r=t.getTotalVertices()>0&&a===!0?t.createInstance("Instance of "+(t.name||t.id)):t.clone("Clone of "+(t.name||t.id),n||t.parent,!0);r&&(r.parent=n||t.parent,r.position=t.position.clone(),r.scaling=t.scaling.clone(),t.rotationQuaternion?r.rotationQuaternion=t.rotationQuaternion.clone():r.rotation=t.rotation.clone(),i&&i(t,r));for(var o=0,s=t.getChildTransformNodes(!0);o<s.length;o++){var l=s[o];e.Utilities.InstantiateHierarchy(l,r,i)}return r},t.ComputeBlendingSpeed=function(e,t,n){void 0===n&&(n=!1);var a=1/(e*t);return n===!0&&(a*=.5),a},t.CalculateCameraDistance=function(e,t,n){void 0===n&&(n=1);var a=1;return Math.round(e*n*t*a)},t.InstantiateClass=function(e){for(var t=e.split("."),n=window||this,a=0,i=t.length;a<i;a++)n=n[t[a]];return"function"==typeof n?n:null},t.GetSimpleClassName=function(e){if(e&&e.constructor&&e.constructor.toString){var t=e.constructor.toString().match(/function\s*(\w+)/);if(t&&2==t.length)return t[1]}},t.DisposeEntity=function(t){if(null!=t){if(null!=t.metadata&&t.metadata.unity){var n=t.metadata.unity;null!=n.components&&n.components.length>0&&n.components.forEach(function(t){if(null!=t.instance){try{e.SceneManager.DestroyScriptComponent(t.instance)}catch(n){}t.instance=null}}),delete t.metadata.unity}if(null!=t.metadata&&t.metadata.mixer&&delete t.metadata.mixer,null!=t.metadata&&null!=t.metadata.clone&&delete t.metadata.clone,null!=t.physicsImpostor){var a=t.physicsImpostor;null!=a.onCollideEvent&&(a.onCollideEvent=null),null!=a.tmpCollisionObjects&&delete a.tmpCollisionObjects,null!=t.physicsImpostor.physicsBody&&(null!=t.physicsImpostor.physicsBody.entity&&delete t.physicsImpostor.physicsBody.entity,null!=t.physicsImpostor.physicsBody.triangleMapInfo&&delete t.physicsImpostor.physicsBody.triangleMapInfo),t.physicsImpostor.dispose(),t.physicsImpostor=null}null!=t.skeleton&&(null!=t.skeleton._sockets&&delete t.skeleton._sockets,null!=t.skeleton.bones&&t.skeleton.bones.length>0&&t.skeleton.bones.forEach(function(e){null!=e&&null!=e.metadata&&(e.metadata=null)})),null!=t.cameraRig&&(t.cameraRig.dispose&&t.cameraRig.dispose(),delete t.cameraRig),null!=t.lightRig&&(t.lightRig.dispose&&t.lightRig.dispose(),delete t.lightRig),null!=t.shadowBox&&(t.shadowBox.dispose&&t.shadowBox.dispose(),delete t.shadowBox)}},t.SearchTransformNodes=function(t,n,a){void 0===a&&(a=e.SearchType.ExactMatch);var i=null,r=null!=a?a:e.SearchType.ExactMatch;if(null!=n&&n.length>0)for(var o=0;o<n.length;o++){var s=n[o];if(r===e.SearchType.ExactMatch){if(s.name===t){i=s;break}}else if(r===e.SearchType.StartsWith){if(e.Utilities.StartsWith(s.name,t)){i=s;break}}else if(r===e.SearchType.EndsWith){if(e.Utilities.EndsWith(s.name,t)){i=s;break}}else if(r===e.SearchType.IndexOf){if(s.name.indexOf(t)>=0){i=s;break}}else if(s.name===t){i=s;break}}return i},t.SearchTransformNodeForTags=function(t,n){var a=null;if(null!=n&&n.length>0)for(var i=0;i<n.length;i++){var r=n[i];if(r instanceof e.TransformNode&&e.Tags.MatchesQuery(r,t)){a=r;break}}return a},t.SearchAllTransformNodesForTags=function(t,n){var a=null;if(null!=n&&n.length>0)for(var i=0;i<n.length;i++){var r=n[i];r instanceof e.TransformNode&&e.Tags.MatchesQuery(r,t)&&(null==a&&(a=[]),a.push(r))}return a},t.SearchTransformNodeForScript=function(t,n){var a=null;if(null!=n&&n.length>0)for(var i=0;i<n.length;i++){var r=n[i];if(r instanceof e.TransformNode){var o=e.SceneManager.FindScriptComponent(r,t);if(null!=o){a=r;break}}}return a},t.SearchAllTransformNodesForScript=function(t,n){var a=null;if(null!=n&&n.length>0)for(var i=0;i<n.length;i++){var r=n[i];if(r instanceof e.TransformNode){var o=e.SceneManager.FindScriptComponent(r,t);null!=o&&(null==a&&(a=[]),a.push(r))}}return a},t.CreateGuid=function(t){void 0===t&&(t=null);var n=e.Tools.RandomId();return e.Utilities.IsNullOrEmpty(t)||(n+="-"+t),n},t.ValidateTransformGuid=function(e){if(null!=e&&null!=e.metadata&&null!=e.metadata.unity&&null!=e.metadata.unity.guid&&""!==e.metadata.unity.guid){var t=e.metadata.unity.guid;e.id!==t&&(e.id=t),delete e.metadata.unity.guid}},t.RegisterInstancedMeshBuffers=function(t){var n=null!=t.metadata.unity.buffers?t.metadata.unity.buffers:null;null!=n&&(null!=n.floats&&n.floats.length>0&&n.floats.forEach(function(e){null!=e.kind&&""!==e.kind&&null!=e.value&&(t.registerInstancedBuffer(e.kind,1),t.instancedBuffers[e.kind]=e.value)}),null!=n.colors&&n.colors.length>0&&n.colors.forEach(function(n){null!=n.kind&&""!==n.kind&&null!=n.value&&(t.registerInstancedBuffer(n.kind,4),t.instancedBuffers[n.kind]=new e.Color4(n.value.r||0,n.value.g||0,n.value.b||0,n.value.a||1).toLinearSpace())}),null!=n.vector2&&n.vector2.length>0&&n.vector2.forEach(function(n){null!=n.kind&&""!==n.kind&&null!=n.value&&(t.registerInstancedBuffer(n.kind,2),t.instancedBuffers[n.kind]=new e.Vector2(n.value.x||0,n.value.y||0))}),null!=n.vector3&&n.vector3.length>0&&n.vector3.forEach(function(n){null!=n.kind&&""!==n.kind&&null!=n.value&&(t.registerInstancedBuffer(n.kind,3),t.instancedBuffers[n.kind]=new e.Vector3(n.value.x||0,n.value.y||0,n.value.z||0))}),null!=n.vector4&&n.vector4.length>0&&n.vector4.forEach(function(n){null!=n.kind&&""!==n.kind&&null!=n.value&&(t.registerInstancedBuffer(n.kind,4),t.instancedBuffers[n.kind]=new e.Vector4(n.value.x||0,n.value.y||0,n.value.z||0,n.value.w||0))}))},t.CloneValue=function(t,n){return t?t instanceof e.Mesh?null:t instanceof e.SubMesh?t.clone(n):t.clone?t.clone():t:null},t.CloneEntityMetadata=function(t){var n=null;if(null!=t){var a=null;if(null!=t.unity){var i=null!=t.unity.instance&&t.unity.instance,r=null==t.unity.visible||t.unity.visible,o=null!=t.unity.visibility?t.unity.visibility:1,s=null!=t.unity.billboard?t.unity.billboard:0,l=null!=t.unity.tags?t.unity.tags:"Untagged Layer0",u=null!=t.unity.skin&&t.unity.skin,c=null!=t.unity.bone?t.unity.bone:null,h=null!=t.unity.rootbone&&t.unity.rootbone,m=null!=t.unity.group?t.unity.group:"Untagged",p=null!=t.unity.layer?t.unity.layer:0,d=null!=t.unity.layername?t.unity.layername:"Default",g=null!=t.unity.navigation?t.unity.navigation:null,f=null!=t.unity.lightmapped&&t.unity.lightmapped,y=null!=t.unity.animator?t.unity.animator:null,_=null,v=null,M=null,S=null;t.unity.physics&&(_={},e.Utilities.DeepCopyProperties(t.unity.physics,_)),t.unity.renderer&&(v={},e.Utilities.DeepCopyProperties(t.unity.renderer,v)),t.unity.collision&&(M={},e.Utilities.DeepCopyProperties(t.unity.collision,M)),t.unity.properties&&(S={},e.Utilities.DeepCopyProperties(t.unity.properties,S));var b=null;null!=t.unity.wheels&&t.unity.wheels.length>0&&(b=[],t.unity.wheels.forEach(function(t){if(null!=t){var n={};e.Utilities.DeepCopyProperties(t,n),b.push(n)}}));var T=null;null!=t.unity.components&&t.unity.components.length>0&&(T=[],t.unity.components.forEach(function(t){if(null!=t){var n={},a=null!=t.alias&&"script"===t.alias;e.Utilities.DeepCopyProperties(t,n,["instance"]),a===!0&&(n.instance=null),T.push(n)}})),a={},a.parsed=!1,a.prefab=!1,a.buffers=null,a.lods=null,a.coverages=null,a.distances=null,a.handlers=null,a.instance=i,a.visible=r,a.visibility=o,a.billboard=s,a.tags=l,a.skin=u,a.bone=c,a.rootbone=h,a.group=m,a.layer=p,a.layername=d,a.navigation=g,a.lightmapped=f,a.animator=y,a.renderer=v,a.physics=_,a.wheels=b,a.collision=M,a.properties=S,a.components=T}null!=a&&(n={unity:a})}return n},t.DeepCopyProperties=function(t,n,a,i){for(var r in t)if(("_"!==r[0]||i&&i.indexOf(r)!==-1)&&(!a||a.indexOf(r)===-1)){var o=t[r],s=typeof o;if("function"!==s)if("object"===s)if(o instanceof Array){if(n[r]=[],o.length>0)if("object"==typeof o[0])for(var l=0;l<o.length;l++){var u=e.Utilities.CloneValue(o[l],n);n[r].indexOf(u)===-1&&n[r].push(u)}else n[r]=o.slice(0)}else n[r]=e.Utilities.CloneValue(o,n);else n[r]=o}},t.ValidateTransformMetadata=function(t){null==t.metadata&&(t.metadata={}),null==t.metadata.unity&&(t.metadata.unity={});var n=t.metadata.unity;e.Utilities.HasOwnProperty(n,"entity")||(t.metadata.unity.entity=!0),e.Utilities.HasOwnProperty(n,"parsed")||(t.metadata.unity.parsed=!1),e.Utilities.HasOwnProperty(n,"prefab")||(t.metadata.unity.prefab=!1),e.Utilities.HasOwnProperty(n,"instance")||(t.metadata.unity.instance=!1),e.Utilities.HasOwnProperty(n,"buffers")||(t.metadata.unity.buffers=null),e.Utilities.HasOwnProperty(n,"visible")||(t.metadata.unity.visible=!0),e.Utilities.HasOwnProperty(n,"visibility")||(t.metadata.unity.visibility=1),e.Utilities.HasOwnProperty(n,"billboard")||(t.metadata.unity.billboard=0),e.Utilities.HasOwnProperty(n,"tags")||(t.metadata.unity.tags="Untagged Layer0"),e.Utilities.HasOwnProperty(n,"skin")||(t.metadata.unity.skin=!1),e.Utilities.HasOwnProperty(n,"bone")||(t.metadata.unity.bone=null),e.Utilities.HasOwnProperty(n,"rootbone")||(t.metadata.unity.rootbone=!1),e.Utilities.HasOwnProperty(n,"group")||(t.metadata.unity.group="Untagged"),e.Utilities.HasOwnProperty(n,"layer")||(t.metadata.unity.layer=0),e.Utilities.HasOwnProperty(n,"layername")||(t.metadata.unity.layername="Default"),e.Utilities.HasOwnProperty(n,"navigation")||(t.metadata.unity.navigation=null),e.Utilities.HasOwnProperty(n,"lightmapped")||(t.metadata.unity.lightmapped=!1),e.Utilities.HasOwnProperty(n,"animator")||(t.metadata.unity.animator=null),e.Utilities.HasOwnProperty(n,"lods")||(t.metadata.unity.lods=null),e.Utilities.HasOwnProperty(n,"coverages")||(t.metadata.unity.coverages=null),e.Utilities.HasOwnProperty(n,"distances")||(t.metadata.unity.distances=null),e.Utilities.HasOwnProperty(n,"handlers")||(t.metadata.unity.handlers=null),e.Utilities.HasOwnProperty(n,"physics")||(t.metadata.unity.physics=null),e.Utilities.HasOwnProperty(n,"wheels")||(t.metadata.unity.wheels=null),e.Utilities.HasOwnProperty(n,"renderer")||(t.metadata.unity.renderer=null),e.Utilities.HasOwnProperty(n,"collision")||(t.metadata.unity.collision=null),e.Utilities.HasOwnProperty(n,"properties")||(t.metadata.unity.properties=null),e.Utilities.HasOwnProperty(n,"components")||(t.metadata.unity.components=null)},t.UpVector=e.Vector3.Up(),t.AuxVector=e.Vector3.Zero(),t.ZeroVector=e.Vector3.Zero(),t.TempMatrix=e.Matrix.Zero(),t.TempVector2=e.Vector2.Zero(),t.TempVector3=e.Vector3.Zero(),t.TempQuaternion=e.Quaternion.Zero(),t.PrintElement=null,t.LoadingState=-1,t.TmpHullMatrix=null,t.TmpAmmoVectorA=null,t.TmpAmmoVectorB=null,t.TmpAmmoVectorC=null,t.TmpAmmoVectorD=null,t.TmpAmmoNormalA=null,t.TmpAmmoNormalB=null,t.TmpAmmoNormalC=null,t}();e.Utilities=A}(BABYLON||(BABYLON={}));var UTIL=BABYLON.Utilities,__extends=this&&this.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(t,n)};return function(t,n){function a(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(a.prototype=n.prototype,new a)}}(),BABYLON;!function(e){var t=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,t){this._defines[e]=t},e.ShaderIndexer=0,e}();e.UniversalShaderDefines=t;var n=function(){function e(){}return e}();e.UniversalAlbedoChunks=n;var a=function(t){function n(n,a){var i=t.call(this,n,a)||this;return i.universalMaterial=!0,i.locals=null,i.terrainInfo=null,i._defines=null,i._uniforms=[],i._samplers=[],i._attributes=[],i._textures={},i._vectors4={},i._floats={},i.locals=new e.UniversalShaderDefines,i._defines=null,i._createdShaderName=null,i.enableShaderChunks=!1,i.materialShaderChunks=new e.UniversalAlbedoChunks,i.customShaderNameResolve=i._buildCustomShader,i.customShaderChunkResolve(),i}return __extends(n,t),n.prototype.updateShaderChunks=function(){},n.prototype.getClassName=function(){return"UniversalAlbedoMaterial"},n.prototype.getShaderName=function(){return"pbr"},n.prototype.getShaderChunk=function(){return null},n.prototype.getShaderDefines=function(){return this._defines},n.prototype.getCustomAttributes=function(){return null},n.prototype.getTexture=function(e){return this._textures[e]},n.prototype.getVector4=function(e){return this._vectors4[e]},n.prototype.getFloat=function(e){return this._floats[e]},n.prototype.setTexture=function(e,t,n){return void 0===n&&(n=!1),n===!0&&this.checkSampler(e),this._textures[e]=t,this},n.prototype.setVector4=function(e,t,n){return void 0===n&&(n=!1),n===!0&&this.checkUniform(e),this._vectors4[e]=t,this},n.prototype.setFloat=function(e,t,n){return void 0===n&&(n=!1),n===!0&&this.checkUniform(e),this._floats[e]=t,this},n.prototype.addAttribute=function(e){this._attributes.indexOf(e)===-1&&this._attributes.push(e)},n.prototype.checkUniform=function(e){this._uniforms.indexOf(e)===-1&&(this._uniforms.push(e),this.locals.defineBoolean(e.toUpperCase()))},n.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"))},n.prototype.getAnimatables=function(){var e=t.prototype.getAnimatables.call(this);for(var n in this._textures){var a=this._textures[n];a&&a.animations&&a.animations.length>0&&e.push(a)}return e},n.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);for(var n in this._textures){var a=this._textures[n];a&&e.push(a)}return e},n.prototype.hasTexture=function(e){if(t.prototype.hasTexture.call(this,e))return!0;var n=!1;for(var a in this._textures){var i=this._textures[a];if(i===i){n=!0;break}}return n},n.prototype.dispose=function(e,n){if(n)for(var a in this._textures){var i=this._textures[a];i&&i.dispose(),this._textures[a]=null}this._textures={},t.prototype.dispose.call(this,e,n)},n.prototype.clone=function(t){var n,a=this,i=e.SerializationHelper.Clone(function(){return new e.UniversalAlbedoMaterial(t,a.getScene())},this);i._textures={};for(n in this._textures){var r=this._textures[n];r&&i.setTexture(n,r.clone(),!0)}i._vectors4={};for(n in this._vectors4)i.setVector4(n,this._vectors4[n].clone(),!0);i._floats={};for(n in this._floats)i.setFloat(n,this._floats[n],!0);return i},n.prototype.serialize=function(){var t,n=e.SerializationHelper.Serialize(this);n.customType="BABYLON.UniversalAlbedoMaterial",n.textures={};for(t in this._textures){var a=this._textures[t];a&&(n.textures[t]=a.serialize())}n.vectors4={};for(t in this._vectors4)n.vectors4[t]=this._vectors4[t].asArray();n.floats={};for(t in this._floats)n.floats[t]=this._floats[t];return n},n.Parse=function(t,n,a){var i,r=e.SerializationHelper.Parse(function(){return new e.UniversalAlbedoMaterial(t.name,n)},t,n,a);for(i in t.textures){var o=t.textures[i];o&&r.setTexture(i,e.Texture.Parse(o,n,a),!0)}for(i in t.vectors4)r.setVector4(i,e.Vector4.FromArray(t.vectors4[i]),!0);for(i in t.floats)r.setFloat(i,t.floats[i],!0);return r},n.prototype.customShaderChunkResolve=function(){var t=this.getShaderChunk();if(null!=t&&""!==t){var n=t+"ShaderChunks";if(null!=e.Effect.ShadersStore[n]){var a=e.Effect.ShadersStore[n],i=e.Utilities.HasOwnProperty(a,"VertexBegin")?a.VertexBegin:null;null!=i&&""!==i&&(this.materialShaderChunks.Vertex_Begin=i);var r=e.Utilities.HasOwnProperty(a,"VertexDefinitions")?a.VertexDefinitions:null;null!=r&&""!==r&&(this.materialShaderChunks.Vertex_Definitions=r);var o=e.Utilities.HasOwnProperty(a,"VertexMainBegin")?a.VertexMainBegin:null;null!=o&&""!==o&&(this.materialShaderChunks.Vertex_MainBegin=o);var s=e.Utilities.HasOwnProperty(a,"VertexUpdatePosition")?a.VertexUpdatePosition:null;null!=s&&""!==s&&(this.materialShaderChunks.Vertex_Before_PositionUpdated=s.replace("result","positionUpdated"));var l=e.Utilities.HasOwnProperty(a,"VertexUpdateNormal")?a.VertexUpdateNormal:null;null!=l&&""!==l&&(this.materialShaderChunks.Vertex_Before_NormalUpdated=l.replace("result","normalUpdated"));var u=e.Utilities.HasOwnProperty(a,"VertexWorldPos")?a.VertexWorldPos:null;null!=u&&""!==u&&(this.materialShaderChunks.Vertex_After_WorldPosComputed=u);var c=e.Utilities.HasOwnProperty(a,"VertexMainEnd")?a.VertexMainEnd:null;null!=c&&""!==c&&(this.materialShaderChunks.Vertex_MainEnd=c);var h=e.Utilities.HasOwnProperty(a,"FragmentBegin")?a.FragmentBegin:null;null!=h&&""!==h&&(this.materialShaderChunks.Fragment_Begin=h);var m=e.Utilities.HasOwnProperty(a,"FragmentDefinitions")?a.FragmentDefinitions:null;null!=m&&""!==m&&(this.materialShaderChunks.Fragment_Definitions=m);var p=e.Utilities.HasOwnProperty(a,"FragmentMainBegin")?a.FragmentMainBegin:null;null!=p&&""!==p&&(this.materialShaderChunks.Fragment_MainBegin=p);var d=e.Utilities.HasOwnProperty(a,"FragmentUpdateAlbedo")?a.FragmentUpdateAlbedo:null;null!=d&&""!==d&&(this.materialShaderChunks.Fragment_Custom_Albedo=d.replace("result","surfaceAlbedo"));var g=e.Utilities.HasOwnProperty(a,"FragmentUpdateAlpha")?a.FragmentUpdateAlpha:null;null!=g&&""!==g&&(this.materialShaderChunks.Fragment_Custom_Alpha=g.replace("result","alpha"));var f=e.Utilities.HasOwnProperty(a,"FragmentMetallicRoughness")?a.FragmentMetallicRoughness:null;null!=f&&""!==f&&(this.materialShaderChunks.Fragment_MetallicRoughness=f);var y=e.Utilities.HasOwnProperty(a,"FragmentMicroSurface")?a.FragmentMicroSurface:null;null!=y&&""!==y&&(this.materialShaderChunks.Fragment_MicroSurface=y);var _=e.Utilities.HasOwnProperty(a,"FragmentBeforeLights")?a.FragmentBeforeLights:null;null!=_&&""!==_&&(this.materialShaderChunks.Fragment_Before_Lights=_);var v=e.Utilities.HasOwnProperty(a,"FragmentBeforeFog")?a.FragmentBeforeFog:null;null!=v&&""!==v&&(this.materialShaderChunks.Fragment_Before_Fog=v);var M=e.Utilities.HasOwnProperty(a,"FragmentBeforeFragColor")?a.FragmentBeforeFragColor:null;null!=M&&""!==M&&(this.materialShaderChunks.Fragment_Before_FragColor=M.replace("result","color"))}else e.Tools.Warn("Failed To Locate Shader Chunk Base: "+n)}},n.prototype._buildCustomShader=function(t,n,a,i,r,o,s){var l=this;null==s||null!=s.processFinalCode&&void 0!=s.processFinalCode||(s.processFinalCode=function(t,n){if("vertex"===t)return n;var a=new e.ShaderCodeInliner(n);return a.inlineToken="#define pbr_inline",a.processCode(),a.code}),this._defines=r;var u=this.locals.getDefines();if(null!=u&&null!=this._defines){var c=Object.keys(u);if(null!=c&&c.length>0){for(var h=this._defines,m=0,p=c;m<p.length;m++){var d=p[m];h[d]=u[d]}this._defines.rebuild()}}var g=0;if(null!=this._uniforms&&this._uniforms.length>0)for(g=0;g<this._uniforms.length;g++){var f=this._uniforms[g];n.indexOf(f)===-1&&n.push(f)}if(g=0,null!=this._samplers&&this._samplers.length>0)for(g=0;g<this._samplers.length;g++){var y=this._samplers[g];i.indexOf(y)===-1&&i.push(y)}if(g=0,null!=this._attributes&&this._attributes.length>0)for(g=0;g<this._attributes.length;g++){var _=this._attributes[g];o.indexOf(_)===-1&&o.push(_)}g=0;var v=this.getCustomAttributes();if(null!=v&&v.length>0)for(g=0;g<v.length;g++){var M=v[g];o.indexOf(M)===-1&&o.push(M)}if(null!=this._createdShaderName&&""!==this._createdShaderName)return this._createdShaderName;var S=this.getShaderName();null!=S&&""!==S||(S=t),null!=S&&""!==S||(S="pbr");var b=this._afterBind.bind(this);return this._afterBind=function(e,t){if(t){l._attachAfterBind(e,t);try{b(e,t)}catch(t){}}},this._createdShaderName=this.enableShaderChunks===!0?this._createShaderChunks(S):S,this._createdShaderName},n.prototype._createShaderChunks=function(t){var n=this.getShaderChunk();null!=n&&""!==n||(n=t),e.UniversalShaderDefines.ShaderIndexer++;var a=(n+"Custom"+e.UniversalShaderDefines.ShaderIndexer).trim(),i=e.Effect.ShadersStore[t+"VertexShader"],r=e.Effect.ShadersStore[t+"PixelShader"];r=r.replace(/#include<pbrBlockAlbedoOpacity>/g,e.Effect.IncludesShadersStore.pbrBlockAlbedoOpacity),r=r.replace(/#include<pbrBlockReflectivity>/g,e.Effect.IncludesShadersStore.pbrBlockReflectivity),r=r.replace(/#include<pbrBlockFinalColorComposition>/g,e.Effect.IncludesShadersStore.pbrBlockFinalColorComposition),this.updateShaderChunks();var o=a+"VertexShader";e.Effect.ShadersStore[o]=i.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 s=a+"PixelShader";return e.Effect.ShadersStore[s]=r.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[s]=e.Effect.ShadersStore[s].replace("#define CUSTOM_FRAGMENT_BEFORE_FOG",this.materialShaderChunks.Fragment_Before_Fog)),a},n.prototype._attachAfterBind=function(e,t){var n,a=this.getScene();if(a.texturesEnabled)for(n in this._textures){var i=this._textures[n];null!=i&&i.isReady&&i.isReady()&&(t.setTexture(n,i),t.setFloat2(n+"Infos",i.coordinatesIndex,i.level),t.setMatrix(n+"Matrix",i.getTextureMatrix()))}for(n in this._vectors4)t.setVector4(n,this._vectors4[n]);for(n in this._floats)t.setFloat(n,this._floats[n])},n}(e.PBRMaterial);e.UniversalAlbedoMaterial=a,e._TypeStore.RegisteredTypes.UniversalAlbedoMaterial=a;var i=function(t){function n(e,n){var a=t.call(this,e,n)||this;return a.enableShaderChunks=!0,a}return __extends(n,t),n.prototype.getClassName=function(){return"UniversalTerrainMaterial"},n.prototype.getShaderName=function(){return"pbr"},n.prototype.getShaderChunk=function(){return null},n.prototype.updateShaderChunks=function(){var t="surfaceAlbedo",n="splatmapSampler",a="detailsSampler",i="normalsSampler",r=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(n,a,i)+this.materialShaderChunks.Fragment_Definitions:this.materialShaderChunks.Fragment_Definitions=this.formatTerrainFragmentDefintions(n,a,i),null!=this.materialShaderChunks.Fragment_Custom_Albedo&&""!==this.materialShaderChunks.Fragment_Custom_Albedo?this.materialShaderChunks.Fragment_Custom_Albedo=this.formatTerrainFragmentUpdateColor(this.terrainInfo,t,n,a,i,r)+this.materialShaderChunks.Fragment_Custom_Albedo:this.materialShaderChunks.Fragment_Custom_Albedo=this.formatTerrainFragmentUpdateColor(this.terrainInfo,t,n,a,i,r)},n.prototype.formatTerrainVertexDefintions=function(){return"\r\n#define TERRAIN_VERTEX_DEFINITIONS\r\n\r\nvarying vec2 vSplatmapUV;\r\n\r\n"},n.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"},n.prototype.formatTerrainFragmentDefintions=function(e,t,n){return"\r\n#define TERRAIN_FRAGMENT_DEFNITIONS\r\n\r\nvarying vec2 vSplatmapUV;\r\nuniform sampler2D "+e+";\r\nuniform sampler2D "+t+";\r\nuniform sampler2D "+n+";\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"},n.prototype.formatTerrainFragmentUpdateColor=function(e,t,n,a,i,r){
- void 0===r&&(r=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 = "+t+".rgb;\r\nfloat autoMipMapLevel = -1.0;\r\nfloat normalCorrection = 1.0;\r\nfloat detailCorrection = "+r.toFixed(4)+";\r\n\r\n#if defined(ALBEDO) && defined("+n.toUpperCase()+") && defined("+a.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 s=0,l=0;l<e.splatmapCount;l++){s=4*l;var u=e["splatmapRect"+l];if(o+="vec4 splatmapRect"+l+" = vec4("+u[0].toFixed(4)+", "+u[1].toFixed(4)+", "+u[2].toFixed(4)+", "+u[3].toFixed(4)+");\r\n",o+="vec4 splatmapAlbedo"+l+" = sampleSplatmapAtlas2D("+n+", vec2(splatTileSize, splatTileBits), splatmapRect"+l+", (vSplatmapUV + uvOffset));\r\n",o+="vec4 textureAlbedo"+(s+0)+" = vec4(0.0, 0.0, 0.0, 1.0);\r\n",o+="vec4 textureAlbedo"+(s+1)+" = vec4(0.0, 0.0, 0.0, 1.0);\r\n",o+="vec4 textureAlbedo"+(s+2)+" = vec4(0.0, 0.0, 0.0, 1.0);\r\n",o+="vec4 textureAlbedo"+(s+3)+" = vec4(0.0, 0.0, 0.0, 1.0);\r\n",e["textureRect"+(s+0)]){var c=e["textureRect"+(s+0)],h=e["textureInfo"+(s+0)];o+="vec4 textureRect"+(s+0)+" = vec4("+c[0].toFixed(4)+", "+c[1].toFixed(4)+", "+c[2].toFixed(4)+", "+c[3].toFixed(4)+");\r\n",o+="vec2 textureScale"+(s+0)+" = vec2("+h[0].toFixed(4)+", "+h[1].toFixed(4)+");\r\n",o+="vec2 textureOffset"+(s+0)+" = vec2("+h[2].toFixed(4)+", "+h[3].toFixed(4)+");\r\n",o+="vec2 textureTileUV"+(s+0)+" = ((vSplatmapUV + textureOffset"+(s+0)+") * textureScale"+(s+0)+");\r\n",o+="textureAlbedo"+(s+0)+" = sampleTextureAtlas2D("+a+", detailCorrection, vec2(detailTileSize, detailTileBits), textureRect"+(s+0)+", textureTileUV"+(s+0)+", autoMipMapLevel);\r\n"}if(e["textureRect"+(s+1)]){var c=e["textureRect"+(s+1)],h=e["textureInfo"+(s+1)];o+="vec4 textureRect"+(s+1)+" = vec4("+c[0].toFixed(4)+", "+c[1].toFixed(4)+", "+c[2].toFixed(4)+", "+c[3].toFixed(4)+");\r\n",o+="vec2 textureScale"+(s+1)+" = vec2("+h[0].toFixed(4)+", "+h[1].toFixed(4)+");\r\n",o+="vec2 textureOffset"+(s+1)+" = vec2("+h[2].toFixed(4)+", "+h[3].toFixed(4)+");\r\n",o+="vec2 textureTileUV"+(s+1)+" = ((vSplatmapUV + textureOffset"+(s+1)+") * textureScale"+(s+1)+");\r\n",o+="textureAlbedo"+(s+1)+" = sampleTextureAtlas2D("+a+", detailCorrection, vec2(detailTileSize, detailTileBits), textureRect"+(s+1)+", textureTileUV"+(s+1)+", autoMipMapLevel);\r\n"}if(e["textureRect"+(s+2)]){var c=e["textureRect"+(s+2)],h=e["textureInfo"+(s+2)];o+="vec4 textureRect"+(s+2)+" = vec4("+c[0].toFixed(4)+", "+c[1].toFixed(4)+", "+c[2].toFixed(4)+", "+c[3].toFixed(4)+");\r\n",o+="vec2 textureScale"+(s+2)+" = vec2("+h[0].toFixed(4)+", "+h[1].toFixed(4)+");\r\n",o+="vec2 textureOffset"+(s+2)+" = vec2("+h[2].toFixed(4)+", "+h[3].toFixed(4)+");\r\n",o+="vec2 textureTileUV"+(s+2)+" = ((vSplatmapUV + textureOffset"+(s+2)+") * textureScale"+(s+2)+");\r\n",o+="textureAlbedo"+(s+2)+" = sampleTextureAtlas2D("+a+", detailCorrection, vec2(detailTileSize, detailTileBits), textureRect"+(s+2)+", textureTileUV"+(s+2)+", autoMipMapLevel);\r\n"}if(e["textureRect"+(s+3)]){var c=e["textureRect"+(s+3)],h=e["textureInfo"+(s+3)];o+="vec4 textureRect"+(s+3)+" = vec4("+c[0].toFixed(4)+", "+c[1].toFixed(4)+", "+c[2].toFixed(4)+", "+c[3].toFixed(4)+");\r\n",o+="vec2 textureScale"+(s+3)+" = vec2("+h[0].toFixed(4)+", "+h[1].toFixed(4)+");\r\n",o+="vec2 textureOffset"+(s+3)+" = vec2("+h[2].toFixed(4)+", "+h[3].toFixed(4)+");\r\n",o+="vec2 textureTileUV"+(s+3)+" = ((vSplatmapUV + textureOffset"+(s+3)+") * textureScale"+(s+3)+");\r\n",o+="textureAlbedo"+(s+3)+" = sampleTextureAtlas2D("+a+", detailCorrection, vec2(detailTileSize, detailTileBits), textureRect"+(s+3)+", textureTileUV"+(s+3)+", autoMipMapLevel);\r\n"}if(o+="splatmapBuffer = blendSplatmapAtlasColors(splatmapAlbedo"+l+", textureAlbedo"+(s+0)+", textureAlbedo"+(s+1)+", textureAlbedo"+(s+2)+", textureAlbedo"+(s+3)+", splatmapBuffer);\r\n",o+="#if defined(BUMP) || defined(PARALLAX) || defined(ANISOTROPIC)\r\n",o+=" #if defined("+i.toUpperCase()+")\r\n",o+=" vec4 normalColor"+(s+0)+" = vec4(0.0, 0.0, 0.0, 1.0);\r\n",o+=" vec4 normalColor"+(s+1)+" = vec4(0.0, 0.0, 0.0, 1.0);\r\n",o+=" vec4 normalColor"+(s+2)+" = vec4(0.0, 0.0, 0.0, 1.0);\r\n",o+=" vec4 normalColor"+(s+3)+" = vec4(0.0, 0.0, 0.0, 1.0);\r\n",e["textureRect"+(s+0)]){var m=e["normalsScale"+(s+0)];o+=" float normalScale"+(s+0)+" = "+m.toFixed(4)+";\r\n",o+=" normalColor"+(s+0)+" = sampleTextureAtlas2D("+i+", normalCorrection, vec2(detailTileSize, detailTileBits), textureRect"+(s+0)+", textureTileUV"+(s+0)+", autoMipMapLevel);\r\n",o+=" normalColor"+(s+0)+".rgb = perturbNormalSamplerColor(TBN, normalColor"+(s+0)+".rgb, normalScale"+(s+0)+");\r\n"}if(e["textureRect"+(s+1)]){var m=e["normalsScale"+(s+1)];o+=" float normalScale"+(s+1)+" = "+m.toFixed(4)+";\r\n",o+=" normalColor"+(s+1)+" = sampleTextureAtlas2D("+i+", normalCorrection, vec2(detailTileSize, detailTileBits), textureRect"+(s+1)+", textureTileUV"+(s+1)+", autoMipMapLevel);\r\n",o+=" normalColor"+(s+1)+".rgb = perturbNormalSamplerColor(TBN, normalColor"+(s+1)+".rgb, normalScale"+(s+1)+");\r\n"}if(e["textureRect"+(s+2)]){var m=e["normalsScale"+(s+2)];o+=" float normalScale"+(s+2)+" = "+m.toFixed(4)+";\r\n",o+=" normalColor"+(s+2)+" = sampleTextureAtlas2D("+i+", normalCorrection, vec2(detailTileSize, detailTileBits), textureRect"+(s+2)+", textureTileUV"+(s+2)+", autoMipMapLevel);\r\n",o+=" normalColor"+(s+2)+".rgb = perturbNormalSamplerColor(TBN, normalColor"+(s+2)+".rgb, normalScale"+(s+2)+");\r\n"}if(e["textureRect"+(s+3)]){var m=e["normalsScale"+(s+3)];o+=" float normalScale"+(s+3)+" = "+m.toFixed(4)+";\r\n",o+=" normalColor"+(s+3)+" = sampleTextureAtlas2D("+i+", normalCorrection, vec2(detailTileSize, detailTileBits), textureRect"+(s+3)+", textureTileUV"+(s+3)+", autoMipMapLevel);\r\n",o+=" normalColor"+(s+3)+".rgb = perturbNormalSamplerColor(TBN, normalColor"+(s+3)+".rgb, normalScale"+(s+3)+");\r\n"}o+=" normalsBuffer = blendSplatmapAtlasColors(splatmapAlbedo"+l+", normalColor"+(s+0)+", normalColor"+(s+1)+", normalColor"+(s+2)+", normalColor"+(s+3)+", normalsBuffer);\r\n",o+=" #endif\r\n",o+="#endif\r\n",o+="\r\n"}o+="// Update Color Values\r\n"+t+".rgb = splatmapBuffer.rgb;\r\n#if defined(BUMP) || defined(PARALLAX) || defined(ANISOTROPIC)\r\n #if defined("+i.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},n}(e.UniversalAlbedoMaterial);e.UniversalTerrainMaterial=i,e._TypeStore.RegisteredTypes.UniversalTerrainMaterial=i}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,n,a){if(void 0===a&&(a={}),this._update=null,this._late=null,this._after=null,this._lateUpdate=!1,this._properties=null,this._awoken=!1,this._started=!1,this._scene=null,this._transform=null,this._registeredClassname=null,this.onTriggerEnterObservable=new e.Observable,this.onTriggerStayObservable=new e.Observable,this.onTriggerExitObservable=new e.Observable,this.triggerMesh=null,this.triggerVolumeList=null,this.useTriggerVolumePrecision=!1,this.includeTriggerVolumeDescendants=!1,null==t)throw new Error("Null transform object specified.");if(null==n)throw new Error("Null host scene object specified.");this._scene=n,this._transform=t,this._properties=a||{},this._registeredClassname=null;var i=this;i._update=function(){e.ScriptComponent.UpdateInstance(i)},i._late=function(){e.ScriptComponent.LateInstance(i)},i._after=function(){e.ScriptComponent.AfterInstance(i)},i.registerComponentInstance&&i.destroyComponentInstance||e.Tools.Warn("Invalid component registration handlers for: "+this._transform.name)}return Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transform",{get:function(){return this._transform},enumerable:!1,configurable:!0}),t.prototype.setProperty=function(e,t){null==this._properties&&(this._properties={}),this._properties[e]=t},t.prototype.getProperty=function(e,t){void 0===t&&(t=null);var n=null;return null!=this._properties&&(n=this._properties[e],null==n&&(n=this._properties["auto__"+e])),null==n&&(n=t),null!=n?n:null},t.prototype.getClassName=function(){return this._registeredClassname},t.prototype.getTime=function(){return e.SceneManager.GetTime()},t.prototype.getGameTime=function(){return e.SceneManager.GetGameTime()},t.prototype.getDeltaSeconds=function(){return e.SceneManager.GetDeltaSeconds(this.scene)},t.prototype.getAnimationRatio=function(){return e.SceneManager.GetAnimationRatio(this.scene)},t.prototype.getTransformMesh=function(){return this._transform instanceof e.Mesh?this._transform:null},t.prototype.getAbstractMesh=function(){return this._transform instanceof e.AbstractMesh?this._transform:null},t.prototype.getInstancedMesh=function(){return this._transform instanceof e.InstancedMesh?this._transform:null},t.prototype.getPrimitiveMeshes=function(){return e.SceneManager.GetPrimitiveMeshes(this.transform)},t.prototype.getMetadata=function(){return e.SceneManager.FindSceneMetadata(this._transform)},t.prototype.getComponent=function(t){var n=e.SceneManager.FindScriptComponent(this._transform,t);return null!=n?n:null},t.prototype.getComponents=function(t){var n=e.SceneManager.FindAllScriptComponents(this._transform,t);return null!=n?n:null},t.prototype.getLightRig=function(){return e.SceneManager.FindSceneLightRig(this._transform)},t.prototype.getCameraRig=function(){return e.SceneManager.FindSceneCameraRig(this._transform)},t.prototype.getTransformTag=function(){return e.SceneManager.GetTransformTag(this.transform)},t.prototype.hasTransformTags=function(t){return e.SceneManager.HasTransformTags(this._transform,t)},t.prototype.getChildNode=function(t,n,a,i){return void 0===n&&(n=e.SearchType.ExactMatch),void 0===a&&(a=!0),void 0===i&&(i=null),e.SceneManager.FindChildTransformNode(this._transform,t,n,a,i)},t.prototype.getChildWithTags=function(t,n,a){return void 0===n&&(n=!0),void 0===a&&(a=null),e.SceneManager.FindChildTransformWithTags(this._transform,t,n,a)},t.prototype.getChildrenWithTags=function(t,n,a){return void 0===n&&(n=!0),void 0===a&&(a=null),e.SceneManager.FindAllChildTransformsWithTags(this._transform,t,n,a)},t.prototype.getChildWithScript=function(t,n,a){return void 0===n&&(n=!0),void 0===a&&(a=null),e.SceneManager.FindChildTransformWithScript(this._transform,t,n,a)},t.prototype.getChildrenWithScript=function(t,n,a){return void 0===n&&(n=!0),void 0===a&&(a=null),e.SceneManager.FindAllChildTransformsWithScript(this._transform,t,n,a)},t.prototype.registerOnSceneReady=function(e){this.scene.onAfterRenderObservable.addOnce(e)},t.prototype.registerOnClickAction=function(t){var n=null;return this.transform instanceof e.AbstractMesh&&(n=e.SceneManager.RegisterClickAction(this.scene,this.transform,t)),n},t.prototype.unregisterOnClickAction=function(t){var n=!1;return this.transform instanceof e.AbstractMesh&&(n=e.SceneManager.UnregisterClickAction(this.transform,t)),n},t.prototype.registerOnFixedUpdate=function(t){var n=!1;return null!=this._transform&&this._transform instanceof e.AbstractMesh&&null!=this._transform.physicsImpostor?(this._transform.physicsImpostor.registerAfterPhysicsStep(t),n=!0):e.Tools.Warn("Failed to register physics fixed update for: "+this.transform.name),n},t.prototype.unregisterOnFixedUpdate=function(t){var n=!1;return null!=this._transform&&this._transform instanceof e.AbstractMesh&&null!=this._transform.physicsImpostor?(this._transform.physicsImpostor.unregisterAfterPhysicsStep(t),n=!0):e.Tools.Warn("Failed to unregister physics fixed update for: "+this.transform.name),n},t.prototype.getTriggerVolumeList=function(){return this.triggerVolumeList},t.prototype.resetTriggerVolumeList=function(){this.triggerVolumeList=null},t.prototype.registerTriggerVolume=function(t){var n=new e.TriggerVolume;n.mesh=t,n.state=0,null==this.triggerVolumeList&&(this.triggerVolumeList=[]),this.triggerVolumeList.push(n)},t.prototype.unregisterTriggerVolume=function(e){if(null!=this.triggerVolumeList&&this.triggerVolumeList.length>0)for(var t=0;t<this.triggerVolumeList.length;t++){var n=this.triggerVolumeList[t];if(n.mesh===e){this.triggerVolumeList.splice(t);break}n=null}},t.prototype.registerComponentInstance=function(t,n,a){if(void 0===a&&(a=!0),a===!0){e.Utilities.ValidateTransformMetadata(this._transform);var i={alias:"script",order:0,klass:n,properties:null,instance:t};null==this._transform.metadata.unity.components&&(this._transform.metadata.unity.components=[]),this._transform.metadata.unity.components.push(i)}t._registeredClassname=n,e.ScriptComponent.RegisterInstance(t)},t.prototype.destroyComponentInstance=function(t){e.ScriptComponent.DestroyInstance(t)},t.RegisterInstance=function(e){null!=e&&(null!=e._update&&e.scene.registerBeforeRender(e._update),null!=e._late&&e.scene.onBeforeRenderTargetsRenderObservable.add(e._late),null!=e._after&&e.scene.registerAfterRender(e._after))},t.UpdateInstance=function(t){null!=t&&null!=t.transform&&t.transform._isEnabled===!0&&(t._awoken===!1?(t._awoken=!0,e.ScriptComponent.ParseAutoProperties(t),t.awake&&t.awake()):t._started===!1?(t._started=!0,t.start&&t.start()):t._awoken===!0&&t._started===!0&&(t.update&&t.update(),t._lateUpdate=!0))},t.LateInstance=function(e){null!=e&&null!=e.transform&&e.transform._isEnabled===!0&&e._lateUpdate===!0&&(e._lateUpdate=!1,e._started&&e.late&&e.late())},t.AfterInstance=function(e){null!=e&&null!=e.transform&&e.transform._isEnabled===!0&&(e._started&&e.after&&e.after(),null!=e.triggerVolumeList&&e.triggerVolumeList.length>0&&(null==e.triggerMesh&&(e.triggerMesh=e.getAbstractMesh()),null!=e.triggerMesh&&e.triggerVolumeList.forEach(function(t){if(null!=t.mesh){var n=e.triggerMesh.intersectsMesh(t.mesh,e.useTriggerVolumePrecision,e.includeTriggerVolumeDescendants);n===!0?0===t.state?(t.state=1,e.onTriggerEnterObservable.hasObservers()&&e.onTriggerEnterObservable.notifyObservers(t.mesh)):1===t.state&&e.onTriggerStayObservable.hasObservers()&&e.onTriggerStayObservable.notifyObservers(t.mesh):0!==t.state&&(t.state=0,e.onTriggerExitObservable.hasObservers()&&e.onTriggerExitObservable.notifyObservers(t.mesh))}})))},t.DestroyInstance=function(e){if(null!=e){e.scene.unregisterBeforeRender(e._update),e.scene.onBeforeRenderTargetsRenderObservable.removeCallback(e._late),e.scene.unregisterAfterRender(e._after);try{e.destroy&&e.destroy()}catch(t){}e.onTriggerEnterObservable.clear(),e.onTriggerEnterObservable=null,e.onTriggerStayObservable.clear(),e.onTriggerStayObservable=null,e.onTriggerExitObservable.clear(),e.onTriggerExitObservable=null,e._transform=null,e._properties=null,e._started=!1,e._update=null,e._late=null,e._after=null,e._scene=null}},t.ParseAutoProperties=function(t){var n=Object.keys(t._properties);if(null!=n&&n.length>0)for(var a=function(a){var i=n[a];if(e.Utilities.StartsWith(i,"auto__")){var r=i.replace("auto__","");if(e.Utilities.HasOwnProperty(t,r)){var o=t.getProperty(i);if(null!=o){var s=typeof o;if(null!=s&&""!==s)if("object"===s)if(Array.isArray(o)){var l=[],u=o;u.forEach(function(n){if(null!=n){var a=typeof n;"object"===a?l.push(e.ScriptComponent.UnpackObjectProperty(n,t.scene)):l.push(n)}}),t[r]=l}else{var c=t[r],h=e.ScriptComponent.UnpackObjectProperty(o,t.scene);c instanceof e.Color3&&h instanceof e.Color4?t[r]=new e.Color3(h.r,h.g,h.b):t[r]=h}else t[r]=o;else t[r]=o}else t[r]=o}else e.Tools.Warn(t.getClassName()||"Unregistered Class: Auto property '"+r+"' not found for transform '"+t.transform.name+"'")}},i=0;i<n.length;i++)a(i)},t.UnpackObjectProperty=function(t,n){var a=null;if(null!=t)if(void 0!==t.x&&void 0!==t.y)a=void 0!==t.z?void 0!==t.w?new e.Vector4(t.x,t.y,t.z,t.w):new e.Vector3(t.x,t.y,t.z):new e.Vector2(t.x,t.y);else if(void 0!==t.r&&void 0!==t.g&&void 0!==t.b){var i=1;void 0!==t.a&&(i=t.a),a=new e.Color4(t.r,t.g,t.b,i)}else if(void 0!==t.type)switch(t.type){case"UnityEngine.AnimationCurve":var r=t;a=e.Animation.Parse(r.animation);break;case"UnityEngine.Transform":var o=t;a=e.Utilities.ParseTransformByID(o,n);break;case"UnityEngine.Material":var s=t;a=n.getMaterialByName(s.name);break;case"UnityEngine.Texture2D":var l=t;a=e.Utilities.ParseTexture(l,n);break;case"UnityEngine.Cubemap":var u=t;a=e.Utilities.ParseCubemap(u,n);break;case"UnityEngine.AudioClip":var c=t;a=c;break;case"UnityEngine.Video.VideoClip":var h=t;a=h;break;case"UnityEngine.Font":var m=t;a=m;break;case"UnityEngine.TextAsset":var p=t;a=null!=p.base64?window.atob(p.base64):p;break;case"UnityEditor.DefaultAsset":var d=t;a=null!=d.base64?window.atob(d.base64):d;break;default:a=t}else a=t;return a},t}();e.ScriptComponent=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(e){this._babylonScene=e,this._physicList=[],this._shadowList=[],this._scriptList=[],this._freezeList=[]}return t.prototype.parseSceneComponents=function(t){e.MetadataParser.DoParseSceneComponents(this._babylonScene,t,this._physicList,this._shadowList,this._scriptList,this._freezeList)},t.prototype.postProcessSceneComponents=function(){e.MetadataParser.DoProcessPendingPhysics(this._babylonScene,this._physicList),e.MetadataParser.DoProcessPendingShadows(this._babylonScene,this._shadowList),e.MetadataParser.DoProcessPendingScripts(this._babylonScene,this._scriptList),e.MetadataParser.DoProcessPendingFreezes(this._freezeList),this._babylonScene=null,this._physicList=null,this._shadowList=null,this._scriptList=null,this._freezeList=null},t.DoParseSceneComponents=function(t,n,a,i,r,o){if(null!=n&&null!=n.metadata&&null!=n.metadata.unity&&null!=n.metadata.unity.parsed&&n.metadata.unity.parsed===!1){n.setEnabled(!0),n.metadata.unity.parsed=!0,n.metadata.unity.prefab=!1;var s=n.metadata.unity;n.isVisible=null==n.metadata.unity.visible||n.metadata.unity.visible,n.visibility=null!=n.metadata.unity.visibility?n.metadata.unity.visibility:1,n.billboardMode=null!=n.metadata.unity.billboard?n.metadata.unity.billboard:0,n.onDisposeObservable.addOnce(function(){e.Utilities.DisposeEntity(n)});var l=n instanceof e.AbstractMesh,u=(null!=n.metadata.unity.lightmapped&&n.metadata.unity.lightmapped,s.tags);if(null!=u&&""!==u&&(e.Tags.AddTagsTo(n,u),u.indexOf("NavigationMesh")>=0&&(n.isVisible=!1,n.isPickable=!1,n.useVertexColors=!1)),null!=s.physics&&null!=a&&a.push(n),null!=s.renderer)if(l===!0)n.isPickable=!0,n.useVertexColors=!1,n.cullingStrategy=e.AbstractMesh.CULLINGSTRATEGY_STANDARD,null!=s.renderer.cullingstrategy&&s.renderer.cullingstrategy!==e.AbstractMesh.CULLINGSTRATEGY_STANDARD&&(n.cullingStrategy=s.renderer.cullingstrategy),null!=s.renderer.castshadows&&s.renderer.castshadows===!0&&null!=i&&i.push(n),null!=s.renderer.receiveshadows&&s.renderer.receiveshadows===!0&&(n.receiveShadows=!0),null!=s.renderer.checkcollisions&&s.renderer.checkcollisions===!0&&(n.checkCollisions=!0),null!=s.renderer.istriggervolume&&s.renderer.istriggervolume===!0&&(n.collisionResponse=!1),null!=s.renderer.usevertexcolors&&(n.useVertexColors=s.renderer.usevertexcolors),null!=s.renderer.setmeshpickable&&(n.isPickable=s.renderer.setmeshpickable),null!=s.renderer.showboundingbox&&(n.showBoundingBox=s.renderer.showboundingbox),null!=s.renderer.defaultellipsoid&&(n.ellipsoid=e.Utilities.ParseVector3(s.renderer.defaultellipsoid)),null!=s.renderer.ellipsoidoffset&&(n.ellipsoidOffset=e.Utilities.ParseVector3(s.renderer.ellipsoidoffset)),null!=s.renderer.rendergroupid&&(n.renderingGroupId=s.renderer.rendergroupid),null!=s.renderer.freezeworldmatrix&&s.renderer.freezeworldmatrix===!0&&null!=o&&o.push(n);else{var c=e.SceneManager.GetPrimitiveMeshes(n);null!=c&&c.length>0&&c.forEach(function(t){t.isPickable=!0,t.useVertexColors=!1,t.cullingStrategy=e.AbstractMesh.CULLINGSTRATEGY_STANDARD,null!=s.renderer.cullingstrategy&&s.renderer.cullingstrategy!==e.AbstractMesh.CULLINGSTRATEGY_STANDARD&&(t.cullingStrategy=s.renderer.cullingstrategy),null!=s.renderer.castshadows&&s.renderer.castshadows===!0&&null!=i&&i.push(t),null!=s.renderer.receiveshadows&&s.renderer.receiveshadows===!0&&(t.receiveShadows=!0),null!=s.renderer.checkcollisions&&s.renderer.checkcollisions===!0&&(t.checkCollisions=!0),null!=s.renderer.istriggervolume&&s.renderer.istriggervolume===!0&&(t.collisionResponse=!1),null!=s.renderer.usevertexcolors&&(t.useVertexColors=s.renderer.usevertexcolors),null!=s.renderer.setmeshpickable&&(t.isPickable=s.renderer.setmeshpickable),null!=s.renderer.showboundingbox&&(t.showBoundingBox=s.renderer.showboundingbox),null!=s.renderer.defaultellipsoid&&(t.ellipsoid=e.Utilities.ParseVector3(s.renderer.defaultellipsoid)),null!=s.renderer.ellipsoidoffset&&(t.ellipsoidOffset=e.Utilities.ParseVector3(s.renderer.ellipsoidoffset)),null!=s.renderer.rendergroupid&&(t.renderingGroupId=s.renderer.rendergroupid),null!=s.renderer.freezeworldmatrix&&s.renderer.freezeworldmatrix===!0&&null!=o&&o.push(t)})}if(null!=s.components){var h=s.components;null!=h&&h.length>0&&h.forEach(function(a){if(null!=a)switch(a.alias){case"camera":e.MetadataParser.SetupCameraComponent(t,n,a);break;case"light":e.MetadataParser.SetupLightComponent(t,n,a);break;case"script":null!=r&&r.push({mesh:n,comp:a})}})}}},t.DoProcessPendingScripts=function(t,n){null!=n&&n.length>0&&(n.sort(function(e,t){return e.comp.order<t.comp.order?-1:e.comp.order>t.comp.order?1:0}),n.forEach(function(n){if(null!=n.comp.klass&&""!==n.comp.klass&&"BABYLON.ScriptComponent"!==n.comp.klass){var a=e.Utilities.InstantiateClass(n.comp.klass);if(null!=a){var i=new a(n.mesh,t,n.comp.properties);if(null!=i){var r=i instanceof e.ScriptComponent;r===!0?(n.comp.instance=i,e.SceneManager.RegisterScriptComponent(n.comp.instance,n.comp.klass,!1)):e.Tools.Warn("Non script component instantiated class: "+n.comp.klass)}else e.Tools.Warn("Failed to instantiate script class: "+n.comp.klass)}else e.Tools.Warn("Failed to locate script class: "+n.comp.klass)}}))},t.DoProcessPendingShadows=function(e,t){null!=t&&t.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 n=e._shadowGenerator,a=n.getShadowMap();null!=a&&(null==a.renderList&&(a.renderList=[]),t.forEach(function(e){a.renderList.push(e)}))}})},t.DoProcessPendingPhysics=function(t,n){if(null!=n&&n.length>0){var a=t.isPhysicsEnabled(),i=a===!0?t.getPhysicsEngine():null,r=a===!0&&null!=i&&"AmmoJSPlugin"===i.getPhysicsPluginName();r===!0?n.forEach(function(n){e.RigidbodyPhysics&&e.RigidbodyPhysics.SetupPhysicsComponent?e.RigidbodyPhysics.SetupPhysicsComponent(t,n):e.Tools.Warn("Ammo.js rigidbody physics system not loaded. Physics impostors will not be created for: "+n.name)}):e.Tools.Warn("Ammo.js physics engine not loaded. Physics impostors will not be created.")}},t.DoProcessPendingFreezes=function(e){null!=e&&e.length>0&&e.forEach(function(e){e.freezeWorldMatrix()})},t.SetupCameraComponent=function(t,n,a){n.checkCollisions=!1;var i=n.name+".Rig",r=e.SceneManager.GetRightHanded(t)===!0?Math.PI:0,o=new e.UniversalCamera(i,e.Vector3.Zero(),t);o.checkCollisions=!1,o.rotationQuaternion=e.Quaternion.FromEulerAngles(0,r,0),o.parent=n;var s=null!=a.culling&&a.culling,l=(null!=a.clearflags?a.clearflags:0,null!=a.renderlist?a.renderlist:null),u=null!=a.maincamera&&a.maincamera;u===!0&&(t.activeCamera=o);var c=null!=a.type?a.type:0;switch(c){case 0:o.mode=e.Camera.PERSPECTIVE_CAMERA,null!=a.perspectiveyfov&&(o.fov=a.perspectiveyfov),null!=a.perspectiveznear&&(o.minZ=a.perspectiveznear),null!=a.perspectivezfar&&(o.maxZ=a.perspectivezfar);break;case 1:o.mode=e.Camera.ORTHOGRAPHIC_CAMERA,null!=a.orthoxmag&&(o.orthoLeft=-a.orthoxmag,o.orthoRight=a.orthoxmag),null!=a.orthoymag&&(o.orthoBottom=-a.orthoymag,o.orthoTop=a.orthoymag),null!=a.orthoznear&&(o.minZ=a.orthoznear),null!=a.orthozfar&&(o.maxZ=a.orthozfar)}if(0===s);else if(s===-1);else{var h=0,m=l;if(null!=m&&m.length>0){var p=function(){var n=m[h],a=e.SceneManager.GetMeshByID(t,n);if(null!=a){var i=a.name+".Detail",r=a.getChildren(function(e){return e.name===i},!0);null!=r&&r.length>0}};for(h=0;h<m.length;h++)p()}}n.cameraRig=o},t.SetupLightComponent=function(t,n,a){n.checkCollisions=!1;var i,r=n.name+".Rig",o=1,s=null!=a.culling&&a.culling,l=(null!=a.clearflags?a.clearflags:0,null!=a.renderlist?a.renderlist:null),u=null!=a.type?a.type:0,c=e.SceneManager.GetRenderQuality(),h=null!=a.exponentdecayspeed?a.exponentdecayspeed:1,m=!1;switch(u){case 0:var p=e.SceneManager.GetRightHanded(t)===!0?e.Vector3.Backward():e.Vector3.Forward(),d=null!=a.orthoscale?a.orthoscale:.1,g=new e.DirectionalLight(r,p,t);g.shadowOrthoScale=d,i=g,i.falloffType=e.Light.FALLOFF_STANDARD,m=c===e.RenderQuality.High||c===e.RenderQuality.Medium,o=1;break;case 1:var f=i=new e.PointLight(r,e.Vector3.Zero(),t);i=f,i.falloffType=e.Light.FALLOFF_STANDARD,m=c===e.RenderQuality.High||c===e.RenderQuality.Medium,o=1;break;case 2:var p=e.SceneManager.GetRightHanded(t)===!0?e.Vector3.Backward():e.Vector3.Forward(),y=null!=a.spotangle?a.spotangle:Math.PI/4,_=new e.SpotLight(r,e.Vector3.Zero(),p,0,h,t);_.angle=.966*e.Tools.ToRadians(y),_.innerAngle=.8*_.angle,i=_,i.falloffType=e.Light.FALLOFF_GLTF,m=c===e.RenderQuality.High||c===e.RenderQuality.Medium,o=10}if(null!=i){var v=null!=a.range?a.range:Number.MAX_VALUE,M=null!=a.color?e.Utilities.ParseColor3(a.color,e.Color3.White()):e.Color3.White(),S=null!=a.specular?e.Utilities.ParseColor3(a.specular,e.Color3.White()):e.Color3.White();i.parent=n,i.range=v,i.diffuse=M,i.specular=S,i.intensity=(null!=a.intensity?a.intensity:1)*o,i.lightmapMode=e.Light.LIGHTMAP_DEFAULT,i.intensityMode=e.Light.INTENSITYMODE_AUTOMATIC,i.shadowEnabled=!1;var b=null==a.autorender||a.autorender,T=null!=a.softshadows&&a.softshadows,C=null!=a.numcascades?a.numcascades:0,A=null!=a.cascadelambda?a.cascadelambda:1,P=null!=a.setdepthclamp&&a.setdepthclamp,x=null!=a.blendpertecntage?a.blendpertecntage:1e-8,O=null!=a.boundsrefreshrate?a.boundsrefreshrate:1,w=null!=a.lightcontactratio?a.lightcontactratio:.1,B=null!=a.stabilizecascades&&a.stabilizecascades,R=null!=a.penumbradarkness?a.penumbradarkness:1,I=null!=a.softshadowsfilter?a.softshadowsfilter:99,k=null!=a.freezeshadows&&a.freezeshadows,L=null!=a.calcdepths&&a.calcdepths,D=null!=a.depthscaling?a.depthscaling:50,N=null!=a.blurscaling?a.blurscaling:2,V=null==a.kernelblur||a.kernelblur,F=null!=a.blurkernelsize?a.blurkernelsize:1,U=null!=a.blurboxoffset?a.blurboxoffset:1,E=null!=a.shadowmapsize?a.shadowmapsize:1024,G=null!=a.generateshadows&&a.generateshadows,H=null!=a.shadowbiasfactor?a.shadowbiasfactor:.1,W=null!=a.shadowmapbias?a.shadowmapbias:.05,z=null!=a.normalmapbias?a.normalmapbias:.4,Y=null!=a.shadowstrength?a.shadowstrength:1,j=null!=a.shadowdistance?a.shadowdistance:150,Q=null!=a.shadownearplane?a.shadownearplane:.2,X=null!=a.shadowfilterquality?a.shadowfilterquality:"Medium",K=null!=a.transparencyshadow&&a.transparencyshadow,q=null!=a.softtransparency&&a.softtransparency,J=null==a.forcebackfacesonly||a.forcebackfacesonly,Z=null!=a.frustumedgefalloff?a.frustumedgefalloff:0;if(m===!0&&G===!0){var $=i,ee=e.SceneManager.GetWebGLVersionNumber(t),te=0===u&&C>=2&&ee>=2,ne=te===!0?new e.CascadedShadowGenerator(E,i,(!0)):new e.ShadowGenerator(E,$,(!0));if(ne.bias=W*H,ne.normalBias=z*H*.1,ne.depthScale=D,ne.useKernelBlur=V,ne.blurKernel=F,ne.blurScale=N,ne.blurBoxOffset=U,ne.frustumEdgeFalloff=Z,ne.forceBackFacesOnly=J,ne.setTransparencyShadow(K),ne.enableSoftTransparentShadow=q,ne.contactHardeningLightSizeUVRatio=w,T===!0)if(ee<=1)ne.usePoissonSampling=!0;else if(te===!0)ne.usePercentageCloserFiltering=!0;else switch(I){case 0:ne.usePoissonSampling=!0;break;case 1:ne.useExponentialShadowMap=!0;break;case 2:ne.useBlurExponentialShadowMap=!0;break;case 3:ne.useCloseExponentialShadowMap=!0;break;case 4:ne.useBlurCloseExponentialShadowMap=!0;break;case 5:ne.useContactHardeningShadow=!0;break;case 99:ne.usePercentageCloserFiltering=!0;break;default:ne.usePoissonSampling=!0}switch(X){case"High":ne.filteringQuality=e.ShadowGenerator.QUALITY_HIGH;break;case"Medium":ne.filteringQuality=e.ShadowGenerator.QUALITY_MEDIUM;break;case"Low":ne.filteringQuality=e.ShadowGenerator.QUALITY_LOW}if(te===!0){var ae=ne;ae.lambda=A,ae.depthClamp=P,ae.shadowMaxZ=j,ae.numCascades=C,ae.penumbraDarkness=R,ae.autoCalcDepthBounds=L,ae.stabilizeCascades=B,ae.cascadeBlendPercentage=x,ae.autoCalcDepthBoundsRefreshRate=O,ae.freezeShadowCastersBoundingInfo=k,ae.setDarkness(1-e.Scalar.Clamp(Y)),$.shadowEnabled=!0,ae.splitFrustum()}else{var ie=ne;ie.setDarkness(1-e.Scalar.Clamp(Y)),$.shadowEnabled=!0,$.shadowMinZ=Q,$.shadowMaxZ=j}null==i.metadata&&(i.metadata={}),null==i.metadata.unity&&(i.metadata.unity={}),i.metadata.unity.autorender=b}if(0===s){var re=n.name+".Holder";i.includedOnlyMeshes=[new e.Mesh(re,t)]}else if(s===-1)i.includedOnlyMeshes=[];else{var oe=0;i.includedOnlyMeshes=[];var se=l;if(null!=se&&se.length>0){var le=function(){var n=se[oe],a=e.SceneManager.GetMeshByID(t,n);if(null!=a){var r=a.name+".Detail",o=a.getChildren(function(e){return e.name===r},!0);null!=o&&o.length>0?i.includedOnlyMeshes.push(o[0]):i.includedOnlyMeshes.push(a)}};for(oe=0;oe<se.length;oe++)le()}}n.lightRig=i}},t}();e.MetadataParser=t}(BABYLON||(BABYLON={}));var CVTOOLS_NAME="CVTOOLS_unity_metadata",CVTOOLS_MESH="CVTOOLS_babylon_mesh",CVTOOLS_HAND="CVTOOLS_left_handed",CVTOOLS_unity_metadata=function(){function e(e){this.name=CVTOOLS_NAME,this.enabled=!1,this._materialMap=null,this._lightmapMap=null,this._reflectionMap=null,this._activeMeshes=!1,this._parseScene=!1,this._leftHanded=!1,this._disposeRoot=!1,this._sceneParsed=!1,this._rootUrl=null,this._loader=e,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._materialMap=null,this._lightmapMap=null,this._reflectionMap=null,this._rootUrl=null,this.order=100}return e.prototype.dispose=function(){delete this._loader},e.prototype.onLoading=function(){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._materialMap=new Map,this._lightmapMap=new Map,this._reflectionMap=new Map,this._parseScene===!0,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(t,n){if(this._parseScene===!0&&null!=n.extras&&null!=n.extras.metadata){if(this.preProcessSceneProperties(n,e.LastBabylonScene),null!=n.extras.metadata.rawmaterials){var a=this._loader,i=n.extras.metadata.rawmaterials;this._preloadRawMaterialsAsync(t,a._gltf.materials,i)}return BABYLON.Utilities.LoadingState=1,this._loader.loadSceneAsync(t,n)}return BABYLON.Utilities.LoadingState=1,null},e.prototype.onReady=function(){if(this._parseScene===!0){var t=this._loader._fileName?this._loader._fileName:"Unknown";null!=this._loader.rootBabylonMesh&&(this._loader.rootBabylonMesh.name="Root."+t.replace(".gltf","").replace(".glb",""));var n=e.LastRootUrl,a=e.LastBabylonScene;this._processShaderMaterials(a,this._shaderList),this._processLevelOfDetail(a,this._detailList),this._processActiveMeshes(a,this._activeMeshes),this._processUnityMeshes(this._masterList),e.LastParseScene===!0&&this.postProcessSceneProperties(n,a),this._disposeRoot===!0&&null!=this._loader.rootBabylonMesh&&this._loader.rootBabylonMesh.dispose(!0),null!=this._parserList&&this._parserList.length>0&&BABYLON.Utilities.ParseSceneComponents(a,this._parserList)}BABYLON.Utilities.LoadingState=2},e.prototype._processActiveMeshes=function(e,t){t===!0&&e.freeActiveMeshes()},e.prototype._processUnityMeshes=function(e){null!=e&&e.length>0&&e.forEach(function(e){BABYLON.Utilities.RegisterInstancedMeshBuffers(e)})},e.prototype.loadNodeAsync=function(e,t,n){var a=this;return this._parseScene===!0&&null!=t.extras&&null!=t.extras.metadata?this._loader.loadNodeAsync(e,t,function(e){var i=e,r=t.extras.metadata;null==i.metadata&&(i.metadata={}),i.metadata.unity=r,BABYLON.Utilities.ValidateTransformGuid(i),BABYLON.Utilities.ValidateTransformMetadata(i),BABYLON.Utilities.ValidateTransformQuaternion(i),a._leftHanded===!0||a._loader.babylonScene.useRightHandedSystem===!0?i.overrideMaterialSideOrientation=BABYLON.Material.CounterClockWiseSideOrientation:i.overrideMaterialSideOrientation=BABYLON.Material.ClockWiseSideOrientation,i.isVisible=null==i.metadata.unity.visible||i.metadata.unity.visible,i.visibility=null!=i.metadata.unity.visibility?i.metadata.unity.visibility:1,i.billboardMode=null!=i.metadata.unity.billboard?i.metadata.unity.billboard:0,i.metadata.unity.prefab=a._loader._forAssetContainer,i.metadata.unity.prefab===!0?i.setEnabled(!1):a._parserList.push(i),a._masterList.push(i),n(i)}):null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){if(this._parseScene===!0){var a=-1;t.index&&(a=t.index,a>=0&&null!=this._materialMap&&(this._materialMap.has(a)||this._materialMap.set(a,n))),n.gltfIndex=a;var i=this._loader,r=new Array;return n instanceof BABYLON.ShaderMaterial?r.push(this._parseShaderMaterialPropertiesAsync(e+"/shaderMaterial",t,n)):n instanceof BABYLON.StandardMaterial?r.push(this._parseDiffuseMaterialPropertiesAsync(e+"/standardMaterial",t,n)):(r.push(i.loadMaterialBasePropertiesAsync(e,t,n)),t.pbrMetallicRoughness&&r.push(i._loadMaterialMetallicRoughnessPropertiesAsync(e+"/pbrMetallicRoughness",t.pbrMetallicRoughness,n)),i.loadMaterialAlphaProperties(e,t,n),this._parseCommonConstantProperties(r,e+"/commonConstant",t,n)),Promise.all(r).then(function(){})}return null},e.prototype._getCachedLightmapByIndex=function(e){var t=null;return e>=0&&null!=this._lightmapMap&&(t=this._lightmapMap.get(e)||null),t},e.prototype._getCachedMaterialByIndex=function(e){var t=null;return e>=0&&null!=this._materialMap&&(t=this._materialMap.get(e)||null),t},e.prototype._getCachedCubemapByUrl=function(e){var t=null;return null!=e&&""!==e&&null!=this._reflectionMap&&(t=this._reflectionMap.get(e)||null),t},e.prototype.createMaterial=function(e,t,n){if(this._parseScene===!0&&t.index){var a=t.index;if(a>=0){var i=this._getCachedMaterialByIndex(a);if(null!=i)return i}}if(this._parseScene===!0&&null!=t.extras&&null!=t.extras.metadata&&null!=t.extras.metadata.customMaterial){var r=null,o=t.name||"No Name",s=t.extras.metadata,l=s.customMaterial,u=(s.customShader,BABYLON.Utilities.InstantiateClass(l));if(null!=u){var c=new u(o,this._loader.babylonScene);if(null!=c){var h=c instanceof BABYLON.Material;h===!0?(r=c,r.fillMode=n,r instanceof BABYLON.ShaderMaterial&&BABYLON.Utilities.InitializeShaderMaterial(r)):BABYLON.Tools.Warn("Non material instantiated class: "+l)}else BABYLON.Tools.Warn("Failed to instantiate material class: "+l)}else BABYLON.Tools.Warn("Failed to locate material class: "+l);return r}return null},e.prototype._loadSkinAsync=function(e,t,n){if(this._parseScene===!0){var a=this._loader,i=n,r=function(e){a._forEachPrimitive(t,function(t){t.skeleton=e,t instanceof BABYLON.AbstractMesh&&null!=u._offscreen&&u._offscreen===!0&&(t.alwaysSelectAsActiveMesh=!0)})};if(i._data)return r(i._data.babylonSkeleton),i._data.promise;var o=null!=n.extras&&null!=n.extras.metadata&&null!=n.extras.metadata.name&&""!==n.extras.metadata.name?n.extras.metadata.name:"Skeleton"+i.index,s=this._loader._fileName?this._loader._fileName:"Unknown",l=s.replace(".gltf","").replace(".glb","")+"."+o;a._babylonScene._blockEntityCollection=a._forAssetContainer;var u=new BABYLON.Skeleton(n.name||l,l,a._babylonScene);a._babylonScene._blockEntityCollection=!1,u.overrideMesh=a._rootBabylonMesh,null!=n.extras&&null!=n.extras.metadata&&null!=n.extras.metadata.offscreen&&n.extras.metadata.offscreen===!0&&(u._offscreen=!0),a._loadBones(e,n,u),r(u);var c=a._loadSkinInverseBindMatricesDataAsync(e,n).then(function(e){a._updateBoneMatrices(u,e)});return i._data={babylonSkeleton:u,promise:c},c}return null},e.prototype.loadAnimationAsync=function(e,t){if(this._parseScene===!0&&null!=t.extras&&null!=t.extras.metadata){var n=this._loader,a=t;n._babylonScene._blockEntityCollection=n._forAssetContainer;var i=new BABYLON.AnimationGroup(t.name||"animation"+a.index,n._babylonScene);n._babylonScene._blockEntityCollection=!1,a._babylonAnimationGroup=i;var r=new Array;BABYLON.GLTF2.ArrayItem.Assign(a.channels),BABYLON.GLTF2.ArrayItem.Assign(a.samplers);for(var o=0,s=t.channels;o<s.length;o++){var l=s[o],u=l;r.push(n._loadAnimationChannelAsync(e+"/channels/"+u.index,e,t,l,i))}return Promise.all(r).then(function(){var e={};return e.unity=t.extras.metadata,i.metadata=e,i.normalize(0),i})}return null},e.prototype._loadMeshPrimitiveAsync=function(e,t,n,a,i,r){var o=this;if(this._parseScene===!0){var s=this._loader;s.logOpen(""+e);var l,u=void 0==n.skin&&!a.primitives[0].targets,c=void 0,h=i._instanceData;if(u&&h)l=h.babylonSourceMesh.createInstance(t),c=h.promise;else{var m=new Array,p=new BABYLON.Mesh(t,s._babylonScene);s._createMorphTargets(e,n,a,i,p),m.push(s._loadVertexDataAsync(e,i,p).then(function(t){return s._loadMorphTargetsAsync(e,i,p,t).then(function(){t.applyToMesh(p),o._setupBabylonMesh(p,n,a,i)})}));var d=BABYLON.GLTF2.GLTFLoader._GetDrawMode(e,i.mode);if(null!=i.extras&&null!=i.extras.metadata&&null!=i.extras.metadata.multimaterial&&null!=i.extras.metadata.submeshes)this._setupBabylonMaterials(e,m,d,p,a,i);else if(void 0==i.material){var g=s._defaultBabylonMaterialData[d];g||(g=s._createDefaultMaterial("__GLTFLoader._default",d),s._parent.onMaterialLoadedObservable.notifyObservers(g),s._defaultBabylonMaterialData[d]=g),p.material=g}else{var f=BABYLON.GLTF2.ArrayItem.Get(e+"/material",s._gltf.materials,i.material);m.push(s._loadMaterialAsync("/materials/"+f.index,f,p,d,function(e){p.material=e}))}c=Promise.all(m),u&&(i._instanceData={babylonSourceMesh:p,promise:c}),l=p}return BABYLON.GLTF2.GLTFLoader.AddPointerMetadata(l,e),s._parent.onMeshLoadedObservable.notifyObservers(l),r(l),s.logClose(),c.then(function(){return l})}return null},e.prototype._setupBabylonMesh=function(e,t,n,a){if(this._parseScene===!0){this._loader;if(null!=a.extras&&null!=a.extras.metadata&&null!=a.extras.metadata.multimaterial&&null!=a.extras.metadata.submeshes){var i=a.extras.metadata.submeshes;e.subMeshes=[];for(var r=0;r<i.length;r++){var o=i[r];BABYLON.SubMesh.AddToMesh(o.materialIndex,o.verticesStart,o.verticesCount,o.indexStart,o.indexCount,e)}}null!=t.extras&&null!=t.extras.metadata&&null!=t.extras.metadata.lods&&null!=t.extras.metadata.distances&&null!=this._detailList&&this._detailList.push(e),e.computeWorldMatrix(!0)}},e.prototype._processLevelOfDetail=function(e,t){null!=t&&t.length>0&&t.forEach(function(t){if(null!=t.metadata&&null!=t.metadata.unity&&null!=t.metadata.unity.lods){var n=t.metadata.unity.lods,a=t.isEnabled(!1),i=t;if(null!=t.metadata.unity.distances){var r=t.metadata.unity.distances;if(r.length>=n.length){var o=r.length>n.length?r[r.length-1]:0;i.setEnabled(!1);for(var s=0;s<n.length;s++){var l=n[s],u=e.getMeshByID(l);null!=u?i.addLODLevel(r[s],u):BABYLON.Tools.Warn("Failed to locate lod mesh with id "+l+" for "+t.name)}o>0&&i.addLODLevel(o,null),a===!0&&i.setEnabled(!0)}else BABYLON.Tools.Warn("Invalid level of detail distances for "+t.name)}else null!=t.metadata.unity.coverages}})},e.prototype._setupBabylonMaterials=function(e,t,n,a,i,r){if(this._parseScene===!0){var o=this._loader,s=r.extras.metadata.multimaterial,l=s.materials,u=[],c=s.id||"MM_"+i.name,h=s.name||"MM_"+i.name,m=new BABYLON.MultiMaterial("["+h+"]",o._babylonScene);m.id=c,l.forEach(function(t){var n=BABYLON.GLTF2.ArrayItem.Get(e+"/material",o._gltf.materials,parseInt(t));u.push(n)}),t.push(this._parseMultiMaterialAsync("/materials/"+h,u,a,n,function(e){m.subMaterials=e,a.material=m}))}},e.prototype._processShaderMaterials=function(e,t){null!=t&&t.length>0&&t.forEach(function(e){e.freeze()})},e.prototype.preProcessSceneProperties=function(t,n){if(this._loader._forAssetContainer!==!0&&this._sceneParsed===!1&&null!=t.extras&&null!=t.extras.metadata&&null!=t.extras.metadata.properties&&t.extras.metadata.properties===!0){this._sceneParsed=!0,e.LastParseScene=!0;var a=null!=this._rootUrl?this._rootUrl:"/",i=this._loader._fileName?this._loader._fileName:null,r=t.extras.metadata;if(null==n.metadata&&(n.metadata={}),null==n.metadata.unity&&(n.metadata.unity={}),n.metadata.unity=r,this._disposeRoot=null!=r.disposeroot&&r.disposeroot===!0,BABYLON.SceneManager.SetRootUrl(n,a),BABYLON.SceneManager.SetSceneFile(n,i),BABYLON.SceneManager.SetRightHanded(n,!this._leftHanded),window.intensityFactor=null!=r.intensity?r.intensity:2,window.debugModeEnabled=null!=r.debugging&&r.debugging,window.showDebugColliders=null!=r.showdebugcolliders&&r.showdebugcolliders,window.colliderVisibility=null!=r.collidervisibility?r.collidervisibility:0,window.collisionWireframe=null!=r.collisionwireframe&&r.collisionwireframe,null!=r.clearcolor&&(n.clearColor=BABYLON.Utilities.ParseColor4(r.clearcolor)),null!=r.autoclear&&r.autoclear===!0&&(n.autoClear=!0,n.autoClearDepthAndStencil=!0),null!=r.rendergroups&&(BABYLON.RenderingManager.MAX_RENDERINGGROUPS=r.rendergroups),null!=r.imageprocessing){var o=r.imageprocessing,s=null!=o.contrast?o.contrast:1,l=null!=o.exposure?o.exposure:1;null!=n.imageProcessingConfiguration&&(n.imageProcessingConfiguration.contrast=s,n.imageProcessingConfiguration.exposure=l)}if(null!=r.ambientcoloring&&(n.ambientColor=BABYLON.Utilities.ParseColor3(r.ambientcoloring)),null!=r.ambientlighting&&r.ambientlighting>0){var u=n;null==u._AmbientLight&&(u._AmbientLight=new BABYLON.HemisphericLight("Ambient Lighting",new BABYLON.Vector3(0,1,0),n),u._AmbientLight.falloffType=BABYLON.Light.FALLOFF_STANDARD,u._AmbientLight.lightmapMode=BABYLON.Light.LIGHTMAP_DEFAULT),null!=u._AmbientLight&&(null!=r.ambientskycolor&&(u._AmbientLight.diffuse=BABYLON.Utilities.ParseColor3(r.ambientskycolor,BABYLON.Color3.Gray())),null!=r.ambientspecularcolor&&(u._AmbientLight.specular=BABYLON.Utilities.ParseColor3(r.ambientspecularcolor,BABYLON.Color3.White())),null!=r.ambientgroundcolor&&(u._AmbientLight.groundColor=BABYLON.Utilities.ParseColor3(r.ambientgroundcolor,BABYLON.Color3.Gray())),null!=r.ambientlightintensity&&(u._AmbientLight.intensity=r.ambientlightintensity))}if(null!=r.fogmode){var c=r.fogmode;if(c>0){var h=.6;n.fogMode=c,n.fogEnabled=!0,null!=r.fogdensity&&(n.fogDensity=r.fogdensity*h),null!=r.fogstart&&(n.fogStart=r.fogstart),null!=r.fogend&&(n.fogEnd=r.fogend),null!=r.fogcolor&&(n.fogColor=BABYLON.Utilities.ParseColor3(r.fogcolor))}}var m=new BABYLON.Vector3(0,(-9.81),0),p=null!=r.defaultgravity?BABYLON.Utilities.ParseVector3(r.defaultgravity,m):m;if(n.gravity=p.clone(),n.collisionsEnabled=!0,null!=r.enablephysics){var d=r.enablephysics;if(d===!0){var g=null!=r.maxphysicsstep?r.maxphysicsstep:0,f=null!=r.maxworldsweep?r.maxworldsweep:0,y=null==r.ccdenabled||r.ccdenabled,_=null!=r.ccdpenetration?r.ccdpenetration:0,v=null==r.deltaworldstep||r.deltaworldstep;BABYLON.SceneManager.ConfigurePhysicsEngine(n,v,g,f,y,_,p)}}var M=!1,S=0;if(null!=r.userinput){var b=r.userinput;S=b.joystickInputValue,M=b.disableRightStick;var T=b.joystickRightColorText;null!=T&&""!==T&&(BABYLON.UserInputOptions.JoystickRightHandleColor=T),BABYLON.UserInputOptions.KeyboardSmoothing=b.keyboardSmoothing,BABYLON.UserInputOptions.KeyboardMoveSensibility=b.keyboardSensitivity,BABYLON.UserInputOptions.KeyboardMoveDeadZone=b.keyboardDeadZone,BABYLON.UserInputOptions.GamepadDeadStickValue=b.padDeadStick,BABYLON.UserInputOptions.GamepadLStickXInverted=b.padLStickXInvert,BABYLON.UserInputOptions.GamepadLStickYInverted=b.padLStickYInvert,BABYLON.UserInputOptions.GamepadRStickXInverted=b.padRStickXInvert,BABYLON.UserInputOptions.GamepadRStickYInverted=b.padRStickYInvert,BABYLON.UserInputOptions.GamepadLStickSensibility=b.padLStickLevel,BABYLON.UserInputOptions.GamepadRStickSensibility=b.padRStickLevel,BABYLON.UserInputOptions.JoystickDeadStickValue=b.joystickDeadStick,BABYLON.UserInputOptions.JoystickLeftSensibility=b.joystickLeftLevel,BABYLON.UserInputOptions.JoystickRightSensibility=b.joystickRightLevel,BABYLON.UserInputOptions.PointerAngularSensibility=b.mouseSensitivity,BABYLON.UserInputOptions.PointerWheelDeadZone=b.wheelDeadZone,BABYLON.UserInputOptions.PointerMouseDeadZone=b.mouseDeadZone,BABYLON.UserInputOptions.UseArrowKeyRotation=b.arrowKeyRotation,BABYLON.UserInputOptions.UseCanvasElement=b.useCanvasElement}if(null!=r.enableinput){var C=r.enableinput;if(C===!0){var A=null!=r.pointerlock&&r.pointerlock,P=null!=r.preventdefault&&r.preventdefault,x=null!=r.usecapture&&r.usecapture,O={pointerLock:A,preventDefault:P,useCapture:x,enableVirtualJoystick:1===S||2===S&&BABYLON.SceneManager.IsMobile(),disableRightStick:M};BABYLON.SceneManager.EnableUserInput(n,O)}}null!=r.freezeactivemeshes&&r.freezeactivemeshes===!0&&(this._activeMeshes=!0)}},e.prototype.postProcessSceneProperties=function(e,t){if(null!=t.metadata&&null!=t.metadata.unity){var n=t.metadata.unity;if(null!=n.skybox){var a=n.skybox,i=null!=a.skyfog&&a.skyfog,r=(null!=a.skysrgb&&a.skysrgb,null!=a.skytags?a.skytags:"Untagged"),o=null!=a.skysize?a.skysize:1e3,s=null!=a.rotation?a.rotation:0,l=null!=a.basename&&""!==a.basename?e+a.basename:null,u=null!=a.skyfaces?a.skyfaces:null,c=null!=a.extensions&&a.extensions.length>0?a.extensions:null,h=null!=a.polynomial?a.polynomial:1;try{if(null!=u&&""!==u&&null!=l&&""!==l){var m=null;if("png"===u)m=new BABYLON.CubeTexture(l,t,c),m.isRGBD=!0;else{var p=!0,d=l+"."+u;m=new BABYLON.CubeTexture(d,t,null,(!0),null,null,null,null,p)}m.name=a.basename,m.gammaSpace=!1,m.coordinatesMode=BABYLON.Texture.SKYBOX_MODE,m.rotationY=BABYLON.Tools.ToRadians(s),BABYLON.SceneManager.GetRightHanded(t)===!0&&(m.rotationY+=Math.PI);var g="Ambient Skybox",f=BABYLON.Mesh.CreateBox(g,o,t);f.id=g,f.infiniteDistance=!0,f.applyFog=i,null!=r&&""!==r&&BABYLON.Tags.AddTagsTo(f,r),t.useRightHandedSystem===!0&&(f.scaling.x*=-1);var y=new BABYLON.StandardMaterial("Skybox-Material",t);y.backFaceCulling=!1,y.disableLighting=!0,y.diffuseColor=new BABYLON.Color3(0,0,0),y.emissiveColor=new BABYLON.Color3(0,0,0),y.specularColor=new BABYLON.Color3(0,0,0),y.ambientColor=new BABYLON.Color3(0,0,0),y.reflectionTexture=m,f.material=y}}catch(_){console.warn(_)}if(null!=a.environment){var v=a.environment;t.environmentIntensity=null!=v.level?BABYLON.Scalar.Clamp(v.level,0,10):1;var M=null!=v.info&&""!==v.info?v.info:null;if(null!=M&&""!==M)try{var S=BABYLON.SceneManager.GetRootUrl(t),b=S+M.rooturl,T=BABYLON.CubeTexture.Parse(M,t,b);if(null!=T&&(T.gammaSpace=!1,t.environmentTexture=T),null!=t.environmentTexture&&null!=t.environmentTexture.sphericalPolynomial){var C=t;C.isReady()?C.environmentTexture.sphericalPolynomial.scaleInPlace(h):C.onReadyObservable.addOnce(function(){C.environmentTexture.sphericalPolynomial.scaleInPlace(h)})}}catch(A){console.warn(A)}}}if(null!=n.navigation&&null!=n.navigation.prebaked&&""!==n.navigation.prebaked){var P=null!=n.navigation.collision&&n.navigation.collision===!0,x=null!=n.navigation.showdebug&&n.navigation.showdebug===!0,O=null!=n.navigation.debugcolor?n.navigation.debugcolor:[.05,.225,.75],w=new BABYLON.Color3(O[0],O[1],O[2]),B=null!=n.navigation.timesteps?n.navigation.timesteps:0,R=new XMLHttpRequest;R.open("GET",n.navigation.prebaked,!0),R.responseType="arraybuffer",R.addEventListener("readystatechange",function(){if(200===R.status&&R.response){var e=new Uint8Array(R.response);BABYLON.SceneManager.LoadNavigationMesh(t,e,x,w,B,P)}},!1),R.send()}}},e.prototype._preloadRawMaterialsAsync=function(e,t,n){var a=this._loader,i=new Array,r=BABYLON.Material.TriangleFillMode;return n.forEach(function(n){var o=BABYLON.GLTF2.ArrayItem.Get(e+"/material",t,n);if(null!=o){var s=a.createMaterial(e,o,r);BABYLON.GLTF2.GLTFLoader.AddPointerMetadata(s,e),a._parent.onMaterialLoadedObservable.notifyObservers(s),i.push(a.loadMaterialPropertiesAsync(e,o,s))}}),Promise.all(i).then(function(){})},e.prototype._parseMultiMaterialAsync=function(e,t,n,a,i){var r=this;void 0===i&&(i=function(){});var o=this._loader,s=t;s._data=s._data||{};var l=s._data[a];if(!l){o.logOpen(e+" "+(n.name||""));var u=[],c=new Array;t.forEach(function(t){var n=null;if(t.index){var i=t.index;i>=0&&(n=r._getCachedMaterialByIndex(i))}null==n&&(n=o.createMaterial(e,t,a),BABYLON.GLTF2.GLTFLoader.AddPointerMetadata(n,e),o._parent.onMaterialLoadedObservable.notifyObservers(n),c.push(o.loadMaterialPropertiesAsync(e,t,n))),u.push(n)}),l={babylonMaterials:u,babylonMeshes:[],promises:c},s._data[a]=l,o.logClose()}return l.babylonMeshes.push(n),n.onDisposeObservable.addOnce(function(){var e=l.babylonMeshes.indexOf(n);e!==-1&&l.babylonMeshes.splice(e,1)}),i(l.babylonMaterials),Promise.all(l.promises).then(function(){return l.babylonMaterials})},e.prototype._parseShaderMaterialPropertiesAsync=function(e,t,n){var a=null!=t.extras&&null!=t.extras.metadata?t.extras.metadata:null,i=n,r=new Array;i.backFaceCulling=null==a||null==a.backFaceCulling||a.backFaceCulling,t.doubleSided&&(i.backFaceCulling=!1),BABYLON.Utilities.HasOwnProperty(i,"ambientColor")&&(i.ambientColor=null!=a&&a.ambientColorFactor?BABYLON.Color3.FromArray(a.ambientColorFactor):BABYLON.Color3.Black());var o=1;if(t.pbrMetallicRoughness){var s=t.pbrMetallicRoughness;if(s){if(s.baseColorFactor){var l=BABYLON.Color4.FromArray(s.baseColorFactor);i.setVector4("diffuseColor",new BABYLON.Vector4(Math.pow(l.r,1/2.2),Math.pow(l.g,1/2.2),Math.pow(l.b,1/2.2),l.a)),o=l.a}else i.setVector4("diffuseColor",new BABYLON.Vector4(1,1,1,1));s.baseColorTexture&&r.push(this._loader.loadTextureInfoAsync(e+"/baseColorTexture",s.baseColorTexture,function(e){e.name=n.name+" (Base Color)";var t=e;t.level=null!=a&&null!=a.diffuseIntensity?a.diffuseIntensity:1,i.setTexture("diffuseTexture",t)}))}}if(t.normalTexture&&r.push(this._loader.loadTextureInfoAsync(e+"/normalTexture",t.normalTexture,function(e){e.name=n.name+" (Normal)";var a=e;void 0!=t.normalTexture.scale&&(a.level=t.normalTexture.scale),i.setTexture("bumpTexture",a)})),t.occlusionTexture&&r.push(this._loader.loadTextureInfoAsync(e+"/occlusionTexture",t.occlusionTexture,function(e){e.name=n.name+" (Occlusion)";var a=e;void 0!=t.occlusionTexture.strength&&(a.level=t.occlusionTexture.strength),i.setTexture("ambientTexture",a)})),t.emissiveFactor){var u=BABYLON.Color4.FromArray(t.emissiveFactor);(u.r>0||u.g>0||u.b>0)&&i.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))}t.emissiveTexture&&r.push(this._loader.loadTextureInfoAsync(e+"/emissiveTexture",t.emissiveTexture,function(e){e.name=n.name+" (Emissive)";var t=e;i.setTexture("emissiveTexture",t)})),i.alpha=o;var c=t.alphaMode||"OPAQUE";switch(c){case"OPAQUE":i.alpha=1,i.transparencyMode=BABYLON.ShaderMaterial.MATERIAL_OPAQUE;break;case"MASK":i.transparencyMode=BABYLON.ShaderMaterial.MATERIAL_ALPHATEST;break;case"BLEND":i.transparencyMode=BABYLON.ShaderMaterial.MATERIAL_ALPHABLEND;break;default:throw new Error(e+"/AlphaMode: Invalid value ("+t.alphaMode+")")}if(null!=a){if(i.wireframe=null!=a.useWireframe&&a.useWireframe,i.needDepthPrePass=null!=a.depthPrepass&&a.depthPrepass,a.customTextures){var h=function(t){var o=a.customTextures[t];null!=o&&r.push(m._loader.loadTextureInfoAsync(e+"/"+t,o,function(e){e.name=n.name+" (Custom)",i.setTexture(t,e)}))},m=this;for(var p in a.customTextures)h(p)}if(a.customVectors)for(var d in a.customVectors){var g=a.customVectors[d];null!=g&&i.setVector4(d,BABYLON.Vector4.FromArray(g))}if(a.customColors)for(var f in a.customColors){var y=a.customColors[f];null!=y&&i.setVector4(f,BABYLON.Vector4.FromArray(y))}if(a.customFloats)for(var _ in a.customFloats){var v=a.customFloats[_];null!=v&&i.setFloat(_,v)}null!=a.freezeMaterial&&a.freezeMaterial===!0&&null!=this._shaderList&&this._shaderList.push(i)}return Promise.all(r).then(function(){})},e.prototype._parseDiffuseMaterialPropertiesAsync=function(e,t,n){var a=null!=t.extras&&null!=t.extras.metadata?t.extras.metadata:null,i=n,r=new Array;BABYLON.Utilities.HasOwnProperty(i,"ambientColor")&&(i.ambientColor=null!=a&&a.ambientColorFactor?BABYLON.Color3.FromArray(a.ambientColorFactor):BABYLON.Color3.Black()),BABYLON.Utilities.HasOwnProperty(i,"backFaceCulling")&&(i.backFaceCulling=null==a||null==a.backFaceCulling||a.backFaceCulling),t.doubleSided&&(BABYLON.Utilities.HasOwnProperty(i,"twoSidedLighting")&&(i.twoSidedLighting=!0),BABYLON.Utilities.HasOwnProperty(i,"backFaceCulling")&&(i.backFaceCulling=!1));var o=1;if(t.pbrMetallicRoughness){var s=t.pbrMetallicRoughness;if(s){if(BABYLON.Utilities.HasOwnProperty(i,"diffuseColor"))if(s.baseColorFactor){var l=BABYLON.Color4.FromArray(s.baseColorFactor);i.diffuseColor=new BABYLON.Color3(Math.pow(l.r,1/2.2),Math.pow(l.g,1/2.2),Math.pow(l.b,1/2.2)),o=l.a}else i.diffuseColor=BABYLON.Color3.White();BABYLON.Utilities.HasOwnProperty(i,"diffuseTexture")&&s.baseColorTexture&&r.push(this._loader.loadTextureInfoAsync(e+"/baseColorTexture",s.baseColorTexture,function(e){e.name=n.name+" (Base Color)",i.diffuseTexture=e,i.diffuseTexture.level=null!=a&&null!=a.diffuseIntensity?a.diffuseIntensity:1}))}}if(BABYLON.Utilities.HasOwnProperty(i,"bumpTexture")&&t.normalTexture&&(r.push(this._loader.loadTextureInfoAsync(e+"/normalTexture",t.normalTexture,function(e){e.name=n.name+" (Normal)",i.bumpTexture=e,void 0!=t.normalTexture.scale&&(i.bumpTexture.level=t.normalTexture.scale)})),BABYLON.Utilities.HasOwnProperty(i,"invertNormalMapX")&&(i.invertNormalMapX=!this._loader.babylonScene.useRightHandedSystem),BABYLON.Utilities.HasOwnProperty(i,"invertNormalMapY")&&(i.invertNormalMapY=this._loader.babylonScene.useRightHandedSystem)),BABYLON.Utilities.HasOwnProperty(i,"ambientTexture")&&t.occlusionTexture&&r.push(this._loader.loadTextureInfoAsync(e+"/occlusionTexture",t.occlusionTexture,function(e){e.name=n.name+" (Occlusion)",i.ambientTexture=e,void 0!=t.occlusionTexture.strength&&(i.ambientTexture.level=t.occlusionTexture.strength)})),BABYLON.Utilities.HasOwnProperty(i,"emissiveColor")){var u=t.emissiveFactor?BABYLON.Color4.FromArray(t.emissiveFactor):new BABYLON.Color4(0,0,0,1);i.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(i,"emissiveTexture")&&t.emissiveTexture&&r.push(this._loader.loadTextureInfoAsync(e+"/emissiveTexture",t.emissiveTexture,function(e){e.name=n.name+" (Emissive)",i.emissiveTexture=e,BABYLON.Utilities.HasOwnProperty(i,"useEmissiveAsIllumination")&&(i.useEmissiveAsIllumination=null!=a&&null!=a.useEmissiveAsIllumination&&a.useEmissiveAsIllumination)})),BABYLON.Utilities.HasOwnProperty(i,"alpha")&&(i.alpha=o);var c=t.alphaMode||"OPAQUE";switch(c){case"OPAQUE":BABYLON.Utilities.HasOwnProperty(i,"alpha")&&(i.alpha=1);break;case"MASK":i.alphaCutOff=void 0==t.alphaCutoff?.5:t.alphaCutoff,i.diffuseTexture&&BABYLON.Utilities.HasOwnProperty(i,"diffuseTexture")&&(i.diffuseTexture.hasAlpha=!0);break;case"BLEND":i.diffuseTexture&&(BABYLON.Utilities.HasOwnProperty(i,"diffuseTexture")&&(i.diffuseTexture.hasAlpha=!0),BABYLON.Utilities.HasOwnProperty(i,"useAlphaFromDiffuseTexture")&&(i.useAlphaFromDiffuseTexture=!0));break;default:throw new Error(e+"/AlphaMode: Invalid value ("+t.alphaMode+")")}return this._parseCommonConstantProperties(r,e,t,n),Promise.all(r).then(function(){})},e.prototype._parseCommonConstantProperties=function(e,t,n,a){var i=this,r=null!=n.extras&&null!=n.extras.metadata?n.extras.metadata:null;if(null!=r){var o=a;if(BABYLON.Utilities.HasOwnProperty(o,"alphaMode")&&(o.alphaMode=null!=r&&r.alphaMode?r.alphaMode:BABYLON.Engine.ALPHA_COMBINE),BABYLON.Utilities.HasOwnProperty(o,"ambientColor")&&(o.ambientColor=null!=r&&r.ambientColorFactor?BABYLON.Color3.FromArray(r.ambientColorFactor):BABYLON.Color3.Black()),BABYLON.Utilities.HasOwnProperty(o,"backFaceCulling")&&(o.backFaceCulling=null==r||null==r.backFaceCulling||r.backFaceCulling),a instanceof BABYLON.PBRMaterial&&(a.useMetallnessFromMetallicTextureBlue=!0,a.useRoughnessFromMetallicTextureGreen=!0,a.useRoughnessFromMetallicTextureAlpha=!1,a.useAmbientOcclusionFromMetallicTextureRed=!1,a.directIntensity=null!=r.directIntensity?r.directIntensity:1,a.specularIntensity=null!=r.specularIntensity?r.specularIntensity:1,a.emissiveIntensity=null!=r.emissiveIntensity?r.emissiveIntensity:1,a.environmentIntensity=null!=r.environmentIntensity?r.environmentIntensity:1,a.indexOfRefraction=null!=r.indexOfRefraction?r.indexOfRefraction:1.5,null!=r.useAlphaFromAlbedoTexture&&(a.useAlphaFromAlbedoTexture=r.useAlphaFromAlbedoTexture),null!=r.parallaxBias&&r.parallaxBias>0&&(a.useParallax=!0,a.parallaxScaleBias=.9*r.parallaxBias,a.useParallaxOcclusion=null==r.parallaxOcclusion||r.parallaxOcclusion,a.useParallaxOcclusion===!0&&(a.parallaxScaleBias*=.5))),BABYLON.Utilities.HasOwnProperty(o,"unlit")&&(o.unlit=null!=r.unlitMaterial&&r.unlitMaterial),BABYLON.Utilities.HasOwnProperty(o,"wireframe")&&(o.wireframe=null!=r.useWireframe&&r.useWireframe),BABYLON.Utilities.HasOwnProperty(o,"disableLighting")&&(o.disableLighting=null!=r.disableLighting&&r.disableLighting),BABYLON.Utilities.HasOwnProperty(o,"maxSimultaneousLights")&&(o.maxSimultaneousLights=null!=r.maxSimultaneousLights?r.maxSimultaneousLights:4),BABYLON.Utilities.HasOwnProperty(o,"needDepthPrePass")&&(o.needDepthPrePass=null!=r.depthPrepass&&r.depthPrepass),BABYLON.Utilities.HasOwnProperty(o,"lightmapTexture")&&r.lightmapTexture){var s=null,l=null!=r.lightmapTexture.index?r.lightmapTexture.index:-1;l>=0&&(s=this._getCachedLightmapByIndex(l)),null!=s?(o.lightmapTexture=s,o.useLightmapAsShadowmap=!0,BABYLON.Utilities.HasOwnProperty(o,"ambientColor")&&(o.ambientColor=BABYLON.Color3.White())):e.push(this._loader.loadTextureInfoAsync(t+"/lightmapTexture",r.lightmapTexture,function(e){e.name=a.name+" (Light Map)",e.level=r.lightmapLevel?r.lightmapLevel:1,e.gammaSpace=!1;var t=e;t.onLoadObservable.addOnce(function(){t.isReady()?t.isRGBD=!0:BABYLON.Tools.Warn("Failed to register texture as RGBD: "+t.name)}),o.lightmapTexture=e,l>=0&&null!=i._lightmapMap&&(i._lightmapMap.has(l)||i._lightmapMap.set(l,t)),o.useLightmapAsShadowmap=!0,BABYLON.Utilities.HasOwnProperty(o,"ambientColor")&&(o.ambientColor=BABYLON.Color3.White())}))}a instanceof BABYLON.PBRMaterial&&r.detailMapTexture&&e.push(this._loader.loadTextureInfoAsync(t+"/detailMapTexture",r.detailMapTexture,function(e){e.name=a.name+" (Detail Map)",e.level=1,a.detailMap.texture=e,a.detailMap.bumpLevel=r.detailBumpLevel?r.detailBumpLevel:1,a.detailMap.diffuseBlendLevel=r.detailBlendLevel?r.detailBlendLevel:.75,a.detailMap.roughnessBlendLevel=r.detailRoughLevel?r.detailRoughLevel:.5,a.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!=r&&r.reflectionColorFactor?BABYLON.Color3.FromArray(r.reflectionColorFactor):BABYLON.Color3.White()),c===!0&&BABYLON.Utilities.HasOwnProperty(o,"reflectionTexture")&&r.reflectionCubemapInfo){var h=BABYLON.SceneManager.GetRootUrl(this._loader.babylonScene),m=h+r.reflectionCubemapInfo.rooturl,p=this._getCachedCubemapByUrl(m);if(null!=p)o.reflectionTexture=p;else{var d=BABYLON.CubeTexture.Parse(r.reflectionCubemapInfo,this._loader.babylonScene,m);null!=d&&(d.gammaSpace=!1,o.reflectionTexture=d,null==this._reflectionMap||this._reflectionMap.has(m)||this._reflectionMap.set(m,d))}}if(BABYLON.Utilities.HasOwnProperty(o,"terrainInfo")&&(o.terrainInfo=null!=r.terrainInfo?r.terrainInfo:null),BABYLON.Utilities.HasOwnProperty(a,"universalMaterial")){var g=a;if(r.customTextures){var f=function(n){var i=r.customTextures[n];null!=i&&(g.checkSampler(n),e.push(y._loader.loadTextureInfoAsync(t+"/"+n,i,function(e){e.name=a.name+" (Custom)",g.setTexture(n,e,!0)})))},y=this;for(var _ in r.customTextures)f(_)}if(r.customVectors)for(var v in r.customVectors){var M=r.customVectors[v];null!=M&&g.setVector4(v,BABYLON.Vector4.FromArray(M),!0)}if(r.customColors)for(var S in r.customColors){var b=r.customColors[S];null!=b&&g.setVector4(S,BABYLON.Vector4.FromArray(b),!0)}if(r.customFloats)for(var T in r.customFloats){var C=r.customFloats[T];null!=C&&g.setFloat(T,C,!0)}}else{if(r.customTextures){var A=function(n){var i=r.customTextures[n];null!=i&&BABYLON.Utilities.HasOwnProperty(o,n)&&e.push(P._loader.loadTextureInfoAsync(t+"/"+n,i,function(e){e.name=a.name+" (Custom)",o[n]=e}))},P=this;for(var _ in r.customTextures)A(_)}if(r.customVectors)for(var v in r.customVectors){var M=r.customVectors[v];null!=M&&BABYLON.Utilities.HasOwnProperty(o,v)&&(o[v]=BABYLON.Vector4.FromArray(M))}if(r.customColors)for(var S in r.customColors){var b=r.customColors[S];null!=b&&BABYLON.Utilities.HasOwnProperty(o,S)&&(o[S]instanceof BABYLON.Vector4?o[S]=BABYLON.Vector4.FromArray(b):o[S]instanceof BABYLON.Color4?o[S]=BABYLON.Color4.FromArray(b):o[S]=BABYLON.Color3.FromArray(b))}if(r.customFloats)for(var T in r.customFloats){var C=r.customFloats[T];null!=C&&BABYLON.Utilities.HasOwnProperty(o,T)&&(o[T]instanceof Boolean?o[T]=C>0:o[T]=C)}}null!=r.freezeMaterial&&r.freezeMaterial===!0&&null!=this._shaderList&&this._shaderList.push(a)}},e.LastRootUrl=null,e.LastParseScene=!1,e.LastBabylonScene=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,t){window.setTimeout(e,1e3/60)}}(),TimerPlugin.requestInterval=function(e,t){function n(){var r=TimerPlugin.getTimeMilliseconds(),o=r-a;o>=t&&(e.call(),a=TimerPlugin.getTimeMilliseconds()),i.value=TimerPlugin.requestAnimFrame(n)}if(!(TimerPlugin.requestAnimationFrame||TimerPlugin.webkitRequestAnimationFrame||TimerPlugin.mozRequestAnimationFrame&&TimerPlugin.mozCancelRequestAnimationFrame||TimerPlugin.oRequestAnimationFrame||TimerPlugin.msRequestAnimationFrame))return window.setInterval(e,t);var a=TimerPlugin.getTimeMilliseconds(),i=new Object;return i.value=TimerPlugin.requestAnimFrame(n),i},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,t){function n(){var r=TimerPlugin.getTimeMilliseconds(),o=r-a;o>=t?e.call():i.value=TimerPlugin.requestAnimFrame(n)}if(!(TimerPlugin.requestAnimationFrame||TimerPlugin.webkitRequestAnimationFrame||TimerPlugin.mozRequestAnimationFrame&&TimerPlugin.mozCancelRequestAnimationFrame||TimerPlugin.oRequestAnimationFrame||TimerPlugin.msRequestAnimationFrame))return window.setTimeout(e,t);var a=TimerPlugin.getTimeMilliseconds(),i=new Object;return i.value=TimerPlugin.requestAnimFrame(n),i},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();var __extends=this&&this.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(t,n)};return function(t,n){function a(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(a.prototype=n.prototype,new a)}}(),BABYLON;!function(e){var t=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n._frametime=0,n._layercount=0,n._updatemode=0,n._hasrootmotion=!1,n._processmotion=!0,n._initialtargetblending=!1,n._hastransformhierarchy=!1,n._leftfeetbottomheight=0,n._rightfeetbottomheight=0,n._runtimecontroller=null,n._executed=!1,n._checkers=new e.TransitionCheck,n._source="",n._machine=null,n._deltaPosition=new e.Vector3(0,0,0),n._deltaRotation=new e.Quaternion(0,0,0,1),n._deltaAngleY=0,n._positionWeight=!1,n._rootBoneWeight=!1,n._rotationWeight=!1,n._rootQuatWeight=!1,n._positionHolder=new e.Vector3(0,0,0),n._rootBoneHolder=new e.Vector3(0,0,0),n._rotationHolder=new e.Quaternion(0,0,0,1),n._rootQuatHolder=new e.Quaternion(0,0,0,1),n._rootMotionMatrix=e.Matrix.Zero(),n._rootMotionScaling=new e.Vector3(0,0,0),n._rootMotionRotation=new e.Quaternion(0,0,0,1),n._rootMotionPosition=new e.Vector3(0,0,0),n._lastMotionRotation=new e.Quaternion(0,0,0,1),n._lastMotionPosition=new e.Vector3(0,0,0),n._quatRotationDiff=new e.Quaternion(0,0,0,1),n._quatRotateVector=new e.Vector3(0,0,0),n._dirtyMotionMatrix=null,n._dirtyBlenderMatrix=null,n._targetPosition=new e.Vector3(0,0,0),n._targetRotation=new e.Quaternion(0,0,0,1),n._targetScaling=new e.Vector3(1,1,1),n._updateMatrix=e.Matrix.Zero(),n._blenderMatrix=e.Matrix.Zero(),n._blendWeights=new e.BlendingWeights,n._data=new Map,n._anims=new Map,n._numbers=new Map,n._booleans=new Map,n._triggers=new Map,n._parameters=new Map,n.speedRatio=1,n.applyRootMotion=!1,n.enableAnimation=!0,n.m_avatarMask=null,n.m_defaultGroup=null,n.m_animationTargets=null,n.onAnimationIKObservable=new e.Observable,n.onAnimationEndObservable=new e.Observable,n.onAnimationLoopObservable=new e.Observable,n.onAnimationEventObservable=new e.Observable,n.onAnimationUpdateObservable=new e.Observable,n}return __extends(n,t),n.prototype.hasRootMotion=function(){return this._hasrootmotion},n.prototype.getAnimationTime=function(){return this._frametime},n.prototype.getDeltaPosition=function(){return this._deltaPosition},n.prototype.getDeltaRotation=function(){return this._deltaRotation},n.prototype.getRuntimeController=function(){return this._runtimecontroller},n.prototype.awake=function(){this.awakeStateMachine()},n.prototype.late=function(){this.lateStateMachine()},n.prototype.destroy=function(){this.destroyStateMachine()},n.prototype.playAnimation=function(t,n,a,i){void 0===n&&(n=0),void 0===a&&(a=0),void 0===i&&(i=null);var r=!1;if(null!=this._machine.layers&&this._machine.layers.length>a){var o=this._machine.layers[a],s=null!=o.animationStateMachine?o.animationStateMachine.rate||e.AnimationState.FPS:e.AnimationState.FPS,l=n>0?e.Utilities.ComputeBlendingSpeed(i||s,n):0;this.setCurrentAnimationState(o,t,l),r=!0}else e.Tools.Warn("No animation state layers on "+this.transform.name);return r},n.prototype.getBool=function(e){return this._booleans.get(e)||!1},n.prototype.setBool=function(e,t){this._booleans.set(e,t)},n.prototype.getFloat=function(e){return this._numbers.get(e)||0},n.prototype.setFloat=function(e,t){this._numbers.set(e,t)},n.prototype.getInteger=function(e){return this._numbers.get(e)||0},n.prototype.setInteger=function(e,t){this._numbers.set(e,t)},n.prototype.getTrigger=function(e){return this._triggers.get(e)||!1},n.prototype.setTrigger=function(e){this._triggers.set(e,!0)},n.prototype.resetTrigger=function(e){this._triggers.set(e,!1)},n.prototype.getMachineState=function(e){return this._data.get(e)},n.prototype.setMachineState=function(e,t){this._data.set(e,t)},n.prototype.getCurrentState=function(e){return null!=this._machine.layers&&this._machine.layers.length>e?this._machine.layers[e].animationStateMachine:null},n.prototype.getAnimationGroup=function(e){return this._anims.get(e)},n.prototype.getAnimationGroups=function(){return this._anims},n.prototype.setAnimationGroups=function(t,n){var a=this;void 0===n&&(n=!1),null!=t&&t.length>0&&(this._anims=new Map,this.m_animationTargets=[],this.m_defaultGroup=t[0],t.forEach(function(t){var n=t;try{t.stop()}catch(i){}null!=t.targetedAnimations&&t.targetedAnimations.length>0&&t.targetedAnimations.forEach(function(t){for(var n=-1,i=0;i<a.m_animationTargets.length;i++)if(a.m_animationTargets[i].target===t.target){n=i;break}if(n<0)if(a.m_animationTargets.push(t),null==t.target.metadata&&(t.target.metadata={}),t.target instanceof e.TransformNode){e.Utilities.ValidateTransformQuaternion(t.target);for(var r=[],o=0;o<a._layercount;o++){var s=new e.AnimationMixer;s.positionBuffer=null,s.rotationBuffer=null,s.scalingBuffer=null,s.originalMatrix=null,s.blendingFactor=0,s.blendingSpeed=0,s.rootPosition=null,s.rootRotation=null,r.push(s)}t.target.metadata.mixer=r}else if(t.target instanceof e.MorphTarget){for(var l=[],o=0;o<a._layercount;o++){var u=new e.AnimationMixer;u.influenceBuffer=null,l.push(u)}t.target.metadata.mixer=l}}),null!=n&&null!=n.metadata&&null!=n.metadata.unity&&null!=n.metadata.unity.clip&&""!==n.metadata.unity.clip&&a._anims.set(n.metadata.unity.clip,t)}))},n.prototype.getRootMotionAngle=function(){return this._deltaAngleY},n.prototype.getRootMotionSpeed=function(){var t=this._deltaPosition.length();return t>=e.AnimationState.MOTION?t:0},n.prototype.getForwardMoveSpeed=function(e){return void 0===e&&(e=!0),e?Math.abs(this._deltaPosition.z):this._deltaPosition.z},n.prototype.awakeStateMachine=function(){var t=this;if(this.m_animationTargets=[],this.m_defaultGroup=null,this.m_avatarMask=new Map,this._machine=this.getProperty("machine",this._machine),this._updatemode=this.getProperty("updatemode",this._updatemode),this._hasrootmotion=this.getProperty("hasrootmotion",this._hasrootmotion),this._processmotion=this.getProperty("parserootmotion",this._processmotion),this._runtimecontroller=this.getProperty("runtimecontroller",this._runtimecontroller),this._hastransformhierarchy=this.getProperty("hastransformhierarchy",this._hastransformhierarchy),this._leftfeetbottomheight=this.getProperty("leftfeetbottomheight",this._leftfeetbottomheight),this._rightfeetbottomheight=this.getProperty("rightfeetbottomheight",this._rightfeetbottomheight),this.applyRootMotion=this.getProperty("applyrootmotion",this.applyRootMotion),this._source=null!=this.transform.metadata&&null!=this.transform.metadata.unity&&null!=this.transform.metadata.unity.animator&&""!==this.transform.metadata.unity.animator?this.transform.metadata.unity.animator:null,null!=this._machine){if(null!=this._machine.speed&&(this.speedRatio=this._machine.speed),null!=this._machine.parameters&&this._machine.parameters.length>0){var n=this._machine.parameters;n.forEach(function(n){var a=n.name,i=n.type,r=(n.curve,n.defaultFloat),o=n.defaultBool,s=n.defaultInt;t._parameters.set(a,i),i===e.AnimatorParameterType.Bool?t.setBool(a,o):i===e.AnimatorParameterType.Float?t.setFloat(a,r):i===e.AnimatorParameterType.Int?t.setInteger(a,s):i===e.AnimatorParameterType.Trigger&&t.resetTrigger(a)})}null!=this._machine.layers&&this._machine.layers.length>0&&(this._layercount=this._machine.layers.length,this._machine.layers.sort(function(e,t){return e.index<t.index?-1:e.index>t.index?1:0}),this._machine.layers.forEach(function(e){if(null!=e.avatarMask&&null!=e.avatarMask.transformPaths&&e.avatarMask.transformPaths.length>0)for(var n=0;n<e.avatarMask.transformPaths.length;n++)t.m_avatarMask.set(e.avatarMask.transformPaths[n],n)}))}if(null!=this._source&&""!==this._source&&null!=this.scene.animationGroups){var a=null;this.scene.animationGroups.forEach(function(e){var n=e;null!=n&&null!=n.metadata&&null!=n.metadata.unity&&null!=n.metadata.unity.source&&""!==n.metadata.unity.source&&n.metadata.unity.source===t._source&&(null==a&&(a=[]),a.push(e))}),null!=a&&a.length>0&&this.setAnimationGroups(a)}null!=this._machine&&null!=this._machine.states&&this._machine.states.length>0&&this._machine.states.forEach(function(e){null!=e&&null!=e.name&&(t.setupTreeBranches(e.blendtree),t.setMachineState(e.name,e))})},n.prototype.lateStateMachine=function(e){var t=this;if(void 0===e&&(e=null),this._executed===!1&&(this._executed=!0,null!=this._machine.layers&&this._machine.layers.length>0&&this._machine.layers.forEach(function(e){t.setCurrentAnimationState(e,e.entry,0)})),this.enableAnimation===!0){var n=e||this.getDeltaSeconds();this.updateAnimationState(n),this.updateAnimationCurves(n),this.updateAnimationTargets(n),this.onAnimationUpdateObservable.hasObservers()===!0&&this.onAnimationUpdateObservable.notifyObservers(this.transform)}},n.prototype.destroyStateMachine=function(){this._data=null,this._anims=null,this._numbers=null,this._booleans=null,this._triggers=null,this._parameters=null,this._checkers=null,this._machine=null,this.onAnimationIKObservable.clear(),this.onAnimationIKObservable=null,this.onAnimationEndObservable.clear(),this.onAnimationEndObservable=null,this.onAnimationLoopObservable.clear(),this.onAnimationLoopObservable=null,this.onAnimationEventObservable.clear(),this.onAnimationEventObservable=null,this.onAnimationUpdateObservable.clear(),this.onAnimationUpdateObservable=null},n.prototype.updateAnimationState=function(e){var t=this;null!=this._machine.layers&&this._machine.layers.length>0&&this._machine.layers.forEach(function(n){t.checkStateMachine(n,e)})},n.prototype.updateAnimationCurves=function(e){},n.prototype.updateAnimationTargets=function(t){var n=this;null!=this.transform.rotationQuaternion||null!=this.transform.rotation,null!=this._machine.layers&&this._machine.layers.length>0&&this._machine.layers.forEach(function(a){if(0===a.index&&(n._frametime=a.animationTime),null!=a.animationStateMachine&&null!=a.animationStateMachine.blendtree){a.iKPass===!0&&n.onAnimationIKObservable.hasObservers()===!0&&n.onAnimationIKObservable.notifyObservers(a.index);var i=a.animationStateMachine;if(i.type===e.MotionType.Clip&&i.played!==-1&&(i.played+=t),null!=i.blendtree.children&&i.blendtree.children.length>0){var r=i.blendtree.children[0];if(null!=r)if(i.blendtree.blendType==e.BlendTreeType.Clip){var o=r.track;if(null!=o){var s=e.AnimationState.TIME/o.to;a.animationNormal=a.animationTime/e.AnimationState.TIME;var l=a.animationNormal>.99?1:a.animationNormal,u=Math.round(100*l)/100;i.speed<0&&(a.animationNormal=1-a.animationNormal);var c=o.to*a.animationNormal,h=0,m=!1,p=!1,d=0,g=!1,f=0,y=!1,_=!1,v=!1,M=!1,S=!1,b=!1,T=o;null!=T.metadata&&null!=T.metadata.unity&&null!=T.metadata.unity.settings&&(h=null!=T.metadata.unity.settings.level?T.metadata.unity.settings.level:0,m=null!=T.metadata.unity.settings.looptime&&T.metadata.unity.settings.looptime,p=null!=T.metadata.unity.settings.loopblend&&T.metadata.unity.settings.loopblend,d=null!=T.metadata.unity.settings.cycleoffset?T.metadata.unity.settings.cycleoffset:0,g=null!=T.metadata.unity.settings.heightfromfeet&&T.metadata.unity.settings.heightfromfeet,f=null!=T.metadata.unity.settings.orientationoffsety?T.metadata.unity.settings.orientationoffsety:0,y=null!=T.metadata.unity.settings.keeporiginalorientation&&T.metadata.unity.settings.keeporiginalorientation,_=null!=T.metadata.unity.settings.keeporiginalpositionxz&&T.metadata.unity.settings.keeporiginalpositionxz,v=null!=T.metadata.unity.settings.keeporiginalpositiony&&T.metadata.unity.settings.keeporiginalpositiony,M=null!=T.metadata.unity.settings.loopblendorientation&&T.metadata.unity.settings.loopblendorientation,S=null!=T.metadata.unity.settings.loopblendpositiony&&T.metadata.unity.settings.loopblendpositiony,b=null!=T.metadata.unity.settings.loopblendpositionxz&&T.metadata.unity.settings.loopblendpositionxz),f=e.Tools.ToRadians(f),f*=-1,h*=-1,a.animationTime>=e.AnimationState.TIME&&(a.animationFirstRun=!1,a.animationLoopFrame=!0,m===!0?n.onAnimationLoopObservable.hasObservers()===!0&&n.onAnimationLoopObservable.notifyObservers(a.index):a.animationEndFrame===!1&&(a.animationEndFrame=!0,n.onAnimationEndObservable.hasObservers()===!0&&n.onAnimationEndObservable.notifyObservers(a.index))),a.animationFirstRun!==!0&&m!==!0||o.targetedAnimations.forEach(function(t){if(t.target instanceof e.TransformNode){var i=t.target;if(0===a.index||null==a.avatarMask||n.filterTargetAvatarMask(a,i)){var r=null!=i.metadata&&null!=i.metadata.unity&&null!=i.metadata.unity.rootbone&&i.metadata.unity.rootbone;if(null!=i.metadata&&null!=i.metadata.mixer){var o=i.metadata.mixer[a.index];if(null!=o)if("position"===t.animation.targetProperty)n._targetPosition=e.Utilities.SampleAnimationVector3(t.animation,c),r===!0?(n._positionWeight=!1,n._positionHolder.set(0,0,0),n._rootBoneWeight=!1,n._rootBoneHolder.set(0,0,0),n.applyRootMotion===!0?S===!0&&b===!0?(n._positionWeight=!0,n._positionHolder.set(n._targetPosition.x,n._targetPosition.y+h,n._targetPosition.z)):S===!1&&b===!1?(n._rootBoneWeight=!0,n._rootBoneHolder.set(n._targetPosition.x,n._targetPosition.y+h,n._targetPosition.z)):S===!0&&b===!1?(n._positionWeight=!0,n._positionHolder.set(0,n._targetPosition.y+h,0),n._rootBoneWeight=!0,n._rootBoneHolder.set(n._targetPosition.x,0,n._targetPosition.z)):b===!0&&S===!1&&(n._positionWeight=!0,n._positionHolder.set(n._targetPosition.x,0,n._targetPosition.z),n._rootBoneWeight=!0,n._rootBoneHolder.set(0,n._targetPosition.y+h,0)):n._processmotion===!0?(n._positionWeight=!0,n._positionHolder.set(0,n._targetPosition.y+h,0),n._rootBoneWeight=!0,n._rootBoneHolder.set(0,0,0)):(n._positionWeight=!0,n._positionHolder.set(n._targetPosition.x,n._targetPosition.y+h,n._targetPosition.z)),n._positionWeight===!0&&(null==o.positionBuffer&&(o.positionBuffer=new e.Vector3(0,0,0)),e.Utilities.BlendVector3Value(o.positionBuffer,n._positionHolder,1)),n._rootBoneWeight===!0&&(null==o.rootPosition&&(o.rootPosition=new e.Vector3(0,0,0)),e.Utilities.BlendVector3Value(o.rootPosition,n._rootBoneHolder,1))):(null==o.positionBuffer&&(o.positionBuffer=new e.Vector3(0,0,0)),e.Utilities.BlendVector3Value(o.positionBuffer,n._targetPosition,1));else if("rotationQuaternion"===t.animation.targetProperty)if(n._targetRotation=e.Utilities.SampleAnimationQuaternion(t.animation,c),r===!0){n._rotationWeight=!1,n._rotationHolder.set(0,0,0,0),n._rootQuatWeight=!1,n._rootQuatHolder.set(0,0,0,0);var s=n._targetRotation.toEulerAngles(),l=s.y;n.applyRootMotion===!0?M===!0?(n._rotationWeight=!0,e.Quaternion.FromEulerAnglesToRef(s.x,l+f,s.z,n._rotationHolder)):(n._rotationWeight=!0,e.Quaternion.FromEulerAnglesToRef(s.x,0,s.z,n._rotationHolder),n._rootQuatWeight=!0,e.Quaternion.FromEulerAnglesToRef(0,l+f,0,n._rootQuatHolder)):(n._rotationWeight=!0,e.Quaternion.FromEulerAnglesToRef(s.x,l+f,s.z,n._rotationHolder)),n._rotationWeight===!0&&(null==o.rotationBuffer&&(o.rotationBuffer=new e.Quaternion(0,0,0,1)),e.Utilities.BlendQuaternionValue(o.rotationBuffer,n._rotationHolder,1)),n._rootQuatWeight===!0&&(null==o.rootRotation&&(o.rootRotation=new e.Quaternion(0,0,0,1)),e.Utilities.BlendQuaternionValue(o.rootRotation,n._rootQuatHolder,1))}else null==o.rotationBuffer&&(o.rotationBuffer=new e.Quaternion(0,0,0,1)),e.Utilities.BlendQuaternionValue(o.rotationBuffer,n._targetRotation,1);else"scaling"===t.animation.targetProperty&&(n._targetScaling=e.Utilities.SampleAnimationVector3(t.animation,c),null==o.scalingBuffer&&(o.scalingBuffer=new e.Vector3(1,1,1)),e.Utilities.BlendVector3Value(o.scalingBuffer,n._targetScaling,1))}}}else if(t.target instanceof e.MorphTarget){var u=t.target;if(null!=u.metadata&&null!=u.metadata.mixer){var m=u.metadata.mixer[a.index];if("influence"===t.animation.targetProperty){var p=e.Utilities.SampleAnimationFloat(t.animation,c);null==m.influenceBuffer&&(m.influenceBuffer=0),m.influenceBuffer=e.Utilities.BlendFloatValue(m.influenceBuffer,p,1)}}}}),null!=a.animationStateMachine.events&&a.animationStateMachine.events.length>0&&a.animationStateMachine.events.forEach(function(e){if(e.time===u){var t=e["function"]+"_"+e.time;null==a.animationLoopEvents&&(a.animationLoopEvents={}),a.animationLoopEvents[t]||(a.animationLoopEvents[t]=!0,n.onAnimationEventObservable.hasObservers()===!0&&n.onAnimationEventObservable.notifyObservers(e))}}),a.animationLoopFrame===!0?(a.animationTime=0,a.animationNormal=0,a.animationLoopFrame=!1,a.animationLoopEvents=null):(a.animationTime+=t*s*Math.abs(i.speed)*Math.abs(n.speedRatio),a.animationTime=e.Scalar.Clamp(a.animationTime,0,e.AnimationState.TIME))}}else{n._blendWeights.primary=null,n._blendWeights.secondary=null;var C=[],A=i.blendtree;n.parseTreeBranches(a,A,1,C);var s=n.computeWeightedFrameRatio(C);a.animationNormal=a.animationTime/e.AnimationState.TIME;var l=a.animationNormal>.99?1:a.animationNormal,P=Math.round(100*l)/100;i.speed<0&&(a.animationNormal=1-a.animationNormal);var x=a.animationNormal;a.animationTime>=e.AnimationState.TIME&&(a.animationLoopFrame=!0);var O=null!=C&&C.length>0&&null!=C[0].track?C[0].track:null;if(null!=O)for(var w=O.targetedAnimations.length,B=0;B<w;B++){var R=O.targetedAnimations[B];if(R.target instanceof e.TransformNode){var I=R.target;if(0===a.index||null==a.avatarMask||n.filterTargetAvatarMask(a,I)){var k=null!=I.metadata&&null!=I.metadata.unity&&null!=I.metadata.unity.rootbone&&I.metadata.unity.rootbone;if(null!=I.metadata&&null!=I.metadata.mixer){n._initialtargetblending=!0;var L=I.metadata.mixer[a.index];n.updateBlendableTargets(t,a,A,R,B,L,x,k)}}}}null!=a.animationStateMachine.events&&a.animationStateMachine.events.length>0&&a.animationStateMachine.events.forEach(function(e){if(e.time===P){var t=e["function"]+"_"+e.time;null==a.animationLoopEvents&&(a.animationLoopEvents={}),a.animationLoopEvents[t]||(a.animationLoopEvents[t]=!0,n.onAnimationEventObservable.hasObservers()===!0&&n.onAnimationEventObservable.notifyObservers(e))}}),a.animationLoopFrame===!0?(a.animationTime=0,a.animationNormal=0,a.animationLoopFrame=!1,a.animationLoopEvents=null):(a.animationTime+=t*s*Math.abs(i.speed)*Math.abs(n.speedRatio),a.animationTime=e.Scalar.Clamp(a.animationTime,0,e.AnimationState.TIME))}}}}),this.finalizeAnimationTargets()},n.prototype.updateBlendableTargets=function(t,n,a,i,r,o,s,l){if(null!=o&&null!=a.children&&a.children.length>0)for(var u=0;u<a.children.length;u++){var c=a.children[u];if(c.weight>0)if(c.type===e.MotionType.Clip){if(null!=c.track){var h=0,m=!1,p=0,d=!1,g=0,f=!1,y=!1,_=!1,v=!1,M=!1,S=!1,b=c.track;null!=b.metadata&&null!=b.metadata.unity&&null!=b.metadata.unity.settings&&(h=null!=b.metadata.unity.settings.level?b.metadata.unity.settings.level:0,m=null!=b.metadata.unity.settings.loopblend&&b.metadata.unity.settings.loopblend,p=null!=b.metadata.unity.settings.cycleoffset?b.metadata.unity.settings.cycleoffset:0,d=null!=b.metadata.unity.settings.heightfromfeet&&b.metadata.unity.settings.heightfromfeet,g=null!=b.metadata.unity.settings.orientationoffsety?b.metadata.unity.settings.orientationoffsety:0,f=null!=b.metadata.unity.settings.keeporiginalorientation&&b.metadata.unity.settings.keeporiginalorientation,y=null!=b.metadata.unity.settings.keeporiginalpositionxz&&b.metadata.unity.settings.keeporiginalpositionxz,_=null!=b.metadata.unity.settings.keeporiginalpositiony&&b.metadata.unity.settings.keeporiginalpositiony,v=null!=b.metadata.unity.settings.loopblendorientation&&b.metadata.unity.settings.loopblendorientation,M=null!=b.metadata.unity.settings.loopblendpositiony&&b.metadata.unity.settings.loopblendpositiony,S=null!=b.metadata.unity.settings.loopblendpositionxz&&b.metadata.unity.settings.loopblendpositionxz),g=e.Tools.ToRadians(g),g*=-1,h*=-1;var T=c.track.targetedAnimations[r],C=this._initialtargetblending===!0?1:parseFloat(c.weight.toFixed(2));if(this._initialtargetblending=!1,T.target===i.target&&T.animation.targetProperty===i.animation.targetProperty){var A=s;c.timescale<0&&(A=1-A);var P=c.track.to*A;if("position"===i.animation.targetProperty)this._targetPosition=e.Utilities.SampleAnimationVector3(T.animation,P),l===!0?(this._positionWeight=!1,this._positionHolder.set(0,0,0),this._rootBoneWeight=!1,this._rootBoneHolder.set(0,0,0),this.applyRootMotion===!0?M===!0&&S===!0?(this._positionWeight=!0,this._positionHolder.set(this._targetPosition.x,this._targetPosition.y+h,this._targetPosition.z)):M===!1&&S===!1?(this._rootBoneWeight=!0,this._rootBoneHolder.set(this._targetPosition.x,this._targetPosition.y+h,this._targetPosition.z)):M===!0&&S===!1?(this._positionWeight=!0,this._positionHolder.set(0,this._targetPosition.y+h,0),this._rootBoneWeight=!0,this._rootBoneHolder.set(this._targetPosition.x,0,this._targetPosition.z)):S===!0&&M===!1&&(this._positionWeight=!0,this._positionHolder.set(this._targetPosition.x,0,this._targetPosition.z),this._rootBoneWeight=!0,this._rootBoneHolder.set(0,this._targetPosition.y+h,0)):this._processmotion===!0?(this._positionWeight=!0,this._positionHolder.set(0,this._targetPosition.y+h,0),this._rootBoneWeight=!0,this._rootBoneHolder.set(0,0,0)):(this._positionWeight=!0,this._positionHolder.set(this._targetPosition.x,this._targetPosition.y+h,this._targetPosition.z)),this._positionWeight===!0&&(null==o.positionBuffer&&(o.positionBuffer=new e.Vector3(0,0,0)),e.Utilities.BlendVector3Value(o.positionBuffer,this._positionHolder,C)),this._rootBoneWeight===!0&&(null==o.rootPosition&&(o.rootPosition=new e.Vector3(0,0,0)),e.Utilities.BlendVector3Value(o.rootPosition,this._rootBoneHolder,C))):(null==o.positionBuffer&&(o.positionBuffer=new e.Vector3(0,0,0)),e.Utilities.BlendVector3Value(o.positionBuffer,this._targetPosition,C));else if("rotationQuaternion"===i.animation.targetProperty)if(this._targetRotation=e.Utilities.SampleAnimationQuaternion(T.animation,P),l===!0){this._rotationWeight=!1,this._rotationHolder.set(0,0,0,0),this._rootQuatWeight=!1,this._rootQuatHolder.set(0,0,0,0);var x=this._targetRotation.toEulerAngles(),O=x.y;this.applyRootMotion===!0?v===!0?(this._rotationWeight=!0,e.Quaternion.FromEulerAnglesToRef(x.x,O+g,x.z,this._rotationHolder)):(this._rotationWeight=!0,e.Quaternion.FromEulerAnglesToRef(x.x,0,x.z,this._rotationHolder),this._rootQuatWeight=!0,e.Quaternion.FromEulerAnglesToRef(0,O+g,0,this._rootQuatHolder)):(this._rotationWeight=!0,e.Quaternion.FromEulerAnglesToRef(x.x,O+g,x.z,this._rotationHolder)),this._rotationWeight===!0&&(null==o.rotationBuffer&&(o.rotationBuffer=new e.Quaternion(0,0,0,1)),e.Utilities.BlendQuaternionValue(o.rotationBuffer,this._rotationHolder,C)),this._rootQuatWeight===!0&&(null==o.rootRotation&&(o.rootRotation=new e.Quaternion(0,0,0,1)),e.Utilities.BlendQuaternionValue(o.rootRotation,this._rootQuatHolder,C))}else null==o.rotationBuffer&&(o.rotationBuffer=new e.Quaternion(0,0,0,1)),e.Utilities.BlendQuaternionValue(o.rotationBuffer,this._targetRotation,C);else"scaling"===i.animation.targetProperty&&(this._targetScaling=e.Utilities.SampleAnimationVector3(T.animation,P),null==o.scalingBuffer&&(o.scalingBuffer=new e.Vector3(1,1,1)),e.Utilities.BlendVector3Value(o.scalingBuffer,this._targetScaling,C))}else e.Tools.Warn(a.name+" - "+c.track.name+" blend tree mismatch ("+r+"): "+i.target.name+" >>> "+T.target.name)}}else c.type===e.MotionType.Tree&&this.updateBlendableTargets(t,n,c.subtree,i,r,o,s,l)}},n.prototype.finalizeAnimationTargets=function(){var t=this;this._deltaAngleY=0,this._deltaPosition.set(0,0,0),this._deltaRotation.set(0,0,0,1),this._dirtyMotionMatrix=null,null!=this.m_animationTargets&&this.m_animationTargets.length>0&&this.m_animationTargets.forEach(function(n){var a=n.target;null!=a.metadata&&null!=a.metadata.mixer&&null!=t._machine.layers&&t._machine.layers.length>0&&(t._blenderMatrix.reset(),t._dirtyBlenderMatrix=null,t._machine.layers.forEach(function(n){var i=a.metadata.mixer[n.index];null!=i&&(a instanceof e.TransformNode?(null==i.positionBuffer&&null==i.rotationBuffer&&null==i.scalingBuffer||(e.Matrix.ComposeToRef(i.scalingBuffer||a.scaling,i.rotationBuffer||a.rotationQuaternion,i.positionBuffer||a.position,t._updateMatrix),i.blendingSpeed>0&&(i.blendingFactor<=1&&null==i.originalMatrix&&(i.originalMatrix=e.Matrix.Compose(a.scaling,a.rotationQuaternion,a.position)),i.blendingFactor<=1&&null!=i.originalMatrix&&(e.Utilities.FastMatrixSlerp(i.originalMatrix,t._updateMatrix,i.blendingFactor,t._updateMatrix),i.blendingFactor+=i.blendingSpeed)),e.Utilities.FastMatrixSlerp(t._blenderMatrix,t._updateMatrix,n.defaultWeight,t._blenderMatrix),t._dirtyBlenderMatrix=!0,i.positionBuffer=null,i.rotationBuffer=null,i.scalingBuffer=null),null==i.rootPosition&&null==i.rootRotation||(e.Matrix.ComposeToRef(t.transform.scaling,i.rootRotation||t.transform.rotationQuaternion,i.rootPosition||t.transform.position,t._updateMatrix),e.Utilities.FastMatrixSlerp(t._rootMotionMatrix,t._updateMatrix,n.defaultWeight,t._rootMotionMatrix),t._dirtyMotionMatrix=!0,i.rootPosition=null,i.rootRotation=null)):a instanceof e.MorphTarget&&null!=i.influenceBuffer&&(a.influence=e.Scalar.Lerp(a.influence,i.influenceBuffer,n.defaultWeight),i.influenceBuffer=null))}),null!=t._dirtyBlenderMatrix&&t._blenderMatrix.decompose(a.scaling,a.rotationQuaternion,a.position))}),null!=this._dirtyMotionMatrix&&(this._rootMotionMatrix.decompose(this._rootMotionScaling,this._rootMotionRotation,this._rootMotionPosition),0===this._frametime&&(this._lastMotionPosition.copyFrom(this._rootMotionPosition),this._lastMotionRotation.copyFrom(this._rootMotionRotation)),null!=this.applyRootMotion&&(this._rootMotionPosition.subtractToRef(this._lastMotionPosition,this._deltaPosition),e.Utilities.QuaternionDiffToRef(this._lastMotionRotation,this._rootMotionRotation,this._quatRotationDiff),this._quatRotationDiff.toEulerAnglesToRef(this._quatRotateVector),this._deltaAngleY=this._quatRotateVector.y,e.Quaternion.FromEulerAnglesToRef(0,this._deltaAngleY,0,this._deltaRotation),this._lastMotionPosition.addInPlace(this._deltaPosition),this._lastMotionRotation.multiplyInPlace(this._deltaRotation)))},n.prototype.checkStateMachine=function(t,n){var a=this;this._checkers.result=null,this._checkers.offest=0,this._checkers.blending=0,this._checkers.triggered=[],null!=t.animationStateMachine&&(this.checkStateTransitions(t,t.animationStateMachine.transitions,t.animationStateMachine.time,t.animationStateMachine.length,t.animationStateMachine.rate),null==this._checkers.result&&null!=this._machine.transitions&&this.checkStateTransitions(t,this._machine.transitions,t.animationStateMachine.time,t.animationStateMachine.length,t.animationStateMachine.rate)),null!=this._checkers.triggered&&this._checkers.triggered.length>0&&(this._checkers.triggered.forEach(function(e){a.resetTrigger(e)}),this._checkers.triggered=null),null!=this._checkers.result&&(this._checkers.offest>0?e.SceneManager.SetTimeout(1e3*this._checkers.offest,function(){a.setCurrentAnimationState(t,a._checkers.result,a._checkers.blending)}):this.setCurrentAnimationState(t,this._checkers.result,this._checkers.blending))},n.prototype.checkStateTransitions=function(t,n,a,i,r){var o=this;if(null!=n&&n.length>0){var s=0,l=-1;for(s=0;s<n.length;s++)if(n[s].solo===!0&&n[s].mute===!1){l=s;break}var u=function(){var u=n[s];if(u.layerIndex!==t.index)return"continue";if(u.mute===!0)return"continue";if(l>=0&&l!==s)return"continue";var h=!1,m=e.Scalar.Denormalize(u.exitTime,0,i),p=e.SceneManager.GetGameTime()-a>=m;if(u.hasExitTime===!0&&u.intSource==e.InterruptionSource.None&&p===!1)return"continue";if(null!=u.conditions&&u.conditions.length>0){var d=0,g=u.conditions.length;u.conditions.forEach(function(t){var n=o._parameters.get(t.parameter);if(null!=n)if(n==e.AnimatorParameterType.Float||n==e.AnimatorParameterType.Int){var a=parseFloat(o.getFloat(t.parameter).toFixed(2));t.mode===e.ConditionMode.Greater&&a>t.threshold?d++:t.mode===e.ConditionMode.Less&&a<t.threshold?d++:t.mode===e.ConditionMode.Equals&&a===t.threshold?d++:t.mode===e.ConditionMode.NotEqual&&a!==t.threshold&&d++}else if(n==e.AnimatorParameterType.Bool){var i=o.getBool(t.parameter);t.mode===e.ConditionMode.If&&i===!0?d++:t.mode===e.ConditionMode.IfNot&&i===!1&&d++}else if(n==e.AnimatorParameterType.Trigger){var r=o.getTrigger(t.parameter);if(r===!0){d++;for(var s=-1,l=0;l<o._checkers.triggered.length;l++)if(o._checkers.triggered[l]===t.parameter){s=l;break}s<0&&o._checkers.triggered.push(t.parameter)}}}),h=u.hasExitTime===!0?p===!0&&d===g:d===g}else h=u.hasExitTime===!0&&p===!0;if(h===!0){
- var f=i>0?i:1,y=r>0?r:e.AnimationState.FPS,_=u.isExit===!1?u.destination:e.AnimationState.EXIT,v=u.fixedDuration===!0?u.offset:e.Scalar.Denormalize(u.offset,0,f),M=u.fixedDuration===!0?u.duration:e.Scalar.Denormalize(u.duration,0,f),S=e.Utilities.ComputeBlendingSpeed(y,M);return c._checkers.result=_,c._checkers.offest=v,c._checkers.blending=S,"break"}},c=this;for(s=0;s<n.length;s++){var h=u();if("break"===h)break}}},n.prototype.setCurrentAnimationState=function(t,n,a){if(null!=n&&""!==n&&n!==e.AnimationState.EXIT&&(null==t.animationStateMachine||t.animationStateMachine.name!==n)){var i=this.getMachineState(n);null!=this.m_animationTargets&&this.m_animationTargets.length>0&&this.m_animationTargets.forEach(function(e){var n=e.target;if(null!=n.metadata&&null!=n.metadata.mixer){var i=n.metadata.mixer[t.index];null!=i&&(i.originalMatrix=null,i.blendingFactor=0,i.blendingSpeed=a)}}),null!=i&&i.layerIndex===t.index&&(i.time=0,i.played=0,i.interrupted=!1,t.animationTime=0,t.animationNormal=0,t.animationFirstRun=!0,t.animationEndFrame=!1,t.animationLoopFrame=!1,t.animationLoopEvents=null,t.animationStateMachine=i,t.animationStateMachine.time=e.SceneManager.GetGameTime())}},n.prototype.checkAvatarTransformPath=function(e,t){var n=!1;if(null!=this.m_avatarMask){var a=this.m_avatarMask.get(t);null!=a&&a>=0&&(n=!0)}return n},n.prototype.filterTargetAvatarMask=function(e,t){var n=!1;if(null!=t.metadata&&null!=t.metadata.unity&&null!=t.metadata.unity.bone&&""!==t.metadata.unity.bone){var a=t.metadata.unity.bone;n=this.checkAvatarTransformPath(e,a)}return n},n.prototype.sortWeightedBlendingList=function(e){null!=e&&e.length>0&&e.sort(function(e,t){return e.weight<t.weight?1:e.weight>t.weight?-1:0})},n.prototype.computeWeightedFrameRatio=function(t){var n=1;if(null!=t&&t.length>0){this.sortWeightedBlendingList(t),this._blendWeights.primary=t[0];var a=this._blendWeights.primary.weight;if(a<1&&t.length>1&&(this._blendWeights.secondary=t[1]),null!=this._blendWeights.primary&&null!=this._blendWeights.secondary){var i=e.Scalar.Clamp(this._blendWeights.primary.weight);n=e.Scalar.Lerp(this._blendWeights.secondary.ratio,this._blendWeights.primary.ratio,i)}else null!=this._blendWeights.primary&&null==this._blendWeights.secondary&&(n=this._blendWeights.primary.ratio)}return n},n.prototype.setupTreeBranches=function(t){var n=this;null!=t&&null!=t.children&&t.children.length>0&&t.children.forEach(function(t){t.type===e.MotionType.Tree?n.setupTreeBranches(t.subtree):t.type===e.MotionType.Clip&&null!=t.motion&&""!==t.motion&&(t.weight=0,t.ratio=0,t.track=n.getAnimationGroup(t.motion),null!=t.track&&(t.ratio=e.AnimationState.TIME/t.track.to))})},n.prototype.parseTreeBranches=function(t,n,a,i){if(null!=n)switch(n.valueParameterX=null!=n.blendParameterX?parseFloat(this.getFloat(n.blendParameterX).toFixed(2)):0,n.valueParameterY=null!=n.blendParameterY?parseFloat(this.getFloat(n.blendParameterY).toFixed(2)):0,n.blendType){case e.BlendTreeType.Simple1D:this.parse1DSimpleTreeBranches(t,n,a,i);break;case e.BlendTreeType.SimpleDirectional2D:this.parse2DSimpleDirectionalTreeBranches(t,n,a,i);break;case e.BlendTreeType.FreeformDirectional2D:this.parse2DFreeformDirectionalTreeBranches(t,n,a,i);break;case e.BlendTreeType.FreeformCartesian2D:this.parse2DFreeformCartesianTreeBranches(t,n,a,i)}},n.prototype.parse1DSimpleTreeBranches=function(t,n,a,i){var r=this;if(null!=n&&null!=n.children&&n.children.length>0){var o=[];n.children.forEach(function(e){e.weight=0;var t={source:e,motion:e.motion,posX:e.threshold,posY:e.threshold,weight:e.weight};o.push(t)}),e.BlendTreeSystem.Calculate1DSimpleBlendTree(n.valueParameterX,o),o.forEach(function(e){null!=e.source&&(e.source.weight=e.weight)}),n.children.forEach(function(n){n.weight*=a,n.type===e.MotionType.Clip&&n.weight>0&&i.push(n),n.type===e.MotionType.Tree&&r.parseTreeBranches(t,n.subtree,n.weight,i)})}},n.prototype.parse2DSimpleDirectionalTreeBranches=function(t,n,a,i){var r=this;if(null!=n&&null!=n.children&&n.children.length>0){var o=[];n.children.forEach(function(e){e.weight=0;var t={source:e,motion:e.motion,posX:e.positionX,posY:e.positionY,weight:e.weight};o.push(t)}),e.BlendTreeSystem.Calculate2DFreeformDirectional(n.valueParameterX,n.valueParameterY,o),o.forEach(function(e){null!=e.source&&(e.source.weight=e.weight)}),n.children.forEach(function(n){n.weight*=a,n.type===e.MotionType.Clip&&n.weight>0&&i.push(n),n.type===e.MotionType.Tree&&r.parseTreeBranches(t,n.subtree,n.weight,i)})}},n.prototype.parse2DFreeformDirectionalTreeBranches=function(t,n,a,i){var r=this;if(null!=n&&null!=n.children&&n.children.length>0){var o=[];n.children.forEach(function(e){e.weight=0;var t={source:e,motion:e.motion,posX:e.positionX,posY:e.positionY,weight:e.weight};o.push(t)}),e.BlendTreeSystem.Calculate2DFreeformDirectional(n.valueParameterX,n.valueParameterY,o),o.forEach(function(e){null!=e.source&&(e.source.weight=e.weight)}),n.children.forEach(function(n){n.weight*=a,n.type===e.MotionType.Clip&&n.weight>0&&i.push(n),n.type===e.MotionType.Tree&&r.parseTreeBranches(t,n.subtree,n.weight,i)})}},n.prototype.parse2DFreeformCartesianTreeBranches=function(t,n,a,i){var r=this;if(null!=n&&null!=n.children&&n.children.length>0){var o=[];n.children.forEach(function(e){e.weight=0;var t={source:e,motion:e.motion,posX:e.positionX,posY:e.positionY,weight:e.weight};o.push(t)}),e.BlendTreeSystem.Calculate2DFreeformCartesian(n.valueParameterX,n.valueParameterY,o),o.forEach(function(e){null!=e.source&&(e.source.weight=e.weight)}),n.children.forEach(function(n){n.weight*=a,n.type===e.MotionType.Clip&&n.weight>0&&i.push(n),n.type===e.MotionType.Tree&&r.parseTreeBranches(t,n.subtree,n.weight,i)})}},n.FPS=30,n.TIME=1,n.EXIT="[EXIT]",n.MOTION=.001,n}(e.ScriptComponent);e.AnimationState=t;var n=function(){function e(e){this.source=e.source,this.motion=e.motion,this.posX=e.posX||0,this.posY=e.posY||0,this.weight=e.weight||0}return e}();e.BlendTreeValue=n;var a=function(){function e(){}return e.ClampValue=function(e,t,n){return e<=t?t:e>=n?n:e},e.GetSignedAngle=function(e,t){return Math.atan2(e.x*t.y-e.y*t.x,e.x*t.x+e.y*t.y)},e.GetLinearInterpolation=function(e,t,n,a,i){return t+(i-e)*((a-t)/(n-e))},e.GetRightNeighbourIndex=function(e,t){t.sort(function(e,t){return e.posX-t.posX});for(var n=0;n<t.length;++n)if(t[n].posX>e)return n;return-1},e}();e.BlendTreeUtils=a;var i=function(){function t(){}return t.Calculate1DSimpleBlendTree=function(t,n){var a=n[0],i=n[n.length-1];if(t<=a.posX)a.weight=1;else if(t>=i.posX)i.weight=1;else{var r=e.BlendTreeUtils.GetRightNeighbourIndex(t,n),o=n[r-1],s=n[r],l=e.BlendTreeUtils.GetLinearInterpolation(o.posX,1,s.posX,0,t);o.weight=l,s.weight=1-o.weight}},t.Calculate2DFreeformDirectional=function(t,n,a){e.BlendTreeSystem.TempVector2_IP.set(t,n),e.BlendTreeSystem.TempVector2_POSI.set(0,0),e.BlendTreeSystem.TempVector2_POSJ.set(0,0),e.BlendTreeSystem.TempVector2_POSIP.set(0,0),e.BlendTreeSystem.TempVector2_POSIJ.set(0,0);for(var i=2,r=0,o=e.BlendTreeSystem.TempVector2_IP.length(),s=0;s<a.length;++s){var l=a[s];e.BlendTreeSystem.TempVector2_POSI.set(l.posX,l.posY);for(var u=e.BlendTreeSystem.TempVector2_POSI.length(),c=o-u,h=e.BlendTreeUtils.GetSignedAngle(e.BlendTreeSystem.TempVector2_POSI,e.BlendTreeSystem.TempVector2_IP),m=1,p=0;p<a.length;++p)if(p!==s){e.BlendTreeSystem.TempVector2_POSJ.set(a[p].posX,a[p].posY);var d=e.BlendTreeSystem.TempVector2_POSJ.length(),g=(u+d)/2,f=c/g,y=(d-u)/g,_=e.BlendTreeUtils.GetSignedAngle(e.BlendTreeSystem.TempVector2_POSI,e.BlendTreeSystem.TempVector2_POSJ);e.BlendTreeSystem.TempVector2_POSIP.set(f,h*i),e.BlendTreeSystem.TempVector2_POSIJ.set(y,_*i);var v=e.BlendTreeSystem.TempVector2_POSIJ.lengthSquared(),M=e.Vector2.Dot(e.BlendTreeSystem.TempVector2_POSIP,e.BlendTreeSystem.TempVector2_POSIJ)/v;M=1-M,M=e.BlendTreeUtils.ClampValue(M,0,1),m=Math.min(M,m)}l.weight=m,r+=m}for(var S=0,b=a;S<b.length;S++){var l=b[S];l.weight/=r}},t.Calculate2DFreeformCartesian=function(t,n,a){e.BlendTreeSystem.TempVector2_IP.set(t,n),e.BlendTreeSystem.TempVector2_POSI.set(0,0),e.BlendTreeSystem.TempVector2_POSJ.set(0,0),e.BlendTreeSystem.TempVector2_POSIP.set(0,0),e.BlendTreeSystem.TempVector2_POSIJ.set(0,0);for(var i=0,r=0;r<a.length;++r){var o=a[r];e.BlendTreeSystem.TempVector2_POSI.set(o.posX,o.posY),e.BlendTreeSystem.TempVector2_IP.subtractToRef(e.BlendTreeSystem.TempVector2_POSI,e.BlendTreeSystem.TempVector2_POSIP);for(var s=1,l=0;l<a.length;++l)if(l!==r){e.BlendTreeSystem.TempVector2_POSJ.set(a[l].posX,a[l].posY),e.BlendTreeSystem.TempVector2_POSJ.subtractToRef(e.BlendTreeSystem.TempVector2_POSI,e.BlendTreeSystem.TempVector2_POSIJ);var u=e.BlendTreeSystem.TempVector2_POSIJ.lengthSquared(),c=e.Vector2.Dot(e.BlendTreeSystem.TempVector2_POSIP,e.BlendTreeSystem.TempVector2_POSIJ)/u;c=1-c,c=e.BlendTreeUtils.ClampValue(c,0,1),s=Math.min(s,c)}o.weight=s,i+=s}for(var h=0,m=a;h<m.length;h++){var o=m[h];o.weight/=i}},t.TempVector2_IP=new e.Vector2(0,0),t.TempVector2_POSI=new e.Vector2(0,0),t.TempVector2_POSJ=new e.Vector2(0,0),t.TempVector2_POSIP=new e.Vector2(0,0),t.TempVector2_POSIJ=new e.Vector2(0,0),t}();e.BlendTreeSystem=i;var r=function(){function e(){}return e}();e.MachineState=r;var o=function(){function e(){}return e}();e.TransitionCheck=o;var s=function(){function e(){}return e}();e.AnimationMixer=s;var l=function(){function e(){}return e}();e.BlendingWeights=l;var u;!function(e){e[e.Clip=0]="Clip",e[e.Tree=1]="Tree"}(u=e.MotionType||(e.MotionType={}));var c;!function(e){e[e.If=1]="If",e[e.IfNot=2]="IfNot",e[e.Greater=3]="Greater",e[e.Less=4]="Less",e[e.Equals=6]="Equals",e[e.NotEqual=7]="NotEqual"}(c=e.ConditionMode||(e.ConditionMode={}));var h;!function(e){e[e.None=0]="None",e[e.Source=1]="Source",e[e.Destination=2]="Destination",e[e.SourceThenDestination=3]="SourceThenDestination",e[e.DestinationThenSource=4]="DestinationThenSource"}(h=e.InterruptionSource||(e.InterruptionSource={}));var m;!function(e){e[e.Simple1D=0]="Simple1D",e[e.SimpleDirectional2D=1]="SimpleDirectional2D",e[e.FreeformDirectional2D=2]="FreeformDirectional2D",e[e.FreeformCartesian2D=3]="FreeformCartesian2D",e[e.Direct=4]="Direct",e[e.Clip=5]="Clip"}(m=e.BlendTreeType||(e.BlendTreeType={}));var p;!function(e){e[e.Lower=0]="Lower",e[e.Upper=1]="Upper"}(p=e.BlendTreePosition||(e.BlendTreePosition={}));var d;!function(e){e[e.Float=1]="Float",e[e.Int=3]="Int",e[e.Bool=4]="Bool",e[e.Trigger=9]="Trigger"}(d=e.AnimatorParameterType||(e.AnimatorParameterType={}))}(BABYLON||(BABYLON={}));var __extends=this&&this.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(t,n)};return function(t,n){function a(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(a.prototype=n.prototype,new a)}}(),BABYLON;!function(e){var t=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n._audio=null,n._name=null,n._file=null,n._loop=!1,n._mute=!1,n._volume=1,n._pitch=1,n._priority=128,n._panstereo=0,n._mindistance=1,n._maxdistance=50,n._rolloffmode="linear",n._rollofffactor=1,n._playonawake=!0,n._spatialblend=0,n._reverbzonemix=1,n._lastmutedvolume=null,n._bypasseffects=!1,n._bypassreverbzones=!1,n._bypasslistenereffects=!1,n._initializedReadyInstance=!1,n.onReadyObservable=new e.Observable,n}return __extends(n,t),n.prototype.getSoundClip=function(){return this._audio},n.prototype.getAudioElement=function(){return null!=this._audio?this._audio._htmlAudioElement:null},n.prototype.awake=function(){this.awakeAudioSource()},n.prototype.destroy=function(){this.destroyAudioSource()},n.prototype.awakeAudioSource=function(){var t=this;this._name=this.getProperty("name",this._name),this._file=this.getProperty("file",this._file),this._loop=this.getProperty("loop",this._loop),this._mute=this.getProperty("mute",this._mute),this._volume=this.getProperty("volume",this._volume),this._pitch=this.getProperty("pitch",this._pitch),this._priority=this.getProperty("priority",this._priority),this._panstereo=this.getProperty("panstereo",this._panstereo),this._playonawake=this.getProperty("playonawake",this._playonawake),this._mindistance=this.getProperty("mindistance",this._mindistance),this._maxdistance=this.getProperty("maxdistance",this._maxdistance),this._rolloffmode=this.getProperty("rolloffmode",this._rolloffmode),this._rollofffactor=this.getProperty("rollofffactor",this._rollofffactor),this._spatialblend=this.getProperty("spatialblend",this._spatialblend),this._reverbzonemix=this.getProperty("reverbzonemix",this._reverbzonemix),this._bypasseffects=this.getProperty("bypasseffects",this._bypasseffects),this._bypassreverbzones=this.getProperty("bypassreverbzones",this._bypassreverbzones),this._bypasslistenereffects=this.getProperty("bypasslistenereffects",this._bypasslistenereffects);var n=null!=this.transform.metadata&&null!=this.transform.metadata.vtt&&this.transform.metadata.vtt===!0;if(null!=this._name&&""!==this._name||(this._name="Unknown"),null!=this._file&&""!==this._file){var a=e.SceneManager.GetRootUrl(this.scene),i=this._spatialblend>=.1,r="logarithmic"===this._rolloffmode?"exponential":"linear";this._audio=new e.Sound(this._name,a+this._file,this.scene,function(){t._mute===!0?(t._lastmutedvolume=t._volume,t._audio.setVolume(0)):t._audio.setVolume(t._volume),t._audio.setVolume(t._mute===!0?0:t._volume),t._audio.setPlaybackRate(t._pitch),t._initializedReadyInstance=!0,t.onReadyObservable.hasObservers()===!0&&t.onReadyObservable.notifyObservers(t._audio)},{loop:this._loop,autoplay:this._playonawake,refDistance:this._mindistance,maxDistance:this._maxdistance,rolloffFactor:this._rollofffactor,spatialSound:i,distanceModel:r,streaming:n}),this._audio.setPosition(this.transform.position.clone()),i===!0&&this._audio.attachToMesh(this.transform)}},n.prototype.destroyAudioSource=function(){this.onReadyObservable.clear(),this.onReadyObservable=null,null!=this._audio&&(this._audio.dispose(),this._audio=null)},n.prototype.isReady=function(){var e=!1;return null!=this._audio&&(e=this._audio.isReady()),e},n.prototype.isPlaying=function(){var e=!1;return null!=this._audio&&(e=this._audio.isPlaying),e},n.prototype.isPaused=function(){var e=!1;return null!=this._audio&&(e=this._audio.isPaused),e},n.prototype.play=function(e,t,n){var a=this,i=!1;return null!=this._audio&&(this._initializedReadyInstance===!0?this._audio.play(e,t,n):this.onReadyObservable.addOnce(function(){a._audio.play(e,t,n)}),i=!0),i},n.prototype.pause=function(){var e=!1;return null!=this._audio&&(this._audio.pause(),e=!0),e},n.prototype.stop=function(e){var t=!1;return null!=this._audio&&(this._audio.stop(e),t=!0),t},n.prototype.mute=function(e){var t=!1;return null!=this._audio&&(this._lastmutedvolume=this._audio.getVolume(),this._audio.setVolume(0,e)),t},n.prototype.unmute=function(e){var t=!1;return null!=this._audio&&null!=this._lastmutedvolume&&(this._audio.setVolume(this._lastmutedvolume,e),this._lastmutedvolume=null),t},n.prototype.getVolume=function(){var e=0;return null!=this._audio&&(e=this._audio.getVolume()),e},n.prototype.setVolume=function(e,t){var n=!1;return null!=this._audio&&(this._audio.setVolume(e,t),n=!0),n},n.prototype.getSpatialSound=function(){var e=!1;return null!=this._audio&&(e=this._audio.spatialSound),e},n.prototype.setSpatialSound=function(e){null!=this._audio&&(this._audio.spatialSound=e)},n.prototype.setPlaybackSpeed=function(e){null!=this._audio&&this._audio.setPlaybackRate(e)},n.prototype.getCurrentTrackTime=function(){var e=0;return null!=this._audio&&(e=this._audio.currentTime),e},n}(e.ScriptComponent);e.AudioSource=t}(BABYLON||(BABYLON={}));var __extends=this&&this.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(t,n)};return function(t,n){function a(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(a.prototype=n.prototype,new a)}}(),BABYLON;!function(e){var t=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n._abstractMesh=null,n._avatarRadius=.5,n._avatarHeight=2,n._centerOffset=new e.Vector3(0,0,0),n._skinWidth=.08,n._stepOffset=.3,n._slopeLimit=45,n._capsuleSegments=16,n._minMoveDistance=.001,n._isPhysicsReady=!1,n._maxCollisions=4,n._useGhostSweepTest=!1,n._tmpCollisionContacts=null,n.updatePosition=!0,n.m_character=null,n.m_ghostShape=null,n.m_ghostObject=null,n.m_ghostCollision=null,n.m_ghostTransform=null,n.m_ghostPosition=null,n.m_startPosition=null,n.m_startTransform=null,n.m_walkDirection=null,n.m_warpPosition=null,n.m_turningRate=0,n.m_moveDeltaX=0,n.m_moveDeltaZ=0,n.m_physicsEngine=null,n.m_collisionPosition=e.Vector3.Zero(),n.onUpdatePositionObservable=new e.Observable,n.onCollisionEnterObservable=new e.Observable,n.onCollisionStayObservable=new e.Observable,n.onCollisionExitObservable=new e.Observable,n}return __extends(n,t),n.prototype.getInternalCharacter=function(){return this.m_character},n.prototype.getAvatarRadius=function(){return this._avatarRadius},n.prototype.getAvatarHeight=function(){return this._avatarHeight},n.prototype.getSkinWidth=function(){return this._skinWidth},n.prototype.getStepOffset=function(){return this._stepOffset},n.prototype.getUseSweepTest=function(){return this._useGhostSweepTest},n.prototype.getMinMoveDistance=function(){return this._minMoveDistance},n.prototype.setMinMoveDistance=function(e){this._minMoveDistance=e},n.prototype.getVerticalVelocity=function(){return null!=this.m_character&&this.m_character.getVerticalVelocity?this.m_character.getVerticalVelocity():0},n.prototype.getAddedMargin=function(){return null!=this.m_character&&this.m_character.getAddedMargin?this.m_character.getAddedMargin():0},n.prototype.setAddedMargin=function(e){null!=this.m_character&&this.m_character.getAddedMargin&&this.m_character.setAddedMargin(e)},n.prototype.setMaxJumpHeight=function(e){null!=this.m_character&&this.m_character.setMaxJumpHeight(e)},n.prototype.setFallingSpeed=function(e){null!=this.m_character&&this.m_character.setFallSpeed(e)},n.prototype.getSlopeLimit=function(){return null!=this.m_character?this.m_character.getMaxSlope():0},n.prototype.setSlopeLimit=function(e){null!=this.m_character&&this.m_character.setMaxSlope(e)},n.prototype.setUpAxis=function(e){null!=this.m_character&&this.m_character.setUpAxis(e)},n.prototype.getGravity=function(){return null!=this.m_character?this.m_character.getGravity():0},n.prototype.setGravity=function(e){null!=this.m_character&&this.m_character.setGravity(e)},n.prototype.isGrounded=function(){return null!=this.m_character&&this.m_character.onGround()},n.prototype.isReady=function(){return null!=this.m_character},n.prototype.canJump=function(){return null!=this.m_character&&this.m_character.canJump()},n.prototype.internalWarp=function(e){null!=this.m_character&&this.m_character.warp(e)},n.prototype.internalJump=function(){null!=this.m_character&&this.m_character.jump()},n.prototype.internalSetJumpSpeed=function(e){null!=this.m_character&&this.m_character.setJumpSpeed(e)},n.prototype.internalSetWalkDirection=function(e){null!=this.m_character&&this.m_character.setWalkDirection(e)},n.prototype.internalSetVelocityForTimeInterval=function(e,t){null!=this.m_character&&this.m_character.setVelocityForTimeInterval(e,t)},n.prototype.awake=function(){this.awakeMovementState()},n.prototype.start=function(){this.startMovementState()},n.prototype.update=function(){this.updateMovementState()},n.prototype.destroy=function(){this.destroyMovementState()},n.prototype.awakeMovementState=function(){this._abstractMesh=this.getAbstractMesh(),this._avatarRadius=this.getProperty("avatarRadius",this._avatarRadius),this._avatarHeight=this.getProperty("avatarHeight",this._avatarHeight),this._skinWidth=this.getProperty("skinWidth",this._skinWidth),this._slopeLimit=this.getProperty("slopeLimit",this._slopeLimit),this._stepOffset=this.getProperty("stepOffset",this._stepOffset),this._minMoveDistance=this.getProperty("minMoveDistance",this._minMoveDistance),this._capsuleSegments=this.getProperty("capsuleSegments",this._capsuleSegments),this._useGhostSweepTest=this.getProperty("useGhostSweepTest",this._useGhostSweepTest),this.m_warpPosition=new Ammo.btVector3(0,0,0),this.m_walkDirection=new Ammo.btVector3(0,0,0),this.m_physicsEngine=e.SceneManager.GetPhysicsEngine(this.scene);var t=this.getProperty("centerOffset");null!=t&&(this._centerOffset=e.Utilities.ParseVector3(t)),this.setMaxNotifications(this._maxCollisions);var n=e.SceneManager.GetPhysicsWorld(this.scene);if(null!=n){var a=e.Utilities.GetAbsolutePosition(this.transform,this._centerOffset);this.m_startPosition=new Ammo.btVector3(a.x,a.y,a.z),this.m_startTransform=new Ammo.btTransform,this.m_startTransform.setIdentity(),this.m_startTransform.setOrigin(this.m_startPosition);var i=e.Utilities.ShowDebugColliders(),r=e.Utilities.ColliderVisibility();if(i===!0&&null==this.transform._debugCollider){var o=new e.Vector3(this._avatarRadius,this._avatarHeight,1);o.x*=Math.max(Math.abs(this.transform.scaling.x),Math.abs(this.transform.scaling.z)),o.y*=this.transform.scaling.y;var s=this.transform.name+".Debug",l=e.MeshBuilder.CreateCapsule(s,{tessellation:this._capsuleSegments,subdivisions:8,capSubdivisions:16,height:o.y,radius:o.x},this.scene);l.position.set(0,0,0),l.rotationQuaternion=this.transform.rotationQuaternion.clone(),l.setParent(this.transform),l.position.copyFrom(this._centerOffset),l.visibility=r,l.material=e.Utilities.GetColliderMaterial(this.scene),l.checkCollisions=!1,l.isPickable=!1,this.transform._debugCollider=l}this.m_ghostShape=new Ammo.btCapsuleShape(this._avatarRadius,this._avatarHeight/2),this.m_ghostShape.setMargin(this._skinWidth+e.CharacterController.MARGIN_FACTOR),this.m_ghostObject=new Ammo.btPairCachingGhostObject,this.m_ghostObject.setWorldTransform(this.m_startTransform),this.m_ghostObject.setCollisionShape(this.m_ghostShape),this.m_ghostObject.setCollisionFlags(e.CollisionFlags.CF_CHARACTER_OBJECT),this.m_ghostCollision=Ammo.castObject(this.m_ghostObject,Ammo.btCollisionObject),this.m_ghostCollision.entity=this._abstractMesh,this.m_character=new Ammo.btKinematicCharacterController(this.m_ghostObject,this.m_ghostShape,this._stepOffset),this.m_character.setUseGhostSweepTest(this._useGhostSweepTest),this.m_character.setUpInterpolate(!0),this.m_character.setMaxSlope(e.Tools.ToRadians(this._slopeLimit)),this.m_character.setGravity(e.System.Gravity3G),n.addCollisionObject(this.m_ghostObject,e.CollisionFilters.CharacterFilter,e.CollisionFilters.StaticFilter|e.CollisionFilters.DefaultFilter|e.CollisionFilters.CharacterFilter),n.addAction(this.m_character)}else e.Tools.Warn("Null physics world detected. Failed to create character controller: "+this.transform.name);this._isPhysicsReady=null!=this.m_physicsEngine&&null!=this._tmpCollisionContacts&&null!=this.m_ghostObject&&null!=this._abstractMesh},n.prototype.startMovementState=function(){this.updateMovementState()},n.prototype.syncMovementState=function(){this._isPhysicsReady===!0&&(this.m_ghostTransform=this.m_ghostObject.getWorldTransform(),null!=this.m_ghostTransform?this.m_ghostPosition=this.m_ghostTransform.getOrigin():this.m_ghostPosition=null)},n.prototype.updateMovementState=function(){this.syncMovementState(),this._isPhysicsReady===!0&&null!=this.m_ghostPosition&&(this.updatePosition===!0?(this.m_collisionPosition.set(this.m_ghostPosition.x(),this.m_ghostPosition.y(),this.m_ghostPosition.z()),null!=this._centerOffset&&this.m_collisionPosition.subtractInPlace(this._centerOffset),this.transform.position.copyFrom(this.m_collisionPosition)):this.setGhostWorldPosition(this.transform.position),this.onUpdatePositionObservable.hasObservers()===!0&&this.onUpdatePositionObservable.notifyObservers(this.transform)),this.parseGhostCollisionContacts()},n.prototype.parseGhostCollisionContacts=function(){if(this._isPhysicsReady===!0){var e=this.onCollisionEnterObservable.hasObservers(),t=this.onCollisionStayObservable.hasObservers(),n=this.onCollisionExitObservable.hasObservers();if(e||t||n){var a=0;for(a=0;a<this._tmpCollisionContacts.length;a++)this._tmpCollisionContacts[a].reset=!0;var i=this.m_ghostObject.getNumOverlappingObjects();if(i>this._maxCollisions&&(i=this._maxCollisions),i>0)for(a=0;a<i;a++){var r=this.m_ghostObject.getOverlappingObject(a);if(null!=r){var o=Ammo.castObject(r,Ammo.btCollisionObject);if(null!=o&&null!=o.entity&&o.isActive()){var s=-1,l=o.entity;for(a=0;a<this._tmpCollisionContacts.length;a++){var u=this._tmpCollisionContacts[a];if(null!=u.mesh&&u.mesh===l){u.state=1,u.reset=!1,s=a;break}}if(s===-1)for(a=0;a<this._tmpCollisionContacts.length;a++){var c=this._tmpCollisionContacts[a];if(null==c.mesh){c.mesh=l,c.state=0,c.reset=!1;break}}}}}for(a=0;a<this._tmpCollisionContacts.length;a++){var h=this._tmpCollisionContacts[a];h.reset===!0?(n&&null!=h.mesh&&this.onCollisionExitObservable.notifyObservers(h.mesh),h.mesh=null,h.state=0,h.reset=!1):0===h.state?e&&null!=h.mesh&&this.onCollisionEnterObservable.notifyObservers(h.mesh):t&&null!=h.mesh&&this.onCollisionStayObservable.notifyObservers(h.mesh)}}}},n.prototype.destroyMovementState=function(){this.m_physicsEngine=null,null!=this.m_character&&(Ammo.destroy(this.m_character),this.m_character=null),null!=this.m_ghostObject&&(Ammo.destroy(this.m_ghostObject),this.m_ghostObject=null),null!=this.m_ghostShape&&(Ammo.destroy(this.m_ghostShape),this.m_ghostShape=null),null!=this.m_ghostCollision&&(Ammo.destroy(this.m_ghostCollision),this.m_ghostCollision=null),null!=this.m_ghostPosition&&(Ammo.destroy(this.m_ghostPosition),this.m_ghostPosition=null),null!=this.m_ghostTransform&&(Ammo.destroy(this.m_ghostTransform),this.m_ghostTransform=null),null!=this.m_startPosition&&(Ammo.destroy(this.m_startPosition),this.m_startPosition=null),null!=this.m_startTransform&&(Ammo.destroy(this.m_startTransform),this.m_startTransform=null),null!=this.m_warpPosition&&(Ammo.destroy(this.m_warpPosition),this.m_warpPosition=null),null!=this.m_walkDirection&&(Ammo.destroy(this.m_walkDirection),this.m_walkDirection=null),this.onUpdatePositionObservable.clear(),this.onUpdatePositionObservable=null,this.onCollisionEnterObservable.clear(),this.onCollisionEnterObservable=null,this.onCollisionStayObservable.clear(),this.onCollisionStayObservable=null,this.onCollisionExitObservable.clear(),this.onCollisionExitObservable=null,this._tmpCollisionContacts=null,this._abstractMesh=null},n.prototype.setMaxNotifications=function(t){this._maxCollisions=t,this._tmpCollisionContacts=[];for(var n=0;n<this._maxCollisions;n++)this._tmpCollisionContacts.push(new e.CollisionContactInfo)},n.prototype.setActivationState=function(e){null!=this.m_ghostCollision&&this.m_ghostCollision.setActivationState&&this.m_ghostCollision.setActivationState(e)},n.prototype.getCollisionFilterGroup=function(){var e=-1;return null!=this.m_ghostCollision&&this.m_ghostCollision.getBroadphaseHandle&&(e=this.m_ghostCollision.getBroadphaseHandle().get_m_collisionFilterGroup()),e},n.prototype.setCollisionFilterGroup=function(e){null!=this.m_ghostCollision&&this.m_ghostCollision.getBroadphaseHandle&&this.m_ghostCollision.getBroadphaseHandle().set_m_collisionFilterGroup(e)},n.prototype.getCollisionFilterMask=function(){var e=-1;return null!=this.m_ghostCollision&&this.m_ghostCollision.getBroadphaseHandle&&(e=this.m_ghostCollision.getBroadphaseHandle().get_m_collisionFilterMask()),e},n.prototype.setCollisionFilterMask=function(e){null!=this.m_ghostCollision&&this.m_ghostCollision.getBroadphaseHandle&&this.m_ghostCollision.getBroadphaseHandle().set_m_collisionFilterMask(e)},n.prototype.getContactProcessingThreshold=function(){var e=-1;return null!=this.m_ghostCollision&&this.m_ghostCollision.getContactProcessingThreshold&&this.m_ghostCollision.getContactProcessingThreshold(),e},n.prototype.setContactProcessingThreshold=function(e){null!=this.m_ghostCollision&&this.m_ghostCollision.setContactProcessingThreshold&&this.m_ghostCollision.setContactProcessingThreshold(e)},n.prototype.setGhostWorldPosition=function(e){null!=this.m_ghostObject&&null!=this.m_ghostTransform&&(null!=this.m_ghostPosition&&null!=e&&(this.m_ghostPosition.setValue(e.x,e.y,e.z),this.m_ghostTransform.setOrigin(this.m_ghostPosition)),this.m_ghostObject.setWorldTransform(this.m_ghostTransform))},n.prototype.move=function(e){null!=e&&(this.m_moveDeltaX=e.x,this.m_moveDeltaZ=e.z,Math.abs(e.x)<this._minMoveDistance&&(e.x>0?this.m_moveDeltaX=this._minMoveDistance:e.x<0&&(this.m_moveDeltaX=-this._minMoveDistance)),Math.abs(e.z)<this._minMoveDistance&&(e.z>0?this.m_moveDeltaZ=this._minMoveDistance:e.z<0&&(this.m_moveDeltaZ=-this._minMoveDistance)),null!=this.m_walkDirection&&(this.m_walkDirection.setValue(this.m_moveDeltaX,0,this.m_moveDeltaZ),this.internalSetWalkDirection(this.m_walkDirection)))},n.prototype.jump=function(e){this.internalSetJumpSpeed(e),this.internalJump()},n.prototype.warp=function(e){null!=this.m_warpPosition&&(this.m_warpPosition.setValue(e.x,e.y,e.z),this.internalWarp(this.m_warpPosition))},n.MARGIN_FACTOR=-.04,n}(e.ScriptComponent);e.CharacterController=t}(BABYLON||(BABYLON={}));var __extends=this&&this.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(t,n)};return function(t,n){function a(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(a.prototype=n.prototype,new a)}}(),BABYLON;!function(e){var t=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.distanceToTarget=0,n.moveDirection=new e.Vector3(0,0,0),n.resetPosition=new e.Vector3(0,0,0),n.lastPosition=new e.Vector3(0,0,0),n.currentPosition=new e.Vector3(0,0,0),n.currentVelocity=new e.Vector3(0,0,0),n.currentWaypoint=new e.Vector3(0,0,0),n.heightOffset=0,n.angularSpeed=0,n.updatePosition=!0,n.updateRotation=!0,n.distanceEpsilon=.1,n.velocityEpsilon=1.1,n.offMeshVelocity=1.5,n.stoppingDistance=0,n.m_agentState=0,n.m_agentIndex=-1,n.m_agentReady=!1,n.m_agentGhost=null,n.m_agentParams=null,n.m_agentRotation=new e.Quaternion(0,0,0,1),n.m_agentMovement=new e.Vector3(0,0,0),n.m_agentDirection=new e.Vector3(0,0,1),n.m_agentQuaternion=new e.Quaternion(0,0,0,1),n.m_agentDestination=null,n.onReadyObservable=new e.Observable,n.onPreUpdateObservable=new e.Observable,n.onPostUpdateObservable=new e.Observable,n.onNavCompleteObservable=new e.Observable,n}return __extends(n,t),n.prototype.isReady=function(){return this.m_agentReady},n.prototype.isNavigating=function(){return null!=this.m_agentDestination},n.prototype.isOnOffMeshLink=function(){return this.m_agentState===e.CrowdAgentState.DT_CROWDAGENT_STATE_OFFMESH},n.prototype.getAgentType=function(){return this.type},n.prototype.getAgentState=function(){return this.m_agentState},n.prototype.getAgentIndex=function(){return this.m_agentIndex},n.prototype.getAgentOffset=function(){return this.baseOffset},n.prototype.getTargetDistance=function(){return this.distanceToTarget},n.prototype.getAgentParameters=function(){return this.m_agentParams},n.prototype.setAgentParameters=function(e){this.m_agentParams=e,this.updateAgentParameters()},n.prototype.awake=function(){this.awakeNavigationAgent()},n.prototype.late=function(){this.updateNavigationAgent()},n.prototype.destroy=function(){this.destroyNavigationAgent()},n.prototype.awakeNavigationAgent=function(){this.type=this.getProperty("type",this.type),this.speed=this.getProperty("speed",this.speed),this.baseOffset=this.getProperty("offset",this.baseOffset),this.angularSpeed=this.getProperty("angularspeed",this.angularSpeed),this.acceleration=this.getProperty("acceleration",this.acceleration),this.stoppingDistance=this.getProperty("stoppingdistance",this.stoppingDistance),this.autoBraking=this.getProperty("autobraking",this.autoBraking),this.avoidRadius=this.getProperty("avoidradius",this.avoidRadius),
- this.avoidHeight=this.getProperty("avoidheight",this.avoidHeight),this.obstacleAvoidanceType=this.getProperty("avoidquality",this.obstacleAvoidanceType),this.avoidancePriority=this.getProperty("avoidpriority",this.avoidancePriority),this.autoTraverseOffMeshLink=this.getProperty("autotraverse",this.autoTraverseOffMeshLink),this.autoRepath=this.getProperty("autopepath",this.autoRepath),this.areaMask=this.getProperty("areamask",this.areaMask),e.Utilities.ValidateTransformQuaternion(this.transform),this.m_agentGhost=new e.TransformNode(this.transform.name+".Agent",this.scene),this.m_agentGhost.position=new e.Vector3(0,0,0),this.m_agentGhost.rotation=new e.Vector3(0,0,0),e.Utilities.ValidateTransformQuaternion(this.m_agentGhost),this.m_agentGhost.position.copyFrom(this.transform.position),this.lastPosition.copyFrom(this.transform.position)},n.prototype.updateNavigationAgent=function(){var t=e.SceneManager.GetCrowdInterface(this.scene);if(null!=t){if(this.m_agentIndex<0)return this.m_agentParams={radius:this.avoidRadius,height:this.avoidHeight,maxSpeed:this.speed,maxAcceleration:this.acceleration,collisionQueryRange:2,pathOptimizationRange:20,separationWeight:1},e.Utilities.GetAbsolutePositionToRef(this.transform,this.resetPosition),this.m_agentIndex=t.addAgent(this.resetPosition,this.m_agentParams,this.m_agentGhost),void(this.m_agentIndex>=0&&(this.m_agentReady=!0,this.onReadyObservable.hasObservers()===!0&&this.onReadyObservable.notifyObservers(this.transform)));if(this.m_agentState=t.getAgentState(this.m_agentIndex),this.getAgentWaypointToRef(this.currentWaypoint),this.getAgentPositionToRef(this.currentPosition),this.isOnOffMeshLink()?(this.currentPosition.subtractToRef(this.lastPosition,this.currentVelocity),this.currentVelocity.scaleInPlace(this.speed*this.offMeshVelocity)):this.getAgentVelocityToRef(this.currentVelocity),null!=this.m_agentDestination){if(this.distanceToTarget=e.Vector3.Distance(this.currentPosition,this.m_agentDestination),this.updatePosition===!0||this.updateRotation===!0){if(this.onPreUpdateObservable.hasObservers()===!0&&this.onPreUpdateObservable.notifyObservers(this.transform),this.updateRotation===!0&&this.currentVelocity.length()>=this.velocityEpsilon){this.currentVelocity.normalize();var n=this.angularSpeed*e.NavigationAgent.ANGULAR_SPEED_RATIO*this.getDeltaSeconds();if(this.isOnOffMeshLink()){this.moveDirection.copyFrom(this.m_agentDirection),this.m_agentDirection.set(this.moveDirection.x+(this.currentVelocity.x-this.moveDirection.x),this.moveDirection.y+(this.currentVelocity.y-this.moveDirection.y),this.moveDirection.z+(this.currentVelocity.z-this.moveDirection.z)),this.m_agentDirection.normalize();var a=e.NavigationAgent.TARGET_ANGLE_FACTOR-Math.atan2(this.m_agentDirection.x,this.m_agentDirection.z);e.Quaternion.FromEulerAnglesToRef(0,a,0,this.m_agentRotation),e.Quaternion.SlerpToRef(this.transform.rotationQuaternion,this.m_agentRotation,n,this.transform.rotationQuaternion)}else this.m_agentQuaternion.copyFrom(this.transform.rotationQuaternion),this.transform.lookAt(this.currentWaypoint),this.transform.rotationQuaternion.toEulerAnglesToRef(this.m_agentDirection),e.Quaternion.FromEulerAnglesToRef(0,this.m_agentDirection.y,0,this.m_agentRotation),e.Quaternion.SlerpToRef(this.m_agentQuaternion,this.m_agentRotation,n,this.transform.rotationQuaternion)}this.updatePosition===!0&&this.transform.position.set(this.currentPosition.x,this.currentPosition.y+this.baseOffset+this.heightOffset,this.currentPosition.z),this.onPostUpdateObservable.hasObservers()===!0&&this.onPostUpdateObservable.notifyObservers(this.transform)}this.distanceToTarget<=Math.max(this.distanceEpsilon,this.stoppingDistance)&&(this.resetAgentPosition(),this.onNavCompleteObservable.hasObservers()===!0&&this.onNavCompleteObservable.notifyObservers(this.transform))}else this.distanceToTarget=0;this.lastPosition.copyFrom(this.transform.position)}},n.prototype.updateAgentParameters=function(){var t=e.SceneManager.GetCrowdInterface(this.scene);null!=t&&this.m_agentIndex>=0&&t.updateAgentParameters(this.m_agentIndex,this.m_agentParams)},n.prototype.destroyNavigationAgent=function(){this.m_agentIndex=-1,this.m_agentReady=!1,this.m_agentRotation=null,this.m_agentMovement=null,this.m_agentDirection=null,this.m_agentDestination=null,this.moveDirection=null,this.resetPosition=null,this.lastPosition=null,this.currentPosition=null,this.currentVelocity=null,this.currentWaypoint=null,this.onReadyObservable.clear(),this.onReadyObservable=null,this.onPreUpdateObservable.clear(),this.onPreUpdateObservable=null,this.onPostUpdateObservable.clear(),this.onPostUpdateObservable=null,this.onNavCompleteObservable.clear(),this.onNavCompleteObservable=null,null!=this.m_agentGhost&&(this.m_agentGhost.dispose(),this.m_agentGhost=null)},n.prototype.move=function(t,n){void 0===n&&(n=!0);var a=e.SceneManager.GetNavigationTools(),i=e.SceneManager.GetCrowdInterface(this.scene);null!=a&&null!=i?(i.getAgentPosition(this.m_agentIndex).addToRef(t,this.m_agentMovement),n===!0?this.m_agentDestination=a.getClosestPoint(this.m_agentMovement):this.m_agentDestination=this.m_agentMovement.clone(),this.m_agentIndex>=0&&i.agentGoto(this.m_agentIndex,this.m_agentDestination)):e.Tools.Warn("No recast navigation mesh or crowd interface data available!")},n.prototype.teleport=function(t,n){void 0===n&&(n=!0);var a=e.SceneManager.GetNavigationTools(),i=e.SceneManager.GetCrowdInterface(this.scene);null!=a&&null!=i?(n===!0?this.m_agentDestination=a.getClosestPoint(t):this.m_agentDestination=t.clone(),this.m_agentIndex>=0&&i.agentTeleport(this.m_agentIndex,this.m_agentDestination)):e.Tools.Warn("No recast navigation mesh or crowd interface data available!")},n.prototype.setDestination=function(t,n){void 0===n&&(n=!0);var a=e.SceneManager.GetNavigationTools(),i=e.SceneManager.GetCrowdInterface(this.scene);null!=a&&null!=i?(n===!0?this.m_agentDestination=a.getClosestPoint(t):this.m_agentDestination=t.clone(),this.m_agentIndex>=0&&i.agentGoto(this.m_agentIndex,this.m_agentDestination)):e.Tools.Warn("No recast navigation mesh or crowd interface data available!")},n.prototype.getAgentVelocity=function(){var t=e.SceneManager.GetCrowdInterface(this.scene);return null!=t&&this.m_agentIndex>=0?t.getAgentVelocity(this.m_agentIndex):null},n.prototype.getAgentVelocityToRef=function(t){var n=e.SceneManager.GetCrowdInterface(this.scene);null!=n&&this.m_agentIndex>=0&&n.getAgentVelocityToRef(this.m_agentIndex,t)},n.prototype.getAgentPosition=function(){var t=e.SceneManager.GetCrowdInterface(this.scene);return null!=t&&this.m_agentIndex>=0?t.getAgentPosition(this.m_agentIndex):null},n.prototype.getAgentPositionToRef=function(t){var n=e.SceneManager.GetCrowdInterface(this.scene);null!=n&&this.m_agentIndex>=0&&n.getAgentPositionToRef(this.m_agentIndex,t)},n.prototype.getAgentWaypoint=function(){var t=e.SceneManager.GetCrowdInterface(this.scene);return null!=t&&this.m_agentIndex>=0?t.getAgentNextTargetPath(this.m_agentIndex):null},n.prototype.getAgentWaypointToRef=function(t){var n=e.SceneManager.GetCrowdInterface(this.scene);null!=n&&this.m_agentIndex>=0&&n.getAgentNextTargetPathToRef(this.m_agentIndex,t)},n.prototype.resetAgentPosition=function(){this.m_agentDestination=null;var t=e.SceneManager.GetCrowdInterface(this.scene),n=this.getAgentPosition();null!=n&&null!=t&&this.m_agentIndex>=0&&(t.agentTeleport(this.m_agentIndex,n),n.y+=this.baseOffset+this.heightOffset,this.transform.position.copyFrom(n))},n.prototype.cancelNavigation=function(){this.resetAgentPosition()},n.TARGET_ANGLE_FACTOR=.5*Math.PI,n.ANGULAR_SPEED_RATIO=.05,n}(e.ScriptComponent);e.NavigationAgent=t;var n;!function(e){e[e.DT_CROWDAGENT_STATE_INVALID=0]="DT_CROWDAGENT_STATE_INVALID",e[e.DT_CROWDAGENT_STATE_WALKING=1]="DT_CROWDAGENT_STATE_WALKING",e[e.DT_CROWDAGENT_STATE_OFFMESH=2]="DT_CROWDAGENT_STATE_OFFMESH"}(n=e.CrowdAgentState||(e.CrowdAgentState={}))}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,n,a,i){void 0===i&&(i=null),this._centerMass=new e.Vector3(0,0,0),this._chassisMesh=null,this._tempVectorPos=new e.Vector3(0,0,0),this.lockedWheelIndexes=null,this.m_vehicle=null,this.m_vehicleTuning=null,this.m_vehicleRaycaster=null,this.m_vehicleColliders=null,this.m_tempTransform=null,this.m_tempPosition=null,this.m_wheelDirectionCS0=null,this.m_wheelAxleCS=null,this._chassisMesh=t,this._centerMass=a,this.m_vehicleTuning=new Ammo.btVehicleTuning,this.m_vehicleRaycaster=null!=Ammo.btSmoothVehicleRaycaster?new Ammo.btSmoothVehicleRaycaster(n):new Ammo.btDefaultVehicleRaycaster(n),this.m_vehicleColliders=null!=this._chassisMesh.metadata&&null!=this._chassisMesh.metadata.unity&&null!=this._chassisMesh.metadata.unity.wheels?this._chassisMesh.metadata.unity.wheels:null,this.m_vehicle=new Ammo.btRaycastVehicle(this.m_vehicleTuning,this._chassisMesh.physicsImpostor.physicsBody,this.m_vehicleRaycaster),this.m_vehicle.setCoordinateSystem(0,1,2),this.m_wheelDirectionCS0=new Ammo.btVector3(0,(-1),0),this.m_wheelAxleCS=new Ammo.btVector3((-1),0,0),this.m_tempPosition=null,this.m_tempTransform=null,this.setupWheelInformation(i),n.addAction(this.m_vehicle)}return t.prototype.getInternalVehicle=function(){return this.m_vehicle},t.prototype.getUpAxis=function(){if(null!=this.m_vehicle)return this.m_vehicle.getUpAxis()},t.prototype.getRightAxis=function(){if(null!=this.m_vehicle)return this.m_vehicle.getRightAxis()},t.prototype.getForwardAxis=function(){if(null!=this.m_vehicle)return this.m_vehicle.getForwardAxis()},t.prototype.getForwardVector=function(){if(null!=this.m_vehicle)return this.m_vehicle.getForwardVector()},t.prototype.getNumWheels=function(){if(null!=this.m_vehicle)return this.m_vehicle.getNumWheels()},t.prototype.getWheelInfo=function(e){if(null!=this.m_vehicle)return this.m_vehicle.getWheelInfo(e)},t.prototype.resetSuspension=function(){null!=this.m_vehicle&&this.m_vehicle.resetSuspension()},t.prototype.setPitchControl=function(e){null!=this.m_vehicle&&this.m_vehicle.setPitchControl(e)},t.prototype.setEngineForce=function(e,t){null!=this.m_vehicle&&this.m_vehicle.applyEngineForce(e,t)},t.prototype.setBrakingForce=function(e,t){null!=this.m_vehicle&&this.m_vehicle.setBrake(e,t)},t.prototype.getWheelTransform=function(e){if(null!=this.m_vehicle)return this.m_vehicle.getWheelTransformWS(e)},t.prototype.updateWheelTransform=function(e,t){null!=this.m_vehicle&&this.m_vehicle.updateWheelTransform(e,t)},t.prototype.getUserConstraintType=function(){if(null!=this.m_vehicle)return this.m_vehicle.getUserConstraintType()},t.prototype.setUserConstraintType=function(e){null!=this.m_vehicle&&this.m_vehicle.setUserConstraintType(e)},t.prototype.setUserConstraintId=function(e){null!=this.m_vehicle&&this.m_vehicle.setUserConstraintId(e)},t.prototype.getUserConstraintId=function(){if(null!=this.m_vehicle)return this.m_vehicle.getUserConstraintId()},t.prototype.getRawCurrentSpeedKph=function(){if(null!=this.m_vehicle)return this.m_vehicle.getCurrentSpeedKmHour()},t.prototype.getRawCurrentSpeedMph=function(){if(null!=this.m_vehicle)return this.m_vehicle.getCurrentSpeedKmHour()*e.System.Kph2Mph},t.prototype.getAbsCurrentSpeedKph=function(){if(null!=this.m_vehicle)return Math.abs(this.m_vehicle.getCurrentSpeedKmHour())},t.prototype.getAbsCurrentSpeedMph=function(){if(null!=this.m_vehicle)return Math.abs(this.m_vehicle.getCurrentSpeedKmHour())*e.System.Kph2Mph},t.prototype.getVehicleTuningSystem=function(){return this.m_vehicleTuning},t.prototype.getChassisWorldTransform=function(){if(null!=this.m_vehicle)return this.m_vehicle.getChassisWorldTransform()},t.prototype.dispose=function(){this.deleteWheelInformation(),null!=this.m_vehicle&&(Ammo.destroy(this.m_vehicle),this.m_vehicle=null),null!=this.m_vehicleTuning&&(Ammo.destroy(this.m_vehicleTuning),this.m_vehicleTuning=null),null!=this.m_vehicleRaycaster&&(Ammo.destroy(this.m_vehicleRaycaster),this.m_vehicleRaycaster=null),null!=this.m_wheelDirectionCS0&&(Ammo.destroy(this.m_wheelDirectionCS0),this.m_wheelDirectionCS0=null),null!=this.m_wheelAxleCS&&(Ammo.destroy(this.m_wheelAxleCS),this.m_wheelAxleCS=null),null!=this.m_tempPosition&&(Ammo.destroy(this.m_tempPosition),this.m_tempPosition=null),null!=this.m_tempTransform&&(Ammo.destroy(this.m_tempTransform),this.m_tempTransform=null),this.m_vehicleColliders=null},t.GetInstance=function(t,n,a){void 0===a&&(a=null);var i=n;if(null==i.m_raycastVehicle)if(n.hasWheelColliders()){var r=e.SceneManager.GetRightHanded(t);r===!0&&e.Tools.Warn("Raycast vehicle not supported for right handed scene: "+i._abstractMesh.name),i.m_raycastVehicle=new e.RaycastVehicle(i._abstractMesh,i.m_physicsWorld,i._centerOfMass,a)}else e.Tools.Warn("No wheel collider metadata found for: "+i._abstractMesh.name);return i.m_raycastVehicle},t.prototype.getEnableMultiRaycast=function(){var e=!1;return null!=this.m_vehicle&&this.m_vehicle.get_m_enableMultiRaycast&&(e=this.m_vehicle.get_m_enableMultiRaycast()),e},t.prototype.setEnableMultiRaycast=function(e){null!=this.m_vehicle&&this.m_vehicle.set_m_enableMultiRaycast&&this.m_vehicle.set_m_enableMultiRaycast(e)},t.prototype.getStabilizingForce=function(){var e=-1;return null!=this.m_vehicle&&this.m_vehicle.get_m_stabilizingForce&&(e=this.m_vehicle.get_m_stabilizingForce()),e},t.prototype.setStabilizingForce=function(e){null!=this.m_vehicle&&this.m_vehicle.set_m_stabilizingForce&&this.m_vehicle.set_m_stabilizingForce(e)},t.prototype.getSmoothFlyingImpulse=function(){var e=-1;return null!=this.m_vehicle&&this.m_vehicle.get_m_smoothFlyingImpulse&&(e=this.m_vehicle.get_m_smoothFlyingImpulse()),e},t.prototype.setSmoothFlyingImpulse=function(e){null!=this.m_vehicle&&this.m_vehicle.set_m_smoothFlyingImpulse&&this.m_vehicle.set_m_smoothFlyingImpulse(e)},t.prototype.getTrackConnectionAccel=function(){var e=-1;return null!=this.m_vehicle&&this.m_vehicle.get_m_trackConnectionAccel&&(e=this.m_vehicle.get_m_trackConnectionAccel()),e},t.prototype.setTrackConnectionAccel=function(e){null!=this.m_vehicle&&this.m_vehicle.set_m_trackConnectionAccel&&this.m_vehicle.set_m_trackConnectionAccel(e)},t.prototype.getMinimumWheelContacts=function(){var e=-1;return null!=this.m_vehicle&&this.m_vehicle.get_m_minimumWheelContacts&&(e=this.m_vehicle.get_m_minimumWheelContacts()),e},t.prototype.setMinimumWheelContacts=function(e){null!=this.m_vehicle&&this.m_vehicle.set_m_minimumWheelContacts&&this.m_vehicle.set_m_minimumWheelContacts(e)},t.prototype.getInterpolateNormals=function(){var e=!1;return null!=this.m_vehicleRaycaster&&this.m_vehicleRaycaster.get_m_interpolateNormals&&(e=this.m_vehicleRaycaster.get_m_interpolateNormals()),e},t.prototype.setInterpolateNormals=function(e){null!=this.m_vehicleRaycaster&&this.m_vehicleRaycaster.set_m_interpolateNormals&&this.m_vehicleRaycaster.set_m_interpolateNormals(e)},t.prototype.getShapeTestingMode=function(){var e=!1;return null!=this.m_vehicleRaycaster&&this.m_vehicleRaycaster.get_m_shapeTestingMode&&(e=this.m_vehicleRaycaster.get_m_shapeTestingMode()),e},t.prototype.setShapeTestingMode=function(e){null!=this.m_vehicleRaycaster&&this.m_vehicleRaycaster.set_m_shapeTestingMode&&this.m_vehicleRaycaster.set_m_shapeTestingMode(e)},t.prototype.getShapeTestingSize=function(){var e=0;return null!=this.m_vehicleRaycaster&&this.m_vehicleRaycaster.get_m_shapeTestingSize&&(e=this.m_vehicleRaycaster.get_m_shapeTestingSize()),e},t.prototype.setShapeTestingSize=function(e){null!=this.m_vehicleRaycaster&&this.m_vehicleRaycaster.set_m_shapeTestingSize&&this.m_vehicleRaycaster.set_m_shapeTestingSize(e)},t.prototype.getShapeTestingCount=function(){var e=0;return null!=this.m_vehicleRaycaster&&this.m_vehicleRaycaster.get_m_testPointCount&&(e=this.m_vehicleRaycaster.get_m_testPointCount()),e},t.prototype.setShapeTestingCount=function(e){null!=this.m_vehicleRaycaster&&this.m_vehicleRaycaster.set_m_testPointCount&&this.m_vehicleRaycaster.set_m_testPointCount(e)},t.prototype.getSweepPenetration=function(){var e=0;return null!=this.m_vehicleRaycaster&&this.m_vehicleRaycaster.get_m_sweepPenetration&&(e=this.m_vehicleRaycaster.get_m_sweepPenetration()),e},t.prototype.setSweepPenetration=function(e){null!=this.m_vehicleRaycaster&&this.m_vehicleRaycaster.set_m_sweepPenetration&&this.m_vehicleRaycaster.set_m_sweepPenetration(e)},t.prototype.getCollisionFilterGroup=function(){var e=-1;return null!=this.m_vehicleRaycaster&&this.m_vehicleRaycaster.get_m_collisionFilterGroup&&(e=this.m_vehicleRaycaster.get_m_collisionFilterGroup()),e},t.prototype.setCollisionFilterGroup=function(e){null!=this.m_vehicleRaycaster&&this.m_vehicleRaycaster.set_m_collisionFilterGroup&&this.m_vehicleRaycaster.set_m_collisionFilterGroup(e)},t.prototype.getCollisionFilterMask=function(){var e=-1;return null!=this.m_vehicleRaycaster&&this.m_vehicleRaycaster.get_m_collisionFilterMask&&(e=this.m_vehicleRaycaster.get_m_collisionFilterMask()),e},t.prototype.setCollisionFilterMask=function(e){null!=this.m_vehicleRaycaster&&this.m_vehicleRaycaster.set_m_collisionFilterMask&&this.m_vehicleRaycaster.set_m_collisionFilterMask(e)},t.prototype.getWheelIndexByID=function(e){var t=-1;if(null!=this.m_vehicleColliders&&this.m_vehicleColliders.length>0)for(var n=0;n<this.m_vehicleColliders.length;n++){var a=this.m_vehicleColliders[n];if(e.toLowerCase()===a.id.toLowerCase()){t=n;break}}return t},t.prototype.getWheelIndexByName=function(e){var t=-1;if(null!=this.m_vehicleColliders&&this.m_vehicleColliders.length>0)for(var n=0;n<this.m_vehicleColliders.length;n++){var a=this.m_vehicleColliders[n];if(e.toLowerCase()===a.name.toLowerCase()){t=n;break}}return t},t.prototype.getWheelColliderInfo=function(e){var t=-1;return null!=this.m_vehicleColliders&&this.m_vehicleColliders.length>0&&this.m_vehicleColliders.length>e&&(t=this.m_vehicleColliders[e]),t},t.prototype.setWheelTransformMesh=function(e,t){if(null!=t){var n=this.getWheelInfo(e);null!=n&&(n.transform=t)}},t.prototype.getVisualSteeringAngle=function(e){var t=0,n=this.getWheelInfo(e);return null!=n&&null!=n.steeringAngle&&(t=n.steeringAngle),t},t.prototype.setVisualSteeringAngle=function(e,t){var n=this.getWheelInfo(t);null!=n&&(n.steeringAngle=e)},t.prototype.getPhysicsSteeringAngle=function(e){if(null!=this.m_vehicle)return Math.abs(this.m_vehicle.getSteeringValue(e))},t.prototype.setPhysicsSteeringAngle=function(e,t){null!=this.m_vehicle&&this.m_vehicle.setSteeringValue(e,t)},t.prototype.setupWheelInformation=function(t){if(void 0===t&&(t=null),null!=this._chassisMesh&&null!=this._chassisMesh.physicsImpostor&&null!=this._chassisMesh.physicsImpostor.physicsBody&&(null!=t&&this._chassisMesh.physicsImpostor.physicsBody.setAngularFactor(new Ammo.btVector3(t.x,t.y,t.z)),this._chassisMesh.physicsImpostor.physicsBody.setActivationState(e.CollisionState.DISABLE_DEACTIVATION)),null!=this.m_vehicle&&null!=this.m_vehicleColliders&&this.m_vehicleColliders.length>0){var n=-1;for(n=0;n<this.m_vehicleColliders.length;n++){var a=this.m_vehicleColliders[n],i=null!=a.name?a.name:"Unknown",r=null!=a.radius?a.radius:.35,o=null!=a.position&&a.position.length>=3?a.position[0]:1,s=null!=a.position&&a.position.length>=3?a.position[2]:-1,l=null!=a.wheelconnectionpoint?a.wheelconnectionpoint:.5,u=null!=a.suspensionrestlength?a.suspensionrestlength:.3,c=null!=a.frontwheel||i.toLowerCase().indexOf("front")>=0,h=s,m=o,p=-this._centerMass.x,d=-this._centerMass.z;this.m_vehicle.addWheel(new Ammo.btVector3(m+p,l,h+d),this.m_wheelDirectionCS0,this.m_wheelAxleCS,u,r,this.m_vehicleTuning,c)}if(this.m_vehicle.getNumWheels()===this.m_vehicleColliders.length)for(n=0;n<this.m_vehicleColliders.length;n++){var a=this.m_vehicleColliders[n],g=null!=a.totalsuspensionforces?a.totalsuspensionforces:1e6,f=null!=a.suspensiontravelcm?a.suspensiontravelcm:25,y=null!=a.rollinfluence?a.rollinfluence:.2,_=null!=a.frictionslip?a.frictionslip:10,v=null!=a.suspensionstiffness?a.suspensionstiffness:50,M=null!=a.dampingcompression?a.dampingcompression:3.5,S=null!=a.dampingrelaxation?a.dampingrelaxation:4.5,b=this.m_vehicle.getWheelInfo(n);null!=b&&(b.steeringAngle=0,b.rotationBoost=0,b.defaultFriction=_,b.set_m_frictionSlip(_),b.set_m_rollInfluence(y),b.set_m_maxSuspensionForce(g),b.set_m_maxSuspensionTravelCm(f),b.set_m_suspensionStiffness(v),b.set_m_wheelsDampingCompression(M),b.set_m_wheelsDampingRelaxation(S))}else e.Tools.Warn("Failed to create proper number of wheels for: "+this._chassisMesh.name)}},t.prototype.updateWheelInformation=function(){var t=this.getNumWheels();if(t>0)for(var n=0;n<t;n++){var a=this.getWheelInfo(n);if(null!=a){var i=this.lockedWheelInformation(n);if(this.updateWheelTransform(n,!1),this.m_tempTransform=this.getWheelTransform(n),this.m_tempPosition=this.m_tempTransform.getOrigin(),null!=a.transform){var r=a.transform;if(null!=r.parent){e.Utilities.ConvertAmmoVector3ToRef(this.m_tempPosition,this._tempVectorPos),e.Utilities.InverseTransformPointToRef(r.parent,this._tempVectorPos,this._tempVectorPos),r.position.y=this._tempVectorPos.y;var o=null!=a.steeringAngle?a.steeringAngle:0;if(e.Quaternion.FromEulerAnglesToRef(0,o,0,r.rotationQuaternion),null!=a.spinner&&a.spinner.addRotation&&i===!1){var s=0,l=null!=a.get_m_deltaRotation?a.get_m_deltaRotation():0,u=null!=a.rotationBoost?a.rotationBoost:0;s=l<0?l+-u:l+u,a.spinner.addRotation(s,0,0)}}}}}},t.prototype.lockedWheelInformation=function(e){var t=!1;if(null!=this.lockedWheelIndexes&&this.lockedWheelIndexes.length>0)for(var n=0;n<this.lockedWheelIndexes.length;n++)if(this.lockedWheelIndexes[n]===e){t=!0;break}return t},t.prototype.deleteWheelInformation=function(){var e=this.getNumWheels();if(e>0)for(var t=0;t<e;t++){var n=this.getWheelInfo(t);null!=n&&(null!=n.transform&&delete n.transform,null!=n.spinner&&delete n.spinner,null!=n.steeringAngle&&delete n.steeringAngle,null!=n.rotationBoost&&delete n.rotationBoost,null!=n.defaultFriction&&delete n.defaultFriction)}},t}();e.RaycastVehicle=t}(BABYLON||(BABYLON={}));var __extends=this&&this.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(t,n)};return function(t,n){function a(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(a.prototype=n.prototype,new a)}}(),BABYLON;!function(e){var t=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.renderList=null,e.probeList=null,e.refreshMode=0,e.cullingMask=0,e.clearFlags=0,e.probeid=0,e.useProbeList=!1,e.includeChildren=!1,e.resolution=128,e.boxPos=null,e.boxSize=null,e.boxProjection=!1,e}return __extends(n,t),n.prototype.getProbeList=function(){return this.probeList},n.prototype.getRenderList=function(){return this.renderList},n.prototype.awake=function(){this.awakeRealtimReflections()},n.prototype.start=function(){this.startRealtimReflections()},n.prototype.destroy=function(){this.destroyRealtimReflections()},n.prototype.awakeRealtimReflections=function(){if(this.probeid=this.getProperty("id",this.probeid),this.resolution=this.getProperty("resolution",this.resolution),this.cullingMask=this.getProperty("culling",this.cullingMask),this.clearFlags=this.getProperty("clearflags",this.clearFlags),this.refreshMode=this.getProperty("refreshmode",this.refreshMode),this.useProbeList=this.getProperty("useprobelist",this.useProbeList),this.includeChildren=this.getProperty("includechildren",this.includeChildren),this.boxProjection=this.getProperty("boxprojection",this.boxProjection),this.boxProjection===!0){var t=this.getProperty("boundingboxposition");null!=t&&t.length>=3&&(this.boxPos=new e.Vector3(t[0],t[1],t[2]));var n=this.getProperty("boundingboxsize");null!=n&&n.length>=3&&(this.boxSize=new e.Vector3(n[0],n[1],n[2]))}},n.prototype.startRealtimReflections=function(){var t,n=0,a=e.SceneManager.GetRenderQuality(),i=a===e.RenderQuality.High;if(i===!0){if(0===this.cullingMask){if(this.clearFlags===e.RealtimeReflection.SKYBOX_FLAG){var r=e.SceneManager.GetAmbientSkybox(this.scene);null!=r&&(null==this.renderList&&(this.renderList=[]),this.renderList.push(r))}}else if(this.cullingMask===-1)for(n=0;n<this.scene.meshes.length;n++){var o=!1,s=this.scene.meshes[n];null!=s&&(o="Ambient Skybox"!==s.id||this.clearFlags===e.RealtimeReflection.SKYBOX_FLAG,o===!0&&(null==this.renderList&&(this.renderList=[]),this.renderList.push(s)))}else{var l=this.getProperty("renderlist");if(null!=l&&l.length>0){var u=function(){var t=l[n],a=e.SceneManager.GetMeshByID(c.scene,t);if(null!=a){null==c.renderList&&(c.renderList=[]);var i=a.name+".Detail",r=a.getChildren(function(e){return e.name===i},!0);null!=r&&r.length>0?c.renderList.push(r[0]):c.renderList.push(a)}},c=this;for(n=0;n<l.length;n++)u()}if(this.clearFlags===e.RealtimeReflection.SKYBOX_FLAG){var r=e.SceneManager.GetAmbientSkybox(this.scene);null!=r&&(null==this.renderList&&(this.renderList=[]),this.renderList.push(r))}}if(this.useProbeList===!0){var h=this.getProperty("probelist");if(null!=h&&h.length>0)for(n=0;n<h.length;n++){var m=h[n],p=e.SceneManager.GetMeshByID(this.scene,m);if(null!=p&&(null==this.probeList&&(this.probeList=[]),this.probeList.push(p),this.includeChildren===!0))for(var d=p.getChildMeshes(!1),g=0;g<d.length;g++){var f=d[g];this.probeList.push(f)}}}else{var y="PROBE_"+this.probeid.toFixed(0);this.probeList=this.scene.getMeshesByTags(y)}if(null!=this.probeList&&this.probeList.length>0){var _=this.getAbstractMesh();for(n=0;n<this.probeList.length;n++){var v=this.probeList[n],M=new e.ReflectionProbe(v.name+".Probe",this.resolution,this.scene);if(M.refreshRate=0===this.refreshMode?e.RenderTargetTexture.REFRESHRATE_RENDER_ONCE:e.RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME,(t=M.renderList).push.apply(t,this.renderList),null!=_&&M.attachToMesh(_),this.boxProjection===!0&&(null!=this.boxSize&&(M.cubeTexture.boundingBoxSize=this.boxSize),null!=this.boxPos&&(M.cubeTexture.boundingBoxPosition=this.boxPos)),v.material instanceof e.MultiMaterial){for(var S=v.material.clone(v.material.name+"."+v.name),b=0;b<S.subMaterials.length;b++){var T=(S.subMaterials[b],S.subMaterials[b].clone(S.subMaterials[b].name+"_"+v.name));T.unfreeze(),T.reflectionTexture=M.cubeTexture,S.subMaterials[b]=T}v.material=S}else{var C=v.material.clone(v.material.name+"."+v.name);C.unfreeze(),C.reflectionTexture=M.cubeTexture,v.material=C}}}}},n.prototype.destroyRealtimReflections=function(){this.probeList=null,this.renderList=null},n.SKYBOX_FLAG=1,n}(e.ScriptComponent);e.RealtimeReflection=t}(BABYLON||(BABYLON={}));var __extends=this&&this.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(t,n)};return function(t,n){function a(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(a.prototype=n.prototype,new a)}}(),BABYLON;!function(e){var t=function(t){function a(){var n=null!==t&&t.apply(this,arguments)||this;return n._abstractMesh=null,n._isKinematic=!1,n._maxCollisions=4,n._isPhysicsReady=!1,n._centerOfMass=new e.Vector3(0,0,0),n._tmpLinearFactor=new e.Vector3(0,0,0),n._tmpAngularFactor=new e.Vector3(0,0,0),n._tmpCenterOfMass=new e.Vector3(0,0,0),n._tmpGravityVector=null,n._tmpCollisionContacts=null,n.m_physicsWorld=null,n.m_physicsEngine=null,n.m_raycastVehicle=null,n.onCollisionEnterObservable=new e.Observable,n.onCollisionStayObservable=new e.Observable,n.onCollisionExitObservable=new e.Observable,n}return __extends(a,t),Object.defineProperty(a.prototype,"isKinematic",{get:function(){return this._isKinematic},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"centerOfMass",{get:function(){return this._centerOfMass},enumerable:!1,configurable:!0}),a.prototype.awake=function(){this.awakeRigidbodyState()},a.prototype.update=function(){this.updateRigidbodyState()},a.prototype.after=function(){this.afterRigidbodyState()},a.prototype.destroy=function(){this.destroyRigidbodyState()},a.prototype.awakeRigidbodyState=function(){this._abstractMesh=this.getAbstractMesh(),this._isKinematic=this.getProperty("isKinematic",this._isKinematic),this.m_physicsWorld=e.SceneManager.GetPhysicsWorld(this.scene),this.m_physicsEngine=e.SceneManager.GetPhysicsEngine(this.scene),null!=this.transform.metadata&&null!=this.transform.metadata.unity&&null!=this.transform.metadata.unity.physics&&(this._centerOfMass=null!=this.transform.metadata.unity.physics.center?e.Utilities.ParseVector3(this.transform.metadata.unity.physics.center,this._centerOfMass):this._centerOfMass),this.setMaxNotifications(this._maxCollisions),e.Utilities.ValidateTransformQuaternion(this.transform),this._isPhysicsReady=null!=this.m_physicsEngine&&null!=this._tmpCollisionContacts&&null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody;var t=this._isKinematic===!0?e.CollisionFilters.StaticFilter:e.CollisionFilters.DefaultFilter,n=this._isKinematic===!0?e.CollisionFilters.AllFilter^e.CollisionFilters.StaticFilter:e.CollisionFilters.AllFilter;this.setCollisionFilterGroup(t),this.setCollisionFilterMask(n),this.resetBodyCollisionContacts()},a.prototype.updateRigidbodyState=function(){this.syncronizeVehicleController()},a.prototype.afterRigidbodyState=function(){this.parseBodyCollisionContacts(),this.resetBodyCollisionContacts()},a.prototype.destroyRigidbodyState=function(){this.m_physicsWorld=null,this.m_physicsEngine=null,null!=this.m_raycastVehicle&&(this.m_raycastVehicle.dispose&&this.m_raycastVehicle.dispose(),this.m_raycastVehicle=null),null!=this._tmpGravityVector&&(Ammo.destroy(this._tmpGravityVector),this._tmpGravityVector=null),this.onCollisionEnterObservable.clear(),this.onCollisionEnterObservable=null,this.onCollisionStayObservable.clear(),this.onCollisionStayObservable=null,this.onCollisionExitObservable.clear(),this.onCollisionExitObservable=null,this._tmpCollisionContacts=null,this._abstractMesh=null},a.prototype.syncronizeVehicleController=function(){null!=this.m_raycastVehicle&&this.m_raycastVehicle.updateWheelInformation&&this.m_raycastVehicle.updateWheelInformation()},a.prototype.parseBodyCollisionContacts=function(){if(this._isPhysicsReady===!0){var e=this.onCollisionEnterObservable.hasObservers(),t=this.onCollisionStayObservable.hasObservers(),n=this.onCollisionExitObservable.hasObservers();if(e||t||n){var a=0;for(a=0;a<this._tmpCollisionContacts.length;a++)this._tmpCollisionContacts[a].reset=!0;var i=0;if(null!=this._abstractMesh.physicsImpostor.tmpCollisionObjects){var r=this._abstractMesh.physicsImpostor.tmpCollisionObjects;for(var o in r){var s=-1,l=r[o];for(a=0;a<this._tmpCollisionContacts.length;a++){var u=this._tmpCollisionContacts[a];if(null!=u.mesh&&u.mesh===l){u.state=1,u.reset=!1,s=a;break}}if(s===-1)for(a=0;a<this._tmpCollisionContacts.length;a++){var c=this._tmpCollisionContacts[a];if(null==c.mesh){c.mesh=l,c.state=0,c.reset=!1;break}}if(i++,i>this._maxCollisions)break}}for(a=0;a<this._tmpCollisionContacts.length;a++){var h=this._tmpCollisionContacts[a];h.reset===!0?(n&&null!=h.mesh&&this.onCollisionExitObservable.notifyObservers(h.mesh),h.mesh=null,h.state=0,h.reset=!1):0===h.state?e&&null!=h.mesh&&this.onCollisionEnterObservable.notifyObservers(h.mesh):t&&null!=h.mesh&&this.onCollisionStayObservable.notifyObservers(h.mesh)}}}},a.prototype.resetBodyCollisionContacts=function(){if(this._isPhysicsReady===!0){var e=this.onCollisionEnterObservable.hasObservers(),t=this.onCollisionStayObservable.hasObservers(),n=this.onCollisionExitObservable.hasObservers();e||t||n?this._abstractMesh.physicsImpostor.tmpCollisionObjects={}:this._abstractMesh.physicsImpostor.tmpCollisionObjects=null}},a.prototype.setGravity=function(e){null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody&&this._abstractMesh.physicsImpostor.physicsBody.setGravity&&null!=e&&(null==this._tmpGravityVector&&(this._tmpGravityVector=new Ammo.btVector3(0,0,0)),this._tmpGravityVector.setValue(e.x,e.y,e.z),
- this._abstractMesh.physicsImpostor.physicsBody.setGravity(this._tmpGravityVector))},a.prototype.getGravity=function(){var t=new e.Vector3(0,0,0);return this.getGravityToRef(t),t},a.prototype.getGravityToRef=function(t){if(null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody&&this._abstractMesh.physicsImpostor.physicsBody.getGravity){var n=this._abstractMesh.physicsImpostor.physicsBody.getGravity();e.Utilities.ConvertAmmoVector3ToRef(n,t)}},a.prototype.getMass=function(){var e=0;return null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&(e=this._abstractMesh.physicsImpostor.mass),e},a.prototype.setMass=function(e){null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&this._abstractMesh.physicsImpostor.mass!==e&&(this._abstractMesh.physicsImpostor.mass=e)},a.prototype.getFriction=function(){var e=0;return null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&(e=this._abstractMesh.physicsImpostor.friction),e},a.prototype.setFriction=function(e){null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&this._abstractMesh.physicsImpostor.friction!==e&&(this._abstractMesh.physicsImpostor.friction=e)},a.prototype.getRestitution=function(){var e=0;return null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&(e=this._abstractMesh.physicsImpostor.restitution),e},a.prototype.setRestitution=function(e){null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&this._abstractMesh.physicsImpostor.restitution!==e&&(this._abstractMesh.physicsImpostor.restitution=e)},a.prototype.getLinearVelocity=function(){var e=null;return null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&(e=this._abstractMesh.physicsImpostor.getLinearVelocity()),e},a.prototype.setLinearVelocity=function(e){null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=e&&this._abstractMesh.physicsImpostor.setLinearVelocity(e)},a.prototype.getAngularVelocity=function(){var e=null;return null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&(e=this._abstractMesh.physicsImpostor.getAngularVelocity()),e},a.prototype.setAngularVelocity=function(e){null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=e&&this._abstractMesh.physicsImpostor.setAngularVelocity(e)},a.prototype.getWorldTransform=function(){var e=null;if(null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody){var t=Ammo.castObject(this._abstractMesh.physicsImpostor.physicsBody,Ammo.btCollisionObject);null!=t&&t.getWorldTransform&&(e=t.getWorldTransform())}return e},a.prototype.getTransformPositionToRef=function(t){var n=this.getWorldTransform();if(null!=n&&null!=t){var a=n.getOrigin();e.Utilities.ConvertAmmoVector3ToRef(a,t)}},a.prototype.getTransformRotationToRef=function(t){var n=this.getWorldTransform();if(null!=n&&null!=t){var a=n.getRotation();e.Utilities.ConvertAmmoQuaternionToRef(a,t)}},a.prototype.clearForces=function(){null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody&&this._abstractMesh.physicsImpostor.physicsBody.clearForces&&this._abstractMesh.physicsImpostor.physicsBody.clearForces()},a.prototype.applyTorque=function(t){null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody&&this._abstractMesh.physicsImpostor.physicsBody.applyTorque&&null!=t&&(null==e.RigidbodyPhysics.TempAmmoVector&&(e.RigidbodyPhysics.TempAmmoVector=new Ammo.btVector3(0,0,0)),e.RigidbodyPhysics.TempAmmoVector.setValue(t.x,t.y,t.z),this._abstractMesh.physicsImpostor.physicsBody.applyTorque(e.RigidbodyPhysics.TempAmmoVector))},a.prototype.applyLocalTorque=function(t){null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody&&this._abstractMesh.physicsImpostor.physicsBody.applyLocalTorque&&null!=t&&(null==e.RigidbodyPhysics.TempAmmoVector&&(e.RigidbodyPhysics.TempAmmoVector=new Ammo.btVector3(0,0,0)),e.RigidbodyPhysics.TempAmmoVector.setValue(t.x,t.y,t.z),this._abstractMesh.physicsImpostor.physicsBody.applyLocalTorque(e.RigidbodyPhysics.TempAmmoVector))},a.prototype.applyImpulse=function(t,n){null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody&&this._abstractMesh.physicsImpostor.physicsBody.applyImpulse&&null!=t&&(null==e.RigidbodyPhysics.TempAmmoVector&&(e.RigidbodyPhysics.TempAmmoVector=new Ammo.btVector3(0,0,0)),null==e.RigidbodyPhysics.TempAmmoVectorAux&&(e.RigidbodyPhysics.TempAmmoVectorAux=new Ammo.btVector3(0,0,0)),e.RigidbodyPhysics.TempAmmoVector.setValue(t.x,t.y,t.z),e.RigidbodyPhysics.TempAmmoVectorAux.setValue(n.x,n.y,n.z),this._abstractMesh.physicsImpostor.physicsBody.applyImpulse(e.RigidbodyPhysics.TempAmmoVector,e.RigidbodyPhysics.TempAmmoVectorAux))},a.prototype.applyCentralImpulse=function(t){null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody&&this._abstractMesh.physicsImpostor.physicsBody.applyCentralImpulse&&null!=t&&(null==e.RigidbodyPhysics.TempAmmoVector&&(e.RigidbodyPhysics.TempAmmoVector=new Ammo.btVector3(0,0,0)),e.RigidbodyPhysics.TempAmmoVector.setValue(t.x,t.y,t.z),this._abstractMesh.physicsImpostor.physicsBody.applyCentralImpulse(e.RigidbodyPhysics.TempAmmoVector))},a.prototype.applyTorqueImpulse=function(t){null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody&&this._abstractMesh.physicsImpostor.physicsBody.applyTorqueImpulse&&null!=t&&(null==e.RigidbodyPhysics.TempAmmoVector&&(e.RigidbodyPhysics.TempAmmoVector=new Ammo.btVector3(0,0,0)),e.RigidbodyPhysics.TempAmmoVector.setValue(t.x,t.y,t.z),this._abstractMesh.physicsImpostor.physicsBody.applyTorqueImpulse(e.RigidbodyPhysics.TempAmmoVector))},a.prototype.applyForce=function(t,n){null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody&&this._abstractMesh.physicsImpostor.physicsBody.applyForce&&null!=t&&(null==e.RigidbodyPhysics.TempAmmoVector&&(e.RigidbodyPhysics.TempAmmoVector=new Ammo.btVector3(0,0,0)),null==e.RigidbodyPhysics.TempAmmoVectorAux&&(e.RigidbodyPhysics.TempAmmoVectorAux=new Ammo.btVector3(0,0,0)),e.RigidbodyPhysics.TempAmmoVector.setValue(t.x,t.y,t.z),e.RigidbodyPhysics.TempAmmoVectorAux.setValue(n.x,n.y,n.z),this._abstractMesh.physicsImpostor.physicsBody.applyForce(e.RigidbodyPhysics.TempAmmoVector,e.RigidbodyPhysics.TempAmmoVectorAux))},a.prototype.applyCentralForce=function(t){null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody&&this._abstractMesh.physicsImpostor.physicsBody.applyCentralForce&&null!=t&&(null==e.RigidbodyPhysics.TempAmmoVector&&(e.RigidbodyPhysics.TempAmmoVector=new Ammo.btVector3(0,0,0)),e.RigidbodyPhysics.TempAmmoVector.setValue(t.x,t.y,t.z),this._abstractMesh.physicsImpostor.physicsBody.applyCentralForce(e.RigidbodyPhysics.TempAmmoVector))},a.prototype.applyCentralLocalForce=function(t){null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody&&this._abstractMesh.physicsImpostor.physicsBody.applyCentralLocalForce&&null!=t&&(null==e.RigidbodyPhysics.TempAmmoVector&&(e.RigidbodyPhysics.TempAmmoVector=new Ammo.btVector3(0,0,0)),e.RigidbodyPhysics.TempAmmoVector.setValue(t.x,t.y,t.z),this._abstractMesh.physicsImpostor.physicsBody.applyCentralLocalForce(e.RigidbodyPhysics.TempAmmoVector))},a.prototype.getCenterOfMassTransform=function(){if(null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody&&this._abstractMesh.physicsImpostor.physicsBody.getCenterOfMassTransform){var e=this._abstractMesh.physicsImpostor.physicsBody.getCenterOfMassTransform(),t=e.getOrigin();this._tmpCenterOfMass.set(t.x(),t.y(),t.z())}return this._tmpCenterOfMass},a.prototype.setCenterOfMassTransform=function(t){null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody&&this._abstractMesh.physicsImpostor.physicsBody.setCenterOfMassTransform&&null!=t&&(null==e.RigidbodyPhysics.TempAmmoVector&&(e.RigidbodyPhysics.TempAmmoVector=new Ammo.btVector3(0,0,0)),e.RigidbodyPhysics.TempAmmoVector.setValue(t.x,t.y,t.z),null==e.RigidbodyPhysics.TempCenterTransform&&(e.RigidbodyPhysics.TempCenterTransform=new Ammo.btTransform),e.RigidbodyPhysics.TempCenterTransform.setIdentity(),e.RigidbodyPhysics.TempCenterTransform.setOrigin(e.RigidbodyPhysics.TempAmmoVector),this._abstractMesh.physicsImpostor.physicsBody.setCenterOfMassTransform(e.RigidbodyPhysics.TempCenterTransform))},a.prototype.getLinearFactor=function(){if(null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody&&this._abstractMesh.physicsImpostor.physicsBody.getLinearFactor){var e=this._abstractMesh.physicsImpostor.physicsBody.getLinearFactor();this._tmpLinearFactor.set(e.x(),e.y(),e.z())}return this._tmpLinearFactor},a.prototype.setLinearFactor=function(t){null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody&&this._abstractMesh.physicsImpostor.physicsBody.setLinearFactor&&(null==e.RigidbodyPhysics.TempAmmoVector&&(e.RigidbodyPhysics.TempAmmoVector=new Ammo.btVector3(0,0,0)),e.RigidbodyPhysics.TempAmmoVector.setValue(t.x,t.y,t.z),this._abstractMesh.physicsImpostor.physicsBody.setLinearFactor(e.RigidbodyPhysics.TempAmmoVector))},a.prototype.getAngularFactor=function(){if(null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody&&this._abstractMesh.physicsImpostor.physicsBody.getAngularFactor){var e=this._abstractMesh.physicsImpostor.physicsBody.getAngularFactor();this._tmpAngularFactor.set(e.x(),e.y(),e.z())}return this._tmpAngularFactor},a.prototype.setAngularFactor=function(t){null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody&&this._abstractMesh.physicsImpostor.physicsBody.setAngularFactor&&(null==e.RigidbodyPhysics.TempAmmoVector&&(e.RigidbodyPhysics.TempAmmoVector=new Ammo.btVector3(0,0,0)),e.RigidbodyPhysics.TempAmmoVector.setValue(t.x,t.y,t.z),this._abstractMesh.physicsImpostor.physicsBody.setAngularFactor(e.RigidbodyPhysics.TempAmmoVector))},a.prototype.getAngularDamping=function(){var e=0;return null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody&&this._abstractMesh.physicsImpostor.physicsBody.getAngularDamping&&(e=this._abstractMesh.physicsImpostor.physicsBody.getAngularDamping()),e},a.prototype.getLinearDamping=function(){var e=0;return null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody&&this._abstractMesh.physicsImpostor.physicsBody.getLinearDamping&&(e=this._abstractMesh.physicsImpostor.physicsBody.getLinearDamping()),e},a.prototype.setDamping=function(e,t){null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody&&this._abstractMesh.physicsImpostor.physicsBody.setDamping&&this._abstractMesh.physicsImpostor.physicsBody.setDamping(e,t)},a.prototype.setSleepingThresholds=function(e,t){null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody&&this._abstractMesh.physicsImpostor.physicsBody.setSleepingThresholds&&this._abstractMesh.physicsImpostor.physicsBody.setSleepingThresholds(e,t)},a.prototype.hasWheelColliders=function(){return this._isPhysicsReady===!0&&null!=this._abstractMesh.metadata&&null!=this._abstractMesh.metadata.unity&&null!=this._abstractMesh.metadata.unity.wheels},a.prototype.setMaxNotifications=function(e){this._maxCollisions=e,this._tmpCollisionContacts=[];for(var t=0;t<this._maxCollisions;t++)this._tmpCollisionContacts.push(new n)},a.prototype.setActivationState=function(e){if(null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody){var t=Ammo.castObject(this._abstractMesh.physicsImpostor.physicsBody,Ammo.btCollisionObject);null!=t&&t.setActivationState&&t.setActivationState(e)}},a.prototype.getCollisionFilterGroup=function(){var e=-1;return null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody&&this._abstractMesh.physicsImpostor.physicsBody.getBroadphaseProxy&&(e=this._abstractMesh.physicsImpostor.physicsBody.getBroadphaseProxy().get_m_collisionFilterGroup()),e},a.prototype.setCollisionFilterGroup=function(e){null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody&&this._abstractMesh.physicsImpostor.physicsBody.getBroadphaseProxy&&this._abstractMesh.physicsImpostor.physicsBody.getBroadphaseProxy().set_m_collisionFilterGroup(e)},a.prototype.getCollisionFilterMask=function(){var e=-1;return null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody&&this._abstractMesh.physicsImpostor.physicsBody.getBroadphaseProxy&&(e=this._abstractMesh.physicsImpostor.physicsBody.getBroadphaseProxy().get_m_collisionFilterMask()),e},a.prototype.setCollisionFilterMask=function(e){null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody&&this._abstractMesh.physicsImpostor.physicsBody.getBroadphaseProxy&&this._abstractMesh.physicsImpostor.physicsBody.getBroadphaseProxy().set_m_collisionFilterMask(e)},a.prototype.getCollisionShapeType=function(){var e=-1;if(null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody){var t=Ammo.castObject(this._abstractMesh.physicsImpostor.physicsBody,Ammo.btCollisionObject);if(null!=t){var n=t.getCollisionShape();null!=n&&n.getShapeType&&(e=n.getShapeType())}}return e},a.prototype.getCollisionShapeMargin=function(){var e=-1;if(null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody){var t=Ammo.castObject(this._abstractMesh.physicsImpostor.physicsBody,Ammo.btCollisionObject);if(null!=t){var n=t.getCollisionShape();null!=n&&n.getMargin&&(e=n.getMargin())}}return e},a.prototype.setCollisionShapeMargin=function(e){if(null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody){var t=Ammo.castObject(this._abstractMesh.physicsImpostor.physicsBody,Ammo.btCollisionObject);if(null!=t){var n=t.getCollisionShape();null!=n&&n.setMargin&&n.setMargin(e)}}},a.prototype.setContactProcessingThreshold=function(e){if(null!=this._abstractMesh&&null!=this._abstractMesh.physicsImpostor&&null!=this._abstractMesh.physicsImpostor.physicsBody){var t=Ammo.castObject(this._abstractMesh.physicsImpostor.physicsBody,Ammo.btCollisionObject);null!=t&&t.setContactProcessingThreshold&&t.setContactProcessingThreshold(e)}},a.CreatePhysicsMetadata=function(t,n,a,i){void 0===n&&(n=0),void 0===a&&(a=.05),void 0===i&&(i=null);var r=null!=i?i:new e.Vector3(0,0,0);return{type:"rigidbody",mass:t,ldrag:n,adrag:a,center:{x:r.x,y:r.y,z:r.z}}},a.CreateCollisionMetadata=function(e,t,n,a,i,r){return void 0===t&&(t=!1),void 0===n&&(n=!1),void 0===a&&(a=0),void 0===i&&(i=.6),void 0===r&&(r=.6),{type:e,trigger:t,convexmesh:n,restitution:a,dynamicfriction:i,staticfriction:r,wheelinformation:null}},a.CreatePhysicsProperties=function(e,t,n,a,i){return void 0===t&&(t=0),void 0===n&&(n=.05),void 0===a&&(a=!0),void 0===i&&(i=!1),{mass:e,drag:t,angularDrag:n,useGravity:a,isKinematic:i}},a.SetupPhysicsComponent=function(t,n){var a=null!=n.metadata&&null!=n.metadata.unity?n.metadata.unity:null;if(null!=a&&(null!=a.physics||null!=a.collision)){var i=null!=a.physics,r=null!=a.physics&&null!=a.physics.root&&a.physics.root,o=null!=a.physics&&null!=a.physics.mass?a.physics.mass:0,s=0===o,l=null!=a.collision,u=null!=a.collision&&null!=a.collision.type?a.collision.type:"BoxCollider",c=null!=a.collision&&null!=a.collision.convexmesh&&a.collision.convexmesh,h=null!=a.collision&&null!=a.collision.dynamicfriction?a.collision.dynamicfriction:.6,m=null!=a.collision&&null!=a.collision.staticfriction?a.collision.staticfriction:.6,p=null!=a.collision&&null!=a.collision.restitution?a.collision.restitution:0,d=null!=a.collision&&null!=a.collision.trigger&&a.collision.trigger,g=e.PhysicsImpostor.BoxImpostor;if(g="MeshCollider"===u?c===!0?e.PhysicsImpostor.ConvexHullImpostor:e.PhysicsImpostor.MeshImpostor:"CapsuleCollider"===u?e.PhysicsImpostor.CapsuleImpostor:"SphereCollider"===u?e.PhysicsImpostor.SphereImpostor:e.PhysicsImpostor.BoxImpostor,i===!0)if(r){var f=null,y=0,_=0,v=0,M=!1,S=0,b=null!=a.physics&&null!=a.physics.center?e.Utilities.ParseVector3(a.physics.center,e.Vector3.Zero()):e.Vector3.Zero(),T=n.getChildren(null,!0);null!=T&&T.length>0&&T.forEach(function(e){e.position.subtractInPlace(b)});var C=n.getChildren(null,!1);null!=C&&C.length>0&&C.forEach(function(n){if(null!=n.metadata&&null!=n.metadata.unity&&null!=n.metadata.unity.collision){var i=n.metadata.unity.collision,r=null!=i.wheelinformation?i.wheelinformation:null;if(null!=r)null==f&&(f=[]),f.push(r);else{var o=null!=i.dynamicfriction?i.dynamicfriction:.6,s=null!=i.staticfriction?i.staticfriction:.6,l=null!=i.restitution?i.restitution:0,u=null!=i.trigger&&i.trigger,c=null!=i.type?i.type:"BoxCollider",h=e.PhysicsImpostor.BoxImpostor;h="MeshCollider"===c?e.PhysicsImpostor.ConvexHullImpostor:"CapsuleCollider"===c?e.PhysicsImpostor.CapsuleImpostor:"SphereCollider"===c?e.PhysicsImpostor.SphereImpostor:e.PhysicsImpostor.BoxImpostor,o>y&&(y=o),s>_&&(_=s),l>v&&(v=l),1==u&&(M=!0),e.SceneManager.CreatePhysicsImpostor(t,n,h,{mass:0,friction:0,restitution:0}),e.RigidbodyPhysics.ConfigRigidbodyPhysics(t,n,!0,!1,a.physics),S++}}}),S>0&&(e.SceneManager.CreatePhysicsImpostor(t,n,e.PhysicsImpostor.NoImpostor,{mass:o,friction:y,restitution:v}),e.RigidbodyPhysics.ConfigRigidbodyPhysics(t,n,!1,M,a.physics)),null!=f&&f.length>0&&(null==n.metadata&&(n.metadata={}),null==n.metadata.unity&&(n.metadata.unity={}),n.metadata.unity.wheels=f),C=null}else l===!0&&(e.SceneManager.CreatePhysicsImpostor(t,n,g,{mass:o,friction:s?m:h,restitution:p}),e.RigidbodyPhysics.ConfigRigidbodyPhysics(t,n,!1,d,a.physics))}},a.ConfigRigidbodyPhysics=function(t,n,a,i,r){null!=n&&(null!=n.physicsImpostor?n.physicsImpostor.executeNativeFunction(function(a,o){o.activate&&o.activate();var s=Ammo.castObject(o,Ammo.btCollisionObject);s.entity=n;var l=e.SceneManager.GetPhysicsWorld(t);if(null!=l&&l.generateInternalEdgeInfo){var u=s.getCollisionShape();if(null!=u&&u.getShapeType){var c=u.getShapeType();if(21===c){var h=Ammo.castObject(u,Ammo.btBvhTriangleMeshShape);s.triangleMapInfo=new Ammo.btTriangleInfoMap,l.generateInternalEdgeInfo(h,s.triangleMapInfo)}}}var m=null==r||null==r.gravity||r.gravity;if(m===!1&&(o.setGravity?o.setGravity(new Ammo.btVector3(0,0,0)):e.Tools.Warn("Physics engine set gravity override not supported for: "+n.name)),o.setDamping){var p=null!=r&&null!=r.ldrag?r.ldrag:0,d=null!=r&&null!=r.adrag?r.adrag:.05;o.setDamping(p,d)}else e.Tools.Warn("Physics engine set drag damping not supported for: "+n.name);o.setCollisionFlags&&o.getCollisionFlags?i===!0?o.setCollisionFlags(o.getCollisionFlags()|e.CollisionFlags.CF_NO_CONTACT_RESPONSE|e.CollisionFlags.CF_CUSTOM_MATERIAL_CALLBACK):o.setCollisionFlags(o.getCollisionFlags()|e.CollisionFlags.CF_CUSTOM_MATERIAL_CALLBACK):e.Tools.Warn("Physics engine set collision flags not supported for: "+n.name);var g=null!=r&&null!=r.freeze?r.freeze:null;if(null!=g){if(o.setLinearFactor){var f=null!=g.positionx&&g.positionx===!0?0:1,y=null!=g.positiony&&g.positiony===!0?0:1,_=null!=g.positionz&&g.positionz===!0?0:1;o.setLinearFactor(new Ammo.btVector3(f,y,_))}else e.Tools.Warn("Physics engine set linear factor not supported for: "+n.name);if(o.setAngularFactor){var v=null!=g.rotationx&&g.rotationx===!0?0:1,M=null!=g.rotationy&&g.rotationy===!0?0:1,S=null!=g.rotationz&&g.rotationz===!0?0:1;o.setAngularFactor(new Ammo.btVector3(v,M,S))}else e.Tools.Warn("Physics engine set angular factor not supported for: "+n.name)}}):e.Tools.Warn("No valid physics impostor to setup for "+n.name))},a.TempAmmoVector=null,a.TempAmmoVectorAux=null,a.TempCenterTransform=null,a}(e.ScriptComponent);e.RigidbodyPhysics=t;var n=function(){function e(){this.mesh=null,this.state=0,this.reset=!1}return e}();e.CollisionContactInfo=n}(BABYLON||(BABYLON={}));var __extends=this&&this.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(t,n)};return function(t,n){function a(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(a.prototype=n.prototype,new a)}}(),BABYLON;!function(e){var t=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.awake=function(){},t.prototype.start=function(){},t.prototype.update=function(){},t.prototype.late=function(){},t.prototype.after=function(){},t.prototype.destroy=function(){},t}(e.ScriptComponent);e.ShurikenParticles=t}(BABYLON||(BABYLON={}));var __extends=this&&this.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(t,n)};return function(t,n){function a(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(a.prototype=n.prototype,new a)}}(),BABYLON;!function(e){var t=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.m_abstractMesh=null,e.m_videoTexture=null,e.m_videoMaterial=null,e.m_diffuseIntensity=1,e}return __extends(n,t),n.prototype.getVideoMaterial=function(){return this.m_videoMaterial},n.prototype.getVideoTexture=function(){return this.m_videoTexture},n.prototype.getVideoElement=function(){return null!=this.m_videoTexture?this.m_videoTexture.video:null},n.prototype.getVideoScreen=function(){return this.m_abstractMesh},n.prototype.awake=function(){this.awakeWebVideoPlayer()},n.prototype.destroy=function(){this.destroyWebVideoPlayer()},n.prototype.awakeWebVideoPlayer=function(){if(this.m_abstractMesh=this.getAbstractMesh(),null!=this.m_abstractMesh){this.m_diffuseIntensity=this.getProperty("intensity",1),this.m_videoMaterial=new e.StandardMaterial(this.transform.name+".VideoMat",this.scene),this.m_videoMaterial.roughness=1,this.m_videoMaterial.emissiveColor=new e.Color3(1,1,1),this.m_abstractMesh.material=this.m_videoMaterial;var t=this.getProperty("url",null),n=this.getProperty("source",null),a=t;if(null!=n&&null!=n.filename&&""!==n.filename){var i=e.SceneManager.GetRootUrl(this.scene);a=i+n.filename}if(null!=a&&""!==a){var r=this.getProperty("muted",!1),o=this.getProperty("poster",null),s=this.getProperty("inverty",!0),l=this.getProperty("sampling",3),u=this.getProperty("mipmaps",!1),c=this.getProperty("looping",!1),h=this.getProperty("playonawake",!0),m=this.getProperty("volume",1),p=this.getProperty("playbackspeed",1),d={autoUpdateTexture:!0,autoPlay:h,loop:c,muted:r,poster:o};this.setVideoSource(a,u,s,l,d,m,p)}}else e.Tools.Warn("No video mesh available for: "+this.transform.name)},n.prototype.destroyWebVideoPlayer=function(){this.m_abstractMesh=null,null!=this.m_videoTexture&&(this.m_videoTexture.dispose(),this.m_videoTexture=null),null!=this.m_videoMaterial&&(this.m_videoMaterial.dispose(),this.m_videoMaterial=null)},n.prototype.setVideoSource=function(t,n,a,i,r,o,s){void 0===n&&(n=!1),void 0===a&&(a=!0),void 0===i&&(i=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===o&&(o=1),void 0===s&&(s=1),null!=this.m_abstractMesh&&null!=this.m_videoMaterial?(this.m_videoMaterial.diffuseTexture=null,null!=this.m_videoTexture&&(this.m_videoTexture.dispose(),this.m_videoTexture=null),this.m_videoTexture=new e.VideoTexture(this.transform.name+".VideoTex",t,this.scene,n,a,i,r),null!=this.m_videoTexture&&null!=this.m_videoTexture.video&&(this.m_videoTexture.video.volume=o,this.m_videoTexture.video.playbackRate=s),null!=this.m_videoTexture&&(this.m_videoTexture.level=this.m_diffuseIntensity),this.m_videoMaterial.diffuseTexture=this.m_videoTexture):e.Tools.Warn("No video mesh or material available for: "+this.transform.name)},n}(e.ScriptComponent);e.WebVideoPlayer=t}(BABYLON||(BABYLON={}));
|