var BABYLON;!function(e){var t=function(){function t(){}return Object.defineProperty(t,"Version",{get:function(){return"5.0.0 - A31"},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;n0?(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.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.CreateFloatAnimation(n,i,r,o,l,u);null!=c&&m.setEasingFunction(c);var p=e.Utilities.GetLastKeyFrameIndex(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);a0)for(var a=(e.materials.length,0);a0&&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;i0)for(var i=0;i0&&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.SceneManager.LogMessage("Ammo.js plugin (btAxisSweep3 - "+g+" MB)")}else d=new e.AmmoJSPlugin(n),e.SceneManager.LogMessage("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.SceneManager.LogWarning("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.SceneManager.LogWarning("Ammo.js plugin enabled");if(p===!0&&null!=h&&null!=m&&null!=m.world){if(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.SceneManager.LogMessage("Ammo.js internal edges adjusted")):e.SceneManager.LogWarning("Ammo.js failed to load addFunction. Internal edge contact support disabled.")}else e.SceneManager.LogWarning("Ammo.js is missing addFunction. Internal edge contact support disabled.");var v=t;v._monitorContactManifolds||(v._monitorContactManifolds=!0,r===!0&&(e.SceneManager.LogMessage("Ammo.js contact manifolds enabled"),t.registerBeforeRender(function(){var e=m.world.getDispatcher().getNumManifolds();if(e>0)for(var t=0;t0){for(var l=0,u=[{frame:0,value:n.position}],c=0;c0&&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.SceneManager.LogMessage("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.SceneManager.LogMessage("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.SceneManager.LogMessage("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.SceneManager.LogMessage("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.None=0]="None",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=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(a360&&(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)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();ni[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();ni[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();ni[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();ni[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();ni[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.CreateFloatAnimation=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.GetLastKeyFrameIndex=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;s0&&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;r0)for(var i=0;i0)for(var y=0;y0)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;m0&&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=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);r0&&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);o0&&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=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;i0)for(var i=0;i0)for(var i=0;i0)for(var i=0;i0&&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;l0&&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.SceneManager.LogWarning("Failed To Locate Shader Chunk Base: "+n)}},n.prototype._buildCustomShader=function(e,t,n,a,i,r,o){var s=this;this._defines=i;var l=this.locals.getDefines();if(null!=l&&null!=this._defines){var u=Object.keys(l);if(null!=u&&u.length>0){for(var c=this._defines,h=0,m=u;h0)for(d=0;d0)for(d=0;d0)for(d=0;d0)for(d=0;d<_.length;d++){var v=_[d];r.indexOf(v)===-1&&r.push(v)}if(null!=this._createdShaderName&&""!==this._createdShaderName)return this._createdShaderName;var M=this.getShaderName();null!=M&&""!==M||(M=e),null!=M&&""!==M||(M="pbr");var S=this._afterBind.bind(this);return this._afterBind=function(e,t){if(t){s._attachAfterBind(e,t);try{S(e,t)}catch(t){}}},this._createdShaderName=this.enableShaderChunks===!0?this._createShaderChunks(M):M,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/g,e.Effect.IncludesShadersStore.pbrBlockAlbedoOpacity),r=r.replace(/#include/g,e.Effect.IncludesShadersStore.pbrBlockReflectivity),r=r.replace(/#include/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;l0)for(var t=0;t0&&(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&&null!=e.transform){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){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=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.ordert.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.SceneManager.LogWarning("Non script component instantiated class: "+n.comp.klass)}else e.SceneManager.LogWarning("Failed to instantiate script class: "+n.comp.klass)}else e.SceneManager.LogWarning("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.SceneManager.LogWarning("Ammo.js rigidbody physics system not loaded. Physics impostors will not be created for: "+n.name)}):e.SceneManager.LogWarning("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=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=F,ne.blurKernel=V,ne.blurScale=N,ne.blurBoxOffset=U,ne.frustumEdgeFalloff=Z,ne.forceBackFacesOnly=J,ne.setTransparencyShadow(K),ne.enableSoftTransparentShadow=q,ne.contactHardeningLightSizeUVRatio=O,b===!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=C,ae.depthClamp=A,ae.shadowMaxZ=j,ae.numCascades=T,ae.penumbraDarkness=R,ae.autoCalcDepthBounds=L,ae.stabilizeCascades=B,ae.cascadeBlendPercentage=P,ae.autoCalcDepthBoundsRefreshRate=x,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=S}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;oe0&&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.SceneManager.LogWarning("Non material instantiated class: "+l)}else BABYLON.SceneManager.LogWarning("Failed to instantiate material class: "+l)}else BABYLON.SceneManager.LogWarning("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;o0&&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;s0&&i.addLODLevel(o,null),a===!0&&i.setEnabled(!0)}else BABYLON.SceneManager.LogWarning("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.showdebug&&n.navigation.showdebug===!0,x=null!=n.navigation.debugcolor?n.navigation.debugcolor:[.05,.225,.75],O=new BABYLON.Color3(x[0],x[1],x[2]),w=null!=n.navigation.timesteps?n.navigation.timesteps:0,B=new XMLHttpRequest;B.open("GET",n.navigation.prebaked,!0),B.responseType="arraybuffer",B.addEventListener("readystatechange",function(){if(200===B.status&&B.response){var e=new Uint8Array(B.response);BABYLON.SceneManager.LoadNavigationMesh(t,e,P,O,w)}},!1),B.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.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.SceneManager.LogWarning("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=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.indext.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;n0&&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;B0&&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;u0)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=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&&a0?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;s0&&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.weightt.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;ne)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=.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;athis._maxCollisions&&(i=this._maxCollisions),i>0)for(a=0;a0?this.m_moveDeltaX=this._minMoveDistance:e.x<0&&(this.m_moveDeltaX=-this._minMoveDistance)),Math.abs(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.distanceEpsilon=.1,n.velocityEpsilon=1,n.stoppingDistance=0,n.m_agentState=0,n.m_agentIndex=-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.onPreUpdateObservable=new e.Observable,n.onPostUpdateObservable=new e.Observable,n.onNavCompleteObservable=new e.Observable,n}return __extends(n,t),n.prototype.isNavigating=function(){return null!=this.m_agentDestination},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.getAgentRadius=function(){return this.avoidRadius},n.prototype.getAgentHeight=function(){return this.avoidHeight},n.prototype.getAgentSpeed=function(){return this.speed},n.prototype.getAgentOffset=function(){return this.baseOffset},n.prototype.getTargetDistance=function(){return this.distanceToTarget},n.prototype.awake=function(){this.awakeNavigationAgent()},n.prototype.update=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&&(this.m_agentParams={radius:this.avoidRadius,height:this.avoidHeight,maxSpeed:this.speed,maxAcceleration:this.acceleration,collisionQueryRange:.5,pathOptimizationRange:0,separationWeight:1},e.Utilities.GetAbsolutePositionToRef(this.transform,this.resetPosition),this.m_agentIndex=t.addAgent(this.resetPosition,this.m_agentParams,this.m_agentGhost)),this.m_agentState=t.getAgentState(this.m_agentIndex),this.getAgentWaypointToRef(this.currentWaypoint),this.getAgentPositionToRef(this.currentPosition),this.m_agentState===e.CrowdAgentState.DT_CROWDAGENT_STATE_OFFMESH?(this.currentPosition.subtractToRef(this.lastPosition,this.currentVelocity),this.currentVelocity.scaleInPlace(1.5*this.speed)):this.getAgentVelocityToRef(this.currentVelocity),null!=this.m_agentDestination){if(this.distanceToTarget=e.Vector3.Distance(this.currentPosition,this.m_agentDestination),this.updatePosition===!0||this.angularSpeed>0){if(this.onPreUpdateObservable.hasObservers()===!0&&this.onPreUpdateObservable.notifyObservers(this.transform),this.angularSpeed>0&&this.currentVelocity.length()>=this.velocityEpsilon){this.currentVelocity.normalize();var n=this.angularSpeed*e.NavigationAgent.ANGULAR_SPEED_RATIO*this.getDeltaSeconds();if(this.m_agentState===e.CrowdAgentState.DT_CROWDAGENT_STATE_OFFMESH){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.z,this.m_agentDirection.x);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.cancelNavigation(),this.onNavCompleteObservable.hasObservers()===!0&&this.onNavCompleteObservable.notifyObservers(this.transform))}else this.distanceToTarget=0;this.lastPosition.copyFrom(this.transform.position)}},n.prototype.destroyNavigationAgent=function(){this.m_agentIndex=-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.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,a){void 0===n&&(n=!0),void 0===a&&(a=!0);var i=e.SceneManager.GetNavigationTools(),r=e.SceneManager.GetCrowdInterface(this.scene);null!=i&&null!=r?(a===!0&&this.resetAgentPosition(),n===!0?this.m_agentDestination=i.getClosestPoint(t):this.m_agentDestination=t.clone(),this.m_agentIndex>=0&&r.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,e.Utilities.GetAbsolutePositionToRef(this.transform,this.resetPosition);var t=e.SceneManager.GetCrowdInterface(this.scene);null!=t&&this.m_agentIndex>=0&&t.agentTeleport(this.m_agentIndex,this.resetPosition)},n.prototype.cancelNavigation=function(){this.resetAgentPosition()},n.TARGET_ANGLE_FACTOR=.5*Math.PI,n.ANGULAR_SPEED_RATIO=.1,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),null==Ammo.btSmoothVehicleRaycaster&&e.Tools.Warn("Using Default Vehicle Raycaster For:"+t.name)}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;n0)for(var n=0;n0&&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=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;n0)for(var n=0;n0)for(var n=0;n0)for(var t=0;t=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;n0){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;n0)for(n=0;n0){var _=this.getAbstractMesh();for(n=0;nthis._maxCollisions)break}}for(a=0;a0&&_.forEach(function(e){if(null!=e.metadata&&null!=e.metadata.unity&&null!=e.metadata.unity.collision){var t=e.metadata.unity.collision,n=null!=t.wheelinformation?t.wheelinformation:null;null!=n?(null==y&&(y=[]),y.push(n)):(null==f&&(f=[]),f.push(e))}}),null!=y&&y.length>0&&(null==n.metadata&&(n.metadata={}),null==n.metadata.unity&&(n.metadata.unity={}),n.metadata.unity.wheels=y),null!=f&&f.length>0&&(l===!0&&f.unshift(n),n._compoundNodes=f,e.SceneManager.CreatePhysicsImpostor(t,n,e.PhysicsImpostor.NoImpostor,{mass:o,friction:h,restitution:p}),e.RigidbodyPhysics.ConfigRigidbodyPhysics(t,n,!1,d,a.physics)),_=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 BABYLON;!function(e){var t=function(){function t(){}return t.RegisterOnSocketConnect=function(t){e.SceneManager.SetWindowState("onSocketConnect",t)},t.RegisterOnSocketDisconnect=function(t){e.SceneManager.SetWindowState("onSocketDisconnect",t)},t.ConnectWindowSocket=function(e){var t=null;return window.top.socketConnect&&(t=window.top.socketConnect(e)),t},t.GetWindowSocket=function(){return e.SceneManager.GetWindowState("socket")},t}();e.SocketController=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={}));